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