- Three classes by MinJung Kweon AliHFEpriVtx, AliHFEsecVtx and AliHFEmcQA for primar...
[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
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;
199 TString fTempGuid = 0;
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();
283 TTree ttag("T","A Tree with event tags");
284 TBranch * btag = ttag.Branch("AliTAG", &tag);
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") {
455 evTag->SetMD5(0);
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());
2b6cdc43 478 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
479 evTag->SetNumOfParticipants2(esd->GetZDCParticipants2());
103d3fba 480
481
482 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
483 evTag->SetNumOfPosTracks(nPos);
484 evTag->SetNumOfNegTracks(nNeg);
485 evTag->SetNumOfNeutrTracks(nNeutr);
486
487 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
488 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
489 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
490 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
491
492 evTag->SetNumOfProtons(nProtons);
493 evTag->SetNumOfKaons(nKaons);
494 evTag->SetNumOfPions(nPions);
495 evTag->SetNumOfMuons(nMuons);
ba4804f9 496 evTag->SetNumOfFWMuons(nFWMuons);
103d3fba 497 evTag->SetNumOfElectrons(nElectrons);
498 evTag->SetNumOfPhotons(nGamas);
499 evTag->SetNumOfPi0s(nPi0s);
500 evTag->SetNumOfNeutrons(nNeutrons);
501 evTag->SetNumOfKaon0s(nK0s);
502
503 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
504 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
505 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
506 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
507 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
508 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
509 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
510 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
511 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
512
a69c1246 513 tmp.Clear();
514 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
515 tmp.Clear();
516 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
103d3fba 517
518 evTag->SetTotalMomentum(totalP);
519 evTag->SetMeanPt(meanPt);
520 evTag->SetMaxPt(maxPt);
73e1181d 521 evTag->SetEtaMaxPt(etamaxPt);
522 evTag->SetPhiMaxPt(phimaxPt);
103d3fba 523
524 tag->SetRunId(iInitRunNumber);
525 if(fIsSim) tag->SetDataType(0);
526 else tag->SetDataType(1);
103d3fba 527
528 if(fguid != fTempGuid) {
529 fTempGuid = fguid;
530 ttag.Fill();
531 tag->Clear("");
532 }
fcc6b05f 533 tag->AddEventTag(*evTag);
97721f42 534 if(iEventNumber+1 == chain->GetEntries()) {
fcc6b05f 535 //AliInfo(Form("File: %s",fturl.Data()));
536 ttag.Fill();
537 tag->Clear("");
538 }
103d3fba 539 }//event loop
97721f42 540 lastEvent = chain->GetEntries();
103d3fba 541
542 //gSystem->GetMemInfo(meminfo);
543 //AliInfo(Form("After the event and track loop - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
544 //tempmem = meminfo->fMemUsed;
545
97721f42 546 //chain->Delete("");
103d3fba 547
548 //gSystem->GetMemInfo(meminfo);
549 //AliInfo(Form("After the t->Delete - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
550 //tempmem = meminfo->fMemUsed;
551
103d3fba 552 ftag->cd();
103d3fba 553 tag->Clear();
554 ttag.Write();
555 ftag->Close();
556
557 //gSystem->GetMemInfo(meminfo);
558 //AliInfo(Form("After the file closing - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
559 //tempmem = meminfo->fMemUsed;
560
103d3fba 561 delete esd;
103d3fba 562 delete tag;
fcc6b05f 563
103d3fba 564 //gSystem->GetMemInfo(meminfo);
565 //AliInfo(Form("After the delete objects - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
566}
567
568//_____________________________________________________________________________
08e1a23e 569void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
570 //private method that creates tag files
571 TString fguid = guid;
572 TString fmd5 = md5;
573 TString fturl = turl;
574 /////////////
575 //muon code//
576 ////////////
577 Double_t fMUONMASS = 0.105658369;
578 //Variables
579 Double_t fX,fY,fZ ;
580 Double_t fThetaX, fThetaY, fPyz, fChisquare;
581 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
582 Int_t fCharge;
583 TLorentzVector fEPvector;
584
585 Float_t fZVertexCut = 10.0;
586 Float_t fRhoVertexCut = 2.0;
587
588 Float_t fLowPtCut = 1.0;
589 Float_t fHighPtCut = 3.0;
590 Float_t fVeryHighPtCut = 10.0;
591 ////////////
592
593 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
594
595 // Creates the tags for all the events in a given ESD file
596 Bool_t fIsSim = kTRUE;
597 Int_t ntrack;
ba4804f9 598 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 599 Int_t nPos, nNeg, nNeutr;
600 Int_t nK0s, nNeutrons, nPi0s, nGamas;
601 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
602 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
603 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 604 Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 605 Int_t fVertexflag;
606 Int_t iRunNumber = 0;
607 TString fVertexName;
a69c1246 608 TRefArray tmp;
08e1a23e 609
610 AliRunTag *tag = new AliRunTag();
611 AliEventTag *evTag = new AliEventTag();
612 TTree ttag("T","A Tree with event tags");
613 TBranch * btag = ttag.Branch("AliTAG", &tag);
614 btag->SetCompressionLevel(9);
103d3fba 615 gSystem->GetMemInfo(meminfo);
616 AliInfo(Form("After the tag initialization - Memory used: %d MB",meminfo->fMemUsed));
617 Int_t tempmem = meminfo->fMemUsed;
08e1a23e 618
a1069ee1 619 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 620
621 Int_t firstEvent = 0,lastEvent = 0;
622 TTree *t = (TTree*) file->Get("esdTree");
623 AliESDEvent *esd = new AliESDEvent();
624 esd->ReadFromTree(t);
625
103d3fba 626 gSystem->GetMemInfo(meminfo);
627 AliInfo(Form("After the esd initialization - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
628 tempmem = meminfo->fMemUsed;
629
08e1a23e 630 t->GetEntry(0);
631 Int_t iInitRunNumber = esd->GetRunNumber();
632
633 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
634 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
635 ntrack = 0;
636 nPos = 0;
637 nNeg = 0;
638 nNeutr =0;
639 nK0s = 0;
640 nNeutrons = 0;
641 nPi0s = 0;
642 nGamas = 0;
643 nProtons = 0;
644 nKaons = 0;
645 nPions = 0;
646 nMuons = 0;
ba4804f9 647 nFWMuons = 0;
08e1a23e 648 nElectrons = 0;
649 nCh1GeV = 0;
650 nCh3GeV = 0;
651 nCh10GeV = 0;
652 nMu1GeV = 0;
653 nMu3GeV = 0;
654 nMu10GeV = 0;
655 nEl1GeV = 0;
656 nEl3GeV = 0;
657 nEl10GeV = 0;
658 maxPt = .0;
73e1181d 659 etamaxPt = -999.;
660 phimaxPt = -999.;
08e1a23e 661 meanPt = .0;
662 totalP = .0;
663 fVertexflag = 1;
664
665 t->GetEntry(iEventNumber);
666 iRunNumber = esd->GetRunNumber();
667 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
668 const AliESDVertex * vertexIn = esd->GetVertex();
669 fVertexName = vertexIn->GetName();
670 if(fVertexName == "default") fVertexflag = 0;
671
672 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
673 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
674 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
675 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
676 UInt_t status = esdTrack->GetStatus();
677
678 //select only tracks with ITS refit
679 if ((status&AliESDtrack::kITSrefit)==0) continue;
680 //select only tracks with TPC refit
681 if ((status&AliESDtrack::kTPCrefit)==0) continue;
682
683 //select only tracks with the "combined PID"
684 if ((status&AliESDtrack::kESDpid)==0) continue;
685 Double_t p[3];
686 esdTrack->GetPxPyPz(p);
60e55aee 687 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
688 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
689 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 690 totalP += momentum;
691 meanPt += fPt;
73e1181d 692 if(fPt > maxPt) {
693 maxPt = fPt;
694 etamaxPt = esdTrack->Eta();
695 phimaxPt = esdTrack->Phi();
696 }
08e1a23e 697
73e1181d 698
08e1a23e 699 if(esdTrack->GetSign() > 0) {
700 nPos++;
701 if(fPt > fLowPtCut) nCh1GeV++;
702 if(fPt > fHighPtCut) nCh3GeV++;
703 if(fPt > fVeryHighPtCut) nCh10GeV++;
704 }
705 if(esdTrack->GetSign() < 0) {
706 nNeg++;
707 if(fPt > fLowPtCut) nCh1GeV++;
708 if(fPt > fHighPtCut) nCh3GeV++;
709 if(fPt > fVeryHighPtCut) nCh10GeV++;
710 }
711 if(esdTrack->GetSign() == 0) nNeutr++;
712
713 //PID
714 Double_t prob[5];
715 esdTrack->GetESDpid(prob);
716
717 Double_t rcc = 0.0;
718 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
719 if(rcc == 0.0) continue;
720 //Bayes' formula
721 Double_t w[5];
722 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
723
724 //protons
725 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
726 //kaons
727 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
728 //pions
729 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
730 //electrons
731 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
732 nElectrons++;
733 if(fPt > fLowPtCut) nEl1GeV++;
734 if(fPt > fHighPtCut) nEl3GeV++;
735 if(fPt > fVeryHighPtCut) nEl10GeV++;
736 }
737 ntrack++;
738 }//esd track loop
739
740 /////////////
741 //muon code//
742 ////////////
743 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
744 // loop over all reconstructed tracks (also first track of combination)
745 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
746 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
747 if (muonTrack == 0x0) continue;
748
749 // Coordinates at vertex
750 fZ = muonTrack->GetZ();
751 fY = muonTrack->GetBendingCoor();
752 fX = muonTrack->GetNonBendingCoor();
753
754 fThetaX = muonTrack->GetThetaX();
755 fThetaY = muonTrack->GetThetaY();
756
757 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
758 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
759 fPxRec = fPzRec * TMath::Tan(fThetaX);
760 fPyRec = fPzRec * TMath::Tan(fThetaY);
761 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
762
763 //ChiSquare of the track if needed
764 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
765 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
766 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
767
768 // total number of muons inside a vertex cut
769 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
770 nMuons++;
ba4804f9 771 nFWMuons++;
08e1a23e 772 if(fEPvector.Pt() > fLowPtCut) {
773 nMu1GeV++;
774 if(fEPvector.Pt() > fHighPtCut) {
775 nMu3GeV++;
776 if (fEPvector.Pt() > fVeryHighPtCut) {
777 nMu10GeV++;
778 }
779 }
780 }
781 }
782 }//muon track loop
783
784 // Fill the event tags
785 if(ntrack != 0) meanPt = meanPt/ntrack;
786
7e3c2e04 787 //First physics data
788 const AliMultiplicity *spdMult = esd->GetMultiplicity();
789 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
790 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
791 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
792
4c454ade 793 AliESDVZERO *vzeroData = esd->GetVZEROData();
794 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
795 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
796 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
797 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
798
7e3c2e04 799 //evTag->SetEventId(iEventNumber+1);
800 evTag->SetPeriodNumber(esd->GetPeriodNumber());
801 evTag->SetOrbitNumber(esd->GetOrbitNumber());
802 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
803
08e1a23e 804 evTag->SetGUID(fguid);
805 evTag->SetMD5(fmd5);
806 evTag->SetTURL(fturl);
807 evTag->SetSize(size);
808 evTag->SetVertexX(vertexIn->GetXv());
809 evTag->SetVertexY(vertexIn->GetYv());
810 evTag->SetVertexZ(vertexIn->GetZv());
811 evTag->SetVertexZError(vertexIn->GetZRes());
812 evTag->SetVertexFlag(fVertexflag);
813
814 evTag->SetT0VertexZ(esd->GetT0zVertex());
815
816 evTag->SetTriggerMask(esd->GetTriggerMask());
817 evTag->SetTriggerCluster(esd->GetTriggerCluster());
818
819 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
820 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
a85132e7 821 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 822 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
823 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
824 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
825
826
827 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
828 evTag->SetNumOfPosTracks(nPos);
829 evTag->SetNumOfNegTracks(nNeg);
830 evTag->SetNumOfNeutrTracks(nNeutr);
831
832 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
833 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
834 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
835 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
836
837 evTag->SetNumOfProtons(nProtons);
838 evTag->SetNumOfKaons(nKaons);
839 evTag->SetNumOfPions(nPions);
840 evTag->SetNumOfMuons(nMuons);
ba4804f9 841 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 842 evTag->SetNumOfElectrons(nElectrons);
843 evTag->SetNumOfPhotons(nGamas);
844 evTag->SetNumOfPi0s(nPi0s);
845 evTag->SetNumOfNeutrons(nNeutrons);
846 evTag->SetNumOfKaon0s(nK0s);
847
848 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
849 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
850 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
851 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
852 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
853 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
854 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
855 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
856 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
857
a69c1246 858 tmp.Clear();
859 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
860 tmp.Clear();
861 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 862
863 evTag->SetTotalMomentum(totalP);
864 evTag->SetMeanPt(meanPt);
865 evTag->SetMaxPt(maxPt);
73e1181d 866 evTag->SetEtaMaxPt(etamaxPt);
867 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 868
869 tag->SetRunId(iInitRunNumber);
870 if(fIsSim) tag->SetDataType(0);
871 else tag->SetDataType(1);
872 tag->AddEventTag(*evTag);
873 }//event loop
874 lastEvent = iNumberOfEvents;
875
103d3fba 876 gSystem->GetMemInfo(meminfo);
877 AliInfo(Form("After the event and track loop - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
878 tempmem = meminfo->fMemUsed;
08e1a23e 879 t->Delete("");
880
103d3fba 881 gSystem->GetMemInfo(meminfo);
882 AliInfo(Form("After the t->Delete - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
883 tempmem = meminfo->fMemUsed;
884
08e1a23e 885 TString localFileName = "Run"; localFileName += tag->GetRunId();
886 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
887 localFileName += ".ESD.tag.root";
888
889 TString fileName;
890
891 if(fStorage == 0) {
892 fileName = localFileName.Data();
893 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
894 }
895 else if(fStorage == 1) {
896 TString alienLocation = "/alien";
897 alienLocation += gGrid->Pwd();
898 alienLocation += fgridpath.Data();
899 alienLocation += "/";
900 alienLocation += localFileName;
901 alienLocation += "?se=";
902 alienLocation += fSE.Data();
903 fileName = alienLocation.Data();
904 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
905 }
906
907 TFile* ftag = TFile::Open(fileName, "recreate");
908 ftag->cd();
7ee67d2a 909 ttag.Fill();
910 tag->Clear();
08e1a23e 911 ttag.Write();
912 ftag->Close();
913
103d3fba 914 gSystem->GetMemInfo(meminfo);
915 AliInfo(Form("After the file closing - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
916 tempmem = meminfo->fMemUsed;
917
08e1a23e 918 delete ftag;
919 delete esd;
920
921 delete tag;
103d3fba 922 gSystem->GetMemInfo(meminfo);
923 AliInfo(Form("After the delete objects - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
08e1a23e 924}
925
926//_____________________________________________________________________________
927void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
928 //private method that creates tag files
929 /////////////
930 //muon code//
931 ////////////
932 Double_t fMUONMASS = 0.105658369;
933 //Variables
934 Double_t fX,fY,fZ ;
935 Double_t fThetaX, fThetaY, fPyz, fChisquare;
936 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
937 Int_t fCharge;
938 TLorentzVector fEPvector;
939
940 Float_t fZVertexCut = 10.0;
941 Float_t fRhoVertexCut = 2.0;
942
943 Float_t fLowPtCut = 1.0;
944 Float_t fHighPtCut = 3.0;
945 Float_t fVeryHighPtCut = 10.0;
946 ////////////
947
948 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
949
950 // Creates the tags for all the events in a given ESD file
951 Bool_t fIsSim = kTRUE;
952 Int_t ntrack;
ba4804f9 953 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 954 Int_t nPos, nNeg, nNeutr;
955 Int_t nK0s, nNeutrons, nPi0s, nGamas;
956 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
957 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
958 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 959 Float_t maxPt = .0, etamaxPt = -999, phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 960 Int_t fVertexflag;
961 Int_t iRunNumber = 0;
962 TString fVertexName;
a69c1246 963 TRefArray tmp;
08e1a23e 964
965 AliRunTag *tag = new AliRunTag();
966 AliEventTag *evTag = new AliEventTag();
967 TTree ttag("T","A Tree with event tags");
968 TBranch * btag = ttag.Branch("AliTAG", &tag);
969 btag->SetCompressionLevel(9);
970
a1069ee1 971 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 972
973 Int_t firstEvent = 0,lastEvent = 0;
974
975 TTree *t = (TTree*) file->Get("esdTree");
976 AliESDEvent *esd = new AliESDEvent();
977 esd->ReadFromTree(t);
978
979 t->GetEntry(0);
980 Int_t iInitRunNumber = esd->GetRunNumber();
981
982 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
983 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
984 ntrack = 0;
985 nPos = 0;
986 nNeg = 0;
987 nNeutr =0;
988 nK0s = 0;
989 nNeutrons = 0;
990 nPi0s = 0;
991 nGamas = 0;
992 nProtons = 0;
993 nKaons = 0;
994 nPions = 0;
995 nMuons = 0;
ba4804f9 996 nFWMuons = 0;
08e1a23e 997 nElectrons = 0;
998 nCh1GeV = 0;
999 nCh3GeV = 0;
1000 nCh10GeV = 0;
1001 nMu1GeV = 0;
1002 nMu3GeV = 0;
1003 nMu10GeV = 0;
1004 nEl1GeV = 0;
1005 nEl3GeV = 0;
1006 nEl10GeV = 0;
1007 maxPt = .0;
73e1181d 1008 etamaxPt = -999.;
1009 phimaxPt = -999.;
08e1a23e 1010 meanPt = .0;
1011 totalP = .0;
1012 fVertexflag = 1;
1013
1014 t->GetEntry(iEventNumber);
1015 iRunNumber = esd->GetRunNumber();
1016 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
1017 const AliESDVertex * vertexIn = esd->GetVertex();
1018 fVertexName = vertexIn->GetName();
1019 if(fVertexName == "default") fVertexflag = 0;
1020
1021 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
1022 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
1023 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
1024 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
1025 UInt_t status = esdTrack->GetStatus();
1026
1027 //select only tracks with ITS refit
1028 if ((status&AliESDtrack::kITSrefit)==0) continue;
1029 //select only tracks with TPC refit
1030 if ((status&AliESDtrack::kTPCrefit)==0) continue;
1031
1032 //select only tracks with the "combined PID"
1033 if ((status&AliESDtrack::kESDpid)==0) continue;
1034 Double_t p[3];
1035 esdTrack->GetPxPyPz(p);
60e55aee 1036 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
1037 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
1038 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 1039 totalP += momentum;
1040 meanPt += fPt;
73e1181d 1041 if(fPt > maxPt) {
1042 maxPt = fPt;
1043 etamaxPt = esdTrack->Eta();
1044 phimaxPt = esdTrack->Phi();
1045 }
1046
08e1a23e 1047
1048 if(esdTrack->GetSign() > 0) {
1049 nPos++;
1050 if(fPt > fLowPtCut) nCh1GeV++;
1051 if(fPt > fHighPtCut) nCh3GeV++;
1052 if(fPt > fVeryHighPtCut) nCh10GeV++;
1053 }
1054 if(esdTrack->GetSign() < 0) {
1055 nNeg++;
1056 if(fPt > fLowPtCut) nCh1GeV++;
1057 if(fPt > fHighPtCut) nCh3GeV++;
1058 if(fPt > fVeryHighPtCut) nCh10GeV++;
1059 }
1060 if(esdTrack->GetSign() == 0) nNeutr++;
1061
1062 //PID
1063 Double_t prob[5];
1064 esdTrack->GetESDpid(prob);
1065
1066 Double_t rcc = 0.0;
1067 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
1068 if(rcc == 0.0) continue;
1069 //Bayes' formula
1070 Double_t w[5];
1071 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
1072
1073 //protons
1074 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
1075 //kaons
1076 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
1077 //pions
1078 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
1079 //electrons
1080 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
1081 nElectrons++;
1082 if(fPt > fLowPtCut) nEl1GeV++;
1083 if(fPt > fHighPtCut) nEl3GeV++;
1084 if(fPt > fVeryHighPtCut) nEl10GeV++;
1085 }
1086 ntrack++;
1087 }//esd track loop
1088
1089 /////////////
1090 //muon code//
1091 ////////////
1092 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
1093 // loop over all reconstructed tracks (also first track of combination)
1094 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
1095 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
1096 if (muonTrack == 0x0) continue;
1097
1098 // Coordinates at vertex
1099 fZ = muonTrack->GetZ();
1100 fY = muonTrack->GetBendingCoor();
1101 fX = muonTrack->GetNonBendingCoor();
1102
1103 fThetaX = muonTrack->GetThetaX();
1104 fThetaY = muonTrack->GetThetaY();
1105
1106 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
1107 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
1108 fPxRec = fPzRec * TMath::Tan(fThetaX);
1109 fPyRec = fPzRec * TMath::Tan(fThetaY);
1110 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
1111
1112 //ChiSquare of the track if needed
1113 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
1114 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
1115 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
1116
1117 // total number of muons inside a vertex cut
1118 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
1119 nMuons++;
ba4804f9 1120 nFWMuons++;
08e1a23e 1121 if(fEPvector.Pt() > fLowPtCut) {
1122 nMu1GeV++;
1123 if(fEPvector.Pt() > fHighPtCut) {
1124 nMu3GeV++;
1125 if (fEPvector.Pt() > fVeryHighPtCut) {
1126 nMu10GeV++;
1127 }
1128 }
1129 }
1130 }
1131 }//muon track loop
1132
1133 // Fill the event tags
1134 if(ntrack != 0) meanPt = meanPt/ntrack;
1135
7e3c2e04 1136 //First physics data
1137 const AliMultiplicity *spdMult = esd->GetMultiplicity();
1138 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
1139 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
1140 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
1141
4c454ade 1142 AliESDVZERO *vzeroData = esd->GetVZEROData();
1143 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
1144 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
1145 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
1146 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
1147
7e3c2e04 1148 //evTag->SetEventId(iEventNumber+1);
1149 evTag->SetPeriodNumber(esd->GetPeriodNumber());
1150 evTag->SetOrbitNumber(esd->GetOrbitNumber());
1151 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
08e1a23e 1152 evTag->SetPath(filepath);
1153
1154 evTag->SetVertexX(vertexIn->GetXv());
1155 evTag->SetVertexY(vertexIn->GetYv());
1156 evTag->SetVertexZ(vertexIn->GetZv());
1157 evTag->SetVertexZError(vertexIn->GetZRes());
1158 evTag->SetVertexFlag(fVertexflag);
1159
1160 evTag->SetT0VertexZ(esd->GetT0zVertex());
1161
1162 evTag->SetTriggerMask(esd->GetTriggerMask());
1163 evTag->SetTriggerCluster(esd->GetTriggerCluster());
1164
1165 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
1166 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
a85132e7 1167 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 1168 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
1169 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
1170 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
1171
1172
1173 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
1174 evTag->SetNumOfPosTracks(nPos);
1175 evTag->SetNumOfNegTracks(nNeg);
1176 evTag->SetNumOfNeutrTracks(nNeutr);
1177
1178 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
1179 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
1180 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
1181 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
1182
1183 evTag->SetNumOfProtons(nProtons);
1184 evTag->SetNumOfKaons(nKaons);
1185 evTag->SetNumOfPions(nPions);
1186 evTag->SetNumOfMuons(nMuons);
ba4804f9 1187 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 1188 evTag->SetNumOfElectrons(nElectrons);
1189 evTag->SetNumOfPhotons(nGamas);
1190 evTag->SetNumOfPi0s(nPi0s);
1191 evTag->SetNumOfNeutrons(nNeutrons);
1192 evTag->SetNumOfKaon0s(nK0s);
1193
1194 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
1195 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
1196 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
1197 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
1198 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
1199 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
1200 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
1201 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
1202 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
1203
a69c1246 1204 tmp.Clear();
1205 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
1206 tmp.Clear();
1207 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 1208
1209 evTag->SetTotalMomentum(totalP);
1210 evTag->SetMeanPt(meanPt);
1211 evTag->SetMaxPt(maxPt);
73e1181d 1212 evTag->SetEtaMaxPt(etamaxPt);
1213 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 1214
1215 tag->SetRunId(iInitRunNumber);
1216 if(fIsSim) tag->SetDataType(0);
1217 else tag->SetDataType(1);
1218 tag->AddEventTag(*evTag);
1219 }//event loop
1220 lastEvent = iNumberOfEvents;
1221
1222 t->Delete("");
1223
08e1a23e 1224 TString localFileName = "Run"; localFileName += tag->GetRunId();
1225 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
1226 localFileName += ".ESD.tag.root";
1227
1228 TString fileName;
1229
1230 if(fStorage == 0) {
1231 fileName = localFileName.Data();
1232 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
1233 }
1234 else if(fStorage == 1) {
1235 TString alienLocation = "/alien";
1236 alienLocation += gGrid->Pwd();
1237 alienLocation += fgridpath.Data();
1238 alienLocation += "/";
1239 alienLocation += localFileName;
1240 alienLocation += "?se=";
1241 alienLocation += fSE.Data();
1242 fileName = alienLocation.Data();
1243 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
1244 }
1245
1246 TFile* ftag = TFile::Open(fileName, "recreate");
1247 ftag->cd();
7ee67d2a 1248 ttag.Fill();
1249 tag->Clear();
08e1a23e 1250 ttag.Write();
1251 ftag->Close();
1252
1253 delete ftag;
1254 delete esd;
1255
1256 delete tag;
1257}
1258
1259//_____________________________________________________________________________
27293674 1260void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, AliGRPObject *grpData, ULong_t * qa, Bool_t * es, Int_t qalength, Int_t eslength) {
08e1a23e 1261 //GRP
1262 Float_t lhcLuminosity = 0.0;
1263 TString lhcState = "test";
44e45fac 1264 //UInt_t detectorMask = 0;
1265 Int_t detectorMask = 0;
08e1a23e 1266
44e45fac 1267 detectorMask = grpData->GetDetectorMask();
1268 time_t startTime = grpData->GetTimeStart();
126f4d0c 1269 TTimeStamp *t1 = new TTimeStamp(startTime);
44e45fac 1270 time_t endTime = grpData->GetTimeEnd();
1271 TTimeStamp *t2 = new TTimeStamp(endTime);
1272 const char* beamtype = grpData->GetBeamType();
1273 Float_t beamenergy = grpData->GetBeamEnergy();
126f4d0c 1274
1275
08e1a23e 1276 /////////////
1277 //muon code//
1278 ////////////
1279 Double_t fMUONMASS = 0.105658369;
1280 //Variables
1281 Double_t fX,fY,fZ ;
1282 Double_t fThetaX, fThetaY, fPyz, fChisquare;
1283 Double_t fPxRec,fPyRec, fPzRec, fEnergy;
1284 Int_t fCharge;
1285 TLorentzVector fEPvector;
1286
1287 Float_t fZVertexCut = 10.0;
1288 Float_t fRhoVertexCut = 2.0;
1289
1290 Float_t fLowPtCut = 1.0;
1291 Float_t fHighPtCut = 3.0;
1292 Float_t fVeryHighPtCut = 10.0;
1293 ////////////
1294
1295 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
1296
1297 // Creates the tags for all the events in a given ESD file
1298 Int_t ntrack;
ba4804f9 1299 Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
08e1a23e 1300 Int_t nPos, nNeg, nNeutr;
1301 Int_t nK0s, nNeutrons, nPi0s, nGamas;
1302 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
1303 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
1304 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
73e1181d 1305 Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
08e1a23e 1306 Int_t fVertexflag;
1307 Int_t iRunNumber = 0;
1308 TString fVertexName("default");
a69c1246 1309 TRefArray tmp;
08e1a23e 1310
a1069ee1 1311 AliInfo(Form("Creating the ESD tags......."));
08e1a23e 1312
1313 TFile *file = TFile::Open("AliESDs.root");
1314 if (!file || !file->IsOpen()) {
1315 AliError(Form("opening failed"));
1316 delete file;
1317 return ;
1318 }
1319 Int_t lastEvent = 0;
1320 TTree *b = (TTree*) file->Get("esdTree");
1321 AliESDEvent *esd = new AliESDEvent();
1322 esd->ReadFromTree(b);
1323
1324 b->GetEntry(fFirstEvent);
1325 Int_t iInitRunNumber = esd->GetRunNumber();
1326
1327 Int_t iNumberOfEvents = (Int_t)b->GetEntries();
fcc6b05f 1328 if(fLastEvent == -1) lastEvent = (Int_t)b->GetEntries();
1329 else lastEvent = fLastEvent;
1330
1331 char fileName[256];
1332 sprintf(fileName, "Run%d.Event%d_%d.ESD.tag.root",
517aef4e 1333 iInitRunNumber,fFirstEvent,lastEvent);
fcc6b05f 1334 AliInfo(Form("writing tags to file %s", fileName));
1335 AliDebug(1, Form("writing tags to file %s", fileName));
1336
1337 TFile* ftag = TFile::Open(fileName, "recreate");
1338
517aef4e 1339 AliRunTag *tag = new AliRunTag();
1340 AliEventTag *evTag = new AliEventTag();
1341 TTree ttag("T","A Tree with event tags");
1342 TBranch * btag = ttag.Branch("AliTAG", &tag);
1343 btag->SetCompressionLevel(9);
1344
08e1a23e 1345 if(fLastEvent != -1) iNumberOfEvents = fLastEvent + 1;
1346 for (Int_t iEventNumber = fFirstEvent; iEventNumber < iNumberOfEvents; iEventNumber++) {
1347 ntrack = 0;
1348 nPos = 0;
1349 nNeg = 0;
1350 nNeutr =0;
1351 nK0s = 0;
1352 nNeutrons = 0;
1353 nPi0s = 0;
1354 nGamas = 0;
1355 nProtons = 0;
1356 nKaons = 0;
1357 nPions = 0;
1358 nMuons = 0;
ba4804f9 1359 nFWMuons = 0;
08e1a23e 1360 nElectrons = 0;
1361 nCh1GeV = 0;
1362 nCh3GeV = 0;
1363 nCh10GeV = 0;
1364 nMu1GeV = 0;
1365 nMu3GeV = 0;
1366 nMu10GeV = 0;
1367 nEl1GeV = 0;
1368 nEl3GeV = 0;
1369 nEl10GeV = 0;
1370 maxPt = .0;
73e1181d 1371 etamaxPt = -999.;
1372 phimaxPt = -999.;
08e1a23e 1373 meanPt = .0;
1374 totalP = .0;
1375 fVertexflag = 0;
1376
1377 b->GetEntry(iEventNumber);
1378 iRunNumber = esd->GetRunNumber();
1379 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
1380 const AliESDVertex * vertexIn = esd->GetVertex();
1381 if (!vertexIn) AliError("ESD has not defined vertex.");
1382 if (vertexIn) fVertexName = vertexIn->GetName();
1383 if(fVertexName != "default") fVertexflag = 1;
1384 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
1385 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
1386 UInt_t status = esdTrack->GetStatus();
1387
1388 //select only tracks with ITS refit
1389 if ((status&AliESDtrack::kITSrefit)==0) continue;
1390 //select only tracks with TPC refit
1391 if ((status&AliESDtrack::kTPCrefit)==0) continue;
1392
1393 //select only tracks with the "combined PID"
1394 if ((status&AliESDtrack::kESDpid)==0) continue;
1395 Double_t p[3];
1396 esdTrack->GetPxPyPz(p);
60e55aee 1397 Double_t pt2 = p[0]*p[0]+p[1]*p[1];
1398 Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
1399 Double_t fPt = TMath::Sqrt(pt2);
08e1a23e 1400 totalP += momentum;
1401 meanPt += fPt;
73e1181d 1402 if(fPt > maxPt) {
1403 maxPt = fPt;
1404 phimaxPt = esdTrack->Eta();
1405 etamaxPt = esdTrack->Phi();
1406 }
08e1a23e 1407
1408 if(esdTrack->GetSign() > 0) {
1409 nPos++;
1410 if(fPt > fLowPtCut) nCh1GeV++;
1411 if(fPt > fHighPtCut) nCh3GeV++;
1412 if(fPt > fVeryHighPtCut) nCh10GeV++;
1413 }
1414 if(esdTrack->GetSign() < 0) {
1415 nNeg++;
1416 if(fPt > fLowPtCut) nCh1GeV++;
1417 if(fPt > fHighPtCut) nCh3GeV++;
1418 if(fPt > fVeryHighPtCut) nCh10GeV++;
1419 }
1420 if(esdTrack->GetSign() == 0) nNeutr++;
1421
1422 //PID
1423 Double_t prob[5];
1424 esdTrack->GetESDpid(prob);
1425
1426 Double_t rcc = 0.0;
1427 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
1428 if(rcc == 0.0) continue;
1429 //Bayes' formula
1430 Double_t w[5];
1431 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
1432
1433 //protons
1434 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
1435 //kaons
1436 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
1437 //pions
1438 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
1439 //electrons
1440 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
1441 nElectrons++;
1442 if(fPt > fLowPtCut) nEl1GeV++;
1443 if(fPt > fHighPtCut) nEl3GeV++;
1444 if(fPt > fVeryHighPtCut) nEl10GeV++;
1445 }
1446 ntrack++;
1447 }//track loop
1448
1449 /////////////
1450 //muon code//
1451 ////////////
1452 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
1453 // loop over all reconstructed tracks (also first track of combination)
1454 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
1455 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
1456 if (muonTrack == 0x0) continue;
1457
1458 // Coordinates at vertex
1459 fZ = muonTrack->GetZ();
1460 fY = muonTrack->GetBendingCoor();
1461 fX = muonTrack->GetNonBendingCoor();
1462
1463 fThetaX = muonTrack->GetThetaX();
1464 fThetaY = muonTrack->GetThetaY();
1465
1466 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
1467 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
1468 fPxRec = fPzRec * TMath::Tan(fThetaX);
1469 fPyRec = fPzRec * TMath::Tan(fThetaY);
1470 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
1471
1472 //ChiSquare of the track if needed
1473 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
1474 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
1475 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
1476
1477 // total number of muons inside a vertex cut
1478 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
1479 nMuons++;
ba4804f9 1480 nFWMuons++;
08e1a23e 1481 if(fEPvector.Pt() > fLowPtCut) {
1482 nMu1GeV++;
1483 if(fEPvector.Pt() > fHighPtCut) {
1484 nMu3GeV++;
1485 if (fEPvector.Pt() > fVeryHighPtCut) {
1486 nMu10GeV++;
1487 }
1488 }
1489 }
1490 }
1491 }//muon track loop
7e3c2e04 1492
08e1a23e 1493
1494 // Fill the event tags
1495 if(ntrack != 0)
1496 meanPt = meanPt/ntrack;
7e3c2e04 1497
1498 //First physics data
1499 const AliMultiplicity *spdMult = esd->GetMultiplicity();
1500 evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
1501 evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
1502 evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
1503
4c454ade 1504 AliESDVZERO *vzeroData = esd->GetVZEROData();
1505 evTag->SetMTotV0A(vzeroData->GetMTotV0A());
1506 evTag->SetMTotV0C(vzeroData->GetMTotV0C());
1507 evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
1508 evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
1509
7e3c2e04 1510 //evTag->SetEventId(iEventNumber+1);
1511 evTag->SetPeriodNumber(esd->GetPeriodNumber());
1512 evTag->SetOrbitNumber(esd->GetOrbitNumber());
1513 evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
08e1a23e 1514 if (vertexIn) {
1515 evTag->SetVertexX(vertexIn->GetXv());
1516 evTag->SetVertexY(vertexIn->GetYv());
1517 evTag->SetVertexZ(vertexIn->GetZv());
1518 evTag->SetVertexZError(vertexIn->GetZRes());
1519 }
1520 evTag->SetVertexFlag(fVertexflag);
1521
1522 evTag->SetT0VertexZ(esd->GetT0zVertex());
1523
1524 evTag->SetTriggerMask(esd->GetTriggerMask());
1525 evTag->SetTriggerCluster(esd->GetTriggerCluster());
1526
1527 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
1528 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
1529 evTag->SetZDCNeutron2Energy(esd->GetZDCN2Energy());
1530 evTag->SetZDCProton2Energy(esd->GetZDCP2Energy());
a85132e7 1531 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
08e1a23e 1532 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
1533
1534
1535 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
1536 evTag->SetNumOfPosTracks(nPos);
1537 evTag->SetNumOfNegTracks(nNeg);
1538 evTag->SetNumOfNeutrTracks(nNeutr);
1539
1540 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
1541 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
1542 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
1543 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
1544
1545 evTag->SetNumOfProtons(nProtons);
1546 evTag->SetNumOfKaons(nKaons);
1547 evTag->SetNumOfPions(nPions);
1548 evTag->SetNumOfMuons(nMuons);
ba4804f9 1549 evTag->SetNumOfFWMuons(nFWMuons);
08e1a23e 1550 evTag->SetNumOfElectrons(nElectrons);
1551 evTag->SetNumOfPhotons(nGamas);
1552 evTag->SetNumOfPi0s(nPi0s);
1553 evTag->SetNumOfNeutrons(nNeutrons);
1554 evTag->SetNumOfKaon0s(nK0s);
1555
1556 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
1557 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
1558 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
1559 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
1560 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
1561 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
1562 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
1563 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
1564 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
1565
a69c1246 1566 tmp.Clear();
1567 evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
1568 tmp.Clear();
1569 evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
08e1a23e 1570
1571 evTag->SetTotalMomentum(totalP);
1572 evTag->SetMeanPt(meanPt);
1573 evTag->SetMaxPt(maxPt);
73e1181d 1574 evTag->SetEtaMaxPt(etamaxPt);
1575 evTag->SetPhiMaxPt(phimaxPt);
08e1a23e 1576
1577 tag->SetLHCTag(lhcLuminosity,lhcState);
1578 tag->SetDetectorTag(detectorMask);
1579
1580 tag->SetRunId(iInitRunNumber);
126f4d0c 1581 tag->SetRunStartTime(t1->GetDate());
1582 tag->SetRunStopTime(t2->GetDate());
1583 tag->SetBeamEnergy(beamenergy);
1584 tag->SetBeamType(beamtype);
27293674 1585
1586 //QA setting
9ee5d033 1587 tag->SetQAArray(qa, qalength) ;
27293674 1588 tag->SetEventSpecies(es, eslength) ;
126f4d0c 1589
08e1a23e 1590 tag->AddEventTag(*evTag);
1591 }
08e1a23e 1592
08e1a23e 1593 ftag->cd();
7ee67d2a 1594 ttag.Fill();
1595 tag->Clear();
08e1a23e 1596 ttag.Write();
1597 ftag->Close();
1598 file->cd();
1599 delete tag;
1600 delete evTag;
1601}
1602
517aef4e 1603//_____________________________________________________________________________
1604void AliESDTagCreator::SwitchOffBranches() const {
2856e38b 1605 //
1606 // Switch of branches on user request
517aef4e 1607 TObjArray * tokens = fBranches.Tokenize(" ");
1608 Int_t ntok = tokens->GetEntries();
1609 for (Int_t i = 0; i < ntok; i++) {
1610 TString str = ((TObjString*) tokens->At(i))->GetString();
1611 fChain->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
1612 AliInfo(Form("Branch %s switched off \n", str.Data()));
1613 }
2856e38b 1614}