]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdPt/AlidNdPtEventCuts.cxx
Adding absolute paths to macros, fitting DCA with 3 components (primaries + fakes...
[u/mrichter/AliRoot.git] / PWG0 / dNdPt / AlidNdPtEventCuts.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 #include <iostream>
17 #include <TList.h>
18
19 #include "AliLog.h"
20 #include "AliESDEvent.h"
21 #include "AliESDVertex.h"
22 #include "AliMCEvent.h"
23 #include "AliHeader.h"
24 #include "AliGenEventHeader.h"
25
26 #include "AlidNdPtEventCuts.h"
27
28 using namespace std;
29
30 ClassImp(AlidNdPtEventCuts)
31
32 //_____________________________________________________________________________
33 AlidNdPtEventCuts::AlidNdPtEventCuts(const Char_t* name,const Char_t *title) : 
34 AliAnalysisCuts(name, title)
35 , fTriggerRequired(kTRUE)
36 , fRecVertexRequired(kTRUE)
37 , fEventProcessType(AliPWG0Helper::kInvalidProcess)
38 , fMinNContributors(0)
39 , fMaxNContributors(0)
40 , fMaxR(0)
41 , fMinZv(0)
42 , fMaxZv(0)
43 , fMeanXv(0)
44 , fMeanYv(0)
45 , fMeanZv(0)
46 , fSigmaMeanXv(0)
47 , fSigmaMeanYv(0)
48 , fSigmaMeanZv(0)
49 , fRedoTPCVertex(kTRUE)
50 , fUseBeamSpotConstraint(kTRUE)
51 {
52   // default constructor 
53   
54   // init data members with defaults
55   Init();
56 }
57
58 //_____________________________________________________________________________
59 AlidNdPtEventCuts::~AlidNdPtEventCuts()  
60 {
61   // destructor
62 }
63
64 //_____________________________________________________________________________
65 void AlidNdPtEventCuts::Init()  
66 {
67   // set default values
68   SetTriggerRequired();
69   SetRecVertexRequired();
70   SetEventProcessType();
71   SetNContributorsRange();
72   SetMaxR();
73   SetZvRange();
74   SetMeanXYZv();
75   SetSigmaMeanXYZv();
76   SetRedoTPCVertex();
77   SetUseBeamSpotConstraint();
78 }
79
80 //_____________________________________________________________________________
81 Bool_t AlidNdPtEventCuts::AcceptEvent(AliESDEvent *esdEvent,AliMCEvent *mcEvent, const AliESDVertex *vtx)
82 {
83   // Check event selection cuts
84   Bool_t retValue=kTRUE;
85
86   if(!esdEvent) return kFALSE;
87   if(!IsRecVertexRequired()) return kTRUE;
88   if(!vtx) return kFALSE;
89   if(!vtx->GetStatus()) return kFALSE;
90
91   if(mcEvent) {
92    // check MC event conditions
93    AliHeader* header = mcEvent->Header();
94    if(!header) return kFALSE;
95   
96     // select event type (ND-non diffractive, SD-single diffractive, DD-double diffractive)
97     if(fEventProcessType == AliPWG0Helper::kInvalidProcess) { 
98       retValue=kTRUE;
99     } 
100     else if(fEventProcessType == AliPWG0Helper::kSD || fEventProcessType == AliPWG0Helper::kDD) {
101       AliPWG0Helper::MCProcessType processType = AliPWG0Helper::GetEventProcessType(header);
102       if(processType == AliPWG0Helper::kND) retValue=kFALSE;
103       else retValue=kTRUE;
104     }
105     else if(fEventProcessType == AliPWG0Helper::GetEventProcessType(header)) { 
106       retValue=kTRUE;
107     }
108     else 
109       retValue=kFALSE;
110   }
111
112   /*
113   Float_t R = TMath::Sqrt(vtx->GetXv()*vtx->GetXv()+vtx->GetYv()*vtx->GetYv());
114   if(vtx->GetNContributors() < fMinNContributors) return kFALSE; 
115   if(vtx->GetNContributors() > fMaxNContributors) return kFALSE; 
116   if(R > fMaxR) return kFALSE; 
117   */
118
119   if(vtx->GetZv() < fMinZv) return kFALSE; 
120   if(vtx->GetZv() > fMaxZv) return kFALSE; 
121
122 return retValue;  
123 }
124
125 //_____________________________________________________________________________
126 Bool_t AlidNdPtEventCuts::AcceptMCEvent(AliMCEvent *mcEvent)
127 {
128   // Check event selection cuts
129   if(!mcEvent) return kFALSE;
130
131   Bool_t retValue=kTRUE;
132
133   // check MC event conditions
134   AliHeader* header = mcEvent->Header();
135   if(!header) return kFALSE;
136
137   AliGenEventHeader* genHeader = header->GenEventHeader();
138   if (!genHeader) {
139     AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");
140     return kFALSE;
141   }
142   TArrayF vtxMC(3);
143   genHeader->PrimaryVertex(vtxMC);
144   
145   // select event type (ND-non diffractive, SD-single diffractive, DD-double diffractive)
146   if(fEventProcessType == AliPWG0Helper::kInvalidProcess) { 
147      retValue=kTRUE;
148   } else {
149      if(fEventProcessType == AliPWG0Helper::GetEventProcessType(header)) retValue=kTRUE;
150      else retValue=kFALSE;
151   }
152
153   /*
154   Float_t R = TMath::Sqrt(vtxMC[0]*vtxMC[0]+vtxMC[1]*vtxMC[1]);
155   if(R > fMaxR) return kFALSE; 
156   */
157
158   if(vtxMC[2] < fMinZv) return kFALSE; 
159   if(vtxMC[2] > fMaxZv) return kFALSE; 
160
161 return retValue;  
162 }
163
164 //_____________________________________________________________________________
165 Long64_t AlidNdPtEventCuts::Merge(TCollection* list) 
166 {
167   // Merge list of objects (needed by PROOF)
168   if (!list)
169   return 0;
170
171   if (list->IsEmpty())
172   return 1;
173
174   TIterator* iter = list->MakeIterator();
175   TObject* obj = 0;
176
177   Int_t count=0;
178   while((obj = iter->Next()) != 0) 
179   {
180     AlidNdPtEventCuts* entry = dynamic_cast<AlidNdPtEventCuts*>(obj);
181     if (entry == 0)  
182       continue; 
183
184   count++;
185   }
186
187 return count;
188 }