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