00001 #include "PlotTAP_Integral.h" 00002 #include "RegisterModule.inc" 00003 #include "TGlobalData.h" 00004 #include "TSetupData.h" 00005 #include "ModulesOptions.h" 00006 #include "ModulesParser.h" 00007 #include "definitions.h" 00008 #include "TAnalysedPulse.h" 00009 #include "IdSource.h" 00010 00011 #include <TH1F.h> 00012 00013 #include <iostream> 00014 using std::cout; 00015 using std::endl; 00016 00017 extern SourceAnalPulseMap gAnalysedPulseMap; 00018 00019 PlotTAP_Integral::PlotTAP_Integral(modules::options* opts): 00020 BaseModule("PlotTAP_Integral",opts){ 00021 } 00022 00023 PlotTAP_Integral::~PlotTAP_Integral(){ 00024 } 00025 00026 int PlotTAP_Integral::BeforeFirstEntry(TGlobalData* gData,const TSetupData *setup){ 00027 // For each source, 00028 TH1F* hist=NULL; 00029 std::string name, title; 00030 const IDs::source* source=NULL; 00031 for(SourceAnalPulseMap::const_iterator i_source = gAnalysedPulseMap.begin(); 00032 i_source!=gAnalysedPulseMap.end(); ++i_source){ 00033 source=&i_source->first; 00034 00035 // setup the name and title for the histogram 00036 name="h"+modules::parser::ToCppValid(source->str())+"_integrals"; 00037 title="Integral of pulses coming from "+source->str(); 00038 00039 // make a histogram 00040 int x_min = -100000; 00041 int x_max = 5000000; 00042 int bin_width = 100; 00043 int n_bins = (x_max - x_min) / bin_width; 00044 hist=new TH1F(name.c_str(),title.c_str(),n_bins,x_min,x_max); 00045 hist->SetXTitle("Integral of each pulse (arb. units)"); 00046 00047 // register histogram with list 00048 fPlots[*source]=hist; 00049 } 00050 return 0; 00051 } 00052 00053 int PlotTAP_Integral::ProcessEntry(TGlobalData* gData,const TSetupData *setup){ 00054 00055 PlotList_t::iterator i_plot; 00056 const AnalysedPulseList* pulseList; 00057 const IDs::source* source; 00058 for(SourceAnalPulseMap::const_iterator i_source = gAnalysedPulseMap.begin(); 00059 i_source!=gAnalysedPulseMap.end(); ++i_source){ 00060 source=&i_source->first; 00061 pulseList=&i_source->second; 00062 00063 // Find the corresponding histogram 00064 i_plot=fPlots.find(*source); 00065 if(i_plot==fPlots.end()){ 00066 cout<<"PlotTAP_Integral: Error: Unable to find plot for source '"<<*source<<"'"<<endl; 00067 return 1; 00068 } 00069 00070 // For each TAP 00071 for(AnalysedPulseList::const_iterator i_pulse=pulseList->begin(); 00072 i_pulse!=pulseList->end();++i_pulse){ 00073 // Fill integral histogram 00074 i_plot->second->Fill((*i_pulse)->GetIntegral()); 00075 } 00076 } 00077 00078 return 0; 00079 } 00080 00081 int PlotTAP_Integral::AfterLastEntry(TGlobalData* gData,const TSetupData *setup){ 00082 /* for(PlotList_t::iterator i_plot=fPlots.begin(); 00083 i_plot!=fPlots.end(); ++i_plot){ 00084 i_plot->second->Draw(); 00085 } 00086 */ 00087 return 0; 00088 } 00089 00090 ALCAP_REGISTER_MODULE(PlotTAP_Integral);