1 /**************************************************************************
2 * Author: Panos Christakoglou. *
3 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
23 #include <Riostream.h>
29 #include <TLorentzVector.h>
33 #include <TGridResult.h>
36 #include "AliRunTag.h"
37 #include "AliEventTag.h"
39 #include "AliAODEvent.h"
40 #include "AliAODVertex.h"
43 #include "AliAODTagCreator.h"
46 ClassImp(AliAODTagCreator)
49 //______________________________________________________________________________
50 AliAODTagCreator::AliAODTagCreator() :
52 //==============Default constructor for a AliAODTagCreator================
55 //______________________________________________________________________________
56 AliAODTagCreator::~AliAODTagCreator() {
57 //================Default destructor for a AliAODTagCreator===================
60 //______________________________________________________________________________
61 Bool_t AliAODTagCreator::ReadGridCollection(TGridResult *fresult) {
62 // Reads the entry of the TGridResult and creates the tags
63 Int_t nEntries = fresult->GetEntries();
72 for(Int_t i = 0; i < nEntries; i++) {
73 alienUrl = fresult->GetKey(i,"turl");
74 guid = fresult->GetKey(i,"guid");
75 if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size"));
76 md5 = fresult->GetKey(i,"md5");
77 turl = fresult->GetKey(i,"turl");
78 if(md5 && !strlen(guid)) md5 = 0;
79 if(guid && !strlen(guid)) guid = 0;
81 TFile *f = TFile::Open(alienUrl,"READ");
82 CreateTag(f,guid,md5,turl,size,counter);
91 //______________________________________________________________________________
92 Bool_t AliAODTagCreator::ReadLocalCollection(const char *localpath) {
93 // Checks the different subdirs of the given local path and in the
94 // case where it finds an AliAODs.root file it creates the tags
96 void *dira = gSystem->OpenDirectory(localpath);
98 const char * dirname = 0x0;
99 const char * filename = 0x0;
100 const char * pattern = "AliAOD.root";
103 while((dirname = gSystem->GetDirEntry(dira))) {
104 sprintf(fPath,"%s/%s",localpath,dirname);
105 void *dirb = gSystem->OpenDirectory(fPath);
106 while((filename = gSystem->GetDirEntry(dirb))) {
107 if(strstr(filename,pattern)) {
108 TString fAODFileName;
109 fAODFileName = fPath;
111 fAODFileName += pattern;
112 TFile *f = TFile::Open(fAODFileName,"READ");
113 CreateTag(f,fAODFileName,counter);
119 }//child directory's entry loop
120 }//parent directory's entry loop
125 //______________________________________________________________________________
126 Bool_t AliAODTagCreator::ReadCAFCollection(const char *filename) {
127 // Temporary solution for CAF: Takes as an input the ascii file that
128 // lists the AODs stored in the SE of the CAF and creates the tags.
130 // Open the input stream
136 // Read the input list of files and add them to the chain
139 if (!esdfile.Contains("root")) continue; // protection
140 TFile *f = TFile::Open(esdfile,"READ");
141 CreateTag(f,esdfile,counter);
151 //__________________________________________________________________________
152 void AliAODTagCreator::CreateAODTags(Int_t fFirstEvent, Int_t fLastEvent) {
153 //creates tag files for AODs
155 Float_t fLowPtCut = 1.0;
156 Float_t fHighPtCut = 3.0;
157 Float_t fVeryHighPtCut = 10.0;
160 Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.};
162 // Creates the tags for all the events in a given AOD file
164 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
165 Int_t nPos, nNeg, nNeutr;
166 Int_t nKinks, nV0s, nCascades;
167 Int_t nK0s, nNeutrons, nPi0s, nGamas;
168 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
169 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
170 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
171 Float_t maxPt = .0, meanPt = .0, totalP = .0;
173 AliRunTag *tag = new AliRunTag();
174 TTree ttag("T","A Tree with event tags");
175 TBranch * btag = ttag.Branch("AliTAG", &tag);
176 btag->SetCompressionLevel(9);
178 //reading the esd tag file
179 TChain *oldTagTree = new TChain("T");
180 const char * tagPattern = "ESD.tag";
181 // Open the working directory
182 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
183 const char * name = 0x0;
184 // Add all files matching *pattern* to the chain
185 while((name = gSystem->GetDirEntry(dirp))) {
186 if (strstr(name,tagPattern)) oldTagTree->Add(name);
188 AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries()));
190 //reading the esd tag file
191 AliRunTag *oldtag = new AliRunTag();
193 oldTagTree->SetBranchAddress("AliTAG",&oldtag);
194 oldTagTree->GetEntry(0);
195 tag->CopyStandardContent(oldtag);
196 const TClonesArray *evTagList = oldtag->GetEventTags();
198 AliInfo(Form("Creating the AOD tags......."));
200 TFile *file = TFile::Open("AliAOD.root");
201 if (!file || !file->IsOpen()) {
202 AliError(Form("opening failed"));
206 TTree *aodTree = (TTree*)file->Get("aodTree");
207 AliAODEvent *aod = new AliAODEvent();
208 aod->ReadFromTree(aodTree);
211 if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries();
212 else lastEvent = fLastEvent;
215 Int_t nEvents = aodTree->GetEntries();
216 for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) {
217 AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber);
219 nPos = 0; nNeg = 0; nNeutr =0;
220 nKinks = 0; nV0s = 0; nCascades = 0;
221 nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0;
222 nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0;
223 nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
224 nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
225 nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
226 maxPt = .0; meanPt = .0; totalP = .0;
229 aodTree->GetEvent(iEventNumber);
232 aod->GetStdContent();
234 Int_t nTracks = aod->GetNTracks();
235 // loop over vertices
236 Int_t nVtxs = aod->GetNVertices();
237 for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
239 AliAODVertex *vertex = aod->GetVertex(nVtx);
240 if(vertex->GetType() == 1) nKinks += 1;
241 if(vertex->GetType() == 2) nV0s += 1;
242 if(vertex->GetType() == 3) nCascades += 1;
244 for (Int_t nTr = 0; nTr < nTracks; nTr++) {
245 AliAODTrack *track = aod->GetTrack(nTr);
247 Double_t fPt = track->Pt();
248 if(fPt > maxPt) maxPt = fPt;
249 if(track->Charge() > 0) {
251 if(fPt > fLowPtCut) nCh1GeV++;
252 if(fPt > fHighPtCut) nCh3GeV++;
253 if(fPt > fVeryHighPtCut) nCh10GeV++;
255 if(track->Charge() < 0) {
257 if(fPt > fLowPtCut) nCh1GeV++;
258 if(fPt > fHighPtCut) nCh3GeV++;
259 if(fPt > fVeryHighPtCut) nCh10GeV++;
261 if(track->Charge() == 0) nNeutr++;
264 const Double32_t *prob = track->PID();
266 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
267 if(rcc == 0.0) continue;
270 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
273 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
275 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
277 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
279 if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) {
281 if(fPt > fLowPtCut) nMu1GeV++;
282 if(fPt > fHighPtCut) nMu3GeV++;
283 if(fPt > fVeryHighPtCut) nMu10GeV++;
286 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
288 if(fPt > fLowPtCut) nEl1GeV++;
289 if(fPt > fHighPtCut) nEl3GeV++;
290 if(fPt > fVeryHighPtCut) nEl10GeV++;
293 totalP += track->P();
297 // Fill the event tags
299 meanPt = meanPt/ntrack;
301 evTag->SetEventId(iEventNumber+1);
303 evTag->SetNumOfTracks(nTracks);
304 evTag->SetNumOfPosTracks(nPos);
305 evTag->SetNumOfNegTracks(nNeg);
306 evTag->SetNumOfNeutrTracks(nNeutr);
308 evTag->SetNumOfV0s(nV0s);
309 evTag->SetNumOfCascades(nCascades);
310 evTag->SetNumOfKinks(nKinks);
312 evTag->SetNumOfProtons(nProtons);
313 evTag->SetNumOfKaons(nKaons);
314 evTag->SetNumOfPions(nPions);
315 evTag->SetNumOfMuons(nMuons);
316 evTag->SetNumOfElectrons(nElectrons);
317 evTag->SetNumOfPhotons(nGamas);
318 evTag->SetNumOfPi0s(nPi0s);
319 evTag->SetNumOfNeutrons(nNeutrons);
320 evTag->SetNumOfKaon0s(nK0s);
322 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
323 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
324 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
325 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
326 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
327 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
328 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
329 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
330 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
332 evTag->SetTotalMomentum(totalP);
333 evTag->SetMeanPt(meanPt);
334 evTag->SetMaxPt(maxPt);
335 tag->AddEventTag(*evTag);
337 if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries();
338 else lastEvent = fLastEvent;
341 sprintf(fileName, "Run%d.Event%d_%d.AOD.tag.root",
342 tag->GetRunId(),fFirstEvent,lastEvent );
343 AliInfo(Form("writing tags to file %s", fileName));
344 AliDebug(1, Form("writing tags to file %s", fileName));
346 TFile* ftag = TFile::Open(fileName, "recreate");
356 //_____________________________________________________________________________
357 void AliAODTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
358 //private method that creates tag files
359 TString fguid = guid;
361 TString fturl = turl;
363 //private method that creates tag files
364 Float_t fLowPtCut = 1.0;
365 Float_t fHighPtCut = 3.0;
366 Float_t fVeryHighPtCut = 10.0;
368 Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.};
370 // Creates the tags for all the events in a given AOD file
372 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
373 Int_t nPos, nNeg, nNeutr;
374 Int_t nKinks, nV0s, nCascades;
375 Int_t nK0s, nNeutrons, nPi0s, nGamas;
376 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
377 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
378 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
379 Float_t maxPt = .0, meanPt = .0, totalP = .0;
381 AliRunTag *tag = new AliRunTag();
382 TTree ttag("T","A Tree with event tags");
383 TBranch * btag = ttag.Branch("AliTAG", &tag);
384 btag->SetCompressionLevel(9);
386 //reading the esd tag file
388 TChain *oldTagTree = new TChain("T");
389 const char * tagPattern = "ESD.tag";
390 // Open the working directory
391 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
392 const char * name = 0x0;
393 // Add all files matching *pattern* to the chain
394 while((name = gSystem->GetDirEntry(dirp))) {
395 if (strstr(name,tagPattern)) oldTagTree->Add(name);
397 AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries()));
399 //reading the esd tag file
400 AliRunTag *oldtag = new AliRunTag();
402 oldTagTree->SetBranchAddress("AliTAG",&oldtag);
403 oldTagTree->GetEntry(0);
404 tag->CopyStandardContent(oldtag);
405 const TClonesArray *evTagList = oldtag->GetEventTags();
407 AliInfo(Form("Creating the AOD tags......."));
409 if (!file || !file->IsOpen()) {
410 AliError(Form("opening failed"));
414 TTree *aodTree = (TTree*)file->Get("aodTree");
415 AliAODEvent *aod = new AliAODEvent();
416 aod->ReadFromTree(aodTree);
417 Int_t firstEvent = 0, lastEvent = 0;
418 lastEvent = (Int_t)aodTree->GetEntries();
421 Int_t nEvents = aodTree->GetEntries();
422 for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) {
423 AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber);
425 nPos = 0; nNeg = 0; nNeutr =0;
426 nKinks = 0; nV0s = 0; nCascades = 0;
427 nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0;
428 nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0;
429 nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
430 nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
431 nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
432 maxPt = .0; meanPt = .0; totalP = .0;
435 aodTree->GetEvent(iEventNumber);
437 aod->GetStdContent();
439 Int_t nTracks = aod->GetNTracks();
440 // loop over vertices
441 Int_t nVtxs = aod->GetNVertices();
442 for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
443 AliAODVertex *vertex = aod->GetVertex(nVtx);
444 if(vertex->GetType() == 1) nKinks += 1;
445 if(vertex->GetType() == 2) nV0s += 1;
446 if(vertex->GetType() == 3) nCascades += 1;
448 for (Int_t nTr = 0; nTr < nTracks; nTr++) {
449 AliAODTrack *track = aod->GetTrack(nTr);
451 Double_t fPt = track->Pt();
452 if(fPt > maxPt) maxPt = fPt;
453 if(track->Charge() > 0) {
455 if(fPt > fLowPtCut) nCh1GeV++;
456 if(fPt > fHighPtCut) nCh3GeV++;
457 if(fPt > fVeryHighPtCut) nCh10GeV++;
459 if(track->Charge() < 0) {
461 if(fPt > fLowPtCut) nCh1GeV++;
462 if(fPt > fHighPtCut) nCh3GeV++;
463 if(fPt > fVeryHighPtCut) nCh10GeV++;
465 if(track->Charge() == 0) nNeutr++;
467 const Double32_t *prob = track->PID();
469 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
470 if(rcc == 0.0) continue;
473 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
476 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
478 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
480 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
482 if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) {
484 if(fPt > fLowPtCut) nMu1GeV++;
485 if(fPt > fHighPtCut) nMu3GeV++;
486 if(fPt > fVeryHighPtCut) nMu10GeV++;
489 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
491 if(fPt > fLowPtCut) nEl1GeV++;
492 if(fPt > fHighPtCut) nEl3GeV++;
493 if(fPt > fVeryHighPtCut) nEl10GeV++;
496 totalP += track->P();
500 // Fill the event tags
502 meanPt = meanPt/ntrack;
504 evTag->SetEventId(iEventNumber+1);
505 evTag->SetGUID(fguid);
507 evTag->SetTURL(fturl);
508 evTag->SetSize(size);
510 evTag->SetNumOfTracks(nTracks);
511 evTag->SetNumOfPosTracks(nPos);
512 evTag->SetNumOfNegTracks(nNeg);
513 evTag->SetNumOfNeutrTracks(nNeutr);
515 evTag->SetNumOfV0s(nV0s);
516 evTag->SetNumOfCascades(nCascades);
517 evTag->SetNumOfKinks(nKinks);
519 evTag->SetNumOfProtons(nProtons);
520 evTag->SetNumOfKaons(nKaons);
521 evTag->SetNumOfPions(nPions);
522 evTag->SetNumOfMuons(nMuons);
523 evTag->SetNumOfElectrons(nElectrons);
524 evTag->SetNumOfPhotons(nGamas);
525 evTag->SetNumOfPi0s(nPi0s);
526 evTag->SetNumOfNeutrons(nNeutrons);
527 evTag->SetNumOfKaon0s(nK0s);
529 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
530 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
531 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
532 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
533 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
534 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
535 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
536 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
537 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
539 evTag->SetTotalMomentum(totalP);
540 evTag->SetMeanPt(meanPt);
541 evTag->SetMaxPt(maxPt);
542 tag->AddEventTag(*evTag);
545 TString localFileName = "Run"; localFileName += tag->GetRunId();
546 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_";
547 localFileName += lastEvent; localFileName += "."; localFileName += Counter;
548 localFileName += ".AOD.tag.root";
553 fileName = localFileName.Data();
554 AliInfo(Form("Writing AOD tags to local file: %s",fileName.Data()));
556 else if(fStorage == 1) {
557 TString alienLocation = "/alien";
558 alienLocation += gGrid->Pwd();
559 alienLocation += fgridpath.Data();
560 alienLocation += "/";
561 alienLocation += localFileName;
562 alienLocation += "?se=";
563 alienLocation += fSE.Data();
564 fileName = alienLocation.Data();
565 AliInfo(Form("Writing AOD tags to grid file: %s",fileName.Data()));
568 TFile* ftag = TFile::Open(fileName, "recreate");
577 //_____________________________________________________________________________
578 void AliAODTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
579 //private method that creates tag files
580 Float_t fLowPtCut = 1.0;
581 Float_t fHighPtCut = 3.0;
582 Float_t fVeryHighPtCut = 10.0;
585 Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.};
587 // Creates the tags for all the events in a given AOD file
589 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
590 Int_t nPos, nNeg, nNeutr;
591 Int_t nKinks, nV0s, nCascades;
592 Int_t nK0s, nNeutrons, nPi0s, nGamas;
593 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
594 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
595 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
596 Float_t maxPt = .0, meanPt = .0, totalP = .0;
598 AliRunTag *tag = new AliRunTag();
599 TTree ttag("T","A Tree with event tags");
600 TBranch * btag = ttag.Branch("AliTAG", &tag);
601 btag->SetCompressionLevel(9);
603 //reading the esd tag file
604 TChain *oldTagTree = new TChain("T");
605 const char * tagPattern = "ESD.tag";
606 // Open the working directory
607 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
608 const char * name = 0x0;
609 // Add all files matching *pattern* to the chain
610 while((name = gSystem->GetDirEntry(dirp))) {
611 if (strstr(name,tagPattern)) oldTagTree->Add(name);
613 AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries()));
615 //reading the esd tag file
616 AliRunTag *oldtag = new AliRunTag();
618 oldTagTree->SetBranchAddress("AliTAG",&oldtag);
619 oldTagTree->GetEntry(0);
620 tag->CopyStandardContent(oldtag);
621 const TClonesArray *evTagList = oldtag->GetEventTags();
623 AliInfo(Form("Creating the AOD tags......."));
625 if (!file || !file->IsOpen()) {
626 AliError(Form("opening failed"));
630 TTree *aodTree = (TTree*)file->Get("aodTree");
631 AliAODEvent *aod = new AliAODEvent();
632 aod->ReadFromTree(aodTree);
633 Int_t firstEvent = 0, lastEvent = 0;
634 lastEvent = (Int_t)aodTree->GetEntries();
637 Int_t nEvents = aodTree->GetEntries();
638 for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) {
639 AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber);
641 nPos = 0; nNeg = 0; nNeutr =0;
642 nKinks = 0; nV0s = 0; nCascades = 0;
643 nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0;
644 nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0;
645 nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
646 nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
647 nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
648 maxPt = .0; meanPt = .0; totalP = .0;
651 aodTree->GetEvent(iEventNumber);
654 aod->GetStdContent();
656 Int_t nTracks = aod->GetNTracks();
657 // loop over vertices
658 Int_t nVtxs = aod->GetNVertices();
659 for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
661 AliAODVertex *vertex = aod->GetVertex(nVtx);
662 if(vertex->GetType() == 1) nKinks += 1;
663 if(vertex->GetType() == 2) nV0s += 1;
664 if(vertex->GetType() == 3) nCascades += 1;
666 for (Int_t nTr = 0; nTr < nTracks; nTr++) {
667 AliAODTrack *track = aod->GetTrack(nTr);
669 Double_t fPt = track->Pt();
670 if(fPt > maxPt) maxPt = fPt;
671 if(track->Charge() > 0) {
673 if(fPt > fLowPtCut) nCh1GeV++;
674 if(fPt > fHighPtCut) nCh3GeV++;
675 if(fPt > fVeryHighPtCut) nCh10GeV++;
677 if(track->Charge() < 0) {
679 if(fPt > fLowPtCut) nCh1GeV++;
680 if(fPt > fHighPtCut) nCh3GeV++;
681 if(fPt > fVeryHighPtCut) nCh10GeV++;
683 if(track->Charge() == 0) nNeutr++;
686 const Double32_t *prob = track->PID();
688 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
689 if(rcc == 0.0) continue;
692 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
695 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
697 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
699 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
701 if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) {
703 if(fPt > fLowPtCut) nMu1GeV++;
704 if(fPt > fHighPtCut) nMu3GeV++;
705 if(fPt > fVeryHighPtCut) nMu10GeV++;
708 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
710 if(fPt > fLowPtCut) nEl1GeV++;
711 if(fPt > fHighPtCut) nEl3GeV++;
712 if(fPt > fVeryHighPtCut) nEl10GeV++;
715 totalP += track->P();
719 // Fill the event tags
721 meanPt = meanPt/ntrack;
723 evTag->SetEventId(iEventNumber+1);
724 evTag->SetPath(filepath);
726 evTag->SetNumOfTracks(nTracks);
727 evTag->SetNumOfPosTracks(nPos);
728 evTag->SetNumOfNegTracks(nNeg);
729 evTag->SetNumOfNeutrTracks(nNeutr);
731 evTag->SetNumOfV0s(nV0s);
732 evTag->SetNumOfCascades(nCascades);
733 evTag->SetNumOfKinks(nKinks);
735 evTag->SetNumOfProtons(nProtons);
736 evTag->SetNumOfKaons(nKaons);
737 evTag->SetNumOfPions(nPions);
738 evTag->SetNumOfMuons(nMuons);
739 evTag->SetNumOfElectrons(nElectrons);
740 evTag->SetNumOfPhotons(nGamas);
741 evTag->SetNumOfPi0s(nPi0s);
742 evTag->SetNumOfNeutrons(nNeutrons);
743 evTag->SetNumOfKaon0s(nK0s);
745 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
746 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
747 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
748 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
749 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
750 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
751 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
752 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
753 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
755 evTag->SetTotalMomentum(totalP);
756 evTag->SetMeanPt(meanPt);
757 evTag->SetMaxPt(maxPt);
758 tag->AddEventTag(*evTag);
761 TString localFileName = "Run"; localFileName += tag->GetRunId();
762 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_";
763 localFileName += lastEvent; localFileName += "."; localFileName += Counter;
764 localFileName += ".AOD.tag.root";
769 fileName = localFileName.Data();
770 AliInfo(Form("Writing AOD tags to local file: %s",fileName.Data()));
772 else if(fStorage == 1) {
773 TString alienLocation = "/alien";
774 alienLocation += gGrid->Pwd();
775 alienLocation += fgridpath.Data();
776 alienLocation += "/";
777 alienLocation += localFileName;
778 alienLocation += "?se=";
779 alienLocation += fSE.Data();
780 fileName = alienLocation.Data();
781 AliInfo(Form("Writing AOD tags to grid file: %s",fileName.Data()));
784 TFile* ftag = TFile::Open(fileName, "recreate");