Fixes for memory problems
[u/mrichter/AliRoot.git] / STEER / AliESDTagCreator.cxx
CommitLineData
08e1a23e 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// AliESDTagCreator 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>
103d3fba 29#include <TList.h>
30#include <TObjString.h>
08e1a23e 31#include <TLorentzVector.h>
6b6e4472 32#include <TMap.h>
126f4d0c 33#include <TTimeStamp.h>
a69c1246 34#include <TRefArray.h>
08e1a23e 35
36//ROOT-AliEn
37#include <TGrid.h>
38#include <TGridResult.h>
39
40//AliRoot
41#include "AliRunTag.h"
42#include "AliEventTag.h"
43#include "AliESD.h"
44#include "AliESDEvent.h"
45#include "AliESDVertex.h"
46#include "AliLog.h"
44e45fac 47#include "AliGRPObject.h"
08e1a23e 48
49#include "AliESDTagCreator.h"
50
51
52ClassImp(AliESDTagCreator)
53
54
55//______________________________________________________________________________
56 AliESDTagCreator::AliESDTagCreator() :
103d3fba 57 AliTagCreator(),
58 fChain(new TChain("esdTree")), fGUIDList(new TList()),
517aef4e 59 fMD5List(new TList()), fTURLList(new TList()), fBranches(""),
103d3fba 60 meminfo(new MemInfo_t) {
08e1a23e 61 //==============Default constructor for a AliESDTagCreator================
62}
63
64//______________________________________________________________________________
65AliESDTagCreator::~AliESDTagCreator() {
66//================Default destructor for a AliESDTagCreator===================
103d3fba 67 delete fChain;
68 delete fGUIDList;
69 delete fMD5List;
70 delete fTURLList;
71 delete meminfo;
08e1a23e 72}
73
74//______________________________________________________________________________
75Bool_t AliESDTagCreator::ReadGridCollection(TGridResult *fresult) {
76 // Reads the entry of the TGridResult and creates the tags
77 Int_t nEntries = fresult->GetEntries();
78
79 TString alienUrl;
103d3fba 80 const char* guid;
81 const char* md5;
82 const char* turl;
08e1a23e 83 Long64_t size = -1;
84
85 Int_t counter = 0;
86 for(Int_t i = 0; i < nEntries; i++) {
87 alienUrl = fresult->GetKey(i,"turl");
88 guid = fresult->GetKey(i,"guid");
89 if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size"));
90 md5 = fresult->GetKey(i,"md5");
91 turl = fresult->GetKey(i,"turl");
92 if(md5 && !strlen(guid)) md5 = 0;
93 if(guid && !strlen(guid)) guid = 0;
103d3fba 94
95 fChain->Add(alienUrl);
96 //fGUIDList->Add(new TObjString(guid));
97 //fMD5List->Add(new TObjString(md5));
98 //fTURLList->Add(new TObjString(turl));
99
100 //TFile *f = TFile::Open(alienUrl,"READ");
101 //CreateTag(f,guid,md5,turl,size,counter);
102 //f->Close();
103 //delete f;
08e1a23e 104 counter += 1;
105 }//grid result loop
103d3fba 106
107 AliInfo(Form("ESD chain created......."));
108 AliInfo(Form("Chain entries: %d",fChain->GetEntries()));
2856e38b 109 // Switch of branches on user request
110 SwitchOffBranches();
103d3fba 111 CreateTag(fChain,"grid");
112
08e1a23e 113 return kTRUE;
114}
115
116//______________________________________________________________________________
117Bool_t AliESDTagCreator::ReadLocalCollection(const char *localpath) {
118 // Checks the different subdirs of the given local path and in the
119 // case where it finds an AliESDs.root file it creates the tags
120
121 void *dira = gSystem->OpenDirectory(localpath);
122 Char_t fPath[256];
123 const char * dirname = 0x0;
124 const char * filename = 0x0;
125 const char * pattern = "AliESDs.root";
126
127 Int_t counter = 0;
128 while((dirname = gSystem->GetDirEntry(dira))) {
129 sprintf(fPath,"%s/%s",localpath,dirname);
130 void *dirb = gSystem->OpenDirectory(fPath);
131 while((filename = gSystem->GetDirEntry(dirb))) {
132 if(strstr(filename,pattern)) {
133 TString fESDFileName;
134 fESDFileName = fPath;
135 fESDFileName += "/";
136 fESDFileName += pattern;
103d3fba 137
138 fChain->Add(fESDFileName);
139
140 //TFile *f = TFile::Open(fESDFileName,"READ");
141 //CreateTag(f,fESDFileName,counter);
142 //f->Close();
143 //delete f;
08e1a23e 144
145 counter += 1;
146 }//pattern check
147 }//child directory's entry loop
148 }//parent directory's entry loop
149
103d3fba 150 AliInfo(Form("ESD chain created......."));
151 AliInfo(Form("Chain entries: %d",fChain->GetEntries()));
2856e38b 152 // Switch of branches on user request
153 SwitchOffBranches();
103d3fba 154 CreateTag(fChain,"local");
155
08e1a23e 156 return kTRUE;
157}
158
159//______________________________________________________________________________
160Bool_t AliESDTagCreator::ReadCAFCollection(const char *filename) {
161 // Temporary solution for CAF: Takes as an input the ascii file that
162 // lists the ESDs stored in the SE of the CAF and creates the tags.
163
164 // Open the input stream
165 ifstream in;
166 in.open(filename);
167
168 Int_t counter = 0;
169 TString esdfile;
170 // Read the input list of files and add them to the chain
171 while(in.good()) {
172 in >> esdfile;
173 if (!esdfile.Contains("root")) continue; // protection
103d3fba 174
175 fChain->Add(esdfile);
176
177 //TFile *f = TFile::Open(esdfile,"READ");
178 //CreateTag(f,esdfile,counter);
179 //f->Close();
180 //delete f;
08e1a23e 181
182 counter += 1;
183 }
184
103d3fba 185 AliInfo(Form("ESD chain created......."));
186 AliInfo(Form("Chain entries: %d",fChain->GetEntries()));
2856e38b 187 // Switch of branches on user request
188 SwitchOffBranches();
103d3fba 189 CreateTag(fChain,"proof");
190
08e1a23e 191 return kTRUE;
192}
193
103d3fba 194//_____________________________________________________________________________
97721f42 195void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
103d3fba 196 //private method that creates tag files
197 TString fSession = type;
103d3fba 198 TString fguid, fmd5, fturl;
9b4aee57 199 TString fTempGuid;
103d3fba 200
201 /////////////
202 //muon code//
203 ////////////
204 Double_t fMUONMASS = 0.105658369;
205 //Variables
206 Double_t fX,fY,fZ ;
207 Double_t fThetaX, fThetaY, fPyz, fChisquare;
208 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
209 Int_t fCharge;
210 TLorentzVector fEPvector;
211
212 Float_t fZVertexCut = 10.0;
213 Float_t fRhoVertexCut = 2.0;
214
215 Float_t fLowPtCut = 1.0;
216 Float_t fHighPtCut = 3.0;
217 Float_t fVeryHighPtCut = 10.0;
218 ////////////
219
220 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
221
222 // Creates the tags for all the events in a given ESD file
223 Bool_t fIsSim = kTRUE;
224 Int_t ntrack;
ba4804f9 225 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
103d3fba 226 Int_t nPos, nNeg, nNeutr;
227 Int_t nK0s, nNeutrons, nPi0s, nGamas;
228 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
229 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
230 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 231 Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
103d3fba 232 Int_t fVertexflag;
233 Int_t iRunNumber = 0;
234 TString fVertexName;
235
103d3fba 236 //gSystem->GetMemInfo(meminfo);
237 //AliInfo(Form("After the tag initialization - Memory used: %d MB",meminfo->fMemUsed));
238 //Int_t tempmem = meminfo->fMemUsed;
239
240 AliInfo(Form("Creating the ESD tags......."));
241
242 Int_t firstEvent = 0,lastEvent = 0;
243 AliESDEvent *esd = new AliESDEvent();
97721f42 244 esd->ReadFromTree(chain);
fcc6b05f 245 AliESD *esdold = 0x0;
103d3fba 246
247 //gSystem->GetMemInfo(meminfo);
248 //AliInfo(Form("After the esd initialization - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
249 //tempmem = meminfo->fMemUsed;
250
251 Int_t iInitRunNumber = -1;
97721f42 252 chain->GetEntry(0);
253 TFile *f = chain->GetFile();
fcc6b05f 254 fTempGuid = f->GetUUID().AsString();
255
256 TString localFileName = "Run"; localFileName += esd->GetRunNumber();
97721f42 257 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += chain->GetEntries(); //localFileName += "."; localFileName += Counter;
fcc6b05f 258 localFileName += ".ESD.tag.root";
259
260 TString fileName;
a69c1246 261 TRefArray tmp;
262
fcc6b05f 263 if(fStorage == 0) {
264 fileName = localFileName.Data();
265 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
266 }
267 else if(fStorage == 1) {
268 TString alienLocation = "/alien";
269 alienLocation += gGrid->Pwd();
270 alienLocation += fgridpath.Data();
271 alienLocation += "/";
272 alienLocation += localFileName;
273 alienLocation += "?se=";
274 alienLocation += fSE.Data();
275 fileName = alienLocation.Data();
276 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
277 }
278
279 TFile* ftag = TFile::Open(fileName, "recreate");
280
281 AliRunTag *tag = new AliRunTag();
282 AliEventTag *evTag = new AliEventTag();
bc6cefce 283 TTree * ttag = new TTree("T","A Tree with event tags");
284 TBranch * btag = ttag->Branch("AliTAG", &tag);
fcc6b05f 285 btag->SetCompressionLevel(9);
286
97721f42 287 for(Int_t iEventNumber = 0; iEventNumber < chain->GetEntries(); iEventNumber++) {
103d3fba 288 ntrack = 0; nPos = 0; nNeg = 0; nNeutr =0;
289 nK0s = 0; nNeutrons = 0; nPi0s = 0;
290 nGamas = 0; nProtons = 0; nKaons = 0;
ba4804f9 291 nPions = 0; nMuons = 0; nElectrons = 0; nFWMuons = 0;
103d3fba 292 nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
293 nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
294 nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
73e1181d 295 maxPt = .0; etamaxPt = -999.; phimaxPt = -999.; meanPt = .0; totalP = .0;
103d3fba 296 fVertexflag = 1;
297
97721f42 298 chain->GetEntry(iEventNumber);
fcc6b05f 299 esdold = esd->GetAliESDOld();
300 if(esdold) esd->CopyFromOldESD();
301
97721f42 302 TFile *file = chain->GetFile();
303 const TUrl *url = file->GetEndpointUrl();
304 fguid = file->GetUUID().AsString();
103d3fba 305 if(fSession == "grid") {
306 TString fturltemp = "alien://"; fturltemp += url->GetFile();
307 fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
308 }
309 else fturl = url->GetFile();
310
311 if(iEventNumber == 0) iInitRunNumber = esd->GetRunNumber();
312 iRunNumber = esd->GetRunNumber();
313 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD - You are trying to merge different runs!!!");
314
315 const AliESDVertex * vertexIn = esd->GetVertex();
316 fVertexName = vertexIn->GetName();
317 if(fVertexName == "default") fVertexflag = 0;
318
319 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
320 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
321 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
322 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
323 UInt_t status = esdTrack->GetStatus();
324
325 //select only tracks with ITS refit
326 if ((status&AliESDtrack::kITSrefit)==0) continue;
327 //select only tracks with TPC refit
328 if ((status&AliESDtrack::kTPCrefit)==0) continue;
329
330 //select only tracks with the "combined PID"
331 if ((status&AliESDtrack::kESDpid)==0) continue;
332 Double_t p[3];
333 esdTrack->GetPxPyPz(p);
60e55aee 334 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
335 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
336 Double_t fPt = TMath::Sqrt(pt2);
103d3fba 337 totalP += momentum;
338 meanPt += fPt;
73e1181d 339 if(fPt > maxPt) {
340 maxPt = fPt;
341 phimaxPt = esdTrack->Phi();
342 etamaxPt = esdTrack->Eta();
343 }
103d3fba 344
345 if(esdTrack->GetSign() > 0) {
346 nPos++;
347 if(fPt > fLowPtCut) nCh1GeV++;
348 if(fPt > fHighPtCut) nCh3GeV++;
349 if(fPt > fVeryHighPtCut) nCh10GeV++;
350 }
351 if(esdTrack->GetSign() < 0) {
352 nNeg++;
353 if(fPt > fLowPtCut) nCh1GeV++;
354 if(fPt > fHighPtCut) nCh3GeV++;
355 if(fPt > fVeryHighPtCut) nCh10GeV++;
356 }
357 if(esdTrack->GetSign() == 0) nNeutr++;
358
359 //PID
360 Double_t prob[5];
361 esdTrack->GetESDpid(prob);
362
363 Double_t rcc = 0.0;
364 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
365 if(rcc == 0.0) continue;
366 //Bayes' formula
367 Double_t w[5];
368 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
369
370 //protons
371 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
372 //kaons
373 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
374 //pions
375 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
376 //electrons
377 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
378 nElectrons++;
379 if(fPt > fLowPtCut) nEl1GeV++;
380 if(fPt > fHighPtCut) nEl3GeV++;
381 if(fPt > fVeryHighPtCut) nEl10GeV++;
382 }
383 ntrack++;
384 }//esd track loop
385
386 /////////////
387 //muon code//
388 ////////////
389 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
390 // loop over all reconstructed tracks (also first track of combination)
391 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
392 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
393 if (muonTrack == 0x0) continue;
394
395 // Coordinates at vertex
396 fZ = muonTrack->GetZ();
397 fY = muonTrack->GetBendingCoor();
398 fX = muonTrack->GetNonBendingCoor();
399
400 fThetaX = muonTrack->GetThetaX();
401 fThetaY = muonTrack->GetThetaY();
402
403 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
404 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
405 fPxRec = fPzRec * TMath::Tan(fThetaX);
406 fPyRec = fPzRec * TMath::Tan(fThetaY);
407 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
408
409 //ChiSquare of the track if needed
410 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
411 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
412 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
413
414 // total number of muons inside a vertex cut
415 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
416 nMuons++;
ba4804f9 417 nFWMuons++;
103d3fba 418 if(fEPvector.Pt() > fLowPtCut) {
419 nMu1GeV++;
420 if(fEPvector.Pt() > fHighPtCut) {
421 nMu3GeV++;
422 if (fEPvector.Pt() > fVeryHighPtCut) {
423 nMu10GeV++;
424 }
425 }
426 }
427 }
428 }//muon track loop
429
430 // Fill the event tags
431 if(ntrack != 0) meanPt = meanPt/ntrack;
432
fcc6b05f 433 //AliInfo(Form("====================================="));
434 //AliInfo(Form("URL: %s - GUID: %s",fturl.Data(),fguid.Data()));
435 //AliInfo(Form("====================================="));
103d3fba 436
7e3c2e04 437 //First physics data
438 const AliMultiplicity *spdMult = esd->GetMultiplicity();
439 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
440 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
441 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
442
4c454ade 443 AliESDVZERO *vzeroData = esd->GetVZEROData();
444 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
445 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
446 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
447 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
448
7e3c2e04 449 //evTag->SetEventId(iEventNumber+1);
450 evTag->SetPeriodNumber(esd->GetPeriodNumber());
451 evTag->SetOrbitNumber(esd->GetOrbitNumber());
452 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
103d3fba 453 evTag->SetGUID(fguid);
454 if(fSession == "grid") {
9b4aee57 455 evTag->SetMD5("");
103d3fba 456 evTag->SetTURL(fturl);
457 evTag->SetSize(0);
458 }
459 else evTag->SetPath(fturl);
460
461 evTag->SetVertexX(vertexIn->GetXv());
462 evTag->SetVertexY(vertexIn->GetYv());
463 evTag->SetVertexZ(vertexIn->GetZv());
464 evTag->SetVertexZError(vertexIn->GetZRes());
465 evTag->SetVertexFlag(fVertexflag);
466
467 evTag->SetT0VertexZ(esd->GetT0zVertex());
468
469 evTag->SetTriggerMask(esd->GetTriggerMask());
470 evTag->SetTriggerCluster(esd->GetTriggerCluster());
471
472 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
473 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
a85132e7 474 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
103d3fba 475 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
476 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
477 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
478
479
480 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
481 evTag->SetNumOfPosTracks(nPos);
482 evTag->SetNumOfNegTracks(nNeg);
483 evTag->SetNumOfNeutrTracks(nNeutr);
484
485 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
486 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
487 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
488 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
489
490 evTag->SetNumOfProtons(nProtons);
491 evTag->SetNumOfKaons(nKaons);
492 evTag->SetNumOfPions(nPions);
493 evTag->SetNumOfMuons(nMuons);
ba4804f9 494 evTag->SetNumOfFWMuons(nFWMuons);
103d3fba 495 evTag->SetNumOfElectrons(nElectrons);
496 evTag->SetNumOfPhotons(nGamas);
497 evTag->SetNumOfPi0s(nPi0s);
498 evTag->SetNumOfNeutrons(nNeutrons);
499 evTag->SetNumOfKaon0s(nK0s);
500
501 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
502 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
503 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
504 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
505 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
506 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
507 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
508 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
509 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
510
a69c1246 511 tmp.Clear();
512 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
513 tmp.Clear();
514 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
103d3fba 515
516 evTag->SetTotalMomentum(totalP);
517 evTag->SetMeanPt(meanPt);
518 evTag->SetMaxPt(maxPt);
73e1181d 519 evTag->SetEtaMaxPt(etamaxPt);
520 evTag->SetPhiMaxPt(phimaxPt);
103d3fba 521
522 tag->SetRunId(iInitRunNumber);
523 if(fIsSim) tag->SetDataType(0);
524 else tag->SetDataType(1);
103d3fba 525
526 if(fguid != fTempGuid) {
527 fTempGuid = fguid;
bc6cefce 528 ttag->Fill();
103d3fba 529 tag->Clear("");
530 }
fcc6b05f 531 tag->AddEventTag(*evTag);
97721f42 532 if(iEventNumber+1 == chain->GetEntries()) {
fcc6b05f 533 //AliInfo(Form("File: %s",fturl.Data()));
bc6cefce 534 ttag->Fill();
fcc6b05f 535 tag->Clear("");
536 }
103d3fba 537 }//event loop
97721f42 538 lastEvent = chain->GetEntries();
103d3fba 539
540 //gSystem->GetMemInfo(meminfo);
541 //AliInfo(Form("After the event and track loop - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
542 //tempmem = meminfo->fMemUsed;
543
97721f42 544 //chain->Delete("");
103d3fba 545
546 //gSystem->GetMemInfo(meminfo);
547 //AliInfo(Form("After the t->Delete - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
548 //tempmem = meminfo->fMemUsed;
549
103d3fba 550 ftag->cd();
103d3fba 551 tag->Clear();
bc6cefce 552 ttag->Write();
103d3fba 553 ftag->Close();
554
555 //gSystem->GetMemInfo(meminfo);
556 //AliInfo(Form("After the file closing - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
557 //tempmem = meminfo->fMemUsed;
558
103d3fba 559 delete esd;
103d3fba 560 delete tag;
fcc6b05f 561
103d3fba 562 //gSystem->GetMemInfo(meminfo);
563 //AliInfo(Form("After the delete objects - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
564}
565
08e1a23e 566//_____________________________________________________________________________
567void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
568 //private method that creates tag files
569 TString fguid = guid;
570 TString fmd5 = md5;
571 TString fturl = turl;
572 /////////////
573 //muon code//
574 ////////////
575 Double_t fMUONMASS = 0.105658369;
576 //Variables
577 Double_t fX,fY,fZ ;
578 Double_t fThetaX, fThetaY, fPyz, fChisquare;
579 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
580 Int_t fCharge;
581 TLorentzVector fEPvector;
582
583 Float_t fZVertexCut = 10.0;
584 Float_t fRhoVertexCut = 2.0;
585
586 Float_t fLowPtCut = 1.0;
587 Float_t fHighPtCut = 3.0;
588 Float_t fVeryHighPtCut = 10.0;
589 ////////////
590
591 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
592
593 // Creates the tags for all the events in a given ESD file
594 Bool_t fIsSim = kTRUE;
595 Int_t ntrack;
ba4804f9 596 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 597 Int_t nPos, nNeg, nNeutr;
598 Int_t nK0s, nNeutrons, nPi0s, nGamas;
599 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
600 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
601 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 602 Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 603 Int_t fVertexflag;
604 Int_t iRunNumber = 0;
605 TString fVertexName;
a69c1246 606 TRefArray tmp;
08e1a23e 607
608 AliRunTag *tag = new AliRunTag();
609 AliEventTag *evTag = new AliEventTag();
bc6cefce 610 TTree * ttag = new TTree("T","A Tree with event tags");
611 TBranch * btag = ttag->Branch("AliTAG", &tag);
08e1a23e 612 btag->SetCompressionLevel(9);
103d3fba 613 gSystem->GetMemInfo(meminfo);
614 AliInfo(Form("After the tag initialization - Memory used: %d MB",meminfo->fMemUsed));
615 Int_t tempmem = meminfo->fMemUsed;
08e1a23e 616
a1069ee1 617 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 618
619 Int_t firstEvent = 0,lastEvent = 0;
620 TTree *t = (TTree*) file->Get("esdTree");
621 AliESDEvent *esd = new AliESDEvent();
622 esd->ReadFromTree(t);
623
103d3fba 624 gSystem->GetMemInfo(meminfo);
625 AliInfo(Form("After the esd initialization - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
626 tempmem = meminfo->fMemUsed;
627
08e1a23e 628 t->GetEntry(0);
629 Int_t iInitRunNumber = esd->GetRunNumber();
630
631 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
632 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
633 ntrack = 0;
634 nPos = 0;
635 nNeg = 0;
636 nNeutr =0;
637 nK0s = 0;
638 nNeutrons = 0;
639 nPi0s = 0;
640 nGamas = 0;
641 nProtons = 0;
642 nKaons = 0;
643 nPions = 0;
644 nMuons = 0;
ba4804f9 645 nFWMuons = 0;
08e1a23e 646 nElectrons = 0;
647 nCh1GeV = 0;
648 nCh3GeV = 0;
649 nCh10GeV = 0;
650 nMu1GeV = 0;
651 nMu3GeV = 0;
652 nMu10GeV = 0;
653 nEl1GeV = 0;
654 nEl3GeV = 0;
655 nEl10GeV = 0;
656 maxPt = .0;
73e1181d 657 etamaxPt = -999.;
658 phimaxPt = -999.;
08e1a23e 659 meanPt = .0;
660 totalP = .0;
661 fVertexflag = 1;
662
663 t->GetEntry(iEventNumber);
664 iRunNumber = esd->GetRunNumber();
665 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
666 const AliESDVertex * vertexIn = esd->GetVertex();
667 fVertexName = vertexIn->GetName();
668 if(fVertexName == "default") fVertexflag = 0;
669
670 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
671 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
672 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
673 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
674 UInt_t status = esdTrack->GetStatus();
675
676 //select only tracks with ITS refit
677 if ((status&AliESDtrack::kITSrefit)==0) continue;
678 //select only tracks with TPC refit
679 if ((status&AliESDtrack::kTPCrefit)==0) continue;
680
681 //select only tracks with the "combined PID"
682 if ((status&AliESDtrack::kESDpid)==0) continue;
683 Double_t p[3];
684 esdTrack->GetPxPyPz(p);
60e55aee 685 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
686 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
687 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 688 totalP += momentum;
689 meanPt += fPt;
73e1181d 690 if(fPt > maxPt) {
691 maxPt = fPt;
692 etamaxPt = esdTrack->Eta();
693 phimaxPt = esdTrack->Phi();
694 }
08e1a23e 695
73e1181d 696
08e1a23e 697 if(esdTrack->GetSign() > 0) {
698 nPos++;
699 if(fPt > fLowPtCut) nCh1GeV++;
700 if(fPt > fHighPtCut) nCh3GeV++;
701 if(fPt > fVeryHighPtCut) nCh10GeV++;
702 }
703 if(esdTrack->GetSign() < 0) {
704 nNeg++;
705 if(fPt > fLowPtCut) nCh1GeV++;
706 if(fPt > fHighPtCut) nCh3GeV++;
707 if(fPt > fVeryHighPtCut) nCh10GeV++;
708 }
709 if(esdTrack->GetSign() == 0) nNeutr++;
710
711 //PID
712 Double_t prob[5];
713 esdTrack->GetESDpid(prob);
714
715 Double_t rcc = 0.0;
716 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
717 if(rcc == 0.0) continue;
718 //Bayes' formula
719 Double_t w[5];
720 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
721
722 //protons
723 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
724 //kaons
725 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
726 //pions
727 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
728 //electrons
729 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
730 nElectrons++;
731 if(fPt > fLowPtCut) nEl1GeV++;
732 if(fPt > fHighPtCut) nEl3GeV++;
733 if(fPt > fVeryHighPtCut) nEl10GeV++;
734 }
735 ntrack++;
736 }//esd track loop
737
738 /////////////
739 //muon code//
740 ////////////
741 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
742 // loop over all reconstructed tracks (also first track of combination)
743 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
744 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
745 if (muonTrack == 0x0) continue;
746
747 // Coordinates at vertex
748 fZ = muonTrack->GetZ();
749 fY = muonTrack->GetBendingCoor();
750 fX = muonTrack->GetNonBendingCoor();
751
752 fThetaX = muonTrack->GetThetaX();
753 fThetaY = muonTrack->GetThetaY();
754
755 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
756 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
757 fPxRec = fPzRec * TMath::Tan(fThetaX);
758 fPyRec = fPzRec * TMath::Tan(fThetaY);
759 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
760
761 //ChiSquare of the track if needed
762 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
763 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
764 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
765
766 // total number of muons inside a vertex cut
767 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
768 nMuons++;
ba4804f9 769 nFWMuons++;
08e1a23e 770 if(fEPvector.Pt() > fLowPtCut) {
771 nMu1GeV++;
772 if(fEPvector.Pt() > fHighPtCut) {
773 nMu3GeV++;
774 if (fEPvector.Pt() > fVeryHighPtCut) {
775 nMu10GeV++;
776 }
777 }
778 }
779 }
780 }//muon track loop
781
782 // Fill the event tags
783 if(ntrack != 0) meanPt = meanPt/ntrack;
784
7e3c2e04 785 //First physics data
786 const AliMultiplicity *spdMult = esd->GetMultiplicity();
787 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
788 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
789 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
790
4c454ade 791 AliESDVZERO *vzeroData = esd->GetVZEROData();
792 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
793 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
794 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
795 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
796
7e3c2e04 797 //evTag->SetEventId(iEventNumber+1);
798 evTag->SetPeriodNumber(esd->GetPeriodNumber());
799 evTag->SetOrbitNumber(esd->GetOrbitNumber());
800 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
801
08e1a23e 802 evTag->SetGUID(fguid);
803 evTag->SetMD5(fmd5);
804 evTag->SetTURL(fturl);
805 evTag->SetSize(size);
806 evTag->SetVertexX(vertexIn->GetXv());
807 evTag->SetVertexY(vertexIn->GetYv());
808 evTag->SetVertexZ(vertexIn->GetZv());
809 evTag->SetVertexZError(vertexIn->GetZRes());
810 evTag->SetVertexFlag(fVertexflag);
811
812 evTag->SetT0VertexZ(esd->GetT0zVertex());
813
814 evTag->SetTriggerMask(esd->GetTriggerMask());
815 evTag->SetTriggerCluster(esd->GetTriggerCluster());
816
817 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
818 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
a85132e7 819 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 820 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
821 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
822 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
823
824
825 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
826 evTag->SetNumOfPosTracks(nPos);
827 evTag->SetNumOfNegTracks(nNeg);
828 evTag->SetNumOfNeutrTracks(nNeutr);
829
830 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
831 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
832 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
833 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
834
835 evTag->SetNumOfProtons(nProtons);
836 evTag->SetNumOfKaons(nKaons);
837 evTag->SetNumOfPions(nPions);
838 evTag->SetNumOfMuons(nMuons);
ba4804f9 839 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 840 evTag->SetNumOfElectrons(nElectrons);
841 evTag->SetNumOfPhotons(nGamas);
842 evTag->SetNumOfPi0s(nPi0s);
843 evTag->SetNumOfNeutrons(nNeutrons);
844 evTag->SetNumOfKaon0s(nK0s);
845
846 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
847 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
848 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
849 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
850 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
851 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
852 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
853 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
854 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
855
a69c1246 856 tmp.Clear();
857 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
858 tmp.Clear();
859 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 860
861 evTag->SetTotalMomentum(totalP);
862 evTag->SetMeanPt(meanPt);
863 evTag->SetMaxPt(maxPt);
73e1181d 864 evTag->SetEtaMaxPt(etamaxPt);
865 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 866
867 tag->SetRunId(iInitRunNumber);
868 if(fIsSim) tag->SetDataType(0);
869 else tag->SetDataType(1);
870 tag->AddEventTag(*evTag);
871 }//event loop
872 lastEvent = iNumberOfEvents;
873
103d3fba 874 gSystem->GetMemInfo(meminfo);
875 AliInfo(Form("After the event and track loop - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
876 tempmem = meminfo->fMemUsed;
08e1a23e 877 t->Delete("");
878
103d3fba 879 gSystem->GetMemInfo(meminfo);
880 AliInfo(Form("After the t->Delete - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
881 tempmem = meminfo->fMemUsed;
882
08e1a23e 883 TString localFileName = "Run"; localFileName += tag->GetRunId();
884 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
885 localFileName += ".ESD.tag.root";
886
887 TString fileName;
888
889 if(fStorage == 0) {
890 fileName = localFileName.Data();
891 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
892 }
893 else if(fStorage == 1) {
894 TString alienLocation = "/alien";
895 alienLocation += gGrid->Pwd();
896 alienLocation += fgridpath.Data();
897 alienLocation += "/";
898 alienLocation += localFileName;
899 alienLocation += "?se=";
900 alienLocation += fSE.Data();
901 fileName = alienLocation.Data();
902 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
903 }
904
905 TFile* ftag = TFile::Open(fileName, "recreate");
906 ftag->cd();
bc6cefce 907 ttag->Fill();
7ee67d2a 908 tag->Clear();
bc6cefce 909 ttag->Write();
08e1a23e 910 ftag->Close();
911
103d3fba 912 gSystem->GetMemInfo(meminfo);
913 AliInfo(Form("After the file closing - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
914 tempmem = meminfo->fMemUsed;
915
08e1a23e 916 delete ftag;
917 delete esd;
918
919 delete tag;
103d3fba 920 gSystem->GetMemInfo(meminfo);
921 AliInfo(Form("After the delete objects - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
08e1a23e 922}
923
924//_____________________________________________________________________________
925void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
926 //private method that creates tag files
927 /////////////
928 //muon code//
929 ////////////
930 Double_t fMUONMASS = 0.105658369;
931 //Variables
932 Double_t fX,fY,fZ ;
933 Double_t fThetaX, fThetaY, fPyz, fChisquare;
934 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
935 Int_t fCharge;
936 TLorentzVector fEPvector;
937
938 Float_t fZVertexCut = 10.0;
939 Float_t fRhoVertexCut = 2.0;
940
941 Float_t fLowPtCut = 1.0;
942 Float_t fHighPtCut = 3.0;
943 Float_t fVeryHighPtCut = 10.0;
944 ////////////
945
946 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
947
948 // Creates the tags for all the events in a given ESD file
949 Bool_t fIsSim = kTRUE;
950 Int_t ntrack;
ba4804f9 951 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 952 Int_t nPos, nNeg, nNeutr;
953 Int_t nK0s, nNeutrons, nPi0s, nGamas;
954 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
955 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
956 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 957 Float_t maxPt = .0, etamaxPt = -999, phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 958 Int_t fVertexflag;
959 Int_t iRunNumber = 0;
960 TString fVertexName;
a69c1246 961 TRefArray tmp;
08e1a23e 962
963 AliRunTag *tag = new AliRunTag();
964 AliEventTag *evTag = new AliEventTag();
bc6cefce 965 TTree * ttag = new TTree("T","A Tree with event tags");
966 TBranch * btag = ttag->Branch("AliTAG", &tag);
08e1a23e 967 btag->SetCompressionLevel(9);
968
a1069ee1 969 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 970
971 Int_t firstEvent = 0,lastEvent = 0;
972
973 TTree *t = (TTree*) file->Get("esdTree");
974 AliESDEvent *esd = new AliESDEvent();
975 esd->ReadFromTree(t);
976
977 t->GetEntry(0);
978 Int_t iInitRunNumber = esd->GetRunNumber();
979
980 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
981 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
982 ntrack = 0;
983 nPos = 0;
984 nNeg = 0;
985 nNeutr =0;
986 nK0s = 0;
987 nNeutrons = 0;
988 nPi0s = 0;
989 nGamas = 0;
990 nProtons = 0;
991 nKaons = 0;
992 nPions = 0;
993 nMuons = 0;
ba4804f9 994 nFWMuons = 0;
08e1a23e 995 nElectrons = 0;
996 nCh1GeV = 0;
997 nCh3GeV = 0;
998 nCh10GeV = 0;
999 nMu1GeV = 0;
1000 nMu3GeV = 0;
1001 nMu10GeV = 0;
1002 nEl1GeV = 0;
1003 nEl3GeV = 0;
1004 nEl10GeV = 0;
1005 maxPt = .0;
73e1181d 1006 etamaxPt = -999.;
1007 phimaxPt = -999.;
08e1a23e 1008 meanPt = .0;
1009 totalP = .0;
1010 fVertexflag = 1;
1011
1012 t->GetEntry(iEventNumber);
1013 iRunNumber = esd->GetRunNumber();
1014 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
1015 const AliESDVertex * vertexIn = esd->GetVertex();
1016 fVertexName = vertexIn->GetName();
1017 if(fVertexName == "default") fVertexflag = 0;
1018
1019 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
1020 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
1021 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
1022 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
1023 UInt_t status = esdTrack->GetStatus();
1024
1025 //select only tracks with ITS refit
1026 if ((status&AliESDtrack::kITSrefit)==0) continue;
1027 //select only tracks with TPC refit
1028 if ((status&AliESDtrack::kTPCrefit)==0) continue;
1029
1030 //select only tracks with the "combined PID"
1031 if ((status&AliESDtrack::kESDpid)==0) continue;
1032 Double_t p[3];
1033 esdTrack->GetPxPyPz(p);
60e55aee 1034 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
1035 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
1036 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 1037 totalP += momentum;
1038 meanPt += fPt;
73e1181d 1039 if(fPt > maxPt) {
1040 maxPt = fPt;
1041 etamaxPt = esdTrack->Eta();
1042 phimaxPt = esdTrack->Phi();
1043 }
1044
08e1a23e 1045
1046 if(esdTrack->GetSign() > 0) {
1047 nPos++;
1048 if(fPt > fLowPtCut) nCh1GeV++;
1049 if(fPt > fHighPtCut) nCh3GeV++;
1050 if(fPt > fVeryHighPtCut) nCh10GeV++;
1051 }
1052 if(esdTrack->GetSign() < 0) {
1053 nNeg++;
1054 if(fPt > fLowPtCut) nCh1GeV++;
1055 if(fPt > fHighPtCut) nCh3GeV++;
1056 if(fPt > fVeryHighPtCut) nCh10GeV++;
1057 }
1058 if(esdTrack->GetSign() == 0) nNeutr++;
1059
1060 //PID
1061 Double_t prob[5];
1062 esdTrack->GetESDpid(prob);
1063
1064 Double_t rcc = 0.0;
1065 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
1066 if(rcc == 0.0) continue;
1067 //Bayes' formula
1068 Double_t w[5];
1069 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
1070
1071 //protons
1072 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
1073 //kaons
1074 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
1075 //pions
1076 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
1077 //electrons
1078 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
1079 nElectrons++;
1080 if(fPt > fLowPtCut) nEl1GeV++;
1081 if(fPt > fHighPtCut) nEl3GeV++;
1082 if(fPt > fVeryHighPtCut) nEl10GeV++;
1083 }
1084 ntrack++;
1085 }//esd track loop
1086
1087 /////////////
1088 //muon code//
1089 ////////////
1090 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
1091 // loop over all reconstructed tracks (also first track of combination)
1092 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
1093 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
1094 if (muonTrack == 0x0) continue;
1095
1096 // Coordinates at vertex
1097 fZ = muonTrack->GetZ();
1098 fY = muonTrack->GetBendingCoor();
1099 fX = muonTrack->GetNonBendingCoor();
1100
1101 fThetaX = muonTrack->GetThetaX();
1102 fThetaY = muonTrack->GetThetaY();
1103
1104 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
1105 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
1106 fPxRec = fPzRec * TMath::Tan(fThetaX);
1107 fPyRec = fPzRec * TMath::Tan(fThetaY);
1108 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
1109
1110 //ChiSquare of the track if needed
1111 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
1112 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
1113 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
1114
1115 // total number of muons inside a vertex cut
1116 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
1117 nMuons++;
ba4804f9 1118 nFWMuons++;
08e1a23e 1119 if(fEPvector.Pt() > fLowPtCut) {
1120 nMu1GeV++;
1121 if(fEPvector.Pt() > fHighPtCut) {
1122 nMu3GeV++;
1123 if (fEPvector.Pt() > fVeryHighPtCut) {
1124 nMu10GeV++;
1125 }
1126 }
1127 }
1128 }
1129 }//muon track loop
1130
1131 // Fill the event tags
1132 if(ntrack != 0) meanPt = meanPt/ntrack;
1133
7e3c2e04 1134 //First physics data
1135 const AliMultiplicity *spdMult = esd->GetMultiplicity();
1136 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
1137 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
1138 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
1139
4c454ade 1140 AliESDVZERO *vzeroData = esd->GetVZEROData();
1141 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
1142 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
1143 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
1144 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
1145
7e3c2e04 1146 //evTag->SetEventId(iEventNumber+1);
1147 evTag->SetPeriodNumber(esd->GetPeriodNumber());
1148 evTag->SetOrbitNumber(esd->GetOrbitNumber());
1149 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
08e1a23e 1150 evTag->SetPath(filepath);
1151
1152 evTag->SetVertexX(vertexIn->GetXv());
1153 evTag->SetVertexY(vertexIn->GetYv());
1154 evTag->SetVertexZ(vertexIn->GetZv());
1155 evTag->SetVertexZError(vertexIn->GetZRes());
1156 evTag->SetVertexFlag(fVertexflag);
1157
1158 evTag->SetT0VertexZ(esd->GetT0zVertex());
1159
1160 evTag->SetTriggerMask(esd->GetTriggerMask());
1161 evTag->SetTriggerCluster(esd->GetTriggerCluster());
1162
1163 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
1164 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
a85132e7 1165 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 1166 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
1167 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
1168 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
1169
1170
1171 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
1172 evTag->SetNumOfPosTracks(nPos);
1173 evTag->SetNumOfNegTracks(nNeg);
1174 evTag->SetNumOfNeutrTracks(nNeutr);
1175
1176 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
1177 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
1178 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
1179 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
1180
1181 evTag->SetNumOfProtons(nProtons);
1182 evTag->SetNumOfKaons(nKaons);
1183 evTag->SetNumOfPions(nPions);
1184 evTag->SetNumOfMuons(nMuons);
ba4804f9 1185 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 1186 evTag->SetNumOfElectrons(nElectrons);
1187 evTag->SetNumOfPhotons(nGamas);
1188 evTag->SetNumOfPi0s(nPi0s);
1189 evTag->SetNumOfNeutrons(nNeutrons);
1190 evTag->SetNumOfKaon0s(nK0s);
1191
1192 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
1193 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
1194 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
1195 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
1196 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
1197 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
1198 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
1199 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
1200 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
1201
a69c1246 1202 tmp.Clear();
1203 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
1204 tmp.Clear();
1205 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 1206
1207 evTag->SetTotalMomentum(totalP);
1208 evTag->SetMeanPt(meanPt);
1209 evTag->SetMaxPt(maxPt);
73e1181d 1210 evTag->SetEtaMaxPt(etamaxPt);
1211 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 1212
1213 tag->SetRunId(iInitRunNumber);
1214 if(fIsSim) tag->SetDataType(0);
1215 else tag->SetDataType(1);
1216 tag->AddEventTag(*evTag);
1217 }//event loop
1218 lastEvent = iNumberOfEvents;
1219
1220 t->Delete("");
1221
08e1a23e 1222 TString localFileName = "Run"; localFileName += tag->GetRunId();
1223 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
1224 localFileName += ".ESD.tag.root";
1225
1226 TString fileName;
1227
1228 if(fStorage == 0) {
1229 fileName = localFileName.Data();
1230 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
1231 }
1232 else if(fStorage == 1) {
1233 TString alienLocation = "/alien";
1234 alienLocation += gGrid->Pwd();
1235 alienLocation += fgridpath.Data();
1236 alienLocation += "/";
1237 alienLocation += localFileName;
1238 alienLocation += "?se=";
1239 alienLocation += fSE.Data();
1240 fileName = alienLocation.Data();
1241 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
1242 }
1243
1244 TFile* ftag = TFile::Open(fileName, "recreate");
1245 ftag->cd();
bc6cefce 1246 ttag->Fill();
7ee67d2a 1247 tag->Clear();
bc6cefce 1248 ttag->Write();
08e1a23e 1249 ftag->Close();
1250
1251 delete ftag;
1252 delete esd;
1253
1254 delete tag;
1255}
1256
1257//_____________________________________________________________________________
27293674 1258void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, AliGRPObject *grpData, ULong_t * qa, Bool_t * es, Int_t qalength, Int_t eslength) {
08e1a23e 1259 //GRP
1260 Float_t lhcLuminosity = 0.0;
1261 TString lhcState = "test";
44e45fac 1262 //UInt_t detectorMask = 0;
1263 Int_t detectorMask = 0;
08e1a23e 1264
44e45fac 1265 detectorMask = grpData->GetDetectorMask();
1266 time_t startTime = grpData->GetTimeStart();
126f4d0c 1267 TTimeStamp *t1 = new TTimeStamp(startTime);
44e45fac 1268 time_t endTime = grpData->GetTimeEnd();
1269 TTimeStamp *t2 = new TTimeStamp(endTime);
1270 const char* beamtype = grpData->GetBeamType();
1271 Float_t beamenergy = grpData->GetBeamEnergy();
126f4d0c 1272
1273
08e1a23e 1274 /////////////
1275 //muon code//
1276 ////////////
1277 Double_t fMUONMASS = 0.105658369;
1278 //Variables
1279 Double_t fX,fY,fZ ;
1280 Double_t fThetaX, fThetaY, fPyz, fChisquare;
1281 Double_t fPxRec,fPyRec, fPzRec, fEnergy;
1282 Int_t fCharge;
1283 TLorentzVector fEPvector;
1284
1285 Float_t fZVertexCut = 10.0;
1286 Float_t fRhoVertexCut = 2.0;
1287
1288 Float_t fLowPtCut = 1.0;
1289 Float_t fHighPtCut = 3.0;
1290 Float_t fVeryHighPtCut = 10.0;
1291 ////////////
1292
1293 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
1294
1295 // Creates the tags for all the events in a given ESD file
1296 Int_t ntrack;
ba4804f9 1297 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 1298 Int_t nPos, nNeg, nNeutr;
1299 Int_t nK0s, nNeutrons, nPi0s, nGamas;
1300 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
1301 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
1302 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 1303 Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 1304 Int_t fVertexflag;
1305 Int_t iRunNumber = 0;
1306 TString fVertexName("default");
a69c1246 1307 TRefArray tmp;
08e1a23e 1308
a1069ee1 1309 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 1310
1311 TFile *file = TFile::Open("AliESDs.root");
1312 if (!file || !file->IsOpen()) {
1313 AliError(Form("opening failed"));
1314 delete file;
1315 return ;
1316 }
1317 Int_t lastEvent = 0;
1318 TTree *b = (TTree*) file->Get("esdTree");
1319 AliESDEvent *esd = new AliESDEvent();
1320 esd->ReadFromTree(b);
1321
1322 b->GetEntry(fFirstEvent);
1323 Int_t iInitRunNumber = esd->GetRunNumber();
1324
1325 Int_t iNumberOfEvents = (Int_t)b->GetEntries();
fcc6b05f 1326 if(fLastEvent == -1) lastEvent = (Int_t)b->GetEntries();
1327 else lastEvent = fLastEvent;
1328
1329 char fileName[256];
1330 sprintf(fileName, "Run%d.Event%d_%d.ESD.tag.root",
517aef4e 1331 iInitRunNumber,fFirstEvent,lastEvent);
fcc6b05f 1332 AliInfo(Form("writing tags to file %s", fileName));
1333 AliDebug(1, Form("writing tags to file %s", fileName));
1334
1335 TFile* ftag = TFile::Open(fileName, "recreate");
1336
517aef4e 1337 AliRunTag *tag = new AliRunTag();
1338 AliEventTag *evTag = new AliEventTag();
bc6cefce 1339 TTree * ttag = new TTree("T","A Tree with event tags");
1340 TBranch * btag = ttag->Branch("AliTAG", &tag);
517aef4e 1341 btag->SetCompressionLevel(9);
1342
08e1a23e 1343 if(fLastEvent != -1) iNumberOfEvents = fLastEvent + 1;
1344 for (Int_t iEventNumber = fFirstEvent; iEventNumber < iNumberOfEvents; iEventNumber++) {
1345 ntrack = 0;
1346 nPos = 0;
1347 nNeg = 0;
1348 nNeutr =0;
1349 nK0s = 0;
1350 nNeutrons = 0;
1351 nPi0s = 0;
1352 nGamas = 0;
1353 nProtons = 0;
1354 nKaons = 0;
1355 nPions = 0;
1356 nMuons = 0;
ba4804f9 1357 nFWMuons = 0;
08e1a23e 1358 nElectrons = 0;
1359 nCh1GeV = 0;
1360 nCh3GeV = 0;
1361 nCh10GeV = 0;
1362 nMu1GeV = 0;
1363 nMu3GeV = 0;
1364 nMu10GeV = 0;
1365 nEl1GeV = 0;
1366 nEl3GeV = 0;
1367 nEl10GeV = 0;
1368 maxPt = .0;
73e1181d 1369 etamaxPt = -999.;
1370 phimaxPt = -999.;
08e1a23e 1371 meanPt = .0;
1372 totalP = .0;
1373 fVertexflag = 0;
1374
1375 b->GetEntry(iEventNumber);
1376 iRunNumber = esd->GetRunNumber();
1377 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
1378 const AliESDVertex * vertexIn = esd->GetVertex();
1379 if (!vertexIn) AliError("ESD has not defined vertex.");
1380 if (vertexIn) fVertexName = vertexIn->GetName();
1381 if(fVertexName != "default") fVertexflag = 1;
1382 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
1383 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
1384 UInt_t status = esdTrack->GetStatus();
1385
1386 //select only tracks with ITS refit
1387 if ((status&AliESDtrack::kITSrefit)==0) continue;
1388 //select only tracks with TPC refit
1389 if ((status&AliESDtrack::kTPCrefit)==0) continue;
1390
1391 //select only tracks with the "combined PID"
1392 if ((status&AliESDtrack::kESDpid)==0) continue;
1393 Double_t p[3];
1394 esdTrack->GetPxPyPz(p);
60e55aee 1395 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
1396 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
1397 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 1398 totalP += momentum;
1399 meanPt += fPt;
73e1181d 1400 if(fPt > maxPt) {
1401 maxPt = fPt;
1402 phimaxPt = esdTrack->Eta();
1403 etamaxPt = esdTrack->Phi();
1404 }
08e1a23e 1405
1406 if(esdTrack->GetSign() > 0) {
1407 nPos++;
1408 if(fPt > fLowPtCut) nCh1GeV++;
1409 if(fPt > fHighPtCut) nCh3GeV++;
1410 if(fPt > fVeryHighPtCut) nCh10GeV++;
1411 }
1412 if(esdTrack->GetSign() < 0) {
1413 nNeg++;
1414 if(fPt > fLowPtCut) nCh1GeV++;
1415 if(fPt > fHighPtCut) nCh3GeV++;
1416 if(fPt > fVeryHighPtCut) nCh10GeV++;
1417 }
1418 if(esdTrack->GetSign() == 0) nNeutr++;
1419
1420 //PID
1421 Double_t prob[5];
1422 esdTrack->GetESDpid(prob);
1423
1424 Double_t rcc = 0.0;
1425 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
1426 if(rcc == 0.0) continue;
1427 //Bayes' formula
1428 Double_t w[5];
1429 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
1430
1431 //protons
1432 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
1433 //kaons
1434 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
1435 //pions
1436 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
1437 //electrons
1438 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
1439 nElectrons++;
1440 if(fPt > fLowPtCut) nEl1GeV++;
1441 if(fPt > fHighPtCut) nEl3GeV++;
1442 if(fPt > fVeryHighPtCut) nEl10GeV++;
1443 }
1444 ntrack++;
1445 }//track loop
1446
1447 /////////////
1448 //muon code//
1449 ////////////
1450 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
1451 // loop over all reconstructed tracks (also first track of combination)
1452 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
1453 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
1454 if (muonTrack == 0x0) continue;
1455
1456 // Coordinates at vertex
1457 fZ = muonTrack->GetZ();
1458 fY = muonTrack->GetBendingCoor();
1459 fX = muonTrack->GetNonBendingCoor();
1460
1461 fThetaX = muonTrack->GetThetaX();
1462 fThetaY = muonTrack->GetThetaY();
1463
1464 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
1465 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
1466 fPxRec = fPzRec * TMath::Tan(fThetaX);
1467 fPyRec = fPzRec * TMath::Tan(fThetaY);
1468 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
1469
1470 //ChiSquare of the track if needed
1471 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
1472 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
1473 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
1474
1475 // total number of muons inside a vertex cut
1476 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
1477 nMuons++;
ba4804f9 1478 nFWMuons++;
08e1a23e 1479 if(fEPvector.Pt() > fLowPtCut) {
1480 nMu1GeV++;
1481 if(fEPvector.Pt() > fHighPtCut) {
1482 nMu3GeV++;
1483 if (fEPvector.Pt() > fVeryHighPtCut) {
1484 nMu10GeV++;
1485 }
1486 }
1487 }
1488 }
1489 }//muon track loop
7e3c2e04 1490
08e1a23e 1491
1492 // Fill the event tags
1493 if(ntrack != 0)
1494 meanPt = meanPt/ntrack;
7e3c2e04 1495
1496 //First physics data
1497 const AliMultiplicity *spdMult = esd->GetMultiplicity();
1498 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
1499 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
1500 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
1501
4c454ade 1502 AliESDVZERO *vzeroData = esd->GetVZEROData();
1503 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
1504 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
1505 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
1506 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
1507
7e3c2e04 1508 //evTag->SetEventId(iEventNumber+1);
1509 evTag->SetPeriodNumber(esd->GetPeriodNumber());
1510 evTag->SetOrbitNumber(esd->GetOrbitNumber());
1511 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
08e1a23e 1512 if (vertexIn) {
1513 evTag->SetVertexX(vertexIn->GetXv());
1514 evTag->SetVertexY(vertexIn->GetYv());
1515 evTag->SetVertexZ(vertexIn->GetZv());
1516 evTag->SetVertexZError(vertexIn->GetZRes());
1517 }
1518 evTag->SetVertexFlag(fVertexflag);
1519
1520 evTag->SetT0VertexZ(esd->GetT0zVertex());
1521
1522 evTag->SetTriggerMask(esd->GetTriggerMask());
1523 evTag->SetTriggerCluster(esd->GetTriggerCluster());
1524
1525 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
1526 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
1527 evTag->SetZDCNeutron2Energy(esd->GetZDCN2Energy());
1528 evTag->SetZDCProton2Energy(esd->GetZDCP2Energy());
a85132e7 1529 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 1530 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
1531
1532
1533 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
1534 evTag->SetNumOfPosTracks(nPos);
1535 evTag->SetNumOfNegTracks(nNeg);
1536 evTag->SetNumOfNeutrTracks(nNeutr);
1537
1538 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
1539 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
1540 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
1541 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
1542
1543 evTag->SetNumOfProtons(nProtons);
1544 evTag->SetNumOfKaons(nKaons);
1545 evTag->SetNumOfPions(nPions);
1546 evTag->SetNumOfMuons(nMuons);
ba4804f9 1547 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 1548 evTag->SetNumOfElectrons(nElectrons);
1549 evTag->SetNumOfPhotons(nGamas);
1550 evTag->SetNumOfPi0s(nPi0s);
1551 evTag->SetNumOfNeutrons(nNeutrons);
1552 evTag->SetNumOfKaon0s(nK0s);
1553
1554 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
1555 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
1556 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
1557 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
1558 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
1559 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
1560 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
1561 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
1562 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
1563
a69c1246 1564 tmp.Clear();
1565 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
1566 tmp.Clear();
1567 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 1568
1569 evTag->SetTotalMomentum(totalP);
1570 evTag->SetMeanPt(meanPt);
1571 evTag->SetMaxPt(maxPt);
73e1181d 1572 evTag->SetEtaMaxPt(etamaxPt);
1573 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 1574
1575 tag->SetLHCTag(lhcLuminosity,lhcState);
1576 tag->SetDetectorTag(detectorMask);
1577
1578 tag->SetRunId(iInitRunNumber);
126f4d0c 1579 tag->SetRunStartTime(t1->GetDate());
1580 tag->SetRunStopTime(t2->GetDate());
1581 tag->SetBeamEnergy(beamenergy);
1582 tag->SetBeamType(beamtype);
27293674 1583
1584 //QA setting
9ee5d033 1585 tag->SetQAArray(qa, qalength) ;
27293674 1586 tag->SetEventSpecies(es, eslength) ;
126f4d0c 1587
08e1a23e 1588 tag->AddEventTag(*evTag);
1589 }
08e1a23e 1590
08e1a23e 1591 ftag->cd();
bc6cefce 1592 ttag->Fill();
7ee67d2a 1593 tag->Clear();
bc6cefce 1594 ttag->Write();
08e1a23e 1595 ftag->Close();
1596 file->cd();
1597 delete tag;
1598 delete evTag;
1599}
1600
517aef4e 1601//_____________________________________________________________________________
1602void AliESDTagCreator::SwitchOffBranches() const {
2856e38b 1603 //
1604 // Switch of branches on user request
517aef4e 1605 TObjArray * tokens = fBranches.Tokenize(" ");
1606 Int_t ntok = tokens->GetEntries();
1607 for (Int_t i = 0; i < ntok; i++) {
1608 TString str = ((TObjString*) tokens->At(i))->GetString();
1609 fChain->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
1610 AliInfo(Form("Branch %s switched off \n", str.Data()));
1611 }
2856e38b 1612}