Skip to content

Commit 7035ff8

Browse files
matthias-kleinerdavidrohr
authored andcommitted
TPC gain map using tracks: use every nth TF
- some other small changes
1 parent b94e9dc commit 7035ff8

4 files changed

Lines changed: 33 additions & 21 deletions

File tree

Detectors/TPC/calibration/doc/CalibPadGainTracks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Histogram options:
1313
--reldEdxMax Maximum x coordinate of the histogram for Q/(dE/dx)
1414
--underflowBin Using under flow bin
1515
--overflowBin Using under flow bin
16+
--useEveryNthTF Use only every nth TF
1617
1718
Track cuts:
1819
--momMin Minimum momentum of the tracks
@@ -31,7 +32,6 @@ The workflow `o2-tpc-calibrator-gainmap-tracks` should run in an aggregation nod
3132
```
3233
--tf-per-slot Number of TFs per calibration slot
3334
--max-delay Number of slots in past to consider
34-
--ccdb-uri URI for the CCDB (default URI will be used)
3535
3636
--min-entries Minimum number of entries per pad-by-pad histogram which are required
3737
--lowTrunc Lower truncation range for calculating the residual gain from the pad-by-pad histogram
@@ -46,8 +46,8 @@ The full residual gainmap extraction workflow can be executed in the following w
4646

4747
```
4848
o2-tpc-file-reader --input-type "clusters,tracks" --disable-mc \
49-
| o2-tpc-calib-gainmap-tracks -b --publish-after-tfs 100 --overflowBin true --debug true \
50-
| o2-tpc-calibrator-gainmap-tracks --ccdb-uri "http://localhost:8080" --min-entries 0 --tf-per-slot 100 --file-dump true --shm-segment-size 100000000000
49+
| o2-tpc-calib-gainmap-tracks --publish-after-tfs 100 --overflowBin true --condition-tf-per-query -1 --debug true \
50+
| o2-tpc-calibrator-gainmap-tracks --min-entries 0 --tf-per-slot 100 --file-dump true --shm-segment-size 100000000000 -b
5151
```
5252

5353

@@ -66,6 +66,6 @@ For the EPN start the `o2-tpc-calib-gainmap-tracks` workflow in a new shell:
6666

6767
```
6868
o2-tpc-file-reader --input-type "clusters,tracks" --disable-mc \
69-
| o2-tpc-calib-gainmap-tracks --publish-after-tfs 100 --overflowBin true \
69+
| o2-tpc-calib-gainmap-tracks --publish-after-tfs 100 --overflowBin true --condition-tf-per-query -1 \
7070
| o2-dpl-output-proxy --channel-config "name=downstream,method=connect,address=tcp://localhost:30453,type=push,transport=zeromq" --dataspec downstream:TPC/TRACKGAINHISTOS -b
7171
```

Detectors/TPC/calibration/include/TPCCalibration/CalibPadGainTracks.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class CalibPadGainTracks : public CalibPadGainTracksBase
194194
gsl::span<const TPCClRefElem>* mTPCTrackClIdxVecInput{nullptr}; ///<! input vector with TPC tracks cluster indicies
195195
const o2::tpc::ClusterNativeAccess* mClusterIndex{nullptr}; ///<! needed to access clusternative with tpctracks
196196
std::vector<unsigned char> mBufVec; ///<! buffer for filling shared cluster map
197-
unsigned char* mClusterShMapTPC{nullptr}; ///< externally set TPC clusters sharing map
197+
unsigned char* mClusterShMapTPC{nullptr}; ///<! externally set TPC clusters sharing map
198198
DEdxType mMode = dedxTrack; ///< normalization type: type=DedxTrack use truncated mean, type=DedxBB use value from BB fit
199199
DEdxRegion mDedxRegion = stack; ///< using the dE/dx per chamber, stack or per sector
200200
float mField{-5}; ///< Magnetic field in kG, used for track propagation
@@ -206,6 +206,7 @@ class CalibPadGainTracks : public CalibPadGainTracksBase
206206
ChargeType mChargeType{ChargeType::Max}; ///< charge type which is used for calculating the dE/dx and filling the pad-by-pad histograms
207207
std::vector<std::vector<float>> mDEdxBuffer{}; ///<! memory for dE/dx
208208
std::vector<std::tuple<unsigned char, unsigned char, unsigned char, float>> mClTrk; ///<! memory for cluster informations
209+
std::vector<float> mDedxTmp{}; ///<! memory for dE/dx calculation
209210
std::unique_ptr<CalPad> mGainMapRef; ///<! static Gain map object used for correcting the cluster charge
210211
std::unique_ptr<CalibdEdxTrackTopologyPol> mCalibTrackTopologyPol; ///<! calibration container for the cluster charge
211212
std::unique_ptr<o2::gpu::TPCFastTransform> mFastTransform; ///<! fast transform for refitting the track
@@ -228,10 +229,9 @@ class CalibPadGainTracks : public CalibPadGainTracksBase
228229
float getTrackTopologyCorrectionPol(const o2::tpc::TrackTPC& track, const o2::tpc::ClusterNative& cl, const unsigned int region, const float charge) const;
229230

230231
/// get the truncated mean for input vector and the truncation range low*nCl<nCl<high*nCl
231-
/// \param vCharge vector containing all qmax values of the track
232232
/// \param low lower cluster cut of 0.05*nCluster
233233
/// \param high higher cluster cut of 0.6*nCluster
234-
std::vector<float> getTruncMean(std::vector<std::vector<float>>& vCharge, float low = 0.05f, float high = 0.6f) const;
234+
void getTruncMean(float low = 0.05f, float high = 0.6f);
235235

236236
/// Helper function for drawing the reference gain map
237237
void drawRefGainMapHelper(const bool type, const Sector sector, const std::string filename, const float minZ, const float maxZ) const;

Detectors/TPC/calibration/src/CalibPadGainTracks.cxx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ void CalibPadGainTracks::processTrack(o2::tpc::TrackTPC track, o2::gpu::GPUO2Int
165165
}
166166

167167
if (mMode == dedxTrack) {
168-
const auto dedx = getTruncMean(mDEdxBuffer);
168+
getTruncMean();
169169

170170
// set the dEdx
171171
for (auto& x : mClTrk) {
172172
const unsigned char globRow = std::get<1>(x);
173173
const int region = Mapper::REGION[globRow];
174174
const int indexBuffer = getdEdxBufferIndex(region);
175175

176-
const float dedxTmp = dedx[indexBuffer];
176+
const float dedxTmp = mDedxTmp[indexBuffer];
177177
if (dedxTmp <= 0) {
178178
continue;
179179
}
@@ -193,15 +193,15 @@ void CalibPadGainTracks::processTrack(o2::tpc::TrackTPC track, o2::gpu::GPUO2Int
193193
}
194194
}
195195

196-
std::vector<float> CalibPadGainTracks::getTruncMean(std::vector<std::vector<float>>& vCharge, float low, float high) const
196+
void CalibPadGainTracks::getTruncMean(float low, float high)
197197
{
198-
std::vector<float> dedx;
199-
dedx.reserve(vCharge.size());
198+
mDedxTmp.clear();
199+
mDedxTmp.reserve(mDEdxBuffer.size());
200200
// returns the truncated mean for input vector
201-
for (auto& charge : vCharge) {
201+
for (auto& charge : mDEdxBuffer) {
202202
const int nClustersUsed = static_cast<int>(charge.size());
203203
if (nClustersUsed < mMinClusters) {
204-
dedx.emplace_back(-1);
204+
mDedxTmp.emplace_back(-1);
205205
continue;
206206
}
207207

@@ -211,15 +211,14 @@ std::vector<float> CalibPadGainTracks::getTruncMean(std::vector<std::vector<floa
211211
const int endInd = static_cast<int>(high * nClustersUsed);
212212

213213
if (endInd <= startInd) {
214-
dedx.emplace_back(-1);
214+
mDedxTmp.emplace_back(-1);
215215
continue;
216216
}
217217

218218
const float dEdx = std::accumulate(charge.begin() + startInd, charge.begin() + endInd, 0.f);
219219
const int nClustersTrunc = endInd - startInd; // count number of clusters
220-
dedx.emplace_back(dEdx / nClustersTrunc);
220+
mDedxTmp.emplace_back(dEdx / nClustersTrunc);
221221
}
222-
return dedx;
223222
}
224223

225224
float CalibPadGainTracks::getTrackTopologyCorrection(const o2::tpc::TrackTPC& track, const unsigned int region) const

Detectors/TPC/workflow/include/TPCWorkflow/TPCCalibPadGainTracksSpec.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class TPCCalibPadGainTracksDevice : public o2::framework::Task
7171
assert(chargeType == 0 || chargeType == 1);
7272
mPadGainTracks.setChargeType(static_cast<ChargeType>(chargeType));
7373

74+
mUseEveryNthTF = ic.options().get<int>("useEveryNthTF");
75+
if (mUseEveryNthTF <= 0) {
76+
mUseEveryNthTF = 1;
77+
}
78+
7479
const std::string gainMapFile = ic.options().get<std::string>("gainMapFile");
7580
if (!gainMapFile.empty()) {
7681
LOGP(info, "Loading GainMap from file {}", gainMapFile);
@@ -124,15 +129,20 @@ class TPCCalibPadGainTracksDevice : public o2::framework::Task
124129

125130
void run(o2::framework::ProcessingContext& pc) final
126131
{
127-
++mProcessedTFs;
132+
const auto currentTF = processing_helpers::getCurrentTF(pc);
133+
if (mTFCounter++ % mUseEveryNthTF) {
134+
LOGP(info, "Skipping TF {}", currentTF);
135+
return;
136+
}
137+
128138
auto tracks = pc.inputs().get<gsl::span<o2::tpc::TrackTPC>>("trackTPC");
129139
auto clRefs = pc.inputs().get<gsl::span<o2::tpc::TPCClRefElem>>("trackTPCClRefs");
130140
const auto& clusters = getWorkflowTPCInput(pc);
131141
const auto nTracks = tracks.size();
132142
if (nTracks == 0) {
133143
return;
134144
}
135-
LOGP(info, "Processing TF {} with {} tracks", processing_helpers::getCurrentTF(pc), nTracks);
145+
LOGP(info, "Processing TF {} with {} tracks", currentTF, nTracks);
136146

137147
if (!mDisablePolynomialsCCDB) {
138148
pc.inputs().get<o2::tpc::CalibdEdxTrackTopologyPolContainer*>("tpctopologygain");
@@ -145,12 +155,12 @@ class TPCCalibPadGainTracksDevice : public o2::framework::Task
145155

146156
mPadGainTracks.setMembers(&tracks, &clRefs, clusters->clusterIndex);
147157
mPadGainTracks.processTracks();
148-
158+
++mProcessedTFs;
149159
if ((mPublishAfter && (mProcessedTFs % mPublishAfter) == 0)) {
150160
LOGP(info, "Publishing after {} TFs", mProcessedTFs);
151161
mProcessedTFs = 0;
152162
if (mDebug) {
153-
mPadGainTracks.dumpToFile(fmt::format("calPadGain_TF{}.root", processing_helpers::getCurrentTF(pc)).data());
163+
mPadGainTracks.dumpToFile(fmt::format("calPadGain_TF{}.root", currentTF).data());
154164
}
155165
sendOutput(pc.outputs());
156166
}
@@ -162,8 +172,10 @@ class TPCCalibPadGainTracksDevice : public o2::framework::Task
162172
const bool mUseLastExtractedMapAsReference{false}; ///< using the last extracted gain map as the reference map which will be applied
163173
bool mDisablePolynomialsCCDB{false}; ///< do not load the polynomials from the CCDB
164174
uint32_t mProcessedTFs{0}; ///< counter to keep track of the processed TFs
175+
uint32_t mTFCounter{0}; ///< counter to keep track of the TFs
165176
CalibPadGainTracks mPadGainTracks{false}; ///< class for creating the pad-by-pad gain map
166177
bool mUsingDefaultGainMapForFirstIter{true}; ///< using no reference gain map for the first iteration
178+
unsigned int mUseEveryNthTF{1}; ///< process every Nth TF only
167179

168180
void sendOutput(DataAllocator& output)
169181
{
@@ -215,6 +227,7 @@ DataProcessorSpec getTPCCalibPadGainTracksSpec(const uint32_t publishAfterTFs, c
215227
{"dedxType", VariantType::Int, 0, {"recalculating the dE/dx (0), using it from tracking (1)"}},
216228
{"chargeType", VariantType::Int, 0, {"Using qMax (0) or qTot (1) for the dE/dx and the pad-by-pad histograms"}},
217229
{"propagateTrack", VariantType::Bool, false, {"Propagating the track instead of performing a refit for obtaining track parameters."}},
230+
{"useEveryNthTF", VariantType::Int, 10, {"Using only a fraction of the data: 1: Use every TF, 10: Use only every tenth TF."}},
218231
}}; // end DataProcessorSpec
219232
}
220233

0 commit comments

Comments
 (0)