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