Skip to content

Commit 6dd970a

Browse files
chiarazampollishahor02
authored andcommitted
Using gsl::span to retrieve input
Adjusting commented out lines and logs. clang format.
1 parent 091fbfb commit 6dd970a

2 files changed

Lines changed: 20 additions & 30 deletions

File tree

‎Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx‎

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void TOFChannelData::print(int isect) const
123123
LOG(INFO) << "Number of entries in histogram: " << boost::histogram::algorithm::sum(mHisto[isect]);
124124
for (auto&& x : indexed(mHisto[isect])) { // does not work also when I use indexed(*(mHisto[sector]))
125125
cnt++;
126-
//LOG(INFO) << " c " << cnt << " i " << x.index(0) << " j " << x.index(1) << " b0 " << x.bin(0) << " b1 " << x.bin(1) << " val= " << *x << "|" << x.get();
126+
LOG(DEBUG) << " c " << cnt << " i " << x.index(0) << " j " << x.index(1) << " b0 " << x.bin(0) << " b1 " << x.bin(1) << " val= " << *x << "|" << x.get();
127127
if (x.get() > 0) {
128128
LOG(INFO) << "x = " << x.get() << " c " << cnt;
129129
}
@@ -148,12 +148,11 @@ int TOFChannelData::findBin(float v) const
148148
if (v == mRange)
149149
v -= 1.e-1;
150150

151-
/*
152-
LOG(INFO) << "In FindBin, v = : " << v;
153-
LOG(INFO) << "bin0 limits: lower = " << mHisto[0].axis(0).bin(0).lower() << ", upper = " << mHisto[0].axis(0).bin(0).upper();
154-
LOG(INFO) << "bin1000 limits: lower = " << mHisto[0].axis(0).bin(mNBins-1).lower() << ", upper = " << mHisto[0].axis(0).bin(mNBins-1).upper();
155-
LOG(INFO) << "v = " << v << " is in bin " << mHisto[0].axis(0).index(v);
156-
*/
151+
LOG(DEBUG) << "In FindBin, v = : " << v;
152+
LOG(DEBUG) << "bin0 limits: lower = " << mHisto[0].axis(0).bin(0).lower() << ", upper = " << mHisto[0].axis(0).bin(0).upper();
153+
LOG(DEBUG) << "bin1000 limits: lower = " << mHisto[0].axis(0).bin(mNBins - 1).lower() << ", upper = " << mHisto[0].axis(0).bin(mNBins - 1).upper();
154+
LOG(DEBUG) << "v = " << v << " is in bin " << mHisto[0].axis(0).index(v);
155+
157156
return mHisto[0].axis(0).index(v);
158157
}
159158

@@ -175,28 +174,23 @@ float TOFChannelData::integral(int chmin, int chmax, float binmin, float binmax)
175174

176175
int chinsectormin = chmin % o2::tof::Geo::NPADSXSECTOR;
177176
int chinsectormax = chmax % o2::tof::Geo::NPADSXSECTOR;
178-
//LOG(INFO) << "Calculating integral for channel " << ich << " which is in sector " << sector
179-
// << " (channel in sector is " << chinsector << ")";;
180-
// LOG(INFO) << "Bin min = " << binmin << ", binmax = " << binmax <<
181-
// ", chmin = " << chmin << ", chmax = " << chmax <<
182-
// ", chinsectormin = " << chinsectormin << ", chinsector max = " << chinsectormax;
183177

184178
float res2 = 0;
185-
//TStopwatch t3;
179+
TStopwatch t3;
186180
int ind = -1;
187181
int binxmin = findBin(binmin);
188182
int binxmax = findBin(binmax);
189183
LOG(DEBUG) << "binxmin = " << binxmin << ", binxmax = " << binxmax;
190-
//t3.Start();
184+
t3.Start();
191185
for (unsigned j = chinsectormin; j <= chinsectormax; ++j) {
192186
for (unsigned i = binxmin; i <= binxmax; ++i) {
193187
const auto& v = mHisto[sector].at(i, j);
194188
res2 += v;
195189
}
196190
}
197-
//t3.Stop();
198-
//LOG(DEBUG) << "Time for integral looping over axis (result = " << res2 << "):";
199-
//t3.Print();
191+
t3.Stop();
192+
LOG(DEBUG) << "Time for integral looping over axis (result = " << res2 << "):";
193+
t3.Print();
200194

201195
return res2;
202196

@@ -303,23 +297,19 @@ float TOFChannelData::integral(int chmin, int chmax, int binxmin, int binxmax) c
303297

304298
int chinsectormin = chmin % o2::tof::Geo::NPADSXSECTOR;
305299
int chinsectormax = chmax % o2::tof::Geo::NPADSXSECTOR;
306-
//LOG(INFO) << "Calculating integral for channel " << ich << " which is in sector " << sector
307-
// << " (channel in sector is " << chinsector << ")";;
308-
//LOG(INFO) << "Bin min = " << binmin << ", binmax = " << binmax <<
309-
// ", chmin = " << chmin << ", chmax" << chmax <<
310-
// ", chinsectormin = " << chinsector min << ", chinsector max = " << chinsectormax;
300+
311301
float res2 = 0;
312-
//TStopwatch t3;
313-
//t3.Start();
302+
TStopwatch t3;
303+
t3.Start();
314304
for (unsigned j = chinsectormin; j <= chinsectormax; ++j) {
315305
for (unsigned i = binxmin; i <= binxmax; ++i) {
316306
const auto& v = mHisto[sector].at(i, j);
317307
res2 += v;
318308
}
319309
}
320-
//t3.Stop();
321-
//LOG(DEBUG) << "Time for integral looping over axis (result = " << res2 << "):";
322-
//t3.Print();
310+
t3.Stop();
311+
LOG(DEBUG) << "Time for integral looping over axis (result = " << res2 << "):";
312+
t3.Print();
323313
return res2;
324314

325315
/* // all that is below is alternative methods, all proved to be slower

‎Detectors/TOF/calibration/testWorkflow/TOFCalibCollectorWriterSpec.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class TOFCalibCollectorWriter : public o2::framework::Task
5050

5151
void run(o2::framework::ProcessingContext& pc) final
5252
{
53-
auto collectedInfo = pc.inputs().get<std::vector<o2::dataformats::CalibInfoTOFshort>>("collectedInfo");
54-
auto entriesPerChannel = pc.inputs().get<std::array<int, Geo::NCHANNELS>>("entriesCh");
53+
auto collectedInfo = pc.inputs().get<gsl::span<o2::dataformats::CalibInfoTOFshort>>("collectedInfo");
54+
auto entriesPerChannel = pc.inputs().get<gsl::span<int>>("entriesCh");
5555
int offsetStart = 0;
5656
for (int ich = 0; ich < o2::tof::Geo::NCHANNELS; ich++) {
5757
mTOFCalibInfoOut.clear();
5858
if (entriesPerChannel[ich] > 0) {
5959
mTOFCalibInfoOut.resize(entriesPerChannel[ich]);
60-
auto subSpanVect = gsl::span<const o2::dataformats::CalibInfoTOFshort>(&collectedInfo[offsetStart], entriesPerChannel[ich]);
60+
auto subSpanVect = collectedInfo.subspan(offsetStart, entriesPerChannel[ich]);
6161
memcpy(&mTOFCalibInfoOut[0], subSpanVect.data(), sizeof(o2::dataformats::CalibInfoTOFshort) * subSpanVect.size());
6262
const o2::dataformats::CalibInfoTOFshort* tmp = subSpanVect.data();
6363
}

0 commit comments

Comments
 (0)