@@ -36,6 +36,7 @@ PHOSEnergySlot::PHOSEnergySlot(const PHOSEnergySlot& other)
3636 mPtMin = other.mPtMin ;
3737 mEminHGTime = other.mEminHGTime ;
3838 mEminLGTime = other.mEminLGTime ;
39+ mFillDigitsTree = other.mFillDigitsTree ;
3940 mDigits .clear ();
4041 mHistos = std::make_unique<ETCalibHistos>();
4142}
@@ -50,15 +51,20 @@ void PHOSEnergySlot::fill(const gsl::span<const Cluster>& clusters, const gsl::s
5051 // Scan current list of clusters
5152 // Fill time, non-linearity and mgg histograms
5253 // Fill list of re-calibraiable digits
53- mDigits .clear ();
54+ if (mFillDigitsTree ) {
55+ mDigits .clear ();
56+ }
5457 for (auto & tr : cluTR) {
55- // Mark new event
56- // First goes new event marker + BC (16 bit), next word orbit (32 bit)
57- EventHeader h = {0 };
58- h.mMarker = 16383 ;
59- h.mBC = tr.getBCData ().bc ;
60- mDigits .push_back (h.mDataWord );
61- mDigits .push_back (tr.getBCData ().orbit );
58+
59+ if (mFillDigitsTree ) {
60+ // Mark new event
61+ // First goes new event marker + BC (16 bit), next word orbit (32 bit)
62+ EventHeader h = {0 };
63+ h.mMarker = 16383 ;
64+ h.mBC = tr.getBCData ().bc ;
65+ mDigits .push_back (h.mDataWord );
66+ mDigits .push_back (tr.getBCData ().orbit );
67+ }
6268 mEvBC = tr.getBCData ().bc ;
6369
6470 int firstCluInEvent = tr.getFirstEntry ();
@@ -87,6 +93,10 @@ void PHOSEnergySlot::fill(const gsl::span<const Cluster>& clusters, const gsl::s
8793 }
8894 fillTimeMassHisto (clu, cluelements);
8995
96+ if (!mFillDigitsTree ) {
97+ continue ;
98+ }
99+
90100 uint32_t firstCE = clu.getFirstCluEl ();
91101 uint32_t lastCE = clu.getLastCluEl ();
92102 for (uint32_t idig = firstCE; idig < lastCE; idig++) {
@@ -127,9 +137,15 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
127137 uint32_t firstCE = clu.getFirstCluEl ();
128138 uint32_t lastCE = clu.getLastCluEl ();
129139
140+ short absIdMax = 0 ;
141+ float maxE = 0 .;
130142 for (uint32_t idig = firstCE; idig < lastCE; idig++) {
131143 const CluElement& ce = cluelements[idig];
132144 short absId = ce.absId ;
145+ if (ce.energy > maxE) {
146+ maxE = ce.energy ;
147+ absIdMax = absId;
148+ }
133149 if (ce.isHG ) {
134150 if (ce.energy > mEminHGTime ) {
135151 mHistos ->fill (ETCalibHistos::kTimeHGPerCell , absId, ce.time );
@@ -155,14 +171,21 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
155171 // prepare TLorentsVector
156172 float posX, posZ;
157173 clu.getLocalPosition (posX, posZ);
174+
175+ // Correction for the depth of the shower starting point (TDR p 127)
176+ const float para = 0.925 ;
177+ const float parb = 6.52 ;
178+ float depth = para * TMath::Log (clu.getEnergy ()) + parb;
179+ posX -= posX * depth / 460 .;
180+ posZ -= posZ * depth / 460 .;
181+
158182 TVector3 vec3;
159183 mGeom ->local2Global (clu.module (), posX, posZ, vec3);
160- float e = clu.getEnergy ();
161- short absId;
162- mGeom ->relPosToAbsId (clu.module (), posX, posZ, absId);
163-
164- vec3 *= 1 . / vec3.Mag ();
165- TLorentzVector v (vec3.X () * e, vec3.Y () * e, vec3.Z () * e, e);
184+ // float e = clu.getEnergy();
185+ float e = Nonlinearity (clu.getCoreEnergy ());
186+ // Non-perp inc., nonlin
187+ vec3 *= e / vec3.Mag ();
188+ TLorentzVector v (vec3.X (), vec3.Y (), vec3.Z (), e);
166189 // Fill calibration histograms for all cells, even bad, but partners in inv, mass should be good
167190 bool isGood = checkCluster (clu);
168191 for (short ip = mBuffer ->size (); ip--;) {
@@ -173,20 +196,20 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
173196 mHistos ->fill (ETCalibHistos::kReInvMassNonlin , e, sum.M ());
174197 }
175198 if (sum.Pt () > mPtMin ) {
176- mHistos ->fill (ETCalibHistos::kReInvMassPerCell , absId , sum.M ());
199+ mHistos ->fill (ETCalibHistos::kReInvMassPerCell , absIdMax , sum.M ());
177200 }
178201 } else { // Mixed
179202 if (isGood) {
180203 mHistos ->fill (ETCalibHistos::kMiInvMassNonlin , e, sum.M ());
181204 }
182205 if (sum.Pt () > mPtMin ) {
183- mHistos ->fill (ETCalibHistos::kMiInvMassPerCell , absId , sum.M ());
206+ mHistos ->fill (ETCalibHistos::kMiInvMassPerCell , absIdMax , sum.M ());
184207 }
185208 }
186209 }
187210
188211 // Add to list ot partners only if cluster is good
189- if (isGood) {
212+ if (isGood && e > 0.2 ) {
190213 mBuffer ->addEntry (v);
191214 }
192215}
@@ -204,6 +227,22 @@ bool PHOSEnergySlot::checkCluster(const Cluster& clu)
204227
205228 return (clu.getEnergy () > 0.3 && clu.getMultiplicity () > 1 );
206229}
230+ float PHOSEnergySlot::Nonlinearity (float en)
231+ {
232+ // Correct for non-linearity
233+ const double a = 9.34913e-01 ;
234+ const double b = 2.33e-03 ;
235+ const double c = -8.10e-05 ;
236+ const double d = 3.2e-02 ;
237+ const double f = -8.0e-03 ;
238+ const double g = 1 .e -01 ;
239+ const double h = 2 .e -01 ;
240+ const double k = -1.48e-04 ;
241+ const double l = 0.194 ;
242+ const double m = 0.0025 ;
243+
244+ return en * (a + b * en + c * en * en + d / en + f / ((en - g) * (en - g) + h) + k / ((en - l) * (en - l) + m));
245+ }
207246
208247// ==================================================
209248
@@ -229,6 +268,7 @@ Slot& PHOSEnergyCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType ten
229268 auto & cont = getSlots ();
230269 auto & slot = front ? cont.emplace_front (tstart, tend) : cont.emplace_back (tstart, tend);
231270 slot.setContainer (std::make_unique<es>());
271+ slot.getContainer ()->setFillDigitsTree (mFillDigitsTree );
232272 slot.getContainer ()->setBadMap (mBadMap );
233273 slot.getContainer ()->setCalibration (mCalibParams );
234274 slot.getContainer ()->setCuts (mPtMin , mEminHGTime , mEminLGTime , mDigitEmin , mClusterEmin );
@@ -246,8 +286,10 @@ bool PHOSEnergyCalibrator::process(uint64_t tf, const gsl::span<const Cluster>&
246286 slotTF.getContainer ()->setRunStartTime (tf);
247287 slotTF.getContainer ()->fill (clusters, cluelements, cluTR);
248288 // Add collected Digits
249- auto tmpD = slotTF.getContainer ()->getCollectedDigits ();
250- outputDigits.insert (outputDigits.end (), tmpD.begin (), tmpD.end ());
289+ if (mFillDigitsTree ) {
290+ auto tmpD = slotTF.getContainer ()->getCollectedDigits ();
291+ outputDigits.insert (outputDigits.end (), tmpD.begin (), tmpD.end ());
292+ }
251293 return true ;
252294}
253295
0 commit comments