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),
71 // Default Constructor - do not use
73 DGUARD(fDebug,1, "Default CTOR for AliFMDSharingFilter");
76 //____________________________________________________________________
77 AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
78 : TNamed("fmdSharingFilter", title),
80 fCorrectAngles(kFALSE),
86 fZeroSharedHitsBelowThreshold(false),
89 fUseSimpleMerging(false),
90 fThreeStripSharing(true),
91 fRecalculateEta(false),
98 // title Title of object - not significant
100 DGUARD(fDebug,1, "Named CTOR for AliFMDSharingFilter: %s", title);
101 fRingHistos.SetName(GetName());
102 fRingHistos.SetOwner();
104 fRingHistos.Add(new RingHistos(1, 'I'));
105 fRingHistos.Add(new RingHistos(2, 'I'));
106 fRingHistos.Add(new RingHistos(2, 'O'));
107 fRingHistos.Add(new RingHistos(3, 'I'));
108 fRingHistos.Add(new RingHistos(3, 'O'));
111 fHCuts.SetIncludeSigma(1);
112 fLCuts.SetMultCuts(.15);
114 fExtraDead.Reset(-1);
117 //____________________________________________________________________
118 AliFMDSharingFilter::AliFMDSharingFilter(const AliFMDSharingFilter& o)
121 fCorrectAngles(o.fCorrectAngles),
123 fHighCuts(o.fHighCuts),
124 fLowCuts(o.fLowCuts),
127 fZeroSharedHitsBelowThreshold(o.fZeroSharedHitsBelowThreshold),
130 fUseSimpleMerging(o.fUseSimpleMerging),
131 fThreeStripSharing(o.fThreeStripSharing),
132 fRecalculateEta(o.fRecalculateEta),
133 fExtraDead(o.fExtraDead)
139 // o Object to copy from
141 DGUARD(fDebug,1, "Copy CTOR for AliFMDSharingFilter");
142 TIter next(&o.fRingHistos);
144 while ((obj = next())) fRingHistos.Add(obj);
147 //____________________________________________________________________
148 AliFMDSharingFilter::~AliFMDSharingFilter()
153 DGUARD(fDebug,3, "DTOR for AliFMDSharingFilter");
154 // fRingHistos.Delete();
157 //____________________________________________________________________
159 AliFMDSharingFilter::operator=(const AliFMDSharingFilter& o)
162 // Assignment operator
165 // o Object to assign from
170 DGUARD(fDebug,3, "Assigment for AliFMDSharingFilter");
171 if (&o == this) return *this;
172 TNamed::operator=(o);
174 fCorrectAngles = o.fCorrectAngles;
178 fHighCuts = o.fHighCuts;
179 fLowCuts = o.fLowCuts;
180 fZeroSharedHitsBelowThreshold = o.fZeroSharedHitsBelowThreshold;
183 fUseSimpleMerging = o.fUseSimpleMerging;
184 fThreeStripSharing = o.fThreeStripSharing;
185 fRecalculateEta = o.fRecalculateEta;
187 fRingHistos.Delete();
188 TIter next(&o.fRingHistos);
190 while ((obj = next())) fRingHistos.Add(obj);
195 //____________________________________________________________________
196 AliFMDSharingFilter::RingHistos*
197 AliFMDSharingFilter::GetRingHistos(UShort_t d, Char_t r) const
200 // Get the ring histogram container
207 // Ring histogram container
211 case 1: idx = 0; break;
212 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
213 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
215 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
217 return static_cast<RingHistos*>(fRingHistos.At(idx));
220 //____________________________________________________________________
222 AliFMDSharingFilter::AddDead(UShort_t d, Char_t r, UShort_t s, UShort_t t)
224 if (d < 1 || d > 3) {
225 Warning("AddDead", "Invalid detector FMD%d", d);
228 Bool_t inner = (r == 'I' || r == 'i');
229 if (d == 1 && !inner) {
230 Warning("AddDead", "Invalid ring FMD%d%c", d, r);
233 if ((inner && s >= 20) || (!inner && s >= 40)) {
234 Warning("AddDead", "Invalid sector FMD%d%c[%02d]", d, r, s);
237 if ((inner && t >= 512) || (!inner && t >= 256)) {
238 Warning("AddDead", "Invalid strip FMD%d%c[%02d,%03d]", d, r, s, t);
242 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
244 for (i = 0; i < fExtraDead.GetSize(); i++) {
245 Int_t j = fExtraDead.At(i);
246 if (j == id) return; // Already there
247 if (j < 0) break; // Free slot
249 if (i >= fExtraDead.GetSize()) {
250 Warning("AddDead", "No free slot to add FMD%d%c[%02d,%03d] at",
256 //____________________________________________________________________
258 AliFMDSharingFilter::AddDeadRegion(UShort_t d, Char_t r,
259 UShort_t s1, UShort_t s2,
260 UShort_t t1, UShort_t t2)
262 // Add a dead region spanning from FMD<d><r>[<s1>,<t1>] to
263 // FMD<d><r>[<s2>,<t2>] (both inclusive)
264 for (Int_t s = s1; s <= s2; s++)
265 for (Int_t t = t1; t <= t2; t++)
268 //____________________________________________________________________
270 AliFMDSharingFilter::IsDead(UShort_t d, Char_t r, UShort_t s, UShort_t t) const
272 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
273 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
274 Int_t j = fExtraDead.At(i);
276 //Info("IsDead", "FMD%d%c[%02d,%03d] marked as dead here", d, r, s, t);
279 if (j < 0) break; // High water mark
283 //____________________________________________________________________
285 AliFMDSharingFilter::Init(const TAxis& axis)
288 DGUARD(fDebug,1, "Initialize for AliFMDSharingFilter");
289 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
290 AliFMDCorrELossFit* fits = fcm.GetELossFit();
292 // Get the high cut. The high cut is defined as the
293 // most-probably-value peak found from the energy distributions, minus
294 // 2 times the width of the corresponding Landau.
296 TAxis eAxis(axis.GetNbins(),
300 eAxis.Set(fits->GetEtaAxis().GetNbins(),
301 fits->GetEtaAxis().GetXmin(),
302 fits->GetEtaAxis().GetXmax());
304 UShort_t nEta = eAxis.GetNbins();
306 fHighCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
307 fHighCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
308 fHighCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
309 fHighCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
310 fHighCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
311 fHighCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
313 fLowCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
314 fLowCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
315 fLowCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
316 fLowCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
317 fLowCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
318 fLowCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
321 for (UShort_t d = 1; d <= 3; d++) {
322 UShort_t nr = (d == 1 ? 1 : 2);
323 for (UShort_t q = 0; q < nr; q++) {
324 Char_t r = (q == 0 ? 'I' : 'O');
326 for (UShort_t e = 1; e <= nEta; e++) {
327 Double_t eta = eAxis.GetBinCenter(e);
329 if (fDebug > 3) fHCuts.Print();
331 Double_t hcut = GetHighCut(d, r, eta, false);
332 Double_t lcut = GetLowCut(d, r, eta);
334 if (hcut > 0) fHighCuts->SetBinContent(e, ybin, hcut);
335 if (lcut > 0) fLowCuts ->SetBinContent(e, ybin, lcut);
341 //____________________________________________________________________
342 #define ETA2COS(ETA) \
343 TMath::Cos(2*TMath::ATan(TMath::Exp(-TMath::Abs(ETA))))
346 AliFMDSharingFilter::Filter(const AliESDFMD& input,
352 // Filter the input AliESDFMD object
356 // lowFlux If this is a low-flux event
357 // output Output AliESDFMD object
360 // True on success, false otherwise
362 DGUARD(fDebug,1, "Filter event in AliFMDSharingFilter");
364 TIter next(&fRingHistos);
366 while ((o = static_cast<RingHistos*>(next())))
369 if (fOper) fOper->Reset(0);
371 Int_t nCandidate = 0;
380 for(UShort_t d = 1; d <= 3; d++) {
381 Int_t nRings = (d == 1 ? 1 : 2);
382 for (UShort_t q = 0; q < nRings; q++) {
383 Char_t r = (q == 0 ? 'I' : 'O');
384 UShort_t nsec = (q == 0 ? 20 : 40);
385 UShort_t nstr = (q == 0 ? 512 : 256);
386 RingHistos* histos = GetRingHistos(d, r);
388 for(UShort_t s = 0; s < nsec; s++) {
390 for (UShort_t t = 0; t < nstr; t++) status[t] = kCandidate;
393 Bool_t used = kFALSE;
394 Double_t eTotal = -1;
395 Int_t nDistanceBefore = -1;
396 Int_t nDistanceAfter = -1;
397 Bool_t twoLow = kFALSE;
398 for(UShort_t t = 0; t < nstr; t++) {
402 output.SetMultiplicity(d,r,s,t,0.);
403 Float_t mult = SignalInStrip(input,d,r,s,t);
404 Float_t multNext = (t<nstr-1) ? SignalInStrip(input,d,r,s,t+1) :0;
405 Float_t multNextNext = (t<nstr-2) ? SignalInStrip(input,d,r,s,t+2) :0;
406 if (multNext == AliESDFMD::kInvalidMult) multNext = 0;
407 if (multNextNext == AliESDFMD::kInvalidMult) multNextNext = 0;
408 if(!fThreeStripSharing) multNextNext = 0;
410 // Get the pseudo-rapidity
411 Double_t eta = input.Eta(d,r,s,t);
412 Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
413 if (s == 0) output.SetEta(d,r,s,t,eta);
415 if(fRecalculateEta) {
416 Double_t etaOld = eta;
417 Double_t etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
420 if (mult > 0 && mult != AliESDFMD::kInvalidMult ) {
421 Double_t cosOld = ETA2COS(etaOld);
422 Double_t cosNew = ETA2COS(etaCalc);
423 Double_t corr = cosNew / cosOld;
426 multNextNext *= corr;
430 // Keep dead-channel information.
431 if(mult == AliESDFMD::kInvalidMult || IsDead(d,r,s,t))
432 output.SetMultiplicity(d,r,s,t,AliESDFMD::kInvalidMult);
434 // If no signal or dead strip, go on.
435 if (mult == AliESDFMD::kInvalidMult || mult == 0) {
436 if (mult == 0) histos->fSum->Fill(eta,phi,mult);
441 // Fill the diagnostics histogram
442 histos->fBefore->Fill(mult);
444 Double_t mergedEnergy = 0;
446 if(fUseSimpleMerging) {
448 if (t < nstr-1) histos->fNeighborsBefore->Fill(mult,multNext);
449 if(mult > GetHighCut(d, r, eta ,false)) {
450 histos->fDistanceBefore->Fill(nDistanceBefore);
451 nDistanceBefore = -1;
455 if(fThreeStripSharing && multNext > GetLowCut(d, r, eta) &&
456 (multNext < GetHighCut(d, r, eta ,false) || twoLow)) {
457 eTotal = eTotal + multNext;
459 histos->fTriple->Fill(eTotal);
465 histos->fDouble->Fill(eTotal);
472 if(used) {used = kFALSE; continue; }
473 if(mult > GetLowCut(d, r, eta)) etot = mult;
475 if(mult > GetLowCut(d, r, eta) &&
476 multNext > GetLowCut(d, r, eta) &&
477 (mult < GetHighCut(d, r, eta ,false) ||
478 multNext < GetHighCut(d, r, eta ,false))) {
480 if(mult < GetHighCut(d, r, eta ,false) &&
481 multNext < GetHighCut(d, r, eta ,false) )
484 if(mult>multNext && multNextNext < GetLowCut(d, r, eta))
486 etot = mult + multNext;
488 histos->fDouble->Fill(etot);
493 eTotal = mult + multNext;
498 histos->fSingle->Fill(etot);
499 histos->fSinglePerStrip->Fill(etot,t);
506 if(mergedEnergy > GetHighCut(d, r, eta ,false) ) {
507 histos->fDistanceAfter->Fill(nDistanceAfter);
510 //if(mult>0 && multNext >0)
511 // std::cout<<mult<<" "<<multNext<<" "<<mergedEnergy<<std::endl;
512 } // End of simple merge
514 // Get next and previous signal - if any
517 Status prevStatus = (t == 0 ? kNone : status[t-1]);
518 Status thisStatus = status[t];
519 Status nextStatus = (t == nstr-1 ? kNone : status[t+1]);
521 prevE = SignalInStrip(input,d,r,s,t-1);
522 if (prevE == AliESDFMD::kInvalidMult) prevE = 0;
525 nextE = SignalInStrip(input,d,r,s,t+1);
526 if (nextE == AliESDFMD::kInvalidMult) nextE = 0;
528 if (t != 0) histos->fNeighborsBefore->Fill(prevE, mult);
530 mergedEnergy = MultiplicityOfStrip(mult, prevE, nextE,
536 if (t != 0) status[t-1] = prevStatus;
537 if (t != nstr-1) status[t+1] = nextStatus;
538 status[t] = thisStatus;
539 // If we're processing on non-angle corrected data, we
540 // should do the angle correction here
541 } // End of non-simple
543 mergedEnergy = AngleCorrect(mergedEnergy, eta);
544 if (mergedEnergy > 0) histos->Incr();
547 histos->fNeighborsAfter->Fill(output.Multiplicity(d,r,s,t-1),
549 histos->fBeforeAfter->Fill(mult, mergedEnergy);
551 histos->fAfter->Fill(mergedEnergy);
552 histos->fSum->Fill(eta,phi,mergedEnergy);
554 output.SetMultiplicity(d,r,s,t,mergedEnergy);
556 for (UShort_t t = 0; t < nstr; t++) {
557 if (fOper) fOper->operator()(d, r, s, t) = status[t];
559 case kNone: nNone++; break;
560 case kCandidate: nCandidate++; break;
561 case kMergedWithOther: nMerged++; break;
562 case kMergedInto: nSummed++; break;
568 fSummed->Fill(kNone, nNone);
569 fSummed->Fill(kCandidate, nCandidate);
570 fSummed->Fill(kMergedWithOther, nMerged);
571 fSummed->Fill(kMergedInto, nSummed);
573 DMSG(fDebug, 3,"single=%9d, double=%9d, triple=%9d",
574 nSingle, nDouble, nTriple);
576 while ((o = static_cast<RingHistos*>(next())))
582 //_____________________________________________________________________
584 AliFMDSharingFilter::SignalInStrip(const AliESDFMD& input,
591 // Get the signal in a strip
603 Double_t mult = input.Multiplicity(d,r,s,t);
605 // - bad value (invalid or 0)
606 // - we want angle corrected and data is
607 // - we don't want angle corrected and data isn't
608 // just return read value
609 if (mult == AliESDFMD::kInvalidMult ||
611 (fCorrectAngles && input.IsAngleCorrected()) ||
612 (!fCorrectAngles && !input.IsAngleCorrected()))
615 // If we want angle corrected data, correct it,
616 // otherwise de-correct it
617 if (fCorrectAngles) mult = AngleCorrect(mult, input.Eta(d,r,s,t));
618 else mult = DeAngleCorrect(mult, input.Eta(d,r,s,t));
621 //_____________________________________________________________________
623 AliFMDSharingFilter::GetLowCut(UShort_t d, Char_t r, Double_t eta) const
626 // Get the low cut. Normally, the low cut is taken to be the lower
627 // value of the fit range used when generating the energy loss fits.
628 // However, if fLowCut is set (using SetLowCit) to a value greater
629 // than 0, then that value is used.
631 return fLCuts.GetMultCut(d,r,eta,false);
633 if (!fCutAtFractionOfMPV && fLowCut > 0) return fLowCut;
635 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
636 AliFMDCorrELossFit* fits = fcm.GetELossFit();
638 if (fCutAtFractionOfMPV) {
639 AliFMDCorrELossFit::ELossFit* func = fits->GetFit(d,r,eta);
640 return fFractionOfMPV*func->GetDelta() ;
642 return fits->GetLowCut();
646 //_____________________________________________________________________
648 AliFMDSharingFilter::GetHighCut(UShort_t d, Char_t r,
649 Double_t eta, Bool_t errors) const
652 // Get the high cut. The high cut is defined as the
653 // most-probably-value peak found from the energy distributions, minus
654 // 2 times the width of the corresponding Landau.
656 return fHCuts.GetMultCut(d,r,eta,errors);
659 //_____________________________________________________________________
661 const char* status2String(AliFMDSharingFilter::Status s)
664 case AliFMDSharingFilter::kNone: return "none ";
665 case AliFMDSharingFilter::kCandidate: return "candidate";
666 case AliFMDSharingFilter::kMergedWithOther: return "merged ";
667 case AliFMDSharingFilter::kMergedInto: return "summed ";
673 //_____________________________________________________________________
675 AliFMDSharingFilter::MultiplicityOfStrip(Double_t thisE,
686 Status& nextStatus) const
688 Double_t lowCut = GetLowCut(d, r, eta);
690 DBG(3,Form("FMD%d%c[%2d,%3d]: this=%9f(%s), prev=%9f(%s), next=%9f(%s)",
692 thisE, status2String(thisStatus),
693 prevE, status2String(prevStatus),
694 nextE, status2String(nextStatus)));
696 // If below cut, then modify zero signal and make sure the next
697 // strip is considered a candidate.
698 if (thisE < lowCut || thisE > 20) {
700 DBGL(5,Form(" %9f<%9f || %9f>20, 0'ed", thisE, lowCut, thisE));
701 if (prevStatus == kCandidate) prevStatus = kNone;
704 // It this strip was merged with the previous strip, then
705 // make the next strip a candidate and zero the value in this strip.
706 if (thisStatus == kMergedWithOther) {
707 DBGL(5,Form(" Merged with other, 0'ed"));
711 // Get the upper cut on the sharing
712 Double_t highCut = GetHighCut(d, r, eta ,false);
718 // Only for low-flux events
720 // If this is smaller than the next, and the next is larger
721 // then the cut, mark both as candidates for sharing.
722 // They should be be merged on the next iteration
723 if (thisE < nextE && nextE > highCut) {
724 thisStatus = kCandidate;
725 nextStatus = kCandidate;
730 // Variable to sum signal in
731 Double_t totalE = thisE;
733 // If the previous signal was between the two cuts, and is still
734 // marked as a candidate , then merge it in here.
735 if (prevStatus == kCandidate && prevE > lowCut && prevE < highCut) {
737 prevStatus = kMergedWithOther;
738 DBG(3, Form(" Prev candidate %9f<%9f<%9f->%9f",
739 lowCut, prevE, highCut, totalE));
742 // If the next signal is between the two cuts, then merge it here
743 if (nextE > lowCut && nextE < highCut) {
745 nextStatus = kMergedWithOther;
746 DBG(3, Form(" Next %9f<%9f<%9f->%9f", lowCut, nextE, highCut,totalE));
749 // If the signal is bigger than the high-cut, then return the value
750 if (totalE > highCut) {
752 thisStatus = kMergedInto;
755 DBGL(5, Form(" %9f>%f9 (was %9f) -> %9f %s",
756 totalE, highCut, thisE, totalE,status2String(thisStatus)));
760 // This is below cut, so flag next as a candidate
761 DBG(3, Form(" %9f<=%9f, next candidate", totalE, highCut));
762 nextStatus = kCandidate;
765 // If the total signal is smaller than low cut then zero this and kill this
766 if (totalE < lowCut) {
767 DBGL(5, Form(" %9f<%9f (was %9f), zeroed", totalE, lowCut, thisE));
772 // If total signal not above high cut or lower than low cut,
773 // mark this as a candidate for merging into the next, and zero signal
774 DBGL(5, Form(" %9f<%9f<%9f (was %9f), zeroed, candidate",
775 lowCut, totalE, highCut, thisE));
776 thisStatus = kCandidate;
777 return (fZeroSharedHitsBelowThreshold ? 0 : totalE);
780 //_____________________________________________________________________
782 AliFMDSharingFilter::MultiplicityOfStrip(Double_t mult,
792 Bool_t& usedThis) const
795 // The actual algorithm
798 // mult The unfiltered signal in the strip
799 // eta Psuedo rapidity
800 // prevE Previous strip signal (or 0)
801 // nextE Next strip signal (or 0)
802 // lowFlux Whether this is a low flux event
807 // usedPrev Whether the previous strip was used in sharing or not
808 // usedThis Wether this strip was used in sharing or not.
811 // The filtered signal in the strip
814 // IF the multiplicity is very large, or below the cut, reject it, and
815 // flag it as candidate for sharing
816 Double_t lowCut = GetLowCut(d,r,eta);
817 if(mult > 12 || mult < lowCut) {
823 // If this was shared with the previous signal, return 0 and mark it as
824 // not a candiate for sharing
831 //analyse and perform sharing on one strip
834 Double_t highCut = GetHighCut(d, r, eta, false);
841 // If this signal is smaller than the next, and the next signal is smaller
842 // than then the high cut, and it's a low-flux event, then mark this and
843 // the next signal as candidates for sharing
845 // This is the test if the signal is the smaller of two possibly
855 Double_t totalE = mult;
857 // If the previous signal was larger than the low cut, and
858 // the previous was smaller than high cut, and the previous signal
859 // isn't marked as used, then add it's energy to this signal
860 if (prevE > lowCut &&
865 // If the next signal is larger than the low cut, and
866 // the next signal is smaller than the high cut, then add the next signal
867 // to this, and marked the next signal as used
868 if(nextE > lowCut && nextE < highCut ) {
873 // If we're processing on non-angle corrected data, we should do the
874 // angle correction here
875 // if (!fCorrectAngles)
876 // totalE = AngleCorrect(totalE, eta);
878 // Fill post processing histogram
879 // if(totalE > fLowCut)
880 // GetRingHistos(d,r)->fAfter->Fill(totalE);
883 Double_t mergedEnergy = 0;
886 // If we have a signal, then this is used (sharedPrev=true) and
887 // the signal is set to the result
888 mergedEnergy = totalE;
892 // If we do not have a signal (too low), then this is not shared,
893 // and the next strip is not shared either
900 //____________________________________________________________________
902 AliFMDSharingFilter::AngleCorrect(Double_t mult, Double_t eta) const
905 // Angle correct the signal
908 // mult Angle Un-corrected Signal
909 // eta Pseudo-rapidity
912 // Angle corrected signal
914 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
915 if (eta < 0) theta -= TMath::Pi();
916 return mult * TMath::Cos(theta);
918 //____________________________________________________________________
920 AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
923 // Angle de-correct the signal
926 // mult Angle corrected Signal
927 // eta Pseudo-rapidity
930 // Angle un-corrected signal
932 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
933 if (eta < 0) theta -= TMath::Pi();
934 return mult / TMath::Cos(theta);
937 //____________________________________________________________________
939 AliFMDSharingFilter::ScaleHistograms(const TList* dir, Int_t nEvents)
942 // Scale the histograms to the total number of events
945 // dir Where the output is
946 // nEvents Number of events
948 DGUARD(fDebug,1, "Scale histograms in AliFMDSharingFilter");
949 if (nEvents <= 0) return;
950 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
953 TIter next(&fRingHistos);
955 THStack* sums = new THStack("sums", "Sum of ring signals");
956 while ((o = static_cast<RingHistos*>(next()))) {
957 o->ScaleHistograms(d, nEvents);
958 TH1D* sum = o->fSum->ProjectionX(o->GetName(), 1, o->fSum->GetNbinsY(),"e");
959 sum->Scale(1., "width");
960 sum->SetTitle(o->GetName());
961 sum->SetDirectory(0);
962 sum->SetYTitle("#sum #Delta/#Delta_{mip}");
968 //____________________________________________________________________
970 AliFMDSharingFilter::DefineOutput(TList* dir)
973 // Define the output histograms. These are put in a sub list of the
974 // passed list. The histograms are merged before the parent task calls
975 // AliAnalysisTaskSE::Terminate
978 // dir Directory to add to
980 DGUARD(fDebug,1, "Define output in AliFMDSharingFilter");
981 TList* d = new TList;
982 d->SetName(GetName());
985 fSummed = new TH2I("operations", "Strip operations",
986 kMergedInto, kNone-.5, kMergedInto+.5,
987 51201, -.5, 51200.5);
988 fSummed->SetXTitle("Operation");
989 fSummed->SetYTitle("# of strips");
990 fSummed->SetZTitle("Events");
991 fSummed->GetXaxis()->SetBinLabel(kNone, "None");
992 fSummed->GetXaxis()->SetBinLabel(kCandidate, "Candidate");
993 fSummed->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
994 fSummed->GetXaxis()->SetBinLabel(kMergedInto, "Merged into");
995 fSummed->SetDirectory(0);
998 fHighCuts = new TH2D("highCuts", "High cuts used", 1,0,1, 1,0,1);
999 fHighCuts->SetXTitle("#eta");
1000 fHighCuts->SetDirectory(0);
1003 fLowCuts = new TH2D("lowCuts", "Low cuts used", 1,0,1, 1,0,1);
1004 fLowCuts->SetXTitle("#eta");
1005 fLowCuts->SetDirectory(0);
1011 d->Add(AliForwardUtil::MakeParameter("angle", fCorrectAngles));
1012 d->Add(AliForwardUtil::MakeParameter("lowSignal",
1013 fZeroSharedHitsBelowThreshold));
1014 d->Add(AliForwardUtil::MakeParameter("simple", fUseSimpleMerging));
1016 TObjArray* extraDead = new TObjArray;
1017 extraDead->SetOwner();
1018 extraDead->SetName("extraDead");
1019 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
1020 if (fExtraDead.At(i) < 0) break;
1023 Int_t id = fExtraDead.At(i);
1024 AliFMDStripIndex::Unpack(id, dd, r, s, t);
1025 extraDead->Add(AliForwardUtil::MakeParameter(Form("FMD%d%c[%02d,%03d]",
1029 fLCuts.Output(d,"lCuts");
1030 fHCuts.Output(d,"hCuts");
1032 TIter next(&fRingHistos);
1034 while ((o = static_cast<RingHistos*>(next()))) {
1038 //____________________________________________________________________
1040 AliFMDSharingFilter::Print(Option_t* /*option*/) const
1043 // Print information
1048 char ind[gROOT->GetDirLevel()+1];
1049 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
1050 ind[gROOT->GetDirLevel()] = '\0';
1051 std::cout << ind << ClassName() << ": " << GetName() << '\n'
1053 << ind << " Debug: " << fDebug << "\n"
1054 << ind << " Use corrected angles: " << fCorrectAngles << '\n'
1055 << ind << " Zero below threshold: "
1056 << fZeroSharedHitsBelowThreshold << '\n'
1057 << ind << " Use simple sharing: " << fUseSimpleMerging << '\n'
1058 << std::noboolalpha << std::endl;
1059 std::cout << ind << " Low cuts: " << std::endl;
1061 std::cout << ind << " High cuts: " << std::endl;
1065 //====================================================================
1066 AliFMDSharingFilter::RingHistos::RingHistos()
1067 : AliForwardUtil::RingHistos(),
1077 fNeighborsBefore(0),
1089 //____________________________________________________________________
1090 AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
1091 : AliForwardUtil::RingHistos(d,r),
1101 fNeighborsBefore(0),
1114 fBefore = new TH1D("esdEloss", Form("Energy loss in %s (reconstruction)",
1115 GetName()), 600, 0, 15);
1116 fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
1117 fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
1118 fBefore->SetFillColor(Color());
1119 fBefore->SetFillStyle(3001);
1120 fBefore->SetLineColor(kBlack);
1121 fBefore->SetLineStyle(2);
1122 fBefore->SetDirectory(0);
1124 fAfter = static_cast<TH1D*>(fBefore->Clone("anaEloss"));
1125 fAfter->SetTitle(Form("Energy loss in %s (sharing corrected)", GetName()));
1126 fAfter->SetFillColor(Color()+2);
1127 fAfter->SetLineStyle(1);
1128 fAfter->SetDirectory(0);
1130 fSingle = new TH1D("singleEloss", "Energy loss (single strips)",
1132 fSingle->SetXTitle("#Delta/#Delta_{mip}");
1133 fSingle->SetYTitle("P(#Delta/#Delta_{mip})");
1134 fSingle->SetFillColor(Color());
1135 fSingle->SetFillStyle(3001);
1136 fSingle->SetLineColor(kBlack);
1137 fSingle->SetLineStyle(2);
1138 fSingle->SetDirectory(0);
1140 fDouble = static_cast<TH1D*>(fSingle->Clone("doubleEloss"));
1141 fDouble->SetTitle("Energy loss (two strips)");
1142 fDouble->SetFillColor(Color()+1);
1143 fDouble->SetDirectory(0);
1145 fTriple = static_cast<TH1D*>(fSingle->Clone("tripleEloss"));
1146 fTriple->SetTitle("Energy loss (three strips)");
1147 fTriple->SetFillColor(Color()+2);
1148 fTriple->SetDirectory(0);
1150 //Int_t nBinsForInner = (r == 'I' ? 32 : 16);
1151 Int_t nBinsForInner = (r == 'I' ? 512 : 256);
1152 Int_t nStrips = (r == 'I' ? 512 : 256);
1154 fSinglePerStrip = new TH2D("singlePerStrip", "SinglePerStrip",
1155 600,0,15, nBinsForInner,0,nStrips);
1156 fSinglePerStrip->SetXTitle("#Delta/#Delta_{mip}");
1157 fSinglePerStrip->SetYTitle("Strip #");
1158 fSinglePerStrip->SetZTitle("Counts");
1159 fSinglePerStrip->SetDirectory(0);
1161 fDistanceBefore = new TH1D("distanceBefore", "Distance before sharing",
1162 nStrips , 0,nStrips );
1163 fDistanceBefore->SetXTitle("Distance");
1164 fDistanceBefore->SetYTitle("Counts");
1165 fDistanceBefore->SetFillColor(kGreen+2);
1166 fDistanceBefore->SetFillStyle(3001);
1167 fDistanceBefore->SetLineColor(kBlack);
1168 fDistanceBefore->SetLineStyle(2);
1169 fDistanceBefore->SetDirectory(0);
1171 fDistanceAfter = static_cast<TH1D*>(fDistanceBefore->Clone("distanceAfter"));
1172 fDistanceAfter->SetTitle("Distance after sharing");
1173 fDistanceAfter->SetFillColor(kGreen+1);
1174 fDistanceAfter->SetDirectory(0);
1179 Int_t n = int((max-min) / (max / 300));
1180 fBeforeAfter = new TH2D("beforeAfter", "Before and after correlation",
1181 n, min, max, n, min, max);
1182 fBeforeAfter->SetXTitle("#Delta E/#Delta E_{mip} before");
1183 fBeforeAfter->SetYTitle("#Delta E/#Delta E_{mip} after");
1184 fBeforeAfter->SetZTitle("Correlation");
1185 fBeforeAfter->SetDirectory(0);
1187 fNeighborsBefore = static_cast<TH2D*>(fBeforeAfter->Clone("neighborsBefore"));
1188 fNeighborsBefore->SetTitle("Correlation of neighbors before");
1189 fNeighborsBefore->SetXTitle("#Delta E_{i}/#Delta E_{mip}");
1190 fNeighborsBefore->SetYTitle("#Delta E_{i+1}/#Delta E_{mip}");
1191 fNeighborsBefore->SetDirectory(0);
1194 static_cast<TH2D*>(fNeighborsBefore->Clone("neighborsAfter"));
1195 fNeighborsAfter->SetTitle("Correlation of neighbors after");
1196 fNeighborsAfter->SetDirectory(0);
1198 fSum = new TH2D("summed", "Summed signal", 200, -4, 6,
1199 (fRing == 'I' || fRing == 'i' ? 20 : 40), 0, 2*TMath::Pi());
1200 fSum->SetDirectory(0);
1202 fSum->SetMarkerColor(Color());
1203 // fSum->SetFillColor(Color());
1204 fSum->SetXTitle("#eta");
1205 fSum->SetYTitle("#varphi [radians]");
1206 fSum->SetZTitle("#sum #Delta/#Delta_{mip}(#eta,#varphi) ");
1208 fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
1209 fHits->SetDirectory(0);
1210 fHits->SetXTitle("# of hits");
1211 fHits->SetFillColor(kGreen+1);
1213 //____________________________________________________________________
1214 AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
1215 : AliForwardUtil::RingHistos(o),
1221 fSinglePerStrip(o.fSinglePerStrip),
1222 fDistanceBefore(o.fDistanceBefore),
1223 fDistanceAfter(o.fDistanceAfter),
1224 fBeforeAfter(o.fBeforeAfter),
1225 fNeighborsBefore(o.fNeighborsBefore),
1226 fNeighborsAfter(o.fNeighborsAfter),
1235 // o Object to copy from
1239 //____________________________________________________________________
1240 AliFMDSharingFilter::RingHistos&
1241 AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
1244 // Assignment operator
1247 // o Object to assign from
1250 // Reference to this
1252 if (&o == this) return *this;
1253 AliForwardUtil::RingHistos::operator=(o);
1257 if (fBefore) delete fBefore;
1258 if (fAfter) delete fAfter;
1259 if (fSingle) delete fSingle;
1260 if (fDouble) delete fDouble;
1261 if (fTriple) delete fTriple;
1262 if (fSinglePerStrip) delete fSinglePerStrip;
1263 if (fDistanceBefore) delete fDistanceBefore;
1264 if (fDistanceAfter) delete fDistanceAfter;
1265 if (fHits) delete fHits;
1268 fBefore = static_cast<TH1D*>(o.fBefore->Clone());
1269 fAfter = static_cast<TH1D*>(o.fAfter->Clone());
1270 fSingle = static_cast<TH1D*>(o.fSingle->Clone());
1271 fDouble = static_cast<TH1D*>(o.fDouble->Clone());
1272 fTriple = static_cast<TH1D*>(o.fTriple->Clone());
1273 fSinglePerStrip = static_cast<TH2D*>(o.fSinglePerStrip->Clone());
1274 fDistanceBefore = static_cast<TH1D*>(o.fDistanceBefore->Clone());
1275 fDistanceAfter = static_cast<TH1D*>(o.fDistanceAfter->Clone());
1276 fBeforeAfter = static_cast<TH2D*>(o.fBeforeAfter->Clone());
1277 fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
1278 fNeighborsAfter = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
1279 fHits = static_cast<TH1D*>(o.fHits->Clone());
1280 fSum = static_cast<TH2D*>(o.fSum->Clone());
1284 //____________________________________________________________________
1285 AliFMDSharingFilter::RingHistos::~RingHistos()
1291 //____________________________________________________________________
1293 AliFMDSharingFilter::RingHistos::Finish()
1299 fHits->Fill(fNHits);
1302 //____________________________________________________________________
1304 AliFMDSharingFilter::RingHistos::ScaleHistograms(const TList* dir,
1308 // Scale the histograms to the total number of events
1311 // nEvents Number of events
1312 // dir Where the output is
1314 TList* l = GetOutputList(dir);
1318 TH1D* before = static_cast<TH1D*>(l->FindObject("esdEloss"));
1319 TH1D* after = static_cast<TH1D*>(l->FindObject("anaEloss"));
1320 if (before) before->Scale(1./nEvents);
1321 if (after) after->Scale(1./nEvents);
1324 TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
1325 if (summed) summed->Scale(1./nEvents);
1329 //____________________________________________________________________
1331 AliFMDSharingFilter::RingHistos::Output(TList* dir)
1337 // dir where to store
1339 TList* d = DefineOutputList(dir);
1346 d->Add(fSinglePerStrip);
1347 d->Add(fDistanceBefore);
1348 d->Add(fDistanceAfter);
1349 d->Add(fBeforeAfter);
1350 d->Add(fNeighborsBefore);
1351 d->Add(fNeighborsAfter);
1355 // Removed to avoid doubly adding the list which destroys
1360 //____________________________________________________________________