9 if(configfile!=
"") m_variables.Initialise(configfile);
16 bool use_stopwatch =
false;
17 m_variables.Get(
"use_stopwatch", use_stopwatch);
32 if(! m_variables.Get(
"nevents",
m_n_events) ) {
33 Log(
"WARN: nevents configuration not found. Reading all events",
WARN,
m_verbose);
41 Log(
"ERROR: You must use exactly one of the following options: infile filelist",
ERROR,
m_verbose);
73 m_chain_event->GetBranch(
"wcsimrootevent")->SetAutoDelete(kTRUE);
75 Log(
"INFO: The geometry has an OD. Will add OD digits to m_data",
INFO,
m_verbose);
79 m_chain_event->GetBranch(
"wcsimrootevent_OD")->SetAutoDelete(kTRUE);
84 m_data->HasOD =
false;
96 m_ss <<
"WARN: first_event set to value more than the number of events in the file. Reading just the last event in the file, number: " <<
m_first_event_num;
116 std::cerr <<
"OD PMTs are not currently stored in WCSimRootGeom. When they are TODO fill IDGeom & ODGeom depending on where the PMT is" << std::endl;
118 for(
int ipmt = 0; ipmt <
m_wcsim_geom->GetWCNumPMT(); ipmt++) {
119 const WCSimRootPMT * pmt =
m_wcsim_geom->GetPMTPtr(ipmt);
120 PMTInfo pmt_light(pmt->GetTubeNo(), pmt->GetPosition(0), pmt->GetPosition(1), pmt->GetPosition(2));
121 m_data->IDGeom.push_back(pmt_light);
132 m_data->detector_length =
m_wcsim_geom->GetWCCylLength();
133 m_data->detector_radius =
m_wcsim_geom->GetWCCylRadius();
135 m_data->IDPMTDarkRate =
m_wcsim_opt->GetPMTDarkRate(
"tank");
138 m_data->ODPMTDarkRate =
m_wcsim_opt->GetPMTDarkRate(
"OD");
141 m_data->ODPMTDarkRate = 0;
151 if(! chain->Add(fname, -1)) {
152 m_ss <<
"ERROR: Could not load tree: " << chain->GetName()
153 <<
" in file(s): " << fname;
157 m_ss <<
"INFO: Loaded tree: " << chain->GetName()
158 <<
" from file(s): " << fname
159 <<
" Chain: " << chain->GetName()
160 <<
" now has " << chain->GetEntries()
175 bool return_value =
true;
176 while(infile >> fname) {
179 return_value =
false;
184 Log(
"ERROR: Must use exactly one of the following options: infile filelist",
ERROR,
m_verbose);
191 int n = chain->GetEntries();
198 WCSimRootOptions * wcsim_opt_0;
199 WCSimRootGeom * wcsim_geom_0;
202 modestr =
"WCSimRootOptions";
206 modestr =
"WCSimRootGeom";
210 for(
int i = 1; i < n; i++) {
212 bool diff_file =
false;
216 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDetectorName(),
222 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetPMTQEMethod(),
229 std::vector<string> pmtlocs;
230 pmtlocs.push_back(
"tank");
231 if(m_data->HasOD) pmtlocs.push_back(
"OD");
232 for(
unsigned int i = 0; i < pmtlocs.size(); i++) {
233 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetPMTDarkRate(pmtlocs.at(i)),
236 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetConvRate(pmtlocs.at(i)),
239 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDarkHigh(pmtlocs.at(i)),
242 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDarkLow(pmtlocs.at(i)),
245 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDarkWindow(pmtlocs.at(i)),
248 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDarkMode(pmtlocs.at(i)),
253 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDigitizerClassName(),
255 "DigitizerClassName");
256 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDigitizerDeadTime(),
258 "DigitizerDeadTime");
259 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDigitizerIntegrationWindow(),
261 "DigitizerIntegrationWindow");
262 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDigitizerTimingPrecision(),
264 "DigitizerTimingPrecision");
265 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetDigitizerPEPrecision(),
267 "DigitizerPEPrecision");
291 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetPhysicsListName(),
295 diff_file = diff_file ||
CompareVariable(wcsim_opt_0->GetRandomGenerator(),
301 diff_file = !wcsim_geom_0->CompareAllVariables(
m_wcsim_geom);
304 m_ss <<
"ERROR: Difference between " << modestr <<
" tree between input file 0 and " << i;
316 m_ss <<
"ERROR: Difference between " << modestr <<
" trees";
328 m_ss <<
"WARN: Difference between strings " << v1 <<
" and " << v2 <<
" for variable " << tag;
338 m_data->IDTriggers.Clear();
339 m_data->ODTriggers.Clear();
342 m_data->IDSamples.clear();
343 m_data->ODSamples.clear();
347 m_data->vars.Set(
"StopLoop",1);
371 m_data->CurrentWCSimFile.String() =
m_chain_event->GetFile()->GetName();
374 m_ss <<
"DEBUG: Current event is event " << m_data->CurrentWCSimEventNum
375 <<
" from WCSim file " << m_data->CurrentWCSimFile.String()
385 m_data->IDSamples.push_back(subid);
389 Log(
"INFO: Reading in a file that has already been triggered",
INFO,
m_verbose);
390 Log(
"FATAL: This is not correctly implemented at the moment. Exiting",
FATAL,
m_verbose);
393 for(
int itrigger = 0; itrigger <
m_wcsim_event_ID->GetNumberOfEvents(); itrigger++) {
399 double first = +9E300;
400 double last = -9E300;
401 for(
size_t ihit = 0; ihit < subid_this.
m_time.size(); ihit++) {
402 double time = subid_this.
m_time[ihit];
408 Log(
"TODO: The triggered time logic is not correct.");
409 Log(
"TODO: First and Last need to be converted to absolute times.");
411 trigger_time - first,
413 trigger_time - first,
417 subid_all.
Append(subid_this);
418 Log(
"WARN: Trigger added to TriggerInfo. Note that the mask time has been set to the entire readout window",
WARN,
m_verbose);
420 m_data->IDSamples.push_back(subid_all);
426 m_data->ODSamples.push_back(subod);
434 m_data->vars.Set(
"StopLoop",1);
446 std::vector<int> PMTid;
447 std::vector<float> charge;
448 std::vector<TimeDelta::short_time_t> time;
449 for(
int idigi = 0; idigi <
m_wcsim_trigger->GetNcherenkovdigihits(); idigi++) {
451 TObject *element = (
m_wcsim_trigger->GetCherenkovDigiHits())->At(idigi);
452 WCSimRootCherenkovDigiHit *digit =
453 dynamic_cast<WCSimRootCherenkovDigiHit*
>(element);
455 int ID = digit->GetTubeId();
459 m_ss <<
"DEBUG: 1st digit time before shifting: " << first_time;
463 float Q = digit->GetQ();
468 if(idigi < 10 || m_verbose >=
DEBUG2) {
469 m_ss <<
"DEBUG: Digit " << idigi
476 m_ss <<
"DEBUG: Saved information on " << time.size() <<
" digits";
491 if (not sub.Append(PMTid, time, charge, timestamp)){
std::string m_input_filelist
The input WCSim filelist filename from config file.
std::string Result(std::string method_name, std::string output_file="")
TChain * m_chain_event
Input wcsimT chain - holds WCSim events.
SubSample GetDigits()
Creates a SubSample containing the digits from the current m_wcsim_trigger.
long int m_current_event_num
The current WCSim event number.
float short_time_t
Type for relative hit times within a SubSample. Unit = ns.
util::Stopwatch * m_stopwatch
The stopwatch, if we're using one.
bool Append(const SubSample &sub)
void Start()
Start the stopwatch.
int m_verbose
Verbosity level.
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
float m_interpose_interval
std::string m_stopwatch_file
Image filename to save the histogram to, if required.
WCSimRootGeom * m_wcsim_geom
Holds geometry information - tank size, PMT size, PMT positions, etc.
bool AddTreeToChain(const char *fname, TChain *chain)
Adds a file (or files - wildcards allowed) to the chain.
bool Initialise(std::string configfile, DataModel &data)
TChain * m_chain_geom
Input wcsimGeoT chain - holds WCSim geometry.
void set_interpose_interval(float t)
bool CompareVariable(T v1, T v2, const char *tag)
Checks for equality between 2 variables.
TChain * m_chain_opt
Input wcsimRootOptionsT chain - holds WCSim run options.
std::stringstream m_ss
Streamer for easy formatting of log messages.
WCSimRootEvent * m_wcsim_event_ID
Holds event information for the ID - tracks, hits, digits.
long int m_first_event_num
The first WCSim event number to read.
bool CompareTree(TChain *chain, int mode)
bool ReadTree(TChain *chain)
Calls AddTreeToChain for m_input_filename, or for every file within the m_input_filelist.
WCSimRootTrigger * m_wcsim_trigger
Holds trigger information - trigger time, digits, etc.
WCSimRootEvent * m_wcsim_event_OD
Holds event information for the OD - hits, digits.
static const TimeDelta ns
TimeDelta of 1 ns.
void Log(const std::string &message, const int message_level)
Format messages in the same way as for tools.
long int m_n_events
The total number of events in m_chain_event.
std::vector< TimeDelta::short_time_t > m_time
Vector of hit times relative to timestamp for all hits in SubSample. Unit: ns.
WCSimRootOptions * m_wcsim_opt
Holds WCSim running options - trigger thresholds, geometry names, input .kin filename, etc.
std::string m_input_filename
The input WCSim filename from config file (wildcards allowed)
void StreamToLog(int level)
Helper function to print streamer at specified level, and clear streamer.