1 #include "AnalysisFlow.h" 2 #include "OutputConvention.h" 3 #include "ProgressBar.h" 4 #include "FilterStrategy.h" 5 #include "QualityCut.h" 6 #include "AcclaimFilters.h" 7 #include "NoiseMonitor.h" 8 #include "AcclaimCmdLineArgs.h" 9 #include "UsefulAnitaEvent.h" 10 #include "Compression.h" 57 const char* sgeTaskId =
"SGE_TASK_ID";
58 const char* sgeTaskIdEnv = getenv(sgeTaskId);
66 Int_t jobArrayIndex = atoi(sgeTaskIdEnv);
68 if(jobArrayIndex < 1e3){
73 else if(jobArrayIndex < 1e4){
75 fRun = jobArrayIndex/fNumDivisions;
76 fDivision = jobArrayIndex%10;
78 else if(jobArrayIndex < 1e5){
80 fRun = jobArrayIndex/fNumDivisions;
81 fDivision = jobArrayIndex%100;
84 std::cerr <<
"Error in " << __FILE__ <<
" couldn't figure out the run/divisions from " << sgeTaskId <<
". Giving up." << std::endl;
88 std::cout <<
"Info in " << __PRETTY_FUNCTION__ <<
". " 89 <<
"Found " << sgeTaskId <<
" " << sgeTaskIdEnv
90 <<
", so the jobArrayIndex = " << jobArrayIndex
91 <<
", set fRun = " << fRun
92 <<
", fNumDivisions = " << fNumDivisions
93 <<
", fDivision = " << fDivision <<
"." << std::endl;
117 fSettings->write(fOutFile);
145 bool doDecimated = fSelection == kDecimated ? true :
false;
148 Long64_t numEntriesInRun = fData->N();
150 Long64_t numEventsPerDivision = numEntriesInRun/fNumDivisions;
152 fFirstEntry = numEventsPerDivision*fDivision;
153 fLastEntry = fFirstEntry + numEventsPerDivision;
155 if(fDivision==fNumDivisions-1){
156 Long64_t numRemainder = numEntriesInRun%fNumDivisions;
157 fLastEntry += numRemainder;
169 if(fOutFile==NULL && fOutFileBaseName!=
""){
175 std::vector<char*> fakeArgv;
176 fakeArgv.push_back((
char*) fOutFileBaseName.Data());
177 TString runStr = TString::Format(
"%d", fRun);
178 fakeArgv.push_back((
char*) runStr.Data());
181 if(fNumDivisions > 1){
183 Int_t numDigitsTotal = floor(TMath::Log10(fNumDivisions) + 1);
184 Int_t numDigitsThis = fDivision == 0 ? 1 : floor(TMath::Log10(fDivision) + 1);
189 for(
int i=0; i < numDigitsTotal - numDigitsThis; i++){
192 extraDigits += TString::Format(
"0");
194 extraDigits += TString::Format(
"%d", fDivision);
198 fakeArgv.push_back((
char*) extraDigits.Data());
200 Int_t fakeArgc = (Int_t) fakeArgv.size();
210 if(fOutFileCompressionLevel >= 0){
211 fOutFile->SetCompressionLevel(fOutFileCompressionLevel);
216 fOutFile->SetCompressionAlgorithm((ROOT::ECompressionAlgorithm) fOutFileCompressionAlgo);
228 Bool_t doEvent =
false;
233 doEvent = isPulserWAIS(header, usefulPat);
249 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
", unknown event selection." << std::endl;
262 const int maxSeparationMeters = 1e6;
263 const double c_ns = 0.3;
264 Bool_t isWais =
false;
265 if(triggerTimeNsExpected < maxSeparationMeters/c_ns){
267 const Double_t maxDeltaTriggerTimeNs = 1200;
269 Int_t deltaTriggerTimeNs = Int_t(triggerTimeNs) - Int_t(triggerTimeNsExpected);
271 isWais = TMath::Abs(deltaTriggerTimeNs) < maxDeltaTriggerTimeNs;
285 const int maxSeparationMeters = 1e6;
286 const double c_ns = 0.3;
287 Bool_t
isLDB =
false;
289 if(triggerTimeNsExpected < maxSeparationMeters/c_ns){
291 const double cutTimeNs = 1200;
304 const Int_t delayGenerator = 199996850;
305 const Int_t constdelay = 500;
307 Int_t deltaTriggerTimeNs = Int_t(header->
triggerTimeNs) - Int_t(triggerTimeNsExpected);
308 deltaTriggerTimeNs = deltaTriggerTimeNs%(delayGenerator) - delay - constdelay;
310 isLDB = TMath::Abs(deltaTriggerTimeNs) < cutTimeNs;
321 if(isPulserWAIS(header, usefulPat)){
322 sum->flags.pulser = AnitaEventSummary::EventFlags::WAIS;
324 else if(isPulserLDB(header, usefulPat)){
325 sum->flags.pulser = AnitaEventSummary::EventFlags::LDB;
334 if(fRun >= 257 && fRun <= 263){
335 if(AnitaVersion::get()==3){
336 std::cerr <<
"No ANITA-3 data for run " << fRun <<
" so won't do analysis" << std::endl;
343 fSettings->apply(dynamic_cast<TObject*>(
this));
348 fSettings->apply(fReco);
356 prepareOutputFiles();
359 fEventSummary = NULL;
360 if(fOutFile && !fSumTree){
361 fSumTree =
new TTree(
"sumTree",
"Tree of AnitaEventSummaries");
362 fSumTree->Branch(
"sum", &fEventSummary);
368 fFilterStrat->attachFile(fOutFile);
376 fLastEventConsidered = 0;
382 int entry = fData->getEvent(eventNumber);
383 return entry > 0 ? doEntry(entry) : NULL;
390 fData->getEntry(entry);
396 std::cerr <<
"Debug in " << __PRETTY_FUNCTION__ <<
" doing entry " << entry <<
" for selection " << fSelection
397 <<
", header->eventNumber = " << header->
eventNumber <<
", usefulEvent->eventNumber = " << usefulEvent->
eventNumber 403 if(fLastEventConsidered + 1 != header->
eventNumber){
404 Filters::makeFourierBuffersLoadHistoryOnNextEvent(fFilterStrat);
410 Bool_t needToReconstruct = shouldIDoThisEvent(header, &usefulPat);
412 fEventSummary = NULL;
414 if(needToReconstruct){
419 if(isGoodEvent || (fDoAll && !fEventSummary->flags.isVarner2)){
421 setPulserFlags(header, &usefulPat, fEventSummary);
428 fReco->process(fEv, fEventSummary, fNoiseMonitor);
437 return fEventSummary;
445 fLastEventConsidered = 0;
447 std::cout <<
"Info in " << __PRETTY_FUNCTION__ <<
", doing run " << fRun
448 <<
" from entry " << fFirstEntry <<
" to " << fLastEntry << std::endl;
450 if(startAtThisEntry >= fFirstEntry && startAtThisEntry < fLastEntry){
451 std::cout <<
"Info in " << __PRETTY_FUNCTION__ <<
", starting at entry " << startAtThisEntry
452 <<
" instead of entry " << fFirstEntry << std::endl;
453 fFirstEntry = startAtThisEntry;
455 else if(startAtThisEntry!=-1){
456 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
" got requested start entry " 457 << startAtThisEntry <<
", which lies outside range " << fFirstEntry
458 <<
" to " << fLastEntry <<
". Ignoring request!" << std::endl;
461 const Long64_t numEntries = fLastEntry-fFirstEntry;
463 for(Long64_t entryInd = 0; entryInd < numEntries; entryInd++){
464 Long64_t entry = fFirstEntry + entryInd;
470 p.
inc(entryInd, numEntries);
UInt_t eventNumber
Event number from software.
Bool_t checkForSgeTaskId()
Look for an environmental variable called SGE_TASK_ID for running on the hoffman2 cluster...
bool isLDB(const RawAnitaHeader *hdr, const AnalysisConfig *cfg=0)
Bool_t isPulserWAIS(RawAnitaHeader *header, UsefulAdu5Pat *usefulPat)
void prepareDataSet()
Create the data set if not already done.
selection fSelection
Which event selection is applied?
int fRun
Which run in the data set should be is being processed?
static Bool_t applyAll(const UsefulAnitaEvent *usefulEvent, AnitaEventSummary *sum=NULL)
Applies all the event quality cuts in succession, this should be the primary interface.
selection
A human readable method of selecting the set of events to process, this can be expanded as required...
Adu5Pat – The ADU5 Position and Attitude Data.
void setPulserFlags(RawAnitaHeader *header, UsefulAdu5Pat *usefulPat, AnitaEventSummary *sum)
Does the event reconstruction, and produces a summary of it.
UInt_t getWaisDivideTriggerTimeNs() const
Gets the time of flight to Taylor Dome.
AnalysisFlow(CmdLineArgs *args, FilterStrategy *filterStrat=NULL)
Preferred constructor.
UInt_t fLastEventConsidered
Tracks the event numbers processed by the class.
~AnalysisFlow()
Destructor.
TFile * makeFile()
Create the new output file with proper name.
void prepareOutputFiles()
Coax the OutputConvention class into creating appropriately named output files.
Int_t fDebug
Controls the printing of debug info, feel free to wrap noisy stderr messages with if(fDebug)...
AnalysisReco * fReco
The reconstruction class, fills an AnitaEventSummary.
Bool_t isPulserLDB(RawAnitaHeader *header, UsefulAdu5Pat *usefulPat)
A filter strategy defines the sets of filters that are used and provides some introspection abilities...
High level interface to join up the various bits of the analysis.
A class to systematically name files produced by my analysis programs.
Long64_t fFirstEntry
The first entry to process (derived from fDivision and fNumDivisions)
int fNumDivisions
For parallel processing the run is divided into this many portions.
A simple command line option parser.
void inc(Long64_t &entry, Long64_t numEntries=-1)
New primary function to move through main for loop in analysis program.
AnitaDataset * fData
Rootified data handler.
UInt_t getLDBTriggerTimeNs() const
Gets the time of flight to Siple.
What you should call for analysis work.
FilteredAnitaEvent * fEv
The most recently produced FilteredAnitaEvent, updated after each event processed.
TTree * fSumTree
The produced TTree of AnitaEventSummary.
AnalysisSettings * fSettings
Contains configurable numbers parsed from an Acclaim analysis settings file.
Prints a progress bar and timer to stderr.
UsefulAnitaEvent – The Calibrated Useful Anita Event object.
TFile * fOutFile
the output file, will contain TTree of AnitaEventSummary
AnitaDataset::BlindingStrategy fBlindStrat
The blinding strategy with which to initialize fData.
Int_t fOutFileCompressionLevel
What compression level for the ROOT output files? There's no reason not to set this to the maximum po...
TString fOutFileBaseName
The meat of the output file name.
As UsefulAnitaEvent is to RawAnitaEvent, UsefulAdu5Pat is to Adu5Pat. Well not quite as useful but yo...
int fDivision
Which portion of the run to process (runs from 0 to fNumDivisions)
FilterStrategy * fFilterStrat
Which filter strategy is applied to the events.
void doAnalysis(Long64_t startAtThisEntry=-1)
Common analysis format between UCorrelator and Acclaim.
AnitaEventSummary * doEvent(UInt_t eventNumber)
Long64_t fLastEntry
The final entry to process (derived from fDivision and fNumDivisions)
Bool_t shouldIDoThisEvent(RawAnitaHeader *header, UsefulAdu5Pat *usefulPat)
Applies high level event selection.
void prepareEverything(const char *preferredSettingsFileName=NULL)
Initialize all input and output objects.
AnitaEventSummary * doEntry(Long64_t entry)
This class is intended to store all the necessary data about an ANITA event for filtering and analysi...
Int_t fOutFileCompressionAlgo
Which compression algorithm for the ROOT output files?
AnitaEventSummary * fEventSummary
The most recently filled AnitaEventSummary, updated after each event processed.