00001 #include "PlotTDP_TDiff.h"
00002 #include "RegisterModule.inc"
00003 #include "TGlobalData.h"
00004 #include "TSetupData.h"
00005 #include "ModulesOptions.h"
00006 #include "ModulesNavigator.h"
00007 #include "definitions.h"
00008
00009 #include "TDetectorPulse.h"
00010
00011 #include <iostream>
00012 using std::cout;
00013 using std::endl;
00014
00015 extern SourceDetPulseMap gDetectorPulseMap;
00016
00017 PlotTDP_TDiff::PlotTDP_TDiff(modules::options* opts):
00018 BaseModule("PlotTDP_TDiff",opts),
00019 fTimeLow(opts->GetDouble("time_low",-1.e5)), fTimeHigh(opts->GetDouble("time_high",1.e5)){
00020
00021
00022
00023
00024
00025 fSourceA = IDs::source(opts->GetString("source_a"));
00026 fSourceB = IDs::source(opts->GetString("source_b"));
00027 }
00028
00029 PlotTDP_TDiff::~PlotTDP_TDiff(){
00030 }
00031
00032
00033
00034
00035 int PlotTDP_TDiff::BeforeFirstEntry(TGlobalData* gData,const TSetupData *setup){
00036
00037 if(Debug()){
00038 cout<<"-----PlotTDP_TDiff::BeforeFirstEntry(): I'm debugging!"<<endl;
00039 }
00040
00041 if(!modules::navigator::Instance()->Before("MakeDetectorPulses",GetName())){
00042 cout<<"MakeDetectorPulses must be used before PlotTDP_TDiff"<<endl;
00043 return 1;
00044 }
00045
00046
00047 std::string detname_a = fSourceA.Channel().str();
00048 std::string detname_b = fSourceB.Channel().str();
00049
00050 std::string histogram_name = modules::parser::ToCppValid("h" + fSourceA.str() + "_" + fSourceB.str() + "_TDiff");
00051 std::string histogram_title = "Time Difference between TDP source " + fSourceA.str() + "_" + fSourceB.str();
00052 fTDiffPlot = new TH1F(histogram_name.c_str(), histogram_title.c_str(), 600, fTimeLow, fTimeLow);
00053
00054 std::string axis_title = "t_{" + detname_a + "} - t_{" + detname_b + "} [ns]";
00055 fTDiffPlot->GetXaxis()->SetTitle(axis_title.c_str());
00056
00057 return 0;
00058 }
00059
00060
00061
00062 int PlotTDP_TDiff::ProcessEntry(TGlobalData* gData,const TSetupData *setup){
00063
00064
00065 for(SourceDetPulseMap::const_iterator i_source=gDetectorPulseMap.begin();
00066 i_source!= gDetectorPulseMap.end(); ++i_source){
00067
00068
00069 if ( (i_source->first).matches(fSourceA)) {
00070 fDetPulsesA = i_source->second;
00071 if (Debug()) {
00072 std::cout << "PlotTDP_TDiff: " << fSourceA << " pulses found. (" << fDetPulsesA.size() << " pulses)" << std::endl;;
00073 }
00074 }
00075 else if ((i_source->first).matches(fSourceB)) {
00076 fDetPulsesB = i_source->second;
00077 if (Debug()) {
00078 std::cout << "PlotTDP_TDiff: " << fSourceB << " pulses found. (" << fDetPulsesB.size() << " pulses)" << std::endl;
00079 }
00080 }
00081 }
00082
00083
00084 for (DetectorPulseList::const_iterator i_det_pulse_a = fDetPulsesA.begin(); i_det_pulse_a != fDetPulsesA.end(); ++i_det_pulse_a) {
00085 for (DetectorPulseList::const_iterator i_det_pulse_b = fDetPulsesB.begin(); i_det_pulse_b != fDetPulsesB.end(); ++i_det_pulse_b) {
00086
00087 double time_det_pulse_a = (*i_det_pulse_a)->GetTime();
00088 double time_det_pulse_b = (*i_det_pulse_b)->GetTime();
00089 double time_difference = time_det_pulse_a - time_det_pulse_b;
00090
00091 fTDiffPlot->Fill(time_difference);
00092 }
00093 }
00094 return 0;
00095 }
00096
00097
00098
00099
00100 int PlotTDP_TDiff::AfterLastEntry(TGlobalData* gData,const TSetupData *setup){
00101
00102
00103 if(Debug()){
00104 cout<<"-----PlotTDP_TDiff::AfterLastEntry(): I'm debugging!"<<endl;
00105 }
00106
00107 return 0;
00108 }
00109
00110
00111
00112
00113
00114 ALCAP_REGISTER_MODULE(PlotTDP_TDiff,source_a,source_b, time_low, time_high);