00001 #include "PulseCandidateFinder_InvestigateParameters.h"
00002 #include "RegisterModule.inc"
00003 #include "TGlobalData.h"
00004 #include "TSetupData.h"
00005 #include "ModulesOptions.h"
00006 #include "definitions.h"
00007
00008 #include <iostream>
00009 #include <cmath>
00010 #include <sstream>
00011 using std::cout;
00012 using std::endl;
00013
00014 #include "ExportPulse.h"
00015
00016 PulseCandidateFinder_InvestigateParameters::PulseCandidateFinder_InvestigateParameters(modules::options* opts):
00017 BaseModule("PulseCandidateFinder_InvestigateParameters",opts), fOpts(opts){
00018
00019 }
00020
00021 PulseCandidateFinder_InvestigateParameters::~PulseCandidateFinder_InvestigateParameters(){
00022 }
00023
00024
00025
00026
00027 int PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(TGlobalData* gData, const TSetupData* setup){
00028
00029 if(Debug()){
00030 cout<<"-----PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(): I'm debugging!"<<endl;
00031 }
00032
00033 return 0;
00034 }
00035
00036
00037
00038 int PulseCandidateFinder_InvestigateParameters::ProcessEntry(TGlobalData* gData, const TSetupData* setup){
00039
00040
00041 std::string bankname, detname;
00042 PulseIslandList thePulseIslands;
00043 StringPulseIslandMap::const_iterator it;
00044
00045
00046 for(it = gData->fPulseIslandToChannelMap.begin(); it != gData->fPulseIslandToChannelMap.end(); ++it){
00047
00048
00049 bankname = it->first;
00050 detname = setup->GetDetectorName(bankname);
00051
00052
00053 PulseCandidateFinder* pulse_candidate_finder = new PulseCandidateFinder(detname, fOpts);
00054
00055
00056 thePulseIslands = it->second;
00057 if (thePulseIslands.size() == 0) continue;
00058
00059
00060 if (fParameterHistograms.find(detname) == fParameterHistograms.end()) {
00061
00062 int n_bits = TSetupData::Instance()->GetNBits(bankname);
00063 int max_adc_value = std::pow(2, n_bits);
00064 int min_value = 0;
00065 int max_value = max_adc_value;
00066 int bin_width = 10;
00067 int num_bins = (max_value - min_value) / bin_width;
00068 std::string histname = "fParameterHistogram_" + detname;
00069 TH2D* histogram = new TH2D(histname.c_str(), histname.c_str(), num_bins,min_value,max_value, num_bins,min_value,max_value);
00070 fParameterHistograms[detname] = histogram;
00071 }
00072
00073
00074 TH2D* parameter_histogram = fParameterHistograms[detname];
00075
00076
00077 for (PulseIslandList::iterator pulseIter = thePulseIslands.begin(); pulseIter != thePulseIslands.end(); ++pulseIter) {
00078
00079
00080 pulse_candidate_finder->FindPulseCandidates(*pulseIter);
00081 pulse_candidate_finder->FillParameterHistogram(parameter_histogram);
00082
00083
00084 int n_pulse_candidates = pulse_candidate_finder->GetNPulseCandidates();
00085 if (Debug()) {
00086 if (n_pulse_candidates > 0) {
00087
00088 if (n_pulse_candidates > 1) {
00089 std::cout << detname << "(" << bankname << "): Pulse #" << pulseIter - thePulseIslands.begin() << " has " << n_pulse_candidates << " pulse candidates\n";
00090 }
00091 }
00092 }
00093 }
00094 }
00095
00096 return 0;
00097 }
00098
00099
00100
00101
00102 int PulseCandidateFinder_InvestigateParameters::AfterLastEntry(TGlobalData* gData, const TSetupData* setup){
00103
00104
00105 if(Debug()){
00106 cout<<"-----PulseCandidateFinder_InvestigateParameters::AfterLastEntry(): I'm debugging!"<<endl;
00107 }
00108 return 0;
00109 }
00110
00111
00112
00113
00114
00115 ALCAP_REGISTER_MODULE(PulseCandidateFinder_InvestigateParameters);