Skip to content

Commit 5cf0776

Browse files
authored
EVB2 cleanup per review comments (#378)
* update EBMRD per #334 * update EBLAPPD per #336 * update EBSaver per #337 (except no-op functions) * update ANNIEEventTreeMaker per #339 * update LAPPDTreeMaker per #340 * update EBLoadRaw per #338 deferring proposed improvements to regex matching and path configs. * remove RingCounting models, load from pnfs path Removing the RingCounting v1.0.0 model here, but not pruning it from the git repo to avoid rewriting history. The config is updated to point to the model directory that already exists on pnfs rather than a user directory. * increment class version for Channel and LAPPDPulse * remove no-op tool LAPPDBSCharging * fix memory leak in LAPPDTimeAlignment Note: it may be more efficient to allocate this once rather than within the loop, but this is a minimal fix. * remove LAPPD offset script, updated in #356 * Update Channel.h only archive channelType if it exists in this version * Update LAPPDPulse.h Only archive pulseFollowTime and pulseFollowCharge if they exist in this version of the class ---------
1 parent 3f121c9 commit 5cf0776

22 files changed

Lines changed: 70 additions & 1442 deletions

File tree

DataModel/Channel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ class Channel : public SerialisableObject{
101101
ar & hv_card;
102102
ar & hv_channel;
103103
ar & status;
104-
ar & channelType;
104+
if(version > 0) ar & channelType;
105105
}
106106
}
107107

108108
};
109109

110+
BOOST_CLASS_VERSION(Channel, 1)
111+
110112
#endif

DataModel/LAPPDPulse.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ class LAPPDPulse : public Hit{
6868
ar & halfHeightTime;
6969
ar & halfEndTime;
7070
ar & baseline;
71-
ar & pulseFollowTime;
72-
ar & pulseFollowCharge;
71+
if(version>0){
72+
ar & pulseFollowTime;
73+
ar & pulseFollowCharge;
74+
}
7375
}
7476
}
7577
};
7678

79+
BOOST_CLASS_VERSION(LAPPDPulse, 1)
80+
7781
/* Derived classes, if there's a reason to have them. So far...not really
7882
7983
class TDCHit : public Hit {

UserTools/ANNIEEventTreeMaker/ANNIEEventTreeMaker.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,18 @@ bool ANNIEEventTreeMaker::Execute()
670670

671671
bool ANNIEEventTreeMaker::Finalise()
672672
{
673+
if (MCTruth_fill) {
674+
delete fTrueNeutCapVtxX;
675+
delete fTrueNeutCapVtxY;
676+
delete fTrueNeutCapVtxZ;
677+
delete fTrueNeutCapNucleus;
678+
delete fTrueNeutCapTime;
679+
delete fTrueNeutCapGammas;
680+
delete fTrueNeutCapE;
681+
delete fTrueNeutCapGammaE;
682+
delete fTruePrimaryPdgs;
683+
}
684+
673685
Log("ANNIEEventTreeMaker Tool: Got " + std::to_string(processedEvents) + " events", 0, ANNIEEventTreeMakerVerbosity);
674686
fOutput_tfile->cd();
675687
fANNIETree->Write();

UserTools/EBLAPPD/EBLAPPD.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ bool EBLAPPD::LoadLAPPDData()
276276

277277
bool EBLAPPD::Matching(int targetTrigger, int matchToTrack)
278278
{
279-
cout << "\033[1;34m******* EBLAPPD : Matching *******\033[0m" << endl;
279+
Log("\033[1;34m******* EBLAPPD : Matching *******\033[0m", v_message, verbosityEBLAPPD);
280280
Log("EBLAPPD: Matching LAPPD data with target trigger " + std::to_string(targetTrigger) + " in track " + std::to_string(matchToTrack), v_message, verbosityEBLAPPD);
281281

282282
std::map<int, std::vector<std::map<uint64_t, uint32_t>>> GroupedTriggersInTotal; // each map is a group of triggers, with the key is the target trigger word
@@ -308,7 +308,7 @@ bool EBLAPPD::Matching(int targetTrigger, int matchToTrack)
308308
int matchedTrack = 0;
309309
int matchedIndex = 0;
310310

311-
for (std::pair<int, std::vector<std::map<uint64_t, uint32_t>>> pair : GroupedTriggersInTotal)
311+
for (const std::pair<int, std::vector<std::map<uint64_t, uint32_t>>>& pair : GroupedTriggersInTotal)
312312
{
313313
int TrackTriggerWord = pair.first;
314314
if (matchedNumberInTrack.find(TrackTriggerWord) == matchedNumberInTrack.end())
@@ -318,13 +318,13 @@ bool EBLAPPD::Matching(int targetTrigger, int matchToTrack)
318318
// Log("EBLAPPD: Skipping TrackTriggerWord " + std::to_string(TrackTriggerWord), v_debug, verbosityEBLAPPD);
319319
continue;
320320
}
321-
vector<std::map<uint64_t, uint32_t>> GroupedTriggers = pair.second;
321+
const vector<std::map<uint64_t, uint32_t>>& GroupedTriggers = pair.second;
322322

323323
for (int j = 0; j < GroupedTriggers.size(); j++)
324324
{
325-
map<uint64_t, uint32_t> groupedTrigger = GroupedTriggers.at(j);
325+
const map<uint64_t, uint32_t>& groupedTrigger = GroupedTriggers.at(j);
326326
// itearte over all the grouped triggers, if the value is target trigger, then calculate the time difference
327-
for (std::pair<uint64_t, uint32_t> p : groupedTrigger)
327+
for (const std::pair<uint64_t, uint32_t>& p : groupedTrigger)
328328
{
329329
if (matchToAllTriggers || p.second == targetTrigger)
330330
{
@@ -379,4 +379,4 @@ bool EBLAPPD::Matching(int targetTrigger, int matchToTrack)
379379
}
380380

381381
return true;
382-
}
382+
}

UserTools/EBLoadRaw/EBLoadRaw.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ std::vector<std::string> EBLoadRaw::OrganizeRunParts(std::string FileList)
336336
OrganizedFiles.push_back(SortingVector.at(j).second);
337337
}
338338
}
339+
else
340+
{
341+
std::cerr << "EBLoadRaw::OrganizeRunParts: Failed to open file list " << FileList << std::endl;
342+
}
339343
// print the OrganizedFiles
340344
for (int i = 0; i < (int)OrganizedFiles.size(); i++)
341345
{

UserTools/EBMRD/EBMRD.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ bool EBMRD::Execute()
4545
Log("EBMRD: Current buffer size is " + std::to_string(MRDEventsBuffer.size()), v_message, verbosityEBMRD);
4646
// loop the MRDEvents, save every event to MRDEventsBuffer if it's not already in the buffer
4747
int newLoadedEvents = 0;
48-
for (std::pair<uint64_t, std::vector<std::pair<unsigned long, int>>> p : MRDEvents)
48+
for (const std::pair<uint64_t, std::vector<std::pair<unsigned long, int>>>& p : MRDEvents)
4949
{
50-
uint64_t MTCtime = p.first;
51-
std::vector<std::pair<unsigned long, int>> WaveMap = p.second;
50+
const uint64_t MTCtime = p.first;
51+
const std::vector<std::pair<unsigned long, int>>& WaveMap = p.second;
5252
// if find the MTCtime in the PairedMRDTimeStamps, then skip
5353
if (PairedMRDTimeStamps.size() > 0)
5454
{
5555
bool skip = false;
56-
for (std::pair<int, std::vector<uint64_t>> pair : PairedMRDTimeStamps)
56+
for (const std::pair<int, std::vector<uint64_t>>& pair : PairedMRDTimeStamps)
5757
{
58-
for (uint64_t t : pair.second)
58+
for (const uint64_t t : pair.second)
5959
{
6060
if (t == MTCtime)
6161
{
@@ -135,7 +135,7 @@ bool EBMRD::Finalise()
135135

136136
bool EBMRD::Matching(int targetTrigger, int matchToTrack)
137137
{
138-
cout << "\033[1;34m******* EBMRD : Matching *******\033[0m" << endl;
138+
Log("\033[1;34m******* EBMRD : Matching *******\033[0m", v_message, verbosityEBMRD);
139139
std::map<int, std::vector<std::map<uint64_t, uint32_t>>> GroupedTriggersInTotal; // each map is a group of triggers, with the key is the target trigger word
140140
m_data->CStore.Get("GroupedTriggersInTotal", GroupedTriggersInTotal);
141141

@@ -148,20 +148,20 @@ bool EBMRD::Matching(int targetTrigger, int matchToTrack)
148148
// in each group of trigger, find the target trigger word and it's time
149149
// fine the minimum time difference, if smaller than matchTolerance_ns, then save the time to PairedCTCTimeStamps and PairedMRDTimeStamps
150150
int loopNum = 0;
151-
for (std::pair<uint64_t, std::vector<std::pair<unsigned long, int>>> mrdpair : MRDEventsBuffer)
151+
for (const std::pair<uint64_t, std::vector<std::pair<unsigned long, int>>>& mrdpair : MRDEventsBuffer)
152152
{
153153
if (verbosityEBMRD > 11)
154154
cout << "******************EBMRD: new MRD event: " << loopNum << endl;
155-
uint64_t MTCtime = mrdpair.first;
156-
std::vector<std::pair<unsigned long, int>> WaveMap = mrdpair.second;
155+
const uint64_t MTCtime = mrdpair.first;
156+
const std::vector<std::pair<unsigned long, int>>& WaveMap = mrdpair.second;
157157
// set minDT to 5 min
158158
uint64_t minDT = 5 * 60 * 1e9;
159159
uint64_t minDTTrigger = 0;
160160
uint64_t dt = 0;
161161
uint32_t matchedTrigWord = 0;
162162
int matchedTrack = 0;
163163
int matchedIndex = 0;
164-
for (std::pair<int, std::vector<std::map<uint64_t, uint32_t>>> pair : GroupedTriggersInTotal)
164+
for (const std::pair<int, std::vector<std::map<uint64_t, uint32_t>>>& pair : GroupedTriggersInTotal)
165165
{
166166
int TrackTriggerWord = pair.first;
167167
if (TrackTriggerWord != matchToTrack && !matchToAllTriggers)
@@ -172,13 +172,13 @@ bool EBMRD::Matching(int targetTrigger, int matchToTrack)
172172
if (matchedNumberInTrack.find(TrackTriggerWord) == matchedNumberInTrack.end())
173173
matchedNumberInTrack.emplace(TrackTriggerWord, 0);
174174

175-
vector<std::map<uint64_t, uint32_t>> groupedTriggers = pair.second;
175+
const vector<std::map<uint64_t, uint32_t>>& groupedTriggers = pair.second;
176176

177177
for (int i = 0; i < groupedTriggers.size(); i++)
178178
{
179-
map<uint64_t, uint32_t> groupedTrigger = groupedTriggers.at(i);
179+
const map<uint64_t, uint32_t>& groupedTrigger = groupedTriggers.at(i);
180180
// itearte over all the grouped triggers, if the value is target trigger, then calculate the time difference
181-
for (std::pair<uint64_t, uint32_t> p : groupedTrigger)
181+
for (const std::pair<uint64_t, uint32_t>& p : groupedTrigger)
182182
{
183183
if (matchToAllTriggers || p.second == targetTrigger)
184184
{
@@ -234,4 +234,4 @@ bool EBMRD::Matching(int targetTrigger, int matchToTrack)
234234
}
235235

236236
return true;
237-
}
237+
}

UserTools/EBSaver/EBSaver.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,10 @@ bool EBSaver::Initialise(std::string configfile, DataModel &data)
6464
m_data->CStore.Get("AmBeTriggerMain", AmBeTriggerMain);
6565
m_data->CStore.Get("PPSMain", PPSMain);
6666

67-
InProgressHits = new std::map<uint64_t, std::map<unsigned long, std::vector<Hit>> *>;
68-
InProgressChkey = new std::map<uint64_t, std::vector<unsigned long>>;
69-
InProgressRecoADCHits = new std::map<uint64_t, std::map<unsigned long, std::vector<std::vector<ADCPulse>>>>;
70-
InProgressRecoADCHitsAux = new std::map<uint64_t, std::map<unsigned long, std::vector<std::vector<ADCPulse>>>>;
71-
InProgressHitsAux = new std::map<uint64_t, std::map<unsigned long, std::vector<Hit>> *>;
72-
FinishedRawAcqSize = new std::map<uint64_t, std::map<unsigned long, std::vector<int>>>;
73-
74-
RWMRawWaveforms = new std::map<uint64_t, std::vector<uint16_t>>;
75-
BRFRawWaveforms = new std::map<uint64_t, std::vector<uint16_t>>;
76-
7767
if (saveBeamInfo)
7868
{
7969
Log("EBSaver: saveBeamInfo is true, loading Beam Info", v_message, verbosityEBSaver);
80-
LoadBeamInfo();
70+
return LoadBeamInfo();
8171
}
8272

8373
return true;
@@ -1304,16 +1294,25 @@ void EBSaver::BuildEmptyLAPPDData()
13041294
ANNIEEvent->Set("LAPPDTS_PPSMissing", LAPPDTS_PPSMissing);
13051295
}
13061296

1307-
void EBSaver::LoadBeamInfo()
1297+
bool EBSaver::LoadBeamInfo()
13081298
{
13091299
TFile *file = new TFile(beamInfoFileName.c_str(), "READ");
1300+
1301+
if (file->IsZombie()) {
1302+
delete file;
1303+
Log("EBSaver: Failed to load beam info from file with name: " + beamInfoFileName, v_error, verbosityEBSaver);
1304+
return false;
1305+
}
1306+
13101307
TTree *tree;
13111308
file->GetObject("BeamTree", tree);
13121309

13131310
if (!tree)
13141311
{
1315-
cout << "EBSaver: Failed to load beam info from file with name: " << beamInfoFileName << endl;
1316-
return;
1312+
file->Close();
1313+
delete file;
1314+
Log("EBSaver: Failed to load beam info from file with name: " + beamInfoFileName, v_error, verbosityEBSaver);
1315+
return false;
13171316
}
13181317

13191318
// copy from IFBeamDBInterfaceV2.cpp
@@ -1401,7 +1400,9 @@ void EBSaver::LoadBeamInfo()
14011400

14021401
Log("EBSaver: Finished loading beam info from " + beamInfoFileName, v_message, verbosityEBSaver);
14031402

1404-
return;
1403+
file->Close();
1404+
delete file;
1405+
return true;
14051406
}
14061407

14071408
bool EBSaver::SaveBeamInfo(uint64_t TriggerTime)

UserTools/EBSaver/EBSaver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class EBSaver : public Tool
5959
void BuildEmptyMRDData();
6060
void BuildEmptyLAPPDData();
6161

62-
void LoadBeamInfo();
62+
bool LoadBeamInfo();
6363

6464
private:
6565
int saveRunNumber;

UserTools/Factory/Factory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ if (tool=="ProcessedLAPPDFilter") ret=new ProcessedLAPPDFilter;
186186
if (tool=="BeamQuality") ret=new BeamQuality;
187187
if (tool=="FitRWMWaveform") ret=new FitRWMWaveform;
188188
if (tool=="LAPPDLoadTXT") ret=new LAPPDLoadTXT;
189-
if (tool=="LAPPDBSCharging") ret=new LAPPDBSCharging;
190189
if (tool=="MuonFitter") ret=new MuonFitter;
191190
if (tool=="BackTracker") ret=new BackTracker;
192191
if (tool=="PrintDQ") ret=new PrintDQ;

UserTools/LAPPDBSCharging/LAPPDBSCharging.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)