00001 //#define USE_PRINT_OUT 00002 00003 #include "PlotTAP_Amplitude.h" 00004 #include <iostream> 00005 #include <string> 00006 #include <sstream> 00007 #include <map> 00008 //#include <utility> 00009 //#include <algorithm> 00010 #include <cmath> 00011 00012 #include "TAnalysedPulse.h" 00013 //#include "TDetectorPulse.h" 00014 #include "RegisterModule.inc" 00015 #include "definitions.h" 00016 #include "SetupNavigator.h" 00017 //#include "debug_tools.h" 00018 00019 using std::string; 00020 using std::map; 00021 using std::vector; 00022 using std::pair; 00023 00024 extern SourceAnalPulseMap gAnalysedPulseMap; 00025 00026 PlotTAP_Amplitude::PlotTAP_Amplitude(modules::options* opts) : 00027 BaseModule("PlotTAP_Amplitude",opts) { 00028 } 00029 00030 PlotTAP_Amplitude::~PlotTAP_Amplitude(){ 00031 } 00032 00033 int PlotTAP_Amplitude::BeforeFirstEntry(TGlobalData *gData, const TSetupData *gSetup){ 00034 return 0; 00035 } 00036 00037 int PlotTAP_Amplitude::ProcessEntry(TGlobalData *gData, const TSetupData* gSetup){ 00038 00039 // Loop over each TAP list 00040 for (SourceAnalPulseMap::const_iterator i_det = gAnalysedPulseMap.begin(); 00041 i_det != gAnalysedPulseMap.end(); 00042 i_det++) { 00043 00044 const std::string& detname = i_det->first.str(); 00045 std::string keyname = i_det->first.str() + GetName(); 00046 00047 // Create the histogram if it's not been created yet 00048 if ( fAmplitudePlots.find(keyname) == fAmplitudePlots.end() ) { 00049 00050 // hAmplitude 00051 std::string histname = "h" + detname + "_Amplitude"; 00052 std::stringstream histtitle; 00053 histtitle<<"Amplitude of pulses from source " << i_det->first; 00054 histtitle<<" for run "<<SetupNavigator::Instance()->GetRunNumber(); 00055 int n_bits = gSetup->GetNBits(gSetup->GetBankName(i_det->first.Channel().str())); 00056 double max_adc_value = std::pow(2, n_bits); 00057 TH1F* hAmplitude = new TH1F(histname.c_str(), histtitle.str().c_str(), max_adc_value,0,max_adc_value); 00058 hAmplitude->GetXaxis()->SetTitle("Amplitude (ADC value)"); 00059 hAmplitude->GetYaxis()->SetTitle("Arbitrary Units"); 00060 fAmplitudePlots[keyname] = hAmplitude; 00061 } 00062 00063 const AnalysedPulseList *pulses = &i_det->second; 00064 //if(Debug() && pulses->empty()) DEBUG_PREFIX<<" no pulses to fill for "<<i_det->first<<std::endl; 00065 00066 for (AnalysedPulseList::const_iterator pulseIter = pulses->begin(); pulseIter != pulses->end(); ++pulseIter) { 00067 double amplitude = (*pulseIter)->GetAmplitude(); 00068 fAmplitudePlots[keyname]->Fill(amplitude); 00069 00070 } // end loop through pulses 00071 00072 } // end loop through detectors 00073 return 0; 00074 } 00075 00076 ALCAP_REGISTER_MODULE(PlotTAP_Amplitude)