2 //--------------------------------------------------
3 // Example macro to do analysis with the
4 // analysis classes in CaloTrackCorrelations
5 // Can be executed with Root and AliRoot
7 // Pay attention to the options and definitions
8 // set in the lines below
10 // Author : Gustavo Conesa Balbastre (INFN-LNF)
12 //-------------------------------------------------
13 enum anaModes {mLocal=0, mPROOF=1, mPlugin=2, mGRID=3};
14 //mLocal = 0: Analyze locally files in your computer
15 //mPROOF = 1: Analyze files on GRID with Plugin
16 //mPlugin = 2: Analyze files on GRID with Plugin
17 //mGRID = 3: Analyze files on GRID, jobs launched from aliensh
19 //---------------------------------------------------------------------------
20 // Settings to read locally several files, only for "mLocal" mode
21 // The different values are default, they can be set with environmental
22 // variables: INDIR, PATTERN, NFILES, respectivelly
24 char * kInDir = "/user/data/files/";
25 char * kPattern = ""; // Data are in files kInDir/kPattern+i
28 //---------------------------------------------------------------------------
29 // Dataset for proof analysis, mode=mPROOF
30 // char * kDataset = "/alice/vernet/PbPb_LHC10h_ESD";
32 char * kDatasetPROOF = "/alice/vernet/LHC11b_149646";
33 Int_t kDatasetNMaxFiles = 20;
34 TString ccin2p3UserName = "arbor" ;
35 TString alienUserName = "narbor" ;
37 //---------------------------------------------------------------------------
38 // Collection file for grid analysis
40 char * kXML = "collection.xml";
42 //---------------------------------------------------------------------------
43 //Scale histograms from file. Change to kTRUE when xsection file exists
44 //Put name of file containing xsection
45 //Put number of events per ESD file
46 //This is an specific case for normalization of Pythia files.
47 const char * kXSFileName = "pyxsec.root";
49 //---------------------------------------------------------------------------
51 //Set some default values, but used values are set in the code!
53 Bool_t kMC = kFALSE; //With real data kMC = kFALSE
54 TString kInputData = "ESD"; //ESD, AOD, MC, deltaAOD
56 TString kCollision = "pp";
57 Bool_t outAOD = kFALSE; //Some tasks doesnt need it.
63 //________________________
64 void anaGenKine(Int_t mode=mGRID)
68 //--------------------------------------------------------------------
69 // Load analysis libraries
70 // Look at the method below,
71 // change whatever you need for your analysis case
72 // ------------------------------------------------------------------
75 //gSystem->ListLibraries();
77 //-------------------------------------------------------------------------------------------------
78 //Create chain from ESD and from cross sections files, look below for options.
79 //-------------------------------------------------------------------------------------------------
81 // Set kInputData and kTreeName looking to the kINDIR
83 //CheckInputData(mode);
85 // Check global analysis settings
87 //CheckEnvironmentVariables();
89 //printf("*********************************************\n");
90 //printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
92 //printf("*********************************************\n");
95 TChain * chain = new TChain(kTreeName) ;
96 TChain * chainxs = new TChain("Xsection") ;
98 chain ->AddFile("galice.root");
99 chainxs->AddFile("pyxsec.root");
101 //CreateChain(mode, chain, chainxs);
104 printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
105 if(chainxs && chainxs->GetEntries() > 0)
107 Int_t nfiles = chainxs->GetEntries();
109 //Get the cross section
110 Double_t xsection = 0;
113 GetAverageXsection(chainxs, xsection, ntrials);
115 Int_t nEventsPerFile = chain->GetEntries() / nfiles;
117 Double_t trials = ntrials / nEventsPerFile ;
119 scale = xsection/trials;
121 printf("Get Cross section : nfiles %d, nevents %d, nevents per file %d \n",nfiles, chain->GetEntries(),nEventsPerFile);
122 printf(" ntrials %d, trials %2.2f, xs %2.2e, scale factor %2.2e\n", ntrials,trials,xsection,scale);
126 printf("*********************************************\n");
127 printf("number of entries # %lld, skipped %d\n", chain->GetEntries()) ;
128 printf("*********************************************\n");
132 printf("STOP, no chain available\n");
136 AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
138 //------------------------------------------
139 // Alien handler part
140 //------------------------------------------
141 AliAnalysisGrid *alienHandler=0x0;
144 // Create and configure the alien handler plugin
145 gROOT->LoadMacro("CreateAlienHandler.C");
146 alienHandler = CreateAlienHandler();
147 if (!alienHandler) return;
150 //--------------------------------------
151 // Make the analysis manager
152 //-------------------------------------
153 AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
154 //AliAnalysisManager::SetUseProgressBar(kTRUE);
155 //mgr->SetSkipTerminate(kTRUE);
156 //mgr->SetNSysInfo(1);
160 // // Connect plugin to the analysis manager
161 // mgr->SetGridHandler(alienHandler);
165 if((kMC || kInputData == "MC") && !kInputData.Contains("AOD"))
167 AliMCEventHandler* mcHandler = new AliMCEventHandler();
168 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
169 mgr->SetMCtruthEventHandler(mcHandler);
170 if( kInputData == "MC")
172 cout<<"MC INPUT EVENT HANDLER"<<endl;
173 mgr->SetInputEventHandler(NULL);
178 // // AOD output handler
179 // if(kInputData!="deltaAOD" && outAOD)
181 // cout<<"Init output handler"<<endl;
182 // AliAODHandler* aodoutHandler = new AliAODHandler();
183 // aodoutHandler->SetOutputFileName("aod.root");
184 // ////aodoutHandler->SetCreateNonStandardAOD();
185 // mgr->SetOutputEventHandler(aodoutHandler);
190 // if(kInputData == "ESD")
193 // AliESDInputHandler *esdHandler = new AliESDInputHandler();
194 // esdHandler->SetReadFriends(kFALSE);
195 // mgr->SetInputEventHandler(esdHandler);
196 // cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
198 // else if(kInputData.Contains("AOD"))
201 // AliAODInputHandler *aodHandler = new AliAODInputHandler();
202 // mgr->SetInputEventHandler(aodHandler);
203 // if(kInputData == "deltaAOD") aodHandler->AddFriend("deltaAODCaloTrackCorr.root");
204 // cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
207 //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
208 mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
210 TString outputFile = AliAnalysisManager::GetCommonFileName();
212 gROOT->LoadMacro("AddTaskGenKine.C");
215 AliAnalysisTaskCaloTrackCorrelation *ana = AddTaskGenKine(outputFile, scale);
218 //-----------------------
220 //-----------------------
224 if (mode == mPlugin) mgr->StartAnalysis("grid");
225 else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
226 else mgr->StartAnalysis("local",chain);
228 cout <<" Analysis ended sucessfully "<< endl ;
232 //_____________________________
233 void LoadLibraries(Int_t mode)
236 if (mode == mPROOF) {
237 //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
238 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
239 TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations");
241 // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
243 // //proof->ClearPackages();
244 // proof->UploadPackage("STEERBase");
245 // proof->UploadPackage("ESD");
246 // proof->UploadPackage("AOD");
247 // proof->UploadPackage("ANALYSIS");
248 // proof->UploadPackage("OADB");
249 // proof->UploadPackage("ANALYSISalice");
250 // proof->UploadPackage("CORRFW");
251 // //proof->UploadPackage("JETAN");
252 // proof->UploadPackage("PHOSUtils");
253 // proof->UploadPackage("EMCALUtils");
254 // proof->UploadPackage("PWGCaloTrackCorrBase");
255 // proof->UploadPackage("PWGGACaloTrackCorrelations");
257 // proof->EnablePackage("STEERBase");
258 // proof->EnablePackage("ESD");
259 // proof->EnablePackage("AOD");
260 // proof->EnablePackage("ANALYSIS");
261 // proof->EnablePackage("OADB");
262 // proof->EnablePackage("ANALYSISalice");
263 // proof->EnablePackage("CORRFW");
264 // //proof->EnablePackage("JETAN");
265 // proof->EnablePackage("PHOSUtils");
266 // proof->EnablePackage("EMCALUtils");
267 // proof->EnablePackage("PWGCaloTrackCorrBase");
268 // proof->EnablePackage("PWGGACaloTrackCorrelations");
273 //--------------------------------------
274 // Load the needed libraries most of them already loaded by aliroot
275 //--------------------------------------
276 gSystem->Load("libTree");
277 gSystem->Load("libGeom");
278 gSystem->Load("libVMC");
279 gSystem->Load("libXMLIO");
280 gSystem->Load("libMatrix");
281 gSystem->Load("libPhysics");
282 gSystem->Load("libMinuit"); // Root + libraries to if reclusterization is done
284 gSystem->Load("libSTEERBase");
285 gSystem->Load("libGui"); // Root + libraries to if reclusterization is done
286 gSystem->Load("libCDB"); // Root + libraries to if reclusterization is done
287 gSystem->Load("libESD"); // Root + libraries to if reclusterization is done
288 gSystem->Load("libAOD");
289 gSystem->Load("libRAWDatabase"); // Root + libraries to if reclusterization is done
290 gSystem->Load("libProof");
291 gSystem->Load("libOADB");
292 gSystem->Load("libANALYSIS");
293 gSystem->Load("libSTEER"); // Root + libraries to if reclusterization is done
295 gSystem->Load("libRAWDatarec"); // Root + libraries to if reclusterization is done
296 gSystem->Load("libRAWDatasim"); // Root + libraries to if reclusterization is done
297 gSystem->Load("libVZERObase"); // Root + libraries to if reclusterization is done
298 gSystem->Load("libVZEROrec"); // Root + libraries to if reclusterization is done
300 gSystem->Load("libEMCALUtils");
301 //SetupPar("EMCALUtils");
302 gSystem->Load("libEMCALraw"); // Root + libraries to if reclusterization is done
303 gSystem->Load("libEMCALbase"); // Root + libraries to if reclusterization is done
304 gSystem->Load("libEMCALsim"); // Root + libraries to if reclusterization is done
305 gSystem->Load("libEMCALrec"); // Root + libraries to if reclusterization is done
306 //SetupPar("EMCALraw");
307 //SetupPar("EMCALbase");
308 //SetupPar("EMCALsim");
309 //SetupPar("EMCALrec");
311 gSystem->Load("libANALYSISalice");
312 //gSystem->Load("libTender");
313 //gSystem->Load("libTenderSupplies");
315 gSystem->Load("libPHOSUtils");
316 gSystem->Load("libEMCALUtils");
317 gSystem->Load("libPWGCaloTrackCorrBase");
318 gSystem->Load("libPWGGACaloTrackCorrelations");
319 //SetupPar("PWGCaloTrackCorrBase");
320 //SetupPar("PWGGACaloTrackCorrelations");
323 //gSystem->Load("libJETAN");
324 //gSystem->Load("FASTJETAN");
325 //gSystem->Load("PWGJE");
327 //gSystem->Load("libCORRFW");
328 //gSystem->Load("libPWGGAGammaConv");
329 //SetupPar("PWGGAGammaConv");
331 // needed for plugin?
332 gSystem->AddIncludePath("-I$ALICE_ROOT");
333 gSystem->AddIncludePath("-I./");
337 //_________________________________
338 void SetupPar(char* pararchivename)
340 //Load par files, create analysis libraries
341 //For testing, if par file already decompressed and modified
342 //classes then do not decompress.
344 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
345 TString parpar(Form("%s.par", pararchivename)) ;
347 if ( gSystem->AccessPathName(pararchivename) ) {
348 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
349 gROOT->ProcessLine(processline.Data());
352 TString ocwd = gSystem->WorkingDirectory();
353 gSystem->ChangeDirectory(pararchivename);
355 // check for BUILD.sh and execute
356 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
357 printf("*******************************\n");
358 printf("*** Building PAR archive ***\n");
359 cout<<pararchivename<<endl;
360 printf("*******************************\n");
362 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
363 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
367 // check for SETUP.C and execute
368 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
369 printf("*******************************\n");
370 printf("*** Setup PAR archive ***\n");
371 cout<<pararchivename<<endl;
372 printf("*******************************\n");
373 gROOT->Macro("PROOF-INF/SETUP.C");
376 gSystem->ChangeDirectory(ocwd.Data());
377 printf("Current dir: %s\n", ocwd.Data());
380 //______________________________________
381 void CheckInputData(const anaModes mode)
383 //Sets input data and tree
385 TString ocwd = gSystem->WorkingDirectory();
387 //---------------------------------------
388 //Local files analysis
389 //---------------------------------------
391 //If you want to add several ESD files sitting in a common directory INDIR
392 //Specify as environmental variables the directory (INDIR), the number of files
393 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
395 if(gSystem->Getenv("INDIR"))
396 kInDir = gSystem->Getenv("INDIR") ;
397 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
399 TString sindir(kInDir);
400 if (sindir.Contains("pass1")) kPass = "pass1";
401 else if(sindir.Contains("pass2")) kPass = "pass2";
402 else if(sindir.Contains("pass3")) kPass = "pass3";
404 if(gSystem->Getenv("PATTERN"))
405 kPattern = gSystem->Getenv("PATTERN") ;
406 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
408 cout<<"INDIR : "<<kInDir<<endl;
409 cout<<"NFILES : "<<kFile<<endl;
415 for (Int_t event = 0 ; event < kFile ; event++) {
416 sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
417 sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
418 sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
419 sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
421 TFile * fESD = TFile::Open(fileE) ;
422 TFile * fAOD = TFile::Open(fileA) ;
424 //Check if file exists and add it, if not skip it
427 kTreeName = "esdTree";
429 TFile * fG = TFile::Open(fileG);
430 if(fG) { kMC = kTRUE; fG->Close();}
434 TTree* esdTree = (TTree*)fESD->Get("esdTree");
435 AliESDEvent* esd = new AliESDEvent();
436 esd->ReadFromTree(esdTree);
437 esdTree->GetEvent(0);
438 kRun = esd->GetRunNumber();
444 kTreeName = "aodTree";
446 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
450 TTree* aodTree = (TTree*)fAOD->Get("aodTree");
451 AliAODEvent* aod = new AliAODEvent();
452 aod->ReadFromTree(aodTree);
453 aodTree->GetEvent(0);
454 kRun = aod->GetRunNumber();
457 else if(TFile::Open(fileEm))
459 kTreeName = "aodTree";
465 else if(TFile::Open(fileG))
474 if(fESD) fESD->Close();
475 if(fAOD) fAOD->Close();
477 }// local files analysis
479 //------------------------------
481 //-----------------------------
482 else if(mode == mGRID){
483 //Get colection file. It is specified by the environmental
486 if(gSystem->Getenv("XML") )
487 kXML = gSystem->Getenv("XML");
489 sprintf(kXML, "collection.xml") ;
491 if (!TFile::Open(kXML)) {
492 printf("No collection file with name -- %s -- was found\n",kXML);
495 else cout<<"XML file "<<kXML<<endl;
497 //Load necessary libraries and connect to the GRID
498 gSystem->Load("libNetx") ;
499 gSystem->Load("libRAliEn");
500 TGrid::Connect("alien://") ;
502 //Feed Grid with collection file
503 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
505 AliError(Form("%s not found", kXML)) ;
508 TGridResult* result = collection->GetGridResult("",0 ,0);
510 for (Int_t index = 0; index < result->GetEntries(); index++) {
511 TString alienURL = result->GetKey(index, "turl") ;
512 cout << "================== " << alienURL << endl ;
514 if (alienURL.Contains("pass1")) kPass = "pass1";
515 else if(alienURL.Contains("pass2")) kPass = "pass2";
516 else if(alienURL.Contains("pass3")) kPass = "pass3";
518 kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
519 printf("Run number from alien path = %d\n",kRun);
522 //Check if file exists and add it, if not skip it
523 if (alienURL.Contains("AliESDs.root"))
525 kTreeName = "esdTree";
527 alienURL.ReplaceAll("AliESDs.root","galice.root");
528 if(TFile::Open(alienURL)) kMC=kTRUE;
532 else if(alienURL.Contains("AliAOD.root"))
534 kTreeName = "aodTree";
536 fAOD = TFile::Open(alienURL);
537 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
541 else if(alienURL.Contains("embededAOD.root"))
543 kTreeName = "aodTree";
548 else if(alienURL.Contains("galice.root"))
557 //------------------------------
559 //-----------------------------
560 else if(mode == mPROOF){
562 TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
564 TIter iter(coll->GetList());
566 TFileInfo* fileInfo = 0;
567 while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
569 if (fileInfo->GetFirstUrl()) {
570 TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
571 cout << "================== " << ProofURL << endl ;
573 if (ProofURL.Contains("pass1")) kPass = "pass1";
574 else if(ProofURL.Contains("pass2")) kPass = "pass2";
575 else if(ProofURL.Contains("pass3")) kPass = "pass3";
577 kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
578 printf("Run number from alien path = %d\n",kRun);
581 //Check if file exists and add it, if not skip it
582 if (ProofURL.Contains("AliESDs.root"))
584 kTreeName = "esdTree";
586 alienURL.ReplaceAll("AliESDs.root","galice.root");
587 if(TFile::Open(ProofURL)) kMC=kTRUE;
592 else if(ProofURL.Contains("AliAOD.root"))
594 kTreeName = "aodTree";
596 fAOD = TFile::Open(ProofURL);
597 if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
601 else if(ProofURL.Contains("embededAOD.root"))
603 kTreeName = "aodTree";
608 else if(ProofURL.Contains("galice.root"))
619 gSystem->ChangeDirectory(ocwd.Data());
623 //_____________________________________________________________________
624 void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
626 //Fills chain with data
627 TString ocwd = gSystem->WorkingDirectory();
629 //---------------------------------------
630 // Local files analysis
631 //---------------------------------------
633 //If you want to add several ESD files sitting in a common directory INDIR
634 //Specify as environmental variables the directory (INDIR), the number of files
635 //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
637 if(gSystem->Getenv("INDIR"))
638 kInDir = gSystem->Getenv("INDIR") ;
639 else cout<<"INDIR not set, use default: "<<kInDir<<endl;
641 if(gSystem->Getenv("PATTERN"))
642 kPattern = gSystem->Getenv("PATTERN") ;
643 else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
645 if(gSystem->Getenv("NFILES"))
646 kFile = atoi(gSystem->Getenv("NFILES")) ;
647 else cout<<"NFILES not set, use default: "<<kFile<<endl;
649 //Check if env variables are set and are correct
650 if ( kInDir && kFile) {
651 printf("Get %d files from directory %s\n",kFile,kInDir);
652 if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
653 printf("%s does not exist\n", kInDir) ;
657 //if(gSystem->Getenv("XSFILE"))
658 //kXSFileName = gSystem->Getenv("XSFILE") ;
659 //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
660 char * kGener = gSystem->Getenv("GENER");
662 cout<<"GENER "<<kGener<<endl;
663 if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
664 else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
665 else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
667 else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
669 cout<<"INDIR : "<<kInDir <<endl;
670 cout<<"NFILES : "<<kFile <<endl;
671 cout<<"PATTERN : "<<kPattern <<endl;
672 cout<<"XSFILE : "<<kXSFileName<<endl;
675 if (kInputData == "ESD") datafile = "AliESDs.root" ;
676 else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
677 else if(kInputData == "MC") datafile = "galice.root" ;
679 //Loop on ESD/AOD/MC files, add them to chain
685 for (event = 0 ; event < kFile ; event++) {
686 sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
687 sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
689 //Check if file exists and add it, if not skip it
690 if ( fData = TFile::Open(file)) {
691 if ( fData->Get(kTreeName) ) {
692 printf("++++ Adding %s\n", file) ;
693 chain->AddFile(file);
694 chainxs->Add(filexs) ;
698 printf("---- Skipping %s\n", file) ;
704 TString input = "AliESDs.root" ;
705 cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
706 chain->AddFile(input);
709 }// local files analysis
711 //------------------------------
713 //------------------------------
714 else if(mode == mGRID){
715 //Get colection file. It is specified by the environmental
718 //Feed Grid with collection file
719 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
721 AliError(Form("%s not found", kXML)) ;
725 TGridResult* result = collection->GetGridResult("",0 ,0);
727 // Makes the ESD chain
728 printf("*** Getting the Chain ***\n");
729 for (Int_t index = 0; index < result->GetEntries(); index++) {
730 TString alienURL = result->GetKey(index, "turl") ;
731 cout << "================== " << alienURL << endl ;
732 chain->Add(alienURL) ;
733 alienURL.ReplaceAll("AliESDs.root",kXSFileName);
734 chainxs->Add(alienURL) ;
738 //------------------------------
740 //------------------------------
741 else if (mode == mPROOF) {
743 TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
745 gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
746 chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
747 printf("chain has %d entries\n",chain->GetEntries());
750 gSystem->ChangeDirectory(ocwd.Data());
754 //______________________________
755 void CheckEnvironmentVariables()
758 sprintf(kTrigger,"");
760 Bool_t bRecalibrate = kFALSE;
761 Bool_t bBadChannel = kFALSE;
763 for (int i=0; i< gApplication->Argc();i++){
767 printf("Arg %d: %s\n",i,gApplication->Argv(i));
773 if (!(strcmp(gApplication->Argv(i),"--trigger")))
774 sprintf(trigger,gApplication->Argv(i+1));
776 if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
777 bRecalibrate = atoi(gApplication->Argv(i+1));
779 if (!(strcmp(gApplication->Argv(i),"--badchannel")))
780 bBadChannel = atoi(gApplication->Argv(i+1));
782 if (!(strcmp(gApplication->Argv(i),"--run"))){
783 sRun = gApplication->Argv(i+1);
784 if(sRun.Contains("LHC10")) {
789 kRun = atoi(gApplication->Argv(i+1));
791 else printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
797 if(!sRun.Contains("LHC10")){
801 if( kRun >= 136851 ) kCollision = "PbPb";
803 else if( kRun < 170600)
806 if( kRun >= 166500 ) kCollision = "PbPb";
815 if(kMC) sprintf(kTrigger,"");
817 printf("*********************************************\n");
818 //printf("*** Settings trigger %s, recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
819 // kTrigger,bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
820 printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
821 printf("*********************************************\n");
826 //_________________________________________________________________
827 void GetAverageXsection(TTree * tree, Double_t & xs, Float_t & ntr)
829 // Read the PYTHIA statistics from the file pyxsec.root created by
830 // the function WriteXsection():
831 // integrated cross section (xsection) and
832 // the number of Pyevent() calls (ntrials)
833 // and calculate the weight per one event xsection/ntrials
834 // The spectrum calculated by a user should be
835 // multiplied by this weight, something like this:
836 // TH1F *userSpectrum ... // book and fill the spectrum
837 // userSpectrum->Scale(weight)
839 // Yuri Kharlov 19 June 2007
840 // Gustavo Conesa 15 April 2008
841 Double_t xsection = 0;
846 Int_t nfiles = tree->GetEntries() ;
847 if (tree && nfiles > 0) {
848 tree->SetBranchAddress("xsection",&xsection);
849 tree->SetBranchAddress("ntrials" ,&ntrials );
850 for(Int_t i = 0; i < nfiles; i++){
854 cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
859 cout << "-----------------------------------------------------------------"<<endl;
860 cout << "Average of "<< nfiles<<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
861 cout << "-----------------------------------------------------------------"<<endl;
863 else cout << " >>>> Empty tree !!!! <<<<< "<<endl;