]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliTagAnalysis.cxx
a macro with TPC,ITS, ITSSPD vertex, global vertex and v0's
[u/mrichter/AliRoot.git] / ANALYSIS / AliTagAnalysis.cxx
CommitLineData
d08133e6 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// AliTagAnalysis class
18// This is the class to deal with the tag analysis
19// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20//-----------------------------------------------------------------
21
22//ROOT
cd305eb1 23#include <Riostream.h>
d08133e6 24#include <TSystem.h>
25#include <TChain.h>
26#include <TFile.h>
27#include <TEventList.h>
28#include <TEntryList.h>
29#include <TTreeFormula.h>
f0f29480 30#include <TMap.h>
d08133e6 31
32//ROOT-AliEn
33#include <TGridResult.h>
34
35#include "AliLog.h"
36
37#include "AliRunTag.h"
38#include "AliEventTag.h"
39#include "AliTagAnalysis.h"
40#include "AliEventTagCuts.h"
2ec6a1d3 41#include "AliDetectorTagCuts.h"
42#include "AliLHCTagCuts.h"
d08133e6 43#include "AliRunTagCuts.h"
44#include "AliXMLCollection.h"
45
46class TTree;
47
48ClassImp(AliTagAnalysis)
49
50//___________________________________________________________________________
51AliTagAnalysis::AliTagAnalysis():
52 TObject(),
53 ftagresult(0x0),
54 fTagDirName(),
6cfbb923 55 fChain(0x0),
cd305eb1 56 fAnalysisType(),
57 fGlobalList(0) {
d08133e6 58 //Default constructor for a AliTagAnalysis
59}
60
6cfbb923 61//___________________________________________________________________________
62AliTagAnalysis::AliTagAnalysis(const char* type):
63 TObject(),
64 ftagresult(0x0),
65 fTagDirName(),
66 fChain(0x0),
cd305eb1 67 fAnalysisType(type),
68 fGlobalList(0) {
6cfbb923 69 //constructor for a AliTagAnalysis
70}
71
d08133e6 72//___________________________________________________________________________
73AliTagAnalysis::~AliTagAnalysis() {
cd305eb1 74 //Default destructor for a AliTagAnalysis
75 if(ftagresult) delete ftagresult;
76 if(fChain) delete fChain;
77 if(fGlobalList) delete fGlobalList;
d08133e6 78}
79
80//___________________________________________________________________________
81Bool_t AliTagAnalysis::AddTagsFile(const char *alienUrl) {
d08133e6 82 // Add a single tags file to the chain
83
84 Bool_t rv = kTRUE ;
85
86 if (! fChain) fChain = new TChain("T");
87
88 TFile *f = TFile::Open(alienUrl,"READ");
89 fChain->Add(alienUrl);
90 AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
91 delete f;
92
93 if (fChain->GetEntries() == 0 )
94 rv = kFALSE ;
95
96 return rv ;
97}
98
99//___________________________________________________________________________
100void AliTagAnalysis::ChainLocalTags(const char *dirname) {
101 //Searches the entries of the provided direcory
102 //Chains the tags that are stored locally
103 fTagDirName = dirname;
104 TString fTagFilename;
105
106 if (! fChain) fChain = new TChain("T");
6cfbb923 107 const char * tagPattern = 0x0;
108 if(fAnalysisType == "ESD") tagPattern = "ESD.tag.root";
109 else if(fAnalysisType == "AOD") tagPattern = "AOD.tag.root";
110 else AliFatal("Only ESD and AOD type is implemented!!!");
111
d08133e6 112 // Open the working directory
113 void * dirp = gSystem->OpenDirectory(fTagDirName);
114 const char * name = 0x0;
115 // Add all files matching *pattern* to the chain
116 while((name = gSystem->GetDirEntry(dirp))) {
117 if (strstr(name,tagPattern)) {
118 fTagFilename = fTagDirName;
119 fTagFilename += "/";
120 fTagFilename += name;
121
122 fChain->Add(fTagFilename);
68550043 123 printf("Tag file %s\n", fTagFilename.Data());
124
d08133e6 125 }//pattern check
126 }//directory loop
127 AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
68550043 128 fChain->ls();
129
d08133e6 130}
131
132
133//___________________________________________________________________________
727d922c 134TChain * AliTagAnalysis::ChainGridTags(TGridResult *res) {
d08133e6 135 //Loops overs the entries of the TGridResult
136 //Chains the tags that are stored in the GRID
137 ftagresult = res;
138 Int_t nEntries = ftagresult->GetEntries();
139
140 if (! fChain) fChain = new TChain("T");
141
142 TString gridname = "alien://";
143 TString alienUrl;
144
145 for(Int_t i = 0; i < nEntries; i++) {
146 alienUrl = ftagresult->GetKey(i,"turl");
147 fChain->Add(alienUrl);
727d922c 148 }//grid result loop
149 return fChain;
d08133e6 150}
151
152
153//___________________________________________________________________________
cd305eb1 154TChain *AliTagAnalysis::QueryTags(AliRunTagCuts *runTagCuts,
155 AliLHCTagCuts *lhcTagCuts,
156 AliDetectorTagCuts *detTagCuts,
157 AliEventTagCuts *evTagCuts) {
d08133e6 158 //Queries the tag chain using the defined
159 //event tag cuts from the AliEventTagCuts object
160 //and returns a TChain along with the associated TEventList
161 AliInfo(Form("Querying the tags........"));
b97856f9 162
68550043 163 Bool_t aod = kFALSE;
164 TString aliceFile;
165 if(fAnalysisType == "ESD") aliceFile = "esdTree";
166 else if(fAnalysisType == "AOD") {
167 aliceFile = "aodTree";
168 aod = kTRUE;
169 }
6cfbb923 170 else AliFatal("Only ESD and AOD type is implemented!!!");
b97856f9 171
d08133e6 172 //ESD file chain
68550043 173 TChain *esdChain = new TChain(aliceFile.Data());
b97856f9 174 //global entry list
cd305eb1 175 fGlobalList = new TEntryList();
d08133e6 176
177 //Defining tag objects
5a561fa0 178 AliRunTag *tag = new AliRunTag;
179 AliEventTag *evTag = new AliEventTag;
d08133e6 180 fChain->SetBranchAddress("AliTAG",&tag);
181
9b4aee57 182 TString guid;
183 TString turl;
184 TString path;
d08133e6 185
68550043 186 TTree* cTree = 0;
9ce6b490 187 TEntryList* localList = new TEntryList();
68550043 188
d08133e6 189 Int_t iAccepted = 0;
68550043 190 Int_t iev = 0;
191 Int_t ientry = 0;
192 Int_t cEntries = 0;
193
d08133e6 194 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
195 fChain->GetEntry(iTagFiles);
68550043 196 TTree* tree = fChain->GetTree();
197 if (cTree != tree) {
198 // Fix for aod tags: for each tree in the chain, merge the entries
199 cTree = tree;
200 cEntries = tree->GetEntries();
201 iev = 0;
202 ientry = 0;
203 }
204
2ec6a1d3 205 if(runTagCuts->IsAccepted(tag)) {
206 if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) {
207 if(detTagCuts->IsAccepted(tag->GetDetectorTags())) {
9ce6b490 208 if ((iev == 0) || !aod) localList->Reset();
2ec6a1d3 209 Int_t iEvents = tag->GetNEvents();
210 const TClonesArray *tagList = tag->GetEventTags();
211 for(Int_t i = 0; i < iEvents; i++) {
212 evTag = (AliEventTag *) tagList->At(i);
213 guid = evTag->GetGUID();
214 turl = evTag->GetTURL();
215 path = evTag->GetPath();
68550043 216 localList->SetTreeName(aliceFile.Data());
217 if(turl!="") localList->SetFileName(turl.Data());
218 else localList->SetFileName(path.Data());
219
220 if(evTagCuts->IsAccepted(evTag)) {
221 if(aod) localList->Enter(iev);
222 else localList->Enter(i);
223 }
224 iev++;
2ec6a1d3 225 }//event loop
68550043 226 if ((ientry == cEntries-1) || !aod) {
227 iAccepted += localList->GetN();
228 if(path != "") esdChain->AddFile(path);
229 else if(turl != "") esdChain->AddFile(turl);
230 fGlobalList->Add(localList);
231 }
2ec6a1d3 232 }//detector tag cuts
233 }//lhc tag cuts
d08133e6 234 }//run tags cut
5a561fa0 235 tag->Clear();
68550043 236 ientry++;
d08133e6 237 }//tag file loop
b97856f9 238 AliInfo(Form("Accepted events: %d",iAccepted));
5d0e8364 239 esdChain->ls();
68550043 240 esdChain->SetEntryList(fGlobalList,"ne");
9ce6b490 241 delete tag;
242
68550043 243 return esdChain;
d08133e6 244}
245
246//___________________________________________________________________________
cd305eb1 247TChain *AliTagAnalysis::QueryTags(const char *fRunCut,
248 const char *fLHCCut,
249 const char *fDetectorCut,
250 const char *fEventCut) {
d08133e6 251 //Queries the tag chain using the defined
252 //event tag cuts from the AliEventTagCuts object
253 //and returns a TChain along with the associated TEventList
254 AliInfo(Form("Querying the tags........"));
255
68550043 256 Bool_t aod = kFALSE;
257 TString aliceFile;
258 if(fAnalysisType == "ESD") aliceFile = "esdTree";
259 else if(fAnalysisType == "AOD") {
260 aliceFile = "aodTree";
261 aod = kTRUE;
262 }
6cfbb923 263 else AliFatal("Only ESD and AOD type is implemented!!!");
b97856f9 264
265 //ESD file chain
68550043 266 TChain *esdChain = new TChain(aliceFile.Data());
b97856f9 267 //global entry list
cd305eb1 268 fGlobalList = new TEntryList();
d08133e6 269
270 //Defining tag objects
940b4031 271 AliRunTag *tag = new AliRunTag;
d08133e6 272 AliEventTag *evTag = new AliEventTag;
273 fChain->SetBranchAddress("AliTAG",&tag);
274
9b4aee57 275 TString guid;
276 TString turl;
277 TString path;
d08133e6 278
279 TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);
2ec6a1d3 280 TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain);
281 TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain);
282 TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
d08133e6 283
940b4031 284 TEntryList* localList = new TEntryList();
68550043 285
286 Int_t iev = 0;
287 Int_t ientry = 0;
288 Int_t cEntries = 0;
289 Int_t current = -1;
d08133e6 290 Int_t iAccepted = 0;
68550043 291
cd305eb1 292 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
d08133e6 293 fChain->GetEntry(iTagFiles);
294 if (current != fChain->GetTreeNumber()) {
295 fRunFormula->UpdateFormulaLeaves();
2ec6a1d3 296 fLHCFormula->UpdateFormulaLeaves();
297 fDetectorFormula->UpdateFormulaLeaves();
d08133e6 298 fEventFormula->UpdateFormulaLeaves();
68550043 299 // Fix for aod tags: for each tree in the chain, merge the entries
300 cEntries = (fChain->GetTree())->GetEntries();
301 iev = 0;
302 ientry = 0;
303 //
d08133e6 304 current = fChain->GetTreeNumber();
305 }
306 if(fRunFormula->EvalInstance(iTagFiles) == 1) {
2ec6a1d3 307 if(fLHCFormula->EvalInstance(iTagFiles) == 1) {
68550043 308 if(fDetectorFormula->EvalInstance(iTagFiles) == 1) {
940b4031 309 if ((iev == 0) || !aod) localList->Reset();
2ec6a1d3 310 Int_t iEvents = fEventFormula->GetNdata();
311 const TClonesArray *tagList = tag->GetEventTags();
312 for(Int_t i = 0; i < iEvents; i++) {
313 evTag = (AliEventTag *) tagList->At(i);
314 guid = evTag->GetGUID();
315 turl = evTag->GetTURL();
316 path = evTag->GetPath();
68550043 317 localList->SetTreeName(aliceFile.Data());
318 localList->SetFileName(turl.Data());
319 if(fEventFormula->EvalInstance(i) == 1) {
320 if(aod) localList->Enter(iev);
321 else localList->Enter(i);
322 }
323 iev++;
2ec6a1d3 324 }//event loop
68550043 325
326 if ((ientry == cEntries-1) || !aod) {
327 if(path != "") esdChain->AddFile(path);
328 else if(turl != "") esdChain->AddFile(turl);
329 fGlobalList->Add(localList);
330 iAccepted += localList->GetN();
331 }
2ec6a1d3 332 }//detector tag cuts
333 }//lhc tag cuts
d08133e6 334 }//run tag cut
68550043 335 tag->Clear();
336 ientry++;
d08133e6 337 }//tag file loop
b97856f9 338 AliInfo(Form("Accepted events: %d",iAccepted));
68550043 339 esdChain->SetEntryList(fGlobalList,"ne");
940b4031 340
341 delete tag;
68550043 342 return esdChain;
d08133e6 343}
344
345//___________________________________________________________________________
cd305eb1 346Bool_t AliTagAnalysis::CreateXMLCollection(const char* name,
347 AliRunTagCuts *runTagCuts,
348 AliLHCTagCuts *lhcTagCuts,
349 AliDetectorTagCuts *detTagCuts,
350 AliEventTagCuts *evTagCuts) {
d08133e6 351 //Queries the tag chain using the defined
352 //event tag cuts from the AliEventTagCuts object
353 //and returns a XML collection
354 AliInfo(Form("Creating the collection........"));
355
68550043 356 Bool_t aod = kFALSE;
357 if(fAnalysisType == "AOD") aod = kTRUE;
358
359
d08133e6 360 AliXMLCollection *collection = new AliXMLCollection();
361 collection->SetCollectionName(name);
362 collection->WriteHeader();
363
9b4aee57 364 TString guid;
365 TString turl;
366 TString lfn;
d08133e6 367
68550043 368 TTree* cTree = 0;
940b4031 369 TEntryList* localList = new TEntryList();
68550043 370 Int_t iAccepted = 0;
371 Int_t iev = 0;
372 Int_t ientry = 0;
373 Int_t cEntries = 0;
374
f0f29480 375 Int_t iRejectedRun = 0;
376 Int_t iRejectedLHC = 0;
377 Int_t iRejectedDet = 0;
378 Int_t iRejectedEvt = 0;
379
380 Int_t iTotalEvents = 0;
381
382 Int_t iAcceptedEvtInFile = 0;
383 Int_t iRejectedEvtInFile = 0;
384
d08133e6 385 //Defining tag objects
940b4031 386 AliRunTag *tag = new AliRunTag;
d08133e6 387 AliEventTag *evTag = new AliEventTag;
388 fChain->SetBranchAddress("AliTAG",&tag);
389
390 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
68550043 391
d08133e6 392 fChain->GetEntry(iTagFiles);
68550043 393 TTree* tree = fChain->GetTree();
394 if (cTree != tree) {
395 // Fix for aod tags: for each tree in the chain, merge the entries
396 cTree = tree;
397 cEntries = tree->GetEntries();
398 iev = 0;
399 ientry = 0;
400 }
401 //Event list
f0f29480 402 iTotalEvents += tag->GetNEvents();
940b4031 403 if ((iev == 0) || !aod) localList->Reset();
2ec6a1d3 404 if(runTagCuts->IsAccepted(tag)) {
405 if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) {
406 if(detTagCuts->IsAccepted(tag->GetDetectorTags())) {
407 Int_t iEvents = tag->GetNEvents();
408 const TClonesArray *tagList = tag->GetEventTags();
f0f29480 409 iRejectedEvtInFile = 0;
410 iAcceptedEvtInFile = 0;
2ec6a1d3 411 for(Int_t i = 0; i < iEvents; i++) {
412 evTag = (AliEventTag *) tagList->At(i);
413 guid = evTag->GetGUID();
414 turl = evTag->GetTURL();
415 lfn = turl(8,turl.Length());
68550043 416 if(evTagCuts->IsAccepted(evTag)) {
417 if(aod) localList->Enter(iev);
418 else localList->Enter(i);
f0f29480 419 iAcceptedEvtInFile++;
420 }
421 else {
422 iRejectedEvt++;
423 iRejectedEvtInFile++;
68550043 424 }
425 iev++;
2ec6a1d3 426 }//event loop
68550043 427 if ((ientry == cEntries-1) || !aod) {
f0f29480 428 iAccepted += localList->GetN();
429 collection->WriteBody(iTagFiles+1,guid,lfn,turl,localList,iAcceptedEvtInFile,iRejectedEvtInFile);
68550043 430 }
2ec6a1d3 431 }//detector tag cuts
f0f29480 432 else {
433 iRejectedDet += tag->GetNEvents();
434 }
2ec6a1d3 435 }//lhc tag cuts
f0f29480 436 else {
437 iRejectedLHC += tag->GetNEvents();
438 }
d08133e6 439 }//run tag cuts
f0f29480 440 else {
441 iRejectedRun += tag->GetNEvents();
442 }
5a561fa0 443 tag->Clear();
68550043 444 ientry++;
d08133e6 445 }//tag file loop
f0f29480 446 collection->WriteSummary(iTotalEvents, iAccepted, iRejectedRun, iRejectedLHC, iRejectedDet, iRejectedEvt);
d08133e6 447 collection->Export();
940b4031 448
449 delete tag;
d08133e6 450 return kTRUE;
451}
452
453//___________________________________________________________________________
cd305eb1 454Bool_t AliTagAnalysis::CreateXMLCollection(const char* name,
455 const char *fRunCut,
456 const char *fLHCCut,
457 const char *fDetectorCut,
458 const char *fEventCut) {
d08133e6 459 //Queries the tag chain using the defined
460 //event tag cuts from the AliEventTagCuts object
461 //and returns a XML collection
462 AliInfo(Form("Creating the collection........"));
463
68550043 464 Bool_t aod = kFALSE;
465 if(fAnalysisType == "AOD") aod = kTRUE;
466
d08133e6 467 AliXMLCollection *collection = new AliXMLCollection();
468 collection->SetCollectionName(name);
469 collection->WriteHeader();
470
9b4aee57 471 TString guid;
472 TString turl;
473 TString lfn;
940b4031 474 TEntryList* localList = new TEntryList();
d08133e6 475
68550043 476 Int_t iAccepted = 0;
477 Int_t iev = 0;
478 Int_t ientry = 0;
479 Int_t cEntries = 0;
cd305eb1 480
f0f29480 481 Int_t iRejectedRun = 0;
482 Int_t iRejectedLHC = 0;
483 Int_t iRejectedDet = 0;
484 Int_t iRejectedEvt = 0;
485
486 Int_t iTotalEvents = 0;
487
488 Int_t iAcceptedEvtInFile = 0;
489 Int_t iRejectedEvtInFile = 0;
490
cd305eb1 491 //Defining tag objects
940b4031 492 AliRunTag *tag = new AliRunTag;
cd305eb1 493 AliEventTag *evTag = new AliEventTag;
494 fChain->SetBranchAddress("AliTAG",&tag);
495
496 TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);
497 TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain);
498 TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain);
499 TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
500
501 Int_t current = -1;
502 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
68550043 503
cd305eb1 504 fChain->GetEntry(iTagFiles);
505 if (current != fChain->GetTreeNumber()) {
506 fRunFormula->UpdateFormulaLeaves();
507 fLHCFormula->UpdateFormulaLeaves();
508 fDetectorFormula->UpdateFormulaLeaves();
509 fEventFormula->UpdateFormulaLeaves();
68550043 510 // Fix for aod tags: for each tree in the chain, merge the entries
511 cEntries = (fChain->GetTree())->GetEntries();
512 iev = 0;
513 ientry = 0;
514 //
cd305eb1 515 current = fChain->GetTreeNumber();
516 }
68550043 517 //Event list
f0f29480 518 iTotalEvents += tag->GetNEvents();
940b4031 519 if ((iev == 0) || !aod) localList->Reset();
cd305eb1 520 if(fRunFormula->EvalInstance(iTagFiles) == 1) {
521 if(fLHCFormula->EvalInstance(iTagFiles) == 1) {
522 if(fDetectorFormula->EvalInstance(iTagFiles) == 1) {
523 Int_t iEvents = fEventFormula->GetNdata();
524 const TClonesArray *tagList = tag->GetEventTags();
f0f29480 525 iRejectedEvtInFile = 0;
526 iAcceptedEvtInFile = 0;
cd305eb1 527 for(Int_t i = 0; i < iEvents; i++) {
528 evTag = (AliEventTag *) tagList->At(i);
529 guid = evTag->GetGUID();
530 turl = evTag->GetTURL();
531 lfn = turl(8,turl.Length());
68550043 532 if(fEventFormula->EvalInstance(i) == 1) {
533 if(aod) localList->Enter(iev);
534 else localList->Enter(i);
f0f29480 535 iAcceptedEvtInFile++;
536 }
537 else {
538 iRejectedEvt++;
539 iRejectedEvtInFile++;
68550043 540 }
541 iev++;
cd305eb1 542 }//event loop
68550043 543 if ((ientry == cEntries-1) || !aod) {
f0f29480 544 collection->WriteBody(iTagFiles+1,guid,lfn,turl,localList,iAcceptedEvtInFile, iRejectedEvtInFile);
545 iAccepted += localList->GetN();
68550043 546 }
cd305eb1 547 }//detector tag cuts
f0f29480 548 else {
549 iRejectedDet += tag->GetNEvents();
550 }
cd305eb1 551 }//lhc tag cuts
f0f29480 552 else {
553 iRejectedLHC += tag->GetNEvents();
554 }
cd305eb1 555 }//run tag cuts
f0f29480 556 else {
557 iRejectedRun += tag->GetNEvents();
558 }
68550043 559 ientry++;
cd305eb1 560 }//tag file loop
f0f29480 561 collection->WriteSummary(iTotalEvents, iAccepted, iRejectedRun, iRejectedLHC, iRejectedDet, iRejectedEvt);
68550043 562 collection->Export();
940b4031 563
564 delete tag;
cd305eb1 565 return kTRUE;
566}
567
d08133e6 568//___________________________________________________________________________
569TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) {
570 //returns the chain+event list - used in batch sessions
571 // this function will be removed once the new root
572 // improvements are committed
573 TString fsystem = system;
574 Int_t iAccepted = 0;
6cfbb923 575
88fb0edc 576 TChain *fAnalysisChain = 0;
577 if(fAnalysisType == "ESD") fAnalysisChain = new TChain("esdTree");
578 else if(fAnalysisType == "AOD") fAnalysisChain = new TChain("aodTree");
6cfbb923 579 else AliFatal("Only ESD and AOD type is implemented!!!");
580
d08133e6 581 //Event list
582 TEventList *fEventList = new TEventList();
583 AliXMLCollection *collection = AliXMLCollection::Open(wn);
584
585 collection->Reset();
586 while (collection->Next()) {
587 AliInfo(Form("Adding: %s",collection->GetTURL("")));
6cfbb923 588 fAnalysisChain->Add(collection->GetTURL(""));
d08133e6 589 TEntryList *list = (TEntryList *)collection->GetEventList("");
590 for(Int_t i = 0; i < list->GetN(); i++) fEventList->Enter(iAccepted+list->GetEntry(i));
591
592 if(fsystem == "pp") iAccepted += 100;
593 else if(fsystem == "PbPb") iAccepted += 1;
594 }
595
6cfbb923 596 fAnalysisChain->SetEventList(fEventList);
d08133e6 597
598 AliInfo(Form("Number of selected events: %d",fEventList->GetN()));
599
6cfbb923 600 return fAnalysisChain;
d08133e6 601}
602
603//___________________________________________________________________________
cd305eb1 604TChain *AliTagAnalysis::GetChainFromCollection(const char* collectionname,
605 const char* treename) {
d08133e6 606 //returns the TChain+TEntryList object- used in batch sessions
68550043 607 TString aliceFile = treename;
d08133e6 608 Int_t iAccepted = 0;
88fb0edc 609 TChain *fAnalysisChain = 0;
68550043 610 if(aliceFile == "esdTree") fAnalysisChain = new TChain("esdTree");
611 else if(aliceFile == "aodTree") fAnalysisChain = new TChain("aodTree");
d08133e6 612 else AliFatal("Inconsistent tree name - use esdTree or aodTree!");
6cfbb923 613
d08133e6 614 //Event list
cd305eb1 615 fGlobalList = new TEntryList();
d08133e6 616 AliXMLCollection *collection = AliXMLCollection::Open(collectionname);
617
f0f29480 618 // Tag selection summary per file
619 TMap *tagCutSummary = new TMap();
620 tagCutSummary->SetName("TagCutSumm");
621
d08133e6 622 collection->Reset();
623 while (collection->Next()) {
624 AliInfo(Form("Adding: %s",collection->GetTURL("")));
625 fAnalysisChain->Add(collection->GetTURL(""));
626 TEntryList *list = (TEntryList *)collection->GetEventList("");
68550043 627 list->SetTreeName(aliceFile.Data());
d08133e6 628 list->SetFileName(collection->GetTURL(""));
629 fGlobalList->Add(list);
630 iAccepted += list->GetN();
f0f29480 631 if (collection->GetCutSumm())
632 tagCutSummary->Add(new TObjString(collection->GetTURL("")), new TObjString(collection->GetCutSumm()));
d08133e6 633 }
634
635 fAnalysisChain->SetEntryList(fGlobalList,"ne");
636
637 AliInfo(Form("Number of selected events: %d",iAccepted));
638
f0f29480 639 TList *aUserInfo = fAnalysisChain->GetUserInfo();
640 aUserInfo->Add(tagCutSummary);
641
642 Int_t iAccEv;
643 Int_t iTotalEvents;
644 Int_t iRejRun;
645 Int_t iRejLHC;
646 Int_t iRejDet;
647 Int_t iRejEvt;
648
649 collection->GetCollectionSummary(&iTotalEvents, &iAccEv, &iRejRun, &iRejLHC, &iRejDet, &iRejEvt);
650
651 char nstr[2000];
652
653 sprintf(nstr, "TotalEvents=%i", iTotalEvents);
654 TObjString *iTotStr = new TObjString(nstr);
655 aUserInfo->Add(iTotStr);
656
657 sprintf(nstr, "AcceptedEvents=%i", iAccepted);
658 TObjString *iAccStr = new TObjString(nstr);
659 aUserInfo->Add(iAccStr);
660
661 sprintf(nstr, "RejectedRun=%i", iRejRun);
662 TObjString *iRejRunStr = new TObjString(nstr);
663 aUserInfo->Add(iRejRunStr);
664
665 sprintf(nstr, "RejectedLHC=%i", iRejLHC);
666 TObjString *iRejLHCStr = new TObjString(nstr);
667 aUserInfo->Add(iRejLHCStr);
668
669 sprintf(nstr, "RejectedDet=%i", iRejDet);
670 TObjString *iRejDetStr = new TObjString(nstr);
671 aUserInfo->Add(iRejDetStr);
672
673 sprintf(nstr, "RejectedEvt=%i", iRejEvt);
674 TObjString *iRejEvtStr = new TObjString(nstr);
675 aUserInfo->Add(iRejEvtStr);
676
d08133e6 677 return fAnalysisChain;
678}