Skip to content

Commit 5983116

Browse files
mwinn2sawenzel
authored andcommitted
CLANG format
1 parent 656234f commit 5983116

6 files changed

Lines changed: 52 additions & 62 deletions

File tree

Detectors/MUON/MCH/Simulation/include/MCHSimulation/Digitizer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "SimulationDataFormat/MCTruthContainer.h"
2424
#include "DataFormatsMCH/ROFRecord.h"
2525

26-
2726
namespace o2
2827
{
2928
namespace mch
@@ -49,7 +48,7 @@ class Digitizer
4948
void fillOutputContainer(std::vector<Digit>& digits);
5049

5150
void setEventTime(double timeNS) { mEventTime = timeNS; }
52-
51+
5352
void setContinuous(bool val) { mContinuous = val; }
5453
bool isContinuous() const { return mContinuous; }
5554

Detectors/MUON/MCH/Simulation/src/Digitizer.cxx

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ int Digitizer::processHit(const Hit& hit, int detID, int eventTime)
123123
auto charge = resp.etocharge(hit.GetEnergyLoss());
124124

125125
//convert float ns time to BC counts
126-
auto time = int(eventTime/ 25.) & int(hit.GetTime() / 25.);
126+
auto time = int(eventTime / 25.) & int(hit.GetTime() / 25.);
127127
//FIXME: need to put the orbit and the bc into a TimeFrame information and not here
128128
//Digit::Time time;
129129
//time.sampaTime = hit.GetTime();
130130
//time.bunchCrossing = bc;
131131
//time.orbit = orbit;
132132

133-
134133
//transformation from global to local
135134
auto transformation = o2::mch::geo::transformationFromTGeoManager(*gGeoManager);
136135
auto t = transformation(detID);
@@ -184,7 +183,7 @@ int Digitizer::processHit(const Hit& hit, int detID, int eventTime)
184183

185184
/// FIXME: which time definition is used when calling this function?
186185
digits.emplace_back(detID, padid, signal, time);
187-
// Digit::Time dtime;
186+
// Digit::Time dtime;
188187
//dtime.sampaTime = static_cast<uint16_t>(time) & 0x3FF;
189188
++ndigits;
190189
}
@@ -206,7 +205,7 @@ void Digitizer::generateNoiseDigits()
206205
for (int i = 0; i < nNoisyPads; i++) {
207206
int padid = gRandom->Integer(nNoisyPads + 1);
208207
// FIXME: can we use eventTime as the digit time?
209-
time = int(time/25.);//not clear if ok
208+
time = int(time / 25.); //not clear if ok
210209
// time.sampa = 0; //not clear what to do...
211210
// time.bunchCrossing = bc;
212211
// time.orbit = orbit;
@@ -223,12 +222,12 @@ void Digitizer::generateNoiseDigits()
223222
//______________________________________________________________________
224223
void Digitizer::mergeDigits(std::vector<Digit>& rofdigits, std::vector<o2::MCCompLabel>& rofLabels, std::vector<int>& indexhelper)
225224
{
226-
std::vector<int> indices(rofdigits.size());//TODO problematic. since mDigits.reserve in mergeDi
227-
std::iota(begin(indices), end(indices), 0);//problem with iota if vector longer than number of non-trivial entries
225+
std::vector<int> indices(rofdigits.size()); //TODO problematic. since mDigits.reserve in mergeDi
226+
std::iota(begin(indices), end(indices), 0); //problem with iota if vector longer than number of non-trivial entries
228227
//labels go WRONG!
229228
std::sort(indices.begin(), indices.end(), [&rofdigits, this](int a, int b) {
230229
return (getGlobalDigit(rofdigits[a].getDetID(), rofdigits[a].getPadID()) < getGlobalDigit(rofdigits[b].getDetID(), rofdigits[b].getPadID()));
231-
});// this is ok!
230+
}); // this is ok!
232231

233232
auto sortedDigits = [rofdigits, &indices](int i) {
234233
return rofdigits[indices[i]];
@@ -245,13 +244,13 @@ void Digitizer::mergeDigits(std::vector<Digit>& rofdigits, std::vector<o2::MCCom
245244
rofdigits.reserve(sizedigits);
246245
rofLabels.clear();
247246
rofLabels.reserve(sizelabels);
248-
247+
249248
int count = mDigits.size();
250249

251250
int i = 0;
252251
while (i < indices.size()) {
253252
int j = i + 1;
254-
while (j < indices.size() && (getGlobalDigit(sortedDigits(i).getDetID(), sortedDigits(i).getPadID())) == (getGlobalDigit(sortedDigits(j).getDetID(), sortedDigits(j).getPadID())) && (std::fabs(sortedDigits(i).getTime() - sortedDigits(j).getTime()) < mDeltat)) {//important that time is unambiguous within one processing, i.e. that simulation only does one TF and that it passes a new processing
253+
while (j < indices.size() && (getGlobalDigit(sortedDigits(i).getDetID(), sortedDigits(i).getPadID())) == (getGlobalDigit(sortedDigits(j).getDetID(), sortedDigits(j).getPadID())) && (std::fabs(sortedDigits(i).getTime() - sortedDigits(j).getTime()) < mDeltat)) { //important that time is unambiguous within one processing, i.e. that simulation only does one TF and that it passes a new processing
255254
j++;
256255
}
257256
uint32_t adc{0};
@@ -261,12 +260,12 @@ void Digitizer::mergeDigits(std::vector<Digit>& rofdigits, std::vector<o2::MCCom
261260
for (int k = i; k < j; k++) {
262261
adc += sortedDigits(k).getADC();
263262
if (k == i) {
264-
rofLabels.emplace_back(sortedLabels(k).getTrackID(), sortedLabels(k).getEventID(), sortedLabels(k).getSourceID(), false);
265-
indexhelper.emplace_back(count);
263+
rofLabels.emplace_back(sortedLabels(k).getTrackID(), sortedLabels(k).getEventID(), sortedLabels(k).getSourceID(), false);
264+
indexhelper.emplace_back(count);
266265
} else {
267266
if ((sortedLabels(k).getTrackID() != sortedLabels(k - 1).getTrackID()) || (sortedLabels(k).getSourceID() != sortedLabels(k - 1).getSourceID())) {
268267
rofLabels.emplace_back(sortedLabels(k).getTrackID(), sortedLabels(k).getEventID(), sortedLabels(k).getSourceID(), false);
269-
indexhelper.emplace_back(count);
268+
indexhelper.emplace_back(count);
270269
}
271270
}
272271
}
@@ -289,36 +288,34 @@ void Digitizer::mergeDigits(std::vector<Digit>& digits, o2::dataformats::MCTruth
289288
//and not touch mDigits
290289
//always only doing the index from the start to the end of the ROF
291290
//mDigits only for one Rof used
292-
std::vector<Digit> rofDigits;// use accumDIgits for mDigits and pass digits
291+
std::vector<Digit> rofDigits; // use accumDIgits for mDigits and pass digits
293292
std::vector<o2::MCCompLabel> rofLabels;
294293
std::vector<int> indexhelper;
295-
for(int rofindex = 0; rofindex < rofs.size(); ++rofindex)
296-
{
297-
for (int index = rofs[rofindex].getFirstIdx(); index < (rofs[rofindex].getLastIdx()+1); ++index) {
298-
auto digit = digits.at(index);
299-
rofDigits.emplace_back(digit.getDetID(), digit.getPadID(), digit.getADC(), digit.getTime());
300-
}
301-
for (int index = rofs[rofindex].getFirstIdx(); index < (rofs[rofindex].getLastIdx()+1); ++index) {
302-
//at this stage label schould still have 1-to-1 corresponds in term of number to number of digits
303-
auto label = mcContainer.getElement(index);
304-
rofLabels.emplace_back(label.getTrackID(), label.getEventID(), label.getSourceID(), label.isFake());
305-
}
306-
//mergeDigits does simply merging within 1 ROF
307-
mergeDigits(rofDigits, rofLabels, indexhelper);
308-
rofs[rofindex].setDataRef(mDigits.size(), rofDigits.size());
309-
310-
mDigits.insert(std::end(mDigits), std::begin(rofDigits), std::end(rofDigits));
311-
mTrackLabels.insert(std::end(mTrackLabels), std::begin(rofLabels), std::end(rofLabels));
312-
rofDigits.clear();
313-
rofLabels.clear();
294+
for (int rofindex = 0; rofindex < rofs.size(); ++rofindex) {
295+
for (int index = rofs[rofindex].getFirstIdx(); index < (rofs[rofindex].getLastIdx() + 1); ++index) {
296+
auto digit = digits.at(index);
297+
rofDigits.emplace_back(digit.getDetID(), digit.getPadID(), digit.getADC(), digit.getTime());
314298
}
315-
316-
for(int labelindex=0; labelindex < mTrackLabels.size(); ++labelindex)
317-
{
318-
auto digitindex = indexhelper.at(labelindex);
319-
MCCompLabel label(mTrackLabels[labelindex].getTrackID(), mTrackLabels[labelindex].getEventID(), mTrackLabels[labelindex].getSourceID(), mTrackLabels[labelindex].isFake());
320-
mMCTruthOutputContainer.addElement(digitindex, label);
299+
for (int index = rofs[rofindex].getFirstIdx(); index < (rofs[rofindex].getLastIdx() + 1); ++index) {
300+
//at this stage label schould still have 1-to-1 corresponds in term of number to number of digits
301+
auto label = mcContainer.getElement(index);
302+
rofLabels.emplace_back(label.getTrackID(), label.getEventID(), label.getSourceID(), label.isFake());
321303
}
304+
//mergeDigits does simply merging within 1 ROF
305+
mergeDigits(rofDigits, rofLabels, indexhelper);
306+
rofs[rofindex].setDataRef(mDigits.size(), rofDigits.size());
307+
308+
mDigits.insert(std::end(mDigits), std::begin(rofDigits), std::end(rofDigits));
309+
mTrackLabels.insert(std::end(mTrackLabels), std::begin(rofLabels), std::end(rofLabels));
310+
rofDigits.clear();
311+
rofLabels.clear();
312+
}
313+
314+
for (int labelindex = 0; labelindex < mTrackLabels.size(); ++labelindex) {
315+
auto digitindex = indexhelper.at(labelindex);
316+
MCCompLabel label(mTrackLabels[labelindex].getTrackID(), mTrackLabels[labelindex].getEventID(), mTrackLabels[labelindex].getSourceID(), mTrackLabels[labelindex].isFake());
317+
mMCTruthOutputContainer.addElement(digitindex, label);
318+
}
322319
fillOutputContainer(digits);
323320

324321
provideMC(mcContainer);
@@ -330,7 +327,7 @@ void Digitizer::fillOutputContainer(std::vector<Digit>& digits)
330327
if (mDigits.empty()) {
331328
return;
332329
}
333-
330+
334331
digits.clear();
335332
digits.reserve(mDigits.size());
336333

Detectors/MUON/MCH/Workflow/src/DigitReaderSpec.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ class DigitsReaderDeviceDPL
100100

101101
private:
102102
std::unique_ptr<TFile> mFile{nullptr};
103-
TTree* mTree{nullptr}; // not owner
104-
std::vector<o2::mch::Digit>* mDigits{nullptr}; // not owner
103+
TTree* mTree{nullptr}; // not owner
104+
std::vector<o2::mch::Digit>* mDigits{nullptr}; // not owner
105105
o2::dataformats::MCTruthContainer<MCCompLabel>* mMCContainer{nullptr}; // not owner
106-
std::vector<o2::mch::ROFRecord>* mROFRecords{nullptr}; // not owner
106+
std::vector<o2::mch::ROFRecord>* mROFRecords{nullptr}; // not owner
107107
std::vector<header::DataDescription> mDescriptions{};
108108
int mState = 0;
109109
bool mUseMC = true;

Detectors/MUON/MCH/Workflow/src/DigitReaderSpec.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ namespace o2
2222
{
2323
namespace mch
2424
{
25-
framework::DataProcessorSpec getDigitReaderSpec(bool useMC, const char* baseDescription = "DATAMC");
25+
framework::DataProcessorSpec getDigitReaderSpec(bool useMC, const char* baseDescription = "DATAMC");
2626
}
2727
} // namespace o2
2828

29-
3029
#endif //O2_MCH_DIGITREADERSPEC_H

Detectors/MUON/MCH/Workflow/src/sim-digits-reader-workflow.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "DataFormatsMCH/ROFRecord.h"
2424
#include "DigitReaderSpec.h"
2525

26-
2726
using namespace o2::framework;
2827

2928
// we need to add workflow options before including Framework/runDataProcessing

Steer/DigitizerWorkflow/src/MCHDigitizerSpec.cxx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,25 @@ class MCHDPLDigitizerTask : public o2::base::BaseDPLDigitizer
7373
std::vector<o2::mch::ROFRecord> rofrecords;
7474
//NEED TO GET TIMEFRAME TIME as start time , is this the case automatically?
7575
o2::dataformats::MCTruthContainer<o2::MCCompLabel> labelAccum;
76-
// loop over all composite collisions given from context
76+
// loop over all composite collisions given from context
7777
// (aka loop over all the interaction records)
7878
for (int collID = 0; collID < irecords.size(); ++collID) {
79-
mDigitizer.setEventTime(irecords[collID].getTimeNS());//assume that event time is w.r.t. time frame beginning, to be verified
79+
mDigitizer.setEventTime(irecords[collID].getTimeNS()); //assume that event time is w.r.t. time frame beginning, to be verified
8080
// for each collision, loop over the constituents event and source IDs
8181
// (background signal merging is basically taking place here)
8282
for (auto& part : eventParts[collID]) {
8383
mDigitizer.setEventID(part.entryID);
8484
mDigitizer.setSrcID(part.sourceID);
85-
85+
8686
// get the hits for this event and this source
8787
std::vector<o2::mch::Hit> hits;
88-
88+
8989
context->retrieveHits(mSimChains, "MCHHit", part.sourceID, part.entryID, &hits);
9090
LOG(DEBUG) << "For collision " << collID << " eventID " << part.entryID << " found MCH " << hits.size() << " hits ";
9191

9292
std::vector<o2::mch::Digit> digits; // digits which get filled
9393
o2::dataformats::MCTruthContainer<o2::MCCompLabel> labels;
94-
95-
94+
9695
mDigitizer.process(hits, digits, labels);
9796
LOG(DEBUG) << "MCH obtained " << digits.size() << " digits ";
9897
for (auto& d : digits) {
@@ -106,21 +105,18 @@ class MCHDPLDigitizerTask : public o2::base::BaseDPLDigitizer
106105
LOG(DEBUG) << "labelAccum.getIndexedSize() " << labelAccum.getIndexedSize();
107106
LOG(DEBUG) << "labelAccum.getNElements() " << labelAccum.getNElements();
108107
LOG(DEBUG) << "Have " << digits.size() << " digits ";
109-
//problem for pile-up if events are not one after each other
110-
digitsperEvent += digits.size();
108+
//problem for pile-up if events are not one after each other
109+
digitsperEvent += digits.size();
111110
}
112-
113-
114-
if(rofrecords.size()!=0) startdigitEvent = rofrecords.back().getLastIdx()+1;
111+
112+
if (rofrecords.size() != 0)
113+
startdigitEvent = rofrecords.back().getLastIdx() + 1;
115114
rofrecords.emplace_back(irecords[collID], startdigitEvent, digitsperEvent);
116115
digitsperEvent = 0;
117-
118116
}
119-
120-
117+
121118
mDigitizer.mergeDigits(digitsAccum, labelAccum, rofrecords);
122119

123-
124120
LOG(DEBUG) << "Have " << labelAccum.getNElements() << " MCH labels "; //does not work out!
125121
pc.outputs().snapshot(Output{"MCH", "DIGITS", 0, Lifetime::Timeframe}, digitsAccum);
126122
pc.outputs().snapshot(Output{"MCH", "DIGITROFS", 0, Lifetime::Timeframe}, rofrecords);

0 commit comments

Comments
 (0)