00001 //#define USE_PRINT_OUT 00002 00003 #include "PlotTAP_Time.h" 00004 #include <iostream> 00005 #include <string> 00006 #include <sstream> 00007 #include <map> 00008 //#include <utility> 00009 //#include <algorithm> 00010 #include <cmath> 00011 #include "definitions.h" 00012 #include "SetupNavigator.h" 00013 00014 #include "TAnalysedPulse.h" 00015 #include "TDetectorPulse.h" 00016 #include "RegisterModule.inc" 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_Time::PlotTAP_Time(modules::options* opts) : 00027 BaseModule("PlotTAP_Time",opts) { 00028 } 00029 00030 PlotTAP_Time::~PlotTAP_Time(){ 00031 } 00032 00033 int PlotTAP_Time::ProcessEntry(TGlobalData *gData, const TSetupData* gSetup){ 00034 00035 double min_time = 0; 00036 double max_time = 110e6; // ms 00037 double n_bins = 1e3; 00038 // Loop over each TAP list 00039 for (SourceAnalPulseMap::const_iterator i_det = gAnalysedPulseMap.begin(); 00040 i_det != gAnalysedPulseMap.end(); 00041 i_det++) { 00042 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 ( fTimePlots.find(keyname) == fTimePlots.end() ) { 00049 00050 // hTime 00051 std::string histname = "h" + detname + "_Time"; 00052 std::stringstream histtitle; 00053 histtitle<<"Time of pulses from source " << i_det->first; 00054 histtitle<<" for run "<<SetupNavigator::Instance()->GetRunNumber(); 00055 TH1F* hTime = new TH1F(histname.c_str(), histtitle.str().c_str(), n_bins,min_time,max_time); 00056 hTime->GetXaxis()->SetTitle("Time (ns)"); 00057 hTime->GetYaxis()->SetTitle("Arbitrary Units"); 00058 fTimePlots[keyname] = hTime; 00059 } 00060 00061 const AnalysedPulseList *pulses =& i_det->second; 00062 //if(Debug() && pulses->empty()) DEBUG_PREFIX<<" no pulses to fill for "<<i_det->first<<std::endl; 00063 00064 for (AnalysedPulseList::const_iterator pulseIter = pulses->begin(); pulseIter != pulses->end(); ++pulseIter) { 00065 double time = (*pulseIter)->GetTime(); 00066 fTimePlots[keyname]->Fill(time); 00067 00068 } // end loop through pulses 00069 00070 } // end loop through detectors 00071 return 0; 00072 } 00073 00074 ALCAP_REGISTER_MODULE(PlotTAP_Time)