Skip to content

Commit f8e088e

Browse files
matthias-kleinerktf
authored andcommitted
Pad-by-pad gain calibration using tracks as input
This commit adds a class which allows to extract pad-by-pad gain variations starting from tracks as input. The idea is to use this in future for monitoring short term fluctuations of the gain topology to monitor the GEM amplification stability.
1 parent 98b1089 commit f8e088e

6 files changed

Lines changed: 1345 additions & 2 deletions

File tree

Detectors/TPC/calibration/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ o2_add_library(TPCCalibration
1818
src/CalibPulserParam.cxx
1919
src/CalibTreeDump.cxx
2020
src/DigitDump.cxx
21+
src/CalibPadGainTracks.cxx
2122
PUBLIC_LINK_LIBRARIES O2::DataFormatsTPC O2::TPCBase
2223
O2::TPCReconstruction ROOT::Minuit
2324
ms_gsl::ms_gsl)
@@ -29,7 +30,9 @@ o2_target_root_dictionary(TPCCalibration
2930
include/TPCCalibration/CalibPedestalParam.h
3031
include/TPCCalibration/CalibPulserParam.h
3132
include/TPCCalibration/CalibTreeDump.h
32-
include/TPCCalibration/DigitDump.h)
33+
include/TPCCalibration/DigitDump.h
34+
include/TPCCalibration/CalibPadGainTracks.h
35+
include/TPCCalibration/FastHisto.h)
3336

3437
o2_add_executable(calib-pedestal
3538
COMPONENT_NAME tpc
@@ -57,4 +60,6 @@ o2_add_test_root_macro(macro/runPulser.C
5760
o2_add_test_root_macro(macro/dumpDigits.C
5861
PUBLIC_LINK_LIBRARIES O2::TPCCalibration
5962
LABELS tpc)
60-
63+
o2_add_test_root_macro(macro/extractGainMap.C
64+
PUBLIC_LINK_LIBRARIES O2::TPCCalibration
65+
LABELS tpc)
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
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+
///
12+
/// @file CalibPadGainTracks.h
13+
/// @author Matthias Kleiner, matthias.kleiner@cern.ch
14+
///
15+
16+
#ifndef AliceO2_TPC_CalibPadGainTracks_H
17+
#define AliceO2_TPC_CalibPadGainTracks_H
18+
19+
//o2 includes
20+
#include "DataFormatsTPC/TrackTPC.h"
21+
#include "DataFormatsTPC/ClusterNative.h"
22+
#include "TPCBase/CalDet.h"
23+
#include "TPCBase/ROC.h"
24+
#include "TPCBase/PadPos.h"
25+
#include "TPCBase/Mapper.h"
26+
#include "TPCCalibration/FastHisto.h"
27+
28+
//root includes
29+
#include "TFile.h"
30+
#include "TTree.h"
31+
32+
#include <vector>
33+
#include <tuple>
34+
35+
namespace o2
36+
{
37+
namespace tpc
38+
{
39+
40+
/// \brief Gain calibration class
41+
///
42+
/// This class is used to produce pad wise gain calibration information with reconstructed tracks.
43+
/// The idea is to use the self calibrated probe qMax/dEdx and store the information for each pad in an histogram.
44+
/// The dEdx can be used from the track itself or from some bethe-bloch parametrization.
45+
/// Using the dEdx information from the bethe bloch avoids biases in the dEdx of the track itself.
46+
/// However the use of a bethe bloch parametrization is not yet implemented and shouldnt be used yet.
47+
/// When enough thata is collected, the truncated mean of each histogram delivers the relative gain of each pad.
48+
/// This method can be used to study the pad-by-pad gain as a function of time (i.e. performing this method n times with n different consecutive data samples)
49+
///
50+
/// origin: TPC
51+
/// \author Matthias Kleiner, matthias.kleiner@cern.ch
52+
///
53+
///
54+
/// how to use:
55+
/// example:
56+
/// CalibPadGainTracks cGain{};
57+
/// cGain.init(20, 0, 3, 1, 1); // set the binning which will be used: 20 bins, minimum x=0, maximum x=10, use underflow and overflow bin
58+
/// start loop over the data
59+
/// cGain.setMembers(tpcTracks, tpcTrackClIdxVecInput, clusterIndex); // set the member variables: TrackTPC, TPCClRefElem, o2::tpc::ClusterNativeAccess
60+
/// cGain.processTracks(false, 3, 8); // dont write the histograms to TTree, set minimum and maximum momentum range of the tracks 3<p<8
61+
/// after looping of the data (filling the histograms) is done
62+
/// cGain.fillgainMap(); // fill the gainmap with the truncated mean from each histogram
63+
/// cGain.dumpGainMap(); // write the gainmap to file
64+
///
65+
/// see also: extractGainMap.C macro
66+
67+
class CalibPadGainTracks
68+
{
69+
70+
public:
71+
/// mode of normalizing qmax
72+
enum dEdxType : unsigned char {
73+
DedxTrack, ///< normalize qMax using the truncated mean from the track
74+
DedxBB ///< normalize qMax by evaluating a Bethe Bloch fit. THIS is yet not implemented and shouldnt be used.
75+
};
76+
77+
/// default constructor
78+
/// the member variables have to be set manually with setMembers()
79+
CalibPadGainTracks() = default;
80+
81+
/// constructor
82+
/// \param vTPCTracksArrayInp vector of tpc tracks
83+
/// \param tpcTrackClIdxVecInput the TPCClRefElem of the track
84+
/// \param clIndex clusternative access object
85+
CalibPadGainTracks(std::vector<o2::tpc::TrackTPC>* vTPCTracksArrayInp, std::vector<o2::tpc::TPCClRefElem>* tpcTrackClIdxVecInput, const o2::tpc::ClusterNativeAccess& clIndex)
86+
: mTracks(vTPCTracksArrayInp), mTPCTrackClIdxVecInput(tpcTrackClIdxVecInput), mClusterIndex(&clIndex)
87+
{
88+
initDefault();
89+
};
90+
91+
/// constructor
92+
/// \param vTPCTracksArrayInp vector of tpc tracks
93+
/// \param tpcTrackClIdxVecInput the TPCClRefElem of the track
94+
/// \param clIndex clusternative access object
95+
/// \param nBins number of bins used in the histograms
96+
/// \param xmin minimum value in histogram
97+
/// \param xmax maximum value in histogram
98+
/// \param useUnderflow set usage of underflow bin
99+
/// \param useOverflow set usage of overflow bin
100+
CalibPadGainTracks(std::vector<o2::tpc::TrackTPC>* vTPCTracksArrayInp, std::vector<o2::tpc::TPCClRefElem>* tpcTrackClIdxVecInput, const o2::tpc::ClusterNativeAccess& clIndex,
101+
const unsigned int nBins, const float xmin, const float xmax, const bool useUnderflow, const bool useOverflow)
102+
: mTracks(vTPCTracksArrayInp), mTPCTrackClIdxVecInput(tpcTrackClIdxVecInput), mClusterIndex(&clIndex)
103+
{
104+
init(nBins, xmin, xmax, useUnderflow, useOverflow);
105+
};
106+
107+
/// default destructor
108+
~CalibPadGainTracks() = default;
109+
110+
/// processes input tracks and filling the histograms with self calibrated probe qMax/dEdx
111+
/// \param writeTree write tree for debugging
112+
/// \param momMin minimum momentum which is required by tracks
113+
/// \param momMax maximum momentum which is required by tracks
114+
void processTracks(const bool writeTree = false, const float momMin = 0, const float momMax = 100);
115+
116+
/// set the member variables
117+
/// \param vTPCTracksArrayInp vector of tpc tracks
118+
/// \param tpcTrackClIdxVecInput set the TPCClRefElem member variable
119+
/// \param clIndex set the ClusterNativeAccess member variable
120+
void setMembers(std::vector<o2::tpc::TrackTPC>* vTPCTracksArrayInp, std::vector<o2::tpc::TPCClRefElem>* tpcTrackClIdxVecInput, const o2::tpc::ClusterNativeAccess& clIndex)
121+
{
122+
mTracks = vTPCTracksArrayInp;
123+
mTPCTrackClIdxVecInput = tpcTrackClIdxVecInput;
124+
mClusterIndex = &clIndex;
125+
}
126+
127+
/// this function sets the mode of the class.
128+
/// e.g. mode=0 -> use the truncated mean from the track for normalizing the dedx
129+
/// mode=1 -> use the value from the BB-fit for normalizing the dedx. NOT implemented yet
130+
void setMode(dEdxType iMode)
131+
{
132+
mMode = iMode;
133+
}
134+
135+
/// initialize the histograms with default parameters
136+
void initDefault()
137+
{
138+
mPadHistosDet = std::make_unique<o2::tpc::CalDet<o2::tpc::FastHisto<float>>>("Histo");
139+
}
140+
141+
/// initialize the histograms with custom parameters
142+
/// \param nBins number of bins used in the histograms
143+
/// \param xmin minimum value in histogram
144+
/// \param xmax maximum value in histogram
145+
/// \param useUnderflow set usage of underflow bin
146+
/// \param useOverflow set usage of overflow bin
147+
void init(const unsigned int nBins, const float xmin, const float xmax, const bool useUnderflow, const bool useOverflow)
148+
{
149+
o2::tpc::FastHisto<float> hist(nBins, xmin, xmax, useUnderflow, useOverflow);
150+
initDefault();
151+
for (auto& calArray : mPadHistosDet->getData()) {
152+
for (auto& tHist : calArray.getData()) {
153+
tHist = hist;
154+
}
155+
}
156+
}
157+
158+
/// dump the gain map to disk
159+
void dumpGainMap();
160+
161+
/// get the truncated mean for each histogram and fill the extracted gainvalues in a CalPad object
162+
void fillgainMap();
163+
164+
/// \return returns the gainmap object
165+
CalPad getPadGainMap() const
166+
{
167+
return mGainMap;
168+
}
169+
170+
private:
171+
std::vector<o2::tpc::TrackTPC>* mTracks{nullptr}; ///< vector containing the tpc tracks which will be processed. Cant be const due to the propagate function
172+
std::vector<TPCClRefElem>* mTPCTrackClIdxVecInput{nullptr}; ///< input vector with TPC tracks cluster indicies
173+
const o2::tpc::ClusterNativeAccess* mClusterIndex{nullptr}; ///< needed to access clusternative with tpctracks
174+
dEdxType mMode = DedxTrack; ///< normalization type: type=DedxTrack use truncated mean, type=DedxBB use value from BB fit
175+
176+
inline static auto& mapper = Mapper::instance(); ///< initialize mapper object
177+
static constexpr unsigned int NROWS = 152; ///< number of padrows used TODO change to mapper
178+
static constexpr unsigned int NROWSIROC = 63; ///< number of padrows used TODO change to mapper
179+
static constexpr unsigned int NROWSOROC = 89; ///< number of padrows used TODO change to mapper
180+
static constexpr unsigned int NSECTORS = 36; ///< number of sectors TODO change to mapper
181+
static constexpr unsigned int NPADSINSECTOR = 14560; ///< number of total pads in sector TODO change to mapper
182+
183+
std::unique_ptr<CalDet<o2::tpc::FastHisto<float>>> mPadHistosDet; ///< Calibration object containing for each pad a histogram with normalized charge
184+
CalPad mGainMap{"GainMap"}; ///< Gain map object
185+
186+
/// calculate truncated mean for track
187+
/// \param track input track which will be processed
188+
/// \param momMin minimum momentum required by the track
189+
/// \param momMax maximum momentum required by the track
190+
void processTrack(o2::tpc::TrackTPC track, float momMin, float momMax);
191+
192+
/// get the index for given pad which is needed for the filling of the CalDet object
193+
/// \param padSub pad subset type
194+
/// \param padSubsetNumber index of the pad subset
195+
/// \param row corresponding pad row
196+
/// \param pad pad in row
197+
static int getIndex(o2::tpc::PadSubset padSub, int padSubsetNumber, const int row, const int pad)
198+
{
199+
return mapper.getPadNumber(padSub, padSubsetNumber, row, pad);
200+
}
201+
202+
float getTrackTopologyCorrection(o2::tpc::TrackTPC& track, int iCl);
203+
204+
///get the truncated mean for input vector and the truncation range low*nCl<nCl<high*nCl
205+
/// \param vCharge vector containing all qmax values of the track
206+
/// \param low lower cluster cut of 0.05*nCluster
207+
/// \param high higher cluster cut of 0.6*nCluster
208+
float getTruncMean(std::vector<float> vCharge, float low = 0.05f, float high = 0.6f) const;
209+
210+
/// write the relevant variables used by this class to file
211+
void writeTree() const;
212+
};
213+
214+
} // namespace tpc
215+
} // namespace o2
216+
217+
#endif

0 commit comments

Comments
 (0)