1 /* $Id: AliTriggerAnalysis.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */
3 /**************************************************************************
4 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Implementation of Class AliTriggerAnalysis
20 // This class provides function to check if events have been triggered based on the data in the ESD
21 // The trigger bits, trigger class inputs and only the data (offline trigger) can be used
22 // Origin: Jan Fiete Grosse-Oetringhaus, CERN
23 //-------------------------------------------------------------------------
25 #include <Riostream.h>
29 #include <TIterator.h>
30 #include "TParameter.h"
34 #include <AliTriggerAnalysis.h>
38 #include <AliESDEvent.h>
40 #include <AliMultiplicity.h>
41 #include <AliESDVZERO.h>
42 #include <AliESDZDC.h>
43 #include <AliESDFMD.h>
45 ClassImp(AliTriggerAnalysis)
47 AliTriggerAnalysis::AliTriggerAnalysis() :
72 AliTriggerAnalysis::~AliTriggerAnalysis()
82 if (fHistFiredBitsSPD)
84 delete fHistFiredBitsSPD;
85 fHistFiredBitsSPD = 0;
120 delete fHistFMDSingle;
132 fTriggerClasses->DeleteAll();
133 delete fTriggerClasses;
138 void AliTriggerAnalysis::EnableHistograms()
140 // creates the monitoring histograms
142 // do not add this hists to the directory
143 Bool_t oldStatus = TH1::AddDirectoryStatus();
144 TH1::AddDirectory(kFALSE);
146 fHistBitsSPD = new TH2F("fHistBitsSPD", "SPD GFO;number of fired chips (offline);number of fired chips (hardware)", 1202, -1.5, 1200.5, 1202, -1.5, 1200.5);
147 fHistFiredBitsSPD = new TH1F("fHistFiredBitsSPD", "SPD GFO Hardware;chip number;events", 1200, -0.5, 1199.5);
148 fHistV0A = new TH1F("fHistV0A", "V0A;leading time (ns);events", 200, 0, 100);
149 fHistV0C = new TH1F("fHistV0C", "V0C;leading time (ns);events", 200, 0, 100);
150 fHistZDC = new TH1F("fHistZDC", "ZDC;trigger bits;events", 8, -1.5, 6.5);
153 fHistFMDA = new TH1F("fHistFMDA", "FMDA;combinations above threshold;events", 102, -1.5, 100.5);
154 fHistFMDC = new TH1F("fHistFMDC", "FMDC;combinations above threshold;events", 102, -1.5, 100.5);
155 fHistFMDSingle = new TH1F("fHistFMDSingle", "FMD single;multiplicity value;counts", 1000, 0, 10);
156 fHistFMDSum = new TH1F("fHistFMDSum", "FMD sum;multiplicity value;counts", 1000, 0, 10);
158 fTriggerClasses = new TMap;
159 fTriggerClasses->SetOwner();
161 TH1::AddDirectory(oldStatus);
164 //____________________________________________________________________
165 const char* AliTriggerAnalysis::GetTriggerName(Trigger trigger)
167 // returns the name of the requested trigger
168 // the returned string will only be valid until the next call to this function [not thread-safe]
172 UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags;
174 switch (triggerNoFlags)
176 case kAcceptAll : str = "ACCEPT ALL (bypass!)"; break;
177 case kMB1 : str = "MB1"; break;
178 case kMB2 : str = "MB2"; break;
179 case kMB3 : str = "MB3"; break;
180 case kSPDGFO : str = "SPD GFO"; break;
181 case kSPDGFOBits : str = "SPD GFO Bits"; break;
182 case kV0A : str = "V0 A BB"; break;
183 case kV0C : str = "V0 C BB"; break;
184 case kV0OR : str = "V0 OR BB"; break;
185 case kV0AND : str = "V0 AND BB"; break;
186 case kV0ABG : str = "V0 A BG"; break;
187 case kV0CBG : str = "V0 C BG"; break;
188 case kZDC : str = "ZDC"; break;
189 case kZDCA : str = "ZDC A"; break;
190 case kZDCC : str = "ZDC C"; break;
191 case kFMDA : str = "FMD A"; break;
192 case kFMDC : str = "FMD C"; break;
193 case kFPANY : str = "SPD GFO | V0 | ZDC | FMD"; break;
194 case kNSD1 : str = "NSD1"; break;
195 case kMB1Prime: str = "MB1prime"; break;
196 default: str = ""; break;
199 if (trigger & kOfflineFlag)
205 Bool_t AliTriggerAnalysis::IsTriggerFired(const AliESDEvent* aEsd, Trigger trigger)
207 // checks if an event has been triggered
209 if (trigger & kOfflineFlag)
210 return IsOfflineTriggerFired(aEsd, trigger);
212 return IsTriggerBitFired(aEsd, trigger);
215 Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, Trigger trigger) const
217 // checks if an event is fired using the trigger bits
219 return IsTriggerBitFired(aEsd->GetTriggerMask(), trigger);
222 Bool_t AliTriggerAnalysis::IsTriggerBitFired(ULong64_t triggerMask, Trigger trigger) const
224 // checks if an event is fired using the trigger bits
226 // this function needs the branch TriggerMask in the ESD
228 // definitions from p-p.cfg
229 ULong64_t spdFO = (1 << 14);
230 ULong64_t v0left = (1 << 10);
231 ULong64_t v0right = (1 << 11);
242 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
248 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
254 if (triggerMask & spdFO && (triggerMask & v0left) && (triggerMask & v0right))
260 if (triggerMask & spdFO)
265 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
272 Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, ULong64_t tclass) const
274 // Checks if corresponding bit in mask is on
276 ULong64_t trigmask = aEsd->GetTriggerMask();
277 return (trigmask & (1ull << (tclass-1)));
280 Bool_t AliTriggerAnalysis::IsOfflineTriggerFired(const AliESDEvent* aEsd, Trigger trigger)
282 // checks if an event has been triggered "offline"
284 UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags;
286 switch (triggerNoFlags)
295 if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
301 if (SPDGFOTrigger(aEsd, 0) && (V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB))
307 if (SPDGFOTrigger(aEsd, 0) && V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
313 if (SPDGFOTrigger(aEsd, 0))
319 if (SPDGFOTrigger(aEsd, 1))
325 if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB)
331 if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
337 if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
343 if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
349 if (V0Trigger(aEsd, kASide, kFALSE) == kV0BG)
355 if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BG)
361 if (ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide))
367 if (ZDCTrigger(aEsd, kASide))
373 if (ZDCTrigger(aEsd, kCSide))
379 if (FMDTrigger(aEsd, kASide))
385 if (FMDTrigger(aEsd, kCSide))
391 if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB || ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide) || FMDTrigger(aEsd, kASide) || FMDTrigger(aEsd, kCSide))
397 if (SPDFiredChips(aEsd, 0) >= 5 || (V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB))
404 if (SPDGFOTrigger(aEsd, 0))
406 if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB)
408 if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)
418 AliFatal(Form("Trigger type %d not implemented", triggerNoFlags));
426 Bool_t AliTriggerAnalysis::IsTriggerClassFired(const AliESDEvent* aEsd, const Char_t* tclass) const
428 // tclass is logical function of inputs, e.g. 01 && 02 || 03 && 11 && 21
429 // = L0 inp 1 && L0 inp 2 || L0 inp 3 && L1 inp 1 && L2 inp 1
430 // NO brackets in logical function !
431 // Spaces between operators and inputs.
432 // Not all logical functions are available in CTP=
433 // =any function of first 4 inputs; 'AND' of other inputs, check not done
434 // This method will be replaced/complemened by similar one
435 // which works withh class and inputs names as in CTP cfg file
437 TString TClass(tclass);
438 TObjArray* tcltokens = TClass.Tokenize(" ");
439 Char_t level=((TObjString*)tcltokens->At(0))->String()[0];
440 UInt_t input=atoi((((TObjString*)tcltokens->At(0))->String()).Remove(0));
441 Bool_t tcl = IsInputFired(aEsd,level,input);
443 for (Int_t i=1;i<tcltokens->GetEntriesFast();i=i+2) {
444 level=((TObjString*)tcltokens->At(i+1))->String()[0];
445 input=atoi((((TObjString*)tcltokens->At(i+1))->String()).Remove(0));
446 Bool_t inpnext = IsInputFired(aEsd,level,input);
447 Char_t op =((TObjString*)tcltokens->At(i))->String()[0];
448 if (op == '&') tcl=tcl && inpnext;
449 else if (op == '|') tcl =tcl || inpnext;
451 AliError(Form("Syntax error in %s", tclass));
460 Bool_t AliTriggerAnalysis::IsInputFired(const AliESDEvent* aEsd, Char_t level, UInt_t input) const
462 // Checks trigger input of any level
466 case '0': return IsL0InputFired(aEsd,input);
467 case '1': return IsL1InputFired(aEsd,input);
468 case '2': return IsL2InputFired(aEsd,input);
470 AliError(Form("Wrong level %i",level));
475 Bool_t AliTriggerAnalysis::IsL0InputFired(const AliESDEvent* aEsd, UInt_t input) const
477 // Checks if corresponding bit in mask is on
479 UInt_t inpmask = aEsd->GetHeader()->GetL0TriggerInputs();
480 return (inpmask & (1<<(input-1)));
483 Bool_t AliTriggerAnalysis::IsL1InputFired(const AliESDEvent* aEsd, UInt_t input) const
485 // Checks if corresponding bit in mask is on
487 UInt_t inpmask = aEsd->GetHeader()->GetL1TriggerInputs();
488 return (inpmask & (1<<(input-1)));
491 Bool_t AliTriggerAnalysis::IsL2InputFired(const AliESDEvent* aEsd, UInt_t input) const
493 // Checks if corresponding bit in mask is on
495 UInt_t inpmask = aEsd->GetHeader()->GetL2TriggerInputs();
496 return (inpmask & (1<<(input-1)));
499 void AliTriggerAnalysis::FillHistograms(const AliESDEvent* aEsd)
501 // fills the histograms with the info from the ESD
503 fHistBitsSPD->Fill(SPDFiredChips(aEsd, 0), SPDFiredChips(aEsd, 1, kTRUE));
505 V0Trigger(aEsd, kASide, kFALSE, kTRUE);
506 V0Trigger(aEsd, kCSide, kFALSE, kTRUE);
508 AliESDZDC* zdcData = aEsd->GetESDZDC();
511 UInt_t quality = zdcData->GetESDQuality();
513 // from Nora's presentation, general first physics meeting 16.10.09
514 static UInt_t zpc = 0x20;
515 static UInt_t znc = 0x10;
516 static UInt_t zem1 = 0x08;
517 static UInt_t zem2 = 0x04;
518 static UInt_t zpa = 0x02;
519 static UInt_t zna = 0x01;
521 fHistZDC->Fill(1, quality & zna);
522 fHistZDC->Fill(2, quality & zpa);
523 fHistZDC->Fill(3, quality & zem2);
524 fHistZDC->Fill(4, quality & zem1);
525 fHistZDC->Fill(5, quality & znc);
526 fHistZDC->Fill(6, quality & zpc);
531 AliError("AliESDZDC not available");
534 fHistFMDA->Fill(FMDHitCombinations(aEsd, kASide, kTRUE));
535 fHistFMDC->Fill(FMDHitCombinations(aEsd, kCSide, kTRUE));
538 void AliTriggerAnalysis::FillTriggerClasses(const AliESDEvent* aEsd)
540 // fills trigger classes map
542 TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(aEsd->GetFiredTriggerClasses().Data()));
545 count = new TParameter<Long64_t>(aEsd->GetFiredTriggerClasses(), 0);
546 fTriggerClasses->Add(new TObjString(aEsd->GetFiredTriggerClasses().Data()), count);
548 count->SetVal(count->GetVal() + 1);
550 // TODO add first and last orbit number here
553 Int_t AliTriggerAnalysis::SPDFiredChips(const AliESDEvent* aEsd, Int_t origin, Bool_t fillHists)
555 // returns the number of fired chips in the SPD
557 // origin = 0 --> aEsd->GetMultiplicity()->GetNumberOfFiredChips() (filled from clusters)
558 // origin = 1 --> aEsd->GetMultiplicity()->TestFastOrFiredChips() (from hardware bits)
560 const AliMultiplicity* mult = aEsd->GetMultiplicity();
563 AliError("AliMultiplicity not available");
568 return mult->GetNumberOfFiredChips(0) + mult->GetNumberOfFiredChips(1);
573 for (Int_t i=0; i<1200; i++)
575 if (mult->TestFastOrFiredChips(i) == kTRUE)
577 // efficiency simulation (if enabled)
578 if (fSPDGFOEfficiency)
580 if (gRandom->Uniform() > fSPDGFOEfficiency->GetBinContent(i+1))
586 fHistFiredBitsSPD->Fill(i);
595 Bool_t AliTriggerAnalysis::SPDGFOTrigger(const AliESDEvent* aEsd, Int_t origin)
597 // Returns if the SPD gave a global Fast OR trigger
599 Int_t firedChips = SPDFiredChips(aEsd, origin);
601 if (firedChips >= fSPDGFOThreshold)
606 AliTriggerAnalysis::V0Decision AliTriggerAnalysis::V0Trigger(const AliESDEvent* aEsd, AliceSide side, Bool_t online, Bool_t fillHists)
608 // Returns the V0 trigger decision in V0A | V0C
610 // Returns kV0Fake if the calculated average time is in a window where neither BB nor BG is expected.
611 // The rate of such triggers can be used to estimate the background. Note that the rate has to be
612 // rescaled with the size of the windows (numerical values see below in the code)
614 // argument 'online' is used as a switch between online and offline trigger algorithms
616 // Based on an algorithm by Cvetan Cheshkov
618 AliESDVZERO* esdV0 = aEsd->GetVZEROData();
621 AliError("AliESDVZERO not available");
633 else if (side == kCSide)
646 if (aEsd->GetRunNumber() <= 104803) runRange = 0;
647 else if (aEsd->GetRunNumber() <= 104876) runRange = 1;
650 Float_t factors[3][64] = {
651 // runs: 104792-104803
652 {4.6,5.9,6.3,6.0,4.7,5.9,4.9,5.4,4.8,4.1,4.9,4.6,4.5,5.5,5.1,5.8,4.3,4.0,4.0,3.3,3.1,2.9,3.0,5.6,3.3,4.9,3.9,5.3,4.1,4.4,3.9,5.5,5.7,9.5,5.1,5.3,6.6,7.1,8.9,4.4,4.1,5.9,9.0,4.5,4.1,6.0,4.7,7.1,4.2,4.7,3.9,6.3,5.9,4.8,4.7,4.5,4.7,5.4,5.8,5.0,5.1,5.9,5.3,3.6},
653 // runs: 104841-104876
654 {4.6,4.8,4.9,4.8,4.3,4.9,4.4,4.5,4.6,5.0,4.7,4.6,4.7,4.6,4.6,5.5,4.7,4.5,4.7,5.0,6.5,7.6,5.3,4.9,5.5,4.8,4.6,4.9,4.5,4.5,4.6,4.9,5.7,9.8,4.9,5.2,7.1,7.1,8.1,4.4,4.0,6.0,8.3,4.6,4.2,5.6,4.6,6.4,4.4,4.7,4.5,6.5,6.0,4.7,4.5,4.4,4.8,5.5,5.9,5.3,5.0,5.7,5.1,3.6},
656 {4.7,5.2,4.8,5.0,4.4,5.0,4.4,4.6,4.6,4.5,4.4,4.6,4.5,4.6,4.8,5.5,4.8,4.5,4.4,4.3,5.4,7.7,5.6,5.0,5.4,4.3,4.5,4.8,4.5,4.5,4.6,5.3,5.7,9.6,4.9,5.4,6.1,7.2,8.6,4.4,4.0,5.4,8.8,4.4,4.2,5.8,4.7,6.7,4.3,4.7,4.0,6.1,6.0,4.9,4.8,4.6,4.7,5.2,5.7,5.0,5.0,5.8,5.3,3.6}
658 Float_t dA = 77.4 - 11.0;
659 Float_t dC = 77.4 - 2.9;
661 Float_t timeShift[64] = {0.477957 , 0.0889999 , 0.757669 , 0.205439 , 0.239666 , -0.183705 , 0.442873 , -0.281366 , 0.260976 , 0.788995 , 0.974758 , 0.548532 , 0.495023 , 0.868472 , 0.661167 , 0.358307 , 0.221243 , 0.530179 , 1.26696 , 1.33082 , 1.27086 , 1.77133 , 1.10253 , 0.634806 , 2.14838 , 1.50212 , 1.59253 , 1.66122 , 1.16957 , 1.52056 , 1.47791 , 1.81905 , -1.94123 , -1.29124 , -2.16045 , -1.78939 , -3.11111 , -1.87178 , -1.57671 , -1.70311 , -1.81208 , -1.94475 , -2.53058 , -1.7042 , -2.08109 , -1.84416 , -0.61073 , -1.77145 , 0.16999 , -0.0585339 , 0.00401133 , 0.397726 , 0.851111 , 0.264187 , 0.59573 , -0.158263 , 0.584362 , 1.20835 , 0.927573 , 1.13895 , 0.64648 , 2.18747 , 1.68909 , 0.451194};
662 Float_t dA2 = 2.8, dC2 = 3.3;
665 for (Int_t i = begin; i < end; ++i) {
666 Float_t tempAdc = esdV0->GetAdc(i)/factors[runRange][i];
667 Float_t tempTime = (i >= 32) ? esdV0->GetTime(i)+dA+timeShift[i]+dA2 : esdV0->GetTime(i)+dC+timeShift[i]+dC2;
668 if (esdV0->GetTime(i) >= 1e-6 &&
669 tempTime > fV0HwWinLow && tempTime < fV0HwWinHigh &&
670 tempAdc > fV0HwAdcThr)
676 for (Int_t i = begin; i < end; ++i) {
677 Float_t tempAdc = esdV0->GetAdc(i)/factors[runRange][i];
678 Float_t tempTime = (i >= 32) ? esdV0->GetTime(i)+dA : esdV0->GetTime(i)+dC;
679 Float_t tempRawTime = (i >= 32) ? esdV0->GetTime(i)+dA+timeShift[i]+dA2 : esdV0->GetTime(i)+dC+timeShift[i]+dC2;
680 if (esdV0->GetTime(i) >= 1e-6 &&
681 tempRawTime < 125.0 &&
682 tempAdc > fV0AdcThr) {
691 for (Int_t i = begin; i < end; ++i) {
692 if (esdV0->GetTime(i) >= 1e-6 &&
693 esdV0->GetTime(i) > fV0HwWinLow && esdV0->GetTime(i) < fV0HwWinHigh &&
694 esdV0->GetAdc(i) > fV0HwAdcThr)
700 for (Int_t i = begin; i < end; ++i) {
701 if (esdV0->GetTime(i) > 1e-6 && esdV0->GetAdc(i) > fV0AdcThr) {
702 Float_t correctedTime = V0CorrectLeadingTime(i, esdV0->GetTime(i), esdV0->GetAdc(i));
703 Float_t timeWeight = V0LeadingTimeWeight(esdV0->GetAdc(i));
704 time += correctedTime*timeWeight;
706 weight += timeWeight;
714 time += fV0TimeOffset;
718 if (side == kASide && fHistV0A)
719 fHistV0A->Fill(time);
720 if (side == kCSide && fHistV0C)
721 fHistV0C->Fill(time);
726 if (time > 68 && time < 100)
728 if (time > 54 && time < 57.5)
730 if (time > 57.5 && time < 68)
736 if (time > 75.5 && time < 100)
738 if (time > 69.5 && time < 73)
740 if (time > 55 && time < 69.5)
747 Float_t AliTriggerAnalysis::V0CorrectLeadingTime(Int_t i, Float_t time, Float_t adc) const
749 // Correct for slewing and align the channels
751 // Authors: Cvetan Cheshkov / Raphael Tieulent
753 if (time == 0) return 0;
756 Float_t timeShift[64] = {0.477957 , 0.0889999 , 0.757669 , 0.205439 , 0.239666 , -0.183705 , 0.442873 , -0.281366 , 0.260976 , 0.788995 , 0.974758 , 0.548532 , 0.495023 , 0.868472 , 0.661167 , 0.358307 , 0.221243 , 0.530179 , 1.26696 , 1.33082 , 1.27086 , 1.77133 , 1.10253 , 0.634806 , 2.14838 , 1.50212 , 1.59253 , 1.66122 , 1.16957 , 1.52056 , 1.47791 , 1.81905 , -1.94123 , -1.29124 , -2.16045 , -1.78939 , -3.11111 , -1.87178 , -1.57671 , -1.70311 , -1.81208 , -1.94475 , -2.53058 , -1.7042 , -2.08109 , -1.84416 , -0.61073 , -1.77145 , 0.16999 , -0.0585339 , 0.00401133 , 0.397726 , 0.851111 , 0.264187 , 0.59573 , -0.158263 , 0.584362 , 1.20835 , 0.927573 , 1.13895 , 0.64648 , 2.18747 , 1.68909 , 0.451194};
758 time -= timeShift[i];
760 // Slewing correction
761 if (adc == 0) return time;
763 Float_t p1 = 1.57345e1;
764 Float_t p2 =-4.25603e-1;
766 return (time - p1*TMath::Power(adc,p2));
769 Float_t AliTriggerAnalysis::V0LeadingTimeWeight(Float_t adc) const
771 if (adc < 1e-6) return 0;
774 Float_t p2 =-4.25603e-1;
777 return 1./(p1*p1*TMath::Power(adc,2.*(p2-1.))+p3*p3);
780 Bool_t AliTriggerAnalysis::ZDCTrigger(const AliESDEvent* aEsd, AliceSide side) const
782 // Returns if ZDC triggered
784 AliESDZDC* zdcData = aEsd->GetESDZDC();
787 AliError("AliESDZDC not available");
791 UInt_t quality = zdcData->GetESDQuality();
793 // from Nora's presentation, general first physics meeting 16.10.09
794 static UInt_t zpc = 0x20;
795 static UInt_t znc = 0x10;
796 static UInt_t zem1 = 0x08;
797 static UInt_t zem2 = 0x04;
798 static UInt_t zpa = 0x02;
799 static UInt_t zna = 0x01;
801 if (side == kASide && ((quality & zpa) || (quality & zna)))
803 if (side == kCentralBarrel && ((quality & zem1) || (quality & zem2)))
805 if (side == kCSide && ((quality & zpc) || (quality & znc)))
811 Int_t AliTriggerAnalysis::FMDHitCombinations(const AliESDEvent* aEsd, AliceSide side, Bool_t fillHists)
813 // returns number of hit combinations agove threshold
815 // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger)
817 // Workaround for AliESDEvent::GetFMDData is not const!
818 const AliESDFMD* fmdData = (const_cast<AliESDEvent*>(aEsd))->GetFMDData();
821 AliError("AliESDFMD not available");
825 Int_t detFrom = (side == kASide) ? 1 : 3;
826 Int_t detTo = (side == kASide) ? 2 : 3;
829 Float_t totalMult = 0;
830 for (UShort_t det=detFrom;det<=detTo;det++) {
831 Int_t nRings = (det == 1 ? 1 : 2);
832 for (UShort_t ir = 0; ir < nRings; ir++) {
833 Char_t ring = (ir == 0 ? 'I' : 'O');
834 UShort_t nsec = (ir == 0 ? 20 : 40);
835 UShort_t nstr = (ir == 0 ? 512 : 256);
836 for (UShort_t sec =0; sec < nsec; sec++) {
837 for (UShort_t strip = 0; strip < nstr; strip++) {
838 Float_t mult = fmdData->Multiplicity(det,ring,sec,strip);
839 if (mult == AliESDFMD::kInvalidMult) continue;
842 fHistFMDSingle->Fill(mult);
844 if (mult > fFMDLowCut)
845 totalMult = totalMult + mult;
848 if (totalMult > fFMDHitCut)
852 fHistFMDSum->Fill(totalMult);
864 Bool_t AliTriggerAnalysis::FMDTrigger(const AliESDEvent* aEsd, AliceSide side)
866 // Returns if the FMD triggered
868 // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger)
870 Int_t triggers = FMDHitCombinations(aEsd, side, kFALSE);
878 Long64_t AliTriggerAnalysis::Merge(TCollection* list)
880 // Merge a list of AliMultiplicityCorrection objects with this (needed for
882 // Returns the number of merged objects (including this).
890 TIterator* iter = list->MakeIterator();
893 // collections of all histograms
894 const Int_t nHists = 9;
895 TList collections[nHists];
898 while ((obj = iter->Next())) {
900 AliTriggerAnalysis* entry = dynamic_cast<AliTriggerAnalysis*> (obj);
905 collections[n++].Add(entry->fHistV0A);
906 collections[n++].Add(entry->fHistV0C);
907 collections[n++].Add(entry->fHistZDC);
908 collections[n++].Add(entry->fHistFMDA);
909 collections[n++].Add(entry->fHistFMDC);
910 collections[n++].Add(entry->fHistFMDSingle);
911 collections[n++].Add(entry->fHistFMDSum);
912 collections[n++].Add(entry->fHistBitsSPD);
913 collections[n++].Add(entry->fHistFiredBitsSPD);
915 // merge fTriggerClasses
916 TIterator* iter2 = entry->fTriggerClasses->MakeIterator();
918 while ((obj = dynamic_cast<TObjString*> (iter2->Next())))
920 TParameter<Long64_t>* param2 = dynamic_cast<TParameter<Long64_t>*> (entry->fTriggerClasses->GetValue(obj));
922 TParameter<Long64_t>* param1 = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj));
925 param1->SetVal(param1->GetVal() + param2->GetVal());
929 param1 = dynamic_cast<TParameter<Long64_t>*> (param2->Clone());
930 fTriggerClasses->Add(new TObjString(obj->String()), param1);
940 fHistV0A->Merge(&collections[n++]);
941 fHistV0C->Merge(&collections[n++]);
942 fHistZDC->Merge(&collections[n++]);
943 fHistFMDA->Merge(&collections[n++]);
944 fHistFMDC->Merge(&collections[n++]);
945 fHistFMDSingle->Merge(&collections[n++]);
946 fHistFMDSum->Merge(&collections[n++]);
947 fHistBitsSPD->Merge(&collections[n++]);
948 fHistFiredBitsSPD->Merge(&collections[n++]);
955 void AliTriggerAnalysis::SaveHistograms() const
957 // write histograms to current directory
962 fHistBitsSPD->Write();
963 fHistBitsSPD->ProjectionX();
964 fHistBitsSPD->ProjectionY();
965 fHistFiredBitsSPD->Write();
971 fHistFMDSingle->Write();
972 fHistFMDSum->Write();
974 if (fSPDGFOEfficiency)
975 fSPDGFOEfficiency->Write("fSPDGFOEfficiency");
977 fTriggerClasses->Write("fTriggerClasses", TObject::kSingleKey);
980 void AliTriggerAnalysis::PrintTriggerClasses() const
982 // print trigger classes
984 Printf("Trigger Classes:");
986 Printf("Event count for trigger combinations:");
989 singleTrigger.SetOwner();
991 TIterator* iter = fTriggerClasses->MakeIterator();
993 while ((obj = dynamic_cast<TObjString*> (iter->Next())))
995 TParameter<Long64_t>* param = static_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj));
997 Printf(" %s: %ld triggers", obj->String().Data(), param->GetVal());
999 TObjArray* tokens = obj->String().Tokenize(" ");
1000 for (Int_t i=0; i<tokens->GetEntries(); i++)
1002 TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (singleTrigger.GetValue(((TObjString*) tokens->At(i))->String().Data()));
1005 count = new TParameter<Long64_t>(((TObjString*) tokens->At(i))->String().Data(), 0);
1006 singleTrigger.Add(new TObjString(((TObjString*) tokens->At(i))->String().Data()), count);
1008 count->SetVal(count->GetVal() + param->GetVal());
1015 Printf("Event count for single trigger:");
1017 iter = singleTrigger.MakeIterator();
1018 while ((obj = dynamic_cast<TObjString*> (iter->Next())))
1020 TParameter<Long64_t>* param = static_cast<TParameter<Long64_t>*> (singleTrigger.GetValue(obj));
1022 Printf(" %s: %ld triggers", obj->String().Data(), param->GetVal());
1026 singleTrigger.DeleteAll();