1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 // To select on the Event Class: look at the Trigger mask and the ZDC info.
16 // Only pp-running trigger types implemented so far
17 // handles all masks for the trigger description
18 // and some general combinations like MB1,MB2,MB3,MB4 and MB5.
19 // The argument of IsSelected member function (passed object) is cast into
20 // an AliVEvent, but cuts have a true meaning only for AliESD(AOD)Event
22 // The class derives from AliCFCutBase
23 // Author:S.Arcelli Silvia.Arcelli@cern.ch
29 #include "AliVEvent.h"
30 #include "AliCFEventClassCuts.h"
31 ClassImp(AliCFEventClassCuts)
32 //____________________________________________________________________
33 AliCFEventClassCuts::AliCFEventClassCuts() :
37 fZDCN1EnergyMin(-1.e99),
38 fZDCP1EnergyMin(-1.e99),
39 fZDCN2EnergyMin(-1.e99),
40 fZDCP2EnergyMin(-1.e99),
41 fZDCEM1EnergyMin(-1.e99),
42 fZDCEM2EnergyMin(-1.e99),
43 fZDCN1EnergyMax(1.e99),
44 fZDCP1EnergyMax(1.e99),
45 fZDCN2EnergyMax(1.e99),
46 fZDCP2EnergyMax(1.e99),
47 fZDCEM1EnergyMax(1.e99),
48 fZDCEM2EnergyMax(1.e99),
59 //____________________________________________________________________
60 AliCFEventClassCuts::AliCFEventClassCuts(Char_t* name, Char_t* title) :
61 AliCFCutBase(name,title),
64 fZDCN1EnergyMin(-1.e99),
65 fZDCP1EnergyMin(-1.e99),
66 fZDCN2EnergyMin(-1.e99),
67 fZDCP2EnergyMin(-1.e99),
68 fZDCEM1EnergyMin(-1.e99),
69 fZDCEM2EnergyMin(-1.e99),
70 fZDCN1EnergyMax(1.e99),
71 fZDCP1EnergyMax(1.e99),
72 fZDCN2EnergyMax(1.e99),
73 fZDCP2EnergyMax(1.e99),
74 fZDCEM1EnergyMax(1.e99),
75 fZDCEM2EnergyMax(1.e99),
85 //_____________________________________________________________________________
86 AliCFEventClassCuts::AliCFEventClassCuts(const AliCFEventClassCuts& c) :
88 fTriggerType(c.fTriggerType),
89 fTriggerAND(c.fTriggerAND),
90 fZDCN1EnergyMin(c.fZDCN1EnergyMin),
91 fZDCP1EnergyMin(c.fZDCP1EnergyMin),
92 fZDCN2EnergyMin(c.fZDCN2EnergyMin),
93 fZDCP2EnergyMin(c.fZDCP2EnergyMin),
94 fZDCEM1EnergyMin(c.fZDCEM1EnergyMin),
95 fZDCEM2EnergyMin(c.fZDCEM2EnergyMin),
96 fZDCN1EnergyMax(c.fZDCN1EnergyMax),
97 fZDCP1EnergyMax(c.fZDCP1EnergyMax),
98 fZDCN2EnergyMax(c.fZDCN2EnergyMax),
99 fZDCP2EnergyMax(c.fZDCP2EnergyMax),
100 fZDCEM1EnergyMax(c.fZDCEM1EnergyMax),
101 fZDCEM2EnergyMax(c.fZDCEM2EnergyMax),
110 //_____________________________________________________________________________
111 AliCFEventClassCuts& AliCFEventClassCuts::operator=(const AliCFEventClassCuts& c){
113 // Assignment operator
116 AliCFCutBase::operator=(c) ;
117 fTriggerType = c.fTriggerType ;
118 fTriggerAND = c.fTriggerAND ;
119 fZDCN1EnergyMin = c.fZDCN1EnergyMin;
120 fZDCP1EnergyMin = c.fZDCP1EnergyMin;
121 fZDCN2EnergyMin = c.fZDCN2EnergyMin;
122 fZDCP2EnergyMin = c.fZDCP2EnergyMin;
123 fZDCEM1EnergyMin = c.fZDCEM1EnergyMin;
124 fZDCEM2EnergyMin = c.fZDCEM2EnergyMin;
125 fZDCN1EnergyMax = c.fZDCN1EnergyMax;
126 fZDCP1EnergyMax = c.fZDCP1EnergyMax;
127 fZDCN2EnergyMax = c.fZDCN2EnergyMax;
128 fZDCP2EnergyMax = c.fZDCP2EnergyMax;
129 fZDCEM1EnergyMax = c.fZDCEM1EnergyMax;
130 fZDCEM2EnergyMax = c.fZDCEM2EnergyMax;
135 for (Int_t i=0; i<c.kNCuts; i++){
136 for (Int_t j=0; j<c.kNStepQA; j++){
137 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
144 //_____________________________________________________________________________
145 AliCFEventClassCuts::~AliCFEventClassCuts()
150 for (Int_t i=0; i<kNCuts; i++){
151 for (Int_t j=0; j<kNStepQA; j++){
152 if(fhQA[i][j]) delete fhQA[i][j];
156 if(fBitMap)delete fBitMap;
160 //_____________________________________________________________________________
161 void AliCFEventClassCuts::Initialise()
166 // sets pointers to histos to zero
167 for(Int_t i=0; i<kNCuts; i++){
168 for(Int_t j =0; j<kNStepQA; j++){
174 //____________________________________________________________________
175 Bool_t AliCFEventClassCuts::IsSelected(TObject* obj) {
177 //Check if the requested cuts are passed
180 SelectionBitMap(obj);
182 if (fIsQAOn) FillHistograms(obj,0);
183 Bool_t isSelected = kTRUE;
185 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
186 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
188 if (!isSelected) return kFALSE ;
189 if (fIsQAOn) FillHistograms(obj,1);
193 //____________________________________________________________________
194 void AliCFEventClassCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
197 //setting x-axis bin limits of QA histogram fhQA[index]
199 for(Int_t i=0;i<kNStepQA;i++){
200 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
203 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
206 //____________________________________________________________________
207 void AliCFEventClassCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
210 //setting x-axis bins and range of QA histogram fhQA[index]
212 for(Int_t i=0;i<kNStepQA;i++){
213 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
216 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
219 //____________________________________________________________________
220 void AliCFEventClassCuts::SelectionBitMap(TObject* obj) {
222 //cut on trigger type (just pp running trigger types implemented so far)
223 //and on the energy observed in the ZDC. The argument is cast into
224 //an AliVEvent, but has true meaning only for AliESDEvent type objects.
225 //Check if the requested cuts are passed and return a bitmap
228 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
230 AliVEvent* esd = dynamic_cast<AliVEvent *>(obj);
234 //now start checking the cuts
235 //first assume the event will be accepted:
236 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
241 //look at the Trigger mask in current event
242 TBits *triggerBitMap=new TBits(0);
243 TriggerBitMap(esd,triggerBitMap);
244 //now compare to what was requested as a Trigger:
245 if(fTriggerType.GetNbits()>0)fBitMap->SetBitNumber(0,kFALSE); //trigger required, initialize to false
246 for(Int_t j=0;j<kNTriggers+kNTriggersMB;j++){
247 if(fTriggerType.TestBitNumber(j)){
249 if(triggerBitMap->TestBitNumber(j) == fTriggerType.TestBitNumber(j)){
250 fBitMap->SetBitNumber(0,kTRUE);
252 break;// @least one requested bit fired, ok
255 if(!triggerBitMap->TestBitNumber(j)){
262 delete triggerBitMap;
263 //Then, cut on the energy observed in the ZDC
265 if( esd->GetZDCN1Energy()<fZDCN1EnergyMin || esd->GetZDCN1Energy()>fZDCN1EnergyMax)fBitMap->SetBitNumber(1,kFALSE);
266 if( esd->GetZDCP1Energy()<fZDCP1EnergyMin || esd->GetZDCP1Energy()>fZDCP1EnergyMax)fBitMap->SetBitNumber(2,kFALSE);
267 if( esd->GetZDCN2Energy()<fZDCN2EnergyMin || esd->GetZDCN2Energy()>fZDCN2EnergyMax)fBitMap->SetBitNumber(3,kFALSE);
268 if( esd->GetZDCP2Energy()<fZDCP2EnergyMin || esd->GetZDCP2Energy()>fZDCP2EnergyMax)fBitMap->SetBitNumber(4,kFALSE);
269 if( esd->GetZDCEMEnergy(0)<fZDCEM1EnergyMin || esd->GetZDCEMEnergy(0)>fZDCEM1EnergyMax)fBitMap->SetBitNumber(5,kFALSE);
270 if( esd->GetZDCEMEnergy(1)<fZDCEM2EnergyMin || esd->GetZDCEMEnergy(1)>fZDCEM2EnergyMax)fBitMap->SetBitNumber(6,kFALSE);
275 //_____________________________________________________________________________
276 Bool_t AliCFEventClassCuts::IsTriggered(AliVEvent* ev, TriggerType trigger) {
278 //look at the Trigger mask in current event
279 TBits *triggerBitMap=new TBits(0);
280 TriggerBitMap(ev,triggerBitMap);
281 Bool_t isTriggered=kFALSE;
282 if(triggerBitMap->TestBitNumber(trigger))isTriggered=kTRUE;
283 delete triggerBitMap;
288 //_____________________________________________________________________________
289 void AliCFEventClassCuts::TriggerBitMap(AliVEvent* ev, TBits *bitmapT ) {
292 for(Int_t itrig=0;itrig<kNTriggers+kNTriggersMB;itrig++)bitmapT->SetBitNumber(itrig,kFALSE);
295 ULong64_t triggerMask = ev->GetTriggerMask();
296 //run over the different triggers in the mask, and check which bits have fired
297 for(Int_t itrig=0;itrig<kNTriggers;itrig++){
298 bitmapT->SetBitNumber(itrig,kFALSE);
299 if (triggerMask&(0x1 <<itrig)){
300 bitmapT->SetBitNumber(itrig,kTRUE);
304 //Trigger combinations, Minimum bias triggers
306 //MB1 case: (GFO || V0OR) && !BG
307 if((bitmapT->TestBitNumber(5) || (bitmapT->TestBitNumber(0) || bitmapT->TestBitNumber(1))) && !bitmapT->TestBitNumber(2)) bitmapT->SetBitNumber(17,kTRUE);
309 //MB2 case: (GFO && V0OR) && !BG
310 if((bitmapT->TestBitNumber(5) && (bitmapT->TestBitNumber(0) || bitmapT->TestBitNumber(1))) && !bitmapT->TestBitNumber(2)) bitmapT->SetBitNumber(18,kTRUE);
312 //MB3 case : (GFO && V0AND) && !BG
313 if((bitmapT->TestBitNumber(5) && (bitmapT->TestBitNumber(0) && bitmapT->TestBitNumber(1))) && !bitmapT->TestBitNumber(2)) bitmapT->SetBitNumber(19,kTRUE);
315 //MB4 case: (GFO || V0AND) && !BG
316 if((bitmapT->TestBitNumber(5) || (bitmapT->TestBitNumber(0) && bitmapT->TestBitNumber(1))) && !bitmapT->TestBitNumber(2)) bitmapT->SetBitNumber(20,kTRUE);
318 //MB5 case:: GFO && !BG
319 if(bitmapT->TestBitNumber(5) && !bitmapT->TestBitNumber(2)) bitmapT->SetBitNumber(21,kTRUE);
324 //_____________________________________________________________________________
325 void AliCFEventClassCuts::DefineHistograms() {
327 // histograms for cut variables
332 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
336 // book QA histograms
338 for (Int_t i=0; i<kNStepQA; i++) {
339 if (i==0) snprintf(str,5," ");
340 else snprintf(str,5,"_cut");
342 fhQA[kTrigger][i] = new TH1F(Form("%s_TriggerBits%s",GetName(),str), "",23,-0.5,22.5);
343 fhQA[kZDCEnergyN1][i] = new TH1F(Form("%s_ZDC_Energy_N1%s",GetName(),str), "",800,-500,7500);
344 fhQA[kZDCEnergyP1][i] = new TH1F(Form("%s_ZDC_Energy_P1%s",GetName(),str), "",800,-500,7500);
345 fhQA[kZDCEnergyN2][i] = new TH1F(Form("%s_ZDC_Energy_N2%s",GetName(),str), "",800,-500,7500);
346 fhQA[kZDCEnergyP2][i] = new TH1F(Form("%s_ZDC_Energy_P2%s",GetName(),str), "",800,-500,7500);
347 fhQA[kZDCEnergyEM1][i] = new TH1F(Form("%s_ZDC_Energy_EM1%s",GetName(),str), "",800,-500,7500);
348 fhQA[kZDCEnergyEM2][i] = new TH1F(Form("%s_ZDC_Energy_EM2%s",GetName(),str), "",800,-500,7500);
350 fhQA[kTrigger][i] ->SetXTitle("Trigger Bits");
351 fhQA[kZDCEnergyN1][i] ->SetXTitle("ZDC Energy N1 (GeV)");
352 fhQA[kZDCEnergyP1][i] ->SetXTitle("ZDC Energy P1 (GeV)");
353 fhQA[kZDCEnergyN2][i] ->SetXTitle("ZDC Energy N2 (GeV)");
354 fhQA[kZDCEnergyP2][i] ->SetXTitle("ZDC Energy P2 (GeV)");
355 fhQA[kZDCEnergyEM1][i] ->SetXTitle("ZDC Energy EM1 (GeV)");
356 fhQA[kZDCEnergyEM2][i] ->SetXTitle("ZDC Energy EM2 (GeV)");
360 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
364 //_____________________________________________________________________________
365 void AliCFEventClassCuts::FillHistograms(TObject* obj, Bool_t afterCuts)
368 // fill the QA histograms
372 // cast TObject into VParticle
373 AliVEvent* esd = dynamic_cast<AliVEvent *>(obj);
376 //look at the Trigger mask in current event
377 TBits *triggerBitMap=new TBits(0);
378 TriggerBitMap(esd, triggerBitMap);
381 for(Int_t itrig=0;itrig<kNTriggers+kNTriggersMB;itrig++){
382 if(triggerBitMap->TestBitNumber(itrig)){
383 fhQA[kTrigger][afterCuts]->Fill(itrig);
387 delete triggerBitMap;
390 fhQA[kZDCEnergyN1][afterCuts] ->Fill(esd->GetZDCN1Energy());
391 fhQA[kZDCEnergyP1][afterCuts] ->Fill(esd->GetZDCP1Energy());
392 fhQA[kZDCEnergyN2][afterCuts] ->Fill(esd->GetZDCN2Energy());
393 fhQA[kZDCEnergyP2][afterCuts] ->Fill(esd->GetZDCP2Energy());
394 fhQA[kZDCEnergyEM1][afterCuts]->Fill(esd->GetZDCEMEnergy(0));
395 fhQA[kZDCEnergyEM2][afterCuts]->Fill(esd->GetZDCEMEnergy(1));
399 //_____________________________________________________________________________
400 void AliCFEventClassCuts::AddQAHistograms(TList *qaList) {
402 // saves the histograms in a TList
407 for (Int_t j=0; j<kNStepQA; j++) {
408 for(Int_t i=0; i<kNCuts; i++)
409 qaList->Add(fhQA[i][j]);