Skip to content

Commit 902bdd8

Browse files
authored
TRD calibration subdirectory added (#5894)
* TRD calibration subdirectory added - template for vDrift calibration - after global tracking angular differences between TRD-only tracks and tracklets are collected - small correction to always update to the correct pad plane during track following, since the pad row size depends also on the stack, not only on the layer * Remove copy-paste artifact (wrong comment)
1 parent b4ec9a5 commit 902bdd8

File tree

12 files changed

+326
-12
lines changed

12 files changed

+326
-12
lines changed

DataFormats/Detectors/TRD/include/DataFormatsTRD/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ constexpr float GRANULARITYTRKLSLOPE = 1.f / PADGRANULARITYTRKLSLOPE; // granula
5656

5757
// OS: Should this not be flexible for example in case of Kr calib?
5858
constexpr int TIMEBINS = 30; // the number of time bins
59+
constexpr int NBINSANGLEDIFF = 26; // the number of bins for the track angle used for the vDrift and ExB calibration based on the tracking (last bin is for under-/overflow entries)
5960

6061
// Trigger parameters
6162
constexpr double READOUT_TIME = 3000; // the time the readout takes, as 30 TB = 3 micro-s.

Detectors/TRD/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# submit itself to any jurisdiction.
1010

1111
add_subdirectory(base)
12+
add_subdirectory(calibration)
1213
add_subdirectory(simulation)
1314
add_subdirectory(reconstruction)
1415
add_subdirectory(macros)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Copyright CERN and copyright holders of ALICE O2.This software is distributed
2+
#under the terms of the GNU General Public License v3(GPL Version 3), copied
3+
#verbatim in the file "COPYING".
4+
#
5+
#See http: //alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
#In applying this license CERN does not waive the privileges and immunities
8+
#granted to it by virtue of its status as an Intergovernmental Organization or
9+
#submit itself to any jurisdiction.
10+
11+
o2_add_library(TRDCalibration
12+
SOURCES src/CalibVDrift.cxx
13+
PUBLIC_LINK_LIBRARIES O2::TRDBase
14+
O2::DataFormatsTRD)
15+
16+
o2_target_root_dictionary(TRDCalibration
17+
HEADERS include/TRDCalibration/CalibVDrift.h)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#ifndef ALICEO2_TRD_CALIBVDRIFT_H_
12+
#define ALICEO2_TRD_CALIBVDRIFT_H_
13+
14+
/// \file CalibVDrift.h
15+
/// \author Ole Schmidt, ole.schmidt@cern.ch
16+
17+
#include "DataFormatsTRD/Constants.h"
18+
#include <array>
19+
20+
namespace o2
21+
{
22+
namespace trd
23+
{
24+
25+
/// \brief VDrift calibration class
26+
///
27+
/// This class is used to determine chamber-wise vDrift values
28+
///
29+
/// origin: TRD
30+
/// \author Ole Schmidt, ole.schmidt@cern.ch
31+
32+
class CalibVDrift
33+
{
34+
public:
35+
/// default constructor
36+
CalibVDrift() = default;
37+
38+
/// default destructor
39+
~CalibVDrift() = default;
40+
41+
/// set input angular difference sums
42+
void setAngleDiffSums(float* input)
43+
{
44+
for (int i = 0; i < constants::MAXCHAMBER * constants::NBINSANGLEDIFF; ++i) {
45+
mAngleDiffSums[i] = input[i];
46+
}
47+
}
48+
49+
/// set input angular difference bin counters
50+
void setAngleDiffCounters(short* input)
51+
{
52+
for (int i = 0; i < constants::MAXCHAMBER * constants::NBINSANGLEDIFF; ++i) {
53+
mAngleDiffCounters[i] = input[i];
54+
}
55+
}
56+
57+
/// main processing function
58+
void process();
59+
60+
private:
61+
std::array<float, constants::MAXCHAMBER * constants::NBINSANGLEDIFF> mAngleDiffSums{}; ///< input TRD track to tracklet angular difference sums per bin
62+
std::array<short, constants::MAXCHAMBER * constants::NBINSANGLEDIFF> mAngleDiffCounters{}; ///< input bin counters
63+
};
64+
65+
} // namespace trd
66+
67+
} // namespace o2
68+
#endif
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file CalibVDrift.cxx
12+
/// \author Ole Schmidt, ole.schmidt@cern.ch
13+
14+
#include "TFile.h"
15+
#include "TH2F.h"
16+
17+
#include <fairlogger/Logger.h>
18+
19+
#include "TRDCalibration/CalibVDrift.h"
20+
21+
using namespace o2::trd;
22+
using namespace o2::trd::constants;
23+
24+
void CalibVDrift::process()
25+
{
26+
LOG(info) << "Started processing for vDrift calibration";
27+
28+
for (int iDet = 0; iDet < constants::MAXCHAMBER; ++iDet) {
29+
for (int iBin = 0; iBin < constants::NBINSANGLEDIFF; ++iBin) { // note: iBin = constants::NBINSANGLEDIFF - 1 is under-/overflow bin
30+
short nEntries = mAngleDiffCounters[iDet * constants::NBINSANGLEDIFF + iBin];
31+
float angleDiffSum = mAngleDiffSums[iDet * constants::NBINSANGLEDIFF + iBin];
32+
if (nEntries > 0) {
33+
LOGF(INFO, "Found %i entrie(s) in chamber %i, bin %i. Average angular deviation: %f", nEntries, iDet, iBin, angleDiffSum / nEntries);
34+
}
35+
}
36+
}
37+
38+
/*
39+
// as an example I loop over the input, create a histogram and write it to a file
40+
auto fOut = TFile::Open("trdcalibdummy.root", "recreate");
41+
auto hXY = std::make_unique<TH2F>("histDummy", "foo", 100, -60, 60, 100, 250, 400); // xy distribution of TRD space points
42+
for (int i = 0; i < mAngulerDeviationProf.size(); ++i) {
43+
hXY->Fill(mAngulerDeviationProf[i].mX[0], mAngulerDeviationProf[i].mR);
44+
}
45+
fOut->cd();
46+
hXY->Write();
47+
hXY.reset(); // delete the histogram before closing the output file
48+
fOut->Close();
49+
*/
50+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#ifdef __CLING__
12+
13+
#pragma link off all globals;
14+
#pragma link off all classes;
15+
#pragma link off all functions;
16+
17+
#pragma link C++ class o2::trd::CalibVDrift + ;
18+
19+
#endif

Detectors/TRD/workflow/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ o2_add_library(TRDWorkflow
2525
src/TRDTrackWriterSpec.cxx
2626
src/TRDTrackingWorkflow.cxx
2727
src/EntropyDecoderSpec.cxx
28-
src/EntropyEncoderSpec.cxx
29-
PUBLIC_LINK_LIBRARIES O2::Framework O2::DPLUtils O2::Steer O2::Algorithm O2::DataFormatsTRD O2::TRDSimulation O2::TRDReconstruction O2::DetectorsBase O2::SimulationDataFormat O2::TRDBase O2::GPUTracking O2::GlobalTrackingWorkflow)
28+
src/EntropyEncoderSpec.cxx
29+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DPLUtils O2::Steer O2::Algorithm O2::DataFormatsTRD O2::TRDSimulation O2::TRDReconstruction O2::DetectorsBase O2::SimulationDataFormat O2::TRDBase O2::TRDCalibration O2::GPUTracking O2::GlobalTrackingWorkflow)
3030

3131
#o2_target_root_dictionary(TRDWorkflow
3232
# HEADERS include/TRDWorkflow/TRDTrapSimulatorSpec.h)

Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Framework/Task.h"
1818
#include "TStopwatch.h"
1919
#include "TRDBase/GeometryFlat.h"
20+
#include "TRDCalibration/CalibVDrift.h"
2021
#include "GPUO2Interface.h"
2122
#include "GPUTRDTracker.h"
2223

@@ -41,6 +42,7 @@ class TRDGlobalTracking : public o2::framework::Task
4142
std::unique_ptr<GeometryFlat> mFlatGeo{nullptr}; ///< flat TRD geometry
4243
bool mUseMC{false}; ///< MC flag
4344
bool mUseTrackletTransform{false}; ///< if true, output from TrackletTransformer is used instead of uncalibrated Tracklet64 directly
45+
CalibVDrift mCalibVDrift{}; ///< steers the vDrift calibration
4446
TStopwatch mTimer;
4547
};
4648

Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "DataFormatsTRD/Tracklet64.h"
2323
#include "DataFormatsTRD/CalibratedTracklet.h"
2424
#include "DataFormatsTRD/TriggerRecord.h"
25+
#include "DataFormatsTRD/Constants.h"
2526

2627
// GPU header
2728
#include "GPUReconstruction.h"
@@ -68,6 +69,7 @@ void TRDGlobalTracking::init(InitContext& ic)
6869
mTracker->SetProcessPerTimeFrame();
6970
mTracker->SetNMaxCollisions(mRec->GetProcessingSettings().trdNMaxCollisions);
7071
mTracker->SetTrkltTransformNeeded(!mUseTrackletTransform);
72+
//mTracker->SetDoImpactAngleHistograms(true);
7173

7274
mRec->RegisterGPUProcessor(mTracker, false);
7375
mChainTracking->SetTRDGeometry(std::move(mFlatGeo));
@@ -99,7 +101,7 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
99101
int nTrackletsCal = 0;
100102

101103
if (mUseTrackletTransform) {
102-
cTrklts.emplace(pc.inputs().get<gsl::span<CalibratedTracklet>>("trdctracklets")); // MC labels associated to the input digits
104+
cTrklts.emplace(pc.inputs().get<gsl::span<CalibratedTracklet>>("trdctracklets"));
103105
cTrkltsPtr = &cTrklts.value();
104106
nTrackletsCal = cTrkltsPtr->size();
105107
LOGF(INFO, "Got %i calibrated tracklets as input", nTrackletsCal);
@@ -171,11 +173,18 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
171173
mTracker->SetTriggerRecordIndices(&(trdTriggerIndices[0]));
172174
mTracker->SetNCollisions(nCollisions);
173175
//mTracker->DumpTracks();
176+
mTracker->ResetImpactAngleHistograms();
174177
mTracker->DoTracking(mChainTracking);
175178
//mTracker->DumpTracks();
176179

177180
std::vector<GPUTRDTrack> tracksOut(mTracker->NTracks());
178181
std::copy(mTracker->Tracks(), mTracker->Tracks() + mTracker->NTracks(), tracksOut.begin());
182+
183+
// Temporary until it is transferred to its own DPL device for calibrations
184+
mCalibVDrift.setAngleDiffSums(mTracker->AngleDiffSums());
185+
mCalibVDrift.setAngleDiffCounters(mTracker->AngleDiffCounters());
186+
mCalibVDrift.process();
187+
179188
pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MATCHTRD", 0, Lifetime::Timeframe}, tracksOut);
180189

181190
mTimer.Stop();

GPU/GPUTracking/TRDTracking/GPUTRDInterfaces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class trackInterface<GPUTPCGMTrackParam> : public GPUTPCGMTrackParam
301301
GPUd() const float* getPar() const { return GetPar(); }
302302
GPUd() const float* getCov() const { return GetCov(); }
303303
GPUd() float getTime() const { return -1.f; }
304-
304+
GPUd() void resetCovariance(float s) { ResetCovariance(); }
305305
GPUd() void setAlpha(float alpha) { mAlpha = alpha; }
306306
GPUd() void set(float x, float alpha, const float param[5], const float cov[15])
307307
{

0 commit comments

Comments
 (0)