]>
Commit | Line | Data |
---|---|---|
522851fb | 1 | void runAnalysisTaskPtMothFromPtDaug(TH1F* histPtDaug=0x0, |
2 | Bool_t readKineFromNtupla=kTRUE,const char* galiceList="galice.txt") | |
3 | { | |
4 | ///////////////////////////////////////////////////////////////////////////// | |
5 | // Run-macro to extract pt-spectra (and ptMin-spectra) for mothers // | |
6 | // input: 1) pT histogram of daughter particles // | |
7 | // 2) boolean flag:kFALSE -> read Kinematics.root to evaluate // | |
8 | // correction factors, create a TNtuple // | |
9 | // with kinematic informations of mothers // | |
10 | // and daughters and store it in the file // | |
11 | // "DecayKine.root" // | |
12 | // kTRUE -> read the TNtupla from the file // | |
13 | // "DecayKine.root" (after it is created) // | |
14 | // to evaluate correction factors // | |
15 | // 3) name of file with the list of "galice.root" files to read // | |
16 | // kinematics (not needed after the TNtupla is created) // | |
17 | // // | |
18 | // output: 1) file Mothers.root which contains pt-spectra and ptMin // | |
19 | // spectra of mothers particles // | |
20 | // 2) TNtupla with kinematic informations (optional) // | |
21 | // // | |
22 | // Origin: Giuseppe.Bruno@ba.infn.it, Fiorella.Fionda@ba.infn.it // | |
23 | // // | |
24 | ///////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | char *ntuplaFileName = "DecayKine.root"; // default name of the Ntupla | |
27 | char *mode = "local"; // analysis mode (select local or proof) | |
28 | char *dataset = "/COMMON/COMMON/LHC09a14_0.9TeV_0.5T"; // define dataset for proof | |
29 | ||
30 | if(mode == "proof") loadLib(); | |
31 | else{ | |
32 | gSystem->Load("libANALYSIS.so"); | |
33 | gSystem->Load("libANALYSISalice.so"); | |
40a0a69c | 34 | gSystem->Load("libPWGHFbase.so"); |
522851fb | 35 | } |
36 | // Set AliPtMothFromPtDaugh object | |
37 | AliPtMothFromPtDaugh *ptExtr = new AliPtMothFromPtDaugh(); | |
38 | ptExtr->SetDefaultAnalysis(AliPtMothFromPtDaugh::kBtoJPSI); | |
39 | ptExtr->SetBinsPtMoth(0.,10,20,1); | |
40 | ptExtr->SetBinsPtMinMoth(0.,10,20,1); | |
41 | ptExtr->SetEtaMothers(-1.5,1.5); | |
42 | ptExtr->SetEtaDaughter(-1.,1.); | |
43 | if(!ptExtr->ReadHistoPtDaught(histPtDaug)) | |
44 | { printf("Daughter pt-Histogram is not defined \n"); return; } | |
45 | if(!ptExtr->CreateWeights()) return; | |
46 | // | |
47 | // create Analysis manager with MC and Input handlers | |
48 | // | |
49 | AliAnalysisManager *mgr = new AliAnalysisManager("mgr", "Analysis Manager"); | |
50 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
51 | mgr->SetMCtruthEventHandler(mcHandler); | |
52 | AliInputEventHandler *inputHandler =0x0; | |
53 | mgr->SetInputEventHandler(inputHandler); | |
54 | ||
55 | TChain *chain=0x0; | |
56 | if(mode=="local"){ | |
57 | if(!readKineFromNtupla) chain = CreateChain(galiceList); // create a chain with galice.root files | |
58 | else mgr->SetExternalLoop(kTRUE); // to abort event loop when Ntupla is already created | |
59 | } | |
60 | // | |
61 | // create task and add it to the manager | |
62 | // | |
63 | AliAnalysisTaskPtMothFromPtDaugh *task = new AliAnalysisTaskPtMothFromPtDaugh(readKineFromNtupla); | |
64 | task->SetPtMothFromPtDaugh(ptExtr); // set AliPtMothFromPtDaugh object to the task | |
65 | task->SetNtuplaFileName(ntuplaFileName); | |
66 | mgr->AddTask(task); | |
67 | // | |
68 | // create input / output containers | |
69 | // | |
70 | AliAnalysisDataContainer *cOutput = mgr->CreateContainer("Mothers", TList::Class(), AliAnalysisManager::kOutputContainer,"Mothers.root"); | |
71 | mgr->ConnectOutput(task, 1, cOutput); | |
72 | // optional output for TNtupla | |
73 | AliAnalysisDataContainer *cOutput1 = 0x0; | |
74 | if(!readKineFromNtupla){ | |
75 | cOutput1 = mgr->CreateContainer("DecayKine", TNtuple::Class(), AliAnalysisManager::kOutputContainer,ntuplaFileName); | |
76 | mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); | |
77 | mgr->ConnectOutput(task,2,cOutput1); | |
78 | } | |
79 | // | |
80 | // run analysis locally | |
81 | // | |
82 | Int_t result=mgr->InitAnalysis(); | |
83 | if (!result){ | |
84 | Error("RunAnalysis","Could not initialise Analysis."); | |
85 | return 0; | |
86 | } | |
87 | mgr->PrintStatus(); | |
88 | if(mode=="local") mgr->StartAnalysis(mode,chain); | |
89 | else if(mode=="proof") mgr->StartAnalysis(mode,dataset); | |
90 | if(readKineFromNtupla) mgr->Terminate(); | |
91 | return; | |
92 | } | |
93 | ||
94 | TChain *CreateChain(const char* galiceName) | |
95 | { | |
96 | // | |
97 | // Create a chain from a list of galice.root | |
98 | // | |
99 | ifstream in; | |
100 | in.open(galiceName); | |
101 | if (!in.is_open()) return 0x0; | |
102 | TChain *chain=new TChain("TE"); | |
103 | TString line; | |
104 | while(in.good()) { | |
105 | in >> line; | |
106 | if (!line.IsNull()) chain->AddFile(line); | |
107 | } | |
108 | return chain; | |
109 | } | |
110 | ||
111 | void loadLib(){ | |
112 | printf("****** Connect to PROOF *******\n"); | |
113 | gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
114 | TProof::Open("alicecaf.cern.ch"); | |
115 | gProof->UploadPackage("STEERBase.par"); | |
116 | gProof->EnablePackage("STEERBase.par"); | |
117 | gProof->UploadPackage("ESD.par"); | |
118 | gProof->EnablePackage("ESD.par"); | |
119 | gProof->UploadPackage("AOD.par"); | |
120 | gProof->EnablePackage("AOD.par"); | |
121 | gProof->UploadPackage("ANALYSIS.par"); | |
122 | gProof->EnablePackage("ANALYSIS.par"); | |
123 | gProof->UploadPackage("ANALYSISalice.par"); | |
124 | gProof->EnablePackage("ANALYSISalice.par"); | |
125 | gProof->UploadPackage("PWG3base.par"); | |
126 | gProof->EnablePackage("PWG3base.par"); | |
40a0a69c | 127 | } |