2 // Class to do the sharing correction. That is, a filter that merges
3 // adjacent strip signals presumably originating from a single particle
4 // that impinges on the detector in such a way that it deposite energy
5 // into two or more strips.
8 // - AliESDFMD object - from reconstruction
11 // - AliESDFMD object - copy of input, but with signals merged
14 // - AliFMDCorrELossFit
17 // - For each ring (FMD1i, FMD2i, FMD2o, FMD3i, FMD3o) the distribution of
18 // signals before and after the filter.
19 // - For each ring (see above), an array of distributions of number of
20 // hit strips for each vertex bin (if enabled - see Init method)
24 #include "AliFMDSharingFilter.h"
25 #include "AliFMDStripIndex.h"
26 #include <AliESDFMD.h>
31 #include "AliForwardCorrectionManager.h"
32 #include "AliFMDCorrELossFit.h"
36 #include <TParameter.h>
40 ClassImp(AliFMDSharingFilter)
42 ; // This is for Emacs
46 do { if (L>fDebug)break; std::cout << (M) << std::flush;} while(false)
48 do { if (L>fDebug)break; std::cout << (M) << std::endl;} while(false)
52 //____________________________________________________________________
53 AliFMDSharingFilter::AliFMDSharingFilter()
56 fCorrectAngles(kFALSE),
62 fZeroSharedHitsBelowThreshold(false),
65 fUseSimpleMerging(false),
66 fThreeStripSharing(true),
67 fRecalculateEta(false),
69 fInvalidIsEmpty(false)
72 // Default Constructor - do not use
74 DGUARD(fDebug,1, "Default CTOR for AliFMDSharingFilter");
77 //____________________________________________________________________
78 AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
79 : TNamed("fmdSharingFilter", title),
81 fCorrectAngles(kFALSE),
87 fZeroSharedHitsBelowThreshold(false),
90 fUseSimpleMerging(false),
91 fThreeStripSharing(true),
92 fRecalculateEta(false),
94 fInvalidIsEmpty(false)
100 // title Title of object - not significant
102 DGUARD(fDebug,1, "Named CTOR for AliFMDSharingFilter: %s", title);
103 fRingHistos.SetName(GetName());
104 fRingHistos.SetOwner();
106 fRingHistos.Add(new RingHistos(1, 'I'));
107 fRingHistos.Add(new RingHistos(2, 'I'));
108 fRingHistos.Add(new RingHistos(2, 'O'));
109 fRingHistos.Add(new RingHistos(3, 'I'));
110 fRingHistos.Add(new RingHistos(3, 'O'));
113 fHCuts.SetIncludeSigma(1);
114 fLCuts.SetMultCuts(.15);
116 fExtraDead.Reset(-1);
119 //____________________________________________________________________
120 AliFMDSharingFilter::AliFMDSharingFilter(const AliFMDSharingFilter& o)
123 fCorrectAngles(o.fCorrectAngles),
124 // fSummed(o.fSummed),
125 fHighCuts(o.fHighCuts),
126 fLowCuts(o.fLowCuts),
129 fZeroSharedHitsBelowThreshold(o.fZeroSharedHitsBelowThreshold),
132 fUseSimpleMerging(o.fUseSimpleMerging),
133 fThreeStripSharing(o.fThreeStripSharing),
134 fRecalculateEta(o.fRecalculateEta),
135 fExtraDead(o.fExtraDead),
136 fInvalidIsEmpty(o.fInvalidIsEmpty)
142 // o Object to copy from
144 DGUARD(fDebug,1, "Copy CTOR for AliFMDSharingFilter");
145 TIter next(&o.fRingHistos);
147 while ((obj = next())) fRingHistos.Add(obj);
150 //____________________________________________________________________
151 AliFMDSharingFilter::~AliFMDSharingFilter()
156 DGUARD(fDebug,3, "DTOR for AliFMDSharingFilter");
157 // fRingHistos.Delete();
160 //____________________________________________________________________
162 AliFMDSharingFilter::operator=(const AliFMDSharingFilter& o)
165 // Assignment operator
168 // o Object to assign from
173 DGUARD(fDebug,3, "Assigment for AliFMDSharingFilter");
174 if (&o == this) return *this;
175 TNamed::operator=(o);
177 fCorrectAngles = o.fCorrectAngles;
180 // fSummed = o.fSummed;
181 fHighCuts = o.fHighCuts;
182 fLowCuts = o.fLowCuts;
183 fZeroSharedHitsBelowThreshold = o.fZeroSharedHitsBelowThreshold;
186 fUseSimpleMerging = o.fUseSimpleMerging;
187 fThreeStripSharing = o.fThreeStripSharing;
188 fRecalculateEta = o.fRecalculateEta;
189 fInvalidIsEmpty = o.fInvalidIsEmpty;
191 fRingHistos.Delete();
192 TIter next(&o.fRingHistos);
194 while ((obj = next())) fRingHistos.Add(obj);
199 //____________________________________________________________________
200 AliFMDSharingFilter::RingHistos*
201 AliFMDSharingFilter::GetRingHistos(UShort_t d, Char_t r) const
204 // Get the ring histogram container
211 // Ring histogram container
215 case 1: idx = 0; break;
216 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
217 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
219 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
221 return static_cast<RingHistos*>(fRingHistos.At(idx));
224 //____________________________________________________________________
226 AliFMDSharingFilter::AddDead(UShort_t d, Char_t r, UShort_t s, UShort_t t)
228 if (d < 1 || d > 3) {
229 Warning("AddDead", "Invalid detector FMD%d", d);
232 Bool_t inner = (r == 'I' || r == 'i');
233 if (d == 1 && !inner) {
234 Warning("AddDead", "Invalid ring FMD%d%c", d, r);
237 if ((inner && s >= 20) || (!inner && s >= 40)) {
238 Warning("AddDead", "Invalid sector FMD%d%c[%02d]", d, r, s);
241 if ((inner && t >= 512) || (!inner && t >= 256)) {
242 Warning("AddDead", "Invalid strip FMD%d%c[%02d,%03d]", d, r, s, t);
246 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
248 for (i = 0; i < fExtraDead.GetSize(); i++) {
249 Int_t j = fExtraDead.At(i);
250 if (j == id) return; // Already there
251 if (j < 0) break; // Free slot
253 if (i >= fExtraDead.GetSize()) {
254 Warning("AddDead", "No free slot to add FMD%d%c[%02d,%03d] at",
260 //____________________________________________________________________
262 AliFMDSharingFilter::AddDeadRegion(UShort_t d, Char_t r,
263 UShort_t s1, UShort_t s2,
264 UShort_t t1, UShort_t t2)
266 // Add a dead region spanning from FMD<d><r>[<s1>,<t1>] to
267 // FMD<d><r>[<s2>,<t2>] (both inclusive)
268 for (Int_t s = s1; s <= s2; s++)
269 for (Int_t t = t1; t <= t2; t++)
272 //____________________________________________________________________
274 AliFMDSharingFilter::AddDead(const Char_t* script)
276 if (!script || script[0] == '\0') return;
278 gROOT->Macro(Form("%s((AliFMDSharingFilter*)%p);", script, this));
281 //____________________________________________________________________
283 AliFMDSharingFilter::IsDead(UShort_t d, Char_t r, UShort_t s, UShort_t t) const
285 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
286 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
287 Int_t j = fExtraDead.At(i);
289 //Info("IsDead", "FMD%d%c[%02d,%03d] marked as dead here", d, r, s, t);
292 if (j < 0) break; // High water mark
296 //____________________________________________________________________
298 AliFMDSharingFilter::SetupForData(const TAxis& axis)
300 // Initialise - called on first event
301 DGUARD(fDebug,1, "Initialize for AliFMDSharingFilter");
302 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
303 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
305 // Get the high cut. The high cut is defined as the
306 // most-probably-value peak found from the energy distributions, minus
307 // 2 times the width of the corresponding Landau.
309 TAxis eAxis(axis.GetNbins(),
313 eAxis.Set(fits->GetEtaAxis().GetNbins(),
314 fits->GetEtaAxis().GetXmin(),
315 fits->GetEtaAxis().GetXmax());
317 UShort_t nEta = eAxis.GetNbins();
319 fHighCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
320 fHighCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
321 fHighCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
322 fHighCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
323 fHighCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
324 fHighCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
326 fLowCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
327 fLowCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
328 fLowCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
329 fLowCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
330 fLowCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
331 fLowCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
334 for (UShort_t d = 1; d <= 3; d++) {
335 UShort_t nr = (d == 1 ? 1 : 2);
336 for (UShort_t q = 0; q < nr; q++) {
337 Char_t r = (q == 0 ? 'I' : 'O');
339 for (UShort_t e = 1; e <= nEta; e++) {
340 Double_t eta = eAxis.GetBinCenter(e);
342 if (fDebug > 3) fHCuts.Print();
344 Double_t hcut = GetHighCut(d, r, eta, false);
345 Double_t lcut = GetLowCut(d, r, eta);
347 if (hcut > 0) fHighCuts->SetBinContent(e, ybin, hcut);
348 if (lcut > 0) fLowCuts ->SetBinContent(e, ybin, lcut);
354 //____________________________________________________________________
355 #define ETA2COS(ETA) \
356 TMath::Cos(2*TMath::ATan(TMath::Exp(-TMath::Abs(ETA))))
359 AliFMDSharingFilter::Filter(const AliESDFMD& input,
365 // Filter the input AliESDFMD object
369 // lowFlux If this is a low-flux event
370 // output Output AliESDFMD object
373 // True on success, false otherwise
375 DGUARD(fDebug,1, "Filter event in AliFMDSharingFilter");
377 TIter next(&fRingHistos);
379 while ((o = static_cast<RingHistos*>(next()))) o->Clear();
385 for(UShort_t d = 1; d <= 3; d++) {
386 Int_t nRings = (d == 1 ? 1 : 2);
387 for (UShort_t q = 0; q < nRings; q++) {
388 Char_t r = (q == 0 ? 'I' : 'O');
389 UShort_t nsec = (q == 0 ? 20 : 40);
390 UShort_t nstr = (q == 0 ? 512 : 256);
391 RingHistos* histos = GetRingHistos(d, r);
393 for(UShort_t s = 0; s < nsec; s++) {
394 // `used' flags if the _current_ strip was used by _previous_
396 Bool_t used = kFALSE;
397 // `eTotal' contains the current sum of merged signals so far
398 Double_t eTotal = -1;
399 // Int_t nDistanceBefore = -1;
400 // Int_t nDistanceAfter = -1;
401 // `twoLow' flags if we saw two consequtive strips with a
402 // signal between the two cuts.
403 Bool_t twoLow = kFALSE;
404 for(UShort_t t = 0; t < nstr; t++) {
405 // nDistanceBefore++;
408 output.SetMultiplicity(d,r,s,t,0.);
409 Float_t mult = SignalInStrip(input,d,r,s,t);
410 Float_t multNext = (t<nstr-1) ? SignalInStrip(input,d,r,s,t+1) :0;
411 Float_t multNextNext = (t<nstr-2) ? SignalInStrip(input,d,r,s,t+2) :0;
412 if (multNext == AliESDFMD::kInvalidMult) multNext = 0;
413 if (multNextNext == AliESDFMD::kInvalidMult) multNextNext = 0;
414 if(!fThreeStripSharing) multNextNext = 0;
416 // Get the pseudo-rapidity
417 Double_t eta = input.Eta(d,r,s,t);
418 Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
419 if (s == 0) output.SetEta(d,r,s,t,eta);
421 if(fRecalculateEta) {
422 Double_t etaOld = eta;
423 Double_t etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
426 if (mult > 0 && mult != AliESDFMD::kInvalidMult ) {
427 Double_t cosOld = ETA2COS(etaOld);
428 Double_t cosNew = ETA2COS(etaCalc);
429 Double_t corr = cosNew / cosOld;
432 multNextNext *= corr;
436 // Special case for pre revision 43611 AliFMDReconstructor.
437 // If fInvalidIsEmpty and we get an invalid signal from the
438 // ESD, then we need to set this signal to zero. Note, dead
439 // strips added in the ForwardAODConfig.C file are not
440 // effected by this, and we can use that to set the proper
442 if (mult == AliESDFMD::kInvalidMult && fInvalidIsEmpty)
445 // Keep dead-channel information - either from the ESD (but
446 // see above for older data) or from the settings in the
447 // ForwardAODConfig.C file.
448 if (mult == AliESDFMD::kInvalidMult || IsDead(d,r,s,t)) {
449 output.SetMultiplicity(d,r,s,t,AliESDFMD::kInvalidMult);
450 histos->fBefore->Fill(-1);
451 mult = AliESDFMD::kInvalidMult;
454 // If no signal or dead strip, go on.
455 if (mult == AliESDFMD::kInvalidMult || mult == 0) {
456 if (mult == 0) histos->fSum->Fill(eta,phi,mult);
457 // Flush a possible signal
458 if (eTotal > 0 && t > 0)
459 output.SetMultiplicity(d,r,s,t-1,eTotal);
460 // Reset states so we do not try to merge over a dead strip.
467 // Fill the diagnostics histogram
468 histos->fBefore->Fill(mult);
470 Double_t mergedEnergy = 0;
475 // Fill in neighbor information
476 if (t < nstr-1) histos->fNeighborsBefore->Fill(mult,multNext);
478 Bool_t thisValid = mult > GetLowCut(d, r, eta);
479 Bool_t nextValid = multNext > GetLowCut(d, r, eta);
480 Bool_t thisSmall = mult < GetHighCut(d, r, eta ,false);
481 Bool_t nextSmall = multNext < GetHighCut(d, r, eta ,false);
483 // If this strips signal is above the high cut, reset distance
485 // histos->fDistanceBefore->Fill(nDistanceBefore);
486 // nDistanceBefore = -1;
489 // If the total signal in the past 1 or 2 strips are non-zero
492 // Here, we have already flagged one strip as a candidate
494 // If 3-strip merging is enabled, then check the next
495 // strip to see that it falls within cut, or if we have
497 if (fThreeStripSharing && nextValid && (nextSmall || twoLow)) {
498 eTotal = eTotal + multNext;
500 histos->fTriple->Fill(eTotal);
504 // Otherwise, we got a double hit before, and that
508 histos->fDouble->Fill(eTotal);
511 // Store energy loss and reset sum
516 // If we have no current sum
518 // Check if this is marked as used, and if so, continue
519 if (used) {used = kFALSE; continue; }
521 // If the signal is abvoe the cut, set current
522 if (thisValid) etot = mult;
524 // If the signal is abiove the cut, and so is the next
525 // signal and either of them are below the high cut,
526 if (thisValid && nextValid && (thisSmall || nextSmall)) {
528 // If this is below the high cut, and the next is too, then
529 // we have two low signals
530 if (thisSmall && nextSmall) twoLow = kTRUE;
532 // If this signal is bigger than the next, and the
533 // one after that is below the low-cut, then update
535 if (mult>multNext && multNextNext < GetLowCut(d, r, eta)) {
536 etot = mult + multNext;
538 histos->fDouble->Fill(etot);
541 // Otherwise, we may need to merge with a third strip
544 eTotal = mult + multNext;
547 // This is a signle hit
549 histos->fSingle->Fill(etot);
550 histos->fSinglePerStrip->Fill(etot,t);
553 } // else if (etotal >= 0)
556 // if (mergedEnergy > GetHighCut(d, r, eta ,false)) {
557 // histos->fDistanceAfter->Fill(nDistanceAfter);
558 // nDistanceAfter = -1;
560 //if(mult>0 && multNext >0)
561 // std::cout<<mult<<" "<<multNext<<" "<<mergedEnergy<<std::endl;
564 mergedEnergy = AngleCorrect(mergedEnergy, eta);
565 // if (mergedEnergy > 0) histos->Incr();
568 histos->fNeighborsAfter->Fill(output.Multiplicity(d,r,s,t-1),
570 histos->fBeforeAfter->Fill(mult, mergedEnergy);
572 histos->fAfter->Fill(mergedEnergy);
573 histos->fSum->Fill(eta,phi,mergedEnergy);
575 output.SetMultiplicity(d,r,s,t,mergedEnergy);
580 DMSG(fDebug, 3,"single=%9d, double=%9d, triple=%9d",
581 nSingle, nDouble, nTriple);
583 // while ((o = static_cast<RingHistos*>(next()))) o->Finish();
588 //_____________________________________________________________________
590 AliFMDSharingFilter::SignalInStrip(const AliESDFMD& input,
597 // Get the signal in a strip
609 Double_t mult = input.Multiplicity(d,r,s,t);
611 // - bad value (invalid or 0)
612 // - we want angle corrected and data is
613 // - we don't want angle corrected and data isn't
614 // just return read value
615 if (mult == AliESDFMD::kInvalidMult ||
617 (fCorrectAngles && input.IsAngleCorrected()) ||
618 (!fCorrectAngles && !input.IsAngleCorrected()))
621 // If we want angle corrected data, correct it,
622 // otherwise de-correct it
623 if (fCorrectAngles) mult = AngleCorrect(mult, input.Eta(d,r,s,t));
624 else mult = DeAngleCorrect(mult, input.Eta(d,r,s,t));
627 //_____________________________________________________________________
629 AliFMDSharingFilter::GetLowCut(UShort_t d, Char_t r, Double_t eta) const
632 // Get the low cut. Normally, the low cut is taken to be the lower
633 // value of the fit range used when generating the energy loss fits.
634 // However, if fLowCut is set (using SetLowCit) to a value greater
635 // than 0, then that value is used.
637 return fLCuts.GetMultCut(d,r,eta,false);
639 if (!fCutAtFractionOfMPV && fLowCut > 0) return fLowCut;
641 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
642 AliFMDCorrELossFit* fits = fcm.GetELossFit();
644 if (fCutAtFractionOfMPV) {
645 AliFMDCorrELossFit::ELossFit* func = fits->GetFit(d,r,eta);
646 return fFractionOfMPV*func->GetDelta() ;
648 return fits->GetLowCut();
652 //_____________________________________________________________________
654 AliFMDSharingFilter::GetHighCut(UShort_t d, Char_t r,
655 Double_t eta, Bool_t errors) const
658 // Get the high cut. The high cut is defined as the
659 // most-probably-value peak found from the energy distributions, minus
660 // 2 times the width of the corresponding Landau.
662 return fHCuts.GetMultCut(d,r,eta,errors);
665 //_____________________________________________________________________
667 const char* status2String(AliFMDSharingFilter::Status s)
670 case AliFMDSharingFilter::kNone: return "none ";
671 case AliFMDSharingFilter::kCandidate: return "candidate";
672 case AliFMDSharingFilter::kMergedWithOther: return "merged ";
673 case AliFMDSharingFilter::kMergedInto: return "summed ";
679 //_____________________________________________________________________
681 AliFMDSharingFilter::MultiplicityOfStrip(Double_t thisE,
692 Status& nextStatus) const
694 Double_t lowCut = GetLowCut(d, r, eta);
696 DBG(3,Form("FMD%d%c[%2d,%3d]: this=%9f(%s), prev=%9f(%s), next=%9f(%s)",
698 thisE, status2String(thisStatus),
699 prevE, status2String(prevStatus),
700 nextE, status2String(nextStatus)));
702 // If below cut, then modify zero signal and make sure the next
703 // strip is considered a candidate.
704 if (thisE < lowCut || thisE > 100/*20*/) {
706 DBGL(5,Form(" %9f<%9f || %9f>20, 0'ed", thisE, lowCut, thisE));
707 if (prevStatus == kCandidate) prevStatus = kNone;
710 // It this strip was merged with the previous strip, then
711 // make the next strip a candidate and zero the value in this strip.
712 if (thisStatus == kMergedWithOther) {
713 DBGL(5,Form(" Merged with other, 0'ed"));
717 // Get the upper cut on the sharing
718 Double_t highCut = GetHighCut(d, r, eta ,false);
724 // Only for low-flux events
726 // If this is smaller than the next, and the next is larger
727 // then the cut, mark both as candidates for sharing.
728 // They should be be merged on the next iteration
729 if (thisE < nextE && nextE > highCut) {
730 thisStatus = kCandidate;
731 nextStatus = kCandidate;
736 // Variable to sum signal in
737 Double_t totalE = thisE;
739 // If the previous signal was between the two cuts, and is still
740 // marked as a candidate , then merge it in here.
741 if (prevStatus == kCandidate && prevE > lowCut && prevE < highCut) {
743 prevStatus = kMergedWithOther;
744 DBG(3, Form(" Prev candidate %9f<%9f<%9f->%9f",
745 lowCut, prevE, highCut, totalE));
748 // If the next signal is between the two cuts, then merge it here
749 if (nextE > lowCut && nextE < highCut) {
751 nextStatus = kMergedWithOther;
752 DBG(3, Form(" Next %9f<%9f<%9f->%9f", lowCut, nextE, highCut,totalE));
755 // If the signal is bigger than the high-cut, then return the value
756 if (totalE > highCut) {
758 thisStatus = kMergedInto;
761 DBGL(5, Form(" %9f>%f9 (was %9f) -> %9f %s",
762 totalE, highCut, thisE, totalE,status2String(thisStatus)));
766 // This is below cut, so flag next as a candidate
767 DBG(3, Form(" %9f<=%9f, next candidate", totalE, highCut));
768 nextStatus = kCandidate;
771 // If the total signal is smaller than low cut then zero this and kill this
772 if (totalE < lowCut) {
773 DBGL(5, Form(" %9f<%9f (was %9f), zeroed", totalE, lowCut, thisE));
778 // If total signal not above high cut or lower than low cut,
779 // mark this as a candidate for merging into the next, and zero signal
780 DBGL(5, Form(" %9f<%9f<%9f (was %9f), zeroed, candidate",
781 lowCut, totalE, highCut, thisE));
782 thisStatus = kCandidate;
783 return (fZeroSharedHitsBelowThreshold ? 0 : totalE);
786 //_____________________________________________________________________
788 AliFMDSharingFilter::MultiplicityOfStrip(Double_t mult,
798 Bool_t& usedThis) const
801 // The actual algorithm
804 // mult The unfiltered signal in the strip
805 // eta Psuedo rapidity
806 // prevE Previous strip signal (or 0)
807 // nextE Next strip signal (or 0)
808 // lowFlux Whether this is a low flux event
813 // usedPrev Whether the previous strip was used in sharing or not
814 // usedThis Wether this strip was used in sharing or not.
817 // The filtered signal in the strip
820 // IF the multiplicity is very large, or below the cut, reject it, and
821 // flag it as candidate for sharing
822 Double_t lowCut = GetLowCut(d,r,eta);
823 if(mult > 12 || mult < lowCut) {
829 // If this was shared with the previous signal, return 0 and mark it as
830 // not a candiate for sharing
837 //analyse and perform sharing on one strip
840 Double_t highCut = GetHighCut(d, r, eta, false);
847 // If this signal is smaller than the next, and the next signal is smaller
848 // than then the high cut, and it's a low-flux event, then mark this and
849 // the next signal as candidates for sharing
851 // This is the test if the signal is the smaller of two possibly
861 Double_t totalE = mult;
863 // If the previous signal was larger than the low cut, and
864 // the previous was smaller than high cut, and the previous signal
865 // isn't marked as used, then add it's energy to this signal
866 if (prevE > lowCut &&
871 // If the next signal is larger than the low cut, and
872 // the next signal is smaller than the high cut, then add the next signal
873 // to this, and marked the next signal as used
874 if(nextE > lowCut && nextE < highCut ) {
879 // If we're processing on non-angle corrected data, we should do the
880 // angle correction here
881 // if (!fCorrectAngles)
882 // totalE = AngleCorrect(totalE, eta);
884 // Fill post processing histogram
885 // if(totalE > fLowCut)
886 // GetRingHistos(d,r)->fAfter->Fill(totalE);
889 Double_t mergedEnergy = 0;
892 // If we have a signal, then this is used (sharedPrev=true) and
893 // the signal is set to the result
894 mergedEnergy = totalE;
898 // If we do not have a signal (too low), then this is not shared,
899 // and the next strip is not shared either
906 //____________________________________________________________________
908 AliFMDSharingFilter::AngleCorrect(Double_t mult, Double_t eta) const
911 // Angle correct the signal
914 // mult Angle Un-corrected Signal
915 // eta Pseudo-rapidity
918 // Angle corrected signal
920 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
921 if (eta < 0) theta -= TMath::Pi();
922 return mult * TMath::Cos(theta);
924 //____________________________________________________________________
926 AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
929 // Angle de-correct the signal
932 // mult Angle corrected Signal
933 // eta Pseudo-rapidity
936 // Angle un-corrected signal
938 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
939 if (eta < 0) theta -= TMath::Pi();
940 return mult / TMath::Cos(theta);
943 //____________________________________________________________________
945 AliFMDSharingFilter::Terminate(const TList* dir, TList* output, Int_t nEvents)
948 // Scale the histograms to the total number of events
951 // dir Where the output is
952 // nEvents Number of events
954 DGUARD(fDebug,1, "Scale histograms in AliFMDSharingFilter");
955 if (nEvents <= 0) return;
956 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
959 TList* out = new TList;
960 out->SetName(d->GetName());
963 TParameter<int>* nFiles =
964 static_cast<TParameter<int>*>(dir->FindObject("nFiles"));
966 TH2* lowCuts = static_cast<TH2*>(dir->FindObject("lowCuts"));
967 TH2* highCuts = static_cast<TH2*>(dir->FindObject("highCuts"));
968 if (lowCuts && nFiles) {
969 lowCuts->Scale(1. / nFiles->GetVal());
970 out->Add(lowCuts->Clone());
973 AliWarning("low cuts histogram not found in input list");
974 if (highCuts && nFiles) {
975 highCuts->Scale(1. / nFiles->GetVal());
976 out->Add(highCuts->Clone());
979 AliWarning("high cuts histogram not found in input list");
981 TIter next(&fRingHistos);
983 THStack* sums = new THStack("sums", "Sum of ring signals");
984 while ((o = static_cast<RingHistos*>(next()))) {
985 o->Terminate(d, nEvents);
987 Warning("Terminate", "No sum histogram found for ring %s", o->GetName());
990 TH1D* sum = o->fSum->ProjectionX(o->GetName(), 1, o->fSum->GetNbinsY(),"e");
991 sum->Scale(1., "width");
992 sum->SetTitle(o->GetName());
993 sum->SetDirectory(0);
994 sum->SetYTitle("#sum #Delta/#Delta_{mip}");
1001 //____________________________________________________________________
1003 AliFMDSharingFilter::CreateOutputObjects(TList* dir)
1006 // Define the output histograms. These are put in a sub list of the
1007 // passed list. The histograms are merged before the parent task calls
1008 // AliAnalysisTaskSE::Terminate
1011 // dir Directory to add to
1013 DGUARD(fDebug,1, "Define output in AliFMDSharingFilter");
1014 TList* d = new TList;
1015 d->SetName(GetName());
1019 fSummed = new TH2I("operations", "Strip operations",
1020 kMergedInto, kNone-.5, kMergedInto+.5,
1021 51201, -.5, 51200.5);
1022 fSummed->SetXTitle("Operation");
1023 fSummed->SetYTitle("# of strips");
1024 fSummed->SetZTitle("Events");
1025 fSummed->GetXaxis()->SetBinLabel(kNone, "None");
1026 fSummed->GetXaxis()->SetBinLabel(kCandidate, "Candidate");
1027 fSummed->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
1028 fSummed->GetXaxis()->SetBinLabel(kMergedInto, "Merged into");
1029 fSummed->SetDirectory(0);
1033 fHighCuts = new TH2D("highCuts", "High cuts used", 1,0,1, 1,0,1);
1034 fHighCuts->SetXTitle("#eta");
1035 fHighCuts->SetDirectory(0);
1038 fLowCuts = new TH2D("lowCuts", "Low cuts used", 1,0,1, 1,0,1);
1039 fLowCuts->SetXTitle("#eta");
1040 fLowCuts->SetDirectory(0);
1046 d->Add(AliForwardUtil::MakeParameter("angle", fCorrectAngles));
1047 d->Add(AliForwardUtil::MakeParameter("lowSignal",
1048 fZeroSharedHitsBelowThreshold));
1049 d->Add(AliForwardUtil::MakeParameter("simple", fUseSimpleMerging));
1050 d->Add(AliForwardUtil::MakeParameter("sumThree", fThreeStripSharing));
1051 TParameter<int>* nFiles = new TParameter<int>("nFiles", 1);
1052 nFiles->SetMergeMode('+');
1055 TObjArray* extraDead = new TObjArray;
1056 extraDead->SetOwner();
1057 extraDead->SetName("extraDead");
1058 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
1059 if (fExtraDead.At(i) < 0) break;
1062 Int_t id = fExtraDead.At(i);
1063 AliFMDStripIndex::Unpack(id, dd, r, s, t);
1064 extraDead->Add(AliForwardUtil::MakeParameter(Form("FMD%d%c[%02d,%03d]",
1068 fLCuts.Output(d,"lCuts");
1069 fHCuts.Output(d,"hCuts");
1071 TIter next(&fRingHistos);
1073 while ((o = static_cast<RingHistos*>(next()))) {
1074 o->CreateOutputObjects(d);
1077 //____________________________________________________________________
1079 AliFMDSharingFilter::Print(Option_t* /*option*/) const
1082 // Print information
1087 char ind[gROOT->GetDirLevel()+1];
1088 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
1089 ind[gROOT->GetDirLevel()] = '\0';
1090 std::cout << ind << ClassName() << ": " << GetName() << '\n'
1092 << ind << " Debug: " << fDebug << "\n"
1093 << ind << " Use corrected angles: " << fCorrectAngles << '\n'
1094 << ind << " Zero below threshold: "
1095 << fZeroSharedHitsBelowThreshold << '\n'
1096 << ind << " Use simple sharing: " << fUseSimpleMerging << '\n'
1097 << ind << " Consider invalid null: " << fInvalidIsEmpty << '\n'
1098 << ind << " Allow 3 strip merging: " << fThreeStripSharing
1099 << std::noboolalpha << std::endl;
1100 std::cout << ind << " Low cuts: " << std::endl;
1102 std::cout << ind << " High cuts: " << std::endl;
1106 //====================================================================
1107 AliFMDSharingFilter::RingHistos::RingHistos()
1108 : AliForwardUtil::RingHistos(),
1115 // fDistanceBefore(0),
1116 // fDistanceAfter(0),
1118 fNeighborsBefore(0),
1130 //____________________________________________________________________
1131 AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
1132 : AliForwardUtil::RingHistos(d,r),
1139 // fDistanceBefore(0),
1140 // fDistanceAfter(0),
1142 fNeighborsBefore(0),
1155 fBefore = new TH1D("esdEloss", Form("Energy loss in %s (reconstruction)",
1156 GetName()), 640, -1, 15);
1157 fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
1158 fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
1159 fBefore->SetFillColor(Color());
1160 fBefore->SetFillStyle(3001);
1161 fBefore->SetLineColor(kBlack);
1162 fBefore->SetLineStyle(2);
1163 fBefore->SetDirectory(0);
1165 fAfter = static_cast<TH1D*>(fBefore->Clone("anaEloss"));
1166 fAfter->SetTitle(Form("Energy loss in %s (sharing corrected)", GetName()));
1167 fAfter->SetFillColor(Color()+2);
1168 fAfter->SetLineStyle(1);
1169 fAfter->SetDirectory(0);
1171 fSingle = new TH1D("singleEloss", "Energy loss (single strips)",
1173 fSingle->SetXTitle("#Delta/#Delta_{mip}");
1174 fSingle->SetYTitle("P(#Delta/#Delta_{mip})");
1175 fSingle->SetFillColor(Color());
1176 fSingle->SetFillStyle(3001);
1177 fSingle->SetLineColor(kBlack);
1178 fSingle->SetLineStyle(2);
1179 fSingle->SetDirectory(0);
1181 fDouble = static_cast<TH1D*>(fSingle->Clone("doubleEloss"));
1182 fDouble->SetTitle("Energy loss (two strips)");
1183 fDouble->SetFillColor(Color()+1);
1184 fDouble->SetDirectory(0);
1186 fTriple = static_cast<TH1D*>(fSingle->Clone("tripleEloss"));
1187 fTriple->SetTitle("Energy loss (three strips)");
1188 fTriple->SetFillColor(Color()+2);
1189 fTriple->SetDirectory(0);
1191 //Int_t nBinsForInner = (r == 'I' ? 32 : 16);
1192 Int_t nBinsForInner = (r == 'I' ? 512 : 256);
1193 Int_t nStrips = (r == 'I' ? 512 : 256);
1195 fSinglePerStrip = new TH2D("singlePerStrip", "SinglePerStrip",
1196 600,0,15, nBinsForInner,0,nStrips);
1197 fSinglePerStrip->SetXTitle("#Delta/#Delta_{mip}");
1198 fSinglePerStrip->SetYTitle("Strip #");
1199 fSinglePerStrip->SetZTitle("Counts");
1200 fSinglePerStrip->SetDirectory(0);
1203 fDistanceBefore = new TH1D("distanceBefore", "Distance before sharing",
1204 nStrips , 0,nStrips );
1205 fDistanceBefore->SetXTitle("Distance");
1206 fDistanceBefore->SetYTitle("Counts");
1207 fDistanceBefore->SetFillColor(kGreen+2);
1208 fDistanceBefore->SetFillStyle(3001);
1209 fDistanceBefore->SetLineColor(kBlack);
1210 fDistanceBefore->SetLineStyle(2);
1211 fDistanceBefore->SetDirectory(0);
1213 fDistanceAfter = static_cast<TH1D*>(fDistanceBefore->Clone("distanceAfter"));
1214 fDistanceAfter->SetTitle("Distance after sharing");
1215 fDistanceAfter->SetFillColor(kGreen+1);
1216 fDistanceAfter->SetDirectory(0);
1223 Int_t n = int((max-min) / (max / 300));
1224 fBeforeAfter = new TH2D("beforeAfter", "Before and after correlation",
1225 n, min, max, n, min, max);
1226 fBeforeAfter->SetXTitle("#Delta E/#Delta E_{mip} before");
1227 fBeforeAfter->SetYTitle("#Delta E/#Delta E_{mip} after");
1228 fBeforeAfter->SetZTitle("Correlation");
1229 fBeforeAfter->SetDirectory(0);
1231 fNeighborsBefore = static_cast<TH2D*>(fBeforeAfter->Clone("neighborsBefore"));
1232 fNeighborsBefore->SetTitle("Correlation of neighbors before");
1233 fNeighborsBefore->SetXTitle("#Delta E_{i}/#Delta E_{mip}");
1234 fNeighborsBefore->SetYTitle("#Delta E_{i+1}/#Delta E_{mip}");
1235 fNeighborsBefore->SetDirectory(0);
1238 static_cast<TH2D*>(fNeighborsBefore->Clone("neighborsAfter"));
1239 fNeighborsAfter->SetTitle("Correlation of neighbors after");
1240 fNeighborsAfter->SetDirectory(0);
1242 fSum = new TH2D("summed", "Summed signal", 200, -4, 6,
1243 (fRing == 'I' || fRing == 'i' ? 20 : 40), 0, 2*TMath::Pi());
1244 fSum->SetDirectory(0);
1246 fSum->SetMarkerColor(Color());
1247 // fSum->SetFillColor(Color());
1248 fSum->SetXTitle("#eta");
1249 fSum->SetYTitle("#varphi [radians]");
1250 fSum->SetZTitle("#sum #Delta/#Delta_{mip}(#eta,#varphi) ");
1253 fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
1254 fHits->SetDirectory(0);
1255 fHits->SetXTitle("# of hits");
1256 fHits->SetFillColor(kGreen+1);
1259 //____________________________________________________________________
1260 AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
1261 : AliForwardUtil::RingHistos(o),
1267 fSinglePerStrip(o.fSinglePerStrip),
1268 // fDistanceBefore(o.fDistanceBefore),
1269 // fDistanceAfter(o.fDistanceAfter),
1270 fBeforeAfter(o.fBeforeAfter),
1271 fNeighborsBefore(o.fNeighborsBefore),
1272 fNeighborsAfter(o.fNeighborsAfter),
1281 // o Object to copy from
1285 //____________________________________________________________________
1286 AliFMDSharingFilter::RingHistos&
1287 AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
1290 // Assignment operator
1293 // o Object to assign from
1296 // Reference to this
1298 if (&o == this) return *this;
1299 AliForwardUtil::RingHistos::operator=(o);
1303 if (fBefore) delete fBefore;
1304 if (fAfter) delete fAfter;
1305 if (fSingle) delete fSingle;
1306 if (fDouble) delete fDouble;
1307 if (fTriple) delete fTriple;
1308 if (fSinglePerStrip) delete fSinglePerStrip;
1309 // if (fDistanceBefore) delete fDistanceBefore;
1310 // if (fDistanceAfter) delete fDistanceAfter;
1311 // if (fHits) delete fHits;
1314 fBefore = static_cast<TH1D*>(o.fBefore->Clone());
1315 fAfter = static_cast<TH1D*>(o.fAfter->Clone());
1316 fSingle = static_cast<TH1D*>(o.fSingle->Clone());
1317 fDouble = static_cast<TH1D*>(o.fDouble->Clone());
1318 fTriple = static_cast<TH1D*>(o.fTriple->Clone());
1319 fSinglePerStrip = static_cast<TH2D*>(o.fSinglePerStrip->Clone());
1320 // fDistanceBefore = static_cast<TH1D*>(o.fDistanceBefore->Clone());
1321 // fDistanceAfter = static_cast<TH1D*>(o.fDistanceAfter->Clone());
1322 fBeforeAfter = static_cast<TH2D*>(o.fBeforeAfter->Clone());
1323 fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
1324 fNeighborsAfter = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
1325 // fHits = static_cast<TH1D*>(o.fHits->Clone());
1326 fSum = static_cast<TH2D*>(o.fSum->Clone());
1330 //____________________________________________________________________
1331 AliFMDSharingFilter::RingHistos::~RingHistos()
1338 //____________________________________________________________________
1340 AliFMDSharingFilter::RingHistos::Finish()
1346 // fHits->Fill(fNHits);
1349 //____________________________________________________________________
1351 AliFMDSharingFilter::RingHistos::Terminate(const TList* dir, Int_t nEvents)
1354 // Scale the histograms to the total number of events
1357 // nEvents Number of events
1358 // dir Where the output is
1360 TList* l = GetOutputList(dir);
1364 TH1D* before = static_cast<TH1D*>(l->FindObject("esdEloss"));
1365 TH1D* after = static_cast<TH1D*>(l->FindObject("anaEloss"));
1366 if (before) before->Scale(1./nEvents);
1367 if (after) after->Scale(1./nEvents);
1370 TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
1371 if (summed) summed->Scale(1./nEvents);
1375 //____________________________________________________________________
1377 AliFMDSharingFilter::RingHistos::CreateOutputObjects(TList* dir)
1383 // dir where to store
1385 TList* d = DefineOutputList(dir);
1392 d->Add(fSinglePerStrip);
1393 // d->Add(fDistanceBefore);
1394 // d->Add(fDistanceAfter);
1395 d->Add(fBeforeAfter);
1396 d->Add(fNeighborsBefore);
1397 d->Add(fNeighborsAfter);
1401 // Removed to avoid doubly adding the list which destroys
1406 //____________________________________________________________________