]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliFMDSharingFilter.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDSharingFilter.cxx
CommitLineData
7e4038b5 1//
7984e5f7 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.
6//
7// Input:
8// - AliESDFMD object - from reconstruction
9//
10// Output:
11// - AliESDFMD object - copy of input, but with signals merged
12//
13// Corrections used:
14// - AliFMDCorrELossFit
15//
16// Histograms:
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)
21//
22//
7e4038b5 23//
24#include "AliFMDSharingFilter.h"
5ca83fee 25#include "AliFMDStripIndex.h"
7e4038b5 26#include <AliESDFMD.h>
27#include <TAxis.h>
28#include <TList.h>
29#include <TH1.h>
30#include <TMath.h>
0bd4b00f 31#include "AliForwardCorrectionManager.h"
fb3430ac 32#include "AliFMDCorrELossFit.h"
7e4038b5 33#include <AliLog.h>
0bd4b00f 34#include <TROOT.h>
5bb5d1f6 35#include <THStack.h>
f7cfc454 36#include <TParameter.h>
0bd4b00f 37#include <iostream>
38#include <iomanip>
7e4038b5 39
40ClassImp(AliFMDSharingFilter)
41#if 0
42; // This is for Emacs
43#endif
44
1f7aa5c7 45#define DBG(L,M) \
5bb5d1f6 46 do { if (L>fDebug)break; std::cout << (M) << std::flush;} while(false)
1f7aa5c7 47#define DBGL(L,M) \
5bb5d1f6 48 do { if (L>fDebug)break; std::cout << (M) << std::endl;} while(false)
49
50
7e4038b5 51
52//____________________________________________________________________
53AliFMDSharingFilter::AliFMDSharingFilter()
54 : TNamed(),
55 fRingHistos(),
ea3e5d95 56 fCorrectAngles(kFALSE),
8449e3e0 57 // fSummed(0),
5bb5d1f6 58 fHighCuts(0),
d2638bb7 59 fLowCuts(0),
8449e3e0 60 // fOper(0),
40196108 61 fDebug(0),
d2638bb7 62 fZeroSharedHitsBelowThreshold(false),
63 fLCuts(),
7b212e49 64 fHCuts(),
d1013ccf 65 fUseSimpleMerging(false),
6f4a5c0d 66 fThreeStripSharing(true),
bdd49110 67 fMergingDisabled(false),
68 fIgnoreESDForAngleCorrection(false)
7984e5f7 69{
70 //
71 // Default Constructor - do not use
72 //
241cca4d 73 DGUARD(fDebug,1, "Default CTOR for AliFMDSharingFilter");
7984e5f7 74}
7e4038b5 75
76//____________________________________________________________________
77AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
78 : TNamed("fmdSharingFilter", title),
79 fRingHistos(),
ea3e5d95 80 fCorrectAngles(kFALSE),
8449e3e0 81 // fSummed(0),
5bb5d1f6 82 fHighCuts(0),
d2638bb7 83 fLowCuts(0),
8449e3e0 84 // fOper(0),
40196108 85 fDebug(0),
d2638bb7 86 fZeroSharedHitsBelowThreshold(false),
87 fLCuts(),
7b212e49 88 fHCuts(),
d1013ccf 89 fUseSimpleMerging(false),
6f4a5c0d 90 fThreeStripSharing(true),
bdd49110 91 fMergingDisabled(false),
92 fIgnoreESDForAngleCorrection(false)
7e4038b5 93{
7984e5f7 94 //
95 // Constructor
96 //
97 // Parameters:
98 // title Title of object - not significant
99 //
241cca4d 100 DGUARD(fDebug,1, "Named CTOR for AliFMDSharingFilter: %s", title);
1c8feb73 101 fRingHistos.SetName(GetName());
102 fRingHistos.SetOwner();
103
7e4038b5 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'));
d2638bb7 109
7d596e9b 110 fHCuts.Set(AliFMDMultCuts::kLandauSigmaWidth, 1);
111 fLCuts.Set(AliFMDMultCuts::kFixed, .15);
5ca83fee 112
1f7aa5c7 113 // fExtraDead.Reset(-1);
7e4038b5 114}
115
7e4038b5 116//____________________________________________________________________
117AliFMDSharingFilter::~AliFMDSharingFilter()
118{
7984e5f7 119 //
120 // Destructor
121 //
6ab100ec 122 DGUARD(fDebug,3, "DTOR for AliFMDSharingFilter");
36ffcf83 123 // fRingHistos.Delete();
7e4038b5 124}
125
7e4038b5 126//____________________________________________________________________
127AliFMDSharingFilter::RingHistos*
128AliFMDSharingFilter::GetRingHistos(UShort_t d, Char_t r) const
129{
7984e5f7 130 //
131 // Get the ring histogram container
132 //
133 // Parameters:
134 // d Detector
135 // r Ring
136 //
137 // Return:
138 // Ring histogram container
139 //
7e4038b5 140 Int_t idx = -1;
141 switch (d) {
142 case 1: idx = 0; break;
143 case 2: idx = 1 + (r == 'I' || r == 'i' ? 0 : 1); break;
144 case 3: idx = 3 + (r == 'I' || r == 'i' ? 0 : 1); break;
145 }
146 if (idx < 0 || idx >= fRingHistos.GetEntries()) return 0;
147
148 return static_cast<RingHistos*>(fRingHistos.At(idx));
149}
150
5bb5d1f6 151//____________________________________________________________________
152void
5934a3e3 153AliFMDSharingFilter::SetupForData(const TAxis& axis)
5bb5d1f6 154{
5934a3e3 155 // Initialise - called on first event
6ab100ec 156 DGUARD(fDebug,1, "Initialize for AliFMDSharingFilter");
5c1012c1 157 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
8449e3e0 158 const AliFMDCorrELossFit* fits = fcm.GetELossFit();
1f7aa5c7 159
5bb5d1f6 160 // Get the high cut. The high cut is defined as the
161 // most-probably-value peak found from the energy distributions, minus
162 // 2 times the width of the corresponding Landau.
4077f3e8 163
a76fb27d 164 TAxis eAxis(axis.GetNbins(),
165 axis.GetXmin(),
166 axis.GetXmax());
5c1012c1 167 if(fits)
168 eAxis.Set(fits->GetEtaAxis().GetNbins(),
169 fits->GetEtaAxis().GetXmin(),
170 fits->GetEtaAxis().GetXmax());
5bb5d1f6 171
5c1012c1 172 UShort_t nEta = eAxis.GetNbins();
4077f3e8 173
5bb5d1f6 174 fHighCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
175 fHighCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
176 fHighCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
177 fHighCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
178 fHighCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
179 fHighCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
180
d2638bb7 181 fLowCuts->SetBins(nEta, eAxis.GetXmin(), eAxis.GetXmax(), 5, .5, 5.5);
182 fLowCuts->GetYaxis()->SetBinLabel(1, "FMD1i");
183 fLowCuts->GetYaxis()->SetBinLabel(2, "FMD2i");
184 fLowCuts->GetYaxis()->SetBinLabel(3, "FMD2o");
185 fLowCuts->GetYaxis()->SetBinLabel(4, "FMD3i");
186 fLowCuts->GetYaxis()->SetBinLabel(5, "FMD3o");
187
7095962e
CHC
188 // Cache our cuts in histograms
189 fLCuts.FillHistogram(fLowCuts);
190 fHCuts.FillHistogram(fHighCuts);
5bb5d1f6 191}
192
7e4038b5 193//____________________________________________________________________
1f7aa5c7 194#define ETA2COS(ETA) \
241cca4d 195 TMath::Cos(2*TMath::ATan(TMath::Exp(-TMath::Abs(ETA))))
196
7e4038b5 197Bool_t
198AliFMDSharingFilter::Filter(const AliESDFMD& input,
8449e3e0 199 Bool_t /*lowFlux*/,
6f4a5c0d 200 AliESDFMD& output,
0ccdab7b 201 Double_t /*zvtx*/)
7e4038b5 202{
7984e5f7 203 //
204 // Filter the input AliESDFMD object
205 //
206 // Parameters:
207 // input Input
208 // lowFlux If this is a low-flux event
209 // output Output AliESDFMD object
210 //
211 // Return:
212 // True on success, false otherwise
213 //
6ab100ec 214 DGUARD(fDebug,1, "Filter event in AliFMDSharingFilter");
7e4038b5 215 output.Clear();
216 TIter next(&fRingHistos);
0bd4b00f 217 RingHistos* o = 0;
8449e3e0 218 while ((o = static_cast<RingHistos*>(next()))) o->Clear();
219
241cca4d 220 Int_t nSingle = 0;
221 Int_t nDouble = 0;
222 Int_t nTriple = 0;
7e4038b5 223
224 for(UShort_t d = 1; d <= 3; d++) {
225 Int_t nRings = (d == 1 ? 1 : 2);
226 for (UShort_t q = 0; q < nRings; q++) {
5bb5d1f6 227 Char_t r = (q == 0 ? 'I' : 'O');
228 UShort_t nsec = (q == 0 ? 20 : 40);
229 UShort_t nstr = (q == 0 ? 512 : 256);
7e4038b5 230 RingHistos* histos = GetRingHistos(d, r);
231
8449e3e0 232 for(UShort_t s = 0; s < nsec; s++) {
233 // `used' flags if the _current_ strip was used by _previous_
234 // iteration.
241cca4d 235 Bool_t used = kFALSE;
8449e3e0 236 // `eTotal' contains the current sum of merged signals so far
241cca4d 237 Double_t eTotal = -1;
8449e3e0 238 // Int_t nDistanceBefore = -1;
239 // Int_t nDistanceAfter = -1;
240 // `twoLow' flags if we saw two consequtive strips with a
241 // signal between the two cuts.
242 Bool_t twoLow = kFALSE;
f71c22f5
CHC
243 Int_t nStripsAboveCut = 0;
244
7e4038b5 245 for(UShort_t t = 0; t < nstr; t++) {
8449e3e0 246 // nDistanceBefore++;
247 // nDistanceAfter++;
f71c22f5 248
7e4038b5 249 output.SetMultiplicity(d,r,s,t,0.);
241cca4d 250 Float_t mult = SignalInStrip(input,d,r,s,t);
251 Float_t multNext = (t<nstr-1) ? SignalInStrip(input,d,r,s,t+1) :0;
252 Float_t multNextNext = (t<nstr-2) ? SignalInStrip(input,d,r,s,t+2) :0;
253 if (multNext == AliESDFMD::kInvalidMult) multNext = 0;
254 if (multNextNext == AliESDFMD::kInvalidMult) multNextNext = 0;
9223d782 255 if(!fThreeStripSharing) multNextNext = 0;
241cca4d 256
5bb5d1f6 257 // Get the pseudo-rapidity
258 Double_t eta = input.Eta(d,r,s,t);
259 Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
260 if (s == 0) output.SetEta(d,r,s,t,eta);
7e4038b5 261
8449e3e0 262 // Keep dead-channel information - either from the ESD (but
263 // see above for older data) or from the settings in the
264 // ForwardAODConfig.C file.
0ccdab7b 265 if (mult == AliESDFMD::kInvalidMult) {
7e4038b5 266 output.SetMultiplicity(d,r,s,t,AliESDFMD::kInvalidMult);
8449e3e0 267 histos->fBefore->Fill(-1);
762754c0 268 mult = AliESDFMD::kInvalidMult;
269 }
7b212e49 270
8aa0b3db 271 Double_t lowCut = GetLowCut(d, r, eta);
272 Double_t highCut = GetHighCut(d, r, eta, false);
273 if (mult != AliESDFMD::kInvalidMult && mult > lowCut) {
77f97e3f
CHC
274 // Always fill the ESD sum histogram
275 histos->fSumESD->Fill(eta, phi, mult);
0ccdab7b 276 }
77f97e3f 277
7e4038b5 278 // If no signal or dead strip, go on.
5bb5d1f6 279 if (mult == AliESDFMD::kInvalidMult || mult == 0) {
280 if (mult == 0) histos->fSum->Fill(eta,phi,mult);
8449e3e0 281 // Flush a possible signal
282 if (eTotal > 0 && t > 0)
283 output.SetMultiplicity(d,r,s,t-1,eTotal);
284 // Reset states so we do not try to merge over a dead strip.
285 eTotal = -1;
286 used = false;
287 twoLow = false;
f71c22f5
CHC
288 if (t > 0)
289 histos->fNConsecutive->Fill(nStripsAboveCut);
290 if (mult == AliESDFMD::kInvalidMult)
291 // Why not fill immidiately here?
292 nStripsAboveCut = -1;
293 else
294 // Why not fill immidiately here?
295 nStripsAboveCut = 0;
5bb5d1f6 296 continue;
297 }
7e4038b5 298
7e4038b5 299 // Fill the diagnostics histogram
300 histos->fBefore->Fill(mult);
428cd802 301
302 Double_t mergedEnergy = mult;
f71c22f5 303 // it seems to me that this logic could be condensed a bit
8aa0b3db 304 if(mult > lowCut) {
f71c22f5
CHC
305 if(nStripsAboveCut < 1) {
306 if(t > 0)
307 histos->fNConsecutive->Fill(nStripsAboveCut);
308 nStripsAboveCut=0;
309 }
310 nStripsAboveCut++;
311 }
312 else {
313 if (t > 0)
314 histos->fNConsecutive->Fill(nStripsAboveCut);
315 nStripsAboveCut=0;
316 }
317
428cd802 318 if (!fMergingDisabled) {
319 mergedEnergy = 0;
320
321 // The current sum
322 Float_t etot = 0;
8449e3e0 323
428cd802 324 // Fill in neighbor information
325 if (t < nstr-1) histos->fNeighborsBefore->Fill(mult,multNext);
8449e3e0 326
8aa0b3db 327 Bool_t thisValid = mult > lowCut;
328 Bool_t nextValid = multNext > lowCut;
329 Bool_t thisSmall = mult < highCut;
330 Bool_t nextSmall = multNext < highCut;
8449e3e0 331
428cd802 332 // If this strips signal is above the high cut, reset distance
333 // if (!thisSmall) {
334 // histos->fDistanceBefore->Fill(nDistanceBefore);
335 // nDistanceBefore = -1;
336 // }
8449e3e0 337
428cd802 338 // If the total signal in the past 1 or 2 strips are non-zero
339 // we need to check
340 if (eTotal > 0) {
341 // Here, we have already flagged one strip as a candidate
7b212e49 342
428cd802 343 // If 3-strip merging is enabled, then check the next
344 // strip to see that it falls within cut, or if we have
345 // two low signals
346 if (fThreeStripSharing && nextValid && (nextSmall || twoLow)) {
347 eTotal = eTotal + multNext;
348 used = kTRUE;
349 histos->fTriple->Fill(eTotal);
350 nTriple++;
351 twoLow = kFALSE;
352 }
353 // Otherwise, we got a double hit before, and that
354 // should be stored.
355 else {
356 used = kFALSE;
357 histos->fDouble->Fill(eTotal);
358 nDouble++;
359 }
360 // Store energy loss and reset sum
361 etot = eTotal;
362 eTotal = -1;
363 } // if (eTotal>0)
b0036461 364 else {
428cd802 365 // If we have no current sum
8449e3e0 366
428cd802 367 // Check if this is marked as used, and if so, continue
368 if (used) {used = kFALSE; continue; }
8449e3e0 369
428cd802 370 // If the signal is abvoe the cut, set current
371 if (thisValid) etot = mult;
8449e3e0 372
428cd802 373 // If the signal is abiove the cut, and so is the next
374 // signal and either of them are below the high cut,
375 if (thisValid && nextValid && (thisSmall || nextSmall)) {
8449e3e0 376
428cd802 377 // If this is below the high cut, and the next is too, then
378 // we have two low signals
379 if (thisSmall && nextSmall) twoLow = kTRUE;
b0036461 380
428cd802 381 // If this signal is bigger than the next, and the
382 // one after that is below the low-cut, then update
383 // the sum
8aa0b3db 384 if (mult>multNext && multNextNext < lowCut) {
428cd802 385 etot = mult + multNext;
386 used = kTRUE;
387 histos->fDouble->Fill(etot);
388 nDouble++;
389 }
390 // Otherwise, we may need to merge with a third strip
391 else {
392 etot = 0;
393 eTotal = mult + multNext;
394 }
b0036461 395 }
428cd802 396 // This is a signle hit
397 else if(etot > 0) {
398 histos->fSingle->Fill(etot);
399 histos->fSinglePerStrip->Fill(etot,t);
400 nSingle++;
f26a8959 401 }
428cd802 402 } // else if (etotal >= 0)
8449e3e0 403
428cd802 404 mergedEnergy = etot;
405 // if (mergedEnergy > GetHighCut(d, r, eta ,false)) {
406 // histos->fDistanceAfter->Fill(nDistanceAfter);
407 // nDistanceAfter = -1;
408 // }
409 //if(mult>0 && multNext >0)
410 // std::cout<<mult<<" "<<multNext<<" "<<mergedEnergy<<std::endl;
411 } // if (!fMergingDisabled)
412
5bb5d1f6 413 if (!fCorrectAngles)
414 mergedEnergy = AngleCorrect(mergedEnergy, eta);
8449e3e0 415 // if (mergedEnergy > 0) histos->Incr();
7b212e49 416
5bb5d1f6 417 if (t != 0)
418 histos->fNeighborsAfter->Fill(output.Multiplicity(d,r,s,t-1),
419 mergedEnergy);
420 histos->fBeforeAfter->Fill(mult, mergedEnergy);
f26a8959 421 if(mergedEnergy > 0)
422 histos->fAfter->Fill(mergedEnergy);
5bb5d1f6 423 histos->fSum->Fill(eta,phi,mergedEnergy);
7b212e49 424
7e4038b5 425 output.SetMultiplicity(d,r,s,t,mergedEnergy);
7e4038b5 426 } // for strip
f71c22f5 427 histos->fNConsecutive->Fill(nStripsAboveCut); // fill the last sector
7e4038b5 428 } // for sector
429 } // for ring
430 } // for detector
241cca4d 431 DMSG(fDebug, 3,"single=%9d, double=%9d, triple=%9d",
432 nSingle, nDouble, nTriple);
7e4038b5 433 next.Reset();
8449e3e0 434 // while ((o = static_cast<RingHistos*>(next()))) o->Finish();
7e4038b5 435
436 return kTRUE;
437}
438
439//_____________________________________________________________________
440Double_t
441AliFMDSharingFilter::SignalInStrip(const AliESDFMD& input,
442 UShort_t d,
443 Char_t r,
444 UShort_t s,
445 UShort_t t) const
446{
7984e5f7 447 //
448 // Get the signal in a strip
449 //
450 // Parameters:
451 // fmd ESD object
452 // d Detector
453 // r Ring
454 // s Sector
455 // t Strip
456 //
457 // Return:
458 // The energy signal
459 //
7e4038b5 460 Double_t mult = input.Multiplicity(d,r,s,t);
5bb5d1f6 461 // In case of
462 // - bad value (invalid or 0)
463 // - we want angle corrected and data is
464 // - we don't want angle corrected and data isn't
465 // just return read value
466 if (mult == AliESDFMD::kInvalidMult ||
467 mult == 0 ||
bdd49110 468 (fCorrectAngles && (fIgnoreESDForAngleCorrection || input.IsAngleCorrected())) ||
469 (!fCorrectAngles && !fIgnoreESDForAngleCorrection && !input.IsAngleCorrected()))
5bb5d1f6 470 return mult;
471
472 // If we want angle corrected data, correct it,
473 // otherwise de-correct it
474 if (fCorrectAngles) mult = AngleCorrect(mult, input.Eta(d,r,s,t));
475 else mult = DeAngleCorrect(mult, input.Eta(d,r,s,t));
7e4038b5 476 return mult;
477}
7095962e
CHC
478
479namespace {
480 Double_t Rng2Cut(UShort_t d, Char_t r, Double_t eta, TH2* h) {
481 Double_t ret = 1024;
482 Int_t ybin = 0;
483 switch(d) {
484 case 1: ybin = 1; break;
485 case 2: ybin = (r=='i' || r=='I') ? 2 : 3; break;
486 case 3: ybin = (r=='i' || r=='I') ? 4 : 5; break;
487 default: return ret;
488 }
489 Int_t xbin = h->GetXaxis()->FindBin(eta);
490 if (xbin < 1 && xbin > h->GetXaxis()->GetNbins()) return ret;
491 ret = h->GetBinContent(xbin,ybin);
492 return ret;
493 }
494}
495
496 //_____________________________________________________________________
0bd4b00f 497Double_t
d2638bb7 498AliFMDSharingFilter::GetLowCut(UShort_t d, Char_t r, Double_t eta) const
0bd4b00f 499{
7984e5f7 500 //
501 // Get the low cut. Normally, the low cut is taken to be the lower
502 // value of the fit range used when generating the energy loss fits.
503 // However, if fLowCut is set (using SetLowCit) to a value greater
504 // than 0, then that value is used.
505 //
7095962e
CHC
506 return Rng2Cut(d, r, eta, fLowCuts);
507 // return fLCuts.GetMultCut(d,r,eta,false);
0bd4b00f 508}
7e4038b5 509
510//_____________________________________________________________________
511Double_t
5bb5d1f6 512AliFMDSharingFilter::GetHighCut(UShort_t d, Char_t r,
7095962e 513 Double_t eta, Bool_t /*errors*/) const
7e4038b5 514{
7984e5f7 515 //
516 // Get the high cut. The high cut is defined as the
517 // most-probably-value peak found from the energy distributions, minus
518 // 2 times the width of the corresponding Landau.
519 //
7095962e
CHC
520 return Rng2Cut(d, r, eta, fHighCuts);
521 // return fHCuts.GetMultCut(d,r,eta,errors);
5bb5d1f6 522}
523
7e4038b5 524//____________________________________________________________________
525Double_t
526AliFMDSharingFilter::AngleCorrect(Double_t mult, Double_t eta) const
527{
7984e5f7 528 //
529 // Angle correct the signal
530 //
531 // Parameters:
532 // mult Angle Un-corrected Signal
533 // eta Pseudo-rapidity
534 //
535 // Return:
536 // Angle corrected signal
537 //
7e4038b5 538 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
539 if (eta < 0) theta -= TMath::Pi();
540 return mult * TMath::Cos(theta);
541}
542//____________________________________________________________________
543Double_t
544AliFMDSharingFilter::DeAngleCorrect(Double_t mult, Double_t eta) const
545{
7984e5f7 546 //
547 // Angle de-correct the signal
548 //
549 // Parameters:
550 // mult Angle corrected Signal
551 // eta Pseudo-rapidity
552 //
553 // Return:
554 // Angle un-corrected signal
555 //
7e4038b5 556 Double_t theta = 2 * TMath::ATan(TMath::Exp(-eta));
557 if (eta < 0) theta -= TMath::Pi();
558 return mult / TMath::Cos(theta);
559}
560
561//____________________________________________________________________
562void
5934a3e3 563AliFMDSharingFilter::Terminate(const TList* dir, TList* output, Int_t nEvents)
7e4038b5 564{
7984e5f7 565 //
566 // Scale the histograms to the total number of events
567 //
568 // Parameters:
569 // dir Where the output is
570 // nEvents Number of events
571 //
6ab100ec 572 DGUARD(fDebug,1, "Scale histograms in AliFMDSharingFilter");
7e4038b5 573 if (nEvents <= 0) return;
9d99b0dd 574 TList* d = static_cast<TList*>(dir->FindObject(GetName()));
575 if (!d) return;
7e4038b5 576
5934a3e3 577 TList* out = new TList;
578 out->SetName(d->GetName());
579 out->SetOwner();
bfab35d9 580
581 TParameter<int>* nFiles =
bc31b177 582 static_cast<TParameter<int>*>(d->FindObject("nFiles"));
bfab35d9 583
bc31b177 584 TH2* lowCuts = static_cast<TH2*>(d->FindObject("lowCuts"));
585 TH2* highCuts = static_cast<TH2*>(d->FindObject("highCuts"));
bfab35d9 586 if (lowCuts && nFiles) {
90243764 587 TH1* oh = static_cast<TH1*>(lowCuts->Clone());
588 oh->Scale(1. / nFiles->GetVal());
589 oh->SetBit(BIT(20));
590 out->Add(oh);
bfab35d9 591 }
592 else
593 AliWarning("low cuts histogram not found in input list");
594 if (highCuts && nFiles) {
90243764 595 TH1* oh = static_cast<TH1*>(highCuts->Clone());
596 oh->Scale(1. / nFiles->GetVal());
597 oh->SetBit(BIT(20));
598 out->Add(oh);
bfab35d9 599 }
600 else
601 AliWarning("high cuts histogram not found in input list");
5934a3e3 602
7e4038b5 603 TIter next(&fRingHistos);
604 RingHistos* o = 0;
5bb5d1f6 605 THStack* sums = new THStack("sums", "Sum of ring signals");
77f97e3f 606 THStack* sumsESD = new THStack("sumsESD", "Sum of ring ESD signals");
5bb5d1f6 607 while ((o = static_cast<RingHistos*>(next()))) {
5934a3e3 608 o->Terminate(d, nEvents);
609 if (!o->fSum) {
610 Warning("Terminate", "No sum histogram found for ring %s", o->GetName());
611 continue;
612 }
5bb5d1f6 613 TH1D* sum = o->fSum->ProjectionX(o->GetName(), 1, o->fSum->GetNbinsY(),"e");
614 sum->Scale(1., "width");
615 sum->SetTitle(o->GetName());
616 sum->SetDirectory(0);
77f97e3f 617 sum->SetYTitle("#sum_{c} #Delta/#Delta_{mip}");
5bb5d1f6 618 sums->Add(sum);
77f97e3f 619
2d7a08a0 620
621 if (o->fSumESD) {
622 sum = o->fSumESD->ProjectionX(o->GetName(), 1, o->fSumESD->GetNbinsY(),"e");
623 sum->Scale(1., "width");
624 sum->SetTitle(o->GetName());
625 sum->SetDirectory(0);
626 sum->SetYTitle("#sum_{s} #Delta/#Delta_{mip}");
627 sumsESD->Add(sum);
628 }
5bb5d1f6 629 }
5934a3e3 630 out->Add(sums);
77f97e3f 631 out->Add(sumsESD);
5934a3e3 632 output->Add(out);
7e4038b5 633}
634
635//____________________________________________________________________
636void
5934a3e3 637AliFMDSharingFilter::CreateOutputObjects(TList* dir)
7e4038b5 638{
7984e5f7 639 //
640 // Define the output histograms. These are put in a sub list of the
641 // passed list. The histograms are merged before the parent task calls
642 // AliAnalysisTaskSE::Terminate
643 //
644 // Parameters:
645 // dir Directory to add to
646 //
6ab100ec 647 DGUARD(fDebug,1, "Define output in AliFMDSharingFilter");
7e4038b5 648 TList* d = new TList;
649 d->SetName(GetName());
650 dir->Add(d);
5bb5d1f6 651
8449e3e0 652#if 0
5bb5d1f6 653 fSummed = new TH2I("operations", "Strip operations",
654 kMergedInto, kNone-.5, kMergedInto+.5,
655 51201, -.5, 51200.5);
656 fSummed->SetXTitle("Operation");
657 fSummed->SetYTitle("# of strips");
658 fSummed->SetZTitle("Events");
659 fSummed->GetXaxis()->SetBinLabel(kNone, "None");
660 fSummed->GetXaxis()->SetBinLabel(kCandidate, "Candidate");
661 fSummed->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
662 fSummed->GetXaxis()->SetBinLabel(kMergedInto, "Merged into");
663 fSummed->SetDirectory(0);
664 d->Add(fSummed);
8449e3e0 665#endif
5bb5d1f6 666
667 fHighCuts = new TH2D("highCuts", "High cuts used", 1,0,1, 1,0,1);
668 fHighCuts->SetXTitle("#eta");
669 fHighCuts->SetDirectory(0);
670 d->Add(fHighCuts);
671
d2638bb7 672 fLowCuts = new TH2D("lowCuts", "Low cuts used", 1,0,1, 1,0,1);
673 fLowCuts->SetXTitle("#eta");
674 fLowCuts->SetDirectory(0);
675 d->Add(fLowCuts);
676
d2638bb7 677 // d->Add(lowCut);
678 // d->Add(nXi);
679 // d->Add(sigma);
241cca4d 680 d->Add(AliForwardUtil::MakeParameter("angle", fCorrectAngles));
681 d->Add(AliForwardUtil::MakeParameter("lowSignal",
682 fZeroSharedHitsBelowThreshold));
683 d->Add(AliForwardUtil::MakeParameter("simple", fUseSimpleMerging));
bfab35d9 684 d->Add(AliForwardUtil::MakeParameter("sumThree", fThreeStripSharing));
428cd802 685 d->Add(AliForwardUtil::MakeParameter("disabled", fMergingDisabled));
bfab35d9 686 TParameter<int>* nFiles = new TParameter<int>("nFiles", 1);
687 nFiles->SetMergeMode('+');
688 d->Add(nFiles);
0ccdab7b 689
d2638bb7 690 fLCuts.Output(d,"lCuts");
691 fHCuts.Output(d,"hCuts");
5bb5d1f6 692
7e4038b5 693 TIter next(&fRingHistos);
694 RingHistos* o = 0;
695 while ((o = static_cast<RingHistos*>(next()))) {
5934a3e3 696 o->CreateOutputObjects(d);
7e4038b5 697 }
698}
c8b1a7db 699#define PF(N,V,...) \
700 AliForwardUtil::PrintField(N,V, ## __VA_ARGS__)
701#define PFB(N,FLAG) \
702 do { \
703 AliForwardUtil::PrintName(N); \
704 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
705 } while(false)
706#define PFV(N,VALUE) \
707 do { \
708 AliForwardUtil::PrintName(N); \
709 std::cout << (VALUE) << std::endl; } while(false)
710
0bd4b00f 711//____________________________________________________________________
712void
713AliFMDSharingFilter::Print(Option_t* /*option*/) const
714{
7984e5f7 715 //
716 // Print information
717 //
718 // Parameters:
719 // option Not used
720 //
c8b1a7db 721 AliForwardUtil::PrintTask(*this);
722 gROOT->IncreaseDirLevel();
723
724 PFB("Use corrected angles", fCorrectAngles);
725 PFB("Zero below threshold", fZeroSharedHitsBelowThreshold);
726 PFB("Use simple sharing", fUseSimpleMerging);
c8b1a7db 727 PFB("Allow 3 strip merging", fThreeStripSharing);
728 PF("Low cuts", "");
d2638bb7 729 fLCuts.Print();
c8b1a7db 730 PF("High cuts", "");
d2638bb7 731 fHCuts.Print();
c8b1a7db 732 gROOT->DecreaseDirLevel();
0bd4b00f 733}
7e4038b5 734
735//====================================================================
736AliFMDSharingFilter::RingHistos::RingHistos()
9d99b0dd 737 : AliForwardUtil::RingHistos(),
7e4038b5 738 fBefore(0),
739 fAfter(0),
f26a8959 740 fSingle(0),
741 fDouble(0),
742 fTriple(0),
743 fSinglePerStrip(0),
8449e3e0 744 // fDistanceBefore(0),
745 // fDistanceAfter(0),
5bb5d1f6 746 fBeforeAfter(0),
747 fNeighborsBefore(0),
748 fNeighborsAfter(0),
77f97e3f 749 fSumESD(0),
f71c22f5
CHC
750 fSum(0),
751 fNConsecutive(0)
752 // ,
8449e3e0 753 // fHits(0),
754 // fNHits(0)
7984e5f7 755{
756 //
757 // Default CTOR
758 //
759
760}
7e4038b5 761
762//____________________________________________________________________
763AliFMDSharingFilter::RingHistos::RingHistos(UShort_t d, Char_t r)
9d99b0dd 764 : AliForwardUtil::RingHistos(d,r),
7e4038b5 765 fBefore(0),
766 fAfter(0),
f26a8959 767 fSingle(0),
768 fDouble(0),
769 fTriple(0),
770 fSinglePerStrip(0),
8449e3e0 771 // fDistanceBefore(0),
772 // fDistanceAfter(0),
5bb5d1f6 773 fBeforeAfter(0),
774 fNeighborsBefore(0),
775 fNeighborsAfter(0),
77f97e3f 776 fSumESD(0),
f71c22f5
CHC
777 fSum(0),
778 fNConsecutive(0)
779 //,
8449e3e0 780 // fHits(0),
781 // fNHits(0)
7e4038b5 782{
7984e5f7 783 //
784 // Constructor
785 //
786 // Parameters:
787 // d detector
788 // r ring
789 //
9b2f2e39 790 fBefore = new TH1D("esdEloss", Form("Energy loss in %s (reconstruction)",
8449e3e0 791 GetName()), 640, -1, 15);
7e4038b5 792 fBefore->SetXTitle("#Delta E/#Delta E_{mip}");
793 fBefore->SetYTitle("P(#Delta E/#Delta E_{mip})");
5bb5d1f6 794 fBefore->SetFillColor(Color());
7e4038b5 795 fBefore->SetFillStyle(3001);
f7cfc454 796 fBefore->SetLineColor(kBlack);
797 fBefore->SetLineStyle(2);
7e4038b5 798 fBefore->SetDirectory(0);
5bb5d1f6 799
800 fAfter = static_cast<TH1D*>(fBefore->Clone("anaEloss"));
9b2f2e39 801 fAfter->SetTitle(Form("Energy loss in %s (sharing corrected)", GetName()));
5bb5d1f6 802 fAfter->SetFillColor(Color()+2);
f7cfc454 803 fAfter->SetLineStyle(1);
7e4038b5 804 fAfter->SetDirectory(0);
f26a8959 805
806 fSingle = new TH1D("singleEloss", "Energy loss (single strips)",
807 600, 0, 15);
9b2f2e39 808 fSingle->SetXTitle("#Delta/#Delta_{mip}");
809 fSingle->SetYTitle("P(#Delta/#Delta_{mip})");
810 fSingle->SetFillColor(Color());
f26a8959 811 fSingle->SetFillStyle(3001);
812 fSingle->SetLineColor(kBlack);
813 fSingle->SetLineStyle(2);
814 fSingle->SetDirectory(0);
815
9b2f2e39 816 fDouble = static_cast<TH1D*>(fSingle->Clone("doubleEloss"));
817 fDouble->SetTitle("Energy loss (two strips)");
818 fDouble->SetFillColor(Color()+1);
f26a8959 819 fDouble->SetDirectory(0);
9b2f2e39 820
821 fTriple = static_cast<TH1D*>(fSingle->Clone("tripleEloss"));
822 fTriple->SetTitle("Energy loss (three strips)");
823 fTriple->SetFillColor(Color()+2);
f26a8959 824 fTriple->SetDirectory(0);
825
826 //Int_t nBinsForInner = (r == 'I' ? 32 : 16);
827 Int_t nBinsForInner = (r == 'I' ? 512 : 256);
828 Int_t nStrips = (r == 'I' ? 512 : 256);
829
830 fSinglePerStrip = new TH2D("singlePerStrip", "SinglePerStrip",
831 600,0,15, nBinsForInner,0,nStrips);
9b2f2e39 832 fSinglePerStrip->SetXTitle("#Delta/#Delta_{mip}");
833 fSinglePerStrip->SetYTitle("Strip #");
f26a8959 834 fSinglePerStrip->SetZTitle("Counts");
835 fSinglePerStrip->SetDirectory(0);
7e4038b5 836
8449e3e0 837#if 0
7f1cfdfd 838 fDistanceBefore = new TH1D("distanceBefore", "Distance before sharing",
9b2f2e39 839 nStrips , 0,nStrips );
7f1cfdfd 840 fDistanceBefore->SetXTitle("Distance");
841 fDistanceBefore->SetYTitle("Counts");
842 fDistanceBefore->SetFillColor(kGreen+2);
843 fDistanceBefore->SetFillStyle(3001);
844 fDistanceBefore->SetLineColor(kBlack);
845 fDistanceBefore->SetLineStyle(2);
846 fDistanceBefore->SetDirectory(0);
847
9b2f2e39 848 fDistanceAfter = static_cast<TH1D*>(fDistanceBefore->Clone("distanceAfter"));
849 fDistanceAfter->SetTitle("Distance after sharing");
7f1cfdfd 850 fDistanceAfter->SetFillColor(kGreen+1);
7f1cfdfd 851 fDistanceAfter->SetDirectory(0);
8449e3e0 852#endif
f26a8959 853
5bb5d1f6 854 Double_t max = 15;
855 Double_t min = -1;
856 Int_t n = int((max-min) / (max / 300));
857 fBeforeAfter = new TH2D("beforeAfter", "Before and after correlation",
858 n, min, max, n, min, max);
859 fBeforeAfter->SetXTitle("#Delta E/#Delta E_{mip} before");
860 fBeforeAfter->SetYTitle("#Delta E/#Delta E_{mip} after");
861 fBeforeAfter->SetZTitle("Correlation");
862 fBeforeAfter->SetDirectory(0);
863
864 fNeighborsBefore = static_cast<TH2D*>(fBeforeAfter->Clone("neighborsBefore"));
f7cfc454 865 fNeighborsBefore->SetTitle("Correlation of neighbors before");
5bb5d1f6 866 fNeighborsBefore->SetXTitle("#Delta E_{i}/#Delta E_{mip}");
867 fNeighborsBefore->SetYTitle("#Delta E_{i+1}/#Delta E_{mip}");
868 fNeighborsBefore->SetDirectory(0);
869
870 fNeighborsAfter =
871 static_cast<TH2D*>(fNeighborsBefore->Clone("neighborsAfter"));
872 fNeighborsAfter->SetTitle("Correlation of neighbors after");
873 fNeighborsAfter->SetDirectory(0);
874
77f97e3f
CHC
875 fSumESD = new TH2D("summedESD", "Summed ESD signal", 200, -4, 6,
876 NSector(), 0, 2*TMath::Pi());
877 fSumESD->SetDirectory(0);
878 fSumESD->Sumw2();
879 fSumESD->SetMarkerColor(Color());
5bb5d1f6 880 // fSum->SetFillColor(Color());
77f97e3f
CHC
881 fSumESD->SetXTitle("#eta");
882 fSumESD->SetYTitle("#varphi [radians]");
883 fSumESD->SetZTitle("#sum_{strip} #Delta/#Delta_{mip}(#eta,#varphi) ");
8449e3e0 884
77f97e3f
CHC
885 fSum = static_cast<TH2D*>(fSumESD->Clone("summed"));
886 fSum->SetTitle("Summed cluster signal");
887 fSum->SetZTitle("#sum_{cluster} #Delta/#Delta_{mip}(#eta,#varphi) ");
888 fSum->SetDirectory(0);
f71c22f5
CHC
889
890 // Perhaps we need to ensure that this histogram has enough range to
891 // accommondate all possible ranges - that is, from -1 to the number
892 // of strips in this ring(-type) - i.e., NStrips(). Perhaps the
893 // axis should be defined with increasin bin size - e.g.,
894 //
895 // -1.5,-.5,.5,1.5,...,100.5,128.5,192.5,...,NStrips()
896 //
897 fNConsecutive = new TH1D("nConsecutive","# consecutive strips above low cut",
898 201,-1.5,199.5);
899 fNConsecutive->SetXTitle("N_{strips}");
900 fNConsecutive->SetYTitle("N_{entries}");
901 fNConsecutive->SetFillColor(kYellow+2);
902 fNConsecutive->SetFillStyle(3001);
903 fNConsecutive->SetDirectory(0);
77f97e3f 904
f71c22f5 905
8449e3e0 906#if 0
5bb5d1f6 907 fHits = new TH1D("hits", "Number of hits", 200, 0, 200000);
7e4038b5 908 fHits->SetDirectory(0);
909 fHits->SetXTitle("# of hits");
910 fHits->SetFillColor(kGreen+1);
8449e3e0 911#endif
7e4038b5 912}
913//____________________________________________________________________
914AliFMDSharingFilter::RingHistos::RingHistos(const RingHistos& o)
9d99b0dd 915 : AliForwardUtil::RingHistos(o),
7e4038b5 916 fBefore(o.fBefore),
917 fAfter(o.fAfter),
f26a8959 918 fSingle(o.fSingle),
919 fDouble(o.fDouble),
920 fTriple(o.fTriple),
921 fSinglePerStrip(o.fSinglePerStrip),
8449e3e0 922 // fDistanceBefore(o.fDistanceBefore),
923 // fDistanceAfter(o.fDistanceAfter),
5bb5d1f6 924 fBeforeAfter(o.fBeforeAfter),
925 fNeighborsBefore(o.fNeighborsBefore),
926 fNeighborsAfter(o.fNeighborsAfter),
77f97e3f 927 fSumESD(o.fSumESD), //,
f71c22f5
CHC
928 fSum(o.fSum),
929 fNConsecutive(o.fNConsecutive)
930 //,
8449e3e0 931 // fHits(o.fHits),
932 // fNHits(o.fNHits)
7984e5f7 933{
934 //
935 // Copy constructor
936 //
937 // Parameters:
938 // o Object to copy from
939 //
940}
7e4038b5 941
942//____________________________________________________________________
943AliFMDSharingFilter::RingHistos&
944AliFMDSharingFilter::RingHistos::operator=(const RingHistos& o)
945{
7984e5f7 946 //
947 // Assignment operator
948 //
949 // Parameters:
950 // o Object to assign from
951 //
952 // Return:
953 // Reference to this
954 //
d015ecfe 955 if (&o == this) return *this;
9d99b0dd 956 AliForwardUtil::RingHistos::operator=(o);
7e4038b5 957 fDet = o.fDet;
958 fRing = o.fRing;
959
36ffcf83 960 if (fBefore) delete fBefore;
961 if (fAfter) delete fAfter;
962 if (fSingle) delete fSingle;
963 if (fDouble) delete fDouble;
964 if (fTriple) delete fTriple;
f71c22f5
CHC
965 if (fSinglePerStrip) delete fSinglePerStrip;
966 if (fNConsecutive) delete fNConsecutive;
8449e3e0 967 // if (fDistanceBefore) delete fDistanceBefore;
968 // if (fDistanceAfter) delete fDistanceAfter;
969 // if (fHits) delete fHits;
7e4038b5 970
f26a8959 971
5bb5d1f6 972 fBefore = static_cast<TH1D*>(o.fBefore->Clone());
973 fAfter = static_cast<TH1D*>(o.fAfter->Clone());
f26a8959 974 fSingle = static_cast<TH1D*>(o.fSingle->Clone());
975 fDouble = static_cast<TH1D*>(o.fDouble->Clone());
976 fTriple = static_cast<TH1D*>(o.fTriple->Clone());
977 fSinglePerStrip = static_cast<TH2D*>(o.fSinglePerStrip->Clone());
8449e3e0 978 // fDistanceBefore = static_cast<TH1D*>(o.fDistanceBefore->Clone());
979 // fDistanceAfter = static_cast<TH1D*>(o.fDistanceAfter->Clone());
5bb5d1f6 980 fBeforeAfter = static_cast<TH2D*>(o.fBeforeAfter->Clone());
981 fNeighborsBefore = static_cast<TH2D*>(o.fNeighborsBefore->Clone());
982 fNeighborsAfter = static_cast<TH2D*>(o.fNeighborsAfter->Clone());
8449e3e0 983 // fHits = static_cast<TH1D*>(o.fHits->Clone());
77f97e3f 984 fSumESD = static_cast<TH2D*>(o.fSumESD->Clone());
5bb5d1f6 985 fSum = static_cast<TH2D*>(o.fSum->Clone());
f71c22f5 986 fNConsecutive = static_cast<TH1D*>(o.fNConsecutive->Clone());
5bb5d1f6 987
7e4038b5 988 return *this;
989}
990//____________________________________________________________________
991AliFMDSharingFilter::RingHistos::~RingHistos()
992{
7984e5f7 993 //
994 // Destructor
995 //
7e4038b5 996}
8449e3e0 997#if 0
7e4038b5 998//____________________________________________________________________
999void
1000AliFMDSharingFilter::RingHistos::Finish()
1001{
7984e5f7 1002 //
1003 // Finish off
1004 //
1005 //
8449e3e0 1006 // fHits->Fill(fNHits);
7e4038b5 1007}
8449e3e0 1008#endif
9d99b0dd 1009//____________________________________________________________________
1010void
5934a3e3 1011AliFMDSharingFilter::RingHistos::Terminate(const TList* dir, Int_t nEvents)
9d99b0dd 1012{
7984e5f7 1013 //
1014 // Scale the histograms to the total number of events
1015 //
1016 // Parameters:
1017 // nEvents Number of events
1018 // dir Where the output is
1019 //
9d99b0dd 1020 TList* l = GetOutputList(dir);
1021 if (!l) return;
1022
f7cfc454 1023#if 0
1024 TH1D* before = static_cast<TH1D*>(l->FindObject("esdEloss"));
1025 TH1D* after = static_cast<TH1D*>(l->FindObject("anaEloss"));
9d99b0dd 1026 if (before) before->Scale(1./nEvents);
1027 if (after) after->Scale(1./nEvents);
f7cfc454 1028#endif
1029
1030 TH2D* summed = static_cast<TH2D*>(l->FindObject("summed"));
5bb5d1f6 1031 if (summed) summed->Scale(1./nEvents);
5934a3e3 1032 fSum = summed;
77f97e3f
CHC
1033
1034 TH2D* summedESD = static_cast<TH2D*>(l->FindObject("summedESD"));
1035 if (summedESD) summedESD->Scale(1./nEvents);
1036 fSumESD = summedESD;
f71c22f5
CHC
1037
1038 TH1D* consecutive = static_cast<TH1D*>(l->FindObject("nConsecutive"));
1039 if (consecutive) consecutive->Scale(1./nEvents);
1040 fNConsecutive= consecutive;
9d99b0dd 1041}
1042
7e4038b5 1043//____________________________________________________________________
1044void
5934a3e3 1045AliFMDSharingFilter::RingHistos::CreateOutputObjects(TList* dir)
7e4038b5 1046{
7984e5f7 1047 //
1048 // Make output
1049 //
1050 // Parameters:
1051 // dir where to store
1052 //
9d99b0dd 1053 TList* d = DefineOutputList(dir);
5bb5d1f6 1054
7e4038b5 1055 d->Add(fBefore);
1056 d->Add(fAfter);
f26a8959 1057 d->Add(fSingle);
1058 d->Add(fDouble);
1059 d->Add(fTriple);
1060 d->Add(fSinglePerStrip);
8449e3e0 1061 // d->Add(fDistanceBefore);
1062 // d->Add(fDistanceAfter);
5bb5d1f6 1063 d->Add(fBeforeAfter);
1064 d->Add(fNeighborsBefore);
1065 d->Add(fNeighborsAfter);
8449e3e0 1066 // d->Add(fHits);
77f97e3f 1067 d->Add(fSumESD);
5bb5d1f6 1068 d->Add(fSum);
f71c22f5 1069 d->Add(fNConsecutive);
bfab35d9 1070
1c8feb73 1071 // Removed to avoid doubly adding the list which destroys
1072 // the merging
1073 //dir->Add(d);
7e4038b5 1074}
1075
1076//____________________________________________________________________
1077//
1078// EOF
1079//