Profile TDetectorPulse s. More...
#include <PlotTDPs.h>
Classes | |
struct | Detector_t |
Public Types | |
typedef std::map< IDs::source, Detector_t > | PlotsList_t |
Public Member Functions | |
PlotTDPs (modules::options *opts) | |
Constructor. | |
~PlotTDPs () | |
Destructor. | |
int | ProcessGenericEntry (TGlobalData *gData, const TSetupData *gSetup) |
int | Preprocess (TGlobalData *gData, const TSetupData *gSetup) |
Method called by the main pre-process loop. | |
int | Postprocess (TGlobalData *gData, const TSetupData *gSetup) |
Method called by the main pre-process loop. | |
void | SetAlias (const std::string &alias) |
std::string | GetAlias () const |
const char * | GetName () const |
Get the name of this module as given to the constructor of the base class. | |
Protected Member Functions | |
bool | Debug () const |
TDirectory * | GetDirectory () const |
Get the TDirectory for this module. | |
TDirectory * | GetDirectory (const std::string &name="") |
Protected Attributes | |
TDirectory * | dir |
Private Member Functions | |
virtual int | ProcessEntry (TGlobalData *gData, const TSetupData *gSetup) |
Fill all histograms. | |
virtual int | BeforeFirstEntry (TGlobalData *gData, const TSetupData *setup) |
Setup all histograms. | |
virtual int | AfterLastEntry (TGlobalData *gData, const TSetupData *setup) |
Draw and fit all desired histograms. | |
Private Attributes | |
PlotsList_t | fPlotsList |
double | fFastCut |
double | fSlowCut |
bool | fCutHists |
Profile TDetectorPulse s.
Plot the relative amplitudes, efficiencies and times of paired pulses (TDetectorPulses, TDPs).
Definition at line 23 of file PlotTDPs.h.
typedef std::map<IDs::source,Detector_t> PlotTDPs::PlotsList_t |
Definition at line 39 of file PlotTDPs.h.
PlotTDPs::PlotTDPs | ( | modules::options * | opts | ) |
Constructor.
Definition at line 31 of file PlotTDPs.cpp.
References fCutHists, fFastCut, fSlowCut, modules::options::GetDouble(), and modules::options::GetFlag().
PlotTDPs::~PlotTDPs | ( | ) |
int PlotTDPs::AfterLastEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [private, virtual] |
Draw and fit all desired histograms.
Implements BaseModule.
Definition at line 241 of file PlotTDPs.cpp.
References PlotTDPs::Detector_t::amp_grad, PlotTDPs::Detector_t::amp_inter, PlotTDPs::Detector_t::amp_status, PlotTDPs::Detector_t::amplitudes, BaseModule::Debug(), and fPlotsList.
00241 { 00242 // Draw and save all histograms 00243 for(PlotsList_t::iterator i_source=fPlotsList.begin(); 00244 i_source!=fPlotsList.end(); ++i_source){ 00245 Detector_t& plots=i_source->second; 00246 //plots.amplitudes->Draw(); 00247 //plots.slow_only_amps->Draw(); 00248 //plots.fast_only_amps->Draw(); 00249 //plots.time_diff_fast->Draw(); 00250 //plots.time_diff_slow->Draw(); 00251 //if(fCutHists){ 00252 // plots.fast_amps_slow_cut->Draw(); 00253 // plots.slow_amps_fast_cut->Draw(); 00254 //} 00255 TProfile* profile=plots.amplitudes->ProfileX(Form("%s_fit",plots.amplitudes->GetName())); 00256 TFitResultPtr fit=profile->Fit("pol1","QS"); 00257 if(((int)fit)!=0){ 00258 cout<<"PlotTDPs: Warning: fitting to 2D amplitude plots failed with status: " 00259 << (int)fit <<" for "<<i_source->first<<endl; 00260 } else { 00261 plots.amp_inter=fit->Parameter(0); 00262 plots.amp_grad=fit->Parameter(1); 00263 } 00264 plots.amp_status=fit; 00265 } 00266 00267 if(Debug()){ 00268 cout<<"PlotTDPs: Fitted amplitude gradients:"<<endl; 00269 cout<<" intercept\t| gradient\t| source"<<endl; 00270 cout<<" ---------\t| --------\t| ------"<<endl; 00271 for(PlotsList_t::const_iterator i_source=fPlotsList.begin(); 00272 i_source!=fPlotsList.end(); ++i_source){ 00273 const Detector_t& plots=i_source->second; 00274 if(!plots.amp_status) 00275 cout<< " "<<plots.amp_inter<<"\t| "<< plots.amp_grad<<"\t| "<<i_source->first<<endl; 00276 } 00277 } 00278 00279 00280 return 0; 00281 }
int PlotTDPs::BeforeFirstEntry | ( | TGlobalData * | gData, | |
const TSetupData * | setup | |||
) | [private, virtual] |
Setup all histograms.
Implements BaseModule.
Definition at line 41 of file PlotTDPs.cpp.
References PlotTDPs::Detector_t::amp_grad, PlotTDPs::Detector_t::amp_inter, PlotTDPs::Detector_t::amp_status, PlotTDPs::Detector_t::amplitudes, BaseModule::Debug(), PlotTDPs::Detector_t::fast_amps_slow_cut, PlotTDPs::Detector_t::fast_only_amps, fCutHists, fFastCut, fPlotsList, fSlowCut, gDetectorPulseMap, IDs::channel::GetCorrespondingFastSlow(), BaseModule::GetDirectory(), BaseModule::GetName(), TSetupData::GetNBits(), PassThroughDPGenerator::GetStaticId(), SetupNavigator::Instance(), modules::navigator::Instance(), IDs::kFast, IDs::generator::matches(), PlotTDPs::Detector_t::scale_factor, PlotTDPs::Detector_t::slow_amps_fast_cut, PlotTDPs::Detector_t::slow_only_amps, IDs::channel::SlowFast(), PlotTDPs::Detector_t::time_diff_fast, PlotTDPs::Detector_t::time_diff_slow, PlotTDPs::Detector_t::times, and modules::parser::ToCppValid().
00041 { 00042 // Change into this modules directory 00043 GetDirectory()->cd(); 00044 00045 // Make sure we've got MakeDetectorPulses being used 00046 MakeDetectorPulses* makeTDPs=modules::navigator::Instance()->GetModule<MakeDetectorPulses>("MakeDetectorPulses"); 00047 if(!makeTDPs){ 00048 cout<<"It's meaningless to use the PlotTDPs module without MakeDetectorPulses as well"<<endl; 00049 return 1; 00050 } 00051 // Make sure MakeDetectorPulses is called before PlotTDPs 00052 if(!modules::navigator::Instance()->Before("MakeDetectorPulses",GetName())){ 00053 cout<<"MakeDetectorPulses must be used before PlotTDPs"<<endl; 00054 return 2; 00055 } 00056 00057 // Init loop variables 00058 IDs::generator passThruId=PassThroughDPGenerator::GetStaticId(); 00059 Detector_t tmp; 00060 std::string name; 00061 std::string title; 00062 std::stringstream full_title; 00063 IDs::channel fast_id; 00064 IDs::channel slow_id; 00065 int n_bits; 00066 double fast_amp_max, slow_amp_max; 00067 double fast_amp_min=0, slow_amp_min=0; 00068 double tdiff_min=-1e6, tdiff_max=1e6; 00069 00070 // Loop over all TDP sources 00071 for(SourceDetPulseMap::const_iterator i_source=gDetectorPulseMap.begin(); 00072 i_source!= gDetectorPulseMap.end(); ++i_source){ 00073 00074 // Ignore TDP sources that use the pass-through generator (so only have 00075 // one valid input channel, like a scintillator or the muScA) 00076 if(passThruId.matches(i_source->first.Generator())){ 00077 cout<<"Skipping TDP source, '"<<i_source->first<<"' as it was made with the pass-through generator"<<endl; 00078 continue; 00079 } 00080 00081 // make the name and title for the histogram 00082 name='h'+i_source->first.str(); 00083 modules::parser::ToCppValid(name); 00084 title=" from "; 00085 title+=i_source->first.str(); 00086 if(Debug()) { 00087 cout<<"Made histogram called "<<name<<" with title "<< title<<endl; 00088 } 00089 00090 // Setup the Axis limits 00091 fast_id=i_source->first.Channel(); 00092 fast_id.SlowFast(IDs::kFast); 00093 slow_id=fast_id.GetCorrespondingFastSlow(); 00094 try{ 00095 n_bits = setup->GetNBits(SetupNavigator::Instance()->GetBank(fast_id)); 00096 fast_amp_max = std::pow(2, n_bits); 00097 n_bits = setup->GetNBits(SetupNavigator::Instance()->GetBank(slow_id)); 00098 slow_amp_max = std::pow(2, n_bits); 00099 }catch(Except::InvalidDetector& e){ 00100 cout<<"PlotTDPs::BeforeFirstEntry: Skipping channel '"<<i_source->first.Channel() 00101 <<"' due to an error querying the setup navigator. This is probably casued by only 1 of " 00102 "the fast/slow channels being connected for this run."<<endl; 00103 continue; 00104 } 00105 00106 // Make a histogram of the relative amplitudes 00107 tmp.amplitudes=new TH2F((name+"_amp").c_str(),("Amplitudes of TDPs "+title).c_str(), 00108 150,fast_amp_min,fast_amp_max,150,slow_amp_min,slow_amp_max); 00109 tmp.amplitudes->SetXTitle("Amplitude in Fast channel"); 00110 tmp.amplitudes->SetYTitle("Amplitude in Slow channel"); 00111 00112 // Histogram amplitudes for pulses not in either channel 00113 tmp.fast_only_amps=new TH1F((name+"_fast_only_amp").c_str(), 00114 ("Amplitudes of hits with no corresponding slow pulse "+title).c_str(), 00115 200,fast_amp_min,fast_amp_max); 00116 tmp.fast_only_amps->SetXTitle("Amplitude in Fast channel"); 00117 00118 // Histogram amplitudes for pulses not in either channel 00119 tmp.slow_only_amps=new TH1F((name+"_slow_only_amp").c_str(), 00120 ("Amplitudes of hits with no corresponding fast pulse "+title).c_str(), 00121 200,slow_amp_min,slow_amp_max); 00122 tmp.slow_only_amps->SetXTitle("Amplitude in Slow channel"); 00123 00124 // Histogram of amplitude ratio to show the scale factor in paired 00125 // channels 00126 tmp.scale_factor=new TH1F((name+"_scale_factor").c_str(), 00127 ("Ratio of amplitudes "+title).c_str(), 00128 200,0,10); 00129 tmp.scale_factor->SetXTitle("Ratio of amplitudes, A_{Slow} / A_{Fast}"); 00130 00131 // Make a histogram of the time difference between pulses 00132 full_title.str("Time difference vs. fast amplitude for pulses "); 00133 full_title<<title; 00134 tmp.time_diff_fast=new TH2F((name+"_fast_amp_tdiff").c_str(),full_title.str().c_str(), 00135 200,tdiff_min,tdiff_max,200,fast_amp_min,fast_amp_max); 00136 tmp.time_diff_fast->SetXTitle("t_{Fast} - t_{Slow}"); 00137 tmp.time_diff_fast->SetYTitle("Amplitude in Fast channel"); 00138 00139 full_title.str("Time difference vs. slow amplitude for pulses "); 00140 full_title<<title; 00141 tmp.time_diff_slow=new TH2F((name+"_slow_amp_tdiff").c_str(),full_title.str().c_str(), 00142 200,tdiff_min,tdiff_max,200,slow_amp_min,slow_amp_max); 00143 tmp.time_diff_slow->SetXTitle("t_{Fast} - t_{Slow}"); 00144 tmp.time_diff_slow->SetYTitle("Amplitude in Slow channel"); 00145 00146 tmp.times=new TH2F((name+"_times").c_str(),("Times of pulses "+title).c_str(), 00147 200,0,-1,200,0,-1); 00148 tmp.times->SetXTitle("Time in Fast channel"); 00149 tmp.times->SetYTitle("Time in Slow channel"); 00150 00151 if(fCutHists){ 00152 // Histogram amplitudes for fast pulses with a slow pulse cut 00153 full_title.str(""); 00154 full_title<<"Amplitudes in slow channel if paired to a fast pulse with amplitude above "; 00155 full_title<<fFastCut<<title; 00156 tmp.slow_amps_fast_cut=new TH1F((name+"_slow_amp_fast_cut").c_str(), 00157 full_title.str().c_str(), 200,slow_amp_min,slow_amp_max); 00158 tmp.slow_amps_fast_cut->SetXTitle("Amplitude in Slow channel"); 00159 00160 // Histogram amplitudes for slow pulses with a fast pulse cut 00161 full_title.str(""); 00162 full_title<<"Amplitudes in fast channel if paired to a slow pulse with amplitude above "; 00163 full_title<<fSlowCut<<title; 00164 tmp.fast_amps_slow_cut=new TH1F((name+"_fast_amps_slow_cut").c_str(), 00165 full_title.str().c_str(), 200,fast_amp_min,fast_amp_max); 00166 tmp.fast_amps_slow_cut->SetXTitle("Amplitude in Fast channel"); 00167 } else{ 00168 tmp.fast_amps_slow_cut=NULL; 00169 tmp.slow_amps_fast_cut=NULL; 00170 } 00171 00172 tmp.amp_status=tmp.amp_inter=tmp.amp_grad=0; 00173 00174 // Add tmp to the list of TDPs to draw 00175 fPlotsList[i_source->first]=tmp; 00176 } 00177 00178 // Change back to the top level directory 00179 GetDirectory()->cd("/"); 00180 return 0; 00181 }
bool BaseModule::Debug | ( | ) | const [inline, protected, inherited] |
Check whether this module was asked to print extra debug information
Definition at line 71 of file BaseModule.h.
References BaseModule::fDebug.
Referenced by MakeAnalysedPulses::AddGenerator(), ExportPulse::AddToExportList(), PulseCandidateFinder_InvestigateParameters::AfterLastEntry(), PlotTPI_PedestalAndNoise::AfterLastEntry(), AfterLastEntry(), PlotTDP_TDiff::AfterLastEntry(), IslandLength::AfterLastEntry(), IslandAmplitude::AfterLastEntry(), MakeDetectorPulses::BeforeFirstEntry(), TemplateCreator::BeforeFirstEntry(), PulseCandidateFinder_InvestigateParameters::BeforeFirstEntry(), PlotTPI_PedestalAndNoise::BeforeFirstEntry(), BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), IslandLength::BeforeFirstEntry(), IslandAmplitude::BeforeFirstEntry(), PulseViewer::ConsiderDrawing(), MakeAnalysedPulses::MakeAnalysedPulses(), MakeDetectorPulses::MakeGenerator(), ExportPulse::PlotTPI(), MakeDetectorPulses::ProcessEntry(), TemplateCreator::ProcessEntry(), PulseCandidateFinder_InvestigateParameters::ProcessEntry(), MakeAnalysedPulses::ProcessEntry(), PulseViewer::ProcessEntry(), PlotTDP_TDiff::ProcessEntry(), and TemplateCreator::StartTemplate().
00071 {return fDebug;};
std::string BaseModule::GetAlias | ( | ) | const [inline, inherited] |
Returns a string for the alias of this module. May be empty if no alias was given in the modules file.
Definition at line 63 of file BaseModule.h.
References BaseModule::fAlias.
Referenced by BaseModule::BaseModule().
00063 {return fAlias;};
TDirectory * BaseModule::GetDirectory | ( | const std::string & | name = "" |
) | [protected, inherited] |
Definition at line 77 of file BaseModule.cpp.
References BaseModule::dir, and BaseModule::fDirectory.
00077 { 00078 if(name.empty()) return fDirectory; 00079 TDirectory* dir=fDirectory->GetDirectory(name.c_str()); 00080 if(dir) return dir; 00081 return fDirectory->mkdir(name.c_str()); 00082 }
TDirectory* BaseModule::GetDirectory | ( | ) | const [inline, protected, inherited] |
Get the TDirectory for this module.
Definition at line 74 of file BaseModule.h.
References BaseModule::fDirectory.
Referenced by TemplateCreator::AfterLastEntry(), SavePulses::AfterLastEntry(), TemplateCreator::BeforeFirstEntry(), BeforeFirstEntry(), ExportPulse::ExportPulse(), and TemplateCreator::ProcessEntry().
00074 {return fDirectory;}
const char* BaseModule::GetName | ( | ) | const [inline, inherited] |
Get the name of this module as given to the constructor of the base class.
Definition at line 66 of file BaseModule.h.
References BaseModule::fName.
Referenced by SavePulses::BeforeFirstEntry(), BeforeFirstEntry(), PlotTDP_TDiff::BeforeFirstEntry(), PlotTAP_Time::ProcessEntry(), PlotTAP_Energy::ProcessEntry(), PlotTAP_Amplitude::ProcessEntry(), and LoopSequence::Run().
00066 {return fName.c_str();};
int BaseModule::Postprocess | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [inherited] |
Method called by the main pre-process loop.
Does some simple work, then hooks into the derived class through AfterLastEntry.
Definition at line 66 of file BaseModule.cpp.
References BaseModule::AfterLastEntry(), and BaseModule::fDirectory.
Referenced by LoopSequence::Postprocess().
00066 { 00067 // This is called by our main routine and would allow later to split into different 00068 // process routines if we have more than one Tree and hence different tpyes of data input. 00069 00070 if(fDirectory) fDirectory->cd(); 00071 int ret = AfterLastEntry(gData, gSetup); 00072 gDirectory->cd("/"); 00073 00074 return ret; 00075 }
int BaseModule::Preprocess | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [inherited] |
Method called by the main pre-process loop.
Does some simple work, then hooks into the derived class through BeforeFirstEntry.
Definition at line 55 of file BaseModule.cpp.
References BaseModule::BeforeFirstEntry(), and BaseModule::fDirectory.
Referenced by LoopSequence::Preprocess().
00055 { 00056 // This is called by our main routine and would allow later to split into different 00057 // process routines if we have more than one Tree and hence different tpyes of data input. 00058 00059 if(fDirectory) fDirectory->cd(); 00060 int ret = BeforeFirstEntry(gData, gSetup); 00061 gDirectory->cd("/"); 00062 00063 return ret; 00064 }
int PlotTDPs::ProcessEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [private, virtual] |
Fill all histograms.
Implements BaseModule.
Definition at line 183 of file PlotTDPs.cpp.
References PlotTDPs::Detector_t::amplitudes, definitions::DefaultValue, PlotTDPs::Detector_t::fast_amps_slow_cut, PlotTDPs::Detector_t::fast_only_amps, fCutHists, fFastCut, fPlotsList, fSlowCut, gDetectorPulseMap, TDetectorPulse::kFast, TDetectorPulse::kSlow, PlotTDPs::Detector_t::scale_factor, PlotTDPs::Detector_t::slow_amps_fast_cut, PlotTDPs::Detector_t::slow_only_amps, PlotTDPs::Detector_t::time_diff_fast, PlotTDPs::Detector_t::time_diff_slow, and PlotTDPs::Detector_t::times.
00183 { 00184 00185 // For each TDP source of interest (defined in BeforeFirstEntry) 00186 const DetectorPulseList* pulseList; 00187 SourceDetPulseMap::const_iterator i_pulse_list; 00188 double fast_amp, slow_amp, fast_time, slow_time; 00189 Detector_t plots; 00190 for(PlotsList_t::iterator i_source=fPlotsList.begin(); 00191 i_source!=fPlotsList.end(); ++i_source){ 00192 // Get the desired pulse list 00193 i_pulse_list=gDetectorPulseMap.find(i_source->first); 00194 if(i_pulse_list== gDetectorPulseMap.end()){ 00195 cout<<"Unable to find TDP list for source, "<<i_source->first<<endl; 00196 return 1; 00197 } 00198 pulseList=&i_pulse_list->second; 00199 plots=i_source->second; 00200 00201 // Loop over the pulse list 00202 for(DetectorPulseList::const_iterator i_pulse=pulseList->begin(); 00203 i_pulse!=pulseList->end(); ++i_pulse){ 00204 00205 // get the amplitudes for each pulse 00206 fast_amp=(*i_pulse)->GetAmplitude(TDetectorPulse::kFast); 00207 slow_amp=(*i_pulse)->GetAmplitude(TDetectorPulse::kSlow); 00208 fast_time=(*i_pulse)->GetTime(TDetectorPulse::kFast); 00209 slow_time=(*i_pulse)->GetTime(TDetectorPulse::kSlow); 00210 00211 // If one of the channels is the default value then fill the 00212 // histogram for channels that weren't matched 00213 if(fast_amp==definitions::DefaultValue){ 00214 plots.slow_only_amps->Fill(slow_amp); 00215 }else if(slow_amp==definitions::DefaultValue){ 00216 plots.fast_only_amps->Fill(fast_amp); 00217 }else { 00218 // Both channels saw hits, fill the 2d plot 00219 plots.amplitudes->Fill(slow_amp,fast_amp); 00220 plots.time_diff_fast->Fill(slow_time - fast_time ,fast_amp); 00221 plots.time_diff_slow->Fill(slow_time - fast_time ,slow_amp); 00222 plots.times->Fill(slow_time, fast_time); 00223 plots.scale_factor->Fill(slow_amp/fast_amp); 00224 } 00225 00226 if(!fCutHists) continue; 00227 // Fill the cut histograms 00228 if(fast_amp> fFastCut && slow_amp!=definitions::DefaultValue){ 00229 plots.slow_amps_fast_cut->Fill(slow_amp); 00230 } 00231 if(slow_amp> fSlowCut && fast_amp!=definitions::DefaultValue){ 00232 plots.fast_amps_slow_cut->Fill(fast_amp); 00233 } 00234 00235 } 00236 } 00237 00238 return 0; 00239 }
int BaseModule::ProcessGenericEntry | ( | TGlobalData * | gData, | |
const TSetupData * | gSetup | |||
) | [inherited] |
Method called by the main event loop for each entry in the input root tree. Does some simple work, then hooks into the derived class through ProcessEntry.
Definition at line 44 of file BaseModule.cpp.
References BaseModule::fDirectory, and BaseModule::ProcessEntry().
Referenced by LoopSequence::Process().
00044 { 00045 // This is called by our main routine and would allow later to split into different 00046 // process routines if we have more than one Tree and hence different tpyes of data input. 00047 00048 if(fDirectory) fDirectory->cd(); 00049 int ret = ProcessEntry(gData, gSetup); 00050 gDirectory->cd("/"); 00051 00052 return ret; 00053 }
void BaseModule::SetAlias | ( | const std::string & | alias | ) | [inline, inherited] |
Sets the alias for this module, which should be provided in the modules file
Definition at line 59 of file BaseModule.h.
References BaseModule::fAlias.
Referenced by BaseModule::BaseModule().
00059 {fAlias=alias;};
TDirectory* BaseModule::dir [protected, inherited] |
Many modules use 'dir' still which was the old protected pointer to the modules directory. To prevent things being broken so soon, we keep this pointer available, but be warned that it will be removed shortly...
Definition at line 98 of file BaseModule.h.
Referenced by BaseModule::BaseModule(), FastSlowCompare::FastSlowCompare(), GeSpectrum::GeSpectrum(), BaseModule::GetDirectory(), MakeMuonEvents::MakeMuonEvents(), and PlotAmpVsTDiff::PlotAmpVsTDiff().
bool PlotTDPs::fCutHists [private] |
Definition at line 58 of file PlotTDPs.h.
Referenced by BeforeFirstEntry(), PlotTDPs(), and ProcessEntry().
double PlotTDPs::fFastCut [private] |
Definition at line 57 of file PlotTDPs.h.
Referenced by BeforeFirstEntry(), PlotTDPs(), and ProcessEntry().
PlotsList_t PlotTDPs::fPlotsList [private] |
Definition at line 56 of file PlotTDPs.h.
Referenced by AfterLastEntry(), BeforeFirstEntry(), and ProcessEntry().
double PlotTDPs::fSlowCut [private] |
Definition at line 57 of file PlotTDPs.h.
Referenced by BeforeFirstEntry(), PlotTDPs(), and ProcessEntry().