]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
5a5a1232 | 3 | |
d810d0de | 4 | /************************************************************************** |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
9 | ||
b09247a2 | 10 | #include <memory> |
d810d0de | 11 | #include "AliEveVSDCreator.h" |
5a5a1232 | 12 | |
8cc1d3b4 | 13 | #include "AliEveEventManager.h" |
14 | ||
5a5a1232 | 15 | #include <AliStack.h> |
16 | #include <AliITSLoader.h> | |
17 | #include <AliTPCTrackHitsV2.h> | |
18 | #include <AliPDG.h> | |
19 | #include <AliHit.h> | |
22aefef8 | 20 | #include <AliESDEvent.h> |
d6a49f20 | 21 | #include <AliESDv0.h> |
5a5a1232 | 22 | #include <AliTPCclusterMI.h> |
23 | #include <AliTPCClustersRow.h> | |
5a5a1232 | 24 | #include <AliITSclusterV2.h> |
5a5a1232 | 25 | #include <AliESDkink.h> |
82e1eece | 26 | #include <AliESDtrack.h> |
5a5a1232 | 27 | |
28 | #include <AliRun.h> | |
a15e6d7d | 29 | #include <AliRunLoader.h> |
5a5a1232 | 30 | #include <AliTPCParam.h> |
31 | ||
c180f65d | 32 | #include <TDatabasePDG.h> |
5a5a1232 | 33 | #include <TSystem.h> |
34 | #include <TFile.h> | |
35 | ||
57ffa5fb | 36 | //______________________________________________________________________________ |
5a5a1232 | 37 | // |
73c1c0ec | 38 | // Create VSD file from ALICE data. |
5a5a1232 | 39 | |
d810d0de | 40 | ClassImp(AliEveVSDCreator) |
5a5a1232 | 41 | |
d810d0de | 42 | AliEveVSDCreator::AliEveVSDCreator(const Text_t* name, const Text_t* title) : |
84aff7a4 | 43 | TEveVSD(name, title), |
265ecb21 | 44 | |
73c1c0ec | 45 | fTPCHitRes (2), |
46 | fTRDHitRes (2), | |
5a5a1232 | 47 | |
73c1c0ec | 48 | fDebugLevel (0), |
49 | fRunLoader (0), | |
50 | fGenInfoMap () | |
265ecb21 | 51 | { |
73c1c0ec | 52 | // Constructor. |
53 | ||
5a5a1232 | 54 | // Particles not in ROOT's PDG database occuring in ALICE |
55 | AliPDG::AddParticlesToPdgDataBase(); | |
56 | { | |
57 | TDatabasePDG *pdgDB = TDatabasePDG::Instance(); | |
58 | // const Int_t kspe=50000000; | |
59 | const Int_t kion=10000000; | |
60 | ||
61 | const Double_t kAu2Gev=0.9314943228; | |
62 | const Double_t khSlash = 1.0545726663e-27; | |
63 | const Double_t kErg2Gev = 1/1.6021773349e-3; | |
64 | const Double_t khShGev = khSlash*kErg2Gev; | |
65 | const Double_t kYear2Sec = 3600*24*365.25; | |
66 | ||
67 | pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE, | |
68 | 0,1,"Ion",kion+10020); | |
69 | pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE, | |
70 | khShGev/(12.33*kYear2Sec),1,"Ion",kion+10030); | |
71 | pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE, | |
72 | khShGev/(12.33*kYear2Sec),2,"Ion",kion+20040); | |
73 | pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE, | |
74 | 0,2,"Ion",kion+20030); | |
75 | } | |
76 | ||
51346b82 | 77 | // AliKalmanTrack::SetConvConst(1); |
5a5a1232 | 78 | } |
79 | ||
57ffa5fb | 80 | /******************************************************************************/ |
5a5a1232 | 81 | |
8cc1d3b4 | 82 | void AliEveVSDCreator::CreateVSD(const Text_t* vsdFile) |
5a5a1232 | 83 | { |
8cc1d3b4 | 84 | // Create the VSD for current event in AliEveEventManager. |
73c1c0ec | 85 | // Result is stored in vsdFile. |
86 | // | |
87 | // Needs to be extended to support conversion of multiple events. | |
88 | ||
a15e6d7d | 89 | static const TEveException kEH("AliEveVSDCreator::CreateVSD "); |
5a5a1232 | 90 | |
8cc1d3b4 | 91 | fRunLoader = AliEveEventManager::AssertRunLoader(); |
5a5a1232 | 92 | |
73c1c0ec | 93 | if(fDebugLevel > 0) |
a15e6d7d | 94 | printf("%s open seems ok. Now loading sim data.\n", kEH.Data()); |
5a5a1232 | 95 | |
73c1c0ec | 96 | fRunLoader->LoadHeader(); |
97 | fRunLoader->LoadKinematics(); | |
98 | fRunLoader->LoadTrackRefs(); | |
99 | fRunLoader->LoadHits(); | |
5a5a1232 | 100 | |
101 | // GledNS::PushFD(); | |
102 | ||
73c1c0ec | 103 | if(fDebugLevel > 0) |
a15e6d7d | 104 | printf("%s opening output TEveVSD.\n", kEH.Data()); |
5a5a1232 | 105 | |
8cc1d3b4 | 106 | TFile* file = TFile::Open(vsdFile, "RECREATE", "ALICE Visualization Summary Data"); |
84aff7a4 | 107 | fDirectory = new TDirectoryFile("Event0", ""); |
5a5a1232 | 108 | |
73c1c0ec | 109 | if(fDebugLevel > 0) |
a15e6d7d | 110 | printf("%s creating trees now ...\n", kEH.Data()); |
5a5a1232 | 111 | |
112 | CreateTrees(); | |
113 | ||
73c1c0ec | 114 | if(fDebugLevel > 0) |
a15e6d7d | 115 | printf("%s trees created, closing files.\n", kEH.Data()); |
5a5a1232 | 116 | |
c1d0d915 | 117 | file->Write(); |
5a5a1232 | 118 | file->Close(); |
51346b82 | 119 | delete file; |
84aff7a4 | 120 | fDirectory =0; |
5a5a1232 | 121 | |
122 | //GledNS::PopFD(); | |
123 | ||
84aff7a4 | 124 | // clean after the TEveVSD data was sucessfuly written |
125 | fTreeK = 0; | |
126 | fTreeH = 0; | |
127 | //fTreeTR = 0; | |
128 | fTreeC = 0; | |
129 | fTreeV0 = 0; | |
130 | fTreeKK = 0; | |
131 | fTreeR = 0; | |
132 | fTreeGI = 0; | |
5a5a1232 | 133 | |
73c1c0ec | 134 | fRunLoader = 0; |
5a5a1232 | 135 | |
73c1c0ec | 136 | if(fDebugLevel > 0) |
a15e6d7d | 137 | printf("%s all done.\n", kEH.Data()); |
5a5a1232 | 138 | } |
139 | ||
d810d0de | 140 | void AliEveVSDCreator::CreateTrees() |
5a5a1232 | 141 | { |
73c1c0ec | 142 | // Create and fill the output trees by calling all the |
143 | // ConvertXyzz() functions. | |
144 | // Exceptions from individual functions are displayed as warnings. | |
145 | ||
a15e6d7d | 146 | static const TEveException kEH("AliEveVSDCreator::CreateTrees "); |
5a5a1232 | 147 | |
73c1c0ec | 148 | if (fDirectory == 0) |
a15e6d7d | 149 | throw(kEH + "output directory not set."); |
5a5a1232 | 150 | |
151 | try { | |
73c1c0ec | 152 | if (fDebugLevel > 1) |
a15e6d7d | 153 | printf("%sConvertKinematics.\n", kEH.Data()); |
5a5a1232 | 154 | ConvertKinematics(); |
a15e6d7d | 155 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 156 | |
8cc1d3b4 | 157 | Warning(kEH, "Explicitly abandoning further conversion."); |
158 | return; | |
159 | ||
5a5a1232 | 160 | try { |
73c1c0ec | 161 | if (fDebugLevel > 1) |
a15e6d7d | 162 | printf("%sConvertHits.\n", kEH.Data()); |
5a5a1232 | 163 | ConvertHits(); |
a15e6d7d | 164 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 165 | |
166 | try { | |
73c1c0ec | 167 | if (fDebugLevel > 1) |
a15e6d7d | 168 | printf("%sConvertClusters.\n", kEH.Data()); |
5a5a1232 | 169 | ConvertClusters(); |
a15e6d7d | 170 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 171 | |
5a5a1232 | 172 | try { |
73c1c0ec | 173 | if (fDebugLevel > 1) |
a15e6d7d | 174 | printf("%sConvertRecTracks.\n", kEH.Data()); |
5a5a1232 | 175 | ConvertRecTracks(); |
84aff7a4 | 176 | } catch(TEveException& exc) { |
d810d0de | 177 | Warning(exc, "skipping AliEveV0 extraction."); |
5a5a1232 | 178 | goto end_esd_processing; |
179 | } | |
180 | ||
181 | try { | |
73c1c0ec | 182 | if (fDebugLevel > 1) |
a15e6d7d | 183 | printf("%sConvertV0.\n", kEH.Data()); |
5a5a1232 | 184 | ConvertV0(); |
a15e6d7d | 185 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 186 | |
187 | try { | |
73c1c0ec | 188 | if (fDebugLevel > 1) |
a15e6d7d | 189 | printf("%sConvertKinks.\n", kEH.Data()); |
5a5a1232 | 190 | ConvertKinks(); |
a15e6d7d | 191 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 192 | |
193 | end_esd_processing: | |
194 | ||
195 | try { | |
73c1c0ec | 196 | if (fDebugLevel > 1) |
a15e6d7d | 197 | printf("%sConvertGenInfo.\n", kEH.Data()); |
5a5a1232 | 198 | ConvertGenInfo(); |
a15e6d7d | 199 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 200 | |
5a5a1232 | 201 | return; |
202 | } | |
203 | ||
57ffa5fb | 204 | /******************************************************************************/ |
5a5a1232 | 205 | // Kinematics |
57ffa5fb | 206 | /******************************************************************************/ |
5a5a1232 | 207 | |
d810d0de | 208 | void AliEveVSDCreator::ConvertKinematics() |
5a5a1232 | 209 | { |
73c1c0ec | 210 | // Convert kinematics. |
211 | // Track references are not stored, they should be. | |
212 | ||
a15e6d7d | 213 | static const TEveException kEH("AliEveVSDCreator::ConvertKinematics "); |
5a5a1232 | 214 | |
51346b82 | 215 | if(fTreeK != 0) |
a15e6d7d | 216 | throw (kEH + "kinematics already converted"); |
5a5a1232 | 217 | |
73c1c0ec | 218 | AliStack* stack = fRunLoader->Stack(); |
5a5a1232 | 219 | if(stack == 0) |
a15e6d7d | 220 | throw(kEH + "stack is null."); |
5a5a1232 | 221 | |
84aff7a4 | 222 | fDirectory->cd(); |
223 | fTreeK = new TTree("Kinematics", "TParticles sorted by Label"); | |
51346b82 | 224 | |
5a5a1232 | 225 | Int_t nentries = stack->GetNtrack(); |
fd31e9de | 226 | std::vector<TEveMCTrack> vmc(nentries); |
5a5a1232 | 227 | for (Int_t idx=0; idx<nentries; idx++) { |
73c1c0ec | 228 | TParticle* tp = stack->Particle(idx); |
84aff7a4 | 229 | vmc[idx] = *tp; |
230 | vmc[idx].fLabel = idx; | |
5a5a1232 | 231 | } |
232 | ||
84aff7a4 | 233 | // read track refrences |
d810d0de | 234 | // functionality now in AliEveKineTools. |
84aff7a4 | 235 | /* |
73c1c0ec | 236 | TTree* fTreeTR = fRunLoader->TreeTR(); |
5a5a1232 | 237 | |
84aff7a4 | 238 | if(fTreeTR == 0) { |
a15e6d7d | 239 | Warning(kEH, "no TrackRefs; some data will not be available."); |
5a5a1232 | 240 | } else { |
241 | TClonesArray* RunArrayTR = 0; | |
84aff7a4 | 242 | fTreeTR->SetBranchAddress("AliRun", &RunArrayTR); |
5a5a1232 | 243 | |
84aff7a4 | 244 | Int_t nPrimaries = (Int_t) fTreeTR->GetEntries(); |
5a5a1232 | 245 | for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++) { |
84aff7a4 | 246 | // printf("T0 fTreeTR->GetEntry(%d) \n",iPrimPart); |
247 | fTreeTR->GetEntry(iPrimPart); | |
248 | // printf("END fTreeTR->GetEntry(%d) \n",iPrimPart); | |
51346b82 | 249 | |
5a5a1232 | 250 | for (Int_t iTrackRef = 0; iTrackRef < RunArrayTR->GetEntriesFast(); iTrackRef++) { |
51346b82 | 251 | AliTrackReference *trackRef = (AliTrackReference*)RunArrayTR->At(iTrackRef); |
5a5a1232 | 252 | Int_t track = trackRef->GetTrack(); |
51346b82 | 253 | if(track < nentries && track > 0){ |
254 | TEveMCTrack& mct = vmc[track]; | |
5a5a1232 | 255 | if(trackRef->TestBit(kNotDeleted)) { |
256 | mct.decayed = true; | |
257 | mct.t_decay = trackRef->GetTime(); | |
258 | mct.V_decay.x = trackRef->X(); | |
259 | mct.V_decay.y = trackRef->Y(); | |
260 | mct.V_decay.z = trackRef->Z(); | |
261 | mct.P_decay.x = trackRef->Px(); | |
262 | mct.P_decay.y = trackRef->Py(); | |
263 | mct.P_decay.z = trackRef->Pz(); | |
264 | if(TMath::Abs(mct.GetPdgCode()) == 11) | |
265 | mct.decayed = false; // a bug in TreeTR | |
266 | } | |
51346b82 | 267 | } |
5a5a1232 | 268 | } |
269 | } | |
270 | } | |
84aff7a4 | 271 | */ |
5a5a1232 | 272 | |
84aff7a4 | 273 | fTreeK->Branch("K", "TEveMCTrack", &fpK, fBuffSize); |
5a5a1232 | 274 | |
6242b962 | 275 | printf("sizeofvmc = %d\n", (Int_t) vmc.size()); |
fd31e9de | 276 | for(std::vector<TEveMCTrack>::iterator k=vmc.begin(); k!=vmc.end(); ++k) { |
84aff7a4 | 277 | TEveMCTrack& mct = *k; |
278 | fK = mct; | |
5a5a1232 | 279 | |
280 | TParticle* m = &mct; | |
84aff7a4 | 281 | Int_t mi = mct.fLabel; |
5a5a1232 | 282 | int cnt = 0; |
283 | while(m->GetMother(0) != -1) { | |
284 | if(cnt > 100) { | |
285 | printf("cnt %d mi=%d, mo=%d\n", cnt, mi, m->GetMother(0)); | |
286 | } | |
287 | mi = m->GetMother(0); | |
288 | m = &vmc[mi]; | |
289 | ++cnt; | |
290 | } | |
84aff7a4 | 291 | fK.fEvaLabel = mi; |
5a5a1232 | 292 | |
84aff7a4 | 293 | fTreeK->Fill(); |
5a5a1232 | 294 | } |
295 | ||
8cc1d3b4 | 296 | fTreeK->BuildIndex("fLabel"); |
5a5a1232 | 297 | } |
298 | ||
57ffa5fb | 299 | /******************************************************************************/ |
5a5a1232 | 300 | // Hits |
57ffa5fb | 301 | /******************************************************************************/ |
5a5a1232 | 302 | |
303 | namespace { | |
304 | ||
a15e6d7d | 305 | struct Detector_t |
5a5a1232 | 306 | { |
a15e6d7d | 307 | const char* fName; // Detector name. |
308 | const char* fHitbranch; // Name of branch containing hits. | |
309 | unsigned char fDetidx; // Index identifying the detector internally. | |
5a5a1232 | 310 | }; |
311 | ||
a15e6d7d | 312 | Detector_t fgDetectors[] = { |
5a5a1232 | 313 | { "ITS", "AliITShit", 0 }, |
314 | { "TPC", "AliTPCTrackHitsV2", 1 }, | |
315 | { "TRD", "AliTRDhit", 2 }, | |
316 | { "TOF", "AliTOFhit", 3 } | |
f4b3bbb7 | 317 | // { "HMPID", "AliHMPIDhit", 4 }, |
5a5a1232 | 318 | }; |
319 | ||
320 | } | |
321 | ||
57ffa5fb | 322 | /******************************************************************************/ |
5a5a1232 | 323 | |
d810d0de | 324 | void AliEveVSDCreator::ConvertHits() |
5a5a1232 | 325 | { |
73c1c0ec | 326 | // Convert MC hits. |
327 | // TPC hits are handled specially as they are compressed - only mayor | |
328 | // hits are stored | |
329 | ||
a15e6d7d | 330 | static const TEveException kEH("AliEveVSDCreator::ConvertHits "); |
5a5a1232 | 331 | |
73c1c0ec | 332 | if (fTreeH != 0) |
a15e6d7d | 333 | throw(kEH + "hits already converted."); |
5a5a1232 | 334 | |
84aff7a4 | 335 | fDirectory->cd(); |
336 | fTreeH = new TTree("Hits", "Combined detector hits."); | |
337 | fTreeH->Branch("H", "TEveHit", &fpH, fBuffSize); | |
51346b82 | 338 | |
fd31e9de | 339 | std::map<Int_t, Int_t> hmap; |
5a5a1232 | 340 | // parameters for ITS, TPC hits filtering |
341 | Float_t x,y,z, x1,y1,z1; | |
73c1c0ec | 342 | Float_t tpcSqrRes = fTPCHitRes*fTPCHitRes; |
343 | Float_t trdSqrRes = fTRDHitRes*fTRDHitRes; | |
5a5a1232 | 344 | |
345 | int l=0; | |
346 | // load hits from the rest of detectors | |
a15e6d7d | 347 | while (fgDetectors[l].fName != 0) |
73c1c0ec | 348 | { |
a15e6d7d | 349 | Detector_t& det = fgDetectors[l++]; |
5a5a1232 | 350 | |
a15e6d7d | 351 | switch(det.fDetidx) |
73c1c0ec | 352 | { |
353 | case 1: | |
354 | { | |
355 | Int_t count = 0; | |
a15e6d7d | 356 | TTree* treeh = fRunLoader->GetTreeH(det.fName, false); |
73c1c0ec | 357 | if(treeh == 0) { |
a15e6d7d | 358 | Warning(kEH, Form("no hits for %s.", det.fName)); |
73c1c0ec | 359 | continue; |
360 | } | |
361 | AliTPCTrackHitsV2 hv2, *hv2p = &hv2; | |
362 | treeh->SetBranchAddress("TPC2", &hv2p); | |
363 | Int_t np = treeh->GetEntries(); | |
364 | for (Int_t i = 0; i < np; ++i) | |
365 | { | |
366 | treeh->GetEntry(i); | |
367 | Int_t evaIdx = np -i -1; | |
368 | if (hv2.First() == 0) continue; | |
369 | x = y = z = 0; | |
370 | do { | |
371 | AliHit* ah = hv2.GetHit(); | |
372 | x1 = ah->X(); y1 = ah->Y(); z1 = ah->Z(); | |
373 | if ((x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1) > tpcSqrRes) | |
374 | { | |
a15e6d7d | 375 | fH.fDetId = det.fDetidx; |
73c1c0ec | 376 | fH.fSubdetId = 0; |
377 | fH.fLabel = ah->Track(); | |
378 | fH.fEvaLabel = evaIdx; | |
379 | fH.fV.fX = x1; fH.fV.fY = y1; fH.fV.fZ = z1; | |
380 | fTreeH->Fill(); | |
381 | hmap[fH.fLabel]++; | |
382 | x = x1; y = y1; z = z1; | |
383 | count++; | |
384 | } | |
385 | } while (hv2.Next()); | |
386 | } | |
387 | // printf("%d entries in TPChits \n",count); | |
388 | break; | |
5a5a1232 | 389 | } |
73c1c0ec | 390 | default: |
391 | { | |
a15e6d7d | 392 | TTree* treeh = fRunLoader->GetTreeH(det.fName, false); |
73c1c0ec | 393 | if (treeh == 0) { |
a15e6d7d | 394 | Warning(kEH, Form("no hits for %s.", det.fName)); |
73c1c0ec | 395 | continue; |
396 | } | |
a15e6d7d | 397 | TClonesArray *arr = new TClonesArray(det.fHitbranch); |
398 | treeh->SetBranchAddress(det.fName, &arr); | |
73c1c0ec | 399 | Int_t np = treeh->GetEntries(); |
400 | // in TreeH files hits are grouped in clones arrays | |
401 | // each eva particle has its own clone array | |
402 | for (Int_t i = 0; i < np; ++i) | |
403 | { | |
404 | treeh->GetEntry(i); | |
405 | Int_t evaIdx = np -i -1; | |
406 | Int_t nh=arr->GetEntriesFast(); | |
407 | x = y = z = 0; | |
408 | // printf("%d entry %d hits for primary %d \n", i, nh, evaIdx); | |
409 | for (Int_t j = 0; j < nh; ++j) | |
84aff7a4 | 410 | { |
73c1c0ec | 411 | AliHit* aliHit = (AliHit*)arr->UncheckedAt(j); |
a15e6d7d | 412 | fH.fDetId = det.fDetidx; |
84aff7a4 | 413 | fH.fSubdetId = 0; |
73c1c0ec | 414 | fH.fLabel = aliHit->GetTrack(); |
415 | fH.fEvaLabel = evaIdx; | |
416 | fH.fV.Set(aliHit->X(), aliHit->Y(), aliHit->Z()); | |
a15e6d7d | 417 | if (det.fDetidx == 2) |
73c1c0ec | 418 | { |
419 | x1=aliHit->X();y1=aliHit->Y();z1=aliHit->Z(); | |
420 | if ((x-x1)*(x-x1)+(y-y1)*(y-y1)+(z-z1)*(z-z1) < trdSqrRes) continue; | |
421 | x=x1; y=y1; z=z1; | |
422 | } | |
84aff7a4 | 423 | hmap[fH.fLabel]++; |
73c1c0ec | 424 | fTreeH->Fill(); |
51346b82 | 425 | } |
5a5a1232 | 426 | } |
73c1c0ec | 427 | delete arr; |
428 | break; | |
429 | } // end default | |
5a5a1232 | 430 | } // end switch |
431 | } // end while | |
51346b82 | 432 | |
5a5a1232 | 433 | |
434 | //set geninfo | |
73c1c0ec | 435 | for(std::map<Int_t, Int_t>::iterator j=hmap.begin(); j!=hmap.end(); ++j) |
436 | { | |
84aff7a4 | 437 | GetGeninfo(j->first)->fNHits += j->second; |
5a5a1232 | 438 | } |
5a5a1232 | 439 | } |
440 | ||
57ffa5fb | 441 | /******************************************************************************/ |
5a5a1232 | 442 | // Clusters |
57ffa5fb | 443 | /******************************************************************************/ |
5a5a1232 | 444 | |
d810d0de | 445 | void AliEveVSDCreator::ConvertClusters() |
5a5a1232 | 446 | { |
73c1c0ec | 447 | // Convert clusters. |
448 | // | |
449 | // Only supported for ITS and TPC at the moment, see dedicated | |
450 | // functions ConvertITSClusters() and ConvertTPCClusters(). | |
451 | // | |
452 | // It should be possible now to do this in a general manner (with | |
453 | // the alignment framework). | |
454 | ||
a15e6d7d | 455 | static const TEveException kEH("AliEveVSDCreator::ConvertClusters "); |
5a5a1232 | 456 | |
84aff7a4 | 457 | if(fTreeC != 0) |
a15e6d7d | 458 | throw(kEH + "clusters already converted."); |
5a5a1232 | 459 | |
84aff7a4 | 460 | fDirectory->cd(); |
461 | fTreeC = new TTree("Clusters", "rec clusters"); | |
462 | fTreeC->Branch("C", "TEveCluster", &fpC, fBuffSize); | |
5a5a1232 | 463 | |
464 | try { | |
465 | ConvertITSClusters(); | |
a15e6d7d | 466 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 467 | |
468 | try { | |
469 | ConvertTPCClusters(); | |
a15e6d7d | 470 | } catch(TEveException& exc) { Warning(kEH, exc); } |
5a5a1232 | 471 | } |
472 | ||
57ffa5fb | 473 | /******************************************************************************/ |
5a5a1232 | 474 | |
d810d0de | 475 | void AliEveVSDCreator::ConvertTPCClusters() |
5a5a1232 | 476 | { |
73c1c0ec | 477 | // Convert TPC clusters and transform them to global coordinates. |
478 | ||
a15e6d7d | 479 | static const TEveException kEH("AliEveVSDCreator::ConvertTPCClusters "); |
5a5a1232 | 480 | |
8cc1d3b4 | 481 | fRunLoader->LoadRecPoints("TPC"); |
482 | TTree* tree = fRunLoader->GetTreeR("TPC", false); | |
483 | if (!tree) | |
a15e6d7d | 484 | throw(kEH + "'TreeR' not found."); |
5a5a1232 | 485 | |
73c1c0ec | 486 | AliTPCClustersRow clrow, *clrowp = &clrow; |
5a5a1232 | 487 | AliTPCclusterMI *cl; |
73c1c0ec | 488 | clrow.SetClass("AliTPCclusterMI"); |
489 | tree->SetBranchAddress("Segment", &clrowp); | |
5a5a1232 | 490 | |
491 | // count clusters | |
492 | Int_t nClusters = 0; | |
73c1c0ec | 493 | Int_t nEnt = tree->GetEntries(); |
494 | for (Int_t n = 0; n < nEnt; ++n) | |
495 | { | |
5a5a1232 | 496 | tree->GetEntry(n); |
73c1c0ec | 497 | nClusters += clrow.GetArray()->GetEntriesFast(); |
5a5a1232 | 498 | } |
499 | ||
fd31e9de | 500 | std::map<Int_t, Int_t> cmap; |
5a5a1232 | 501 | |
73c1c0ec | 502 | for (Int_t n = 0; n < tree->GetEntries(); ++n) |
503 | { | |
5a5a1232 | 504 | tree->GetEntry(n); |
73c1c0ec | 505 | Int_t ncl = clrow.GetArray()->GetEntriesFast(); |
506 | if (ncl > 0) | |
507 | { | |
73c1c0ec | 508 | while (ncl--) |
509 | { | |
510 | if (clrow.GetArray()) | |
511 | { | |
512 | // cl = new AliTPCclusterMI(*(AliTPCclusterMI*)clrow.GetArray()->UncheckedAt(ncl)); | |
513 | cl = (AliTPCclusterMI*)clrow.GetArray()->UncheckedAt(ncl); | |
514 | if (cl->GetLabel(0) >= 0) | |
84aff7a4 | 515 | { |
8cc1d3b4 | 516 | Float_t g[3]; //global coordinates |
517 | cl->GetGlobalXYZ(g); | |
5a5a1232 | 518 | |
84aff7a4 | 519 | fC.fDetId = 1; |
8cc1d3b4 | 520 | fC.fSubdetId = clrow.GetID(); |
84aff7a4 | 521 | fC.fLabel[0] = cl->GetLabel(0); |
522 | fC.fLabel[1] = cl->GetLabel(1); | |
523 | fC.fLabel[2] = cl->GetLabel(2); | |
8cc1d3b4 | 524 | fC.fV.Set(g); |
84aff7a4 | 525 | |
526 | fTreeC->Fill(); | |
527 | { | |
528 | int i = 0; | |
73c1c0ec | 529 | while (i < 3 && fC.fLabel[i]) |
84aff7a4 | 530 | cmap[fC.fLabel[i++]]++; |
5a5a1232 | 531 | } |
532 | } | |
533 | } | |
534 | } | |
535 | } | |
536 | } | |
537 | //set geninfo | |
73c1c0ec | 538 | for (std::map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j) |
539 | { | |
84aff7a4 | 540 | GetGeninfo(j->first)->fNClus += j->second; |
5a5a1232 | 541 | } |
542 | } | |
543 | ||
57ffa5fb | 544 | /******************************************************************************/ |
5a5a1232 | 545 | |
d810d0de | 546 | void AliEveVSDCreator::ConvertITSClusters() |
5a5a1232 | 547 | { |
73c1c0ec | 548 | // Convert ITS clusters and transform them to global coordinates. |
549 | ||
a15e6d7d | 550 | static const TEveException kEH("AliEveVSDCreator::ConvertITSClusters "); |
5a5a1232 | 551 | |
8cc1d3b4 | 552 | fRunLoader->LoadRecPoints("ITS"); |
553 | TTree* tree = fRunLoader->GetTreeR("ITS", false); | |
554 | if (!tree) | |
a15e6d7d | 555 | throw(kEH + "'TreeR' not found."); |
5a5a1232 | 556 | |
73c1c0ec | 557 | // |
a15e6d7d | 558 | AliITSLoader *itsLd = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader"); |
559 | AliITSgeom *geom = itsLd->GetITSgeom(); | |
5a5a1232 | 560 | |
561 | //printf("alice ITS geom %p \n",geom ); | |
562 | ||
73c1c0ec | 563 | if (!geom) |
a15e6d7d | 564 | throw(kEH + "can not find ITS geometry"); |
5a5a1232 | 565 | |
566 | TClonesArray *arr = new TClonesArray("AliITSclusterV2"); | |
567 | tree->SetBranchAddress("Clusters", &arr); | |
568 | Int_t nmods = tree->GetEntries(); | |
569 | Float_t gc[3]; | |
fd31e9de | 570 | std::map<Int_t, Int_t> cmap; |
5a5a1232 | 571 | |
73c1c0ec | 572 | for (Int_t mod = 0; mod < nmods; ++mod) |
573 | { | |
5a5a1232 | 574 | tree->GetEntry(mod); |
575 | Int_t nc=arr->GetEntriesFast(); | |
73c1c0ec | 576 | for (Int_t j = 0; j < nc; ++j) |
577 | { | |
578 | AliITSclusterV2* recp = (AliITSclusterV2*) arr->UncheckedAt(j); | |
5a5a1232 | 579 | |
51346b82 | 580 | Double_t rot[9]; |
5a5a1232 | 581 | geom->GetRotMatrix(mod,rot); |
51346b82 | 582 | Int_t lay,lad,det; |
5a5a1232 | 583 | geom->GetModuleId(mod,lay,lad,det); |
51346b82 | 584 | Float_t tx,ty,tz; |
585 | geom->GetTrans(lay,lad,det,tx,ty,tz); | |
5a5a1232 | 586 | |
587 | Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); | |
588 | Double_t phi1=TMath::Pi()/2+alpha; | |
73c1c0ec | 589 | if (lay == 1) phi1+=TMath::Pi(); |
5a5a1232 | 590 | |
591 | Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1); | |
592 | Float_t r=tx*cp+ty*sp; | |
84aff7a4 | 593 | gc[0] = r*cp - recp->GetY()*sp; |
594 | gc[1] = r*sp + recp->GetY()*cp; | |
595 | gc[2] = recp->GetZ(); | |
596 | ||
597 | fC.fDetId = 0; | |
598 | fC.fSubdetId = 0; | |
599 | fC.fLabel[0] = recp->GetLabel(0); | |
600 | fC.fLabel[1] = recp->GetLabel(1); | |
601 | fC.fLabel[2] = recp->GetLabel(2); | |
602 | fC.fV.fX = r*cp - recp->GetY()*sp; | |
603 | fC.fV.fY = r*sp + recp->GetY()*cp; | |
604 | fC.fV.fZ = recp->GetZ(); | |
605 | fTreeC->Fill(); | |
5a5a1232 | 606 | { int i = 0; |
84aff7a4 | 607 | while(i < 3 && fC.fLabel[i]) |
608 | cmap[fC.fLabel[i++]]++; | |
5a5a1232 | 609 | } |
51346b82 | 610 | } |
5a5a1232 | 611 | |
73c1c0ec | 612 | for (std::map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j) |
613 | { | |
84aff7a4 | 614 | GetGeninfo(j->first)->fNClus += j->second; |
5a5a1232 | 615 | } |
616 | } | |
617 | delete arr; | |
618 | } | |
619 | ||
57ffa5fb | 620 | /******************************************************************************/ |
5a5a1232 | 621 | // ESD |
57ffa5fb | 622 | /******************************************************************************/ |
5a5a1232 | 623 | |
d810d0de | 624 | void AliEveVSDCreator::ConvertRecTracks() |
5a5a1232 | 625 | { |
73c1c0ec | 626 | // Convert reconstructed tracks. |
627 | ||
a15e6d7d | 628 | static const TEveException kEH("AliEveVSDCreator::ConvertRecTracks "); |
5a5a1232 | 629 | |
73c1c0ec | 630 | if (fTreeR != 0) |
a15e6d7d | 631 | throw(kEH + "tracks already converted."); |
5a5a1232 | 632 | |
8cc1d3b4 | 633 | AliESDEvent* esdEvent = AliEveEventManager::AssertESD(); |
634 | ||
84aff7a4 | 635 | fDirectory->cd(); |
636 | fTreeR = new TTree("RecTracks", "rec tracks"); | |
5a5a1232 | 637 | |
84aff7a4 | 638 | fTreeR->Branch("R", "TEveRecTrack", &fpR, 512*1024,1); |
51346b82 | 639 | |
5a5a1232 | 640 | // reconstructed tracks |
a15e6d7d | 641 | AliESDtrack* esdTrack; |
5a5a1232 | 642 | Double_t dbuf[3]; |
73c1c0ec | 643 | for (Int_t n = 0; n < esdEvent->GetNumberOfTracks(); ++n) |
644 | { | |
a15e6d7d | 645 | esdTrack = esdEvent->GetTrack(n); |
646 | ||
647 | fR.fLabel = esdTrack->GetLabel(); | |
648 | fR.fStatus = (Int_t) esdTrack->GetStatus(); | |
649 | fR.fSign = (Int_t) esdTrack->GetSign(); | |
650 | esdTrack->GetXYZ(dbuf); fR.fV.Set(dbuf); | |
651 | esdTrack->GetPxPyPz(dbuf); fR.fP.Set(dbuf); | |
652 | Double_t ep = esdTrack->GetP(); | |
653 | fR.fBeta = ep/TMath::Sqrt(ep*ep + TMath::C()*TMath::C()*esdTrack->GetMass()*esdTrack->GetMass()); | |
84aff7a4 | 654 | fTreeR->Fill(); |
5a5a1232 | 655 | } |
84aff7a4 | 656 | fTreeR->BuildIndex("label"); |
73c1c0ec | 657 | delete esdEvent; |
5a5a1232 | 658 | } |
659 | ||
57ffa5fb | 660 | /******************************************************************************/ |
5a5a1232 | 661 | |
d810d0de | 662 | void AliEveVSDCreator::ConvertV0() |
5a5a1232 | 663 | { |
73c1c0ec | 664 | // Convert reconstructed V0s. |
665 | ||
a15e6d7d | 666 | static const TEveException kEH("AliEveVSDCreator::ConvertV0 "); |
5a5a1232 | 667 | |
84aff7a4 | 668 | if(fTreeV0 != 0) |
a15e6d7d | 669 | throw(kEH + "AliEveV0 already converted."); |
5a5a1232 | 670 | |
8cc1d3b4 | 671 | AliESDEvent* esdEvent = AliEveEventManager::AssertESD(); |
672 | ||
84aff7a4 | 673 | fDirectory->cd(); |
d810d0de | 674 | fTreeV0 = new TTree("AliEveV0", "AliEveV0 points"); |
5a5a1232 | 675 | |
d810d0de | 676 | fTreeV0->Branch("AliEveV0", "TEveRecV0", &fpV0, 512*1024,1); |
5a5a1232 | 677 | |
73c1c0ec | 678 | for (Int_t n = 0; n < esdEvent->GetNumberOfV0s(); ++n) |
982f2494 | 679 | { |
73c1c0ec | 680 | AliESDv0 *av = esdEvent->GetV0(n); |
681 | AliESDtrack *trackN = esdEvent->GetTrack(av->GetNindex()); // negative daughter | |
682 | AliESDtrack *trackP = esdEvent->GetTrack(av->GetPindex()); // positive daughter | |
982f2494 | 683 | |
5a5a1232 | 684 | Double_t pos[3]; |
685 | ||
84aff7a4 | 686 | fV0.fStatus = av->GetStatus(); |
5a5a1232 | 687 | // Point of closest approach |
b75d63a7 | 688 | av->GetXYZ(pos[0],pos[1],pos[2]); |
51346b82 | 689 | fV0.fVCa.fX = pos[0]; |
84aff7a4 | 690 | fV0.fVCa.fY = pos[1]; |
691 | fV0.fVCa.fZ = pos[2]; | |
51346b82 | 692 | // set birth vertex of neutral particle |
b75d63a7 | 693 | av->GetXYZ(pos[0], pos[1], pos[2]); |
84aff7a4 | 694 | fV0.fV0Birth.Set(pos); |
5a5a1232 | 695 | |
696 | // momentum and position of negative particle | |
b75d63a7 | 697 | av->GetParamN()->GetPxPyPz(pos); |
84aff7a4 | 698 | fV0.fPNeg.Set(pos); |
b75d63a7 | 699 | av->GetParamN()->GetXYZ(pos); |
84aff7a4 | 700 | fV0.fVNeg.Set(pos); |
5a5a1232 | 701 | |
702 | // momentum and position of positive particle | |
b75d63a7 | 703 | av->GetParamP()->GetPxPyPz(pos); |
84aff7a4 | 704 | fV0.fPPos.Set(pos); |
5a5a1232 | 705 | av->GetParamP()->GetXYZ(pos); |
84aff7a4 | 706 | fV0.fVPos.Set(pos); |
5a5a1232 | 707 | |
84aff7a4 | 708 | fV0.fLabel = 0; // !!!! mother label unknown |
709 | fV0.fPdg = av->GetPdgCode(); | |
982f2494 | 710 | |
5a5a1232 | 711 | // daughter indices |
84aff7a4 | 712 | fV0.fDLabel[0] = TMath::Abs(trackN->GetLabel()); |
713 | fV0.fDLabel[1] = TMath::Abs(trackP->GetLabel()); | |
5a5a1232 | 714 | |
51346b82 | 715 | // printf("AliEveV0 convert labels(%d,%d) index(%d,%d)\n", |
84aff7a4 | 716 | // fV0.d_label[0], fV0.d_label[1], |
982f2494 | 717 | // av->GetNIndex(), av->GetPIndex()); |
5a5a1232 | 718 | |
84aff7a4 | 719 | fTreeV0->Fill(); |
5a5a1232 | 720 | } |
73c1c0ec | 721 | // if (esdEvent->GetNumberOfV0s()) fTreeV0->BuildIndex("label"); |
722 | delete esdEvent; | |
5a5a1232 | 723 | } |
724 | ||
57ffa5fb | 725 | /******************************************************************************/ |
5a5a1232 | 726 | |
d810d0de | 727 | void AliEveVSDCreator::ConvertKinks() |
5a5a1232 | 728 | { |
73c1c0ec | 729 | // Convert reconstructed kinks. |
730 | ||
a15e6d7d | 731 | static const TEveException kEH("AliEveVSDCreator::ConvertKinks "); |
5a5a1232 | 732 | |
73c1c0ec | 733 | if (fTreeKK != 0) |
a15e6d7d | 734 | throw(kEH + "Kinks already converted."); |
5a5a1232 | 735 | |
2626c85d | 736 | throw kEH + "Currently non-supported - TEveRecKink being updated."; |
737 | ||
738 | /* | |
8cc1d3b4 | 739 | AliESDEvent* esdEvent = AliEveEventManager::AssertESD(); |
740 | ||
84aff7a4 | 741 | fDirectory->cd(); |
742 | fTreeKK = new TTree("Kinks", "ESD Kinks"); | |
5a5a1232 | 743 | |
84aff7a4 | 744 | fTreeKK->Branch("KK", "TEveRecKink", &fpKK, fBuffSize); |
5a5a1232 | 745 | |
73c1c0ec | 746 | // printf("CONVERT KINK Read %d entries in tree kinks \n", esdEvent->GetNumberOfKinks()); |
747 | for (Int_t n = 0; n < esdEvent->GetNumberOfKinks(); ++n) | |
748 | { | |
749 | AliESDkink* kk = esdEvent->GetKink(n); | |
5a5a1232 | 750 | |
751 | Double_t pos[3]; | |
752 | ||
84aff7a4 | 753 | fKK.fLabel = kk->GetLabel(0); |
edaf814f | 754 | fKK.fStatus = 0; // status is Char_t[12] ... have no idea how/what to extract. |
5a5a1232 | 755 | |
756 | // reconstructed kink position | |
84aff7a4 | 757 | fKK.fLabelSec = kk->GetLabel(1); |
758 | fKK.fVKink.Set(kk->GetPosition()); | |
5a5a1232 | 759 | |
73c1c0ec | 760 | const AliExternalTrackParam& tpMother = kk->RefParamMother(); |
51346b82 | 761 | // momentum and position of mother |
73c1c0ec | 762 | tpMother.GetPxPyPz(pos); |
84aff7a4 | 763 | fKK.fP.Set(pos); |
73c1c0ec | 764 | tpMother.GetXYZ(pos); |
84aff7a4 | 765 | fKK.fV.Set(pos); |
73c1c0ec | 766 | const Double_t* par = tpMother.GetParameter(); |
767 | // printf("KINK Pt %f, %f \n",1/tpMother.Pt(),par[4] ); | |
84aff7a4 | 768 | fKK.fSign = (par[4] < 0) ? -1 : 1; |
51346b82 | 769 | |
73c1c0ec | 770 | const AliExternalTrackParam& tpDaughter = kk->RefParamDaughter(); |
51346b82 | 771 | // momentum and position of daughter |
73c1c0ec | 772 | tpDaughter.GetPxPyPz(pos); |
84aff7a4 | 773 | fKK.fPSec.Set(pos); |
73c1c0ec | 774 | tpDaughter.GetXYZ(pos); |
84aff7a4 | 775 | fKK.fVEnd.Set(pos); |
5a5a1232 | 776 | |
84aff7a4 | 777 | fTreeKK->Fill(); |
5a5a1232 | 778 | } |
73c1c0ec | 779 | if (esdEvent->GetNumberOfKinks()) fTreeKK->BuildIndex("label"); |
780 | delete esdEvent; | |
2626c85d | 781 | */ |
5a5a1232 | 782 | } |
57ffa5fb | 783 | /******************************************************************************/ |
84aff7a4 | 784 | // TEveMCRecCrossRef |
57ffa5fb | 785 | /******************************************************************************/ |
5a5a1232 | 786 | |
d810d0de | 787 | void AliEveVSDCreator::ConvertGenInfo() |
5a5a1232 | 788 | { |
73c1c0ec | 789 | // Build simulation-reconstruction cross-reference table. |
790 | // In a rather poor state at the moment. | |
791 | ||
a15e6d7d | 792 | static const TEveException kEH("AliEveVSDCreator::ConvertGenInfo "); |
5a5a1232 | 793 | |
84aff7a4 | 794 | if(fTreeGI != 0) |
a15e6d7d | 795 | throw(kEH + "GI already converted."); |
5a5a1232 | 796 | |
84aff7a4 | 797 | fDirectory->cd(); |
798 | fTreeGI = new TTree("TEveMCRecCrossRef", "Objects prepared for cross querry"); | |
5a5a1232 | 799 | |
84aff7a4 | 800 | TEveMCRecCrossRef::Class()->IgnoreTObjectStreamer(true); |
801 | fTreeGI->Branch("GI", "TEveMCRecCrossRef", &fpGI, fBuffSize); | |
802 | fTreeGI->Branch("K.", "TEveMCTrack", &fpK); | |
803 | fTreeGI->Branch("R.", "TEveRecTrack", &fpR); | |
5a5a1232 | 804 | |
73c1c0ec | 805 | for (std::map<Int_t, TEveMCRecCrossRef*>::iterator j=fGenInfoMap.begin(); j!=fGenInfoMap.end(); ++j) { |
84aff7a4 | 806 | fGI = *(j->second); |
807 | fGI.fLabel = j->first; | |
808 | fTreeK->GetEntry(j->first); | |
5a5a1232 | 809 | |
84aff7a4 | 810 | if (fTreeR) { |
811 | Int_t re = fTreeR->GetEntryNumberWithIndex(j->first); | |
51346b82 | 812 | if(re != -1) |
84aff7a4 | 813 | fGI.fIsRec = true; |
5a5a1232 | 814 | } |
73c1c0ec | 815 | // Int_t hasV0 = fTreeV0->GetEntryNumberWithIndex(j->first); |
816 | //if (hasV0 != -1) | |
d810d0de | 817 | // fGI.has_AliEveV0 = true; |
84aff7a4 | 818 | if (fTreeKK) { |
73c1c0ec | 819 | Int_t hasKk = fTreeKK->GetEntryNumberWithIndex(j->first); |
820 | if (hasKk != -1) | |
84aff7a4 | 821 | fGI.fHasKink = true; |
5a5a1232 | 822 | } |
84aff7a4 | 823 | fTreeGI->Fill(); |
5a5a1232 | 824 | } |
73c1c0ec | 825 | fGenInfoMap.clear(); |
5a5a1232 | 826 | } |
827 | ||
57ffa5fb | 828 | /******************************************************************************/ |
829 | /******************************************************************************/ | |
5a5a1232 | 830 | // Protected methods |
57ffa5fb | 831 | /******************************************************************************/ |
832 | /******************************************************************************/ | |
5a5a1232 | 833 | |
d810d0de | 834 | TEveMCRecCrossRef* AliEveVSDCreator::GetGeninfo(Int_t label) |
5a5a1232 | 835 | { |
73c1c0ec | 836 | // Return the cross-reference structure for given label. |
837 | // If the object does not exist it is created. | |
838 | ||
5a5a1232 | 839 | // printf("get_geninfo %d\n", label); |
84aff7a4 | 840 | TEveMCRecCrossRef* gi; |
73c1c0ec | 841 | std::map<Int_t, TEveMCRecCrossRef*>::iterator i = fGenInfoMap.find(label); |
842 | if (i == fGenInfoMap.end()) { | |
84aff7a4 | 843 | gi = new TEveMCRecCrossRef(); |
73c1c0ec | 844 | fGenInfoMap[label] = gi; |
5a5a1232 | 845 | } else { |
846 | gi = i->second; | |
847 | } | |
848 | return gi; | |
849 | } |