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),
70 fInvalidIsEmpty(false),
71 fMergingDisabled(false)
74 // Default Constructor - do not use
76 DGUARD(fDebug,1, "Default CTOR for AliFMDSharingFilter");
79 //____________________________________________________________________
80 AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
81 : TNamed("fmdSharingFilter", title),
83 fCorrectAngles(kFALSE),
89 fZeroSharedHitsBelowThreshold(false),
92 fUseSimpleMerging(false),
93 fThreeStripSharing(true),
94 fRecalculateEta(false),
96 fXtraDead(AliFMDStripIndex::Pack(3,'O',19,511)+1),
97 fInvalidIsEmpty(false),
98 fMergingDisabled(false)
104 // title Title of object - not significant
106 DGUARD(fDebug,1, "Named CTOR for AliFMDSharingFilter: %s", title);
107 fRingHistos.SetName(GetName());
108 fRingHistos.SetOwner();
110 fRingHistos.Add(new RingHistos(1, 'I'));
111 fRingHistos.Add(new RingHistos(2, 'I'));
112 fRingHistos.Add(new RingHistos(2, 'O'));
113 fRingHistos.Add(new RingHistos(3, 'I'));
114 fRingHistos.Add(new RingHistos(3, 'O'));
117 fHCuts.SetIncludeSigma(1);
118 fLCuts.SetMultCuts(.15);
120 // fExtraDead.Reset(-1);
123 //____________________________________________________________________
124 AliFMDSharingFilter::~AliFMDSharingFilter()
129 DGUARD(fDebug,3, "DTOR for AliFMDSharingFilter");
130 // fRingHistos.Delete();
133 //____________________________________________________________________
134 AliFMDSharingFilter::RingHistos*
135 AliFMDSharingFilter::GetRingHistos(UShort_t d, Char_t r) const
138 // Get the ring histogram container
145 // Ring histogram container
149 case 1: idx = 0; break;
150 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
151 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
153 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
155 return static_cast<RingHistos*>(fRingHistos.At(idx));
158 //____________________________________________________________________
160 AliFMDSharingFilter::AddDead(UShort_t d, Char_t r, UShort_t s, UShort_t t)
162 if (d < 1 || d > 3) {
163 Warning("AddDead", "Invalid detector FMD%d", d);
166 Bool_t inner = (r == 'I' || r == 'i');
167 if (d == 1 && !inner) {
168 Warning("AddDead", "Invalid ring FMD%d%c", d, r);
171 if ((inner && s >= 20) || (!inner && s >= 40)) {
172 Warning("AddDead", "Invalid sector FMD%d%c[%02d]", d, r, s);
175 if ((inner && t >= 512) || (!inner && t >= 256)) {
176 Warning("AddDead", "Invalid strip FMD%d%c[%02d,%03d]", d, r, s, t);
180 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
182 fXtraDead.SetBitNumber(id, true);
184 for (i = 0; i < fExtraDead.GetSize(); i++) {
185 Int_t j = fExtraDead.At(i);
186 if (j == id) return; // Already there
187 if (j < 0) break; // Free slot
189 if (i >= fExtraDead.GetSize()) {
190 Warning("AddDead", "No free slot to add FMD%d%c[%02d,%03d] at",
197 //____________________________________________________________________
199 AliFMDSharingFilter::AddDeadRegion(UShort_t d, Char_t r,
200 UShort_t s1, UShort_t s2,
201 UShort_t t1, UShort_t t2)
203 // Add a dead region spanning from FMD<d><r>[<s1>,<t1>] to
204 // FMD<d><r>[<s2>,<t2>] (both inclusive)
205 for (Int_t s = s1; s <= s2; s++)
206 for (Int_t t = t1; t <= t2; t++)
209 //____________________________________________________________________
211 AliFMDSharingFilter::AddDead(const Char_t* script)
213 if (!script || script[0] == '\0') return;
215 gROOT->Macro(Form("%s((AliFMDSharingFilter*)%p);", script, this));
218 //____________________________________________________________________
220 AliFMDSharingFilter::IsDead(UShort_t d, Char_t r, UShort_t s, UShort_t t) const
222 Int_t id = AliFMDStripIndex::Pack(d, r, s, t);
223 return fXtraDead.TestBitNumber(id);
225 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
226 Int_t j = fExtraDead.At(i);
228 //Info("IsDead", "FMD%d%c[%02d,%03d] marked as dead here", d, r, s, t);
231 if (j < 0) break; // High water mark
236 //____________________________________________________________________
238 AliFMDSharingFilter::SetupForData(const TAxis& axis)
240 // Initialise - called on first event
241 DGUARD(fDebug,1, "Initialize for AliFMDSharingFilter");
242 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
243 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
245 // Compactify the xtra dead bits
248 // Get the high cut. The high cut is defined as the
249 // most-probably-value peak found from the energy distributions, minus
250 // 2 times the width of the corresponding Landau.
252 TAxis eAxis(axis.GetNbins(),
256 eAxis.Set(fits->GetEtaAxis().GetNbins(),
257 fits->GetEtaAxis().GetXmin(),
258 fits->GetEtaAxis().GetXmax());
260 UShort_t nEta = eAxis.GetNbins();
262 fHighCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
263 fHighCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
264 fHighCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
265 fHighCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
266 fHighCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
267 fHighCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
269 fLowCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
270 fLowCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
271 fLowCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
272 fLowCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
273 fLowCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
274 fLowCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
276 // Cache our cuts in histograms
277 fLCuts.FillHistogram(fLowCuts);
278 fHCuts.FillHistogram(fHighCuts);
281 //____________________________________________________________________
282 #define ETA2COS(ETA) \
283 TMath::Cos(2*TMath::ATan(TMath::Exp(-TMath::Abs(ETA))))
286 AliFMDSharingFilter::Filter(const AliESDFMD& input,
292 // Filter the input AliESDFMD object
296 // lowFlux If this is a low-flux event
297 // output Output AliESDFMD object
300 // True on success, false otherwise
302 DGUARD(fDebug,1, "Filter event in AliFMDSharingFilter");
304 TIter next(&fRingHistos);
306 while ((o = static_cast<RingHistos*>(next()))) o->Clear();
312 for(UShort_t d = 1; d <= 3; d++) {
313 Int_t nRings = (d == 1 ? 1 : 2);
314 for (UShort_t q = 0; q < nRings; q++) {
315 Char_t r = (q == 0 ? 'I' : 'O');
316 UShort_t nsec = (q == 0 ? 20 : 40);
317 UShort_t nstr = (q == 0 ? 512 : 256);
318 RingHistos* histos = GetRingHistos(d, r);
320 for(UShort_t s = 0; s < nsec; s++) {
321 // `used' flags if the _current_ strip was used by _previous_
323 Bool_t used = kFALSE;
324 // `eTotal' contains the current sum of merged signals so far
325 Double_t eTotal = -1;
326 // Int_t nDistanceBefore = -1;
327 // Int_t nDistanceAfter = -1;
328 // `twoLow' flags if we saw two consequtive strips with a
329 // signal between the two cuts.
330 Bool_t twoLow = kFALSE;
331 Int_t nStripsAboveCut = 0;
333 for(UShort_t t = 0; t < nstr; t++) {
334 // nDistanceBefore++;
337 output.SetMultiplicity(d,r,s,t,0.);
338 Float_t mult = SignalInStrip(input,d,r,s,t);
339 Float_t multNext = (t<nstr-1) ? SignalInStrip(input,d,r,s,t+1) :0;
340 Float_t multNextNext = (t<nstr-2) ? SignalInStrip(input,d,r,s,t+2) :0;
341 if (multNext == AliESDFMD::kInvalidMult) multNext = 0;
342 if (multNextNext == AliESDFMD::kInvalidMult) multNextNext = 0;
343 if(!fThreeStripSharing) multNextNext = 0;
345 // Get the pseudo-rapidity
346 Double_t eta = input.Eta(d,r,s,t);
347 Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
348 if (s == 0) output.SetEta(d,r,s,t,eta);
350 if(fRecalculateEta) {
351 Double_t etaOld = eta;
352 Double_t etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
355 if (mult > 0 && mult != AliESDFMD::kInvalidMult ) {
356 Double_t cosOld = ETA2COS(etaOld);
357 Double_t cosNew = ETA2COS(etaCalc);
358 Double_t corr = cosNew / cosOld;
361 multNextNext *= corr;
365 // Special case for pre revision 43611 AliFMDReconstructor.
366 // If fInvalidIsEmpty and we get an invalid signal from the
367 // ESD, then we need to set this signal to zero. Note, dead
368 // strips added in the ForwardAODConfig.C file are not
369 // effected by this, and we can use that to set the proper
371 if (mult == AliESDFMD::kInvalidMult && fInvalidIsEmpty)
374 // Keep dead-channel information - either from the ESD (but
375 // see above for older data) or from the settings in the
376 // ForwardAODConfig.C file.
377 if (mult == AliESDFMD::kInvalidMult || IsDead(d,r,s,t)) {
378 output.SetMultiplicity(d,r,s,t,AliESDFMD::kInvalidMult);
379 histos->fBefore->Fill(-1);
380 mult = AliESDFMD::kInvalidMult;
383 if (mult != AliESDFMD::kInvalidMult)
384 // Always fill the ESD sum histogram
385 histos->fSumESD->Fill(eta, phi, mult);
387 // If no signal or dead strip, go on.
388 if (mult == AliESDFMD::kInvalidMult || mult == 0) {
389 if (mult == 0) histos->fSum->Fill(eta,phi,mult);
390 // Flush a possible signal
391 if (eTotal > 0 && t > 0)
392 output.SetMultiplicity(d,r,s,t-1,eTotal);
393 // Reset states so we do not try to merge over a dead strip.
398 histos->fNConsecutive->Fill(nStripsAboveCut);
399 if (mult == AliESDFMD::kInvalidMult)
400 // Why not fill immidiately here?
401 nStripsAboveCut = -1;
403 // Why not fill immidiately here?
408 // Fill the diagnostics histogram
409 histos->fBefore->Fill(mult);
411 Double_t mergedEnergy = mult;
412 // it seems to me that this logic could be condensed a bit
413 if(mult > GetLowCut(d, r, eta)) {
414 if(nStripsAboveCut < 1) {
416 histos->fNConsecutive->Fill(nStripsAboveCut);
423 histos->fNConsecutive->Fill(nStripsAboveCut);
427 if (!fMergingDisabled) {
433 // Fill in neighbor information
434 if (t < nstr-1) histos->fNeighborsBefore->Fill(mult,multNext);
436 Bool_t thisValid = mult > GetLowCut(d, r, eta);
437 Bool_t nextValid = multNext > GetLowCut(d, r, eta);
438 Bool_t thisSmall = mult < GetHighCut(d, r, eta ,false);
439 Bool_t nextSmall = multNext < GetHighCut(d, r, eta ,false);
441 // If this strips signal is above the high cut, reset distance
443 // histos->fDistanceBefore->Fill(nDistanceBefore);
444 // nDistanceBefore = -1;
447 // If the total signal in the past 1 or 2 strips are non-zero
450 // Here, we have already flagged one strip as a candidate
452 // If 3-strip merging is enabled, then check the next
453 // strip to see that it falls within cut, or if we have
455 if (fThreeStripSharing && nextValid && (nextSmall || twoLow)) {
456 eTotal = eTotal + multNext;
458 histos->fTriple->Fill(eTotal);
462 // Otherwise, we got a double hit before, and that
466 histos->fDouble->Fill(eTotal);
469 // Store energy loss and reset sum
474 // If we have no current sum
476 // Check if this is marked as used, and if so, continue
477 if (used) {used = kFALSE; continue; }
479 // If the signal is abvoe the cut, set current
480 if (thisValid) etot = mult;
482 // If the signal is abiove the cut, and so is the next
483 // signal and either of them are below the high cut,
484 if (thisValid && nextValid && (thisSmall || nextSmall)) {
486 // If this is below the high cut, and the next is too, then
487 // we have two low signals
488 if (thisSmall && nextSmall) twoLow = kTRUE;
490 // If this signal is bigger than the next, and the
491 // one after that is below the low-cut, then update
493 if (mult>multNext && multNextNext < GetLowCut(d, r, eta)) {
494 etot = mult + multNext;
496 histos->fDouble->Fill(etot);
499 // Otherwise, we may need to merge with a third strip
502 eTotal = mult + multNext;
505 // This is a signle hit
507 histos->fSingle->Fill(etot);
508 histos->fSinglePerStrip->Fill(etot,t);
511 } // else if (etotal >= 0)
514 // if (mergedEnergy > GetHighCut(d, r, eta ,false)) {
515 // histos->fDistanceAfter->Fill(nDistanceAfter);
516 // nDistanceAfter = -1;
518 //if(mult>0 && multNext >0)
519 // std::cout<<mult<<" "<<multNext<<" "<<mergedEnergy<<std::endl;
520 } // if (!fMergingDisabled)
523 mergedEnergy = AngleCorrect(mergedEnergy, eta);
524 // if (mergedEnergy > 0) histos->Incr();
527 histos->fNeighborsAfter->Fill(output.Multiplicity(d,r,s,t-1),
529 histos->fBeforeAfter->Fill(mult, mergedEnergy);
531 histos->fAfter->Fill(mergedEnergy);
532 histos->fSum->Fill(eta,phi,mergedEnergy);
534 output.SetMultiplicity(d,r,s,t,mergedEnergy);
536 histos->fNConsecutive->Fill(nStripsAboveCut); // fill the last sector
540 DMSG(fDebug, 3,"single=%9d, double=%9d, triple=%9d",
541 nSingle, nDouble, nTriple);
543 // while ((o = static_cast<RingHistos*>(next()))) o->Finish();
548 //_____________________________________________________________________
550 AliFMDSharingFilter::SignalInStrip(const AliESDFMD& input,
557 // Get the signal in a strip
569 Double_t mult = input.Multiplicity(d,r,s,t);
571 // - bad value (invalid or 0)
572 // - we want angle corrected and data is
573 // - we don't want angle corrected and data isn't
574 // just return read value
575 if (mult == AliESDFMD::kInvalidMult ||
577 (fCorrectAngles && input.IsAngleCorrected()) ||
578 (!fCorrectAngles && !input.IsAngleCorrected()))
581 // If we want angle corrected data, correct it,
582 // otherwise de-correct it
583 if (fCorrectAngles) mult = AngleCorrect(mult, input.Eta(d,r,s,t));
584 else mult = DeAngleCorrect(mult, input.Eta(d,r,s,t));
589 Double_t Rng2Cut(UShort_t d, Char_t r, Double_t eta, TH2* h) {
593 case 1: ybin = 1; break;
594 case 2: ybin = (r=='i' || r=='I') ? 2 : 3; break;
595 case 3: ybin = (r=='i' || r=='I') ? 4 : 5; break;
598 Int_t xbin = h->GetXaxis()->FindBin(eta);
599 if (xbin < 1 && xbin > h->GetXaxis()->GetNbins()) return ret;
600 ret = h->GetBinContent(xbin,ybin);
605 //_____________________________________________________________________
607 AliFMDSharingFilter::GetLowCut(UShort_t d, Char_t r, Double_t eta) const
610 // Get the low cut. Normally, the low cut is taken to be the lower
611 // value of the fit range used when generating the energy loss fits.
612 // However, if fLowCut is set (using SetLowCit) to a value greater
613 // than 0, then that value is used.
615 return Rng2Cut(d, r, eta, fLowCuts);
616 // return fLCuts.GetMultCut(d,r,eta,false);
619 //_____________________________________________________________________
621 AliFMDSharingFilter::GetHighCut(UShort_t d, Char_t r,
622 Double_t eta, Bool_t /*errors*/) const
625 // Get the high cut. The high cut is defined as the
626 // most-probably-value peak found from the energy distributions, minus
627 // 2 times the width of the corresponding Landau.
629 return Rng2Cut(d, r, eta, fHighCuts);
630 // return fHCuts.GetMultCut(d,r,eta,errors);
633 //____________________________________________________________________
635 AliFMDSharingFilter::AngleCorrect(Double_t mult, Double_t eta) const
638 // Angle correct the signal
641 // mult Angle Un-corrected Signal
642 // eta Pseudo-rapidity
645 // Angle corrected signal
647 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
648 if (eta < 0) theta -= TMath::Pi();
649 return mult * TMath::Cos(theta);
651 //____________________________________________________________________
653 AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
656 // Angle de-correct the signal
659 // mult Angle corrected Signal
660 // eta Pseudo-rapidity
663 // Angle un-corrected signal
665 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
666 if (eta < 0) theta -= TMath::Pi();
667 return mult / TMath::Cos(theta);
670 //____________________________________________________________________
672 AliFMDSharingFilter::Terminate(const TList* dir, TList* output, Int_t nEvents)
675 // Scale the histograms to the total number of events
678 // dir Where the output is
679 // nEvents Number of events
681 DGUARD(fDebug,1, "Scale histograms in AliFMDSharingFilter");
682 if (nEvents <= 0) return;
683 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
686 TList* out = new TList;
687 out->SetName(d->GetName());
690 TParameter<int>* nFiles =
691 static_cast<TParameter<int>*>(d->FindObject("nFiles"));
693 TH2* lowCuts = static_cast<TH2*>(d->FindObject("lowCuts"));
694 TH2* highCuts = static_cast<TH2*>(d->FindObject("highCuts"));
695 if (lowCuts && nFiles) {
696 lowCuts->Scale(1. / nFiles->GetVal());
697 out->Add(lowCuts->Clone());
700 AliWarning("low cuts histogram not found in input list");
701 if (highCuts && nFiles) {
702 highCuts->Scale(1. / nFiles->GetVal());
703 out->Add(highCuts->Clone());
706 AliWarning("high cuts histogram not found in input list");
708 TIter next(&fRingHistos);
710 THStack* sums = new THStack("sums", "Sum of ring signals");
711 THStack* sumsESD = new THStack("sumsESD", "Sum of ring ESD signals");
712 while ((o = static_cast<RingHistos*>(next()))) {
713 o->Terminate(d, nEvents);
715 Warning("Terminate", "No sum histogram found for ring %s", o->GetName());
718 TH1D* sum = o->fSum->ProjectionX(o->GetName(), 1, o->fSum->GetNbinsY(),"e");
719 sum->Scale(1., "width");
720 sum->SetTitle(o->GetName());
721 sum->SetDirectory(0);
722 sum->SetYTitle("#sum_{c} #Delta/#Delta_{mip}");
725 sum = o->fSumESD->ProjectionX(o->GetName(), 1, o->fSumESD->GetNbinsY(),"e");
726 sum->Scale(1., "width");
727 sum->SetTitle(o->GetName());
728 sum->SetDirectory(0);
729 sum->SetYTitle("#sum_{s} #Delta/#Delta_{mip}");
737 //____________________________________________________________________
739 AliFMDSharingFilter::CreateOutputObjects(TList* dir)
742 // Define the output histograms. These are put in a sub list of the
743 // passed list. The histograms are merged before the parent task calls
744 // AliAnalysisTaskSE::Terminate
747 // dir Directory to add to
749 DGUARD(fDebug,1, "Define output in AliFMDSharingFilter");
750 TList* d = new TList;
751 d->SetName(GetName());
755 fSummed = new TH2I("operations", "Strip operations",
756 kMergedInto, kNone-.5, kMergedInto+.5,
757 51201, -.5, 51200.5);
758 fSummed->SetXTitle("Operation");
759 fSummed->SetYTitle("# of strips");
760 fSummed->SetZTitle("Events");
761 fSummed->GetXaxis()->SetBinLabel(kNone, "None");
762 fSummed->GetXaxis()->SetBinLabel(kCandidate, "Candidate");
763 fSummed->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
764 fSummed->GetXaxis()->SetBinLabel(kMergedInto, "Merged into");
765 fSummed->SetDirectory(0);
769 fHighCuts = new TH2D("highCuts", "High cuts used", 1,0,1, 1,0,1);
770 fHighCuts->SetXTitle("#eta");
771 fHighCuts->SetDirectory(0);
774 fLowCuts = new TH2D("lowCuts", "Low cuts used", 1,0,1, 1,0,1);
775 fLowCuts->SetXTitle("#eta");
776 fLowCuts->SetDirectory(0);
782 d->Add(AliForwardUtil::MakeParameter("angle", fCorrectAngles));
783 d->Add(AliForwardUtil::MakeParameter("lowSignal",
784 fZeroSharedHitsBelowThreshold));
785 d->Add(AliForwardUtil::MakeParameter("simple", fUseSimpleMerging));
786 d->Add(AliForwardUtil::MakeParameter("sumThree", fThreeStripSharing));
787 d->Add(AliForwardUtil::MakeParameter("disabled", fMergingDisabled));
788 TParameter<int>* nFiles = new TParameter<int>("nFiles", 1);
789 nFiles->SetMergeMode('+');
792 TObjArray* extraDead = new TObjArray;
793 extraDead->SetOwner();
794 extraDead->SetName("extraDead");
796 for (Int_t i = 0; i < fExtraDead.GetSize(); i++) {
797 if (fExtraDead.At(i) < 0) break;
800 Int_t id = fExtraDead.At(i);
801 AliFMDStripIndex::Unpack(id, dd, r, s, t);
802 extraDead->Add(AliForwardUtil::MakeParameter(Form("FMD%d%c[%02d,%03d]",
807 UInt_t firstBit = fXtraDead.FirstSetBit();
808 UInt_t nBits = fXtraDead.GetNbits();
809 for (UInt_t i = firstBit; i < nBits; i++) {
810 if (!fXtraDead.TestBitNumber(i)) continue;
813 AliFMDStripIndex::Unpack(i, dd, r, s, t);
814 extraDead->Add(AliForwardUtil::MakeParameter(Form("FMD%d%c[%02d,%03d]",
818 // d->Add(&fXtraDead);
820 fLCuts.Output(d,"lCuts");
821 fHCuts.Output(d,"hCuts");
823 TIter next(&fRingHistos);
825 while ((o = static_cast<RingHistos*>(next()))) {
826 o->CreateOutputObjects(d);
829 #define PF(N,V,...) \
830 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
831 #define PFB(N,FLAG) \
833 AliForwardUtil::PrintName(N); \
834 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
836 #define PFV(N,VALUE) \
838 AliForwardUtil::PrintName(N); \
839 std::cout << (VALUE) << std::endl; } while(false)
841 //____________________________________________________________________
843 AliFMDSharingFilter::Print(Option_t* /*option*/) const
851 AliForwardUtil::PrintTask(*this);
852 gROOT->IncreaseDirLevel();
854 PFB("Use corrected angles", fCorrectAngles);
855 PFB("Zero below threshold", fZeroSharedHitsBelowThreshold);
856 PFB("Use simple sharing", fUseSimpleMerging);
857 PFB("Consider invalid null", fInvalidIsEmpty);
858 PFB("Allow 3 strip merging", fThreeStripSharing);
863 gROOT->DecreaseDirLevel();
866 //====================================================================
867 AliFMDSharingFilter::RingHistos::RingHistos()
868 : AliForwardUtil::RingHistos(),
875 // fDistanceBefore(0),
876 // fDistanceAfter(0),
893 //____________________________________________________________________
894 AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
895 : AliForwardUtil::RingHistos(d,r),
902 // fDistanceBefore(0),
903 // fDistanceAfter(0),
921 fBefore = new TH1D("esdEloss", Form("Energy loss in %s (reconstruction)",
922 GetName()), 640, -1, 15);
923 fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
924 fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
925 fBefore->SetFillColor(Color());
926 fBefore->SetFillStyle(3001);
927 fBefore->SetLineColor(kBlack);
928 fBefore->SetLineStyle(2);
929 fBefore->SetDirectory(0);
931 fAfter = static_cast<TH1D*>(fBefore->Clone("anaEloss"));
932 fAfter->SetTitle(Form("Energy loss in %s (sharing corrected)", GetName()));
933 fAfter->SetFillColor(Color()+2);
934 fAfter->SetLineStyle(1);
935 fAfter->SetDirectory(0);
937 fSingle = new TH1D("singleEloss", "Energy loss (single strips)",
939 fSingle->SetXTitle("#Delta/#Delta_{mip}");
940 fSingle->SetYTitle("P(#Delta/#Delta_{mip})");
941 fSingle->SetFillColor(Color());
942 fSingle->SetFillStyle(3001);
943 fSingle->SetLineColor(kBlack);
944 fSingle->SetLineStyle(2);
945 fSingle->SetDirectory(0);
947 fDouble = static_cast<TH1D*>(fSingle->Clone("doubleEloss"));
948 fDouble->SetTitle("Energy loss (two strips)");
949 fDouble->SetFillColor(Color()+1);
950 fDouble->SetDirectory(0);
952 fTriple = static_cast<TH1D*>(fSingle->Clone("tripleEloss"));
953 fTriple->SetTitle("Energy loss (three strips)");
954 fTriple->SetFillColor(Color()+2);
955 fTriple->SetDirectory(0);
957 //Int_t nBinsForInner = (r == 'I' ? 32 : 16);
958 Int_t nBinsForInner = (r == 'I' ? 512 : 256);
959 Int_t nStrips = (r == 'I' ? 512 : 256);
961 fSinglePerStrip = new TH2D("singlePerStrip", "SinglePerStrip",
962 600,0,15, nBinsForInner,0,nStrips);
963 fSinglePerStrip->SetXTitle("#Delta/#Delta_{mip}");
964 fSinglePerStrip->SetYTitle("Strip #");
965 fSinglePerStrip->SetZTitle("Counts");
966 fSinglePerStrip->SetDirectory(0);
969 fDistanceBefore = new TH1D("distanceBefore", "Distance before sharing",
970 nStrips , 0,nStrips );
971 fDistanceBefore->SetXTitle("Distance");
972 fDistanceBefore->SetYTitle("Counts");
973 fDistanceBefore->SetFillColor(kGreen+2);
974 fDistanceBefore->SetFillStyle(3001);
975 fDistanceBefore->SetLineColor(kBlack);
976 fDistanceBefore->SetLineStyle(2);
977 fDistanceBefore->SetDirectory(0);
979 fDistanceAfter = static_cast<TH1D*>(fDistanceBefore->Clone("distanceAfter"));
980 fDistanceAfter->SetTitle("Distance after sharing");
981 fDistanceAfter->SetFillColor(kGreen+1);
982 fDistanceAfter->SetDirectory(0);
987 Int_t n = int((max-min) / (max / 300));
988 fBeforeAfter = new TH2D("beforeAfter", "Before and after correlation",
989 n, min, max, n, min, max);
990 fBeforeAfter->SetXTitle("#Delta E/#Delta E_{mip} before");
991 fBeforeAfter->SetYTitle("#Delta E/#Delta E_{mip} after");
992 fBeforeAfter->SetZTitle("Correlation");
993 fBeforeAfter->SetDirectory(0);
995 fNeighborsBefore = static_cast<TH2D*>(fBeforeAfter->Clone("neighborsBefore"));
996 fNeighborsBefore->SetTitle("Correlation of neighbors before");
997 fNeighborsBefore->SetXTitle("#Delta E_{i}/#Delta E_{mip}");
998 fNeighborsBefore->SetYTitle("#Delta E_{i+1}/#Delta E_{mip}");
999 fNeighborsBefore->SetDirectory(0);
1002 static_cast<TH2D*>(fNeighborsBefore->Clone("neighborsAfter"));
1003 fNeighborsAfter->SetTitle("Correlation of neighbors after");
1004 fNeighborsAfter->SetDirectory(0);
1006 fSumESD = new TH2D("summedESD", "Summed ESD signal", 200, -4, 6,
1007 NSector(), 0, 2*TMath::Pi());
1008 fSumESD->SetDirectory(0);
1010 fSumESD->SetMarkerColor(Color());
1011 // fSum->SetFillColor(Color());
1012 fSumESD->SetXTitle("#eta");
1013 fSumESD->SetYTitle("#varphi [radians]");
1014 fSumESD->SetZTitle("#sum_{strip} #Delta/#Delta_{mip}(#eta,#varphi) ");
1016 fSum = static_cast<TH2D*>(fSumESD->Clone("summed"));
1017 fSum->SetTitle("Summed cluster signal");
1018 fSum->SetZTitle("#sum_{cluster} #Delta/#Delta_{mip}(#eta,#varphi) ");
1019 fSum->SetDirectory(0);
1021 // Perhaps we need to ensure that this histogram has enough range to
1022 // accommondate all possible ranges - that is, from -1 to the number
1023 // of strips in this ring(-type) - i.e., NStrips(). Perhaps the
1024 // axis should be defined with increasin bin size - e.g.,
1026 // -1.5,-.5,.5,1.5,...,100.5,128.5,192.5,...,NStrips()
1028 fNConsecutive = new TH1D("nConsecutive","# consecutive strips above low cut",
1030 fNConsecutive->SetXTitle("N_{strips}");
1031 fNConsecutive->SetYTitle("N_{entries}");
1032 fNConsecutive->SetFillColor(kYellow+2);
1033 fNConsecutive->SetFillStyle(3001);
1034 fNConsecutive->SetDirectory(0);
1038 fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
1039 fHits->SetDirectory(0);
1040 fHits->SetXTitle("# of hits");
1041 fHits->SetFillColor(kGreen+1);
1044 //____________________________________________________________________
1045 AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
1046 : AliForwardUtil::RingHistos(o),
1052 fSinglePerStrip(o.fSinglePerStrip),
1053 // fDistanceBefore(o.fDistanceBefore),
1054 // fDistanceAfter(o.fDistanceAfter),
1055 fBeforeAfter(o.fBeforeAfter),
1056 fNeighborsBefore(o.fNeighborsBefore),
1057 fNeighborsAfter(o.fNeighborsAfter),
1058 fSumESD(o.fSumESD), //,
1060 fNConsecutive(o.fNConsecutive)
1069 // o Object to copy from
1073 //____________________________________________________________________
1074 AliFMDSharingFilter::RingHistos&
1075 AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
1078 // Assignment operator
1081 // o Object to assign from
1084 // Reference to this
1086 if (&o == this) return *this;
1087 AliForwardUtil::RingHistos::operator=(o);
1091 if (fBefore) delete fBefore;
1092 if (fAfter) delete fAfter;
1093 if (fSingle) delete fSingle;
1094 if (fDouble) delete fDouble;
1095 if (fTriple) delete fTriple;
1096 if (fSinglePerStrip) delete fSinglePerStrip;
1097 if (fNConsecutive) delete fNConsecutive;
1098 // if (fDistanceBefore) delete fDistanceBefore;
1099 // if (fDistanceAfter) delete fDistanceAfter;
1100 // if (fHits) delete fHits;
1103 fBefore = static_cast<TH1D*>(o.fBefore->Clone());
1104 fAfter = static_cast<TH1D*>(o.fAfter->Clone());
1105 fSingle = static_cast<TH1D*>(o.fSingle->Clone());
1106 fDouble = static_cast<TH1D*>(o.fDouble->Clone());
1107 fTriple = static_cast<TH1D*>(o.fTriple->Clone());
1108 fSinglePerStrip = static_cast<TH2D*>(o.fSinglePerStrip->Clone());
1109 // fDistanceBefore = static_cast<TH1D*>(o.fDistanceBefore->Clone());
1110 // fDistanceAfter = static_cast<TH1D*>(o.fDistanceAfter->Clone());
1111 fBeforeAfter = static_cast<TH2D*>(o.fBeforeAfter->Clone());
1112 fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
1113 fNeighborsAfter = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
1114 // fHits = static_cast<TH1D*>(o.fHits->Clone());
1115 fSumESD = static_cast<TH2D*>(o.fSumESD->Clone());
1116 fSum = static_cast<TH2D*>(o.fSum->Clone());
1117 fNConsecutive = static_cast<TH1D*>(o.fNConsecutive->Clone());
1121 //____________________________________________________________________
1122 AliFMDSharingFilter::RingHistos::~RingHistos()
1129 //____________________________________________________________________
1131 AliFMDSharingFilter::RingHistos::Finish()
1137 // fHits->Fill(fNHits);
1140 //____________________________________________________________________
1142 AliFMDSharingFilter::RingHistos::Terminate(const TList* dir, Int_t nEvents)
1145 // Scale the histograms to the total number of events
1148 // nEvents Number of events
1149 // dir Where the output is
1151 TList* l = GetOutputList(dir);
1155 TH1D* before = static_cast<TH1D*>(l->FindObject("esdEloss"));
1156 TH1D* after = static_cast<TH1D*>(l->FindObject("anaEloss"));
1157 if (before) before->Scale(1./nEvents);
1158 if (after) after->Scale(1./nEvents);
1161 TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
1162 if (summed) summed->Scale(1./nEvents);
1165 TH2D* summedESD = static_cast<TH2D*>(l->FindObject("summedESD"));
1166 if (summedESD) summedESD->Scale(1./nEvents);
1167 fSumESD = summedESD;
1169 TH1D* consecutive = static_cast<TH1D*>(l->FindObject("nConsecutive"));
1170 if (consecutive) consecutive->Scale(1./nEvents);
1171 fNConsecutive= consecutive;
1174 //____________________________________________________________________
1176 AliFMDSharingFilter::RingHistos::CreateOutputObjects(TList* dir)
1182 // dir where to store
1184 TList* d = DefineOutputList(dir);
1191 d->Add(fSinglePerStrip);
1192 // d->Add(fDistanceBefore);
1193 // d->Add(fDistanceAfter);
1194 d->Add(fBeforeAfter);
1195 d->Add(fNeighborsBefore);
1196 d->Add(fNeighborsAfter);
1200 d->Add(fNConsecutive);
1202 // Removed to avoid doubly adding the list which destroys
1207 //____________________________________________________________________