]>
Commit | Line | Data |
---|---|---|
a1069ee1 | 1 | /************************************************************************** |
2 | * Author: Panos Christakoglou. * | |
3 | * Contributors are mentioned in the code where appropriate. * | |
4 | * * | |
5 | * Permission to use, copy, modify and distribute this software and its * | |
6 | * documentation strictly for non-commercial purposes is hereby granted * | |
7 | * without fee, provided that the above copyright notice appears in all * | |
8 | * copies and that both the copyright notice and this permission notice * | |
9 | * appear in the supporting documentation. The authors make no claims * | |
10 | * about the suitability of this software for any purpose. It is * | |
11 | * provided "as is" without express or implied warranty. * | |
12 | **************************************************************************/ | |
13 | ||
14 | /* $Id$ */ | |
15 | ||
16 | //----------------------------------------------------------------- | |
17 | // AliAODTagCreator class | |
18 | // This is the class to deal with the tag creation (post process) | |
19 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
20 | //----------------------------------------------------------------- | |
21 | ||
22 | //ROOT | |
23 | #include <Riostream.h> | |
24 | #include <TFile.h> | |
25 | #include <TString.h> | |
26 | #include <TTree.h> | |
27 | #include <TSystem.h> | |
28 | #include <TChain.h> | |
29 | #include <TLorentzVector.h> | |
30 | ||
31 | //ROOT-AliEn | |
32 | #include <TGrid.h> | |
33 | #include <TGridResult.h> | |
34 | ||
35 | //AliRoot | |
36 | #include "AliRunTag.h" | |
37 | #include "AliEventTag.h" | |
38 | #include "AliPID.h" | |
a1069ee1 | 39 | #include "AliAODEvent.h" |
40 | #include "AliAODVertex.h" | |
41 | #include "AliLog.h" | |
42 | ||
43 | #include "AliAODTagCreator.h" | |
44 | ||
45 | ||
46 | ClassImp(AliAODTagCreator) | |
47 | ||
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliAODTagCreator::AliAODTagCreator() : | |
103d3fba | 51 | AliTagCreator(), fChain(new TChain("aodTree")) { |
a1069ee1 | 52 | //==============Default constructor for a AliAODTagCreator================ |
53 | } | |
54 | ||
55 | //______________________________________________________________________________ | |
56 | AliAODTagCreator::~AliAODTagCreator() { | |
57 | //================Default destructor for a AliAODTagCreator=================== | |
103d3fba | 58 | delete fChain; |
a1069ee1 | 59 | } |
60 | ||
61 | //______________________________________________________________________________ | |
62 | Bool_t AliAODTagCreator::ReadGridCollection(TGridResult *fresult) { | |
63 | // Reads the entry of the TGridResult and creates the tags | |
64 | Int_t nEntries = fresult->GetEntries(); | |
65 | ||
103d3fba | 66 | TString alienUrl; |
67 | const char* guid; | |
68 | const char* md5; | |
69 | const char* turl; | |
70 | Long64_t size = -1; | |
71 | ||
72 | Int_t counter = 0; | |
73 | for(Int_t i = 0; i < nEntries; i++) { | |
74 | alienUrl = fresult->GetKey(i,"turl"); | |
75 | guid = fresult->GetKey(i,"guid"); | |
76 | if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size")); | |
77 | md5 = fresult->GetKey(i,"md5"); | |
78 | turl = fresult->GetKey(i,"turl"); | |
79 | if(md5 && !strlen(guid)) md5 = 0; | |
80 | if(guid && !strlen(guid)) guid = 0; | |
81 | ||
82 | fChain->Add(alienUrl); | |
83 | //fGUIDList->Add(new TObjString(guid)); | |
84 | //fMD5List->Add(new TObjString(md5)); | |
85 | //fTURLList->Add(new TObjString(turl)); | |
86 | ||
87 | //TFile *f = TFile::Open(alienUrl,"READ"); | |
88 | //CreateTag(f,guid,md5,turl,size,counter); | |
89 | //f->Close(); | |
90 | //delete f; | |
91 | counter += 1; | |
92 | }//grid result loop | |
93 | ||
94 | AliInfo(Form("AOD chain created.......")); | |
95 | AliInfo(Form("Chain entries: %d",fChain->GetEntries())); | |
96 | CreateTag(fChain,"grid"); | |
97 | ||
98 | return kTRUE; | |
99 | } | |
100 | ||
a1069ee1 | 101 | //______________________________________________________________________________ |
102 | Bool_t AliAODTagCreator::ReadLocalCollection(const char *localpath) { | |
103d3fba | 103 | // Checks the different subdirs of the given local path and in the |
104 | // case where it finds an AliESDs.root file it creates the tags | |
105 | ||
106 | void *dira = gSystem->OpenDirectory(localpath); | |
107 | Char_t fPath[256]; | |
108 | const char * dirname = 0x0; | |
109 | const char * filename = 0x0; | |
110 | const char * pattern = "AliAODs.root"; | |
111 | ||
112 | Int_t counter = 0; | |
113 | while((dirname = gSystem->GetDirEntry(dira))) { | |
114 | sprintf(fPath,"%s/%s",localpath,dirname); | |
115 | void *dirb = gSystem->OpenDirectory(fPath); | |
116 | while((filename = gSystem->GetDirEntry(dirb))) { | |
117 | if(strstr(filename,pattern)) { | |
118 | TString fESDFileName; | |
119 | fESDFileName = fPath; | |
120 | fESDFileName += "/"; | |
121 | fESDFileName += pattern; | |
122 | ||
123 | fChain->Add(fESDFileName); | |
124 | ||
125 | //TFile *f = TFile::Open(fESDFileName,"READ"); | |
126 | //CreateTag(f,fESDFileName,counter); | |
127 | //f->Close(); | |
128 | //delete f; | |
129 | ||
130 | counter += 1; | |
131 | }//pattern check | |
132 | }//child directory's entry loop | |
133 | }//parent directory's entry loop | |
134 | ||
135 | AliInfo(Form("AOD chain created.......")); | |
136 | AliInfo(Form("Chain entries: %d",fChain->GetEntries())); | |
137 | CreateTag(fChain,"local"); | |
138 | ||
139 | return kTRUE; | |
140 | } | |
141 | ||
a1069ee1 | 142 | //______________________________________________________________________________ |
143 | Bool_t AliAODTagCreator::ReadCAFCollection(const char *filename) { | |
103d3fba | 144 | // Temporary solution for CAF: Takes as an input the ascii file that |
145 | // lists the ESDs stored in the SE of the CAF and creates the tags. | |
146 | ||
147 | // Open the input stream | |
148 | ifstream in; | |
149 | in.open(filename); | |
150 | ||
151 | Int_t counter = 0; | |
152 | TString esdfile; | |
153 | // Read the input list of files and add them to the chain | |
154 | while(in.good()) { | |
155 | in >> esdfile; | |
156 | if (!esdfile.Contains("root")) continue; // protection | |
157 | ||
158 | fChain->Add(esdfile); | |
159 | ||
160 | //TFile *f = TFile::Open(esdfile,"READ"); | |
161 | //CreateTag(f,esdfile,counter); | |
162 | //f->Close(); | |
163 | //delete f; | |
164 | ||
165 | counter += 1; | |
166 | } | |
167 | ||
168 | AliInfo(Form("AOD chain created.......")); | |
169 | AliInfo(Form("Chain entries: %d",fChain->GetEntries())); | |
170 | CreateTag(fChain,"proof"); | |
171 | ||
172 | return kTRUE; | |
173 | } | |
174 | ||
a1069ee1 | 175 | //__________________________________________________________________________ |
786172af | 176 | void AliAODTagCreator::CreateAODTags(Int_t fFirstEvent, Int_t fLastEvent, TList */*grpList*/) { |
a1069ee1 | 177 | //creates tag files for AODs |
178 | ||
179 | Float_t fLowPtCut = 1.0; | |
180 | Float_t fHighPtCut = 3.0; | |
181 | Float_t fVeryHighPtCut = 10.0; | |
182 | //////////// | |
183 | ||
184 | Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.}; | |
185 | ||
186 | // Creates the tags for all the events in a given AOD file | |
187 | Int_t ntrack; | |
188 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; | |
189 | Int_t nPos, nNeg, nNeutr; | |
190 | Int_t nKinks, nV0s, nCascades; | |
191 | Int_t nK0s, nNeutrons, nPi0s, nGamas; | |
192 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
193 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
194 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
195 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
a1069ee1 | 196 | |
197 | //reading the esd tag file | |
198 | TChain *oldTagTree = new TChain("T"); | |
199 | const char * tagPattern = "ESD.tag"; | |
200 | // Open the working directory | |
201 | void * dirp = gSystem->OpenDirectory(gSystem->pwd()); | |
202 | const char * name = 0x0; | |
203 | // Add all files matching *pattern* to the chain | |
204 | while((name = gSystem->GetDirEntry(dirp))) { | |
205 | if (strstr(name,tagPattern)) oldTagTree->Add(name); | |
206 | }//directory loop | |
207 | AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries())); | |
208 | ||
a1069ee1 | 209 | AliInfo(Form("Creating the AOD tags.......")); |
210 | ||
211 | TFile *file = TFile::Open("AliAOD.root"); | |
212 | if (!file || !file->IsOpen()) { | |
213 | AliError(Form("opening failed")); | |
214 | delete file; | |
215 | return ; | |
216 | } | |
217 | TTree *aodTree = (TTree*)file->Get("aodTree"); | |
218 | AliAODEvent *aod = new AliAODEvent(); | |
219 | aod->ReadFromTree(aodTree); | |
220 | ||
221 | Int_t lastEvent = 0; | |
222 | if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries(); | |
223 | else lastEvent = fLastEvent; | |
224 | ||
fcc6b05f | 225 | if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries(); |
226 | else lastEvent = fLastEvent; | |
227 | ||
228 | char fileName[256]; | |
229 | sprintf(fileName, "Run%d.Event%d_%d.AOD.tag.root", | |
1f466e02 | 230 | aod->GetRunNumber(),fFirstEvent,lastEvent ); |
fcc6b05f | 231 | AliInfo(Form("writing tags to file %s", fileName)); |
232 | AliDebug(1, Form("writing tags to file %s", fileName)); | |
233 | ||
234 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
235 | ||
1f466e02 | 236 | AliRunTag *tag = new AliRunTag(); |
237 | TTree ttag("T","A Tree with event tags"); | |
238 | TBranch * btag = ttag.Branch("AliTAG", &tag); | |
239 | btag->SetCompressionLevel(9); | |
240 | ||
241 | //reading the esd tag file | |
242 | AliRunTag *oldtag = new AliRunTag(); | |
243 | TString tagFilename; | |
244 | oldTagTree->SetBranchAddress("AliTAG",&oldtag); | |
245 | oldTagTree->GetEntry(0); | |
246 | tag->CopyStandardContent(oldtag); | |
247 | const TClonesArray *evTagList = oldtag->GetEventTags(); | |
248 | ||
a1069ee1 | 249 | // loop over events |
250 | Int_t nEvents = aodTree->GetEntries(); | |
251 | for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) { | |
252 | AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber); | |
253 | ntrack = 0; | |
254 | nPos = 0; nNeg = 0; nNeutr =0; | |
255 | nKinks = 0; nV0s = 0; nCascades = 0; | |
256 | nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0; | |
257 | nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0; | |
258 | nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0; | |
259 | nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0; | |
260 | nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0; | |
261 | maxPt = .0; meanPt = .0; totalP = .0; | |
262 | ||
263 | // read events | |
264 | aodTree->GetEvent(iEventNumber); | |
265 | ||
266 | // set pointers | |
267 | aod->GetStdContent(); | |
268 | ||
269 | Int_t nTracks = aod->GetNTracks(); | |
270 | // loop over vertices | |
4c85573c | 271 | Int_t nVtxs = aod->GetNumberOfVertices(); |
a1069ee1 | 272 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { |
273 | // print track info | |
274 | AliAODVertex *vertex = aod->GetVertex(nVtx); | |
275 | if(vertex->GetType() == 1) nKinks += 1; | |
276 | if(vertex->GetType() == 2) nV0s += 1; | |
277 | if(vertex->GetType() == 3) nCascades += 1; | |
278 | } | |
279 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { | |
280 | AliAODTrack *track = aod->GetTrack(nTr); | |
281 | ||
282 | Double_t fPt = track->Pt(); | |
283 | if(fPt > maxPt) maxPt = fPt; | |
284 | if(track->Charge() > 0) { | |
285 | nPos++; | |
286 | if(fPt > fLowPtCut) nCh1GeV++; | |
287 | if(fPt > fHighPtCut) nCh3GeV++; | |
288 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
289 | } | |
290 | if(track->Charge() < 0) { | |
291 | nNeg++; | |
292 | if(fPt > fLowPtCut) nCh1GeV++; | |
293 | if(fPt > fHighPtCut) nCh3GeV++; | |
294 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
295 | } | |
296 | if(track->Charge() == 0) nNeutr++; | |
297 | ||
298 | //PID | |
299 | const Double32_t *prob = track->PID(); | |
300 | Double_t rcc = 0.0; | |
301 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
302 | if(rcc == 0.0) continue; | |
303 | //Bayes' formula | |
304 | Double_t w[10]; | |
305 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; | |
306 | ||
307 | //protons | |
308 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
309 | //kaons | |
310 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
311 | //pions | |
312 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; | |
313 | //muons | |
314 | if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) { | |
315 | nMuons++; | |
316 | if(fPt > fLowPtCut) nMu1GeV++; | |
317 | if(fPt > fHighPtCut) nMu3GeV++; | |
318 | if(fPt > fVeryHighPtCut) nMu10GeV++; | |
319 | } | |
320 | //electrons | |
321 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { | |
322 | nElectrons++; | |
323 | if(fPt > fLowPtCut) nEl1GeV++; | |
324 | if(fPt > fHighPtCut) nEl3GeV++; | |
325 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
326 | } | |
327 | ||
328 | totalP += track->P(); | |
329 | meanPt += fPt; | |
330 | ntrack++; | |
331 | }//track loop | |
332 | // Fill the event tags | |
333 | if(ntrack != 0) | |
334 | meanPt = meanPt/ntrack; | |
335 | ||
336 | evTag->SetEventId(iEventNumber+1); | |
337 | ||
338 | evTag->SetNumOfTracks(nTracks); | |
339 | evTag->SetNumOfPosTracks(nPos); | |
340 | evTag->SetNumOfNegTracks(nNeg); | |
341 | evTag->SetNumOfNeutrTracks(nNeutr); | |
342 | ||
343 | evTag->SetNumOfV0s(nV0s); | |
344 | evTag->SetNumOfCascades(nCascades); | |
345 | evTag->SetNumOfKinks(nKinks); | |
346 | ||
347 | evTag->SetNumOfProtons(nProtons); | |
348 | evTag->SetNumOfKaons(nKaons); | |
349 | evTag->SetNumOfPions(nPions); | |
350 | evTag->SetNumOfMuons(nMuons); | |
351 | evTag->SetNumOfElectrons(nElectrons); | |
352 | evTag->SetNumOfPhotons(nGamas); | |
353 | evTag->SetNumOfPi0s(nPi0s); | |
354 | evTag->SetNumOfNeutrons(nNeutrons); | |
355 | evTag->SetNumOfKaon0s(nK0s); | |
356 | ||
357 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); | |
358 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
359 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
360 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
361 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
362 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
363 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
364 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
365 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
366 | ||
367 | evTag->SetTotalMomentum(totalP); | |
368 | evTag->SetMeanPt(meanPt); | |
369 | evTag->SetMaxPt(maxPt); | |
370 | tag->AddEventTag(*evTag); | |
371 | }//event loop | |
a1069ee1 | 372 | |
a1069ee1 | 373 | ftag->cd(); |
7ee67d2a | 374 | ttag.Fill(); |
375 | tag->Clear(); | |
a1069ee1 | 376 | ttag.Write(); |
377 | ftag->Close(); | |
378 | file->cd(); | |
379 | file->Close(); | |
380 | } | |
381 | ||
103d3fba | 382 | //_____________________________________________________________________________ |
5222362f | 383 | void AliAODTagCreator::CreateTag(TChain* chain, const char *type) { |
103d3fba | 384 | //private method that creates tag files |
385 | TString fSession = type; | |
103d3fba | 386 | TString fguid, fmd5, fturl; |
387 | TString fTempGuid = 0; | |
388 | ||
389 | //private method that creates tag files | |
390 | Float_t fLowPtCut = 1.0; | |
391 | Float_t fHighPtCut = 3.0; | |
392 | Float_t fVeryHighPtCut = 10.0; | |
393 | //////////// | |
394 | Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.}; | |
395 | ||
396 | // Creates the tags for all the events in a given AOD file | |
397 | Int_t ntrack; | |
398 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; | |
399 | Int_t nPos, nNeg, nNeutr; | |
400 | Int_t nKinks, nV0s, nCascades; | |
401 | Int_t nK0s, nNeutrons, nPi0s, nGamas; | |
402 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
403 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
404 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
405 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
103d3fba | 406 | |
fcc6b05f | 407 | //reading the esd tag file |
103d3fba | 408 | TChain *oldTagTree = new TChain("T"); |
409 | const char * tagPattern = "ESD.tag"; | |
410 | // Open the working directory | |
411 | void * dirp = gSystem->OpenDirectory(gSystem->pwd()); | |
412 | const char * name = 0x0; | |
413 | // Add all files matching *pattern* to the chain | |
414 | while((name = gSystem->GetDirEntry(dirp))) { | |
415 | if (strstr(name,tagPattern)) oldTagTree->Add(name); | |
416 | }//directory loop | |
417 | AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries())); | |
418 | ||
103d3fba | 419 | /*if (!file || !file->IsOpen()) { |
420 | AliError(Form("opening failed")); | |
421 | delete file; | |
422 | return ; | |
423 | } | |
424 | TTree *aodTree = (TTree*)file->Get("aodTree");*/ | |
425 | AliAODEvent *aod = new AliAODEvent(); | |
5222362f | 426 | aod->ReadFromTree(chain); |
427 | chain->GetEntry(0); | |
428 | TFile *f = chain->GetFile(); | |
fcc6b05f | 429 | fTempGuid = f->GetUUID().AsString(); |
103d3fba | 430 | Int_t firstEvent = 0, lastEvent = 0; |
431 | //lastEvent = (Int_t)aodTree->GetEntries(); | |
432 | ||
fcc6b05f | 433 | TString localFileName = "Run"; localFileName += aod->GetRunNumber(); |
5222362f | 434 | localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += chain->GetEntries(); //localFileName += "."; localFileName += Counter; |
fcc6b05f | 435 | localFileName += ".AOD.tag.root"; |
436 | ||
437 | TString fileName; | |
438 | ||
439 | if(fStorage == 0) { | |
440 | fileName = localFileName.Data(); | |
441 | AliInfo(Form("Writing tags to local file: %s",fileName.Data())); | |
442 | } | |
443 | else if(fStorage == 1) { | |
444 | TString alienLocation = "/alien"; | |
445 | alienLocation += gGrid->Pwd(); | |
446 | alienLocation += fgridpath.Data(); | |
447 | alienLocation += "/"; | |
448 | alienLocation += localFileName; | |
449 | alienLocation += "?se="; | |
450 | alienLocation += fSE.Data(); | |
451 | fileName = alienLocation.Data(); | |
452 | AliInfo(Form("Writing tags to grid file: %s",fileName.Data())); | |
453 | } | |
454 | ||
455 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
456 | ||
457 | AliRunTag *tag = new AliRunTag(); | |
458 | TTree ttag("T","A Tree with event tags"); | |
459 | TBranch * btag = ttag.Branch("AliTAG", &tag); | |
460 | btag->SetCompressionLevel(9); | |
461 | ||
462 | //reading the esd tag file | |
463 | AliRunTag *oldtag = new AliRunTag(); | |
464 | TString tagFilename; | |
465 | oldTagTree->SetBranchAddress("AliTAG",&oldtag); | |
466 | oldTagTree->GetEntry(0); | |
467 | tag->CopyStandardContent(oldtag); | |
468 | const TClonesArray *evTagList = oldtag->GetEventTags(); | |
469 | ||
470 | AliInfo(Form("Creating the AOD tags.......")); | |
471 | ||
103d3fba | 472 | // loop over events |
5222362f | 473 | Int_t nEvents = chain->GetEntries(); |
103d3fba | 474 | for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) { |
475 | AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber); | |
476 | ntrack = 0; | |
477 | nPos = 0; nNeg = 0; nNeutr =0; | |
478 | nKinks = 0; nV0s = 0; nCascades = 0; | |
479 | nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0; | |
480 | nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0; | |
481 | nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0; | |
482 | nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0; | |
483 | nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0; | |
484 | maxPt = .0; meanPt = .0; totalP = .0; | |
485 | ||
486 | // read events | |
5222362f | 487 | chain->GetEntry(iEventNumber); |
488 | TFile *file = chain->GetFile(); | |
489 | const TUrl *url = file->GetEndpointUrl(); | |
490 | fguid = file->GetUUID().AsString(); | |
103d3fba | 491 | if(fSession == "grid") { |
492 | TString fturltemp = "alien://"; fturltemp += url->GetFile(); | |
493 | fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5); | |
494 | } | |
495 | else fturl = url->GetFile(); | |
496 | ||
497 | // set pointers | |
498 | aod->GetStdContent(); | |
499 | ||
500 | Int_t nTracks = aod->GetNTracks(); | |
501 | // loop over vertices | |
4c85573c | 502 | Int_t nVtxs = aod->GetNumberOfVertices(); |
103d3fba | 503 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { |
504 | AliAODVertex *vertex = aod->GetVertex(nVtx); | |
505 | if(vertex->GetType() == 1) nKinks += 1; | |
506 | if(vertex->GetType() == 2) nV0s += 1; | |
507 | if(vertex->GetType() == 3) nCascades += 1; | |
508 | } | |
509 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { | |
510 | AliAODTrack *track = aod->GetTrack(nTr); | |
511 | ||
512 | Double_t fPt = track->Pt(); | |
513 | if(fPt > maxPt) maxPt = fPt; | |
514 | if(track->Charge() > 0) { | |
515 | nPos++; | |
516 | if(fPt > fLowPtCut) nCh1GeV++; | |
517 | if(fPt > fHighPtCut) nCh3GeV++; | |
518 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
519 | } | |
520 | if(track->Charge() < 0) { | |
521 | nNeg++; | |
522 | if(fPt > fLowPtCut) nCh1GeV++; | |
523 | if(fPt > fHighPtCut) nCh3GeV++; | |
524 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
525 | } | |
526 | if(track->Charge() == 0) nNeutr++; | |
527 | //PID | |
528 | const Double32_t *prob = track->PID(); | |
529 | Double_t rcc = 0.0; | |
530 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
531 | if(rcc == 0.0) continue; | |
532 | //Bayes' formula | |
533 | Double_t w[10]; | |
534 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; | |
535 | ||
536 | //protons | |
537 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
538 | //kaons | |
539 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
540 | //pions | |
541 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; | |
542 | //muons | |
543 | if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) { | |
544 | nMuons++; | |
545 | if(fPt > fLowPtCut) nMu1GeV++; | |
546 | if(fPt > fHighPtCut) nMu3GeV++; | |
547 | if(fPt > fVeryHighPtCut) nMu10GeV++; | |
548 | } | |
549 | //electrons | |
550 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { | |
551 | nElectrons++; | |
552 | if(fPt > fLowPtCut) nEl1GeV++; | |
553 | if(fPt > fHighPtCut) nEl3GeV++; | |
554 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
555 | } | |
556 | ||
557 | totalP += track->P(); | |
558 | meanPt += fPt; | |
559 | ntrack++; | |
560 | }//track loop | |
561 | // Fill the event tags | |
562 | if(ntrack != 0) | |
563 | meanPt = meanPt/ntrack; | |
564 | ||
565 | evTag->SetEventId(iEventNumber+1); | |
566 | evTag->SetGUID(fguid); | |
567 | if(fSession == "grid") { | |
568 | evTag->SetMD5(0); | |
569 | evTag->SetTURL(fturl); | |
570 | evTag->SetSize(0); | |
571 | } | |
572 | else evTag->SetPath(fturl); | |
573 | ||
574 | evTag->SetNumOfTracks(nTracks); | |
575 | evTag->SetNumOfPosTracks(nPos); | |
576 | evTag->SetNumOfNegTracks(nNeg); | |
577 | evTag->SetNumOfNeutrTracks(nNeutr); | |
578 | ||
579 | evTag->SetNumOfV0s(nV0s); | |
580 | evTag->SetNumOfCascades(nCascades); | |
581 | evTag->SetNumOfKinks(nKinks); | |
582 | ||
583 | evTag->SetNumOfProtons(nProtons); | |
584 | evTag->SetNumOfKaons(nKaons); | |
585 | evTag->SetNumOfPions(nPions); | |
586 | evTag->SetNumOfMuons(nMuons); | |
587 | evTag->SetNumOfElectrons(nElectrons); | |
588 | evTag->SetNumOfPhotons(nGamas); | |
589 | evTag->SetNumOfPi0s(nPi0s); | |
590 | evTag->SetNumOfNeutrons(nNeutrons); | |
591 | evTag->SetNumOfKaon0s(nK0s); | |
592 | ||
593 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); | |
594 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
595 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
596 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
597 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
598 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
599 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
600 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
601 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
602 | ||
603 | evTag->SetTotalMomentum(totalP); | |
604 | evTag->SetMeanPt(meanPt); | |
605 | evTag->SetMaxPt(maxPt); | |
103d3fba | 606 | |
607 | if(fguid != fTempGuid) { | |
608 | fTempGuid = fguid; | |
609 | ttag.Fill(); | |
610 | tag->Clear(""); | |
611 | } | |
fcc6b05f | 612 | tag->AddEventTag(*evTag); |
5222362f | 613 | if(iEventNumber+1 == chain->GetEntries()) { |
fcc6b05f | 614 | //AliInfo(Form("File: %s",fturl.Data())); |
615 | ttag.Fill(); | |
616 | tag->Clear(""); | |
617 | } | |
103d3fba | 618 | }//event loop |
5222362f | 619 | lastEvent = chain->GetEntries(); |
103d3fba | 620 | |
103d3fba | 621 | ftag->cd(); |
622 | //ttag.Fill(); | |
623 | tag->Clear(); | |
624 | ttag.Write(); | |
625 | ftag->Close(); | |
626 | } | |
627 | ||
a1069ee1 | 628 | //_____________________________________________________________________________ |
5b8d5d69 | 629 | void AliAODTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) { |
a1069ee1 | 630 | //private method that creates tag files |
631 | TString fguid = guid; | |
632 | TString fmd5 = md5; | |
633 | TString fturl = turl; | |
a1069ee1 | 634 | |
5b8d5d69 | 635 | //private method that creates tag files |
a1069ee1 | 636 | Float_t fLowPtCut = 1.0; |
637 | Float_t fHighPtCut = 3.0; | |
638 | Float_t fVeryHighPtCut = 10.0; | |
5b8d5d69 | 639 | //////////// |
640 | Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.}; | |
a1069ee1 | 641 | |
642 | // Creates the tags for all the events in a given AOD file | |
a1069ee1 | 643 | Int_t ntrack; |
644 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; | |
645 | Int_t nPos, nNeg, nNeutr; | |
5b8d5d69 | 646 | Int_t nKinks, nV0s, nCascades; |
a1069ee1 | 647 | Int_t nK0s, nNeutrons, nPi0s, nGamas; |
648 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
649 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
650 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
651 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
a1069ee1 | 652 | |
653 | AliRunTag *tag = new AliRunTag(); | |
a1069ee1 | 654 | TTree ttag("T","A Tree with event tags"); |
655 | TBranch * btag = ttag.Branch("AliTAG", &tag); | |
656 | btag->SetCompressionLevel(9); | |
657 | ||
5b8d5d69 | 658 | //reading the esd tag file |
659 | ||
660 | TChain *oldTagTree = new TChain("T"); | |
661 | const char * tagPattern = "ESD.tag"; | |
662 | // Open the working directory | |
663 | void * dirp = gSystem->OpenDirectory(gSystem->pwd()); | |
664 | const char * name = 0x0; | |
665 | // Add all files matching *pattern* to the chain | |
666 | while((name = gSystem->GetDirEntry(dirp))) { | |
667 | if (strstr(name,tagPattern)) oldTagTree->Add(name); | |
668 | }//directory loop | |
669 | AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries())); | |
a1069ee1 | 670 | |
5b8d5d69 | 671 | //reading the esd tag file |
672 | AliRunTag *oldtag = new AliRunTag(); | |
673 | TString tagFilename; | |
674 | oldTagTree->SetBranchAddress("AliTAG",&oldtag); | |
675 | oldTagTree->GetEntry(0); | |
676 | tag->CopyStandardContent(oldtag); | |
677 | const TClonesArray *evTagList = oldtag->GetEventTags(); | |
a1069ee1 | 678 | |
5b8d5d69 | 679 | AliInfo(Form("Creating the AOD tags.......")); |
680 | ||
681 | if (!file || !file->IsOpen()) { | |
682 | AliError(Form("opening failed")); | |
683 | delete file; | |
684 | return ; | |
685 | } | |
686 | TTree *aodTree = (TTree*)file->Get("aodTree"); | |
687 | AliAODEvent *aod = new AliAODEvent(); | |
688 | aod->ReadFromTree(aodTree); | |
689 | Int_t firstEvent = 0, lastEvent = 0; | |
690 | lastEvent = (Int_t)aodTree->GetEntries(); | |
691 | ||
692 | // loop over events | |
693 | Int_t nEvents = aodTree->GetEntries(); | |
694 | for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) { | |
695 | AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber); | |
a1069ee1 | 696 | ntrack = 0; |
5b8d5d69 | 697 | nPos = 0; nNeg = 0; nNeutr =0; |
698 | nKinks = 0; nV0s = 0; nCascades = 0; | |
699 | nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0; | |
700 | nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0; | |
701 | nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0; | |
702 | nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0; | |
703 | nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0; | |
704 | maxPt = .0; meanPt = .0; totalP = .0; | |
705 | ||
706 | // read events | |
707 | aodTree->GetEvent(iEventNumber); | |
708 | // set pointers | |
709 | aod->GetStdContent(); | |
710 | ||
711 | Int_t nTracks = aod->GetNTracks(); | |
712 | // loop over vertices | |
4c85573c | 713 | Int_t nVtxs = aod->GetNumberOfVertices(); |
5b8d5d69 | 714 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { |
715 | AliAODVertex *vertex = aod->GetVertex(nVtx); | |
716 | if(vertex->GetType() == 1) nKinks += 1; | |
717 | if(vertex->GetType() == 2) nV0s += 1; | |
718 | if(vertex->GetType() == 3) nCascades += 1; | |
719 | } | |
720 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { | |
721 | AliAODTrack *track = aod->GetTrack(nTr); | |
722 | ||
723 | Double_t fPt = track->Pt(); | |
a1069ee1 | 724 | if(fPt > maxPt) maxPt = fPt; |
5b8d5d69 | 725 | if(track->Charge() > 0) { |
a1069ee1 | 726 | nPos++; |
727 | if(fPt > fLowPtCut) nCh1GeV++; | |
728 | if(fPt > fHighPtCut) nCh3GeV++; | |
729 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
730 | } | |
5b8d5d69 | 731 | if(track->Charge() < 0) { |
a1069ee1 | 732 | nNeg++; |
733 | if(fPt > fLowPtCut) nCh1GeV++; | |
734 | if(fPt > fHighPtCut) nCh3GeV++; | |
735 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
736 | } | |
5b8d5d69 | 737 | if(track->Charge() == 0) nNeutr++; |
a1069ee1 | 738 | //PID |
5b8d5d69 | 739 | const Double32_t *prob = track->PID(); |
a1069ee1 | 740 | Double_t rcc = 0.0; |
741 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
742 | if(rcc == 0.0) continue; | |
5b8d5d69 | 743 | //Bayes' formula |
744 | Double_t w[10]; | |
a1069ee1 | 745 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; |
5b8d5d69 | 746 | |
a1069ee1 | 747 | //protons |
748 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
749 | //kaons | |
750 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
751 | //pions | |
5b8d5d69 | 752 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; |
753 | //muons | |
754 | if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) { | |
755 | nMuons++; | |
756 | if(fPt > fLowPtCut) nMu1GeV++; | |
757 | if(fPt > fHighPtCut) nMu3GeV++; | |
758 | if(fPt > fVeryHighPtCut) nMu10GeV++; | |
759 | } | |
760 | //electrons | |
a1069ee1 | 761 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { |
762 | nElectrons++; | |
763 | if(fPt > fLowPtCut) nEl1GeV++; | |
764 | if(fPt > fHighPtCut) nEl3GeV++; | |
765 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
a1069ee1 | 766 | } |
5b8d5d69 | 767 | |
768 | totalP += track->P(); | |
769 | meanPt += fPt; | |
770 | ntrack++; | |
771 | }//track loop | |
772 | // Fill the event tags | |
773 | if(ntrack != 0) | |
774 | meanPt = meanPt/ntrack; | |
a1069ee1 | 775 | |
776 | evTag->SetEventId(iEventNumber+1); | |
777 | evTag->SetGUID(fguid); | |
778 | evTag->SetMD5(fmd5); | |
779 | evTag->SetTURL(fturl); | |
780 | evTag->SetSize(size); | |
5b8d5d69 | 781 | |
782 | evTag->SetNumOfTracks(nTracks); | |
a1069ee1 | 783 | evTag->SetNumOfPosTracks(nPos); |
784 | evTag->SetNumOfNegTracks(nNeg); | |
785 | evTag->SetNumOfNeutrTracks(nNeutr); | |
5b8d5d69 | 786 | |
787 | evTag->SetNumOfV0s(nV0s); | |
788 | evTag->SetNumOfCascades(nCascades); | |
789 | evTag->SetNumOfKinks(nKinks); | |
790 | ||
a1069ee1 | 791 | evTag->SetNumOfProtons(nProtons); |
792 | evTag->SetNumOfKaons(nKaons); | |
793 | evTag->SetNumOfPions(nPions); | |
794 | evTag->SetNumOfMuons(nMuons); | |
795 | evTag->SetNumOfElectrons(nElectrons); | |
796 | evTag->SetNumOfPhotons(nGamas); | |
797 | evTag->SetNumOfPi0s(nPi0s); | |
798 | evTag->SetNumOfNeutrons(nNeutrons); | |
799 | evTag->SetNumOfKaon0s(nK0s); | |
5b8d5d69 | 800 | |
a1069ee1 | 801 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); |
802 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
803 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
804 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
805 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
806 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
807 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
808 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
809 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
5b8d5d69 | 810 | |
a1069ee1 | 811 | evTag->SetTotalMomentum(totalP); |
812 | evTag->SetMeanPt(meanPt); | |
813 | evTag->SetMaxPt(maxPt); | |
a1069ee1 | 814 | tag->AddEventTag(*evTag); |
815 | }//event loop | |
7ee67d2a | 816 | |
5b8d5d69 | 817 | TString localFileName = "Run"; localFileName += tag->GetRunId(); |
818 | localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; | |
819 | localFileName += lastEvent; localFileName += "."; localFileName += Counter; | |
820 | localFileName += ".AOD.tag.root"; | |
a1069ee1 | 821 | |
822 | TString fileName; | |
5b8d5d69 | 823 | |
a1069ee1 | 824 | if(fStorage == 0) { |
5b8d5d69 | 825 | fileName = localFileName.Data(); |
826 | AliInfo(Form("Writing AOD tags to local file: %s",fileName.Data())); | |
a1069ee1 | 827 | } |
828 | else if(fStorage == 1) { | |
829 | TString alienLocation = "/alien"; | |
830 | alienLocation += gGrid->Pwd(); | |
831 | alienLocation += fgridpath.Data(); | |
832 | alienLocation += "/"; | |
833 | alienLocation += localFileName; | |
834 | alienLocation += "?se="; | |
835 | alienLocation += fSE.Data(); | |
836 | fileName = alienLocation.Data(); | |
5b8d5d69 | 837 | AliInfo(Form("Writing AOD tags to grid file: %s",fileName.Data())); |
a1069ee1 | 838 | } |
839 | ||
840 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
841 | ftag->cd(); | |
7ee67d2a | 842 | ttag.Fill(); |
843 | tag->Clear(); | |
a1069ee1 | 844 | ttag.Write(); |
845 | ftag->Close(); | |
5b8d5d69 | 846 | } |
847 | ||
a1069ee1 | 848 | |
849 | //_____________________________________________________________________________ | |
5b8d5d69 | 850 | void AliAODTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) { |
a1069ee1 | 851 | //private method that creates tag files |
a1069ee1 | 852 | Float_t fLowPtCut = 1.0; |
853 | Float_t fHighPtCut = 3.0; | |
854 | Float_t fVeryHighPtCut = 10.0; | |
855 | //////////// | |
5b8d5d69 | 856 | |
857 | Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.}; | |
858 | ||
859 | // Creates the tags for all the events in a given AOD file | |
a1069ee1 | 860 | Int_t ntrack; |
861 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; | |
862 | Int_t nPos, nNeg, nNeutr; | |
5b8d5d69 | 863 | Int_t nKinks, nV0s, nCascades; |
a1069ee1 | 864 | Int_t nK0s, nNeutrons, nPi0s, nGamas; |
865 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
866 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
867 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
868 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
a1069ee1 | 869 | |
870 | AliRunTag *tag = new AliRunTag(); | |
a1069ee1 | 871 | TTree ttag("T","A Tree with event tags"); |
872 | TBranch * btag = ttag.Branch("AliTAG", &tag); | |
873 | btag->SetCompressionLevel(9); | |
a1069ee1 | 874 | |
5b8d5d69 | 875 | //reading the esd tag file |
876 | TChain *oldTagTree = new TChain("T"); | |
877 | const char * tagPattern = "ESD.tag"; | |
878 | // Open the working directory | |
879 | void * dirp = gSystem->OpenDirectory(gSystem->pwd()); | |
880 | const char * name = 0x0; | |
881 | // Add all files matching *pattern* to the chain | |
882 | while((name = gSystem->GetDirEntry(dirp))) { | |
883 | if (strstr(name,tagPattern)) oldTagTree->Add(name); | |
884 | }//directory loop | |
885 | AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries())); | |
886 | ||
887 | //reading the esd tag file | |
888 | AliRunTag *oldtag = new AliRunTag(); | |
889 | TString tagFilename; | |
890 | oldTagTree->SetBranchAddress("AliTAG",&oldtag); | |
891 | oldTagTree->GetEntry(0); | |
892 | tag->CopyStandardContent(oldtag); | |
893 | const TClonesArray *evTagList = oldtag->GetEventTags(); | |
894 | ||
895 | AliInfo(Form("Creating the AOD tags.......")); | |
896 | ||
897 | if (!file || !file->IsOpen()) { | |
898 | AliError(Form("opening failed")); | |
899 | delete file; | |
900 | return ; | |
901 | } | |
902 | TTree *aodTree = (TTree*)file->Get("aodTree"); | |
903 | AliAODEvent *aod = new AliAODEvent(); | |
904 | aod->ReadFromTree(aodTree); | |
905 | Int_t firstEvent = 0, lastEvent = 0; | |
906 | lastEvent = (Int_t)aodTree->GetEntries(); | |
907 | ||
908 | // loop over events | |
909 | Int_t nEvents = aodTree->GetEntries(); | |
910 | for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) { | |
911 | AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber); | |
a1069ee1 | 912 | ntrack = 0; |
5b8d5d69 | 913 | nPos = 0; nNeg = 0; nNeutr =0; |
914 | nKinks = 0; nV0s = 0; nCascades = 0; | |
915 | nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0; | |
916 | nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0; | |
917 | nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0; | |
918 | nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0; | |
919 | nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0; | |
920 | maxPt = .0; meanPt = .0; totalP = .0; | |
921 | ||
922 | // read events | |
923 | aodTree->GetEvent(iEventNumber); | |
a1069ee1 | 924 | |
5b8d5d69 | 925 | // set pointers |
926 | aod->GetStdContent(); | |
927 | ||
928 | Int_t nTracks = aod->GetNTracks(); | |
929 | // loop over vertices | |
4c85573c | 930 | Int_t nVtxs = aod->GetNumberOfVertices(); |
5b8d5d69 | 931 | for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) { |
932 | // print track info | |
933 | AliAODVertex *vertex = aod->GetVertex(nVtx); | |
934 | if(vertex->GetType() == 1) nKinks += 1; | |
935 | if(vertex->GetType() == 2) nV0s += 1; | |
936 | if(vertex->GetType() == 3) nCascades += 1; | |
937 | } | |
938 | for (Int_t nTr = 0; nTr < nTracks; nTr++) { | |
939 | AliAODTrack *track = aod->GetTrack(nTr); | |
a1069ee1 | 940 | |
5b8d5d69 | 941 | Double_t fPt = track->Pt(); |
a1069ee1 | 942 | if(fPt > maxPt) maxPt = fPt; |
5b8d5d69 | 943 | if(track->Charge() > 0) { |
944 | nPos++; | |
945 | if(fPt > fLowPtCut) nCh1GeV++; | |
946 | if(fPt > fHighPtCut) nCh3GeV++; | |
947 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
a1069ee1 | 948 | } |
5b8d5d69 | 949 | if(track->Charge() < 0) { |
950 | nNeg++; | |
951 | if(fPt > fLowPtCut) nCh1GeV++; | |
952 | if(fPt > fHighPtCut) nCh3GeV++; | |
953 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
a1069ee1 | 954 | } |
5b8d5d69 | 955 | if(track->Charge() == 0) nNeutr++; |
956 | ||
a1069ee1 | 957 | //PID |
5b8d5d69 | 958 | const Double32_t *prob = track->PID(); |
a1069ee1 | 959 | Double_t rcc = 0.0; |
960 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
961 | if(rcc == 0.0) continue; | |
962 | //Bayes' formula | |
5b8d5d69 | 963 | Double_t w[10]; |
a1069ee1 | 964 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; |
965 | ||
966 | //protons | |
967 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
968 | //kaons | |
969 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
970 | //pions | |
971 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; | |
5b8d5d69 | 972 | //muons |
973 | if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) { | |
974 | nMuons++; | |
975 | if(fPt > fLowPtCut) nMu1GeV++; | |
976 | if(fPt > fHighPtCut) nMu3GeV++; | |
977 | if(fPt > fVeryHighPtCut) nMu10GeV++; | |
978 | } | |
a1069ee1 | 979 | //electrons |
980 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { | |
5b8d5d69 | 981 | nElectrons++; |
982 | if(fPt > fLowPtCut) nEl1GeV++; | |
983 | if(fPt > fHighPtCut) nEl3GeV++; | |
984 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
a1069ee1 | 985 | } |
5b8d5d69 | 986 | |
987 | totalP += track->P(); | |
988 | meanPt += fPt; | |
989 | ntrack++; | |
990 | }//track loop | |
a1069ee1 | 991 | // Fill the event tags |
5b8d5d69 | 992 | if(ntrack != 0) |
993 | meanPt = meanPt/ntrack; | |
994 | ||
a1069ee1 | 995 | evTag->SetEventId(iEventNumber+1); |
996 | evTag->SetPath(filepath); | |
5b8d5d69 | 997 | |
998 | evTag->SetNumOfTracks(nTracks); | |
a1069ee1 | 999 | evTag->SetNumOfPosTracks(nPos); |
1000 | evTag->SetNumOfNegTracks(nNeg); | |
1001 | evTag->SetNumOfNeutrTracks(nNeutr); | |
1002 | ||
5b8d5d69 | 1003 | evTag->SetNumOfV0s(nV0s); |
1004 | evTag->SetNumOfCascades(nCascades); | |
1005 | evTag->SetNumOfKinks(nKinks); | |
a1069ee1 | 1006 | |
1007 | evTag->SetNumOfProtons(nProtons); | |
1008 | evTag->SetNumOfKaons(nKaons); | |
1009 | evTag->SetNumOfPions(nPions); | |
1010 | evTag->SetNumOfMuons(nMuons); | |
1011 | evTag->SetNumOfElectrons(nElectrons); | |
1012 | evTag->SetNumOfPhotons(nGamas); | |
1013 | evTag->SetNumOfPi0s(nPi0s); | |
1014 | evTag->SetNumOfNeutrons(nNeutrons); | |
1015 | evTag->SetNumOfKaon0s(nK0s); | |
1016 | ||
1017 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); | |
1018 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
1019 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
1020 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
1021 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
1022 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
1023 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
1024 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
1025 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
1026 | ||
a1069ee1 | 1027 | evTag->SetTotalMomentum(totalP); |
1028 | evTag->SetMeanPt(meanPt); | |
1029 | evTag->SetMaxPt(maxPt); | |
a1069ee1 | 1030 | tag->AddEventTag(*evTag); |
5b8d5d69 | 1031 | }//event loop |
1032 | ||
a1069ee1 | 1033 | TString localFileName = "Run"; localFileName += tag->GetRunId(); |
5b8d5d69 | 1034 | localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; |
1035 | localFileName += lastEvent; localFileName += "."; localFileName += Counter; | |
1036 | localFileName += ".AOD.tag.root"; | |
a1069ee1 | 1037 | |
1038 | TString fileName; | |
1039 | ||
1040 | if(fStorage == 0) { | |
1041 | fileName = localFileName.Data(); | |
5b8d5d69 | 1042 | AliInfo(Form("Writing AOD tags to local file: %s",fileName.Data())); |
a1069ee1 | 1043 | } |
1044 | else if(fStorage == 1) { | |
1045 | TString alienLocation = "/alien"; | |
1046 | alienLocation += gGrid->Pwd(); | |
1047 | alienLocation += fgridpath.Data(); | |
1048 | alienLocation += "/"; | |
1049 | alienLocation += localFileName; | |
1050 | alienLocation += "?se="; | |
1051 | alienLocation += fSE.Data(); | |
1052 | fileName = alienLocation.Data(); | |
5b8d5d69 | 1053 | AliInfo(Form("Writing AOD tags to grid file: %s",fileName.Data())); |
a1069ee1 | 1054 | } |
1055 | ||
1056 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
1057 | ftag->cd(); | |
7ee67d2a | 1058 | ttag.Fill(); |
1059 | tag->Clear(); | |
a1069ee1 | 1060 | ttag.Write(); |
1061 | ftag->Close(); | |
5b8d5d69 | 1062 | } |
a1069ee1 | 1063 |