22#include <fairlogger/Logger.h>
36 LOG(info) <<
"Clusterizer parameters";
52 std::vector<Cluster>&
clusters, std::vector<CluElement>& cluelements, std::vector<TriggerRecord>& trigRec,
57 cluelements.reserve(
digits.size());
62 for (
const auto& tr : dtr) {
66 int firstDigitInEvent = tr.getFirstEntry();
67 int lastDigitInEvent = firstDigitInEvent + tr.getNumberOfObjects();
71 for (
int i = firstDigitInEvent;
i < lastDigitInEvent;
i++) {
74 if (digitSeed.
isTRU()) {
95 LOG(
debug) <<
"Found clusters from " << indexStart <<
" to " <<
clusters.size();
96 trigRec.emplace_back(tr.getBCData(), indexStart,
clusters.size() - indexStart);
105 std::vector<Cluster>&
clusters, std::vector<CluElement>& cluelements, std::vector<TriggerRecord>& trigRec,
111 cluelements.reserve(
cells.size());
116 for (
const auto& tr : ctr) {
117 int firstCellInEvent = tr.getFirstEntry();
118 int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects();
124 for (
int i = firstCellInEvent;
i < lastCellInEvent;
i++) {
126 short absId =
c.getAbsId();
128 mTrigger.emplace_back(
c.getTRUId(),
c.getEnergy(),
c.getTime(), 0);
134 float energy =
calibrate(
c.getEnergy(), absId,
c.getHighGain());
138 float x = 0.,
z = 0.;
140 mCluEl.emplace_back(absId,
c.getHighGain(), energy,
calibrateT(
c.getTime(), absId,
c.getHighGain(), tr.getBCData().bc),
145 trigRec.emplace_back(tr.getBCData(), indexStart,
clusters.size() - indexStart);
160 for (
int i = iFirst;
i <
n;
i++) {
169 int iDigitInCluster = 0;
175 cluelements.emplace_back(digitSeed);
183 while (
index < iDigitInCluster) {
186 for (
int j = iFirst;
j <
n;
j++) {
201 cluelements.emplace_back(digitN);
222 cluelements.pop_back();
246 cluelements.pop_back();
264 std::vector<std::vector<float>> eInClusters(mult, std::vector<float>(nMax));
268 mProp.reserve(mult * nMax);
270 for (
int iclu = nMax; iclu--;) {
285 bool insuficientAccuracy =
true;
286 double chi2Previous = 1.e+6;
289 insuficientAccuracy =
false;
294 for (
int iclu = nMax; iclu--;) {
300 for (
uint32_t idig = firstCE; idig < lastCE; idig++) {
303 for (
int iclu = nMax; iclu--;) {
306 double r2 = lx * lx + lz * lz;
313 sumA += ss *
meMax[iclu];
314 C(iclu) += ce.
energy * ss;
316 double dE = ce.
energy - sumA;
318 for (
int iclu = 0; iclu < nMax; iclu++) {
319 for (
int jclu = iclu; jclu < nMax; jclu++) {
320 B(iclu, jclu) +=
mfij[iclu] *
mfij[jclu];
325 mProp[(idig - firstCE) * nMax + iclu] =
mfij[iclu] *
meMax[iclu] / sumA;
328 if (nIterations > 0 &&
chi2 > chi2Previous) {
330 for (
int iclu = nMax; iclu--;) {
335 insuficientAccuracy =
true;
341 for (
int iclu = nMax; iclu--;) {
348 for (
int iclu = 1; iclu < nMax; iclu++) {
349 for (
int jclu = 0; jclu < iclu; jclu++) {
350 B(iclu, jclu) =
B(jclu, iclu);
353 for (
int iclu = nMax; iclu--;) {
360 for (
int iclu = nMax; iclu--;) {
373 if (bk.Decompose()) {
375 for (
int iclu = 0; iclu < nMax; iclu++) {
376 meMax[iclu] = C(iclu);
391 for (
int iclu = 0; iclu < nMax; iclu++) {
393 int start = cluelements.size();
395 for (
uint32_t idig = firstCE; idig < lastCE; idig++) {
397 float ei = el.
energy *
mProp[(idig - firstCE) * nMax + iclu];
399 cluelements.emplace_back(el);
400 cluelements.back().energy = ei;
401 cluelements.back().fraction =
mProp[(idig - firstCE) * nMax + iclu];
412 cluelements.pop_back();
425 cluelements.pop_back();
449 gsl::span<const MCLabel> spDigList = dmc->
getLabels(
i);
450 if (spDigList.size() == 0 || spDigList.begin()->isFake()) {
453 gsl::span<MCLabel> spCluList = cluMC.
getLabels(labelIndex);
454 auto digL = spDigList.begin();
455 while (digL != spDigList.end()) {
456 if (digL->isFake()) {
461 auto cluL = spCluList.begin();
462 while (cluL != spCluList.end()) {
463 if (*digL == *cluL) {
464 (*cluL).add(*digL, sc);
500 double r295 = TMath::Power(r2, 2.95 / 2.);
501 double a = 2.32 + 0.26 * r4;
502 double b = 31.645570 + 2.0632911 * r295;
503 double s = TMath::Exp(-r4 * ((
a +
b) / (
a *
b)));
504 deriv = -2. *
s * r2 * (2.32 / (
a *
a) + (0.54161392 * r295 + 31.645570) / (
b *
b));
516 float fullEnergy = 0.;
523 float ei = cluel[
i].energy;
529 time = cluel[
i].time;
534 if (fullEnergy <= 0) {
540 float localPosX = 0., localPosZ = 0.;
542 float invE = 1. / fullEnergy;
562 coreRadius2 *= coreRadius2;
564 float dispersion = 0.;
565 float dxx = 0., dxz = 0., dzz = 0., lambdaLong = 0., lambdaShort = 0.;
572 float x = ce.
localX - localPosX;
573 float z = ce.
localZ - localPosZ;
593 lambdaLong = 0.5 * (dxx + dzz) + std::sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz);
594 if (lambdaLong > 0) {
595 lambdaLong = std::sqrt(lambdaLong);
598 lambdaShort = 0.5 * (dxx + dzz) - std::sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz);
599 if (lambdaShort > 0) {
600 lambdaShort = std::sqrt(lambdaShort);
605 if (dispersion >= 0) {
618 short trtype =
trd.is2x2Tile() ? 0 : 1;
622 int dx = relId[1] - trurelid[1];
623 int dz = relId[2] - trurelid[2];
625 if (dx >= 0 && dx < 2 && dz >= 0 && dz < 2) {
630 if (dx >= 0 && dx < 4 && dz >= 0 && dz < 4) {
657 if (cluel[
i].energy > cluel[
j].energy) {
660 if (cluel[
j].energy > cluel[
i].energy - locMaxCut) {
666 if (cluel[
i].energy > cluel[
j].energy - locMaxCut) {
680 static int nAlarms = 0;
682 LOG(alarm) <<
"Too many local maxima, cluster multiplicity " <<
mIsLocalMax.size();
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
Definition of the PHOS cluster finder.
static const PHOSSimParams & Instance()
Contains PHOS cluster parameters.
uint32_t getFirstCluEl() const
void setFirstCluEl(uint32_t first)
void setCoreEnergy(float ec)
int getMultiplicity() const
void setNExMax(char nmax=1)
void setDispersion(float d)
void setFiredTrigger(char t)
void setLocalPosition(float posX, float posZ)
void setLastCluEl(uint32_t last)
void setElipsAxis(float lambdaShort, float lambdaLong)
uint32_t getLastCluEl() const
static constexpr short NLOCMAX
void makeUnfolding(Cluster &clu, std::vector< Cluster > &clusters, std::vector< o2::phos::CluElement > &cluel)
bool isBadChannel(short absId)
void processCells(gsl::span< const Cell > digits, gsl::span< const TriggerRecord > dtr, const o2::dataformats::MCTruthContainer< MCLabel > *dmc, std::vector< Cluster > &clusters, std::vector< CluElement > &cluel, std::vector< TriggerRecord > &rigRec, o2::dataformats::MCTruthContainer< MCLabel > &cluMC)
int mLastElementInEvent
Range of digits from one event.
std::array< double, NLOCMAX > mfijz
transient variable for derivative calculation
std::array< int, NLOCMAX > mMaxAt
indexes of local maxima
char getNumberOfLocalMax(Cluster &clu, std::vector< CluElement > &cluel)
std::array< float, NLOCMAX > meMax
currecnt amplitude in unfoding
void evalLabels(std::vector< Cluster > &clusters, std::vector< CluElement > &cluel, const o2::dataformats::MCTruthContainer< MCLabel > *dmc, o2::dataformats::MCTruthContainer< MCLabel > &cluMC)
float calibrateT(float time, short absId, bool isHighGain, int bc)
std::array< float, NLOCMAX > mdz
step on current minimization iteration
void process(gsl::span< const Digit > digits, gsl::span< const TriggerRecord > dtr, const o2::dataformats::MCTruthContainer< MCLabel > *dmc, std::vector< Cluster > &clusters, std::vector< CluElement > &cluel, std::vector< TriggerRecord > &rigRec, o2::dataformats::MCTruthContainer< MCLabel > &cluMC)
int mFirstElememtInEvent
Range of digits from one event.
std::array< float, NLOCMAX > mdzprev
step on previoud minimization iteration
double showerShape(double r2, double &deriv)
std::array< double, NLOCMAX > mxB
transient variable for derivative calculation
void makeClusters(std::vector< Cluster > &clusters, std::vector< o2::phos::CluElement > &cluel)
std::array< float, NLOCMAX > mdxprev
step on previoud minimization iteration
std::array< double, NLOCMAX > mfij
transient variable for derivative calculation
Geometry * mPHOSGeom
packed shifts for 14 ddls
std::vector< Digit > mTrigger
internal vector of clusters
void unfoldOneCluster(Cluster &iniClu, char nMax, std::vector< Cluster > &clusters, std::vector< CluElement > &cluelements)
std::array< float, NLOCMAX > mdx
step on current minimization iteration
std::vector< CluElement > mCluEl
! Bad map, Clusterizer not owner
float calibrate(float amp, short absId, bool isHighGain)
std::array< double, NLOCMAX > mA
transient variable for derivative calculation
std::vector< float > mProp
proportion of clusters in the current digit
std::array< float, NLOCMAX > mxMax
current maximum coordinate
std::array< double, NLOCMAX > mzB
transient variable for derivative calculation
void evalAll(Cluster &clu, std::vector< CluElement > &cluel) const
std::vector< bool > mIsLocalMax
transient array for local max finding
std::array< double, NLOCMAX > mfijr
transient variable for derivative calculation
std::array< float, NLOCMAX > mzMax
in the unfolding procedure
std::array< double, NLOCMAX > mfijx
transient variable for derivative calculation
std::array< float, NLOCMAX > mxMaxPrev
coordunates at previous step
std::array< float, NLOCMAX > mzMaxPrev
coordunates at previous step
short getAbsId() const
Absolute sell id.
float getAmplitude() const
Energy deposited in a cell.
bool isHighGain() const
Checks if this digit is produced in High Gain or Low Gain channels.
int getLabel() const
index of entry in MCLabels array
float getTime() const
time measured in digit w.r.t. photon to PHOS arrival
static void relPosToRelId(short module, float x, float z, char *relId)
static char absIdToModule(short absId)
static int areNeighbours(short absId1, short absId2)
static void absIdToRelPosInModule(short absId, float &x, float &z)
static bool truAbsToRelNumbering(short truId, short trigType, char *relid)
static Geometry * GetInstance()
GLboolean GLboolean GLboolean b
GLsizei GLsizei GLfloat distance
GLboolean GLboolean GLboolean GLboolean a
GLubyte GLubyte GLubyte GLubyte w
GLdouble GLdouble GLdouble z
float mUnfogingChi2Accuracy
critical chi2/NDF
float mCoreR
Radius to caluclate core energy.
bool mUnfoldClusters
To perform cluster unfolding.
float mLogWeight
Cutoff used in log. weight calculation.
int mUnfoldMaxSize
maximal number of cells in cluster to be unfolded
float mDigitMinEnergy
Minimal energy of digits to be used in cluster (GeV)
float mClusteringThreshold
Minimal energy of digit to start clustering (GeV)
float mUnfogingXZAccuracy
Accuracy of position calculation in unfolding procedure (cm)
float mLocalMaximumCut
Minimal height of local maximum over neighbours.
float mUnfogingEAccuracy
Accuracy of energy calculation in unfoding prosedure (GeV)
int mNMaxIterations
Maximal number of iterations in unfolding procedure.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters
std::vector< Cell > cells
std::vector< Digit > digits