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 <AliESDFMD.h>
30 #include "AliForwardCorrectionManager.h"
31 #include "AliFMDCorrELossFit.h"
35 #include <TParameter.h>
39 ClassImp(AliFMDSharingFilter)
41 ; // This is for Emacs
45 do { if (L>fDebug)break; std::cout << (M) << std::flush;} while(false)
47 do { if (L>fDebug)break; std::cout << (M) << std::endl;} while(false)
51 //____________________________________________________________________
52 AliFMDSharingFilter::AliFMDSharingFilter()
55 fCorrectAngles(kFALSE),
61 fZeroSharedHitsBelowThreshold(false),
64 fUseSimpleMerging(false),
65 fThreeStripSharing(true),
66 fRecalculateEta(false)
69 // Default Constructor - do not use
71 DGUARD(fDebug,0, "Default CTOR for AliFMDSharingFilter");
74 //____________________________________________________________________
75 AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
76 : TNamed("fmdSharingFilter", title),
78 fCorrectAngles(kFALSE),
84 fZeroSharedHitsBelowThreshold(false),
87 fUseSimpleMerging(false),
88 fThreeStripSharing(true),
89 fRecalculateEta(false)
95 // title Title of object - not significant
97 DGUARD(fDebug,0, "Named CTOR for AliFMDSharingFilter: %s", title);
98 fRingHistos.SetName(GetName());
99 fRingHistos.SetOwner();
101 fRingHistos.Add(new RingHistos(1, 'I'));
102 fRingHistos.Add(new RingHistos(2, 'I'));
103 fRingHistos.Add(new RingHistos(2, 'O'));
104 fRingHistos.Add(new RingHistos(3, 'I'));
105 fRingHistos.Add(new RingHistos(3, 'O'));
108 fHCuts.SetIncludeSigma(1);
109 fLCuts.SetMultCuts(.15);
112 //____________________________________________________________________
113 AliFMDSharingFilter::AliFMDSharingFilter(const AliFMDSharingFilter& o)
116 fCorrectAngles(o.fCorrectAngles),
118 fHighCuts(o.fHighCuts),
119 fLowCuts(o.fLowCuts),
122 fZeroSharedHitsBelowThreshold(o.fZeroSharedHitsBelowThreshold),
125 fUseSimpleMerging(o.fUseSimpleMerging),
126 fThreeStripSharing(o.fThreeStripSharing),
127 fRecalculateEta(o.fRecalculateEta)
133 // o Object to copy from
135 DGUARD(fDebug,0, "Copy CTOR for AliFMDSharingFilter");
136 TIter next(&o.fRingHistos);
138 while ((obj = next())) fRingHistos.Add(obj);
141 //____________________________________________________________________
142 AliFMDSharingFilter::~AliFMDSharingFilter()
147 DGUARD(fDebug,3, "DTOR for AliFMDSharingFilter");
148 fRingHistos.Delete();
151 //____________________________________________________________________
153 AliFMDSharingFilter::operator=(const AliFMDSharingFilter& o)
156 // Assignment operator
159 // o Object to assign from
164 DGUARD(fDebug,3, "Assigment for AliFMDSharingFilter");
165 if (&o == this) return *this;
166 TNamed::operator=(o);
168 fCorrectAngles = o.fCorrectAngles;
172 fHighCuts = o.fHighCuts;
173 fLowCuts = o.fLowCuts;
174 fZeroSharedHitsBelowThreshold = o.fZeroSharedHitsBelowThreshold;
177 fUseSimpleMerging = o.fUseSimpleMerging;
178 fThreeStripSharing = o.fThreeStripSharing;
179 fRecalculateEta = o.fRecalculateEta;
181 fRingHistos.Delete();
182 TIter next(&o.fRingHistos);
184 while ((obj = next())) fRingHistos.Add(obj);
189 //____________________________________________________________________
190 AliFMDSharingFilter::RingHistos*
191 AliFMDSharingFilter::GetRingHistos(UShort_t d, Char_t r) const
194 // Get the ring histogram container
201 // Ring histogram container
205 case 1: idx = 0; break;
206 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
207 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
209 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
211 return static_cast<RingHistos*>(fRingHistos.At(idx));
214 //____________________________________________________________________
216 AliFMDSharingFilter::Init(const TAxis& axis)
219 DGUARD(fDebug,1, "Initialize for AliFMDSharingFilter");
220 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
221 AliFMDCorrELossFit* fits = fcm.GetELossFit();
223 // Get the high cut. The high cut is defined as the
224 // most-probably-value peak found from the energy distributions, minus
225 // 2 times the width of the corresponding Landau.
229 eAxis.Set(fits->GetEtaAxis().GetNbins(),
230 fits->GetEtaAxis().GetXmin(),
231 fits->GetEtaAxis().GetXmax());
233 UShort_t nEta = eAxis.GetNbins();
235 fHighCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
236 fHighCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
237 fHighCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
238 fHighCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
239 fHighCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
240 fHighCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
242 fLowCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
243 fLowCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
244 fLowCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
245 fLowCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
246 fLowCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
247 fLowCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
250 for (UShort_t d = 1; d <= 3; d++) {
251 UShort_t nr = (d == 1 ? 1 : 2);
252 for (UShort_t q = 0; q < nr; q++) {
253 Char_t r = (q == 0 ? 'I' : 'O');
255 for (UShort_t e = 1; e <= nEta; e++) {
256 Double_t eta = eAxis.GetBinCenter(e);
258 if (fDebug > 3) fHCuts.Print();
260 Double_t hcut = GetHighCut(d, r, eta, false);
261 Double_t lcut = GetLowCut(d, r, eta);
263 if (hcut > 0) fHighCuts->SetBinContent(e, ybin, hcut);
264 if (lcut > 0) fLowCuts ->SetBinContent(e, ybin, lcut);
270 //____________________________________________________________________
272 AliFMDSharingFilter::Filter(const AliESDFMD& input,
278 // Filter the input AliESDFMD object
282 // lowFlux If this is a low-flux event
283 // output Output AliESDFMD object
286 // True on success, false otherwise
288 DGUARD(fDebug,1, "Filter event in AliFMDSharingFilter");
290 TIter next(&fRingHistos);
292 while ((o = static_cast<RingHistos*>(next())))
295 if (fOper) fOper->Reset(0);
297 Int_t nCandidate = 0;
303 for(UShort_t d = 1; d <= 3; d++) {
304 Int_t nRings = (d == 1 ? 1 : 2);
305 for (UShort_t q = 0; q < nRings; q++) {
306 Char_t r = (q == 0 ? 'I' : 'O');
307 UShort_t nsec = (q == 0 ? 20 : 40);
308 UShort_t nstr = (q == 0 ? 512 : 256);
309 RingHistos* histos = GetRingHistos(d, r);
311 for(UShort_t s = 0; s < nsec; s++) {
313 for (UShort_t t = 0; t < nstr; t++) status[t] = kCandidate;
315 #ifdef USE_OLDER_MERGING
316 Bool_t usedThis = kFALSE;
317 Bool_t usedPrev = kFALSE;
320 Bool_t used = kFALSE;
321 Double_t eTotal = -1;
322 Int_t nDistanceBefore = -1;
323 Int_t nDistanceAfter = -1;
324 Bool_t twoLow = kFALSE;
325 for(UShort_t t = 0; t < nstr; t++) {
329 output.SetMultiplicity(d,r,s,t,0.);
330 Float_t mult = SignalInStrip(input,d,r,s,t);
332 Float_t multNext = 0;
333 Float_t multNextNext = 0;
335 if(t<nstr-1) multNext = SignalInStrip(input,d,r,s,t+1);
336 if(t<nstr-2) multNextNext = SignalInStrip(input,d,r,s,t+2);
337 if(multNext == AliESDFMD::kInvalidMult) multNext = 0;
338 if(multNextNext == AliESDFMD::kInvalidMult) multNextNext = 0;
339 if(!fThreeStripSharing) multNextNext = 0;
340 // Get the pseudo-rapidity
341 Double_t eta = input.Eta(d,r,s,t);
342 Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
343 if (s == 0) output.SetEta(d,r,s,t,eta);
345 Double_t etaOld = eta;
346 Double_t etaCalc = 0;
347 if(fRecalculateEta) {
348 etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
351 if(fRecalculateEta && mult > 0 && mult != AliESDFMD::kInvalidMult ) {
352 Double_t cosOld = TMath::Cos(2*TMath::ATan(TMath::Exp(-1*TMath::Abs(etaOld))));
353 Double_t cosNew = TMath::Cos(2*TMath::ATan(TMath::Exp(-1*TMath::Abs(etaCalc))));
354 if(mult > 0) mult = (mult/cosOld)*cosNew;
355 if(multNext > 0) multNext = (multNext/cosOld)*cosNew;
356 if(multNextNext > 0) multNextNext = (multNextNext/cosOld)*cosNew;
358 //No corrections beyond this point
360 // mult = 0; multNext = 0; multNextNext = 0;
364 // Keep dead-channel information.
365 if(mult == AliESDFMD::kInvalidMult)
366 output.SetMultiplicity(d,r,s,t,AliESDFMD::kInvalidMult);
368 // If no signal or dead strip, go on.
369 if (mult == AliESDFMD::kInvalidMult || mult == 0) {
370 if (mult == 0) histos->fSum->Fill(eta,phi,mult);
375 // Fill the diagnostics histogram
376 histos->fBefore->Fill(mult);
378 Double_t mergedEnergy = 0;
380 if(fUseSimpleMerging) {
382 if (t < nstr-1) histos->fNeighborsBefore->Fill(mult,multNext);
383 if(mult > GetHighCut(d, r, eta ,false)) {
384 histos->fDistanceBefore->Fill(nDistanceBefore);
385 nDistanceBefore = -1;
389 if(fThreeStripSharing && multNext > GetLowCut(d, r, eta) &&
390 (multNext < GetHighCut(d, r, eta ,false) || twoLow)) {
391 eTotal = eTotal + multNext;
393 histos->fTriple->Fill(eTotal);
398 histos->fDouble->Fill(eTotal);
404 if(used) {used = kFALSE; continue; }
405 if(mult > GetLowCut(d, r, eta)) etot = mult;
407 if(mult > GetLowCut(d, r, eta) &&
408 multNext > GetLowCut(d, r, eta) &&
409 (mult < GetHighCut(d, r, eta ,false) ||
410 multNext < GetHighCut(d, r, eta ,false))) {
412 if(mult < GetHighCut(d, r, eta ,false) &&
413 multNext < GetHighCut(d, r, eta ,false) )
416 if(mult>multNext && multNextNext < GetLowCut(d, r, eta))
418 etot = mult + multNext;
420 histos->fDouble->Fill(etot);
424 eTotal = mult + multNext;
429 histos->fSingle->Fill(etot);
430 histos->fSinglePerStrip->Fill(etot,t);
436 if(mergedEnergy > GetHighCut(d, r, eta ,false) ) {
437 histos->fDistanceAfter->Fill(nDistanceAfter);
440 //if(mult>0 && multNext >0)
441 // std::cout<<mult<<" "<<multNext<<" "<<mergedEnergy<<std::endl;
444 // Get next and previous signal - if any
447 Status prevStatus = (t == 0 ? kNone : status[t-1]);
448 Status thisStatus = status[t];
449 Status nextStatus = (t == nstr-1 ? kNone : status[t+1]);
451 prevE = SignalInStrip(input,d,r,s,t-1);
452 if (prevE == AliESDFMD::kInvalidMult) prevE = 0;
455 nextE = SignalInStrip(input,d,r,s,t+1);
456 if (nextE == AliESDFMD::kInvalidMult) nextE = 0;
458 if (t != 0) histos->fNeighborsBefore->Fill(prevE, mult);
460 #ifdef USE_OLDER_MERGING
461 /*Double_t*/ mergedEnergy = MultiplicityOfStrip(mult,eta,prevE,nextE,
464 status[t] = (usedPrev ? kMergedWithOther : kNone);
465 if (t != nstr - 1) status[t] = (usedThis ? kMergedWithOther : kNone);
467 /*Double_t*/ mergedEnergy = MultiplicityOfStrip(mult, prevE, nextE,
473 if (t != 0) status[t-1] = prevStatus;
474 if (t != nstr-1) status[t+1] = nextStatus;
475 status[t] = thisStatus;
478 // If we're processing on non-angle corrected data, we
479 // should do the angle correction here
482 mergedEnergy = AngleCorrect(mergedEnergy, eta);
483 if (mergedEnergy > 0) histos->Incr();
486 histos->fNeighborsAfter->Fill(output.Multiplicity(d,r,s,t-1),
488 histos->fBeforeAfter->Fill(mult, mergedEnergy);
490 histos->fAfter->Fill(mergedEnergy);
491 histos->fSum->Fill(eta,phi,mergedEnergy);
493 output.SetMultiplicity(d,r,s,t,mergedEnergy);
495 for (UShort_t t = 0; t < nstr; t++) {
496 if (fOper) fOper->operator()(d, r, s, t) = status[t];
498 case kNone: nNone++; break;
499 case kCandidate: nCandidate++; break;
500 case kMergedWithOther: nMerged++; break;
501 case kMergedInto: nSummed++; break;
507 fSummed->Fill(kNone, nNone);
508 fSummed->Fill(kCandidate, nCandidate);
509 fSummed->Fill(kMergedWithOther, nMerged);
510 fSummed->Fill(kMergedInto, nSummed);
512 DBGL(5, Form("none=%9d, candidate=%9d, merged=%9d, summed=%9d",
513 nNone, nCandidate, nMerged, nSummed));
515 while ((o = static_cast<RingHistos*>(next())))
521 //_____________________________________________________________________
523 AliFMDSharingFilter::SignalInStrip(const AliESDFMD& input,
530 // Get the signal in a strip
542 Double_t mult = input.Multiplicity(d,r,s,t);
544 // - bad value (invalid or 0)
545 // - we want angle corrected and data is
546 // - we don't want angle corrected and data isn't
547 // just return read value
548 if (mult == AliESDFMD::kInvalidMult ||
550 (fCorrectAngles && input.IsAngleCorrected()) ||
551 (!fCorrectAngles && !input.IsAngleCorrected()))
554 // If we want angle corrected data, correct it,
555 // otherwise de-correct it
556 if (fCorrectAngles) mult = AngleCorrect(mult, input.Eta(d,r,s,t));
557 else mult = DeAngleCorrect(mult, input.Eta(d,r,s,t));
560 //_____________________________________________________________________
562 AliFMDSharingFilter::GetLowCut(UShort_t d, Char_t r, Double_t eta) const
565 // Get the low cut. Normally, the low cut is taken to be the lower
566 // value of the fit range used when generating the energy loss fits.
567 // However, if fLowCut is set (using SetLowCit) to a value greater
568 // than 0, then that value is used.
570 return fLCuts.GetMultCut(d,r,eta,false);
572 if (!fCutAtFractionOfMPV && fLowCut > 0) return fLowCut;
574 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
575 AliFMDCorrELossFit* fits = fcm.GetELossFit();
577 if (fCutAtFractionOfMPV) {
578 AliFMDCorrELossFit::ELossFit* func = fits->GetFit(d,r,eta);
579 return fFractionOfMPV*func->GetDelta() ;
581 return fits->GetLowCut();
585 //_____________________________________________________________________
587 AliFMDSharingFilter::GetHighCut(UShort_t d, Char_t r,
588 Double_t eta, Bool_t errors) const
591 // Get the high cut. The high cut is defined as the
592 // most-probably-value peak found from the energy distributions, minus
593 // 2 times the width of the corresponding Landau.
595 return fHCuts.GetMultCut(d,r,eta,errors);
598 //_____________________________________________________________________
600 const char* status2String(AliFMDSharingFilter::Status s)
603 case AliFMDSharingFilter::kNone: return "none ";
604 case AliFMDSharingFilter::kCandidate: return "candidate";
605 case AliFMDSharingFilter::kMergedWithOther: return "merged ";
606 case AliFMDSharingFilter::kMergedInto: return "summed ";
612 //_____________________________________________________________________
614 AliFMDSharingFilter::MultiplicityOfStrip(Double_t thisE,
625 Status& nextStatus) const
627 Double_t lowCut = GetLowCut(d, r, eta);
629 DBG(3,Form("FMD%d%c[%2d,%3d]: this=%9f(%s), prev=%9f(%s), next=%9f(%s)",
631 thisE, status2String(thisStatus),
632 prevE, status2String(prevStatus),
633 nextE, status2String(nextStatus)));
635 // If below cut, then modify zero signal and make sure the next
636 // strip is considered a candidate.
637 if (thisE < lowCut || thisE > 20) {
639 DBGL(5,Form(" %9f<%9f || %9f>20, 0'ed", thisE, lowCut, thisE));
640 if (prevStatus == kCandidate) prevStatus = kNone;
643 // It this strip was merged with the previous strip, then
644 // make the next strip a candidate and zero the value in this strip.
645 if (thisStatus == kMergedWithOther) {
646 DBGL(5,Form(" Merged with other, 0'ed"));
650 // Get the upper cut on the sharing
651 Double_t highCut = GetHighCut(d, r, eta ,false);
657 // Only for low-flux events
659 // If this is smaller than the next, and the next is larger
660 // then the cut, mark both as candidates for sharing.
661 // They should be be merged on the next iteration
662 if (thisE < nextE && nextE > highCut) {
663 thisStatus = kCandidate;
664 nextStatus = kCandidate;
669 // Variable to sum signal in
670 Double_t totalE = thisE;
672 // If the previous signal was between the two cuts, and is still
673 // marked as a candidate , then merge it in here.
674 if (prevStatus == kCandidate && prevE > lowCut && prevE < highCut) {
676 prevStatus = kMergedWithOther;
677 DBG(3, Form(" Prev candidate %9f<%9f<%9f->%9f",
678 lowCut, prevE, highCut, totalE));
681 // If the next signal is between the two cuts, then merge it here
682 if (nextE > lowCut && nextE < highCut) {
684 nextStatus = kMergedWithOther;
685 DBG(3, Form(" Next %9f<%9f<%9f->%9f", lowCut, nextE, highCut,totalE));
688 // If the signal is bigger than the high-cut, then return the value
689 if (totalE > highCut) {
691 thisStatus = kMergedInto;
694 DBGL(5, Form(" %9f>%f9 (was %9f) -> %9f %s",
695 totalE, highCut, thisE, totalE,status2String(thisStatus)));
699 // This is below cut, so flag next as a candidate
700 DBG(3, Form(" %9f<=%9f, next candidate", totalE, highCut));
701 nextStatus = kCandidate;
704 // If the total signal is smaller than low cut then zero this and kill this
705 if (totalE < lowCut) {
706 DBGL(5, Form(" %9f<%9f (was %9f), zeroed", totalE, lowCut, thisE));
711 // If total signal not above high cut or lower than low cut,
712 // mark this as a candidate for merging into the next, and zero signal
713 DBGL(5, Form(" %9f<%9f<%9f (was %9f), zeroed, candidate",
714 lowCut, totalE, highCut, thisE));
715 thisStatus = kCandidate;
716 return (fZeroSharedHitsBelowThreshold ? 0 : totalE);
719 //_____________________________________________________________________
721 AliFMDSharingFilter::MultiplicityOfStrip(Double_t mult,
731 Bool_t& usedThis) const
734 // The actual algorithm
737 // mult The unfiltered signal in the strip
738 // eta Psuedo rapidity
739 // prevE Previous strip signal (or 0)
740 // nextE Next strip signal (or 0)
741 // lowFlux Whether this is a low flux event
746 // usedPrev Whether the previous strip was used in sharing or not
747 // usedThis Wether this strip was used in sharing or not.
750 // The filtered signal in the strip
753 // IF the multiplicity is very large, or below the cut, reject it, and
754 // flag it as candidate for sharing
755 Double_t lowCut = GetLowCut(d,r,eta);
756 if(mult > 12 || mult < lowCut) {
762 // If this was shared with the previous signal, return 0 and mark it as
763 // not a candiate for sharing
770 //analyse and perform sharing on one strip
773 Double_t highCut = GetHighCut(d, r, eta, false);
780 // If this signal is smaller than the next, and the next signal is smaller
781 // than then the high cut, and it's a low-flux event, then mark this and
782 // the next signal as candidates for sharing
784 // This is the test if the signal is the smaller of two possibly
794 Double_t totalE = mult;
796 // If the previous signal was larger than the low cut, and
797 // the previous was smaller than high cut, and the previous signal
798 // isn't marked as used, then add it's energy to this signal
799 if (prevE > lowCut &&
804 // If the next signal is larger than the low cut, and
805 // the next signal is smaller than the high cut, then add the next signal
806 // to this, and marked the next signal as used
807 if(nextE > lowCut && nextE < highCut ) {
812 // If we're processing on non-angle corrected data, we should do the
813 // angle correction here
814 // if (!fCorrectAngles)
815 // totalE = AngleCorrect(totalE, eta);
817 // Fill post processing histogram
818 // if(totalE > fLowCut)
819 // GetRingHistos(d,r)->fAfter->Fill(totalE);
822 Double_t mergedEnergy = 0;
825 // If we have a signal, then this is used (sharedPrev=true) and
826 // the signal is set to the result
827 mergedEnergy = totalE;
831 // If we do not have a signal (too low), then this is not shared,
832 // and the next strip is not shared either
839 //____________________________________________________________________
841 AliFMDSharingFilter::AngleCorrect(Double_t mult, Double_t eta) const
844 // Angle correct the signal
847 // mult Angle Un-corrected Signal
848 // eta Pseudo-rapidity
851 // Angle corrected signal
853 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
854 if (eta < 0) theta -= TMath::Pi();
855 return mult * TMath::Cos(theta);
857 //____________________________________________________________________
859 AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
862 // Angle de-correct the signal
865 // mult Angle corrected Signal
866 // eta Pseudo-rapidity
869 // Angle un-corrected signal
871 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
872 if (eta < 0) theta -= TMath::Pi();
873 return mult / TMath::Cos(theta);
876 //____________________________________________________________________
878 AliFMDSharingFilter::ScaleHistograms(const TList* dir, Int_t nEvents)
881 // Scale the histograms to the total number of events
884 // dir Where the output is
885 // nEvents Number of events
887 DGUARD(fDebug,1, "Scale histograms in AliFMDSharingFilter");
888 if (nEvents <= 0) return;
889 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
892 TIter next(&fRingHistos);
894 THStack* sums = new THStack("sums", "Sum of ring signals");
895 while ((o = static_cast<RingHistos*>(next()))) {
896 o->ScaleHistograms(d, nEvents);
897 TH1D* sum = o->fSum->ProjectionX(o->GetName(), 1, o->fSum->GetNbinsY(),"e");
898 sum->Scale(1., "width");
899 sum->SetTitle(o->GetName());
900 sum->SetDirectory(0);
901 sum->SetYTitle("#sum #Delta/#Delta_{mip}");
907 //____________________________________________________________________
909 AliFMDSharingFilter::DefineOutput(TList* dir)
912 // Define the output histograms. These are put in a sub list of the
913 // passed list. The histograms are merged before the parent task calls
914 // AliAnalysisTaskSE::Terminate
917 // dir Directory to add to
919 DGUARD(fDebug,1, "Define output in AliFMDSharingFilter");
920 TList* d = new TList;
921 d->SetName(GetName());
924 fSummed = new TH2I("operations", "Strip operations",
925 kMergedInto, kNone-.5, kMergedInto+.5,
926 51201, -.5, 51200.5);
927 fSummed->SetXTitle("Operation");
928 fSummed->SetYTitle("# of strips");
929 fSummed->SetZTitle("Events");
930 fSummed->GetXaxis()->SetBinLabel(kNone, "None");
931 fSummed->GetXaxis()->SetBinLabel(kCandidate, "Candidate");
932 fSummed->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
933 fSummed->GetXaxis()->SetBinLabel(kMergedInto, "Merged into");
934 fSummed->SetDirectory(0);
937 fHighCuts = new TH2D("highCuts", "High cuts used", 1,0,1, 1,0,1);
938 fHighCuts->SetXTitle("#eta");
939 fHighCuts->SetDirectory(0);
942 fLowCuts = new TH2D("lowCuts", "Low cuts used", 1,0,1, 1,0,1);
943 fLowCuts->SetXTitle("#eta");
944 fLowCuts->SetDirectory(0);
947 TNamed* angle = new TNamed("angle", fCorrectAngles ?
948 "corrected" : "uncorrected");
949 angle->SetUniqueID(fCorrectAngles);
950 TNamed* low = new TNamed("lowSignal", fZeroSharedHitsBelowThreshold ?
952 low->SetUniqueID(fZeroSharedHitsBelowThreshold);
953 TNamed* simple = new TNamed("simple", fUseSimpleMerging ? "yes" : "no");
954 simple->SetUniqueID(fUseSimpleMerging);
962 fLCuts.Output(d,"lCuts");
963 fHCuts.Output(d,"hCuts");
965 TIter next(&fRingHistos);
967 while ((o = static_cast<RingHistos*>(next()))) {
971 //____________________________________________________________________
973 AliFMDSharingFilter::Print(Option_t* /*option*/) const
981 char ind[gROOT->GetDirLevel()+1];
982 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
983 ind[gROOT->GetDirLevel()] = '\0';
984 std::cout << ind << ClassName() << ": " << GetName() << '\n'
986 << ind << " Debug: " << fDebug << "\n"
987 << ind << " Use corrected angles: " << fCorrectAngles << '\n'
988 << ind << " Zero below threshold: "
989 << fZeroSharedHitsBelowThreshold << '\n'
990 << ind << " Use simple sharing: " << fUseSimpleMerging << '\n'
991 << std::noboolalpha << std::endl;
992 std::cout << ind << " Low cuts: " << std::endl;
994 std::cout << ind << " High cuts: " << std::endl;
998 //====================================================================
999 AliFMDSharingFilter::RingHistos::RingHistos()
1000 : AliForwardUtil::RingHistos(),
1010 fNeighborsBefore(0),
1022 //____________________________________________________________________
1023 AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
1024 : AliForwardUtil::RingHistos(d,r),
1034 fNeighborsBefore(0),
1047 fBefore = new TH1D("esdEloss", Form("Energy loss in %s (reconstruction)",
1048 GetName()), 600, 0, 15);
1049 fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
1050 fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
1051 fBefore->SetFillColor(Color());
1052 fBefore->SetFillStyle(3001);
1053 fBefore->SetLineColor(kBlack);
1054 fBefore->SetLineStyle(2);
1055 fBefore->SetDirectory(0);
1057 fAfter = static_cast<TH1D*>(fBefore->Clone("anaEloss"));
1058 fAfter->SetTitle(Form("Energy loss in %s (sharing corrected)", GetName()));
1059 fAfter->SetFillColor(Color()+2);
1060 fAfter->SetLineStyle(1);
1061 fAfter->SetDirectory(0);
1063 fSingle = new TH1D("singleEloss", "Energy loss (single strips)",
1065 fSingle->SetXTitle("#Delta/#Delta_{mip}");
1066 fSingle->SetYTitle("P(#Delta/#Delta_{mip})");
1067 fSingle->SetFillColor(Color());
1068 fSingle->SetFillStyle(3001);
1069 fSingle->SetLineColor(kBlack);
1070 fSingle->SetLineStyle(2);
1071 fSingle->SetDirectory(0);
1073 fDouble = static_cast<TH1D*>(fSingle->Clone("doubleEloss"));
1074 fDouble->SetTitle("Energy loss (two strips)");
1075 fDouble->SetFillColor(Color()+1);
1076 fDouble->SetDirectory(0);
1078 fTriple = static_cast<TH1D*>(fSingle->Clone("tripleEloss"));
1079 fTriple->SetTitle("Energy loss (three strips)");
1080 fTriple->SetFillColor(Color()+2);
1081 fTriple->SetDirectory(0);
1083 //Int_t nBinsForInner = (r == 'I' ? 32 : 16);
1084 Int_t nBinsForInner = (r == 'I' ? 512 : 256);
1085 Int_t nStrips = (r == 'I' ? 512 : 256);
1087 fSinglePerStrip = new TH2D("singlePerStrip", "SinglePerStrip",
1088 600,0,15, nBinsForInner,0,nStrips);
1089 fSinglePerStrip->SetXTitle("#Delta/#Delta_{mip}");
1090 fSinglePerStrip->SetYTitle("Strip #");
1091 fSinglePerStrip->SetZTitle("Counts");
1092 fSinglePerStrip->SetDirectory(0);
1094 fDistanceBefore = new TH1D("distanceBefore", "Distance before sharing",
1095 nStrips , 0,nStrips );
1096 fDistanceBefore->SetXTitle("Distance");
1097 fDistanceBefore->SetYTitle("Counts");
1098 fDistanceBefore->SetFillColor(kGreen+2);
1099 fDistanceBefore->SetFillStyle(3001);
1100 fDistanceBefore->SetLineColor(kBlack);
1101 fDistanceBefore->SetLineStyle(2);
1102 fDistanceBefore->SetDirectory(0);
1104 fDistanceAfter = static_cast<TH1D*>(fDistanceBefore->Clone("distanceAfter"));
1105 fDistanceAfter->SetTitle("Distance after sharing");
1106 fDistanceAfter->SetFillColor(kGreen+1);
1107 fDistanceAfter->SetDirectory(0);
1112 Int_t n = int((max-min) / (max / 300));
1113 fBeforeAfter = new TH2D("beforeAfter", "Before and after correlation",
1114 n, min, max, n, min, max);
1115 fBeforeAfter->SetXTitle("#Delta E/#Delta E_{mip} before");
1116 fBeforeAfter->SetYTitle("#Delta E/#Delta E_{mip} after");
1117 fBeforeAfter->SetZTitle("Correlation");
1118 fBeforeAfter->SetDirectory(0);
1120 fNeighborsBefore = static_cast<TH2D*>(fBeforeAfter->Clone("neighborsBefore"));
1121 fNeighborsBefore->SetTitle("Correlation of neighbors before");
1122 fNeighborsBefore->SetXTitle("#Delta E_{i}/#Delta E_{mip}");
1123 fNeighborsBefore->SetYTitle("#Delta E_{i+1}/#Delta E_{mip}");
1124 fNeighborsBefore->SetDirectory(0);
1127 static_cast<TH2D*>(fNeighborsBefore->Clone("neighborsAfter"));
1128 fNeighborsAfter->SetTitle("Correlation of neighbors after");
1129 fNeighborsAfter->SetDirectory(0);
1131 fSum = new TH2D("summed", "Summed signal", 200, -4, 6,
1132 (fRing == 'I' || fRing == 'i' ? 20 : 40), 0, 2*TMath::Pi());
1133 fSum->SetDirectory(0);
1135 fSum->SetMarkerColor(Color());
1136 // fSum->SetFillColor(Color());
1137 fSum->SetXTitle("#eta");
1138 fSum->SetYTitle("#varphi [radians]");
1139 fSum->SetZTitle("#sum #Delta/#Delta_{mip}(#eta,#varphi) ");
1141 fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
1142 fHits->SetDirectory(0);
1143 fHits->SetXTitle("# of hits");
1144 fHits->SetFillColor(kGreen+1);
1146 //____________________________________________________________________
1147 AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
1148 : AliForwardUtil::RingHistos(o),
1154 fSinglePerStrip(o.fSinglePerStrip),
1155 fDistanceBefore(o.fDistanceBefore),
1156 fDistanceAfter(o.fDistanceAfter),
1157 fBeforeAfter(o.fBeforeAfter),
1158 fNeighborsBefore(o.fNeighborsBefore),
1159 fNeighborsAfter(o.fNeighborsAfter),
1168 // o Object to copy from
1172 //____________________________________________________________________
1173 AliFMDSharingFilter::RingHistos&
1174 AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
1177 // Assignment operator
1180 // o Object to assign from
1183 // Reference to this
1185 if (&o == this) return *this;
1186 AliForwardUtil::RingHistos::operator=(o);
1190 if (fBefore) delete fBefore;
1191 if (fAfter) delete fAfter;
1192 if (fSingle) delete fSingle;
1193 if (fDouble) delete fDouble;
1194 if (fTriple) delete fTriple;
1195 if (fSinglePerStrip) delete fSinglePerStrip;
1196 if (fDistanceBefore) delete fDistanceBefore;
1197 if (fDistanceAfter) delete fDistanceAfter;
1198 if (fHits) delete fHits;
1201 fBefore = static_cast<TH1D*>(o.fBefore->Clone());
1202 fAfter = static_cast<TH1D*>(o.fAfter->Clone());
1203 fSingle = static_cast<TH1D*>(o.fSingle->Clone());
1204 fDouble = static_cast<TH1D*>(o.fDouble->Clone());
1205 fTriple = static_cast<TH1D*>(o.fTriple->Clone());
1206 fSinglePerStrip = static_cast<TH2D*>(o.fSinglePerStrip->Clone());
1207 fDistanceBefore = static_cast<TH1D*>(o.fDistanceBefore->Clone());
1208 fDistanceAfter = static_cast<TH1D*>(o.fDistanceAfter->Clone());
1209 fBeforeAfter = static_cast<TH2D*>(o.fBeforeAfter->Clone());
1210 fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
1211 fNeighborsAfter = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
1212 fHits = static_cast<TH1D*>(o.fHits->Clone());
1213 fSum = static_cast<TH2D*>(o.fSum->Clone());
1217 //____________________________________________________________________
1218 AliFMDSharingFilter::RingHistos::~RingHistos()
1224 //____________________________________________________________________
1226 AliFMDSharingFilter::RingHistos::Finish()
1232 fHits->Fill(fNHits);
1235 //____________________________________________________________________
1237 AliFMDSharingFilter::RingHistos::ScaleHistograms(const TList* dir,
1241 // Scale the histograms to the total number of events
1244 // nEvents Number of events
1245 // dir Where the output is
1247 TList* l = GetOutputList(dir);
1251 TH1D* before = static_cast<TH1D*>(l->FindObject("esdEloss"));
1252 TH1D* after = static_cast<TH1D*>(l->FindObject("anaEloss"));
1253 if (before) before->Scale(1./nEvents);
1254 if (after) after->Scale(1./nEvents);
1257 TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
1258 if (summed) summed->Scale(1./nEvents);
1262 //____________________________________________________________________
1264 AliFMDSharingFilter::RingHistos::Output(TList* dir)
1270 // dir where to store
1272 TList* d = DefineOutputList(dir);
1279 d->Add(fSinglePerStrip);
1280 d->Add(fDistanceBefore);
1281 d->Add(fDistanceAfter);
1282 d->Add(fBeforeAfter);
1283 d->Add(fNeighborsBefore);
1284 d->Add(fNeighborsAfter);
1288 // Removed to avoid doubly adding the list which destroys
1293 //____________________________________________________________________