1 /*************************************************************************
2 * Copyright(c) 1998-2008, 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. * **************************************************************************/
15 ////////////////////////////////////////////////////////////////////////////
17 // Event cut class for the TRD Performance Train //
19 // Encapsulation of events cuts for usage with TRD performance train //
20 // - reconstructed vertex //
21 // - vertex Z position //
22 // - vertex number of contributors //
23 // - trigger selection list //
25 // *) see constructor for default values //
28 // Markus Fasel <m.fasel@gsi.de> //
30 ////////////////////////////////////////////////////////////////////////////
33 #include <TIterator.h>
35 #include <TObjArray.h>
36 #include <TObjString.h>
40 #include "AliESDEvent.h"
41 #include "AliESDVertex.h"
43 #include "AliTRDeventInfo.h"
44 #include "AliTRDeventCuts.h"
46 ClassImp(AliTRDeventCuts)
48 //______________________________________________________________
49 AliTRDeventCuts::AliTRDeventCuts()
50 :TNamed("trdEventCuts", "")
63 //______________________________________________________________
64 AliTRDeventCuts::AliTRDeventCuts(const Char_t *name)
73 // Default Constructor
77 //______________________________________________________________
78 AliTRDeventCuts::AliTRDeventCuts(const AliTRDeventCuts &ref)
82 ,fEventType(ref.fEventType)
83 ,fVertexN(ref.fVertexN)
84 ,fVertexZ(ref.fVertexZ)
87 if(ref.fTriggerNames){
88 for(Int_t it(0); it<ref.fTriggerNames->GetEntriesFast(); it++) AddTrigger(((TObjString*)(*ref.fTriggerNames)[it])->GetName());
90 if(ref.fBunches) SetBunchSelection(AliTRDeventInfo::kLHCbunches, ref.fBunches);
93 //______________________________________________________________
94 AliTRDeventCuts::~AliTRDeventCuts()
98 if(fTriggerNames) fTriggerNames->Delete();
100 if(fBunches) delete [] fBunches;
103 //______________________________________________________________
104 Bool_t AliTRDeventCuts::IsSelected(AliESDEvent *ev, Bool_t col)
108 Bool_t select = kTRUE;
110 Bool_t passTrigger = kFALSE;
111 TString trgname = ev->GetFiredTriggerClasses();
112 TObjArray *triggers = trgname.Tokenize(" ");
113 TIterator *trgIter = triggers->MakeIterator();
114 TObjString *trg(NULL);
115 while((trg = dynamic_cast<TObjString *>(trgIter->Next())))
116 passTrigger = passTrigger || CheckTrigger(trg->String().Data());
117 delete triggers; delete trgIter;
118 select = select && passTrigger;
121 AliDebug(1, Form("Reject Ev[%d] for trigger[%s]", ev->GetEventNumberInFile(), ev->GetFiredTriggerClasses().Data()));
124 // select only physical events
125 select = select && (ev->GetEventType() == fEventType);
127 AliDebug(1, Form("Reject Ev[%d] for EvType[%d]", ev->GetEventNumberInFile(), ev->GetEventType()));
131 if(!col) return select;
134 const AliESDVertex *primVtx = ev->GetPrimaryVertex();
136 select = select && (primVtx && primVtx->GetNContributors() >= fVertexN);
138 select = select && (primVtx && TMath::Abs(primVtx->GetZ()) <= fVertexZ);
140 AliDebug(1, Form("Reject Ev[%d] for Vertex[%p][%d %6.2f]", ev->GetEventNumberInFile(), (void*)primVtx, primVtx?primVtx->GetNContributors():0, primVtx?TMath::Abs(primVtx->GetZ()):0));
144 // bunch cross selection
146 Int_t evBC(ev->GetBunchCrossNumber()), ibc(0);
147 Bool_t kFOUND(kFALSE);
148 while(fBunches[ibc]>0){
149 if(evBC==fBunches[ibc]){
155 select = select && kFOUND;
158 AliDebug(1, Form("Reject Ev[%d] for BunchCross[%d]", ev->GetEventNumberInFile(), ev->GetBunchCrossNumber()));
164 //______________________________________________________________
165 void AliTRDeventCuts::AddTrigger(const Char_t *name)
167 // Add trigger name according to the logbook
169 if(!fTriggerNames) fTriggerNames = new TObjArray;
170 if(CheckTrigger(name)) return;
171 fTriggerNames->Add(new TObjString(name));
174 //______________________________________________________________
175 Bool_t AliTRDeventCuts::CheckTrigger(const Char_t *name)
177 // check if trigger with id "name" is on the accepted trigger list
179 if(!fTriggerNames) return kFALSE;
180 Bool_t kExists(kFALSE);
181 for(Int_t it(0); it<fTriggerNames->GetEntriesFast(); it++){
182 if(((TObjString*)(*fTriggerNames)[it])->String().CompareTo(name)==0){
191 //______________________________________________________________
192 void AliTRDeventCuts::Print(Option_t */*opt*/) const
194 // Print content of event cuts
195 printf("Event Type : %2d\n", fEventType);
196 printf("Vertex selection: N[%2d] Z[cm]=%6.2f\n", fVertexN, fVertexZ);
198 printf("Trigger selection: ");
199 for(Int_t it(0); it<fTriggerNames->GetEntriesFast(); it++) printf("\"%s\" ", ((TObjString*)(*fTriggerNames)[it])->GetName());
203 printf("Bunches selection: ");
204 for(Int_t ibc(0); ibc<AliTRDeventInfo::kLHCbunches; ibc++){
205 if(fBunches[ibc]<0) break;
206 printf("%4d ", fBunches[ibc]);
212 //______________________________________________________________
213 void AliTRDeventCuts::SetBunchSelection(Int_t n, Int_t bunches[])
215 // Set Bunch selection for run
216 if(!fBunches) fBunches = new Int_t[AliTRDeventInfo::kLHCbunches];
217 for(Int_t ibc(0); ibc<AliTRDeventInfo::kLHCbunches; ibc++) fBunches[ibc] = ibc<n?bunches[ibc]:-1;