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>
39 #include "AliESDEvent.h"
40 #include "AliESDVertex.h"
42 #include "AliTRDeventCuts.h"
44 ClassImp(AliTRDeventCuts)
46 //______________________________________________________________
47 AliTRDeventCuts::AliTRDeventCuts(const Char_t *name):
54 // Default Constructor
58 //______________________________________________________________
59 AliTRDeventCuts::~AliTRDeventCuts()
63 if(fTriggerNames) fTriggerNames->Delete();
67 //______________________________________________________________
68 Bool_t AliTRDeventCuts::IsSelected(AliESDEvent *ev, Bool_t col)
72 Bool_t select = kTRUE;
74 Bool_t passTrigger = kFALSE;
75 TString trgname = ev->GetFiredTriggerClasses();
76 TObjArray *triggers = trgname.Tokenize("");
77 TIterator *trgIter = triggers->MakeIterator();
78 TObjString *trg = NULL;
79 while((trg = dynamic_cast<TObjString *>(trgIter->Next())))
80 passTrigger = passTrigger || CheckTrigger(trg->String().Data());
81 delete triggers; delete trgIter;
82 select = select && passTrigger;
84 // select only physical events
85 select = select && (ev->GetEventType() == 7);
87 if(!col) return select;
89 const AliESDVertex *primVtx = ev->GetPrimaryVertex();
91 select = select && (primVtx && primVtx->GetNContributors() >= fVertexN);
93 select = select && (primVtx && TMath::Abs(primVtx->GetZ()) <= fVertexZ);
97 //______________________________________________________________
98 void AliTRDeventCuts::AddTrigger(const Char_t *name)
100 // Add trigger name according to the logbook
102 if(!fTriggerNames) fTriggerNames = new TObjArray;
103 if(CheckTrigger(name)) return;
104 fTriggerNames->Add(new TObjString(name));
107 //______________________________________________________________
108 Bool_t AliTRDeventCuts::CheckTrigger(const Char_t *name)
110 // check if trigger with id "name" is on the accepted trigger list
112 TObjString *trg = NULL;
113 TIterator *it = fTriggerNames->MakeIterator();
114 Bool_t triggerExists = kFALSE;
115 while((trg = dynamic_cast<TObjString *>(it))){
116 if(!trg->String().CompareTo(name)) triggerExists = kTRUE;
119 return triggerExists;