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 // AliTagCreator 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>
28 #include <TSystemDirectory.h>
30 #include <TLorentzVector.h>
34 #include <TGridResult.h>
37 #include "AliRunTag.h"
38 #include "AliEventTag.h"
40 #include "AliESDVertex.h"
44 #include "AliTagCreator.h"
47 ClassImp(AliTagCreator)
50 //______________________________________________________________________________
51 AliTagCreator::AliTagCreator() :
53 fSE("ALICE::CERN::se01"),
57 //==============Default constructor for a AliTagCreator==================
60 //______________________________________________________________________________
61 AliTagCreator::~AliTagCreator() {
62 //================Default destructor for a AliTagCreator=======================
65 //______________________________________________________________________________
66 void AliTagCreator::SetStorage(Int_t storage) {
67 // Sets correctly the storage: 0 for local, 1 for GRID
70 AliInfo(Form("Tags will be stored locally...."));
72 AliInfo(Form("Tags will be stored in the grid...."));
73 if((fStorage != 0)&&(fStorage != 1))
75 AliInfo(Form("Storage was not properly set!!!"));
81 //______________________________________________________________________________
82 Bool_t AliTagCreator::ReadGridCollection(TGridResult *fresult) {
83 // Reads the entry of the TGridResult and creates the tags
84 Int_t nEntries = fresult->GetEntries();
93 for(Int_t i = 0; i < nEntries; i++) {
94 alienUrl = fresult->GetKey(i,"turl");
95 guid = fresult->GetKey(i,"guid");
96 if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size"));
97 md5 = fresult->GetKey(i,"md5");
98 turl = fresult->GetKey(i,"turl");
99 if(md5 && !strlen(guid)) md5 = 0;
100 if(guid && !strlen(guid)) guid = 0;
102 TFile *f = TFile::Open(alienUrl,"READ");
103 CreateTag(f,guid,md5,turl,size,counter);
112 //______________________________________________________________________________
113 Bool_t AliTagCreator::ReadLocalCollection(const char *localpath) {
114 // Checks the different subdirs of the given local path and in the
115 // case where it finds an AliESDs.root file it creates the tags
117 void *dira = gSystem->OpenDirectory(localpath);
119 const char * dirname = 0x0;
120 const char * filename = 0x0;
121 const char * pattern = "AliESDs.root";
124 while((dirname = gSystem->GetDirEntry(dira))) {
125 sprintf(fPath,"%s/%s",localpath,dirname);
126 void *dirb = gSystem->OpenDirectory(fPath);
127 while((filename = gSystem->GetDirEntry(dirb))) {
128 if(strstr(filename,pattern)) {
129 TString fESDFileName;
130 fESDFileName = fPath;
132 fESDFileName += pattern;
133 TFile *f = TFile::Open(fESDFileName,"READ");
134 CreateTag(f,fESDFileName,counter);
140 }//child directory's entry loop
141 }//parent directory's entry loop
146 //______________________________________________________________________________
147 Bool_t AliTagCreator::ReadCAFCollection(const char *filename) {
148 // Temporary solution for CAF: Takes as an input the ascii file that
149 // lists the ESDs stored in the SE of the CAF and creates the tags.
151 // Open the input stream
157 // Read the input list of files and add them to the chain
160 if (!esdfile.Contains("root")) continue; // protection
161 TFile *f = TFile::Open(esdfile,"READ");
162 CreateTag(f,esdfile,counter);
173 //__________________________________________________________________________
174 Bool_t AliTagCreator::MergeTags() {
175 //Merges the tags and stores the merged tag file
176 //locally if fStorage=0 or in the grid if fStorage=1
177 AliInfo(Form("Merging tags....."));
178 TChain *fgChain = new TChain("T");
181 const char * tagPattern = "tag";
182 // Open the working directory
183 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
184 const char * name = 0x0;
185 // Add all files matching *pattern* to the chain
186 while((name = gSystem->GetDirEntry(dirp))) {
187 if (strstr(name,tagPattern))
190 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
193 else if(fStorage == 1) {
194 TString alienLocation = gGrid->Pwd();
195 alienLocation += fgridpath.Data();
196 alienLocation += "/";
198 TGridResult *tagresult = gGrid->Query(alienLocation,"*tag.root","","");
199 Int_t nEntries = tagresult->GetEntries();
200 for(Int_t i = 0; i < nEntries; i++) {
201 TString alienUrl = tagresult->GetKey(i,"turl");
202 fgChain->Add(alienUrl);
204 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
207 AliRunTag *tag = new AliRunTag;
208 AliEventTag *evTag = new AliEventTag;
209 fgChain->SetBranchAddress("AliTAG",&tag);
211 //Defining new tag objects
212 AliRunTag *newTag = new AliRunTag();
213 TTree ttag("T","A Tree with event tags");
214 TBranch * btag = ttag.Branch("AliTAG", &newTag);
215 btag->SetCompressionLevel(9);
216 for(Int_t iTagFiles = 0; iTagFiles < fgChain->GetEntries(); iTagFiles++) {
217 fgChain->GetEntry(iTagFiles);
218 newTag->SetRunId(tag->GetRunId());
219 const TClonesArray *tagList = tag->GetEventTags();
220 for(Int_t j = 0; j < tagList->GetEntries(); j++) {
221 evTag = (AliEventTag *) tagList->At(j);
222 newTag->AddEventTag(*evTag);
228 TString localFileName = "Run"; localFileName += tag->GetRunId();
229 localFileName += ".Merged"; localFileName += ".ESD.tag.root";
231 TString filename = 0x0;
234 filename = localFileName.Data();
235 AliInfo(Form("Writing merged tags to local file: %s",filename.Data()));
237 else if(fStorage == 1) {
238 TString alienFileName = "/alien";
239 alienFileName += gGrid->Pwd();
240 alienFileName += fgridpath.Data();
241 alienFileName += "/";
242 alienFileName += localFileName;
243 alienFileName += "?se=";
244 alienFileName += fSE.Data();
245 filename = alienFileName.Data();
246 AliInfo(Form("Writing merged tags to grid file: %s",filename.Data()));
249 TFile* ftag = TFile::Open(filename, "recreate");
260 //__________________________________________________________________________
261 Bool_t AliTagCreator::MergeTags(TGridResult *result) {
262 //Merges the tags that are listed in the TGridResult
263 AliInfo(Form("Merging tags....."));
264 TChain *fgChain = new TChain("T");
266 Int_t nEntries = result->GetEntries();
269 for(Int_t i = 0; i < nEntries; i++) {
270 alienUrl = result->GetKey(i,"turl");
271 fgChain->Add(alienUrl);
273 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
274 AliRunTag *tag = new AliRunTag;
275 AliEventTag *evTag = new AliEventTag;
276 fgChain->SetBranchAddress("AliTAG",&tag);
278 //Defining new tag objects
279 AliRunTag *newTag = new AliRunTag();
280 TTree ttag("T","A Tree with event tags");
281 TBranch * btag = ttag.Branch("AliTAG", &newTag);
282 btag->SetCompressionLevel(9);
283 for(Int_t iTagFiles = 0; iTagFiles < fgChain->GetEntries(); iTagFiles++) {
284 fgChain->GetEntry(iTagFiles);
285 newTag->SetRunId(tag->GetRunId());
286 const TClonesArray *tagList = tag->GetEventTags();
287 for(Int_t j = 0; j < tagList->GetEntries(); j++) {
288 evTag = (AliEventTag *) tagList->At(j);
289 newTag->AddEventTag(*evTag);
295 TString localFileName = "Run"; localFileName += tag->GetRunId();
296 localFileName += ".Merged"; localFileName += ".ESD.tag.root";
298 TString filename = 0x0;
301 filename = localFileName.Data();
302 AliInfo(Form("Writing merged tags to local file: %s",filename.Data()));
304 else if(fStorage == 1) {
305 TString alienFileName = "/alien";
306 alienFileName += gGrid->Pwd();
307 alienFileName += fgridpath.Data();
308 alienFileName += "/";
309 alienFileName += localFileName;
310 alienFileName += "?se=";
311 alienFileName += fSE.Data();
312 filename = alienFileName.Data();
313 AliInfo(Form("Writing merged tags to grid file: %s",filename.Data()));
316 TFile* ftag = TFile::Open(filename, "recreate");
327 //_____________________________________________________________________________
328 void AliTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
329 //private method that creates tag files
330 TString fguid = guid;
332 TString fturl = turl;
336 Double_t fMUONMASS = 0.105658369;
339 Double_t fThetaX, fThetaY, fPyz, fChisquare;
340 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
342 TLorentzVector fEPvector;
344 Float_t fZVertexCut = 10.0;
345 Float_t fRhoVertexCut = 2.0;
347 Float_t fLowPtCut = 1.0;
348 Float_t fHighPtCut = 3.0;
349 Float_t fVeryHighPtCut = 10.0;
352 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
354 // Creates the tags for all the events in a given ESD file
355 Bool_t fIsSim = kTRUE;
357 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
358 Int_t nPos, nNeg, nNeutr;
359 Int_t nK0s, nNeutrons, nPi0s, nGamas;
360 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
361 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
362 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
363 Float_t maxPt = .0, meanPt = .0, totalP = .0;
365 Int_t iRunNumber = 0;
368 AliRunTag *tag = new AliRunTag();
369 AliEventTag *evTag = new AliEventTag();
370 TTree ttag("T","A Tree with event tags");
371 TBranch * btag = ttag.Branch("AliTAG", &tag);
372 btag->SetCompressionLevel(9);
374 AliInfo(Form("Creating the tags......."));
376 Int_t firstEvent = 0,lastEvent = 0;
377 TTree *t = (TTree*) file->Get("esdTree");
378 TBranch * b = t->GetBranch("ESD");
383 Int_t iInitRunNumber = esd->GetRunNumber();
385 Int_t iNumberOfEvents = b->GetEntries();
386 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
414 b->GetEntry(iEventNumber);
415 iRunNumber = esd->GetRunNumber();
416 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
417 const AliESDVertex * vertexIn = esd->GetVertex();
418 fVertexName = vertexIn->GetName();
419 if(fVertexName == "default") fVertexflag = 0;
421 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
422 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
423 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
424 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
425 UInt_t status = esdTrack->GetStatus();
427 //select only tracks with ITS refit
428 if ((status&AliESDtrack::kITSrefit)==0) continue;
429 //select only tracks with TPC refit
430 if ((status&AliESDtrack::kTPCrefit)==0) continue;
432 //select only tracks with the "combined PID"
433 if ((status&AliESDtrack::kESDpid)==0) continue;
435 esdTrack->GetPxPyPz(p);
436 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
437 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
440 if(fPt > maxPt) maxPt = fPt;
442 if(esdTrack->GetSign() > 0) {
444 if(fPt > fLowPtCut) nCh1GeV++;
445 if(fPt > fHighPtCut) nCh3GeV++;
446 if(fPt > fVeryHighPtCut) nCh10GeV++;
448 if(esdTrack->GetSign() < 0) {
450 if(fPt > fLowPtCut) nCh1GeV++;
451 if(fPt > fHighPtCut) nCh3GeV++;
452 if(fPt > fVeryHighPtCut) nCh10GeV++;
454 if(esdTrack->GetSign() == 0) nNeutr++;
458 esdTrack->GetESDpid(prob);
461 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
462 if(rcc == 0.0) continue;
465 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
468 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
470 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
472 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
474 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
476 if(fPt > fLowPtCut) nEl1GeV++;
477 if(fPt > fHighPtCut) nEl3GeV++;
478 if(fPt > fVeryHighPtCut) nEl10GeV++;
486 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
487 // loop over all reconstructed tracks (also first track of combination)
488 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
489 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
490 if (muonTrack == 0x0) continue;
492 // Coordinates at vertex
493 fZ = muonTrack->GetZ();
494 fY = muonTrack->GetBendingCoor();
495 fX = muonTrack->GetNonBendingCoor();
497 fThetaX = muonTrack->GetThetaX();
498 fThetaY = muonTrack->GetThetaY();
500 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
501 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
502 fPxRec = fPzRec * TMath::Tan(fThetaX);
503 fPyRec = fPzRec * TMath::Tan(fThetaY);
504 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
506 //ChiSquare of the track if needed
507 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
508 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
509 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
511 // total number of muons inside a vertex cut
512 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
514 if(fEPvector.Pt() > fLowPtCut) {
516 if(fEPvector.Pt() > fHighPtCut) {
518 if (fEPvector.Pt() > fVeryHighPtCut) {
526 // Fill the event tags
527 if(ntrack != 0) meanPt = meanPt/ntrack;
529 evTag->SetEventId(iEventNumber+1);
530 evTag->SetGUID(fguid);
532 evTag->SetTURL(fturl);
533 evTag->SetSize(size);
534 evTag->SetVertexX(vertexIn->GetXv());
535 evTag->SetVertexY(vertexIn->GetYv());
536 evTag->SetVertexZ(vertexIn->GetZv());
537 evTag->SetVertexZError(vertexIn->GetZRes());
538 evTag->SetVertexFlag(fVertexflag);
540 evTag->SetT0VertexZ(esd->GetT0zVertex());
542 evTag->SetTriggerMask(esd->GetTriggerMask());
543 evTag->SetTriggerCluster(esd->GetTriggerCluster());
545 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
546 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
547 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
548 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
549 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
550 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
553 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
554 evTag->SetNumOfPosTracks(nPos);
555 evTag->SetNumOfNegTracks(nNeg);
556 evTag->SetNumOfNeutrTracks(nNeutr);
558 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
559 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
560 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
561 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
563 evTag->SetNumOfProtons(nProtons);
564 evTag->SetNumOfKaons(nKaons);
565 evTag->SetNumOfPions(nPions);
566 evTag->SetNumOfMuons(nMuons);
567 evTag->SetNumOfElectrons(nElectrons);
568 evTag->SetNumOfPhotons(nGamas);
569 evTag->SetNumOfPi0s(nPi0s);
570 evTag->SetNumOfNeutrons(nNeutrons);
571 evTag->SetNumOfKaon0s(nK0s);
573 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
574 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
575 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
576 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
577 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
578 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
579 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
580 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
581 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
583 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
584 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
586 evTag->SetTotalMomentum(totalP);
587 evTag->SetMeanPt(meanPt);
588 evTag->SetMaxPt(maxPt);
590 tag->SetRunId(iInitRunNumber);
591 if(fIsSim) tag->SetDataType(0);
592 else tag->SetDataType(1);
593 tag->AddEventTag(*evTag);
595 lastEvent = iNumberOfEvents;
602 TString localFileName = "Run"; localFileName += tag->GetRunId();
603 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
604 localFileName += ".ESD.tag.root";
609 fileName = localFileName.Data();
610 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
612 else if(fStorage == 1) {
613 TString alienLocation = "/alien";
614 alienLocation += gGrid->Pwd();
615 alienLocation += fgridpath.Data();
616 alienLocation += "/";
617 alienLocation += localFileName;
618 alienLocation += "?se=";
619 alienLocation += fSE.Data();
620 fileName = alienLocation.Data();
621 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
624 TFile* ftag = TFile::Open(fileName, "recreate");
635 //_____________________________________________________________________________
636 void AliTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
637 //private method that creates tag files
641 Double_t fMUONMASS = 0.105658369;
644 Double_t fThetaX, fThetaY, fPyz, fChisquare;
645 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
647 TLorentzVector fEPvector;
649 Float_t fZVertexCut = 10.0;
650 Float_t fRhoVertexCut = 2.0;
652 Float_t fLowPtCut = 1.0;
653 Float_t fHighPtCut = 3.0;
654 Float_t fVeryHighPtCut = 10.0;
657 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
659 // Creates the tags for all the events in a given ESD file
660 Bool_t fIsSim = kTRUE;
662 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
663 Int_t nPos, nNeg, nNeutr;
664 Int_t nK0s, nNeutrons, nPi0s, nGamas;
665 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
666 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
667 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
668 Float_t maxPt = .0, meanPt = .0, totalP = .0;
670 Int_t iRunNumber = 0;
673 AliRunTag *tag = new AliRunTag();
674 AliEventTag *evTag = new AliEventTag();
675 TTree ttag("T","A Tree with event tags");
676 TBranch * btag = ttag.Branch("AliTAG", &tag);
677 btag->SetCompressionLevel(9);
679 AliInfo(Form("Creating the tags......."));
681 Int_t firstEvent = 0,lastEvent = 0;
683 TTree *t = (TTree*) file->Get("esdTree");
684 TBranch * b = t->GetBranch("ESD");
689 Int_t iInitRunNumber = esd->GetRunNumber();
691 Int_t iNumberOfEvents = b->GetEntries();
692 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
720 b->GetEntry(iEventNumber);
721 iRunNumber = esd->GetRunNumber();
722 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
723 const AliESDVertex * vertexIn = esd->GetVertex();
724 fVertexName = vertexIn->GetName();
725 if(fVertexName == "default") fVertexflag = 0;
727 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
728 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
729 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
730 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
731 UInt_t status = esdTrack->GetStatus();
733 //select only tracks with ITS refit
734 if ((status&AliESDtrack::kITSrefit)==0) continue;
735 //select only tracks with TPC refit
736 if ((status&AliESDtrack::kTPCrefit)==0) continue;
738 //select only tracks with the "combined PID"
739 if ((status&AliESDtrack::kESDpid)==0) continue;
741 esdTrack->GetPxPyPz(p);
742 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
743 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
746 if(fPt > maxPt) maxPt = fPt;
748 if(esdTrack->GetSign() > 0) {
750 if(fPt > fLowPtCut) nCh1GeV++;
751 if(fPt > fHighPtCut) nCh3GeV++;
752 if(fPt > fVeryHighPtCut) nCh10GeV++;
754 if(esdTrack->GetSign() < 0) {
756 if(fPt > fLowPtCut) nCh1GeV++;
757 if(fPt > fHighPtCut) nCh3GeV++;
758 if(fPt > fVeryHighPtCut) nCh10GeV++;
760 if(esdTrack->GetSign() == 0) nNeutr++;
764 esdTrack->GetESDpid(prob);
767 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
768 if(rcc == 0.0) continue;
771 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
774 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
776 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
778 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
780 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
782 if(fPt > fLowPtCut) nEl1GeV++;
783 if(fPt > fHighPtCut) nEl3GeV++;
784 if(fPt > fVeryHighPtCut) nEl10GeV++;
792 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
793 // loop over all reconstructed tracks (also first track of combination)
794 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
795 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
796 if (muonTrack == 0x0) continue;
798 // Coordinates at vertex
799 fZ = muonTrack->GetZ();
800 fY = muonTrack->GetBendingCoor();
801 fX = muonTrack->GetNonBendingCoor();
803 fThetaX = muonTrack->GetThetaX();
804 fThetaY = muonTrack->GetThetaY();
806 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
807 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
808 fPxRec = fPzRec * TMath::Tan(fThetaX);
809 fPyRec = fPzRec * TMath::Tan(fThetaY);
810 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
812 //ChiSquare of the track if needed
813 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
814 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
815 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
817 // total number of muons inside a vertex cut
818 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
820 if(fEPvector.Pt() > fLowPtCut) {
822 if(fEPvector.Pt() > fHighPtCut) {
824 if (fEPvector.Pt() > fVeryHighPtCut) {
832 // Fill the event tags
833 if(ntrack != 0) meanPt = meanPt/ntrack;
835 evTag->SetEventId(iEventNumber+1);
836 evTag->SetPath(filepath);
838 evTag->SetVertexX(vertexIn->GetXv());
839 evTag->SetVertexY(vertexIn->GetYv());
840 evTag->SetVertexZ(vertexIn->GetZv());
841 evTag->SetVertexZError(vertexIn->GetZRes());
842 evTag->SetVertexFlag(fVertexflag);
844 evTag->SetT0VertexZ(esd->GetT0zVertex());
846 evTag->SetTriggerMask(esd->GetTriggerMask());
847 evTag->SetTriggerCluster(esd->GetTriggerCluster());
849 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
850 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
851 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
852 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
853 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
854 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
857 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
858 evTag->SetNumOfPosTracks(nPos);
859 evTag->SetNumOfNegTracks(nNeg);
860 evTag->SetNumOfNeutrTracks(nNeutr);
862 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
863 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
864 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
865 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
867 evTag->SetNumOfProtons(nProtons);
868 evTag->SetNumOfKaons(nKaons);
869 evTag->SetNumOfPions(nPions);
870 evTag->SetNumOfMuons(nMuons);
871 evTag->SetNumOfElectrons(nElectrons);
872 evTag->SetNumOfPhotons(nGamas);
873 evTag->SetNumOfPi0s(nPi0s);
874 evTag->SetNumOfNeutrons(nNeutrons);
875 evTag->SetNumOfKaon0s(nK0s);
877 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
878 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
879 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
880 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
881 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
882 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
883 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
884 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
885 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
887 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
888 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
890 evTag->SetTotalMomentum(totalP);
891 evTag->SetMeanPt(meanPt);
892 evTag->SetMaxPt(maxPt);
894 tag->SetRunId(iInitRunNumber);
895 if(fIsSim) tag->SetDataType(0);
896 else tag->SetDataType(1);
897 tag->AddEventTag(*evTag);
899 lastEvent = iNumberOfEvents;
906 TString localFileName = "Run"; localFileName += tag->GetRunId();
907 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
908 localFileName += ".ESD.tag.root";
913 fileName = localFileName.Data();
914 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
916 else if(fStorage == 1) {
917 TString alienLocation = "/alien";
918 alienLocation += gGrid->Pwd();
919 alienLocation += fgridpath.Data();
920 alienLocation += "/";
921 alienLocation += localFileName;
922 alienLocation += "?se=";
923 alienLocation += fSE.Data();
924 fileName = alienLocation.Data();
925 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
928 TFile* ftag = TFile::Open(fileName, "recreate");