#include <iostream>
#include <string>
#include <map>
#include "SetupNavigator.h"
#include "definitions.h"
#include "TTree.h"
#include "TBranch.h"
#include "TFile.h"
#include "CommandLine.h"
#include "ModulesFactory.h"
#include "ModulesNavigator.h"
#include "BaseModule.h"
#include "TGlobalData.h"
#include "TSetupData.h"
#include "TAnalysedPulse.h"
#include "TDetectorPulse.h"
#include "TMuonEvent.h"
#include "TAnalysedPulseMapWrapper.h"
#include "EventNavigator.h"
#include "debug_tools.h"
Go to the source code of this file.
| |
SourceAnalPulseMap | gAnalysedPulseMap |
SourceDetPulseMap | gDetectorPulseMap |
MuonEventList | gMuonEvents |
Int_t | Main_event_loop (TTree *dataTree, ARGUMENTS &arguments) |
void | ClearGlobalData (TGlobalData *) |
TTree * | GetTree (TFile *inFile, const char *t_name) |
Int_t | PrepareAnalysedPulseMap (TFile *fileOut) |
Int_t | PrepareSingletonObjects (const ARGUMENTS &) |
void | Finish (TFile *) |
int | main (int argc, char **argv) |
void | PrintSetupData (TSetupData *s_data) |
void ClearGlobalData | ( | TGlobalData * | data | ) |
Definition at line 203 of file main.cpp.
References gAnalysedPulseMap, gDetectorPulseMap, gMuonEvents, and modules::navigator::Instance().
Referenced by LoopSequence::Process().
00204 { 00205 // TODO: this comment is now gibberish. 00206 // We could put this into TGlobalData::Clear(), but we need 00207 // to be sure that's okay at the alcapana level. That is, if 00208 // Clear() deletes the TPulseIsland objects, but g_event doesn't 00209 // own the pulses, they would be deleted later. A solution is to 00210 // be sure that TGlobalData isn't called in alcapana, or ensure 00211 // that g_event owns the pulse islands at that level. 00212 // 00213 //--- LoopSequence::Process now takes care of this part by invoking TGlobalData::Clear 00214 // StringPulseIslandMap::iterator mapIter; 00215 // StringPulseIslandMap::iterator mapEnd = data->fPulseIslandToChannelMap.end(); 00216 // for(mapIter = data->fPulseIslandToChannelMap.begin(); mapIter != mapEnd; mapIter++) { 00217 // // The iterator is pointing to a pair<string, vector<TPulseIsland*> > 00218 // std::vector<TPulseIsland*>& pulse_vector= mapIter->second; 00219 // for(size_t i=0; i<pulse_vector.size(); i++){ 00220 // delete pulse_vector[i]; 00221 // pulse_vector[i] = NULL; 00222 // } 00223 // pulse_vector.clear(); 00224 // } 00225 00226 // we should not clear TAPs if we're loading them in from a previously made 00227 // TAP tree (which uses a TClonesArray that is responsible for deleting them ) 00228 static bool should_delete_TAPS=!modules::navigator::Instance()->GetModule("LoadPulses"); 00229 for(SourceAnalPulseMap::iterator mapIter=gAnalysedPulseMap.begin(); 00230 mapIter != gAnalysedPulseMap.end(); ++mapIter) { 00231 00232 // The iterator is pointing to a pair<string, vector<TPulseIsland*> > 00233 AnalysedPulseList& pulse_vector= mapIter->second; 00234 if(should_delete_TAPS){ 00235 for(size_t i=0; i<pulse_vector.size(); i++){ 00236 delete pulse_vector[i]; 00237 pulse_vector[i] = NULL; 00238 } 00239 } 00240 pulse_vector.clear(); 00241 } 00242 // gAnalysedPulseMap.clear(); 00243 00244 for(SourceDetPulseMap::iterator mapIter = gDetectorPulseMap.begin(); 00245 mapIter != gDetectorPulseMap.end(); ++mapIter) { 00246 // The iterator is pointing to a pair<string, vector<TPulseIsland*> > 00247 DetectorPulseList& pulse_vector= mapIter->second; 00248 for(size_t i=0; i<pulse_vector.size(); i++){ 00249 delete pulse_vector[i]; 00250 pulse_vector[i] = NULL; 00251 } 00252 pulse_vector.clear(); 00253 } 00254 //gDetectorPulseMap.clear(); 00255 00256 for(MuonEventList::iterator muonEvent = gMuonEvents.begin(); 00257 muonEvent != gMuonEvents.end(); ++muonEvent) { 00258 delete *muonEvent; 00259 } 00260 gMuonEvents.clear(); 00261 }
void Finish | ( | TFile * | fileOut | ) |
Definition at line 169 of file main.cpp.
References SetupNavigator::Close(), EventNavigator::Close(), SetupNavigator::Instance(), and EventNavigator::Instance().
Referenced by main().
00169 { 00170 // and finish up 00171 fileOut->cd(); 00172 //gAnalysedPulseTree->Write(); 00173 fileOut->Write(); 00174 fileOut->Close(); 00175 EventNavigator::Instance().Close(); 00176 SetupNavigator::Instance()->Close(); 00177 }
TTree* GetTree | ( | TFile * | inFile, | |
const char * | t_name | |||
) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 76 of file main.cpp.
References analyze_command_line(), SetupNavigator::CacheCalibDB(), EventNavigator::ConnectInput(), EventNavigator::DumpRawTree(), Finish(), EventNavigator::GetRawTree(), ARGUMENTS::infile, EventNavigator::Instance(), modules::navigator::Instance(), SetupNavigator::Instance(), Main_event_loop(), ARGUMENTS::mod_file, ARGUMENTS::outfile, PrepareAnalysedPulseMap(), PrepareSingletonObjects(), and SetupNavigator::SetCommandLineArgs().
00077 { 00078 //load_config_file("MODULES.txt"); 00079 00080 // Parse the command line 00081 ARGUMENTS arguments; 00082 int ret = analyze_command_line (argc, argv,arguments); 00083 if(ret!=0) return ret; 00084 std::cout << "Starting event" << std::endl; 00085 // Give the command line arguments to the navigator 00086 SetupNavigator::Instance()->SetCommandLineArgs(arguments); 00087 SetupNavigator::Instance()->CacheCalibDB(); 00088 00089 // Read in the configurations file 00090 ret= modules::navigator::Instance()->LoadConfigFile(arguments.mod_file.c_str()); 00091 if(ret!=0) { 00092 std::cout<<"Error: Problem loading MODULES file"<<std::endl; 00093 return ret; 00094 } 00095 00096 // Open the input tree file 00097 EventNavigator& navi = EventNavigator::Instance(); 00098 if ( ! navi.ConnectInput(arguments.infile.c_str()) ){ 00099 std::cout << "Failed to open input file '" 00100 << arguments.infile <<"'. Exiting." << std::endl; 00101 return 1; 00102 } 00103 if( modules::navigator::Instance()->DumpInputFile()){ 00104 navi.DumpRawTree(); 00105 } 00106 00107 // Make an initial call to singleton objects that are very likely to be called at some point. 00108 ret = PrepareSingletonObjects(arguments); 00109 if(ret!=0) { 00110 std::cout<<"Error: Problem creating a singleton object..."<<std::endl; 00111 return ret; 00112 } 00113 00114 // Now that we've loaded the TSetupData for this run check if there are any 00115 // suggested replacements for the wiremap data 00116 //CheckSetupData(navi.GetSetupData(), arguments.correction_file); 00117 00118 //Event Tree 00119 TTree* eventTree = navi.GetRawTree(); 00120 00121 // Let's open the output file for analysis data, histograms and so on. 00122 TFile *fileOut = new TFile(arguments.outfile.c_str(), "RECREATE"); 00123 if(!fileOut->IsOpen()){ 00124 std::cout << "Could not open ROOT output file " 00125 << arguments.outfile << std::endl; 00126 return 1; 00127 } 00128 modules::navigator::Instance()->SetOutFile(fileOut); 00129 00130 // Now let's setup all the analysis modules we want 00131 // NOTE: This has to be done after the output file was opened else the 00132 // modules wont have a directory to store things to. 00133 ret= modules::navigator::Instance()->MakeModules(); 00134 if(ret!=0) { 00135 std::cout << "Problem creating analysis modules." << std::endl; 00136 return ret; 00137 } 00138 00139 // Setup the analysed pulse map to store / read in the pulses 00140 ret = PrepareAnalysedPulseMap(fileOut); 00141 if(ret!=0) { 00142 std::cout << "Problem preparing analysed pulse map." << std::endl; 00143 return ret; 00144 } 00145 00146 // Finally let's do the main loop 00147 fileOut->cd(); 00148 try { 00149 Main_event_loop(eventTree,arguments); 00150 } 00151 catch (std::exception& e){ 00152 // Attempt to finish the run but ignore further exceptions 00153 try{ Finish(fileOut); }catch(...){} 00154 std::cout << "Terminating due to unexpected exception:\n" 00155 << e.what() << std::endl; 00156 throw; 00157 } 00158 catch (...){ 00159 // Attempt to finish the run but ignore further exceptions 00160 try{ Finish(fileOut); }catch(...){} 00161 std::cout << "Terminating due to unknown exception" << std::endl; 00162 throw; 00163 } 00164 00165 Finish(fileOut); 00166 return 0; 00167 }
Int_t PrepareAnalysedPulseMap | ( | TFile * | fileOut | ) |
Definition at line 292 of file main.cpp.
Referenced by main().
00293 { 00294 // TAnalysedMapWrapper 00295 //gAnalysedPulseMapWrapper = new TAnalysedPulseMapWrapper(gAnalysedPulseMap); 00296 00297 int split = 1; 00298 //int bufsize = 64000; 00299 Int_t branchstyle = 1; 00300 00301 if (split < 0) {branchstyle = 0; split = -1-split;} 00302 TTree::SetBranchStyle(branchstyle); 00303 00304 //gAnalysedPulseTree = new TTree("AnalysedPulseTree", "AnalysedPulseTree"); 00305 //gAnalysedPulseTree->SetAutoSave(100000000); 00306 //gAnalysedPulseTree->SetMaxVirtualSize(100000000); 00307 //gAnalysedPulseBranch = gAnalysedPulseTree->Branch("AnalysedPulseMapWrapper", 00308 // "TAnalysedPulseMapWrapper", 00309 // &gAnalysedPulseMapWrapper, 00310 // bufsize, split); 00311 //gAnalysedPulseBranch->SetAutoDelete(kFALSE); 00312 return 0; 00313 }
Int_t PrepareSingletonObjects | ( | const ARGUMENTS & | ) |
Definition at line 316 of file main.cpp.
References EventNavigator::Instance(), and modules::navigator::Instance().
Referenced by main().
00316 { 00317 // Set up the modules navigator 00318 if(!modules::navigator::Instance()) return 1; 00319 00320 // Make sure the instance of TSetupData get's loaded 00321 // (though in practice we can do this lazily) 00322 if( !EventNavigator::Instance().GetSetupData() ) return 2; 00323 00324 return 0; 00325 }
void PrintSetupData | ( | TSetupData * | s_data | ) |
Definition at line 265 of file main.cpp.
References TSetupData::fBankToDetectorMap, TSetupData::GetClockTick(), TSetupData::GetDetectorName(), TSetupData::GetNBits(), TSetupData::GetPedestal(), TSetupData::GetTimeShift(), and TSetupData::GetTriggerPolarity().
00266 { 00267 if(!s_data) return; 00268 // print things out 00269 std::map<std::string, std::string>::iterator it_info; 00270 std::cout << "### TSetupData ###\n" 00271 << "Bank Detector Name Clock Tick (ns) Pedestal (ADC)" 00272 << " Trigger Polarity Time Shift (ns) No. of Bits\n" 00273 << "---- ------------- --------------- --------------" 00274 << " ---------------- --------------- -----------" 00275 << std::endl; 00276 00277 for (it_info=s_data->fBankToDetectorMap.begin(); 00278 it_info!=s_data->fBankToDetectorMap.end(); ++it_info){ 00279 const std::string& bankname = it_info->first; 00280 std::cout << bankname << " " 00281 << s_data->GetDetectorName(bankname) << "\t\t" 00282 << s_data->GetClockTick(bankname) << "\t" 00283 << s_data->GetPedestal(bankname) << "\t\t" 00284 << s_data->GetTriggerPolarity(bankname) << "\t\t" 00285 << s_data->GetTimeShift(bankname) << "\t\t" 00286 << s_data->GetNBits(bankname) 00287 << std::endl; 00288 } 00289 }
Definition at line 72 of file main.cpp.
Referenced by MakeDetectorPulses::BeforeFirstEntry(), MakeAnalysedPulses::BeforeFirstEntry(), SavePulses::BeforeFirstEntry(), PlotTAP_TDiff::BeforeFirstEntry(), PlotTAP_selfCorrelation::BeforeFirstEntry(), PlotTAP_Integral::BeforeFirstEntry(), PlotAmpVsMuScTDiff::BeforeFirstEntry(), CalcCoarseTimeOffset::BeforeFirstEntry(), PlotIntegralRatios::BeforeFirstEntry(), LoadPulses::BeforeFirstEntry(), ClearGlobalData(), MakeDetectorPulses::ProcessEntry(), MakeAnalysedPulses::ProcessEntry(), SavePulses::ProcessEntry(), PulseViewer::ProcessEntry(), PlotTAP_Time::ProcessEntry(), PlotTAP_TDiff::ProcessEntry(), PlotTAP_selfCorrelation::ProcessEntry(), PlotTAP_Integral::ProcessEntry(), PlotTAP_Energy::ProcessEntry(), PlotTAP_Amplitude::ProcessEntry(), PlotAmpVsTDiff::ProcessEntry(), PlotAmpVsMuScTDiff::ProcessEntry(), CalcCoarseTimeOffset::ProcessEntry(), PlotIntegralRatios::ProcessEntry(), and LoadPulses::ProcessEntry().
Definition at line 73 of file main.cpp.
Referenced by MakeDetectorPulses::BeforeFirstEntry(), PlotTDPs::BeforeFirstEntry(), ClearGlobalData(), MakeSiliconEvents::GetTDPSource(), MakeMuonEvents::ProcessEntry(), MakeDetectorPulses::ProcessEntry(), PlotTDPs::ProcessEntry(), and PlotTDP_TDiff::ProcessEntry().
Definition at line 74 of file main.cpp.
Referenced by ClearGlobalData(), MakeSiliconEvents::ProcessEntry(), MakeMuonEvents::ProcessEntry(), PlotTME_activeSiRmuStops::ProcessEntry(), CheckTMEs::ProcessEntry(), TMEViewer::ProcessEntry(), TME_SiArmTDiff::ProcessEntry(), and TME_Al50_EvdE::ProcessEntry().