17#ifndef AliceO2_TPC_CalculatedEdx_H
18#define AliceO2_TPC_CalculatedEdx_H
38#include <unordered_map>
44class TPCFastTransform;
148 void setRefit(
const unsigned int nHbfPerTf = 32);
192 auto& streamer = mStreamers[debugRootFile];
194 streamer = std::make_unique<o2::utils::TreeStreamRedirector>(debugRootFile,
"recreate");
234 mNPropagationFailed = 0;
237 mNSubThresholdFilledPerSettings.clear();
244 void fillMissingClusters(
int missingClusters[4],
const float minChargeTot[4],
const float minChargeMax[4],
int method, std::array<std::vector<float>, 5>& chargeTotROC, std::array<std::vector<float>, 5>& chargeMaxROC);
248 void handleSameRowClusters(
o2::tpc::TrackTPC& track, std::vector<std::pair<unsigned char, unsigned char>>& rowOrder, std::map<std::pair<unsigned char, unsigned char>, std::vector<int>>& clustersByRow, std::set<std::pair<unsigned char, unsigned char>>& mergeableRows, std::map<
int, std::tuple<unsigned char, unsigned char, unsigned int>>& clusterReferencesByIndex);
253 void handleSameRowClusters(
const std::vector<o2::tpc::ClusterNative>&
clusters,
const ClInfoVec& clusterInfos, std::vector<std::pair<unsigned char, unsigned char>>& rowOrder, std::map<std::pair<unsigned char, unsigned char>, std::vector<int>>& clustersByRow, std::set<std::pair<unsigned char, unsigned char>>& mergeableRows);
267 void calculatedEdx(
TrackTPC& track,
dEdxInfo&
output,
AverageOccupancy& averageOcc,
float low = 2.f / 128.f,
float high = 77.f / 128.f,
CorrectionFlags correctionMask =
CorrectionFlags::TopologyPol |
CorrectionFlags::dEdxResidual,
ClusterFlags clusterMask =
ClusterFlags::None,
int subthresholdMethod = 0,
int stackBoundaryMethod = 0,
const char* debugRootFile =
"dEdxDebug.root",
float maxSubthresholdChargeTot = 100000.f,
float maxSubthresholdChargeMax = 100000.f,
int sameRowClusterMethod = 2);
281 void calculatedEdx(
TrackTPC& track,
const std::vector<o2::tpc::ClusterNative>&
clusters,
const ClInfoVec& clusterInfos,
dEdxInfo&
output,
AverageOccupancy& averageOcc,
float low = 2.f / 128.f,
float high = 77.f / 128.f,
CorrectionFlags correctionMask =
CorrectionFlags::TopologyPol |
CorrectionFlags::dEdxResidual,
ClusterFlags clusterMask =
ClusterFlags::None,
int subthresholdMethod = 0,
int stackBoundaryMethod = 0,
const char* debugRootFile =
"dEdxDebug.root",
float maxSubthresholdChargeTot = 100000.f,
float maxSubthresholdChargeMax = 100000.f,
int sameRowClusterMethod = 2);
319 bool isInStackBoundaries(
int stackNumber,
unsigned char rowIndex,
int stackBoundaryMethod);
328 void loadCalibsFromCCDB(
long runNumberOrTimeStamp,
const bool isMC =
false,
const bool loadSCCorrMap =
true,
const bool useSCCorrMap =
true,
const bool useVDrift =
true,
const float corrMapLumiScale = -1.f);
386 void setVDriftFromFile(
const char* folder,
const char* file,
const char*
object);
400 unsigned int occupancy;
405 static const RowFragment& pickDominantFragment(
const std::vector<RowFragment>& fragments);
408 struct RowClusterData {
409 std::vector<RowFragment> fragments;
411 RowFragment mergedFragment{};
413 unsigned char sectorIndex;
414 unsigned char rowIndex;
419 bool propagationFailed;
422 std::array<int, 4> missingClustersStack{};
423 bool sameSectorAsPrevRow;
424 bool missingClusterGapDeadOrEdge;
425 std::vector<int> inputClusterIndices;
432 void gatherRowClusterData(
o2::tpc::TrackTPC& track, std::vector<RowClusterData>& rowData, AverageOccupancy& averageOcc);
440 void gatherRowClusterData(
o2::tpc::TrackTPC& track,
const std::vector<o2::tpc::ClusterNative>&
clusters,
const ClInfoVec& clusterInfos, std::vector<RowClusterData>& rowData, AverageOccupancy& averageOcc);
455 void gatherRowClusterDataForRow(
o2::tpc::TrackTPC& track,
const std::vector<o2::tpc::ClusterNative>& fragmentClusters,
const std::vector<bool>& fragmentIsShared,
unsigned char sectorIndex,
unsigned char rowIndex,
bool mergeable,
unsigned char rowIndexOld,
unsigned char sectorIndexOld, std::array<std::vector<unsigned int>, 4>& occupancyROC, std::vector<RowClusterData>& rowData,
bool refitFailed);
471 void rebuildTPCCorrMapPOD();
482 void calculatedEdxFromRowData(
const std::vector<RowClusterData>& rowData,
const dEdxSettings& settings,
size_t settingsIndex,
float trackTime0,
const o2::tpc::TrackTPC& trackOrig,
const AverageOccupancy& averageOcc, dEdxInfo&
output,
const MCCompLabel* mcLabel =
nullptr);
484 std::vector<TrackTPC>* mTracks{
nullptr};
485 std::vector<TPCClRefElem>* mTPCTrackClIdxVecInput{
nullptr};
489 std::unique_ptr<o2::gpu::TPCFastTransform> mTPCCorrMapFull;
490 std::vector<unsigned char> mTPCRefitterShMap;
491 std::vector<unsigned int> mTPCRefitterOccMap;
492 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mRefit{
nullptr};
493 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mRefitExt{
nullptr};
494 std::unique_ptr<o2::tpc::ClusterNativeAccess> mExtClusterAccess{
nullptr};
495 std::vector<o2::tpc::ClusterNative> mExtClusters;
496 std::vector<o2::tpc::TPCClRefElem> mExtClusterRefs;
497 std::vector<unsigned char> mExtShMap;
498 bool mUseRefit{
false};
499 unsigned int mNHbfPerTf{32};
501 int mMaxMissingCl{1};
502 int mSubThreshEdgeRows{30};
503 float mSameRowMaxPadDiff{3.f};
504 float mSameRowMaxTimeDiff{4.f};
505 float mFieldNominalGPUBz{5};
506 bool mPropagateTrack{
false};
507 bool mPropagateParams{
false};
508 bool mPropagateToClusterX{
true};
510 CalibdEdxContainer mCalibCont;
511 std::unordered_map<std::string, std::unique_ptr<o2::utils::TreeStreamRedirector>> mStreamers;
512 long mDebugTrackIndex{-1};
513 bool mWarnedMissingRefit{
false};
514 long mNPropagationFailed{0};
515 long mNRefitFallback{0};
516 long mNRowsProcessed{0};
517 std::vector<long> mNSubThresholdFilledPerSettings;
519 CorrectdEdxDistortions mSCdEdxCorrection;
521 std::array<std::vector<unsigned char>, 4> mStackBoundaries = {{{0, 62}, {63, 96}, {97, 126}, {127, 151}}};
Definition of container class for dE/dx corrections.
Class of a TPC cluster in TPC-native coordinates (row, time)
Helper class to access correction maps.
calibration data from laser track calibration
void setSubThreshEdgeRows(int n)
void setPropagateToClusterX(const bool propagate)
float getFieldNominalGPUBz()
void loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isMC=false, const bool loadSCCorrMap=true, const bool useSCCorrMap=true, const bool useVDrift=true, const float corrMapLumiScale=-1.f)
void setFieldNominalGPUBz(const float field)
void setPropagateParams(const bool propagate)
void setSameRowMaxPadDiff(float d)
void setVDriftFromFile(const char *folder, const char *file, const char *object)
load the drift-velocity calibration (VDriftCorrFact) from a local file and rebuild mTPCCorrMap
const std::vector< long > & getNSubThresholdFilledPerSettings() const
long getNPropagationFailed() const
void calculatedEdx(TrackTPC &track, dEdxInfo &output, AverageOccupancy &averageOcc, float low=2.f/128.f, float high=77.f/128.f, CorrectionFlags correctionMask=CorrectionFlags::TopologyPol|CorrectionFlags::dEdxResidual, ClusterFlags clusterMask=ClusterFlags::None, int subthresholdMethod=0, int stackBoundaryMethod=0, const char *debugRootFile="dEdxDebug.root", float maxSubthresholdChargeTot=100000.f, float maxSubthresholdChargeMax=100000.f, int sameRowClusterMethod=2)
void setTPCCorrMap(const o2::gpu::TPCFastTransform &corrMap, const o2::gpu::TPCFastTransform *corrMapRef=nullptr, float lumiScale=-1.f)
void setTrackTopologyCorrectionFromFile(const char *folder, const char *file, const char *object)
void setZeroSuppressionThresholdFromFile(const char *folder, const char *file, const char *object)
void setMaxMissingCl(int maxMissingCl)
void setPropagatorFromFile(const char *folder, const char *file, const char *object)
unsigned int getOccupancy(float clTime) const
void setRefit(const unsigned int nHbfPerTf=32)
set the refitter
float getTrackTopologyCorrectionPol(const o2::tpc::TrackTPC &track, const o2::tpc::ClusterNative &cl, const unsigned int region, const float charge, ChargeType chargeType, const float threshold) const
void calculatedEdxMultipleSettings(TrackTPC &track, std::vector< dEdxInfo > &outputs, AverageOccupancy &averageOcc, const std::vector< dEdxSettings > &settingsList, const MCCompLabel *mcLabel=nullptr)
float getTPCScalerLumiScale(long timeStamp, float meanIDC) const
void setMembers(std::vector< o2::tpc::TPCClRefElem > *tpcTrackClIdxVecInput, const o2::tpc::ClusterNativeAccess &clIndex, std::vector< o2::tpc::TrackTPC > *vTPCTracksArrayInp)
void setPropagateTrack(const bool propagate)
void setLumi(const float lumi)
float getSameRowMaxTimeDiff() const
float getSameRowMaxPadDiff() const
void setTPCCorrMapFromFile(const char *folder, const char *file, const char *object)
load the space-charge correction map for the cluster transform from a local file; without the file,...
long getNRowsProcessed() const
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void loadCalibsFromLocalCCDBFolder(const char *localCCDBFolder, const bool useSCCorrMap=true, const bool useVDrift=true)
void fillMissingClusters(int missingClusters[4], const float minChargeTot[4], const float minChargeMax[4], int method, std::array< std::vector< float >, 5 > &chargeTotROC, std::array< std::vector< float >, 5 > &chargeMaxROC)
float getTruncMean(std::vector< float > &charge, float low, float high) const
void setSameRowMaxTimeDiff(float d)
void setResidualCorrectionFromFile(const char *folder, const char *file, const char *object)
float getTrackTopologyCorrection(const o2::tpc::TrackTPC &track, const unsigned int region) const
bool isInStackBoundaries(int stackNumber, unsigned char rowIndex, int stackBoundaryMethod)
void handleSameRowClusters(o2::tpc::TrackTPC &track, std::vector< std::pair< unsigned char, unsigned char > > &rowOrder, std::map< std::pair< unsigned char, unsigned char >, std::vector< int > > &clustersByRow, std::set< std::pair< unsigned char, unsigned char > > &mergeableRows, std::map< int, std::tuple< unsigned char, unsigned char, unsigned int > > &clusterReferencesByIndex)
void setSCStreamer(const char *debugRootFile="debug_sc_corrections.root")
set the debug streamer of the space-charge dedx correction
void setMagneticFieldFromFile(const char *folder, const char *file, const char *object)
void setGainMapResidualFromFile(const char *folder, const char *file, const char *object)
void setStreamer(const char *debugRootFile)
long getNRefitFallback() const
void setGainMapFromFile(const char *folder, const char *file, const char *object)
void setDebug(const bool debug)
void resetDebugCounters()
reset the running counters returned by getNPropagationFailed()/getNRefitFallback()/getNRowsProcessed(...
int getSubThreshEdgeRows() const
void setStreamer(const char *debugRootFile="debug_sc_corrections.root")
enable the debug streamer
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
Global TPC definitions and constants.
GEMstack
TPC GEM stack types.
@ ExcludeSingleCl
flag to exclude single clusters in dEdx calculation
@ ExcludeSubthresholdCl
flag to exclude subthreshold clusters in dEdx calculation
@ ExcludeSplitPadCl
flag to exclude split pad clusters in dEdx calculation
@ ExcludeEdgeCl
flag to exclude sector edge clusters in dEdx calculation
@ ExcludeSectorBoundaries
flag to exclude sector boundary clusters in subthreshold cluster treatment
@ ExcludeSplitCl
flag to exclude split pad or time clusters in dEdx calculation
@ ExcludeSplitTimeCl
flag to exclude split time clusters in dEdx calculation
@ ExcludeSamePadRowCl
flag to exclude clusters in the same pad row in dEdx calculation
@ ExcludeSharedCl
flag to exclude clusters shared between tracks in dEdx calculation
SourcesDeadMap operator|(SourcesDeadMap a, SourcesDeadMap b)
SourcesDeadMap operator&(SourcesDeadMap a, SourcesDeadMap b)
SourcesDeadMap operator~(SourcesDeadMap a)
std::vector< ClInfo > ClInfoVec
CorrectionFlags
dEdx calculation class
@ TopologyPol
flag for topology correction from polynomials
@ TopologySimple
flag for simple analytical topology correction
@ dEdxResidual
flag for residual dEdx correction
@ dEdxSC
flag for space-charge dEdx correction
@ GainFull
flag for full gain map from calibration container
@ GainResidual
flag for residuals gain map from calibration container
Marks an empty item in the context.
average cluster occupancy of a track, per TPC region
ClassDefNV(AverageOccupancy, 1)
per-cluster info needed by the calculatedEdx()/calculatedEdxMultipleSettings() overloads that take cl...
unsigned char sectorIndex
bundles the settings of one calculatedEdx() call (everything except the track/output/averageOcc) used...
float maxSubthresholdChargeMax
upper limit for the per-region minimum qMax used as the virtual charge of a subthreshold cluster (def...
CorrectionFlags correctionMask
corrections to apply
unsigned short subthresholdMethod
subthreshold cluster charge filling method
std::string debugRootFile
debug streamer output file used if mDebug is set
float maxSubthresholdChargeTot
upper limit for the per-region minimum qTot used as the virtual charge of a subthreshold cluster (def...
ClusterFlags clusterMask
clusters to exclude
unsigned short stackBoundaryMethod
stack boundary cluster exclusion method
float high
higher cluster cut
float low
lower cluster cut
unsigned short sameRowClusterMethod
same (sector,row) cluster group combination method: 0 = do not merge (one sample per cluster),...
std::vector< Cluster > clusters