]>
Commit | Line | Data |
---|---|---|
af885e0f | 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 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
f56a9fa7 | 19 | // Implementation of the AliESDEvent class |
6989bff3 | 20 | // This is the class to deal with during the physics analysis of data. |
f56a9fa7 | 21 | // It also ensures the backward compatibility with the old ESD format. |
6989bff3 | 22 | /* |
23 | AliESDEvent *ev= new AliESDEvent(); | |
24 | ev->ReadFromTree(esdTree); | |
25 | ... | |
26 | for (Int_t i=0; i<nev; i++) { | |
27 | esdTree->GetEntry(i); | |
28 | if(ev->GetAliESDOld())ev->CopyFromOldESD(); | |
29 | */ | |
7d44c466 | 30 | // The AliESDInputHandler does this automatically for you |
f56a9fa7 | 31 | // |
32 | // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch | |
af885e0f | 33 | //----------------------------------------------------------------- |
34 | ||
35 | #include "TList.h" | |
cd1d4ee0 | 36 | #include "TRefArray.h" |
af885e0f | 37 | #include <TNamed.h> |
2a3dfb14 | 38 | #include <TROOT.h> |
39 | #include <TInterpreter.h> | |
af885e0f | 40 | |
41 | #include "AliESDEvent.h" | |
42 | #include "AliESDfriend.h" | |
43 | #include "AliESDVZERO.h" | |
af885e0f | 44 | #include "AliESDFMD.h" |
45 | #include "AliESD.h" | |
f0106218 | 46 | #include "AliESDMuonTrack.h" |
47 | #include "AliESDPmdTrack.h" | |
48 | #include "AliESDTrdTrack.h" | |
49 | #include "AliESDVertex.h" | |
50 | #include "AliESDcascade.h" | |
51 | #include "AliESDPmdTrack.h" | |
52 | #include "AliESDTrdTrack.h" | |
52cd0cc0 | 53 | #include "AliESDTrdTracklet.h" |
f0106218 | 54 | #include "AliESDVertex.h" |
518573d7 | 55 | #include "AliVertexerTracks.h" |
f0106218 | 56 | #include "AliESDcascade.h" |
57 | #include "AliESDkink.h" | |
58 | #include "AliESDtrack.h" | |
59 | #include "AliESDHLTtrack.h" | |
60 | #include "AliESDCaloCluster.h" | |
e649177a | 61 | #include "AliESDCaloCells.h" |
f0106218 | 62 | #include "AliESDv0.h" |
63 | #include "AliESDFMD.h" | |
64 | #include "AliESDVZERO.h" | |
65 | #include "AliMultiplicity.h" | |
66 | #include "AliRawDataErrorLog.h" | |
e649177a | 67 | #include "AliLog.h" |
bd95bae7 | 68 | #include "AliESDACORDE.h" |
8b12d288 | 69 | #include "AliESDHLTDecision.h" |
fba4b2e2 | 70 | #include "AliCentrality.h" |
ce7adfe9 | 71 | #include "AliEventplane.h" |
8b12d288 | 72 | |
af885e0f | 73 | ClassImp(AliESDEvent) |
74 | ||
60e8f114 | 75 | |
76 | ||
77 | // here we define the names, some classes are no TNamed, therefore the classnames | |
78 | // are the Names | |
6989bff3 | 79 | const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun", |
f858b00e | 80 | "AliESDHeader", |
81 | "AliESDZDC", | |
82 | "AliESDFMD", | |
83 | "AliESDVZERO", | |
84 | "AliESDTZERO", | |
85 | "TPCVertex", | |
86 | "SPDVertex", | |
87 | "PrimaryVertex", | |
88 | "AliMultiplicity", | |
89 | "PHOSTrigger", | |
90 | "EMCALTrigger", | |
91 | "SPDPileupVertices", | |
92 | "TrkPileupVertices", | |
93 | "Tracks", | |
94 | "MuonTracks", | |
95 | "PmdTracks", | |
96 | "TrdTracks", | |
52cd0cc0 | 97 | "TrdTracklets", |
f858b00e | 98 | "V0s", |
99 | "Cascades", | |
100 | "Kinks", | |
101 | "CaloClusters", | |
102 | "EMCALCells", | |
103 | "PHOSCells", | |
104 | "AliRawDataErrorLogs", | |
105 | "AliESDACORDE", | |
106 | "AliTOFHeader"}; | |
bd95bae7 | 107 | |
af885e0f | 108 | //______________________________________________________________________________ |
109 | AliESDEvent::AliESDEvent(): | |
024c7734 | 110 | AliVEvent(), |
af885e0f | 111 | fESDObjects(new TList()), |
112 | fESDRun(0), | |
113 | fHeader(0), | |
114 | fESDZDC(0), | |
115 | fESDFMD(0), | |
116 | fESDVZERO(0), | |
117 | fESDTZERO(0), | |
06cc9d95 | 118 | fTPCVertex(0), |
af885e0f | 119 | fSPDVertex(0), |
120 | fPrimaryVertex(0), | |
121 | fSPDMult(0), | |
122 | fPHOSTrigger(0), | |
123 | fEMCALTrigger(0), | |
bd95bae7 | 124 | fESDACORDE(0), |
04d01397 | 125 | fSPDPileupVertices(0), |
126 | fTrkPileupVertices(0), | |
af885e0f | 127 | fTracks(0), |
128 | fMuonTracks(0), | |
129 | fPmdTracks(0), | |
130 | fTrdTracks(0), | |
52cd0cc0 | 131 | fTrdTracklets(0), |
af885e0f | 132 | fV0s(0), |
133 | fCascades(0), | |
134 | fKinks(0), | |
135 | fCaloClusters(0), | |
e649177a | 136 | fEMCALCells(0), fPHOSCells(0), |
af885e0f | 137 | fErrorLogs(0), |
138 | fESDOld(0), | |
1bd10080 | 139 | fESDFriendOld(0), |
60e8f114 | 140 | fConnected(kFALSE), |
f858b00e | 141 | fUseOwnList(kFALSE), |
2eec2a33 | 142 | fTOFHeader(0), |
ce7adfe9 | 143 | fCentrality(0), |
144 | fEventplane(0) | |
af885e0f | 145 | { |
146 | } | |
147 | //______________________________________________________________________________ | |
148 | AliESDEvent::AliESDEvent(const AliESDEvent& esd): | |
024c7734 | 149 | AliVEvent(esd), |
af885e0f | 150 | fESDObjects(new TList()), |
151 | fESDRun(new AliESDRun(*esd.fESDRun)), | |
152 | fHeader(new AliESDHeader(*esd.fHeader)), | |
153 | fESDZDC(new AliESDZDC(*esd.fESDZDC)), | |
154 | fESDFMD(new AliESDFMD(*esd.fESDFMD)), | |
155 | fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)), | |
156 | fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)), | |
06cc9d95 | 157 | fTPCVertex(new AliESDVertex(*esd.fTPCVertex)), |
af885e0f | 158 | fSPDVertex(new AliESDVertex(*esd.fSPDVertex)), |
159 | fPrimaryVertex(new AliESDVertex(*esd.fPrimaryVertex)), | |
160 | fSPDMult(new AliMultiplicity(*esd.fSPDMult)), | |
161 | fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)), | |
162 | fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)), | |
bd95bae7 | 163 | fESDACORDE(new AliESDACORDE(*esd.fESDACORDE)), |
04d01397 | 164 | fSPDPileupVertices(new TClonesArray(*esd.fSPDPileupVertices)), |
165 | fTrkPileupVertices(new TClonesArray(*esd.fTrkPileupVertices)), | |
af885e0f | 166 | fTracks(new TClonesArray(*esd.fTracks)), |
167 | fMuonTracks(new TClonesArray(*esd.fMuonTracks)), | |
168 | fPmdTracks(new TClonesArray(*esd.fPmdTracks)), | |
169 | fTrdTracks(new TClonesArray(*esd.fTrdTracks)), | |
52cd0cc0 | 170 | fTrdTracklets(new TClonesArray(*esd.fTrdTracklets)), |
af885e0f | 171 | fV0s(new TClonesArray(*esd.fV0s)), |
172 | fCascades(new TClonesArray(*esd.fCascades)), | |
173 | fKinks(new TClonesArray(*esd.fKinks)), | |
174 | fCaloClusters(new TClonesArray(*esd.fCaloClusters)), | |
e649177a | 175 | fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)), |
176 | fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)), | |
af885e0f | 177 | fErrorLogs(new TClonesArray(*esd.fErrorLogs)), |
7251b311 | 178 | fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0), |
179 | fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0), | |
60e8f114 | 180 | fConnected(esd.fConnected), |
f858b00e | 181 | fUseOwnList(esd.fUseOwnList), |
2eec2a33 | 182 | fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)), |
ce7adfe9 | 183 | fCentrality(new AliCentrality(*esd.fCentrality)), |
184 | fEventplane(new AliEventplane(*esd.fEventplane)) | |
af885e0f | 185 | { |
186 | // CKB init in the constructor list and only add here ... | |
187 | AddObject(fESDRun); | |
188 | AddObject(fHeader); | |
189 | AddObject(fESDZDC); | |
190 | AddObject(fESDFMD); | |
191 | AddObject(fESDVZERO); | |
192 | AddObject(fESDTZERO); | |
06cc9d95 | 193 | AddObject(fTPCVertex); |
af885e0f | 194 | AddObject(fSPDVertex); |
195 | AddObject(fPrimaryVertex); | |
196 | AddObject(fSPDMult); | |
197 | AddObject(fPHOSTrigger); | |
198 | AddObject(fEMCALTrigger); | |
04d01397 | 199 | AddObject(fSPDPileupVertices); |
200 | AddObject(fTrkPileupVertices); | |
af885e0f | 201 | AddObject(fTracks); |
202 | AddObject(fMuonTracks); | |
203 | AddObject(fPmdTracks); | |
204 | AddObject(fTrdTracks); | |
52cd0cc0 | 205 | AddObject(fTrdTracklets); |
af885e0f | 206 | AddObject(fV0s); |
207 | AddObject(fCascades); | |
208 | AddObject(fKinks); | |
209 | AddObject(fCaloClusters); | |
e649177a | 210 | AddObject(fEMCALCells); |
211 | AddObject(fPHOSCells); | |
af885e0f | 212 | AddObject(fErrorLogs); |
bd95bae7 | 213 | AddObject(fESDACORDE); |
f858b00e | 214 | AddObject(fTOFHeader); |
af885e0f | 215 | |
216 | GetStdContent(); | |
217 | ||
218 | } | |
219 | ||
220 | //______________________________________________________________________________ | |
221 | AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) { | |
222 | ||
223 | // Assignment operator | |
224 | ||
225 | if(&source == this) return *this; | |
024c7734 | 226 | AliVEvent::operator=(source); |
af885e0f | 227 | |
732a24fe | 228 | // This assumes that the list is already created |
229 | // and that the virtual void Copy(Tobject&) function | |
230 | // is correctly implemented in the derived class | |
231 | // otherwise only TObject::Copy() will be used | |
232 | ||
233 | ||
102c56c8 | 234 | |
732a24fe | 235 | if((fESDObjects->GetSize()==0)&&(source.fESDObjects->GetSize()>=kESDListN)){ |
236 | // We cover the case that we do not yet have the | |
237 | // standard content but the source has it | |
238 | CreateStdContent(); | |
239 | } | |
240 | ||
241 | TIter next(source.GetList()); | |
242 | TObject *its = 0; | |
243 | TString name; | |
244 | while ((its = next())) { | |
245 | name.Form("%s", its->GetName()); | |
246 | TObject *mine = fESDObjects->FindObject(name.Data()); | |
247 | if(!mine){ | |
102c56c8 | 248 | TClass* pClass=TClass::GetClass(its->ClassName()); |
249 | if (!pClass) { | |
250 | AliWarning(Form("Can not find class description for entry %s (%s)\n", | |
251 | its->ClassName(), name.Data())); | |
252 | continue; | |
253 | } | |
732a24fe | 254 | |
102c56c8 | 255 | mine=(TObject*)pClass->New(); |
256 | if(!mine){ | |
257 | // not in this: can be added to list | |
258 | AliWarning(Form("%s:%d Could not find %s for copying \n", | |
259 | (char*)__FILE__,__LINE__,name.Data())); | |
260 | continue; | |
261 | } | |
262 | if(mine->InheritsFrom("TNamed")){ | |
263 | ((TNamed*)mine)->SetName(name); | |
264 | } | |
265 | else if(mine->InheritsFrom("TCollection")){ | |
11becff8 | 266 | if(mine->InheritsFrom("TClonesArray")) { |
267 | TClonesArray* tcits = dynamic_cast<TClonesArray*>(its); | |
268 | if (tcits) | |
269 | dynamic_cast<TClonesArray*>(mine)->SetClass(tcits->GetClass()); | |
270 | } | |
102c56c8 | 271 | dynamic_cast<TCollection*>(mine)->SetName(name); |
272 | } | |
273 | AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName())); | |
274 | AddObject(mine); | |
275 | } | |
276 | ||
732a24fe | 277 | if(!its->InheritsFrom("TCollection")){ |
278 | // simple objects | |
279 | its->Copy(*mine); | |
280 | } | |
281 | else if(its->InheritsFrom("TClonesArray")){ | |
282 | // Create or expand the tclonesarray pointers | |
283 | // so we can directly copy to the object | |
284 | TClonesArray *its_tca = (TClonesArray*)its; | |
285 | TClonesArray *mine_tca = (TClonesArray*)mine; | |
286 | ||
287 | // this leaves the capacity of the TClonesArray the same | |
288 | // except for a factor of 2 increase when size > capacity | |
289 | // does not release any memory occupied by the tca | |
290 | mine_tca->ExpandCreate(its_tca->GetEntriesFast()); | |
291 | for(int i = 0;i < its_tca->GetEntriesFast();++i){ | |
292 | // copy | |
293 | TObject *mine_tca_obj = mine_tca->At(i); | |
294 | TObject *its_tca_obj = its_tca->At(i); | |
295 | // no need to delete first | |
296 | // pointers within the class should be handled by Copy()... | |
297 | // Can there be Empty slots? | |
298 | its_tca_obj->Copy(*mine_tca_obj); | |
299 | } | |
300 | } | |
301 | else{ | |
302 | AliWarning(Form("%s:%d cannot copy TCollection \n", | |
303 | (char*)__FILE__,__LINE__)); | |
304 | } | |
305 | } | |
af885e0f | 306 | |
2eec2a33 | 307 | fCentrality = source.fCentrality; |
ce7adfe9 | 308 | fEventplane = source.fEventplane; |
2eec2a33 | 309 | |
310 | fConnected = source.fConnected; | |
a2fbb067 | 311 | fUseOwnList = source.fUseOwnList; |
af885e0f | 312 | |
af885e0f | 313 | return *this; |
af885e0f | 314 | } |
315 | ||
316 | ||
317 | //______________________________________________________________________________ | |
318 | AliESDEvent::~AliESDEvent() | |
319 | { | |
320 | // | |
321 | // Standard destructor | |
322 | // | |
323 | ||
001b9beb | 324 | // everthing on the list gets deleted automatically |
139f2194 | 325 | |
326 | ||
60e8f114 | 327 | if(fESDObjects&&!fConnected) |
328 | { | |
329 | delete fESDObjects; | |
330 | fESDObjects = 0; | |
331 | } | |
cb62947d | 332 | if (fCentrality) delete fCentrality; |
ce7adfe9 | 333 | if (fEventplane) delete fEventplane; |
60e8f114 | 334 | |
af885e0f | 335 | } |
336 | ||
732a24fe | 337 | void AliESDEvent::Copy(TObject &obj) const { |
338 | ||
339 | // interface to TOBject::Copy | |
340 | // Copies the content of this into obj! | |
341 | // bascially obj = *this | |
342 | ||
343 | if(this==&obj)return; | |
344 | AliESDEvent *robj = dynamic_cast<AliESDEvent*>(&obj); | |
345 | if(!robj)return; // not an AliESEvent | |
346 | *robj = *this; | |
347 | return; | |
348 | } | |
349 | ||
af885e0f | 350 | //______________________________________________________________________________ |
351 | void AliESDEvent::Reset() | |
352 | { | |
353 | ||
102c56c8 | 354 | // Handle the cases |
355 | // Std content + Non std content | |
356 | ||
af885e0f | 357 | // Reset the standard contents |
358 | ResetStdContent(); | |
102c56c8 | 359 | |
360 | // reset for the old data without AliESDEvent... | |
af885e0f | 361 | if(fESDOld)fESDOld->Reset(); |
d7749dec | 362 | if(fESDFriendOld){ |
363 | fESDFriendOld->~AliESDfriend(); | |
364 | new (fESDFriendOld) AliESDfriend(); | |
365 | } | |
102c56c8 | 366 | // |
367 | ||
368 | if(fESDObjects->GetSize()>kESDListN){ | |
369 | // we have non std content | |
370 | // this also covers esdfriends | |
371 | for(int i = kESDListN;i < fESDObjects->GetSize();++i){ | |
372 | TObject *pObject = fESDObjects->At(i); | |
373 | // TClonesArrays | |
374 | if(pObject->InheritsFrom(TClonesArray::Class())){ | |
375 | ((TClonesArray*)pObject)->Delete(); | |
376 | } | |
377 | else if(!pObject->InheritsFrom(TCollection::Class())){ | |
00b66af8 | 378 | TClass *pClass = TClass::GetClass(pObject->ClassName()); |
379 | if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) { | |
380 | AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName())); | |
381 | pObject->Clear(); | |
382 | } | |
383 | else { | |
384 | AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName())); | |
385 | ResetWithPlacementNew(pObject); | |
386 | } | |
102c56c8 | 387 | } |
388 | else{ | |
65b25288 | 389 | AliWarning(Form("No reset for %s \n", |
102c56c8 | 390 | pObject->ClassName())); |
391 | } | |
392 | } | |
d7749dec | 393 | } |
394 | ||
102c56c8 | 395 | } |
396 | ||
397 | Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){ | |
398 | Long_t dtoronly = TObject::GetDtorOnly(); | |
399 | TClass *pClass = TClass::GetClass(pObject->ClassName()); | |
400 | TObject::SetDtorOnly(pObject); | |
401 | delete pObject; | |
402 | // Recreate with placement new | |
403 | pClass->New(pObject); | |
404 | // Restore the state. | |
405 | TObject::SetDtorOnly((void*)dtoronly); | |
406 | return kTRUE; | |
af885e0f | 407 | } |
408 | ||
409 | void AliESDEvent::ResetStdContent() | |
410 | { | |
411 | // Reset the standard contents | |
412 | if(fESDRun) fESDRun->Reset(); | |
413 | if(fHeader) fHeader->Reset(); | |
93d96ff5 | 414 | if(fCentrality) fCentrality->Reset(); |
415 | if(fEventplane) fEventplane->Reset(); | |
af885e0f | 416 | if(fESDZDC) fESDZDC->Reset(); |
0f0eb29c | 417 | if(fESDFMD) { |
a2fbb067 | 418 | fESDFMD->Clear(); |
0f0eb29c | 419 | } |
6989bff3 | 420 | if(fESDVZERO){ |
421 | // reset by callin d'to /c'tor keep the pointer | |
422 | fESDVZERO->~AliESDVZERO(); | |
423 | new (fESDVZERO) AliESDVZERO(); | |
424 | } | |
bd95bae7 | 425 | if(fESDACORDE){ |
426 | fESDACORDE->~AliESDACORDE(); | |
427 | new (fESDACORDE) AliESDACORDE(); | |
428 | } | |
af885e0f | 429 | if(fESDTZERO) fESDTZERO->Reset(); |
430 | // CKB no clear/reset implemented | |
06cc9d95 | 431 | if(fTPCVertex){ |
432 | fTPCVertex->~AliESDVertex(); | |
433 | new (fTPCVertex) AliESDVertex(); | |
434 | fTPCVertex->SetName(fgkESDListName[kTPCVertex]); | |
435 | } | |
af885e0f | 436 | if(fSPDVertex){ |
316c6cd9 | 437 | fSPDVertex->~AliESDVertex(); |
af885e0f | 438 | new (fSPDVertex) AliESDVertex(); |
6989bff3 | 439 | fSPDVertex->SetName(fgkESDListName[kSPDVertex]); |
af885e0f | 440 | } |
441 | if(fPrimaryVertex){ | |
316c6cd9 | 442 | fPrimaryVertex->~AliESDVertex(); |
af885e0f | 443 | new (fPrimaryVertex) AliESDVertex(); |
6989bff3 | 444 | fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]); |
af885e0f | 445 | } |
316c6cd9 | 446 | if(fSPDMult){ |
447 | fSPDMult->~AliMultiplicity(); | |
448 | new (fSPDMult) AliMultiplicity(); | |
449 | } | |
f858b00e | 450 | if(fTOFHeader){ |
451 | fTOFHeader->~AliTOFHeader(); | |
452 | new (fTOFHeader) AliTOFHeader(); | |
453 | //fTOFHeader->SetName(fgkESDListName[kTOFHeader]); | |
454 | } | |
042d5330 | 455 | if(fPHOSTrigger)fPHOSTrigger->DeAllocate(); |
456 | if(fEMCALTrigger)fEMCALTrigger->DeAllocate(); | |
04d01397 | 457 | if(fSPDPileupVertices)fSPDPileupVertices->Delete(); |
458 | if(fTrkPileupVertices)fTrkPileupVertices->Delete(); | |
bc9a7b42 | 459 | if(fTracks)fTracks->Delete(); |
6989bff3 | 460 | if(fMuonTracks)fMuonTracks->Delete(); |
461 | if(fPmdTracks)fPmdTracks->Delete(); | |
462 | if(fTrdTracks)fTrdTracks->Delete(); | |
52cd0cc0 | 463 | if(fTrdTracklets)fTrdTracklets->Delete(); |
6989bff3 | 464 | if(fV0s)fV0s->Delete(); |
465 | if(fCascades)fCascades->Delete(); | |
466 | if(fKinks)fKinks->Delete(); | |
bc9a7b42 | 467 | if(fCaloClusters)fCaloClusters->Delete(); |
e649177a | 468 | if(fPHOSCells)fPHOSCells->DeleteContainer(); |
469 | if(fEMCALCells)fEMCALCells->DeleteContainer(); | |
16167d49 | 470 | if(fErrorLogs) fErrorLogs->Delete(); |
af885e0f | 471 | |
d7749dec | 472 | // don't reset fconnected fConnected and the list |
60e8f114 | 473 | |
af885e0f | 474 | } |
475 | ||
476 | ||
477 | Int_t AliESDEvent::AddV0(const AliESDv0 *v) { | |
478 | // | |
479 | // Add V0 | |
480 | // | |
481 | TClonesArray &fv = *fV0s; | |
482 | Int_t idx=fV0s->GetEntriesFast(); | |
483 | new(fv[idx]) AliESDv0(*v); | |
484 | return idx; | |
485 | } | |
486 | ||
487 | //______________________________________________________________________________ | |
488 | void AliESDEvent::Print(Option_t *) const | |
489 | { | |
490 | // | |
491 | // Print header information of the event | |
492 | // | |
493 | printf("ESD run information\n"); | |
494 | printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n", | |
495 | GetEventNumberInFile(), | |
496 | GetBunchCrossNumber(), | |
497 | GetOrbitNumber(), | |
498 | GetPeriodNumber(), | |
499 | GetRunNumber(), | |
500 | GetTriggerMask(), | |
501 | GetMagneticField() ); | |
c017f53f | 502 | if (fPrimaryVertex) |
503 | printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n", | |
af885e0f | 504 | fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(), |
505 | fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(), | |
506 | fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes()); | |
1c7554f9 | 507 | printf("Mean vertex in RUN: X=%.4f Y=%.4f Z=%.4f cm\n", |
508 | GetDiamondX(),GetDiamondY(),GetDiamondZ()); | |
c017f53f | 509 | if(fSPDMult) |
af885e0f | 510 | printf("SPD Multiplicity. Number of tracklets %d \n", |
511 | fSPDMult->GetNumberOfTracklets()); | |
04d01397 | 512 | printf("Number of pileup primary vertices reconstructed with SPD %d\n", |
c017f53f | 513 | GetNumberOfPileupVerticesSPD()); |
04d01397 | 514 | printf("Number of pileup primary vertices reconstructed using the tracks %d\n", |
c017f53f | 515 | GetNumberOfPileupVerticesTracks()); |
af885e0f | 516 | printf("Number of tracks: \n"); |
517 | printf(" charged %d\n", GetNumberOfTracks()); | |
518 | printf(" muon %d\n", GetNumberOfMuonTracks()); | |
519 | printf(" pmd %d\n", GetNumberOfPmdTracks()); | |
520 | printf(" trd %d\n", GetNumberOfTrdTracks()); | |
52cd0cc0 | 521 | printf(" trd trkl %d\n", GetNumberOfTrdTracklets()); |
af885e0f | 522 | printf(" v0 %d\n", GetNumberOfV0s()); |
523 | printf(" cascades %d\n", GetNumberOfCascades()); | |
524 | printf(" kinks %d\n", GetNumberOfKinks()); | |
38f940fb | 525 | if(fPHOSCells)printf(" PHOSCells %d\n", fPHOSCells->GetNumberOfCells()); |
526 | else printf(" PHOSCells not in the Event\n"); | |
527 | if(fEMCALCells)printf(" EMCALCells %d\n", fEMCALCells->GetNumberOfCells()); | |
528 | else printf(" EMCALCells not in the Event\n"); | |
af885e0f | 529 | printf(" CaloClusters %d\n", GetNumberOfCaloClusters()); |
af885e0f | 530 | printf(" FMD %s\n", (fESDFMD ? "yes" : "no")); |
531 | printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no")); | |
8b12d288 | 532 | TObject* pHLTDecision=GetHLTTriggerDecision(); |
533 | printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available"); | |
534 | if (pHLTDecision) pHLTDecision->Print("compact"); | |
024c7734 | 535 | |
536 | return; | |
af885e0f | 537 | } |
538 | ||
7d44c466 | 539 | void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const { |
af885e0f | 540 | // |
541 | // Attaches the complementary info to the ESD | |
542 | // | |
543 | if (!ev) return; | |
544 | ||
5300bdab | 545 | // to be sure that we set the tracks also |
546 | // in case of old esds | |
60e8f114 | 547 | // if(fESDOld)CopyFromOldESD(); |
5300bdab | 548 | |
af885e0f | 549 | Int_t ntrk=ev->GetNumberOfTracks(); |
550 | ||
551 | for (Int_t i=0; i<ntrk; i++) { | |
552 | const AliESDfriendTrack *f=ev->GetTrack(i); | |
553 | GetTrack(i)->SetFriendTrack(f); | |
554 | } | |
555 | } | |
556 | ||
7d44c466 | 557 | Bool_t AliESDEvent::RemoveKink(Int_t rm) const { |
a023d8d8 | 558 | // --------------------------------------------------------- |
559 | // Remove a kink candidate and references to it from ESD, | |
560 | // if this candidate does not come from a reconstructed decay | |
561 | // Not yet implemented... | |
562 | // --------------------------------------------------------- | |
563 | Int_t last=GetNumberOfKinks()-1; | |
564 | if ((rm<0)||(rm>last)) return kFALSE; | |
565 | ||
566 | return kTRUE; | |
567 | } | |
568 | ||
7d44c466 | 569 | Bool_t AliESDEvent::RemoveV0(Int_t rm) const { |
a023d8d8 | 570 | // --------------------------------------------------------- |
571 | // Remove a V0 candidate and references to it from ESD, | |
572 | // if this candidate does not come from a reconstructed decay | |
573 | // --------------------------------------------------------- | |
574 | Int_t last=GetNumberOfV0s()-1; | |
575 | if ((rm<0)||(rm>last)) return kFALSE; | |
576 | ||
577 | AliESDv0 *v0=GetV0(rm); | |
578 | Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex(); | |
579 | ||
580 | v0=GetV0(last); | |
581 | Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex(); | |
582 | ||
583 | Int_t used=0; | |
584 | ||
585 | // Check if this V0 comes from a reconstructed decay | |
586 | Int_t ncs=GetNumberOfCascades(); | |
587 | for (Int_t n=0; n<ncs; n++) { | |
588 | AliESDcascade *cs=GetCascade(n); | |
589 | ||
590 | Int_t csIdxP=cs->GetPindex(); | |
591 | Int_t csIdxN=cs->GetNindex(); | |
592 | ||
593 | if (idxP==csIdxP) | |
594 | if (idxN==csIdxN) return kFALSE; | |
595 | ||
596 | if (csIdxP==lastIdxP) | |
597 | if (csIdxN==lastIdxN) used++; | |
598 | } | |
599 | ||
600 | //Replace the removed V0 with the last V0 | |
601 | TClonesArray &a=*fV0s; | |
602 | delete a.RemoveAt(rm); | |
603 | ||
604 | if (rm==last) return kTRUE; | |
605 | ||
606 | //v0 is pointing to the last V0 candidate... | |
607 | new (a[rm]) AliESDv0(*v0); | |
608 | delete a.RemoveAt(last); | |
609 | ||
610 | if (!used) return kTRUE; | |
611 | ||
612 | ||
613 | // Remap the indices of the daughters of reconstructed decays | |
614 | for (Int_t n=0; n<ncs; n++) { | |
615 | AliESDcascade *cs=GetCascade(n); | |
616 | ||
617 | ||
618 | Int_t csIdxP=cs->GetPindex(); | |
619 | Int_t csIdxN=cs->GetNindex(); | |
620 | ||
621 | if (csIdxP==lastIdxP) | |
622 | if (csIdxN==lastIdxN) { | |
623 | cs->AliESDv0::SetIndex(1,idxP); | |
624 | cs->AliESDv0::SetIndex(0,idxN); | |
625 | used--; | |
626 | if (!used) return kTRUE; | |
627 | } | |
628 | } | |
629 | ||
630 | return kTRUE; | |
631 | } | |
632 | ||
7d44c466 | 633 | Bool_t AliESDEvent::RemoveTrack(Int_t rm) const { |
d64bd07d | 634 | // --------------------------------------------------------- |
7f68891d | 635 | // Remove a track and references to it from ESD, |
636 | // if this track does not come from a reconstructed decay | |
d64bd07d | 637 | // --------------------------------------------------------- |
7f68891d | 638 | Int_t last=GetNumberOfTracks()-1; |
639 | if ((rm<0)||(rm>last)) return kFALSE; | |
640 | ||
641 | Int_t used=0; | |
d64bd07d | 642 | |
6fca035d | 643 | // Check if this track comes from the reconstructed primary vertices |
644 | if (fTPCVertex && fTPCVertex->GetStatus()) { | |
645 | UShort_t *primIdx=fTPCVertex->GetIndices(); | |
646 | Int_t n=fTPCVertex->GetNIndices(); | |
647 | while (n--) { | |
648 | Int_t idx=Int_t(primIdx[n]); | |
649 | if (rm==idx) return kFALSE; | |
650 | if (idx==last) used++; | |
651 | } | |
652 | } | |
653 | if (fPrimaryVertex && fPrimaryVertex->GetStatus()) { | |
654 | UShort_t *primIdx=fPrimaryVertex->GetIndices(); | |
655 | Int_t n=fPrimaryVertex->GetNIndices(); | |
656 | while (n--) { | |
657 | Int_t idx=Int_t(primIdx[n]); | |
658 | if (rm==idx) return kFALSE; | |
659 | if (idx==last) used++; | |
660 | } | |
661 | } | |
662 | ||
d64bd07d | 663 | // Check if this track comes from a reconstructed decay |
7f68891d | 664 | Int_t nv0=GetNumberOfV0s(); |
665 | for (Int_t n=0; n<nv0; n++) { | |
666 | AliESDv0 *v0=GetV0(n); | |
667 | ||
668 | Int_t idx=v0->GetNindex(); | |
669 | if (rm==idx) return kFALSE; | |
670 | if (idx==last) used++; | |
671 | ||
672 | idx=v0->GetPindex(); | |
673 | if (rm==idx) return kFALSE; | |
674 | if (idx==last) used++; | |
675 | } | |
676 | ||
677 | Int_t ncs=GetNumberOfCascades(); | |
678 | for (Int_t n=0; n<ncs; n++) { | |
679 | AliESDcascade *cs=GetCascade(n); | |
d64bd07d | 680 | |
7f68891d | 681 | Int_t idx=cs->GetIndex(); |
682 | if (rm==idx) return kFALSE; | |
683 | if (idx==last) used++; | |
fdbe4208 | 684 | |
685 | AliESDv0 *v0=cs; | |
686 | idx=v0->GetNindex(); | |
687 | if (rm==idx) return kFALSE; | |
688 | if (idx==last) used++; | |
689 | ||
690 | idx=v0->GetPindex(); | |
691 | if (rm==idx) return kFALSE; | |
692 | if (idx==last) used++; | |
7f68891d | 693 | } |
694 | ||
695 | Int_t nkn=GetNumberOfKinks(); | |
696 | for (Int_t n=0; n<nkn; n++) { | |
697 | AliESDkink *kn=GetKink(n); | |
698 | ||
699 | Int_t idx=kn->GetIndex(0); | |
700 | if (rm==idx) return kFALSE; | |
701 | if (idx==last) used++; | |
702 | ||
703 | idx=kn->GetIndex(1); | |
704 | if (rm==idx) return kFALSE; | |
705 | if (idx==last) used++; | |
706 | } | |
d64bd07d | 707 | |
8303b114 | 708 | // Check if this track is associated with a CaloCluster |
709 | Int_t ncl=GetNumberOfCaloClusters(); | |
710 | for (Int_t n=0; n<ncl; n++) { | |
711 | AliESDCaloCluster *cluster=GetCaloCluster(n); | |
712 | TArrayI *arr=cluster->GetTracksMatched(); | |
713 | Int_t s=arr->GetSize(); | |
714 | while (s--) { | |
715 | Int_t idx=arr->At(s); | |
716 | if (rm==idx) return kFALSE; | |
717 | if (idx==last) used++; | |
718 | } | |
719 | } | |
720 | ||
721 | ||
d64bd07d | 722 | |
7f68891d | 723 | //Replace the removed track with the last track |
724 | TClonesArray &a=*fTracks; | |
725 | delete a.RemoveAt(rm); | |
726 | ||
727 | if (rm==last) return kTRUE; | |
728 | ||
729 | AliESDtrack *t=GetTrack(last); | |
730 | t->SetID(rm); | |
731 | new (a[rm]) AliESDtrack(*t); | |
732 | delete a.RemoveAt(last); | |
733 | ||
6fca035d | 734 | |
7f68891d | 735 | if (!used) return kTRUE; |
736 | ||
737 | ||
6fca035d | 738 | // Remap the indices of the tracks used for the primary vertex reconstruction |
739 | if (fTPCVertex && fTPCVertex->GetStatus()) { | |
740 | UShort_t *primIdx=fTPCVertex->GetIndices(); | |
741 | Int_t n=fTPCVertex->GetNIndices(); | |
742 | while (n--) { | |
743 | Int_t idx=Int_t(primIdx[n]); | |
744 | if (idx==last) { | |
745 | primIdx[n]=Short_t(rm); | |
746 | used--; | |
747 | if (!used) return kTRUE; | |
748 | } | |
749 | } | |
750 | } | |
751 | if (fPrimaryVertex && fPrimaryVertex->GetStatus()) { | |
752 | UShort_t *primIdx=fPrimaryVertex->GetIndices(); | |
753 | Int_t n=fPrimaryVertex->GetNIndices(); | |
754 | while (n--) { | |
755 | Int_t idx=Int_t(primIdx[n]); | |
756 | if (idx==last) { | |
757 | primIdx[n]=Short_t(rm); | |
758 | used--; | |
759 | if (!used) return kTRUE; | |
760 | } | |
761 | } | |
762 | } | |
763 | ||
7f68891d | 764 | // Remap the indices of the daughters of reconstructed decays |
765 | for (Int_t n=0; n<nv0; n++) { | |
766 | AliESDv0 *v0=GetV0(n); | |
767 | if (v0->GetIndex(0)==last) { | |
768 | v0->SetIndex(0,rm); | |
769 | used--; | |
770 | if (!used) return kTRUE; | |
771 | } | |
772 | if (v0->GetIndex(1)==last) { | |
773 | v0->SetIndex(1,rm); | |
774 | used--; | |
775 | if (!used) return kTRUE; | |
776 | } | |
777 | } | |
778 | ||
779 | for (Int_t n=0; n<ncs; n++) { | |
780 | AliESDcascade *cs=GetCascade(n); | |
781 | if (cs->GetIndex()==last) { | |
782 | cs->SetIndex(rm); | |
783 | used--; | |
784 | if (!used) return kTRUE; | |
785 | } | |
fdbe4208 | 786 | AliESDv0 *v0=cs; |
787 | if (v0->GetIndex(0)==last) { | |
788 | v0->SetIndex(0,rm); | |
789 | used--; | |
790 | if (!used) return kTRUE; | |
791 | } | |
792 | if (v0->GetIndex(1)==last) { | |
793 | v0->SetIndex(1,rm); | |
794 | used--; | |
795 | if (!used) return kTRUE; | |
796 | } | |
7f68891d | 797 | } |
798 | ||
799 | for (Int_t n=0; n<nkn; n++) { | |
800 | AliESDkink *kn=GetKink(n); | |
801 | if (kn->GetIndex(0)==last) { | |
802 | kn->SetIndex(rm,0); | |
803 | used--; | |
804 | if (!used) return kTRUE; | |
805 | } | |
806 | if (kn->GetIndex(1)==last) { | |
807 | kn->SetIndex(rm,1); | |
808 | used--; | |
809 | if (!used) return kTRUE; | |
810 | } | |
811 | } | |
d64bd07d | 812 | |
8303b114 | 813 | // Remap the indices of the tracks accosicated with CaloClusters |
814 | for (Int_t n=0; n<ncl; n++) { | |
815 | AliESDCaloCluster *cluster=GetCaloCluster(n); | |
816 | TArrayI *arr=cluster->GetTracksMatched(); | |
817 | Int_t s=arr->GetSize(); | |
818 | while (s--) { | |
819 | Int_t idx=arr->At(s); | |
820 | if (idx==last) { | |
821 | arr->AddAt(rm,s); | |
822 | used--; | |
823 | if (!used) return kTRUE; | |
824 | } | |
825 | } | |
826 | } | |
827 | ||
d64bd07d | 828 | return kTRUE; |
829 | } | |
830 | ||
831 | ||
7f68891d | 832 | Bool_t AliESDEvent::Clean(Float_t *cleanPars) { |
833 | // | |
834 | // Remove the data which are not needed for the physics analysis. | |
835 | // | |
a023d8d8 | 836 | // 1) Cleaning the V0 candidates |
837 | // --------------------------- | |
838 | // If the cosine of the V0 pointing angle "csp" and | |
839 | // the DCA between the daughter tracks "dca" does not satisfy | |
840 | // the conditions | |
841 | // | |
842 | // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1]) | |
843 | // | |
844 | // an attempt to remove this V0 candidate from ESD is made. | |
845 | // | |
846 | // The V0 candidate gets removed if it does not belong to any | |
847 | // recosntructed cascade decay | |
848 | // | |
849 | // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999 | |
850 | // | |
851 | // 2) Cleaning the tracks | |
852 | // ---------------------- | |
853 | // If track's transverse parameter is larger than cleanPars[2] | |
7f68891d | 854 | // OR |
a023d8d8 | 855 | // track's longitudinal parameter is larger than cleanPars[3] |
856 | // an attempt to remove this track from ESD is made. | |
7f68891d | 857 | // |
a023d8d8 | 858 | // The track gets removed if it does not come |
859 | // from a reconstructed decay | |
7f68891d | 860 | // |
a023d8d8 | 861 | Bool_t rc=kFALSE; |
862 | ||
863 | Float_t dcaMax=cleanPars[0]; | |
864 | Float_t cspMin=cleanPars[1]; | |
865 | ||
866 | Int_t nV0s=GetNumberOfV0s(); | |
867 | for (Int_t i=nV0s-1; i>=0; i--) { | |
868 | AliESDv0 *v0=GetV0(i); | |
869 | ||
870 | Float_t dca=v0->GetDcaV0Daughters(); | |
871 | Float_t csp=v0->GetV0CosineOfPointingAngle(); | |
872 | Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin); | |
449e752b | 873 | if (csp > cspcut) continue; |
874 | if (RemoveV0(i)) rc=kTRUE; | |
a023d8d8 | 875 | } |
876 | ||
7f68891d | 877 | |
a023d8d8 | 878 | Float_t dmax=cleanPars[2], zmax=cleanPars[3]; |
7f68891d | 879 | |
06cc9d95 | 880 | const AliESDVertex *vertex=GetPrimaryVertexSPD(); |
a023d8d8 | 881 | Bool_t vtxOK=vertex->GetStatus(); |
7f68891d | 882 | |
883 | Int_t nTracks=GetNumberOfTracks(); | |
884 | for (Int_t i=nTracks-1; i>=0; i--) { | |
885 | AliESDtrack *track=GetTrack(i); | |
886 | Float_t xy,z; track->GetImpactParameters(xy,z); | |
887 | if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) { | |
888 | if (RemoveTrack(i)) rc=kTRUE; | |
889 | } | |
890 | } | |
891 | ||
892 | return rc; | |
893 | } | |
894 | ||
6dc21f57 | 895 | Char_t AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx) |
04d01397 | 896 | { |
897 | // Add a pileup primary vertex reconstructed with SPD | |
898 | TClonesArray &ftr = *fSPDPileupVertices; | |
6dc21f57 | 899 | Char_t n=Char_t(ftr.GetEntriesFast()); |
900 | AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx); | |
901 | vertex->SetID(n); | |
902 | return n; | |
04d01397 | 903 | } |
904 | ||
6dc21f57 | 905 | Char_t AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx) |
04d01397 | 906 | { |
907 | // Add a pileup primary vertex reconstructed with SPD | |
908 | TClonesArray &ftr = *fTrkPileupVertices; | |
6dc21f57 | 909 | Char_t n=Char_t(ftr.GetEntriesFast()); |
910 | AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx); | |
911 | vertex->SetID(n); | |
912 | return n; | |
04d01397 | 913 | } |
914 | ||
6989bff3 | 915 | Int_t AliESDEvent::AddTrack(const AliESDtrack *t) |
916 | { | |
af885e0f | 917 | // Add track |
918 | TClonesArray &ftr = *fTracks; | |
919 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t); | |
920 | track->SetID(fTracks->GetEntriesFast()-1); | |
921 | return track->GetID(); | |
922 | } | |
923 | ||
65a0cf79 | 924 | AliESDtrack* AliESDEvent::NewTrack() |
925 | { | |
926 | // Add a new track | |
927 | TClonesArray &ftr = *fTracks; | |
928 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(); | |
929 | track->SetID(fTracks->GetEntriesFast()-1); | |
930 | return track; | |
931 | } | |
932 | ||
6989bff3 | 933 | void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) |
934 | { | |
f0106218 | 935 | TClonesArray &fmu = *fMuonTracks; |
936 | new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t); | |
937 | } | |
938 | ||
6989bff3 | 939 | void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) |
940 | { | |
f0106218 | 941 | TClonesArray &fpmd = *fPmdTracks; |
942 | new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t); | |
943 | } | |
944 | ||
6989bff3 | 945 | void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) |
946 | { | |
f0106218 | 947 | TClonesArray &ftrd = *fTrdTracks; |
948 | new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t); | |
949 | } | |
950 | ||
52cd0cc0 | 951 | void AliESDEvent::AddTrdTracklet(const AliESDTrdTracklet *trkl) |
952 | { | |
953 | new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(*trkl); | |
954 | } | |
f0106218 | 955 | |
6989bff3 | 956 | Int_t AliESDEvent::AddKink(const AliESDkink *c) |
957 | { | |
af885e0f | 958 | // Add kink |
959 | TClonesArray &fk = *fKinks; | |
960 | AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c); | |
961 | kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps.. | |
962 | return fKinks->GetEntriesFast()-1; | |
963 | } | |
964 | ||
f0106218 | 965 | |
6989bff3 | 966 | void AliESDEvent::AddCascade(const AliESDcascade *c) |
967 | { | |
f0106218 | 968 | TClonesArray &fc = *fCascades; |
969 | new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c); | |
970 | } | |
971 | ||
972 | ||
6989bff3 | 973 | Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) |
974 | { | |
af885e0f | 975 | // Add calocluster |
976 | TClonesArray &fc = *fCaloClusters; | |
977 | AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c); | |
978 | clus->SetID(fCaloClusters->GetEntriesFast()-1); | |
979 | return fCaloClusters->GetEntriesFast()-1; | |
980 | } | |
981 | ||
982 | ||
7d44c466 | 983 | void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) const { |
6989bff3 | 984 | TClonesArray &errlogs = *fErrorLogs; |
985 | new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log); | |
986 | } | |
f0106218 | 987 | |
af6f24c9 | 988 | void AliESDEvent::SetZDCData(AliESDZDC * obj) |
989 | { | |
990 | // use already allocated space | |
991 | if(fESDZDC) | |
992 | *fESDZDC = *obj; | |
993 | } | |
994 | ||
06cc9d95 | 995 | void AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex) |
996 | { | |
997 | // Set the TPC vertex | |
998 | // use already allocated space | |
999 | if(fTPCVertex){ | |
1000 | *fTPCVertex = *vertex; | |
1001 | fTPCVertex->SetName(fgkESDListName[kTPCVertex]); | |
1002 | } | |
1003 | } | |
1004 | ||
1005 | void AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex) | |
6989bff3 | 1006 | { |
1007 | // Set the SPD vertex | |
60e8f114 | 1008 | // use already allocated space |
1009 | if(fSPDVertex){ | |
316c6cd9 | 1010 | *fSPDVertex = *vertex; |
6989bff3 | 1011 | fSPDVertex->SetName(fgkESDListName[kSPDVertex]); |
60e8f114 | 1012 | } |
1013 | } | |
1014 | ||
c264b61b | 1015 | void AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex) |
6989bff3 | 1016 | { |
c264b61b | 1017 | // Set the primary vertex reconstructed using he ESD tracks. |
6989bff3 | 1018 | // use already allocated space |
60e8f114 | 1019 | if(fPrimaryVertex){ |
316c6cd9 | 1020 | *fPrimaryVertex = *vertex; |
6989bff3 | 1021 | fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]); |
60e8f114 | 1022 | } |
1023 | } | |
1024 | ||
c264b61b | 1025 | const AliESDVertex * AliESDEvent::GetPrimaryVertex() const |
1026 | { | |
1027 | // | |
1028 | // Get the "best" available reconstructed primary vertex. | |
1029 | // | |
1030 | if(fPrimaryVertex){ | |
1031 | if (fPrimaryVertex->GetStatus()) return fPrimaryVertex; | |
1032 | } | |
1033 | if(fSPDVertex){ | |
1034 | if (fSPDVertex->GetStatus()) return fSPDVertex; | |
1035 | } | |
1036 | if(fTPCVertex) return fTPCVertex; | |
1037 | ||
1038 | AliWarning("No primary vertex available. Returning the \"default\"..."); | |
1039 | return fSPDVertex; | |
1040 | } | |
1041 | ||
518573d7 | 1042 | AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const |
1043 | { | |
1044 | // | |
1045 | // Removes diamond constraint from fPrimaryVertex (reconstructed with tracks) | |
1046 | // Returns a AliESDVertex which has to be deleted by the user | |
1047 | // | |
1048 | if(!fPrimaryVertex) { | |
1049 | AliWarning("No primary vertex from tracks available."); | |
1050 | return 0; | |
1051 | } | |
1052 | if(!fPrimaryVertex->GetStatus()) { | |
1053 | AliWarning("No primary vertex from tracks available."); | |
1054 | return 0; | |
1055 | } | |
1056 | ||
1057 | AliVertexerTracks vertexer(GetMagneticField()); | |
1058 | Float_t diamondxyz[3]={(Float_t)GetDiamondX(),(Float_t)GetDiamondY(),0.}; | |
1059 | Float_t diamondcovxy[3]; GetDiamondCovXY(diamondcovxy); | |
1060 | Float_t diamondcov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,7.}; | |
1061 | AliESDVertex *vertex = | |
1062 | (AliESDVertex*)vertexer.RemoveConstraintFromVertex(fPrimaryVertex,diamondxyz,diamondcov); | |
1063 | ||
1064 | return vertex; | |
1065 | } | |
1066 | ||
6989bff3 | 1067 | void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) |
1068 | { | |
1069 | // Set the SPD Multiplicity | |
f0106218 | 1070 | if(fSPDMult){ |
316c6cd9 | 1071 | *fSPDMult = *mul; |
f0106218 | 1072 | } |
1073 | } | |
1074 | ||
1075 | ||
6989bff3 | 1076 | void AliESDEvent::SetFMDData(AliESDFMD * obj) |
1077 | { | |
af885e0f | 1078 | // use already allocated space |
1079 | if(fESDFMD){ | |
316c6cd9 | 1080 | *fESDFMD = *obj; |
af885e0f | 1081 | } |
1082 | } | |
1083 | ||
6989bff3 | 1084 | void AliESDEvent::SetVZEROData(AliESDVZERO * obj) |
1085 | { | |
af885e0f | 1086 | // use already allocated space |
1087 | if(fESDVZERO) | |
6989bff3 | 1088 | *fESDVZERO = *obj; |
af885e0f | 1089 | } |
1090 | ||
b0e13b29 | 1091 | void AliESDEvent::SetTZEROData(AliESDTZERO * obj) |
1092 | { | |
1093 | // use already allocated space | |
1094 | if(fESDTZERO) | |
1095 | *fESDTZERO = *obj; | |
1096 | } | |
1097 | ||
bd95bae7 | 1098 | void AliESDEvent::SetACORDEData(AliESDACORDE * obj) |
1099 | { | |
1100 | if(fESDACORDE) | |
1101 | *fESDACORDE = *obj; | |
1102 | } | |
1103 | ||
1104 | ||
6989bff3 | 1105 | void AliESDEvent::GetESDfriend(AliESDfriend *ev) const |
1106 | { | |
af885e0f | 1107 | // |
1108 | // Extracts the complementary info from the ESD | |
1109 | // | |
1110 | if (!ev) return; | |
1111 | ||
1112 | Int_t ntrk=GetNumberOfTracks(); | |
1113 | ||
1114 | for (Int_t i=0; i<ntrk; i++) { | |
80799a5f | 1115 | AliESDtrack *t=GetTrack(i); |
af885e0f | 1116 | const AliESDfriendTrack *f=t->GetFriendTrack(); |
1117 | ev->AddTrack(f); | |
80799a5f | 1118 | |
1119 | t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack" | |
1120 | ||
af885e0f | 1121 | } |
af885e0f | 1122 | |
b090e6a3 | 1123 | AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend")); |
1124 | if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend()); | |
1125 | } | |
af885e0f | 1126 | |
1127 | void AliESDEvent::AddObject(TObject* obj) | |
1128 | { | |
1129 | // Add an object to the list of object. | |
1130 | // Please be aware that in order to increase performance you should | |
1131 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
1132 | fESDObjects->SetOwner(kTRUE); | |
1133 | fESDObjects->AddLast(obj); | |
1134 | } | |
1135 | ||
1136 | ||
1137 | void AliESDEvent::GetStdContent() | |
1138 | { | |
1139 | // set pointers for standard content | |
60e8f114 | 1140 | // get by name much safer and not a big overhead since not called very often |
1141 | ||
6989bff3 | 1142 | fESDRun = (AliESDRun*)fESDObjects->FindObject(fgkESDListName[kESDRun]); |
1143 | fHeader = (AliESDHeader*)fESDObjects->FindObject(fgkESDListName[kHeader]); | |
1144 | fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fgkESDListName[kESDZDC]); | |
1145 | fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fgkESDListName[kESDFMD]); | |
1146 | fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fgkESDListName[kESDVZERO]); | |
1147 | fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fgkESDListName[kESDTZERO]); | |
06cc9d95 | 1148 | fTPCVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kTPCVertex]); |
6989bff3 | 1149 | fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kSPDVertex]); |
1150 | fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kPrimaryVertex]); | |
1151 | fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]); | |
1152 | fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]); | |
1153 | fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]); | |
04d01397 | 1154 | fSPDPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kSPDPileupVertices]); |
1155 | fTrkPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrkPileupVertices]); | |
6989bff3 | 1156 | fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]); |
1157 | fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]); | |
1158 | fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]); | |
1159 | fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]); | |
52cd0cc0 | 1160 | fTrdTracklets = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracklets]); |
6989bff3 | 1161 | fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]); |
1162 | fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]); | |
1163 | fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]); | |
1164 | fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]); | |
e649177a | 1165 | fEMCALCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kEMCALCells]); |
1166 | fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]); | |
6989bff3 | 1167 | fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]); |
bd95bae7 | 1168 | fESDACORDE = (AliESDACORDE*)fESDObjects->FindObject(fgkESDListName[kESDACORDE]); |
f858b00e | 1169 | fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]); |
af885e0f | 1170 | } |
1171 | ||
1172 | void AliESDEvent::SetStdNames(){ | |
1173 | // Set the names of the standard contents | |
60e8f114 | 1174 | // |
102c56c8 | 1175 | if(fESDObjects->GetEntries()>=kESDListN){ |
1176 | for(int i = 0;i < fESDObjects->GetEntries() && i<kESDListN;i++){ | |
60e8f114 | 1177 | TObject *fObj = fESDObjects->At(i); |
1178 | if(fObj->InheritsFrom("TNamed")){ | |
6989bff3 | 1179 | ((TNamed*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 1180 | } |
1181 | else if(fObj->InheritsFrom("TClonesArray")){ | |
6989bff3 | 1182 | ((TClonesArray*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 1183 | } |
1184 | } | |
1185 | } | |
1186 | else{ | |
90e88950 | 1187 | AliWarning("Std Entries missing"); |
60e8f114 | 1188 | } |
af885e0f | 1189 | } |
1190 | ||
a2fbb067 | 1191 | |
1192 | void AliESDEvent::CreateStdContent(Bool_t bUseThisList){ | |
1193 | fUseOwnList = bUseThisList; | |
1194 | CreateStdContent(); | |
1195 | } | |
1196 | ||
af885e0f | 1197 | void AliESDEvent::CreateStdContent() |
1198 | { | |
1199 | // create the standard AOD content and set pointers | |
1200 | ||
1201 | // create standard objects and add them to the TList of objects | |
1202 | AddObject(new AliESDRun()); | |
1203 | AddObject(new AliESDHeader()); | |
1204 | AddObject(new AliESDZDC()); | |
1205 | AddObject(new AliESDFMD()); | |
1206 | AddObject(new AliESDVZERO()); | |
1207 | AddObject(new AliESDTZERO()); | |
1208 | AddObject(new AliESDVertex()); | |
1209 | AddObject(new AliESDVertex()); | |
06cc9d95 | 1210 | AddObject(new AliESDVertex()); |
af885e0f | 1211 | AddObject(new AliMultiplicity()); |
1212 | AddObject(new AliESDCaloTrigger()); | |
1213 | AddObject(new AliESDCaloTrigger()); | |
04d01397 | 1214 | AddObject(new TClonesArray("AliESDVertex",0)); |
1215 | AddObject(new TClonesArray("AliESDVertex",0)); | |
af885e0f | 1216 | AddObject(new TClonesArray("AliESDtrack",0)); |
1217 | AddObject(new TClonesArray("AliESDMuonTrack",0)); | |
1218 | AddObject(new TClonesArray("AliESDPmdTrack",0)); | |
1219 | AddObject(new TClonesArray("AliESDTrdTrack",0)); | |
52cd0cc0 | 1220 | AddObject(new TClonesArray("AliESDTrdTracklet",0)); |
af885e0f | 1221 | AddObject(new TClonesArray("AliESDv0",0)); |
1222 | AddObject(new TClonesArray("AliESDcascade",0)); | |
1223 | AddObject(new TClonesArray("AliESDkink",0)); | |
1224 | AddObject(new TClonesArray("AliESDCaloCluster",0)); | |
e649177a | 1225 | AddObject(new AliESDCaloCells()); |
1226 | AddObject(new AliESDCaloCells()); | |
af885e0f | 1227 | AddObject(new TClonesArray("AliRawDataErrorLog",0)); |
bd95bae7 | 1228 | AddObject(new AliESDACORDE()); |
f858b00e | 1229 | AddObject(new AliTOFHeader()); |
af885e0f | 1230 | |
1231 | // check the order of the indices against enum... | |
1232 | ||
af885e0f | 1233 | // set names |
1234 | SetStdNames(); | |
60e8f114 | 1235 | // read back pointers |
1236 | GetStdContent(); | |
af885e0f | 1237 | } |
1238 | ||
2811495d | 1239 | TObject* AliESDEvent::FindListObject(const char *name) const { |
7d44c466 | 1240 | // |
1241 | // Find object with name "name" in the list of branches | |
1242 | // | |
d7749dec | 1243 | if(fESDObjects){ |
1244 | return fESDObjects->FindObject(name); | |
1245 | } | |
001b9beb | 1246 | return 0; |
1247 | } | |
1248 | ||
cd1d4ee0 | 1249 | Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const |
1250 | { | |
1251 | // fills the provided TRefArray with all found phos clusters | |
e649177a | 1252 | |
cd1d4ee0 | 1253 | clusters->Clear(); |
e649177a | 1254 | |
cd1d4ee0 | 1255 | AliESDCaloCluster *cl = 0; |
1256 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
e649177a | 1257 | |
1258 | if ( (cl = GetCaloCluster(i)) ) { | |
cd1d4ee0 | 1259 | if (cl->IsPHOS()){ |
1260 | clusters->Add(cl); | |
e649177a | 1261 | AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 1262 | } |
1263 | } | |
1264 | } | |
1265 | return clusters->GetEntriesFast(); | |
1266 | } | |
1267 | ||
1268 | Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const | |
1269 | { | |
e649177a | 1270 | // fills the provided TRefArray with all found emcal clusters |
cd1d4ee0 | 1271 | |
1272 | clusters->Clear(); | |
1273 | ||
1274 | AliESDCaloCluster *cl = 0; | |
1275 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
1276 | ||
e649177a | 1277 | if ( (cl = GetCaloCluster(i)) ) { |
cd1d4ee0 | 1278 | if (cl->IsEMCAL()){ |
1279 | clusters->Add(cl); | |
e649177a | 1280 | AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 1281 | } |
1282 | } | |
1283 | } | |
1284 | return clusters->GetEntriesFast(); | |
1285 | } | |
1286 | ||
f12d42ce | 1287 | void AliESDEvent::WriteToTree(TTree* tree) const { |
38f940fb | 1288 | // Book the branches as in TTree::Branch(TCollection*) |
1289 | // but add a "." at the end of top level branches which are | |
1290 | // not a TClonesArray | |
1291 | ||
1292 | ||
1293 | TString branchname; | |
1294 | TIter next(fESDObjects); | |
7d44c466 | 1295 | const Int_t kSplitlevel = 99; // default value in TTree::Branch() |
1296 | const Int_t kBufsize = 32000; // default value in TTree::Branch() | |
38f940fb | 1297 | TObject *obj = 0; |
1298 | ||
1299 | while ((obj = next())) { | |
1300 | branchname.Form("%s", obj->GetName()); | |
32ba9c61 | 1301 | if(branchname.CompareTo("AliESDfriend")==0)branchname = "ESDfriend."; |
7d44c466 | 1302 | if ((kSplitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) { |
732a24fe | 1303 | if(!branchname.EndsWith("."))branchname += "."; |
38f940fb | 1304 | } |
102c56c8 | 1305 | if (!tree->FindBranch(branchname)) { |
771c4f86 | 1306 | // For the custom streamer to be called splitlevel |
1307 | // has to be negative, only needed for HLT | |
1308 | Int_t splitLevel = (TString(obj->ClassName()) == "AliHLTGlobalTriggerDecision") ? -1 : kSplitlevel - 1; | |
1309 | tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),kBufsize, splitLevel); | |
102c56c8 | 1310 | } |
38f940fb | 1311 | } |
38f940fb | 1312 | } |
1313 | ||
cd1d4ee0 | 1314 | |
f7ec3414 | 1315 | void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){ |
7d44c466 | 1316 | // |
1317 | // Connect the ESDEvent to a tree | |
1318 | // | |
6989bff3 | 1319 | if(!tree){ |
90e88950 | 1320 | AliWarning("AliESDEvent::ReadFromTree() Zero Pointer to Tree \n"); |
6989bff3 | 1321 | return; |
1322 | } | |
024c7734 | 1323 | // load the TTree |
6989bff3 | 1324 | if(!tree->GetTree())tree->LoadTree(0); |
024c7734 | 1325 | |
001b9beb | 1326 | // if we find the "ESD" branch on the tree we do have the old structure |
1bd10080 | 1327 | if(tree->GetBranch("ESD")) { |
1328 | char ** address = (char **)(tree->GetBranch("ESD")->GetAddress()); | |
0eb6eb59 | 1329 | // do we have the friend branch |
1330 | TBranch * esdFB = tree->GetBranch("ESDfriend."); | |
1331 | char ** addressF = 0; | |
1332 | if(esdFB)addressF = (char **)(esdFB->GetAddress()); | |
6989bff3 | 1333 | if (!address) { |
90e88950 | 1334 | AliInfo("AliESDEvent::ReadFromTree() Reading old Tree"); |
1bd10080 | 1335 | tree->SetBranchAddress("ESD", &fESDOld); |
0eb6eb59 | 1336 | if(esdFB){ |
1337 | tree->SetBranchAddress("ESDfriend.",&fESDFriendOld); | |
1338 | } | |
6989bff3 | 1339 | } else { |
90e88950 | 1340 | AliInfo("AliESDEvent::ReadFromTree() Reading old Tree"); |
1341 | AliInfo("Branch already connected. Using existing branch address."); | |
1bd10080 | 1342 | fESDOld = (AliESD*) (*address); |
0eb6eb59 | 1343 | // addressF can still be 0, since branch needs to switched on |
1344 | if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF); | |
6989bff3 | 1345 | } |
0eb6eb59 | 1346 | |
6989bff3 | 1347 | // have already connected the old ESD structure... ? |
1348 | // reuse also the pointer of the AlliESDEvent | |
1349 | // otherwise create new ones | |
6989bff3 | 1350 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
1351 | ||
1352 | if(connectedList){ | |
1353 | // If connected use the connected list of objects | |
0eb6eb59 | 1354 | if(fESDObjects!= connectedList){ |
1355 | // protect when called twice | |
1356 | fESDObjects->Delete(); | |
1357 | fESDObjects = connectedList; | |
1358 | } | |
6989bff3 | 1359 | GetStdContent(); |
0eb6eb59 | 1360 | |
0eb6eb59 | 1361 | |
d7749dec | 1362 | // The pointer to the friend changes when called twice via InitIO |
1363 | // since AliESDEvent is deleted | |
0eb6eb59 | 1364 | TObject* oldf = FindListObject("AliESDfriend"); |
1365 | TObject* newf = 0; | |
1366 | if(addressF){ | |
1367 | newf = (TObject*)*addressF; | |
1368 | } | |
1369 | if(newf!=0&&oldf!=newf){ | |
1370 | // remove the old reference | |
1371 | // Should we also delete it? Or is this handled in TTree I/O | |
1372 | // since it is created by the first SetBranchAddress | |
1373 | fESDObjects->Remove(oldf); | |
1374 | // add the new one | |
1375 | fESDObjects->Add(newf); | |
1376 | } | |
1377 | ||
6989bff3 | 1378 | fConnected = true; |
b93c2026 | 1379 | return; |
6989bff3 | 1380 | } |
1381 | // else... | |
1382 | CreateStdContent(); // create for copy | |
0eb6eb59 | 1383 | // if we have the esdfriend add it, so we always can access it via the userinfo |
1384 | if(fESDFriendOld)AddObject(fESDFriendOld); | |
6989bff3 | 1385 | // we are not owner of the list objects |
1386 | // must not delete it | |
efea3f54 | 1387 | fESDObjects->SetOwner(kTRUE); |
6989bff3 | 1388 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
1389 | tree->GetUserInfo()->Add(fESDObjects); | |
1390 | fConnected = true; | |
1391 | return; | |
af885e0f | 1392 | } |
0eb6eb59 | 1393 | |
732a24fe | 1394 | |
1395 | delete fESDOld; | |
1396 | fESDOld = 0; | |
af885e0f | 1397 | // Try to find AliESDEvent |
1398 | AliESDEvent *esdEvent = 0; | |
1399 | esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent"); | |
001b9beb | 1400 | if(esdEvent){ |
941603c0 | 1401 | // Check if already connected to tree |
efea3f54 | 1402 | esdEvent->Reset(); |
139f2194 | 1403 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
f7ec3414 | 1404 | |
1405 | ||
1406 | if (connectedList && (strcmp(opt, "reconnect"))) { | |
139f2194 | 1407 | // If connected use the connected list if objects |
1408 | fESDObjects->Delete(); | |
b5bc83df | 1409 | fESDObjects = connectedList; |
1410 | GetStdContent(); | |
60e8f114 | 1411 | fConnected = true; |
139f2194 | 1412 | return; |
1413 | } | |
732a24fe | 1414 | |
139f2194 | 1415 | // Connect to tree |
001b9beb | 1416 | // prevent a memory leak when reading back the TList |
28a79204 | 1417 | // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete(); |
f7ec3414 | 1418 | |
a2fbb067 | 1419 | if(!fUseOwnList){ |
a2fbb067 | 1420 | // create a new TList from the UserInfo TList... |
1421 | // copy constructor does not work... | |
1422 | fESDObjects = (TList*)(esdEvent->GetList()->Clone()); | |
efea3f54 | 1423 | fESDObjects->SetOwner(kTRUE); |
a2fbb067 | 1424 | } |
1425 | else if ( fESDObjects->GetEntries()==0){ | |
1426 | // at least create the std content if we want to read to our list | |
1427 | CreateStdContent(); | |
1428 | } | |
732a24fe | 1429 | |
1430 | // in principle | |
1431 | // we only need new things in the list if we do no already have it.. | |
1432 | // TODO just add new entries | |
1433 | ||
af885e0f | 1434 | if(fESDObjects->GetEntries()<kESDListN){ |
90e88950 | 1435 | AliWarning(Form("AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", |
1436 | fESDObjects->GetEntries(),kESDListN)); | |
af885e0f | 1437 | } |
1438 | // set the branch addresses | |
1439 | TIter next(fESDObjects); | |
1440 | TNamed *el; | |
1441 | while((el=(TNamed*)next())){ | |
1442 | TString bname(el->GetName()); | |
af885e0f | 1443 | if(bname.CompareTo("AliESDfriend")==0) |
1444 | { | |
1445 | // AliESDfriend does not have a name ... | |
4453d900 | 1446 | TBranch *br = tree->GetBranch("ESDfriend."); |
588195ca | 1447 | if (br) tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el)); |
af885e0f | 1448 | } |
1449 | else{ | |
38f940fb | 1450 | // check if branch exists under this Name |
1451 | TBranch *br = tree->GetBranch(bname.Data()); | |
1452 | if(br){ | |
1453 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1454 | } | |
1455 | else{ | |
1456 | br = tree->GetBranch(Form("%s.",bname.Data())); | |
1457 | if(br){ | |
1458 | tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el)); | |
1459 | } | |
1460 | else{ | |
90e88950 | 1461 | AliWarning(Form("AliESDEvent::ReadFromTree() No Branch found with Name %s or %s.",bname.Data(),bname.Data())); |
38f940fb | 1462 | } |
1463 | ||
1464 | } | |
af885e0f | 1465 | } |
1466 | } | |
1467 | GetStdContent(); | |
1468 | // when reading back we are not owner of the list | |
1469 | // must not delete it | |
efea3f54 | 1470 | fESDObjects->SetOwner(kTRUE); |
60e8f114 | 1471 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
139f2194 | 1472 | // we are not owner of the list objects |
1473 | // must not delete it | |
60e8f114 | 1474 | tree->GetUserInfo()->Add(fESDObjects); |
efea3f54 | 1475 | tree->GetUserInfo()->SetOwner(kFALSE); |
60e8f114 | 1476 | fConnected = true; |
efea3f54 | 1477 | }// no esdEvent --> |
af885e0f | 1478 | else { |
001b9beb | 1479 | // we can't get the list from the user data, create standard content |
1480 | // and set it by hand (no ESDfriend at the moment | |
af885e0f | 1481 | CreateStdContent(); |
1482 | TIter next(fESDObjects); | |
1483 | TNamed *el; | |
1484 | while((el=(TNamed*)next())){ | |
1485 | TString bname(el->GetName()); | |
732a24fe | 1486 | TBranch *br = tree->GetBranch(bname.Data()); |
1487 | if(br){ | |
1488 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1489 | } | |
1490 | else{ | |
1491 | br = tree->GetBranch(Form("%s.",bname.Data())); | |
1492 | if(br){ | |
1493 | tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el)); | |
1494 | } | |
1495 | } | |
af885e0f | 1496 | } |
1497 | GetStdContent(); | |
1498 | // when reading back we are not owner of the list | |
1499 | // must not delete it | |
316cf4cc | 1500 | fESDObjects->SetOwner(kTRUE); |
af885e0f | 1501 | } |
af885e0f | 1502 | } |
1503 | ||
1504 | ||
1505 | void AliESDEvent::CopyFromOldESD() | |
1506 | { | |
1507 | // Method which copies over everthing from the old esd structure to the | |
1508 | // new | |
af885e0f | 1509 | if(fESDOld){ |
1510 | ResetStdContent(); | |
1511 | // Run | |
1512 | SetRunNumber(fESDOld->GetRunNumber()); | |
1513 | SetPeriodNumber(fESDOld->GetPeriodNumber()); | |
6ca8842a | 1514 | SetMagneticField(fESDOld->GetMagneticField()); |
af885e0f | 1515 | |
1516 | // leave out diamond ... | |
1517 | // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);} | |
1518 | ||
1519 | // header | |
1520 | SetTriggerMask(fESDOld->GetTriggerMask()); | |
1521 | SetOrbitNumber(fESDOld->GetOrbitNumber()); | |
1522 | SetTimeStamp(fESDOld->GetTimeStamp()); | |
1523 | SetEventType(fESDOld->GetEventType()); | |
1524 | SetEventNumberInFile(fESDOld->GetEventNumberInFile()); | |
1525 | SetBunchCrossNumber(fESDOld->GetBunchCrossNumber()); | |
1526 | SetTriggerCluster(fESDOld->GetTriggerCluster()); | |
1527 | ||
1528 | // ZDC | |
1529 | ||
1530 | SetZDC(fESDOld->GetZDCN1Energy(), | |
a85132e7 | 1531 | fESDOld->GetZDCP1Energy(), |
1532 | fESDOld->GetZDCEMEnergy(), | |
1533 | 0, | |
1534 | fESDOld->GetZDCN2Energy(), | |
1535 | fESDOld->GetZDCP2Energy(), | |
2b6cdc43 | 1536 | fESDOld->GetZDCParticipants(), |
5f0ec064 | 1537 | 0, |
1538 | 0, | |
1539 | 0, | |
1540 | 0, | |
1541 | 0, | |
2b6cdc43 | 1542 | 0); |
af885e0f | 1543 | |
1544 | // FMD | |
1545 | ||
cb6aa27f | 1546 | if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData()); |
af885e0f | 1547 | |
1548 | // T0 | |
1549 | ||
1550 | SetT0zVertex(fESDOld->GetT0zVertex()); | |
1551 | SetT0(fESDOld->GetT0()); | |
1552 | // leave amps out | |
1553 | ||
1554 | // VZERO | |
c06eaba2 | 1555 | if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData()); |
af885e0f | 1556 | |
06cc9d95 | 1557 | if(fESDOld->GetVertex())SetPrimaryVertexSPD(fESDOld->GetVertex()); |
af885e0f | 1558 | |
c264b61b | 1559 | if(fESDOld->GetPrimaryVertex())SetPrimaryVertexTracks(fESDOld->GetPrimaryVertex()); |
af885e0f | 1560 | |
cb6aa27f | 1561 | if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity()); |
1bd10080 | 1562 | |
af885e0f | 1563 | for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){ |
1564 | AddTrack(fESDOld->GetTrack(i)); | |
1565 | } | |
1566 | ||
1567 | for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){ | |
1568 | AddMuonTrack(fESDOld->GetMuonTrack(i)); | |
1569 | } | |
1570 | ||
1571 | for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){ | |
1572 | AddPmdTrack(fESDOld->GetPmdTrack(i)); | |
1573 | } | |
1574 | ||
1575 | for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){ | |
1576 | AddTrdTrack(fESDOld->GetTrdTrack(i)); | |
1577 | } | |
1578 | ||
1579 | for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){ | |
1580 | AddV0(fESDOld->GetV0(i)); | |
1581 | } | |
1582 | ||
1583 | for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){ | |
1584 | AddCascade(fESDOld->GetCascade(i)); | |
1585 | } | |
1586 | ||
1587 | for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){ | |
1588 | AddKink(fESDOld->GetKink(i)); | |
1589 | } | |
1590 | ||
1591 | ||
1592 | for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){ | |
1593 | AddCaloCluster(fESDOld->GetCaloCluster(i)); | |
1594 | } | |
1bd10080 | 1595 | |
af885e0f | 1596 | }// if fesdold |
1597 | } | |
1598 | ||
2a3dfb14 | 1599 | Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const |
1600 | { | |
1601 | // Check if the event satisfies the trigger | |
1602 | // selection expression trigExpr. | |
1603 | // trigExpr can be any logical expression | |
1604 | // of the trigger classes defined in AliESDRun | |
1605 | // In case of wrong syntax return kTRUE. | |
1606 | ||
1607 | TString expr(trigExpr); | |
1608 | if (expr.IsNull()) return kTRUE; | |
1609 | ||
1610 | ULong64_t mask = GetTriggerMask(); | |
1611 | for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses; itrig++) { | |
1612 | if (mask & (1ull << itrig)) { | |
1613 | expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1"); | |
1614 | } | |
1615 | else { | |
1616 | expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0"); | |
1617 | } | |
1618 | } | |
1619 | ||
1620 | Int_t error; | |
1621 | if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) && | |
1622 | (error == TInterpreter::kNoError)) { | |
1623 | return kFALSE; | |
1624 | } | |
1625 | ||
1626 | return kTRUE; | |
1627 | ||
1628 | } | |
1629 | ||
3b286f80 | 1630 | TObject* AliESDEvent::GetHLTTriggerDecision() const |
1631 | { | |
1632 | // get the HLT trigger decission object | |
1633 | ||
1634 | // cast away const'nes because the FindListObject method | |
1635 | // is not const | |
1636 | AliESDEvent* pNonConst=const_cast<AliESDEvent*>(this); | |
1637 | return pNonConst->FindListObject("HLTGlobalTrigger"); | |
1638 | } | |
1639 | ||
1640 | TString AliESDEvent::GetHLTTriggerDescription() const | |
1641 | { | |
1642 | // get the HLT trigger decission description | |
1643 | TString description; | |
1644 | TObject* pDecision=GetHLTTriggerDecision(); | |
1645 | if (pDecision) { | |
1646 | description=pDecision->GetTitle(); | |
1647 | } | |
1648 | ||
1649 | return description; | |
1650 | } | |
1651 | ||
1652 | Bool_t AliESDEvent::IsHLTTriggerFired(const char* name) const | |
1653 | { | |
1654 | // get the HLT trigger decission description | |
1655 | TObject* pDecision=GetHLTTriggerDecision(); | |
1656 | if (!pDecision) return kFALSE; | |
1657 | ||
1658 | Option_t* option=pDecision->GetOption(); | |
1659 | if (option==NULL || *option!='1') return kFALSE; | |
1660 | ||
1661 | if (name) { | |
1662 | TString description=GetHLTTriggerDescription(); | |
1663 | Int_t index=description.Index(name); | |
1664 | if (index<0) return kFALSE; | |
1665 | index+=strlen(name); | |
1666 | if (index>=description.Length()) return kFALSE; | |
1667 | if (description[index]!=0 && description[index]!=' ') return kFALSE; | |
1668 | } | |
1669 | return kTRUE; | |
1670 | } | |
af885e0f | 1671 | |
a98c78e5 | 1672 | //______________________________________________________________________________ |
1673 | Bool_t AliESDEvent::IsPileupFromSPD(Int_t minContributors, | |
1674 | Double_t minZdist, | |
1675 | Double_t nSigmaZdist, | |
1676 | Double_t nSigmaDiamXY, | |
1677 | Double_t nSigmaDiamZ) const{ | |
e741cb7c | 1678 | // |
1679 | // This function checks if there was a pile up | |
1680 | // reconstructed with SPD | |
1681 | // | |
e741cb7c | 1682 | Int_t nc1=fSPDVertex->GetNContributors(); |
1683 | if(nc1<1) return kFALSE; | |
1684 | Int_t nPileVert=GetNumberOfPileupVerticesSPD(); | |
1685 | if(nPileVert==0) return kFALSE; | |
a98c78e5 | 1686 | |
e741cb7c | 1687 | for(Int_t i=0; i<nPileVert;i++){ |
1688 | const AliESDVertex* pv=GetPileupVertexSPD(i); | |
e741cb7c | 1689 | Int_t nc2=pv->GetNContributors(); |
a98c78e5 | 1690 | if(nc2>=minContributors){ |
1691 | Double_t z1=fSPDVertex->GetZ(); | |
1692 | Double_t z2=pv->GetZ(); | |
1693 | Double_t distZ=TMath::Abs(z2-z1); | |
1694 | Double_t distZdiam=TMath::Abs(z2-GetDiamondZ()); | |
569d954c | 1695 | Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ()); |
a98c78e5 | 1696 | if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information |
1697 | if(distZ>minZdist && distZdiam<cutZdiam){ | |
1698 | Double_t x2=pv->GetX(); | |
1699 | Double_t y2=pv->GetY(); | |
1700 | Double_t distXdiam=TMath::Abs(x2-GetDiamondX()); | |
1701 | Double_t distYdiam=TMath::Abs(y2-GetDiamondY()); | |
1702 | Double_t cov1[6],cov2[6]; | |
1703 | fSPDVertex->GetCovarianceMatrix(cov1); | |
1704 | pv->GetCovarianceMatrix(cov2); | |
1705 | Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX()); | |
1706 | Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY()); | |
1707 | Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]); | |
1708 | Double_t cutXdiam=nSigmaDiamXY*errxDist; | |
1709 | if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information | |
1710 | Double_t cutYdiam=nSigmaDiamXY*erryDist; | |
1711 | if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information | |
1712 | if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){ | |
1713 | return kTRUE; | |
1714 | } | |
1715 | } | |
e741cb7c | 1716 | } |
e741cb7c | 1717 | } |
a98c78e5 | 1718 | return kFALSE; |
1719 | } | |
e741cb7c | 1720 | |
4ace6760 | 1721 | //______________________________________________________________________________ |
1722 | void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta, Bool_t useDCAFlag,Bool_t useV0Flag) const | |
1723 | { | |
1724 | // | |
1725 | // calculates 3 estimators for the multiplicity in the -eta:eta range | |
1726 | // tracklets : using SPD tracklets only | |
1727 | // trITSTPC : using TPC/ITS + complementary ITS SA tracks + tracklets from clusters not used by tracks | |
1728 | // trITSSApure : using ITS standalone tracks + tracklets from clusters not used by tracks | |
1729 | // if useDCAFlag is true: account for the ESDtrack flag marking the tracks with large DCA | |
1730 | // if useV0Flag is true: account for the ESDtrack flag marking conversion and K0's V0s | |
1731 | tracklets = trITSSApure = trITSTPC = 0; | |
1732 | int ntr = fSPDMult ? fSPDMult->GetNumberOfTracklets() : 0; | |
1733 | // | |
1734 | // count tracklets | |
1735 | for (int itr=ntr;itr--;) { | |
1736 | if (TMath::Abs(fSPDMult->GetEta(itr))>eta) continue; | |
1737 | tracklets++; | |
1738 | if (fSPDMult->FreeClustersTracklet(itr,0)) trITSTPC++; // not used in ITS/TPC or ITS_SA track | |
1739 | if (fSPDMult->FreeClustersTracklet(itr,1)) trITSSApure++; // not used in ITS_SA_Pure track | |
1740 | } | |
1741 | // | |
1742 | // count real tracks | |
1743 | ntr = GetNumberOfTracks(); | |
1744 | for (int itr=ntr;itr--;) { | |
1745 | AliESDtrack *t = GetTrack(itr); | |
1746 | if (TMath::Abs(t->Eta())>eta) continue; | |
1747 | if (!t->IsOn(AliESDtrack::kITSin)) continue; | |
1748 | if (useDCAFlag && t->IsOn(AliESDtrack::kMultSec)) continue; | |
1749 | if (useV0Flag && t->IsOn(AliESDtrack::kMultInV0)) continue; | |
1750 | if (t->IsOn(AliESDtrack::kITSpureSA)) trITSSApure++; | |
1751 | else trITSTPC++; | |
1752 | } | |
1753 | // | |
1754 | } | |
b46ff4b0 | 1755 | |
1756 | Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const { | |
1757 | Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets(); | |
1758 | if(nTracklets<20) return IsPileupFromSPD(3,0.8); | |
1759 | else if(nTracklets<50) return IsPileupFromSPD(4,0.8); | |
1760 | else return IsPileupFromSPD(5,0.8); | |
1761 | } | |
1762 | ||
f858b00e | 1763 | void AliESDEvent::SetTOFHeader(const AliTOFHeader *header) |
1764 | { | |
1765 | // | |
1766 | // Set the TOF event_time | |
1767 | // | |
1768 | ||
1769 | if (fTOFHeader) { | |
1770 | *fTOFHeader=*header; | |
1771 | //fTOFHeader->SetName(fgkESDListName[kTOFHeader]); | |
1772 | } | |
1773 | else { | |
1774 | // for analysis of reconstructed events | |
1775 | // when this information is not avaliable | |
1776 | fTOFHeader = new AliTOFHeader(*header); | |
1777 | //AddObject(fTOFHeader); | |
1778 | } | |
1779 | ||
1780 | } | |
cb62947d | 1781 | |
fba4b2e2 | 1782 | AliCentrality* AliESDEvent::GetCentrality() |
cb62947d | 1783 | { |
fba4b2e2 | 1784 | if (!fCentrality) fCentrality = new AliCentrality(); |
cb62947d | 1785 | return fCentrality; |
1786 | } | |
ce7adfe9 | 1787 | |
1788 | AliEventplane* AliESDEvent::GetEventplane() | |
1789 | { | |
1790 | if (!fEventplane) fEventplane = new AliEventplane(); | |
1791 | return fEventplane; | |
1792 | } |