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