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() {
52 //==============Default constructor for a AliTagCreator==================
58 //______________________________________________________________________________
59 AliTagCreator::~AliTagCreator() {
60 //================Default destructor for a AliTagCreator=======================
63 //______________________________________________________________________________
64 void AliTagCreator::SetStorage(Int_t storage) {
65 // Sets correctly the storage: 0 for local, 1 for GRID
68 AliInfo(Form("Tags will be stored locally...."));
70 AliInfo(Form("Tags will be stored in the grid...."));
71 if((fStorage != 0)&&(fStorage != 1))
73 AliInfo(Form("Storage was not properly set!!!"));
79 //______________________________________________________________________________
80 Bool_t AliTagCreator::ReadGridCollection(TGridResult *fresult) {
81 // Reads the entry of the TGridResult and creates the tags
82 Int_t nEntries = fresult->GetEntries();
91 for(Int_t i = 0; i < nEntries; i++) {
92 alienUrl = fresult->GetKey(i,"turl");
93 guid = fresult->GetKey(i,"guid");
94 if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size"));
95 md5 = fresult->GetKey(i,"md5");
96 turl = fresult->GetKey(i,"turl");
97 if(md5 && !strlen(guid)) md5 = 0;
98 if(guid && !strlen(guid)) guid = 0;
100 TFile *f = TFile::Open(alienUrl,"READ");
101 CreateTag(f,guid,md5,turl,size,counter);
110 //______________________________________________________________________________
111 Bool_t AliTagCreator::ReadLocalCollection(const char *localpath) {
112 // Checks the different subdirs of the given local path and in the
113 // case where it finds an AliESDs.root file it creates the tags
115 void *dira = gSystem->OpenDirectory(localpath);
117 const char * dirname = 0x0;
118 const char * filename = 0x0;
119 const char * pattern = "AliESDs.root";
122 while(dirname = gSystem->GetDirEntry(dira)) {
123 sprintf(fPath,"%s/%s",localpath,dirname);
124 void *dirb = gSystem->OpenDirectory(fPath);
125 while(filename = gSystem->GetDirEntry(dirb)) {
126 if(strstr(filename,pattern)) {
127 TString fESDFileName;
128 fESDFileName = fPath;
130 fESDFileName += pattern;
131 TFile *f = TFile::Open(fESDFileName,"READ");
132 CreateTag(f,fESDFileName,counter);
138 }//child directory's entry loop
139 }//parent directory's entry loop
144 //______________________________________________________________________________
145 Bool_t AliTagCreator::ReadCAFCollection(const char *filename) {
146 // Temporary solution for CAF: Takes as an input the ascii file that
147 // lists the ESDs stored in the SE of the CAF and creates the tags.
149 // Open the input stream
155 // Read the input list of files and add them to the chain
158 if (!esdfile.Contains("root")) continue; // protection
159 TFile *f = TFile::Open(esdfile,"READ");
160 CreateTag(f,esdfile,counter);
171 //__________________________________________________________________________
172 Bool_t AliTagCreator::MergeTags() {
173 //Merges the tags and stores the merged tag file
174 //locally if fStorage=0 or in the grid if fStorage=1
175 AliInfo(Form("Merging tags....."));
176 TChain *fgChain = new TChain("T");
179 const char * tagPattern = "tag";
180 // Open the working directory
181 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
182 const char * name = 0x0;
183 // Add all files matching *pattern* to the chain
184 while((name = gSystem->GetDirEntry(dirp))) {
185 if (strstr(name,tagPattern))
188 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
191 else if(fStorage == 1) {
192 TString alienLocation = gGrid->Pwd();
193 alienLocation += fgridpath.Data();
194 alienLocation += "/";
196 TGridResult *tagresult = gGrid->Query(alienLocation,"*tag.root","","");
197 Int_t nEntries = tagresult->GetEntries();
198 for(Int_t i = 0; i < nEntries; i++) {
199 TString alienUrl = tagresult->GetKey(i,"turl");
200 fgChain->Add(alienUrl);
202 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
205 AliRunTag *tag = new AliRunTag;
206 AliEventTag *evTag = new AliEventTag;
207 fgChain->SetBranchAddress("AliTAG",&tag);
209 //Defining new tag objects
210 AliRunTag *newTag = new AliRunTag();
211 TTree ttag("T","A Tree with event tags");
212 TBranch * btag = ttag.Branch("AliTAG", &newTag);
213 btag->SetCompressionLevel(9);
214 for(Int_t iTagFiles = 0; iTagFiles < fgChain->GetEntries(); iTagFiles++) {
215 fgChain->GetEntry(iTagFiles);
216 newTag->SetRunId(tag->GetRunId());
217 const TClonesArray *tagList = tag->GetEventTags();
218 for(Int_t j = 0; j < tagList->GetEntries(); j++) {
219 evTag = (AliEventTag *) tagList->At(j);
220 newTag->AddEventTag(*evTag);
226 TString localFileName = "Run"; localFileName += tag->GetRunId();
227 localFileName += ".Merged"; localFileName += ".ESD.tag.root";
229 TString filename = 0x0;
232 filename = localFileName.Data();
233 AliInfo(Form("Writing merged tags to local file: %s",filename.Data()));
235 else if(fStorage == 1) {
236 TString alienFileName = "/alien";
237 alienFileName += gGrid->Pwd();
238 alienFileName += fgridpath.Data();
239 alienFileName += "/";
240 alienFileName += localFileName;
241 alienFileName += "?se=";
242 alienFileName += fSE.Data();
243 filename = alienFileName.Data();
244 AliInfo(Form("Writing merged tags to grid file: %s",filename.Data()));
247 TFile* ftag = TFile::Open(filename, "recreate");
258 //_____________________________________________________________________________
259 void AliTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
260 //private method that creates tag files
261 TString fguid = guid;
263 TString fturl = turl;
267 Double_t fMUONMASS = 0.105658369;
270 Double_t fThetaX, fThetaY, fPyz, fChisquare;
271 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
273 TLorentzVector fEPvector;
275 Float_t fZVertexCut = 10.0;
276 Float_t fRhoVertexCut = 2.0;
278 Float_t fLowPtCut = 1.0;
279 Float_t fHighPtCut = 3.0;
280 Float_t fVeryHighPtCut = 10.0;
283 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
285 // Creates the tags for all the events in a given ESD file
286 Bool_t fIsSim = kTRUE;
288 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
289 Int_t nPos, nNeg, nNeutr;
290 Int_t nK0s, nNeutrons, nPi0s, nGamas;
291 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
292 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
293 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
294 Float_t maxPt = .0, meanPt = .0, totalP = .0;
296 Int_t iRunNumber = 0;
299 AliRunTag *tag = new AliRunTag();
300 AliEventTag *evTag = new AliEventTag();
301 TTree ttag("T","A Tree with event tags");
302 TBranch * btag = ttag.Branch("AliTAG", &tag);
303 btag->SetCompressionLevel(9);
305 AliInfo(Form("Creating the tags......."));
307 Int_t firstEvent = 0,lastEvent = 0;
308 TTree *t = (TTree*) file->Get("esdTree");
309 TBranch * b = t->GetBranch("ESD");
314 Int_t iInitRunNumber = esd->GetRunNumber();
316 Int_t iNumberOfEvents = b->GetEntries();
317 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
345 b->GetEntry(iEventNumber);
346 iRunNumber = esd->GetRunNumber();
347 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
348 const AliESDVertex * vertexIn = esd->GetVertex();
349 fVertexName = vertexIn->GetName();
350 if(fVertexName == "default") fVertexflag = 0;
352 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
353 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
354 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
355 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
356 UInt_t status = esdTrack->GetStatus();
358 //select only tracks with ITS refit
359 if ((status&AliESDtrack::kITSrefit)==0) continue;
360 //select only tracks with TPC refit
361 if ((status&AliESDtrack::kTPCrefit)==0) continue;
363 //select only tracks with the "combined PID"
364 if ((status&AliESDtrack::kESDpid)==0) continue;
366 esdTrack->GetPxPyPz(p);
367 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
368 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
371 if(fPt > maxPt) maxPt = fPt;
373 if(esdTrack->GetSign() > 0) {
375 if(fPt > fLowPtCut) nCh1GeV++;
376 if(fPt > fHighPtCut) nCh3GeV++;
377 if(fPt > fVeryHighPtCut) nCh10GeV++;
379 if(esdTrack->GetSign() < 0) {
381 if(fPt > fLowPtCut) nCh1GeV++;
382 if(fPt > fHighPtCut) nCh3GeV++;
383 if(fPt > fVeryHighPtCut) nCh10GeV++;
385 if(esdTrack->GetSign() == 0) nNeutr++;
389 esdTrack->GetESDpid(prob);
392 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
393 if(rcc == 0.0) continue;
396 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
399 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
401 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
403 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
405 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
407 if(fPt > fLowPtCut) nEl1GeV++;
408 if(fPt > fHighPtCut) nEl3GeV++;
409 if(fPt > fVeryHighPtCut) nEl10GeV++;
417 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
418 // loop over all reconstructed tracks (also first track of combination)
419 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
420 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
421 if (muonTrack == 0x0) continue;
423 // Coordinates at vertex
424 fZ = muonTrack->GetZ();
425 fY = muonTrack->GetBendingCoor();
426 fX = muonTrack->GetNonBendingCoor();
428 fThetaX = muonTrack->GetThetaX();
429 fThetaY = muonTrack->GetThetaY();
431 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
432 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
433 fPxRec = fPzRec * TMath::Tan(fThetaX);
434 fPyRec = fPzRec * TMath::Tan(fThetaY);
435 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
437 //ChiSquare of the track if needed
438 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
439 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
440 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
442 // total number of muons inside a vertex cut
443 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
445 if(fEPvector.Pt() > fLowPtCut) {
447 if(fEPvector.Pt() > fHighPtCut) {
449 if (fEPvector.Pt() > fVeryHighPtCut) {
457 // Fill the event tags
458 if(ntrack != 0) meanPt = meanPt/ntrack;
460 evTag->SetEventId(iEventNumber+1);
461 evTag->SetGUID(fguid);
463 evTag->SetTURL(fturl);
464 evTag->SetSize(size);
465 evTag->SetVertexX(vertexIn->GetXv());
466 evTag->SetVertexY(vertexIn->GetYv());
467 evTag->SetVertexZ(vertexIn->GetZv());
468 evTag->SetVertexZError(vertexIn->GetZRes());
469 evTag->SetVertexFlag(fVertexflag);
471 evTag->SetT0VertexZ(esd->GetT0zVertex());
473 evTag->SetTriggerMask(esd->GetTriggerMask());
474 evTag->SetTriggerCluster(esd->GetTriggerCluster());
476 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
477 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
478 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
479 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
480 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
481 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
484 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
485 evTag->SetNumOfPosTracks(nPos);
486 evTag->SetNumOfNegTracks(nNeg);
487 evTag->SetNumOfNeutrTracks(nNeutr);
489 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
490 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
491 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
492 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
494 evTag->SetNumOfProtons(nProtons);
495 evTag->SetNumOfKaons(nKaons);
496 evTag->SetNumOfPions(nPions);
497 evTag->SetNumOfMuons(nMuons);
498 evTag->SetNumOfElectrons(nElectrons);
499 evTag->SetNumOfPhotons(nGamas);
500 evTag->SetNumOfPi0s(nPi0s);
501 evTag->SetNumOfNeutrons(nNeutrons);
502 evTag->SetNumOfKaon0s(nK0s);
504 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
505 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
506 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
507 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
508 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
509 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
510 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
511 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
512 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
514 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
515 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
517 evTag->SetTotalMomentum(totalP);
518 evTag->SetMeanPt(meanPt);
519 evTag->SetMaxPt(maxPt);
521 tag->SetRunId(iInitRunNumber);
522 if(fIsSim) tag->SetDataType(0);
523 else tag->SetDataType(1);
524 tag->AddEventTag(*evTag);
526 lastEvent = iNumberOfEvents;
533 TString localFileName = "Run"; localFileName += tag->GetRunId();
534 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
535 localFileName += ".ESD.tag.root";
540 fileName = localFileName.Data();
541 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
543 else if(fStorage == 1) {
544 TString alienLocation = "/alien";
545 alienLocation += gGrid->Pwd();
546 alienLocation += fgridpath.Data();
547 alienLocation += "/";
548 alienLocation += localFileName;
549 alienLocation += "?se=";
550 alienLocation += fSE.Data();
551 fileName = alienLocation.Data();
552 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
555 TFile* ftag = TFile::Open(fileName, "recreate");
566 //_____________________________________________________________________________
567 void AliTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
568 //private method that creates tag files
572 Double_t fMUONMASS = 0.105658369;
575 Double_t fThetaX, fThetaY, fPyz, fChisquare;
576 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
578 TLorentzVector fEPvector;
580 Float_t fZVertexCut = 10.0;
581 Float_t fRhoVertexCut = 2.0;
583 Float_t fLowPtCut = 1.0;
584 Float_t fHighPtCut = 3.0;
585 Float_t fVeryHighPtCut = 10.0;
588 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
590 // Creates the tags for all the events in a given ESD file
591 Bool_t fIsSim = kTRUE;
593 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
594 Int_t nPos, nNeg, nNeutr;
595 Int_t nK0s, nNeutrons, nPi0s, nGamas;
596 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
597 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
598 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
599 Float_t maxPt = .0, meanPt = .0, totalP = .0;
601 Int_t iRunNumber = 0;
604 AliRunTag *tag = new AliRunTag();
605 AliEventTag *evTag = new AliEventTag();
606 TTree ttag("T","A Tree with event tags");
607 TBranch * btag = ttag.Branch("AliTAG", &tag);
608 btag->SetCompressionLevel(9);
610 AliInfo(Form("Creating the tags......."));
612 Int_t firstEvent = 0,lastEvent = 0;
614 TTree *t = (TTree*) file->Get("esdTree");
615 TBranch * b = t->GetBranch("ESD");
620 Int_t iInitRunNumber = esd->GetRunNumber();
622 Int_t iNumberOfEvents = b->GetEntries();
623 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
651 b->GetEntry(iEventNumber);
652 iRunNumber = esd->GetRunNumber();
653 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
654 const AliESDVertex * vertexIn = esd->GetVertex();
655 fVertexName = vertexIn->GetName();
656 if(fVertexName == "default") fVertexflag = 0;
658 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
659 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
660 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
661 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
662 UInt_t status = esdTrack->GetStatus();
664 //select only tracks with ITS refit
665 if ((status&AliESDtrack::kITSrefit)==0) continue;
666 //select only tracks with TPC refit
667 if ((status&AliESDtrack::kTPCrefit)==0) continue;
669 //select only tracks with the "combined PID"
670 if ((status&AliESDtrack::kESDpid)==0) continue;
672 esdTrack->GetPxPyPz(p);
673 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
674 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
677 if(fPt > maxPt) maxPt = fPt;
679 if(esdTrack->GetSign() > 0) {
681 if(fPt > fLowPtCut) nCh1GeV++;
682 if(fPt > fHighPtCut) nCh3GeV++;
683 if(fPt > fVeryHighPtCut) nCh10GeV++;
685 if(esdTrack->GetSign() < 0) {
687 if(fPt > fLowPtCut) nCh1GeV++;
688 if(fPt > fHighPtCut) nCh3GeV++;
689 if(fPt > fVeryHighPtCut) nCh10GeV++;
691 if(esdTrack->GetSign() == 0) nNeutr++;
695 esdTrack->GetESDpid(prob);
698 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
699 if(rcc == 0.0) continue;
702 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
705 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
707 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
709 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
711 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
713 if(fPt > fLowPtCut) nEl1GeV++;
714 if(fPt > fHighPtCut) nEl3GeV++;
715 if(fPt > fVeryHighPtCut) nEl10GeV++;
723 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
724 // loop over all reconstructed tracks (also first track of combination)
725 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
726 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
727 if (muonTrack == 0x0) continue;
729 // Coordinates at vertex
730 fZ = muonTrack->GetZ();
731 fY = muonTrack->GetBendingCoor();
732 fX = muonTrack->GetNonBendingCoor();
734 fThetaX = muonTrack->GetThetaX();
735 fThetaY = muonTrack->GetThetaY();
737 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
738 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
739 fPxRec = fPzRec * TMath::Tan(fThetaX);
740 fPyRec = fPzRec * TMath::Tan(fThetaY);
741 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
743 //ChiSquare of the track if needed
744 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
745 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
746 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
748 // total number of muons inside a vertex cut
749 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
751 if(fEPvector.Pt() > fLowPtCut) {
753 if(fEPvector.Pt() > fHighPtCut) {
755 if (fEPvector.Pt() > fVeryHighPtCut) {
763 // Fill the event tags
764 if(ntrack != 0) meanPt = meanPt/ntrack;
766 evTag->SetEventId(iEventNumber+1);
767 evTag->SetPath(filepath);
769 evTag->SetVertexX(vertexIn->GetXv());
770 evTag->SetVertexY(vertexIn->GetYv());
771 evTag->SetVertexZ(vertexIn->GetZv());
772 evTag->SetVertexZError(vertexIn->GetZRes());
773 evTag->SetVertexFlag(fVertexflag);
775 evTag->SetT0VertexZ(esd->GetT0zVertex());
777 evTag->SetTriggerMask(esd->GetTriggerMask());
778 evTag->SetTriggerCluster(esd->GetTriggerCluster());
780 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
781 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
782 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
783 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
784 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
785 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
788 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
789 evTag->SetNumOfPosTracks(nPos);
790 evTag->SetNumOfNegTracks(nNeg);
791 evTag->SetNumOfNeutrTracks(nNeutr);
793 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
794 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
795 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
796 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
798 evTag->SetNumOfProtons(nProtons);
799 evTag->SetNumOfKaons(nKaons);
800 evTag->SetNumOfPions(nPions);
801 evTag->SetNumOfMuons(nMuons);
802 evTag->SetNumOfElectrons(nElectrons);
803 evTag->SetNumOfPhotons(nGamas);
804 evTag->SetNumOfPi0s(nPi0s);
805 evTag->SetNumOfNeutrons(nNeutrons);
806 evTag->SetNumOfKaon0s(nK0s);
808 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
809 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
810 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
811 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
812 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
813 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
814 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
815 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
816 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
818 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
819 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
821 evTag->SetTotalMomentum(totalP);
822 evTag->SetMeanPt(meanPt);
823 evTag->SetMaxPt(maxPt);
825 tag->SetRunId(iInitRunNumber);
826 if(fIsSim) tag->SetDataType(0);
827 else tag->SetDataType(1);
828 tag->AddEventTag(*evTag);
830 lastEvent = iNumberOfEvents;
837 TString localFileName = "Run"; localFileName += tag->GetRunId();
838 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
839 localFileName += ".ESD.tag.root";
844 fileName = localFileName.Data();
845 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
847 else if(fStorage == 1) {
848 TString alienLocation = "/alien";
849 alienLocation += gGrid->Pwd();
850 alienLocation += fgridpath.Data();
851 alienLocation += "/";
852 alienLocation += localFileName;
853 alienLocation += "?se=";
854 alienLocation += fSE.Data();
855 fileName = alienLocation.Data();
856 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
859 TFile* ftag = TFile::Open(fileName, "recreate");