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