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