]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTagCreator.cxx
Adding the CreateAODTags
[u/mrichter/AliRoot.git] / STEER / AliTagCreator.cxx
CommitLineData
b45e5084 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// AliTagCreator class
18// This is the class to deal with the tag creation (post process)
19// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20//-----------------------------------------------------------------
21
22//ROOT
c336835b 23#include <Riostream.h>
b45e5084 24#include <TFile.h>
25#include <TString.h>
cb1645b7 26#include <TTree.h>
4fd84456 27#include <TSystem.h>
28#include <TChain.h>
2bdb9d38 29#include <TLorentzVector.h>
b45e5084 30
31//ROOT-AliEn
32#include <TGrid.h>
b45e5084 33#include <TGridResult.h>
b45e5084 34
35//AliRoot
36#include "AliRunTag.h"
37#include "AliEventTag.h"
38#include "AliESD.h"
63eeb5f1 39#include "AliESDEvent.h"
b45e5084 40#include "AliESDVertex.h"
b45e5084 41#include "AliLog.h"
42
66eb5864 43#include "AliAODEvent.h"
44#include "AliAODVertex.h"
45#include "AliAODTrack.h"
b45e5084 46
47#include "AliTagCreator.h"
48
49
50ClassImp(AliTagCreator)
51
52
53//______________________________________________________________________________
442646f2 54 AliTagCreator::AliTagCreator() :
55 TObject(),
b2dc099f 56 fSE("ALICE::CERN::se"),
442646f2 57 fgridpath(""),
58 fStorage(0)
59{
b45e5084 60 //==============Default constructor for a AliTagCreator==================
b45e5084 61}
62
b45e5084 63//______________________________________________________________________________
c336835b 64AliTagCreator::~AliTagCreator() {
b45e5084 65//================Default destructor for a AliTagCreator=======================
66}
67
28afeb2e 68//______________________________________________________________________________
c336835b 69void AliTagCreator::SetStorage(Int_t storage) {
cb1645b7 70 // Sets correctly the storage: 0 for local, 1 for GRID
28afeb2e 71 fStorage = storage;
72 if(fStorage == 0)
73 AliInfo(Form("Tags will be stored locally...."));
74 if(fStorage == 1)
75 AliInfo(Form("Tags will be stored in the grid...."));
76 if((fStorage != 0)&&(fStorage != 1))
77 {
78 AliInfo(Form("Storage was not properly set!!!"));
79 abort();
80 }
81}
82
b45e5084 83
84//______________________________________________________________________________
c336835b 85Bool_t AliTagCreator::ReadGridCollection(TGridResult *fresult) {
cb1645b7 86 // Reads the entry of the TGridResult and creates the tags
87 Int_t nEntries = fresult->GetEntries();
b45e5084 88
cb1645b7 89 TString alienUrl;
b45e5084 90 const char *guid;
e16601cf 91 const char *md5;
92 const char *turl;
93 Long64_t size = -1;
94
b45e5084 95 Int_t counter = 0;
c336835b 96 for(Int_t i = 0; i < nEntries; i++) {
97 alienUrl = fresult->GetKey(i,"turl");
98 guid = fresult->GetKey(i,"guid");
99 if(fresult->GetKey(i,"size")) size = atol (fresult->GetKey(i,"size"));
100 md5 = fresult->GetKey(i,"md5");
101 turl = fresult->GetKey(i,"turl");
102 if(md5 && !strlen(guid)) md5 = 0;
103 if(guid && !strlen(guid)) guid = 0;
104
105 TFile *f = TFile::Open(alienUrl,"READ");
106 CreateTag(f,guid,md5,turl,size,counter);
107 f->Close();
108 delete f;
109 counter += 1;
110 }//grid result loop
111
112 return kTRUE;
113}
114
115//______________________________________________________________________________
116Bool_t AliTagCreator::ReadLocalCollection(const char *localpath) {
117 // Checks the different subdirs of the given local path and in the
118 // case where it finds an AliESDs.root file it creates the tags
119
120 void *dira = gSystem->OpenDirectory(localpath);
121 Char_t fPath[256];
122 const char * dirname = 0x0;
123 const char * filename = 0x0;
124 const char * pattern = "AliESDs.root";
125
126 Int_t counter = 0;
2005260b 127 while((dirname = gSystem->GetDirEntry(dira))) {
c336835b 128 sprintf(fPath,"%s/%s",localpath,dirname);
129 void *dirb = gSystem->OpenDirectory(fPath);
2005260b 130 while((filename = gSystem->GetDirEntry(dirb))) {
c336835b 131 if(strstr(filename,pattern)) {
132 TString fESDFileName;
133 fESDFileName = fPath;
134 fESDFileName += "/";
135 fESDFileName += pattern;
136 TFile *f = TFile::Open(fESDFileName,"READ");
137 CreateTag(f,fESDFileName,counter);
138 f->Close();
139 delete f;
140
141 counter += 1;
142 }//pattern check
143 }//child directory's entry loop
144 }//parent directory's entry loop
145
146 return kTRUE;
147}
148
149//______________________________________________________________________________
150Bool_t AliTagCreator::ReadCAFCollection(const char *filename) {
151 // Temporary solution for CAF: Takes as an input the ascii file that
152 // lists the ESDs stored in the SE of the CAF and creates the tags.
153
154 // Open the input stream
155 ifstream in;
156 in.open(filename);
157
158 Int_t counter = 0;
159 TString esdfile;
160 // Read the input list of files and add them to the chain
161 while(in.good()) {
162 in >> esdfile;
163 if (!esdfile.Contains("root")) continue; // protection
164 TFile *f = TFile::Open(esdfile,"READ");
165 CreateTag(f,esdfile,counter);
166 f->Close();
167 delete f;
168
169 counter += 1;
170 }
b45e5084 171
172 return kTRUE;
173}
174
c336835b 175
4fd84456 176//__________________________________________________________________________
c336835b 177Bool_t AliTagCreator::MergeTags() {
4fd84456 178 //Merges the tags and stores the merged tag file
179 //locally if fStorage=0 or in the grid if fStorage=1
180 AliInfo(Form("Merging tags....."));
181 TChain *fgChain = new TChain("T");
182
183 if(fStorage == 0) {
184 const char * tagPattern = "tag";
185 // Open the working directory
186 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
187 const char * name = 0x0;
188 // Add all files matching *pattern* to the chain
189 while((name = gSystem->GetDirEntry(dirp))) {
22c08f55 190 if (strstr(name,tagPattern)) fgChain->Add(name);
4fd84456 191 }//directory loop
192 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
193 }//local mode
194
195 else if(fStorage == 1) {
196 TString alienLocation = gGrid->Pwd();
197 alienLocation += fgridpath.Data();
198 alienLocation += "/";
199
200 TGridResult *tagresult = gGrid->Query(alienLocation,"*tag.root","","");
201 Int_t nEntries = tagresult->GetEntries();
202 for(Int_t i = 0; i < nEntries; i++) {
203 TString alienUrl = tagresult->GetKey(i,"turl");
204 fgChain->Add(alienUrl);
205 }//grid result loop
206 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
207 }//grid mode
208
209 AliRunTag *tag = new AliRunTag;
4fd84456 210 fgChain->SetBranchAddress("AliTAG",&tag);
b2dc099f 211 fgChain->GetEntry(0);
442646f2 212 TString localFileName = "Run"; localFileName += tag->GetRunId();
213 localFileName += ".Merged"; localFileName += ".ESD.tag.root";
214
215 TString filename = 0x0;
216
217 if(fStorage == 0) {
218 filename = localFileName.Data();
219 AliInfo(Form("Writing merged tags to local file: %s",filename.Data()));
220 }
221 else if(fStorage == 1) {
222 TString alienFileName = "/alien";
223 alienFileName += gGrid->Pwd();
224 alienFileName += fgridpath.Data();
225 alienFileName += "/";
226 alienFileName += localFileName;
227 alienFileName += "?se=";
228 alienFileName += fSE.Data();
229 filename = alienFileName.Data();
230 AliInfo(Form("Writing merged tags to grid file: %s",filename.Data()));
231 }
442646f2 232
b2dc099f 233 fgChain->Merge(filename);
442646f2 234
235 return kTRUE;
236}
237
238//__________________________________________________________________________
239Bool_t AliTagCreator::MergeTags(TGridResult *result) {
240 //Merges the tags that are listed in the TGridResult
241 AliInfo(Form("Merging tags....."));
242 TChain *fgChain = new TChain("T");
243
244 Int_t nEntries = result->GetEntries();
245
246 TString alienUrl;
247 for(Int_t i = 0; i < nEntries; i++) {
248 alienUrl = result->GetKey(i,"turl");
249 fgChain->Add(alienUrl);
250 }
251 AliInfo(Form("Chained tag files: %d",fgChain->GetEntries()));
252 AliRunTag *tag = new AliRunTag;
442646f2 253 fgChain->SetBranchAddress("AliTAG",&tag);
b2dc099f 254 fgChain->GetEntry(0);
255
4fd84456 256 TString localFileName = "Run"; localFileName += tag->GetRunId();
257 localFileName += ".Merged"; localFileName += ".ESD.tag.root";
258
4fd84456 259 TString filename = 0x0;
260
261 if(fStorage == 0) {
262 filename = localFileName.Data();
263 AliInfo(Form("Writing merged tags to local file: %s",filename.Data()));
264 }
c336835b 265 else if(fStorage == 1) {
266 TString alienFileName = "/alien";
267 alienFileName += gGrid->Pwd();
268 alienFileName += fgridpath.Data();
269 alienFileName += "/";
270 alienFileName += localFileName;
271 alienFileName += "?se=";
272 alienFileName += fSE.Data();
4fd84456 273 filename = alienFileName.Data();
274 AliInfo(Form("Writing merged tags to grid file: %s",filename.Data()));
275 }
276
b2dc099f 277 fgChain->Merge(filename);
4fd84456 278
279 return kTRUE;
280}
b45e5084 281
282//_____________________________________________________________________________
c336835b 283void AliTagCreator::CreateTag(TFile* file, const char *guid, const char *md5, const char *turl, Long64_t size, Int_t Counter) {
284 //private method that creates tag files
285 TString fguid = guid;
286 TString fmd5 = md5;
287 TString fturl = turl;
2bdb9d38 288 /////////////
289 //muon code//
290 ////////////
56982dd1 291 Double_t fMUONMASS = 0.105658369;
2bdb9d38 292 //Variables
56982dd1 293 Double_t fX,fY,fZ ;
294 Double_t fThetaX, fThetaY, fPyz, fChisquare;
295 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
296 Int_t fCharge;
297 TLorentzVector fEPvector;
298
299 Float_t fZVertexCut = 10.0;
300 Float_t fRhoVertexCut = 2.0;
301
302 Float_t fLowPtCut = 1.0;
303 Float_t fHighPtCut = 3.0;
304 Float_t fVeryHighPtCut = 10.0;
2bdb9d38 305 ////////////
306
307 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
308
cb1645b7 309 // Creates the tags for all the events in a given ESD file
c336835b 310 Bool_t fIsSim = kTRUE;
b45e5084 311 Int_t ntrack;
cb1645b7 312 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
313 Int_t nPos, nNeg, nNeutr;
314 Int_t nK0s, nNeutrons, nPi0s, nGamas;
315 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
316 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
317 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
318 Float_t maxPt = .0, meanPt = .0, totalP = .0;
d1a50cb5 319 Int_t fVertexflag;
ea865c85 320 Int_t iRunNumber = 0;
d1a50cb5 321 TString fVertexName;
b45e5084 322
323 AliRunTag *tag = new AliRunTag();
b45e5084 324 AliEventTag *evTag = new AliEventTag();
325 TTree ttag("T","A Tree with event tags");
4fd84456 326 TBranch * btag = ttag.Branch("AliTAG", &tag);
b45e5084 327 btag->SetCompressionLevel(9);
328
329 AliInfo(Form("Creating the tags......."));
330
331 Int_t firstEvent = 0,lastEvent = 0;
332 TTree *t = (TTree*) file->Get("esdTree");
63eeb5f1 333 AliESDEvent *esd = new AliESDEvent();
334 esd->ReadFromTree(t);
b45e5084 335
63eeb5f1 336 t->GetEntry(0);
ea865c85 337 Int_t iInitRunNumber = esd->GetRunNumber();
338
63eeb5f1 339 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
2bdb9d38 340 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
341 ntrack = 0;
342 nPos = 0;
343 nNeg = 0;
344 nNeutr =0;
345 nK0s = 0;
346 nNeutrons = 0;
347 nPi0s = 0;
348 nGamas = 0;
349 nProtons = 0;
350 nKaons = 0;
351 nPions = 0;
352 nMuons = 0;
353 nElectrons = 0;
354 nCh1GeV = 0;
355 nCh3GeV = 0;
356 nCh10GeV = 0;
357 nMu1GeV = 0;
358 nMu3GeV = 0;
359 nMu10GeV = 0;
360 nEl1GeV = 0;
361 nEl3GeV = 0;
362 nEl10GeV = 0;
363 maxPt = .0;
364 meanPt = .0;
365 totalP = .0;
d1a50cb5 366 fVertexflag = 1;
2bdb9d38 367
63eeb5f1 368 t->GetEntry(iEventNumber);
ea865c85 369 iRunNumber = esd->GetRunNumber();
370 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
2bdb9d38 371 const AliESDVertex * vertexIn = esd->GetVertex();
d1a50cb5 372 fVertexName = vertexIn->GetName();
373 if(fVertexName == "default") fVertexflag = 0;
374
2bdb9d38 375 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
376 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
c336835b 377 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
378 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
2bdb9d38 379 UInt_t status = esdTrack->GetStatus();
b45e5084 380
2bdb9d38 381 //select only tracks with ITS refit
382 if ((status&AliESDtrack::kITSrefit)==0) continue;
383 //select only tracks with TPC refit
384 if ((status&AliESDtrack::kTPCrefit)==0) continue;
b45e5084 385
2bdb9d38 386 //select only tracks with the "combined PID"
387 if ((status&AliESDtrack::kESDpid)==0) continue;
388 Double_t p[3];
389 esdTrack->GetPxPyPz(p);
390 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
391 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
392 totalP += momentum;
393 meanPt += fPt;
394 if(fPt > maxPt) maxPt = fPt;
b45e5084 395
2bdb9d38 396 if(esdTrack->GetSign() > 0) {
397 nPos++;
56982dd1 398 if(fPt > fLowPtCut) nCh1GeV++;
399 if(fPt > fHighPtCut) nCh3GeV++;
400 if(fPt > fVeryHighPtCut) nCh10GeV++;
2bdb9d38 401 }
402 if(esdTrack->GetSign() < 0) {
403 nNeg++;
56982dd1 404 if(fPt > fLowPtCut) nCh1GeV++;
405 if(fPt > fHighPtCut) nCh3GeV++;
406 if(fPt > fVeryHighPtCut) nCh10GeV++;
2bdb9d38 407 }
408 if(esdTrack->GetSign() == 0) nNeutr++;
b45e5084 409
2bdb9d38 410 //PID
411 Double_t prob[5];
412 esdTrack->GetESDpid(prob);
b45e5084 413
2bdb9d38 414 Double_t rcc = 0.0;
415 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
416 if(rcc == 0.0) continue;
417 //Bayes' formula
418 Double_t w[5];
419 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
b45e5084 420
2bdb9d38 421 //protons
422 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
423 //kaons
424 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
425 //pions
426 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
427 //electrons
428 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
429 nElectrons++;
56982dd1 430 if(fPt > fLowPtCut) nEl1GeV++;
431 if(fPt > fHighPtCut) nEl3GeV++;
432 if(fPt > fVeryHighPtCut) nEl10GeV++;
2bdb9d38 433 }
434 ntrack++;
435 }//esd track loop
436
437 /////////////
438 //muon code//
439 ////////////
440 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
441 // loop over all reconstructed tracks (also first track of combination)
442 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
443 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
444 if (muonTrack == 0x0) continue;
b45e5084 445
2bdb9d38 446 // Coordinates at vertex
56982dd1 447 fZ = muonTrack->GetZ();
448 fY = muonTrack->GetBendingCoor();
449 fX = muonTrack->GetNonBendingCoor();
b45e5084 450
56982dd1 451 fThetaX = muonTrack->GetThetaX();
452 fThetaY = muonTrack->GetThetaY();
b45e5084 453
56982dd1 454 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
455 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
456 fPxRec = fPzRec * TMath::Tan(fThetaX);
457 fPyRec = fPzRec * TMath::Tan(fThetaY);
458 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
b45e5084 459
2bdb9d38 460 //ChiSquare of the track if needed
56982dd1 461 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
462 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
463 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
b45e5084 464
2bdb9d38 465 // total number of muons inside a vertex cut
56982dd1 466 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
2bdb9d38 467 nMuons++;
56982dd1 468 if(fEPvector.Pt() > fLowPtCut) {
2bdb9d38 469 nMu1GeV++;
56982dd1 470 if(fEPvector.Pt() > fHighPtCut) {
2bdb9d38 471 nMu3GeV++;
56982dd1 472 if (fEPvector.Pt() > fVeryHighPtCut) {
2bdb9d38 473 nMu10GeV++;
474 }
475 }
476 }
477 }
478 }//muon track loop
479
480 // Fill the event tags
c336835b 481 if(ntrack != 0) meanPt = meanPt/ntrack;
2bdb9d38 482
483 evTag->SetEventId(iEventNumber+1);
c336835b 484 evTag->SetGUID(fguid);
485 evTag->SetMD5(fmd5);
486 evTag->SetTURL(fturl);
2bdb9d38 487 evTag->SetSize(size);
488 evTag->SetVertexX(vertexIn->GetXv());
489 evTag->SetVertexY(vertexIn->GetYv());
490 evTag->SetVertexZ(vertexIn->GetZv());
d1a50cb5 491 evTag->SetVertexZError(vertexIn->GetZRes());
492 evTag->SetVertexFlag(fVertexflag);
2bdb9d38 493
494 evTag->SetT0VertexZ(esd->GetT0zVertex());
495
8bd8ac26 496 evTag->SetTriggerMask(esd->GetTriggerMask());
497 evTag->SetTriggerCluster(esd->GetTriggerCluster());
2bdb9d38 498
32a5cab4 499 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
500 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
2bdb9d38 501 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
32a5cab4 502 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
503 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
2bdb9d38 504 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
505
506
507 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
508 evTag->SetNumOfPosTracks(nPos);
509 evTag->SetNumOfNegTracks(nNeg);
510 evTag->SetNumOfNeutrTracks(nNeutr);
511
512 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
513 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
514 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
515 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
516
517 evTag->SetNumOfProtons(nProtons);
518 evTag->SetNumOfKaons(nKaons);
519 evTag->SetNumOfPions(nPions);
520 evTag->SetNumOfMuons(nMuons);
521 evTag->SetNumOfElectrons(nElectrons);
522 evTag->SetNumOfPhotons(nGamas);
523 evTag->SetNumOfPi0s(nPi0s);
524 evTag->SetNumOfNeutrons(nNeutrons);
525 evTag->SetNumOfKaon0s(nK0s);
526
527 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
528 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
529 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
530 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
531 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
532 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
533 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
534 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
535 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
536
85c60a8e 537 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
538 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
2bdb9d38 539
540 evTag->SetTotalMomentum(totalP);
541 evTag->SetMeanPt(meanPt);
542 evTag->SetMaxPt(maxPt);
543
ea865c85 544 tag->SetRunId(iInitRunNumber);
c336835b 545 if(fIsSim) tag->SetDataType(0);
546 else tag->SetDataType(1);
2bdb9d38 547 tag->AddEventTag(*evTag);
548 }//event loop
cb1645b7 549 lastEvent = iNumberOfEvents;
b45e5084 550
551 t->Delete("");
2bdb9d38 552
b45e5084 553 ttag.Fill();
554 tag->Clear();
555
cb1645b7 556 TString localFileName = "Run"; localFileName += tag->GetRunId();
557 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
558 localFileName += ".ESD.tag.root";
b45e5084 559
cb1645b7 560 TString fileName;
28afeb2e 561
c336835b 562 if(fStorage == 0) {
563 fileName = localFileName.Data();
564 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
565 }
566 else if(fStorage == 1) {
567 TString alienLocation = "/alien";
568 alienLocation += gGrid->Pwd();
569 alienLocation += fgridpath.Data();
570 alienLocation += "/";
571 alienLocation += localFileName;
572 alienLocation += "?se=";
573 alienLocation += fSE.Data();
574 fileName = alienLocation.Data();
575 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
576 }
b45e5084 577
cb1645b7 578 TFile* ftag = TFile::Open(fileName, "recreate");
b45e5084 579 ftag->cd();
580 ttag.Write();
581 ftag->Close();
582
583 delete ftag;
584 delete esd;
585
586 delete tag;
b45e5084 587}
588
c336835b 589//_____________________________________________________________________________
590void AliTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counter) {
591 //private method that creates tag files
592 /////////////
593 //muon code//
594 ////////////
595 Double_t fMUONMASS = 0.105658369;
596 //Variables
597 Double_t fX,fY,fZ ;
598 Double_t fThetaX, fThetaY, fPyz, fChisquare;
599 Double_t fPxRec, fPyRec, fPzRec, fEnergy;
600 Int_t fCharge;
601 TLorentzVector fEPvector;
602
603 Float_t fZVertexCut = 10.0;
604 Float_t fRhoVertexCut = 2.0;
605
606 Float_t fLowPtCut = 1.0;
607 Float_t fHighPtCut = 3.0;
608 Float_t fVeryHighPtCut = 10.0;
609 ////////////
610
611 Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
612
613 // Creates the tags for all the events in a given ESD file
614 Bool_t fIsSim = kTRUE;
615 Int_t ntrack;
616 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
617 Int_t nPos, nNeg, nNeutr;
618 Int_t nK0s, nNeutrons, nPi0s, nGamas;
619 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
620 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
621 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
622 Float_t maxPt = .0, meanPt = .0, totalP = .0;
623 Int_t fVertexflag;
624 Int_t iRunNumber = 0;
625 TString fVertexName;
626
627 AliRunTag *tag = new AliRunTag();
628 AliEventTag *evTag = new AliEventTag();
629 TTree ttag("T","A Tree with event tags");
630 TBranch * btag = ttag.Branch("AliTAG", &tag);
631 btag->SetCompressionLevel(9);
632
633 AliInfo(Form("Creating the tags......."));
634
635 Int_t firstEvent = 0,lastEvent = 0;
636
637 TTree *t = (TTree*) file->Get("esdTree");
63eeb5f1 638 AliESDEvent *esd = new AliESDEvent();
639 esd->ReadFromTree(t);
c336835b 640
63eeb5f1 641 t->GetEntry(0);
c336835b 642 Int_t iInitRunNumber = esd->GetRunNumber();
643
63eeb5f1 644 Int_t iNumberOfEvents = (Int_t)t->GetEntries();
c336835b 645 for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) {
646 ntrack = 0;
647 nPos = 0;
648 nNeg = 0;
649 nNeutr =0;
650 nK0s = 0;
651 nNeutrons = 0;
652 nPi0s = 0;
653 nGamas = 0;
654 nProtons = 0;
655 nKaons = 0;
656 nPions = 0;
657 nMuons = 0;
658 nElectrons = 0;
659 nCh1GeV = 0;
660 nCh3GeV = 0;
661 nCh10GeV = 0;
662 nMu1GeV = 0;
663 nMu3GeV = 0;
664 nMu10GeV = 0;
665 nEl1GeV = 0;
666 nEl3GeV = 0;
667 nEl10GeV = 0;
668 maxPt = .0;
669 meanPt = .0;
670 totalP = .0;
671 fVertexflag = 1;
672
63eeb5f1 673 t->GetEntry(iEventNumber);
c336835b 674 iRunNumber = esd->GetRunNumber();
675 if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!");
676 const AliESDVertex * vertexIn = esd->GetVertex();
677 fVertexName = vertexIn->GetName();
678 if(fVertexName == "default") fVertexflag = 0;
679
680 for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) {
681 AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber);
682 if(esdTrack->GetLabel() != 0) fIsSim = kTRUE;
683 else if(esdTrack->GetLabel() == 0) fIsSim = kFALSE;
684 UInt_t status = esdTrack->GetStatus();
685
686 //select only tracks with ITS refit
687 if ((status&AliESDtrack::kITSrefit)==0) continue;
688 //select only tracks with TPC refit
689 if ((status&AliESDtrack::kTPCrefit)==0) continue;
690
691 //select only tracks with the "combined PID"
692 if ((status&AliESDtrack::kESDpid)==0) continue;
693 Double_t p[3];
694 esdTrack->GetPxPyPz(p);
695 Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
696 Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
697 totalP += momentum;
698 meanPt += fPt;
699 if(fPt > maxPt) maxPt = fPt;
700
701 if(esdTrack->GetSign() > 0) {
702 nPos++;
703 if(fPt > fLowPtCut) nCh1GeV++;
704 if(fPt > fHighPtCut) nCh3GeV++;
705 if(fPt > fVeryHighPtCut) nCh10GeV++;
706 }
707 if(esdTrack->GetSign() < 0) {
708 nNeg++;
709 if(fPt > fLowPtCut) nCh1GeV++;
710 if(fPt > fHighPtCut) nCh3GeV++;
711 if(fPt > fVeryHighPtCut) nCh10GeV++;
712 }
713 if(esdTrack->GetSign() == 0) nNeutr++;
714
715 //PID
716 Double_t prob[5];
717 esdTrack->GetESDpid(prob);
718
719 Double_t rcc = 0.0;
720 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
721 if(rcc == 0.0) continue;
722 //Bayes' formula
723 Double_t w[5];
724 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
725
726 //protons
727 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
728 //kaons
729 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
730 //pions
731 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
732 //electrons
733 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
734 nElectrons++;
735 if(fPt > fLowPtCut) nEl1GeV++;
736 if(fPt > fHighPtCut) nEl3GeV++;
737 if(fPt > fVeryHighPtCut) nEl10GeV++;
738 }
739 ntrack++;
740 }//esd track loop
741
742 /////////////
743 //muon code//
744 ////////////
745 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
746 // loop over all reconstructed tracks (also first track of combination)
747 for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) {
748 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
749 if (muonTrack == 0x0) continue;
750
751 // Coordinates at vertex
752 fZ = muonTrack->GetZ();
753 fY = muonTrack->GetBendingCoor();
754 fX = muonTrack->GetNonBendingCoor();
755
756 fThetaX = muonTrack->GetThetaX();
757 fThetaY = muonTrack->GetThetaY();
758
759 fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum());
760 fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY));
761 fPxRec = fPzRec * TMath::Tan(fThetaX);
762 fPyRec = fPzRec * TMath::Tan(fThetaY);
763 fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
764
765 //ChiSquare of the track if needed
766 fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5);
767 fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec);
768 fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy);
769
770 // total number of muons inside a vertex cut
771 if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
772 nMuons++;
773 if(fEPvector.Pt() > fLowPtCut) {
774 nMu1GeV++;
775 if(fEPvector.Pt() > fHighPtCut) {
776 nMu3GeV++;
777 if (fEPvector.Pt() > fVeryHighPtCut) {
778 nMu10GeV++;
779 }
780 }
781 }
782 }
783 }//muon track loop
784
785 // Fill the event tags
786 if(ntrack != 0) meanPt = meanPt/ntrack;
787
788 evTag->SetEventId(iEventNumber+1);
789 evTag->SetPath(filepath);
790
791 evTag->SetVertexX(vertexIn->GetXv());
792 evTag->SetVertexY(vertexIn->GetYv());
793 evTag->SetVertexZ(vertexIn->GetZv());
794 evTag->SetVertexZError(vertexIn->GetZRes());
795 evTag->SetVertexFlag(fVertexflag);
796
797 evTag->SetT0VertexZ(esd->GetT0zVertex());
798
799 evTag->SetTriggerMask(esd->GetTriggerMask());
800 evTag->SetTriggerCluster(esd->GetTriggerCluster());
801
802 evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy());
803 evTag->SetZDCProton1Energy(esd->GetZDCP1Energy());
804 evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy());
805 evTag->SetZDCNeutron1Energy(esd->GetZDCN2Energy());
806 evTag->SetZDCProton1Energy(esd->GetZDCP2Energy());
807 evTag->SetNumOfParticipants(esd->GetZDCParticipants());
808
809
810 evTag->SetNumOfTracks(esd->GetNumberOfTracks());
811 evTag->SetNumOfPosTracks(nPos);
812 evTag->SetNumOfNegTracks(nNeg);
813 evTag->SetNumOfNeutrTracks(nNeutr);
814
815 evTag->SetNumOfV0s(esd->GetNumberOfV0s());
816 evTag->SetNumOfCascades(esd->GetNumberOfCascades());
817 evTag->SetNumOfKinks(esd->GetNumberOfKinks());
818 evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks());
819
820 evTag->SetNumOfProtons(nProtons);
821 evTag->SetNumOfKaons(nKaons);
822 evTag->SetNumOfPions(nPions);
823 evTag->SetNumOfMuons(nMuons);
824 evTag->SetNumOfElectrons(nElectrons);
825 evTag->SetNumOfPhotons(nGamas);
826 evTag->SetNumOfPi0s(nPi0s);
827 evTag->SetNumOfNeutrons(nNeutrons);
828 evTag->SetNumOfKaon0s(nK0s);
829
830 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
831 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
832 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
833 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
834 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
835 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
836 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
837 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
838 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
839
840 evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
841 evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
842
843 evTag->SetTotalMomentum(totalP);
844 evTag->SetMeanPt(meanPt);
845 evTag->SetMaxPt(maxPt);
846
847 tag->SetRunId(iInitRunNumber);
848 if(fIsSim) tag->SetDataType(0);
849 else tag->SetDataType(1);
850 tag->AddEventTag(*evTag);
851 }//event loop
852 lastEvent = iNumberOfEvents;
853
854 t->Delete("");
855
856 ttag.Fill();
857 tag->Clear();
858
859 TString localFileName = "Run"; localFileName += tag->GetRunId();
860 localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += lastEvent; localFileName += "."; localFileName += Counter;
861 localFileName += ".ESD.tag.root";
862
863 TString fileName;
864
865 if(fStorage == 0) {
866 fileName = localFileName.Data();
867 AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
868 }
869 else if(fStorage == 1) {
870 TString alienLocation = "/alien";
871 alienLocation += gGrid->Pwd();
872 alienLocation += fgridpath.Data();
873 alienLocation += "/";
874 alienLocation += localFileName;
875 alienLocation += "?se=";
876 alienLocation += fSE.Data();
877 fileName = alienLocation.Data();
878 AliInfo(Form("Writing tags to grid file: %s",fileName.Data()));
879 }
880
881 TFile* ftag = TFile::Open(fileName, "recreate");
882 ftag->cd();
883 ttag.Write();
884 ftag->Close();
885
886 delete ftag;
887 delete esd;
888
889 delete tag;
890}
66eb5864 891
892//__________________________________________________________________________
893void AliTagCreator::CreateAODTags(Int_t fFirstEvent, Int_t fLastEvent) {
894 //creates tag files for AODs
895
896 Float_t fLowPtCut = 1.0;
897 Float_t fHighPtCut = 3.0;
898 Float_t fVeryHighPtCut = 10.0;
899 ////////////
900
901 Double_t partFrac[10] = {0.01, 0.01, 0.85, 0.10, 0.05, 0., 0., 0., 0., 0.};
902
903 // Creates the tags for all the events in a given ESD file
904 Int_t ntrack;
905 Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
906 Int_t nPos, nNeg, nNeutr;
907 Int_t nKinks, nV0s, nCascades;
908 Int_t nK0s, nNeutrons, nPi0s, nGamas;
909 Int_t nCh1GeV, nCh3GeV, nCh10GeV;
910 Int_t nMu1GeV, nMu3GeV, nMu10GeV;
911 Int_t nEl1GeV, nEl3GeV, nEl10GeV;
912 Float_t maxPt = .0, meanPt = .0, totalP = .0;
913
914 AliRunTag *tag = new AliRunTag();
915 TTree ttag("T","A Tree with event tags");
916 TBranch * btag = ttag.Branch("AliTAG", &tag);
917 btag->SetCompressionLevel(9);
918
919 //reading the esd tag file
920 TChain *oldTagTree = new TChain("T");
921 const char * tagPattern = "ESD.tag";
922 // Open the working directory
923 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
924 const char * name = 0x0;
925 // Add all files matching *pattern* to the chain
926 while((name = gSystem->GetDirEntry(dirp))) {
927 if (strstr(name,tagPattern)) oldTagTree->Add(name);
928 }//directory loop
929 AliInfo(Form("Chained tag files: %d",oldTagTree->GetEntries()));
930
931 //reading the esd tag file
932 AliRunTag *oldtag = new AliRunTag();
933 TString tagFilename;
934 oldTagTree->SetBranchAddress("AliTAG",&oldtag);
935 oldTagTree->GetEntry(0);
936 tag->CopyStandardContent(oldtag);
937 const TClonesArray *evTagList = oldtag->GetEventTags();
938
939 cout<<"Creating the tags......."<<endl;
940
941 TFile *file = TFile::Open("AliAOD.root");
942 if (!file || !file->IsOpen()) {
943 AliError(Form("opening failed"));
944 delete file;
945 return ;
946 }
947 TTree *aodTree = (TTree*)file->Get("AOD");
948 AliAODEvent *aod = (AliAODEvent*)aodTree->GetUserInfo()->FindObject("AliAODEvent");
949 TIter next(aod->GetList());
950 TObject *el;
951
952 Int_t lastEvent = 0;
953 if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries();
954 else lastEvent = fLastEvent;
955
956 while((el=(TNamed*)next()))
957 aodTree->SetBranchAddress(el->GetName(),aod->GetList()->GetObjectRef(el));
958
959 // loop over events
960 Int_t nEvents = aodTree->GetEntries();
961 for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) {
962 AliEventTag *evTag = (AliEventTag *)evTagList->At(iEventNumber);
963 ntrack = 0;
964 nPos = 0; nNeg = 0; nNeutr =0;
965 nKinks = 0; nV0s = 0; nCascades = 0;
966 nK0s = 0; nNeutrons = 0; nPi0s = 0; nGamas = 0;
967 nProtons = 0; nKaons = 0; nPions = 0; nMuons = 0; nElectrons = 0;
968 nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
969 nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
970 nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
971 maxPt = .0; meanPt = .0; totalP = .0;
972
973 // read events
974 aodTree->GetEvent(iEventNumber);
975
976 // set pointers
977 aod->GetStdContent();
978
979 Int_t nTracks = aod->GetNTracks();
980 cout << "Event: " << iEventNumber+1 << "/" << nEvents <<" - Tracks: "<<nTracks<< endl;
981 // loop over vertices
982 Int_t nVtxs = aod->GetNVertices();
983 for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
984 // print track info
985 AliAODVertex *vertex = aod->GetVertex(nVtx);
986 if(vertex->GetType() == 1) nKinks += 1;
987 if(vertex->GetType() == 2) nV0s += 1;
988 if(vertex->GetType() == 3) nCascades += 1;
989 }
990 for (Int_t nTr = 0; nTr < nTracks; nTr++) {
991 AliAODTrack *track = aod->GetTrack(nTr);
992
993 Double_t fPt = track->Pt();
994 if(fPt > maxPt) maxPt = fPt;
995 if(track->Charge() > 0) {
996 nPos++;
997 if(fPt > fLowPtCut) nCh1GeV++;
998 if(fPt > fHighPtCut) nCh3GeV++;
999 if(fPt > fVeryHighPtCut) nCh10GeV++;
1000 }
1001 if(track->Charge() < 0) {
1002 nNeg++;
1003 if(fPt > fLowPtCut) nCh1GeV++;
1004 if(fPt > fHighPtCut) nCh3GeV++;
1005 if(fPt > fVeryHighPtCut) nCh10GeV++;
1006 }
1007 if(track->Charge() == 0) nNeutr++;
1008
1009 //PID
1010 const Double32_t *prob = track->PID();
1011 Double_t rcc = 0.0;
1012 for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i];
1013 if(rcc == 0.0) continue;
1014 //Bayes' formula
1015 Double_t w[10];
1016 for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc;
1017
1018 //protons
1019 if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++;
1020 //kaons
1021 if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++;
1022 //pions
1023 if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++;
1024 //muons
1025 if ((w[1]>w[4])&&(w[1]>w[3])&&(w[1]>w[2])&&(w[1]>w[0])) {
1026 nMuons++;
1027 if(fPt > fLowPtCut) nMu1GeV++;
1028 if(fPt > fHighPtCut) nMu3GeV++;
1029 if(fPt > fVeryHighPtCut) nMu10GeV++;
1030 }
1031 //electrons
1032 if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) {
1033 nElectrons++;
1034 if(fPt > fLowPtCut) nEl1GeV++;
1035 if(fPt > fHighPtCut) nEl3GeV++;
1036 if(fPt > fVeryHighPtCut) nEl10GeV++;
1037 }
1038
1039 totalP += track->P();
1040 meanPt += fPt;
1041 ntrack++;
1042 }//track loop
1043 // Fill the event tags
1044 if(ntrack != 0)
1045 meanPt = meanPt/ntrack;
1046
1047 evTag->SetEventId(iEventNumber+1);
1048
1049 evTag->SetNumOfTracks(nTracks);
1050 evTag->SetNumOfPosTracks(nPos);
1051 evTag->SetNumOfNegTracks(nNeg);
1052 evTag->SetNumOfNeutrTracks(nNeutr);
1053
1054 evTag->SetNumOfV0s(nV0s);
1055 evTag->SetNumOfCascades(nCascades);
1056 evTag->SetNumOfKinks(nKinks);
1057
1058 evTag->SetNumOfProtons(nProtons);
1059 evTag->SetNumOfKaons(nKaons);
1060 evTag->SetNumOfPions(nPions);
1061 evTag->SetNumOfMuons(nMuons);
1062 evTag->SetNumOfElectrons(nElectrons);
1063 evTag->SetNumOfPhotons(nGamas);
1064 evTag->SetNumOfPi0s(nPi0s);
1065 evTag->SetNumOfNeutrons(nNeutrons);
1066 evTag->SetNumOfKaon0s(nK0s);
1067
1068 evTag->SetNumOfChargedAbove1GeV(nCh1GeV);
1069 evTag->SetNumOfChargedAbove3GeV(nCh3GeV);
1070 evTag->SetNumOfChargedAbove10GeV(nCh10GeV);
1071 evTag->SetNumOfMuonsAbove1GeV(nMu1GeV);
1072 evTag->SetNumOfMuonsAbove3GeV(nMu3GeV);
1073 evTag->SetNumOfMuonsAbove10GeV(nMu10GeV);
1074 evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
1075 evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
1076 evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
1077
1078 evTag->SetTotalMomentum(totalP);
1079 evTag->SetMeanPt(meanPt);
1080 evTag->SetMaxPt(maxPt);
1081 tag->AddEventTag(*evTag);
1082 }//event loop
1083 if(fLastEvent == -1) lastEvent = (Int_t)aodTree->GetEntries();
1084 else lastEvent = fLastEvent;
1085
1086 ttag.Fill();
1087 tag->Clear();
1088
1089 char fileName[256];
1090 sprintf(fileName, "Run%d.Event%d_%d.AOD.tag.root",
1091 tag->GetRunId(),fFirstEvent,lastEvent );
1092 cout<<"writing tags to file "<<fileName<<endl;
1093 AliDebug(1, Form("writing tags to file %s", fileName));
1094
1095 TFile* ftag = TFile::Open(fileName, "recreate");
1096 ftag->cd();
1097 ttag.Write();
1098 ftag->Close();
1099 file->cd();
1100 file->Close();
1101}