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