compilation warning fix
[u/mrichter/AliRoot.git] / PWG4 / JetCorrel / AliJetCorrelReader.cxx
CommitLineData
4986dbbd 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15/* $Id: $ */\r
16\r
17//__________________________________________________________________________\r
18// Class for input (ESD or AOD) reading.\r
19// At the moment only ESD input is really implemented, AOD to be added later.\r
20// Its products are the Trigger&Associated particle lists\r
21//-- Author: Paul Constantin\r
22\r
23#include "AliJetCorrelReader.h"\r
24\r
25using namespace std;\r
26\r
27ClassImp(AliJetCorrelReader)\r
28\r
29AliJetCorrelReader::AliJetCorrelReader() :\r
30 fjcESD(NULL), fSelector(NULL), fWriter(NULL){\r
31 // constructor\r
32}\r
33\r
34AliJetCorrelReader::~AliJetCorrelReader(){\r
35 // destructor\r
36}\r
37\r
38void AliJetCorrelReader::Init(AliJetCorrelSelector * const s, AliJetCorrelWriter * const w){\r
39 // initialization method\r
40 fSelector = s;\r
41 fWriter = w;\r
42}\r
43\r
44Float_t AliJetCorrelReader::GetMultiplicity() const {\r
45 // event multiplicity\r
46 if(!fjcESD){\r
47 std::cerr<<"AliJetCorrelReader::GetVertex() - ERROR : fjcESD not set!"<<std::endl; \r
48 exit(-1);\r
49 }\r
50 // return fjcESD->GetNumberOfTracks(); // ESD no of global tracks\r
51 const AliMultiplicity* m = fjcESD->GetMultiplicity(); // SPD no of tracklets\r
52 return m->GetNumberOfTracklets();\r
53}\r
54\r
55Float_t AliJetCorrelReader::GetVertex() const {\r
56 // event vertex\r
57 if(!fjcESD){\r
58 std::cerr<<"AliJetCorrelReader::GetVertex() - ERROR : fjcESD not set!"<<std::endl; \r
59 exit(-1);\r
60 }\r
61 return fjcESD->GetPrimaryVertex()->GetZ();\r
62}\r
63\r
64Bool_t AliJetCorrelReader::VtxOutPipe() const {\r
65 // returns true if vertex R >= beam pipe\r
66 Float_t xVtx2 = fjcESD->GetPrimaryVertex()->GetX()*fjcESD->GetPrimaryVertex()->GetX();\r
67 Float_t yVtx2 = fjcESD->GetPrimaryVertex()->GetY()*fjcESD->GetPrimaryVertex()->GetY();\r
68 if(TMath::Sqrt(xVtx2+yVtx2)>3) return kTRUE;\r
69 return kFALSE;\r
70}\r
71\r
72void AliJetCorrelReader::FillLists(CorrelList_t *trigList, CorrelList_t *assoList){\r
73 // fills the trigger&associated particle lists, in this order!\r
74 cPartType_t trigType = trigList->PartID();\r
75 cPartType_t assoType = assoList->PartID();\r
76 Bool_t filledTrig = trigList->Filled();\r
77 Bool_t filledAsso = assoList->Filled();\r
78 // when needed, fill both lists simultaneously for speed:\r
79 if(!filledTrig && !filledAsso && trigType==assoType){\r
80 switch(trigType){\r
81 case t_hadron:\r
82 FillESDTrackLists(trigList,assoList); // trigger list first!\r
83 break;\r
84 default:\r
85 std::cerr<<"AliJetCorrelReader::FillLists() - ERROR: type not implemented!"<<std::endl;\r
86 exit(-1);\r
87 }\r
88 trigList->SetFilled(kTRUE);\r
89 assoList->SetFilled(kTRUE);\r
90 } else {\r
91 if(!filledTrig){\r
92 FillList(trigList,kTRUE);\r
93 trigList->SetFilled(kTRUE);\r
94 }\r
95 if(!filledAsso){\r
96 FillList(assoList,kFALSE);\r
97 assoList->SetFilled(kTRUE);\r
98 }\r
99 }\r
100}\r
101\r
102void AliJetCorrelReader::FillList(CorrelList_t *list, Bool_t isTrigg){\r
103 // calls the appropriate Fill method for the list's particle type\r
104 cPartType_t partType = list->PartID();\r
105 switch(partType){\r
106 case t_hadron:\r
107 FillESDTrackList(list,isTrigg);\r
108 break;\r
109 case t_electron: \r
110 FillESDTrackList(list,isTrigg);\r
111 break;\r
112 case t_dielectron:\r
113 FillESDDielectronList(list,isTrigg);\r
114 break;\r
115 case t_photon:\r
116 FillESDPhotonList(list,isTrigg);\r
117 break;\r
118 case t_diphoton:\r
119 FillESDDiphotonList(list,isTrigg);\r
120 break;\r
121 default:\r
122 std::cerr<<"AliJetCorrelReader::FillList() - ERROR: type not implemented!"<<std::endl;\r
123 exit(-1);\r
124 }\r
125}\r
126\r
127void AliJetCorrelReader::FillESDTrackLists(CorrelList_t *trigList, CorrelList_t *assoList){\r
128 // fills trigg&assoc lists simultaneously with ESD tracks\r
129 cPartType_t partType = trigList->PartID(); // by definition the two lists store same particle\r
130\r
131 UInt_t nTracks = fjcESD->GetNumberOfTracks() ;\r
132 if(nTracks<1) return;\r
133 for(register UInt_t i=0; i<nTracks; i++){\r
134 AliESDtrack *track = (AliESDtrack*)fjcESD->GetTrack(i);\r
135\r
136 Float_t pT = track->Pt();\r
137 if(pT<fSelector->MinLowBin(t_asso)) continue;\r
138 if(fSelector->GenQA()) fWriter->FillTrackQA(track,0);\r
139 if(fSelector->LowQualityTrack(track)) continue;\r
140 if(!fSelector->PassPID(track,partType)) continue;\r
141 if(fSelector->GenQA()) fWriter->FillTrackQA(track,1);\r
142\r
143 // fill CorrelList_t object with CorrelTrack_t if two-track cuts (TPC entrance) are used and\r
144 // with CorrelParticle_t if not (base particle uses much less memory). Pair (ghost) cuts need\r
145 // to be applied for both real/mixed pairs, but it's not clear yet whether this is necessary.\r
146// CorrelTrack_t *hadr = new CorrelTrack_t; // if uncommenting these 3 lines, comment out next line\r
147// const AliExternalTrackParam* tpcEntry = track->GetInnerParam();\r
148// hadr->SetTPCEntry(tpcEntry->GetX(),tpcEntry->GetY(),tpcEntry->GetZ());\r
149 CorrelParticle_t *hadr = new CorrelParticle_t;\r
150 hadr->SetPt(pT*track->Charge());\r
151 hadr->SetPhi(track->Phi());\r
152 hadr->SetEta(track->Eta());\r
153 hadr->SetMass(track->GetMass());\r
154 hadr->SetID(partType);\r
155\r
156 if(fSelector->GetBin(t_trig,pT)>=0) trigList->Push(hadr->Copy());\r
157 if(fSelector->GetBin(t_asso,pT)>=0) assoList->Push(hadr->Copy());\r
158 delete hadr;\r
159 } // ESD track loop\r
160}\r
161\r
162void AliJetCorrelReader::FillESDTrackList(CorrelList_t *list, Bool_t isTrigg){\r
163 // this method is called for: (1) associated hadrons, when trigger is not hadron;\r
164 // (2) electrons to be used in dielectron reconstruction. Assoc pT cuts apply then...\r
165 if(isTrigg)\r
166 {std::cerr<<"AliJetCorrelReader::FillESDTrackList - ERROR: not meant for triggers!"<<std::endl; exit(-1);}\r
167 cPartType_t partType = list->PartID();\r
168\r
169 UInt_t nTracks = fjcESD->GetNumberOfTracks();\r
170 if(nTracks<1) return;\r
171 for(register UInt_t i=0; i<nTracks; i++){\r
172 AliESDtrack *track = (AliESDtrack*)fjcESD->GetTrack(i);\r
173\r
174 Float_t pT = track->Pt();\r
175 if(pT<fSelector->MinLowBin(t_asso)) continue; \r
176 if(fSelector->GenQA()) fWriter->FillTrackQA(track,0);\r
177 if(fSelector->LowQualityTrack(track)) continue;\r
178 if(fSelector->GenQA()) fWriter->FillTrackQA(track,1);\r
179 if(!fSelector->PassPID(track,partType)) continue;\r
180 \r
181 // fill CorrelList_t object with CorrelKFTrack_t if AliKFParticle is used for di-electrons and \r
182 // with CorrelParticle_t if this is done via TLorentzVector in CorrelRecoParent_t (less memory).\r
183 // AliKFParticle allows for a vertex cut on the reconstructed di-electron\r
184 if(partType==t_electron && fSelector->UseAliKF()){\r
185 CorrelKFTrack_t *elec = new CorrelKFTrack_t;\r
186 const AliExternalTrackParam* tPar = track->GetConstrainedParam();\r
187 elec->SetParam(tPar->GetParameter());\r
188 elec->SetCovar(tPar->GetCovariance());\r
189 elec->SetPt(pT*track->Charge());\r
190 elec->SetPhi(track->Phi());\r
191 elec->SetEta(track->Eta());\r
192 elec->SetMass(track->GetMass());\r
193 elec->SetID(partType);\r
194 list->Push(elec);\r
195 } else {\r
196 CorrelParticle_t *hadr = new CorrelParticle_t;\r
197 hadr->SetPt(pT*track->Charge());\r
198 hadr->SetPhi(track->Phi());\r
199 hadr->SetEta(track->Eta());\r
200 hadr->SetMass(track->GetMass());\r
201 hadr->SetID(partType);\r
202 list->Push(hadr);\r
203 } \r
204 }\r
205}\r
206\r
207void AliJetCorrelReader::FillESDPhotonList(CorrelList_t *list, Bool_t isTrigg){\r
208 // TBI\r
209 std::cerr<<"WARNING : FillESDPhotonList() not emplemented yet. Doing nothing..."<<std::endl;\r
210 std::cerr<<"Photon list size:"<<list->Size()<<" type:"<<isTrigg<<std::endl;\r
211}\r
212\r
213void AliJetCorrelReader::FillESDDiphotonList(CorrelList_t* list, Bool_t isTrigg){\r
214 // makes a diphoton list (see above warning!)\r
215 CorrelList_t *fPhotonList = new CorrelList_t;\r
216 fPhotonList->Label(t_photon,0); // event number unimportant here\r
217 FillESDPhotonList(fPhotonList, isTrigg);\r
218 FillParentList(list, fPhotonList, isTrigg);\r
219 fWriter->FillParentNtuple(list);\r
220 delete fPhotonList;\r
221}\r
222\r
223void AliJetCorrelReader::FillESDDielectronList(CorrelList_t* list, Bool_t isTrigg){\r
224 // makes a dielectron list\r
225 CorrelList_t *fElectronList = new CorrelList_t;\r
226 fElectronList->Label(t_electron,0); // event number unimportant here\r
227 FillESDTrackList(fElectronList, isTrigg);\r
228 FillParentList(list, fElectronList, isTrigg);\r
229 fWriter->FillParentNtuple(list);\r
230 delete fElectronList;\r
231}\r
232\r
233void AliJetCorrelReader::FillParentList(CorrelList_t *ParentList, CorrelList_t *ChildList, Bool_t isTrigg){\r
234 // makes a list of parent particles from a list of children of same type\r
235 if(ChildList->Size()<2) return;\r
236\r
237 CorrelListIter_t iterChild1, iterChild2;\r
238 iterChild1 = ChildList->Head();\r
239 while(!iterChild1.HasEnded()){\r
240 CorrelParticle_t *child1 = iterChild1.Data(); iterChild1.Move();\r
241 iterChild2 = iterChild1;\r
242 while(!iterChild2.HasEnded()){\r
243 CorrelParticle_t *child2 = iterChild2.Data(); iterChild2.Move();\r
244 CorrelRecoParent_t *parent = new CorrelRecoParent_t;\r
245 parent->SetEvent(fjcESD);\r
246 Bool_t goodParent = parent->Reconstruct(child1, child2, fSelector->UseAliKF());\r
247 Bool_t inPtRange = (!isTrigg && fSelector->GetBin(t_asso,parent->Pt())>=0) ||\r
248 (isTrigg && fSelector->GetBin(t_trig,parent->Pt())>=0);\r
249 if(goodParent && inPtRange) ParentList->Push(parent);\r
250 } // 2nd particle loop\r
251 } // 1st particle loop\r
252}\r