]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/info/AliTRDeventCuts.cxx
fix coverity
[u/mrichter/AliRoot.git] / PWG1 / TRD / info / AliTRDeventCuts.cxx
CommitLineData
07ece31c 1/*************************************************************************
2* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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////////////////////////////////////////////////////////////////////////////
16// //
17// Event cut class for the TRD Performance Train //
18// //
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 //
24// //
25// *) see constructor for default values //
26// //
27// author //
28// Markus Fasel <m.fasel@gsi.de> //
29// //
30////////////////////////////////////////////////////////////////////////////
31
32
33#include <TIterator.h>
34#include <TMath.h>
35#include <TObjArray.h>
36#include <TObjString.h>
37#include <TString.h>
38
39#include "AliESDEvent.h"
40#include "AliESDVertex.h"
41
42#include "AliTRDeventCuts.h"
43
44ClassImp(AliTRDeventCuts)
45
62a70d0d 46//______________________________________________________________
47AliTRDeventCuts::AliTRDeventCuts():
48 TNamed("trdEventCuts", ""),
49 fTriggerNames(NULL),
50 fVertexN(1),
51 fVertexZ(15.)
52{
53 //
54 // Dummy Constructor
55 //
56}
57
07ece31c 58//______________________________________________________________
59AliTRDeventCuts::AliTRDeventCuts(const Char_t *name):
60 TNamed(name, ""),
61 fTriggerNames(NULL),
62 fVertexN(1),
63 fVertexZ(15.)
64{
65 //
66 // Default Constructor
67 //
68}
69
70//______________________________________________________________
71AliTRDeventCuts::~AliTRDeventCuts()
72{
73// Destructor
74
75 if(fTriggerNames) fTriggerNames->Delete();
76 delete fTriggerNames;
77}
78
79//______________________________________________________________
80Bool_t AliTRDeventCuts::IsSelected(AliESDEvent *ev, Bool_t col)
81{
82// Apply cuts
83
84 Bool_t select = kTRUE;
85 if(fTriggerNames){
86 Bool_t passTrigger = kFALSE;
87 TString trgname = ev->GetFiredTriggerClasses();
88 TObjArray *triggers = trgname.Tokenize("");
89 TIterator *trgIter = triggers->MakeIterator();
90 TObjString *trg = NULL;
91 while((trg = dynamic_cast<TObjString *>(trgIter->Next())))
92 passTrigger = passTrigger || CheckTrigger(trg->String().Data());
93 delete triggers; delete trgIter;
94 select = select && passTrigger;
95 }
96 // select only physical events
97 select = select && (ev->GetEventType() == 7);
98
99 if(!col) return select;
100
101 const AliESDVertex *primVtx = ev->GetPrimaryVertex();
102 if(fVertexN > 0)
103 select = select && (primVtx && primVtx->GetNContributors() >= fVertexN);
104 if(fVertexZ >= 0.)
105 select = select && (primVtx && TMath::Abs(primVtx->GetZ()) <= fVertexZ);
106 return select;
107}
108
109//______________________________________________________________
110void AliTRDeventCuts::AddTrigger(const Char_t *name)
111{
112// Add trigger name according to the logbook
113
114 if(!fTriggerNames) fTriggerNames = new TObjArray;
115 if(CheckTrigger(name)) return;
116 fTriggerNames->Add(new TObjString(name));
117}
118
119//______________________________________________________________
120Bool_t AliTRDeventCuts::CheckTrigger(const Char_t *name)
121{
122// check if trigger with id "name" is on the accepted trigger list
123
124 TObjString *trg = NULL;
125 TIterator *it = fTriggerNames->MakeIterator();
126 Bool_t triggerExists = kFALSE;
127 while((trg = dynamic_cast<TObjString *>(it))){
128 if(!trg->String().CompareTo(name)) triggerExists = kTRUE;
129 }
130 delete it;
131 return triggerExists;
132}