1 /* $Id: AliPhysicsSelection.h 35782 2009-10-22 11:54:31Z jgrosseo $ */
3 #ifndef ALIPHYSICSSELECTION_H
4 #define ALIPHYSICSSELECTION_H
6 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
9 //-------------------------------------------------------------------------
10 // Implementation of Class AliPhysicsSelection
12 // This class selects collision candidates from data runs, applying selection cuts on triggers
13 // and background rejection based on the content of the ESD
15 // Origin: Jan Fiete Grosse-Oetringhaus, CERN
16 // Michele Floris, CERN
17 //-------------------------------------------------------------------------
19 #include <AliAnalysisCuts.h>
21 #include "TObjString.h"
22 #include "AliVEvent.h"
23 #include "AliAnalysisManager.h"
25 //#define VERBOSE_STAT
31 class AliTriggerAnalysis;
32 class AliAnalysisTaskSE;
33 class AliOADBPhysicsSelection ;
34 class AliOADBFillingScheme ;
37 class AliPhysicsSelection : public AliAnalysisCuts
42 enum {kStatTriggerClass=1,kStatHWTrig,kStatV0ABG,kStatV0CBG,kStatMB1,kStatMB1Prime,kStatFMD,kStatFO1,kStatFO2,kStatFO2L1,kStatV0A,kStatV0C,kStatZDCA,kStatZDCC,kStatZDCAC,kStatZDCTime,kStatV0,kStatOffline,kStatBG,kStatAccepted};
45 enum {kStatRowAllB=0, kStatRowAllAC, kStatRowAllE, kStatRowBG,kStatRowAcc,kStatRowBGFrac,kStatRowAccFrac,kStatRowErrGoodFrac,kStatRowGoodFrac,kStatRowErrGood,kStatRowGood}; // offset wrt fBGStatOffset
47 enum {kStatRowAllB=0, kStatRowAllAC, kStatRowAllE, kStatRowBG, kStatRowAcc,kStatRowGood}; // offset wrt fBGStatOffset
50 enum {kStatIdxAll=0,kStatIdxBin0=1};
51 enum ETriggerLogic { kCINT1 = 0, kCMBS2A, kCMBS2C, kCMBAC, kCMBACS2, kHighMultL1 };
53 typedef Bool_t (*Bin0Callback_t)(const AliESDEvent *);
55 AliPhysicsSelection();
56 virtual ~AliPhysicsSelection();
58 // AliAnalysisCuts interface
59 virtual UInt_t GetSelectionMask(const TObject* obj) { return IsCollisionCandidate((const AliESDEvent*) obj); }
60 virtual Bool_t IsSelected(TList*) { return kFALSE; }
61 virtual Bool_t IsSelected(TObject*) {return kFALSE;}
63 Int_t GetCurrentRun() const {return fCurrentRun;}
64 UInt_t IsCollisionCandidate(const AliESDEvent* aEsd);
65 Bool_t Initialize(const AliESDEvent* aEsd);
66 Bool_t Initialize(Int_t runNumber);
68 void SetAnalyzeMC(Bool_t flag = kTRUE) { fMC = flag; }
69 void SetSkipTriggerClassSelection(Bool_t flag = kTRUE) { fSkipTriggerClassSelection = flag; }
70 void SetSkipV0(Bool_t flag=kTRUE) { fSkipV0 = flag;}
71 void SetSkipZDCTime(Bool_t flag=kTRUE) { fSkipZDCTime = flag;}
73 void AddBackgroundIdentification(AliAnalysisCuts* background) { fBackgroundIdentification = background; }
75 virtual void Print(const Option_t* option = "") const;
76 virtual Long64_t Merge(TCollection* list);
77 void SaveHistograms(const char* folder = 0);
79 const TList* GetCollisionTriggerClasses() const { return &fCollTrigClasses; }
80 const TList* GetBGTriggerClasses() const { return &fBGTrigClasses; }
81 void AddCollisionTriggerClass(const char* className);
82 void AddBGTriggerClass(const char* className) ;
83 void SetCustomOADBObjects(AliOADBPhysicsSelection * oadbPS, AliOADBFillingScheme * oadbFS) { fPSOADB = oadbPS; fFillOADB = oadbFS; fUsingCustomClasses = kTRUE;}
84 const AliOADBPhysicsSelection * GetOADBPhysicsSelection() const {return fPSOADB; }
85 const AliOADBFillingScheme * GetOADBFillingScheme() const {return fFillOADB;}
87 const Int_t GetBGStatOffset() const { return fBGStatOffset; }
90 AliTriggerAnalysis* GetTriggerAnalysis(Int_t i = 0) { return (fTriggerAnalysis.GetEntries() > 0) ? (AliTriggerAnalysis*) fTriggerAnalysis.At(i) : 0; }
92 const TH2F* GetStatisticsHistogram(Int_t idx=kStatIdxAll) const { return fHistStatistics[idx]; }
93 const TH2F* GetBunchCrossingHistogram() const { return fHistBunchCrossing; }
94 virtual TObject *GetStatistics(const Option_t *option) const;
96 void SetBIFactors(const AliESDEvent * aESD);
98 void SetUseBXNumbers(Bool_t flag = kTRUE) {fUseBXNumbers = flag;}
99 void SetComputeBG (UInt_t flag = AliVEvent::kMB) {fComputeBG = flag; if(flag) fUseBXNumbers = flag;}
100 void SetUseMuonTriggers(Bool_t) { Printf("ERROR: Use of AliPhysicsSelection::SetUseMuonTriggers is deprecated. Use AliVEvent::kMUON selection instead."); }
101 void SetBin0Callback( const char * cb) {fBin0CallBack = cb;}
102 void SetBin0CallbackViaPointer( Bin0Callback_t cb) {fBin0CallBackPointer = cb;}// WARNING: THIS SHOULD NOT BE USED, WILL BE REMOVED SOON
104 static const char * GetOADBFileName() { static TString filename; filename.Form("%s/COMMON/PHYSICSSELECTION/data/physicsSelection.root", AliAnalysisManager::GetOADBPath()); return filename.Data();};
107 UInt_t CheckTriggerClass(const AliESDEvent* aEsd, const char* trigger, Int_t& triggerLogic) const;
108 Bool_t EvaluateTriggerLogic(const AliESDEvent* aEsd, AliTriggerAnalysis* triggerAnalysis, const char* triggerLogic, Bool_t offline);
109 TH2F * BookHistStatistics(const char * tag) ;
110 Int_t GetStatRow(const char * triggerBXClass, UInt_t offlineTriggerType, UInt_t ** rowIDs) const;
111 const char * GetTriggerString(TObjString * obj);
114 Int_t fCurrentRun; // run number for which the object is initialized
115 Bool_t fMC; // flag if MC is analyzed
116 TList fCollTrigClasses; // trigger class identifying collision candidates
117 TList fBGTrigClasses; // trigger classes identifying background events
119 TList fTriggerAnalysis; // list of offline trigger objects (several are needed to keep the control histograms separate per trigger class)
121 AliAnalysisCuts* fBackgroundIdentification; // class that performs additional background identification
123 TH2F* fHistStatistics[2]; // how many events are cut away why {all,bin 0}
124 // TH2F* fHistStatisticsTokens; // how many events are cut away why (new version, bins for all tokens. Only used tokens are filled)
125 TH2F* fHistBunchCrossing; // histograms of accepted bunch crossing numbers
126 TH1F* fHistTriggerPattern; // Pattern of the individual detectors in the MB1 trigger. Can reveal inconsistencies/inefficiencies in the trigger
128 Bool_t fSkipTriggerClassSelection; // flag that determines if the trigger classs selection is skipped
129 Bool_t fUsingCustomClasses; // flag that is set if costum trigger classes are defined
130 Bool_t fSkipV0; // ignore information from v0
131 Bool_t fSkipZDCTime; // ignore ZDC timing cut (used in HI)
133 Float_t fBIFactorA; // ratio of interacting over non interacting bunch intensities for beam 1
134 Float_t fBIFactorC; // ratio of interacting over non interacting bunch intensities for beam 2
135 Float_t fBIFactorAC; // ratio of interacting over non interacting bunch intensities for beam 1&2:
136 // for some trigger classes we do not distinguish betweem 1 and 2
139 UInt_t fComputeBG; // Switch on computation of background and filling of relevant stat table entries. If you enable this you can only process one run at a time (the relative bunch intensity used to compute this chages from run to run); This is a mask of the trigger types to be used in the selection, as defined in AliVEvent
140 Int_t fBGStatOffset; // Offset of the BG statistics computed at the end of the processing. It depends on how many trigger classes you have selected
141 Bool_t fUseBXNumbers; // Explicitely select "good" bunch crossing numbers (exclude pilot, afterpulses and fakes). If you anable this you can only process runs within the same filling scheme.
142 Bool_t fUseMuonTriggers; // if true, also use the muon triggers
143 TString fFillingScheme; // stores the filling scheme of the current run.
145 TString fBin0CallBack; // callback used to determine if an event is in the bin0 (name of the task where the callback is implemented);
146 Bin0Callback_t fBin0CallBackPointer; //! don't stream this. TO BE REMOVED SOON
148 Bool_t fIsPP; // True if processing pp run, false if heavy ion
150 AliOADBPhysicsSelection * fPSOADB; // Physics selection OADB object
151 AliOADBFillingScheme * fFillOADB; // Filling scheme OADB object
153 TPRegexp* fRegexp; //! regular expression for trigger tokens
154 TList* fCashedTokens; //! trigger token lookup list
156 ClassDef(AliPhysicsSelection, 13)
159 AliPhysicsSelection(const AliPhysicsSelection&);
160 AliPhysicsSelection& operator=(const AliPhysicsSelection&);