]>
Commit | Line | Data |
---|---|---|
643fea24 | 1 | void AnalysisTrainMuonLocal(char* filein = "AliESDs.root", |
2 | char* fileout = "AliAODs.root", | |
3 | Int_t nev=123456789) | |
f70a1b5d | 4 | |
5 | // Macro to produce a generic AOD starting from an ESD file. | |
6 | // The AOD is filled with two tasks: | |
7 | // 1- with the first one (AliAnalysisTaskESDfilter), | |
8 | // all the branches of the AOD are filled apart from the muons. | |
9 | // 2- with the second task (AliAnalysisTaskESDMuonFilter) | |
10 | // muons tracks are added to the tracks branch | |
643fea24 | 11 | // 3- with a third task (AliAnalysisTaskTagCreator) |
12 | // aod tags are created | |
13 | // There is the possibility to apply cuts on the tracks and muon tracks in | |
14 | // order to reject them before filling the AOD | |
f70a1b5d | 15 | // This macro works locally |
f70a1b5d | 16 | |
17 | { | |
18 | gSystem->Load("libTree.so"); | |
19 | gSystem->Load("libGeom.so"); | |
20 | gSystem->Load("libVMC.so"); | |
21 | gSystem->Load("libPhysics.so"); | |
40a0a69c | 22 | gSystem->Load("${ALICE_ROOT}/lib/tgt_${ALICE_TARGET}/libPWGmuon.so"); // for aliroot based analysis |
f70a1b5d | 23 | |
643fea24 | 24 | // Par files for a par based analysis |
25 | // SetupPar("STEERBase"); | |
26 | // SetupPar("ESD"); | |
27 | // SetupPar("AOD"); | |
28 | // SetupPar("ANALYSIS"); | |
29 | // SetupPar("ANALYSISalice"); | |
30 | // SetupPar("PWG3muon"); | |
31 | ||
32 | // Creating ESD Tags on the fly | |
33 | // The recreation of the ESD tag file is only needed in order to copy the infos on | |
34 | // run/LHC parameters into the AOD tag file. If the ESD tag file is not recreated, the | |
35 | // run/LHC info in the AOD tag file will be empty. | |
36 | AliESDTagCreator *t = new AliESDTagCreator(); | |
37 | t->SetStorage(0); | |
38 | t->ReadLocalCollection("."); | |
f70a1b5d | 39 | |
f70a1b5d | 40 | // Input ESD file |
41 | TChain* chain = new TChain("esdTree"); | |
42 | chain->Add(filein); | |
43 | ||
44 | // Define the analysis manager | |
45 | AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Analysis train"); | |
46 | ||
47 | // ESD input handler | |
48 | AliESDInputHandler *esdHandler = new AliESDInputHandler(); | |
643fea24 | 49 | esdHandler->SetReadTags(); |
f70a1b5d | 50 | |
51 | // AOD output handler | |
52 | AliAODHandler* aodHandler = new AliAODHandler(); | |
53 | aodHandler->SetOutputFileName(fileout); | |
54 | ||
55 | mgr->SetInputEventHandler(esdHandler); | |
56 | mgr->SetOutputEventHandler(aodHandler); | |
57 | ||
643fea24 | 58 | // Set of cuts for the ESD filters. |
59 | // Only tracks surviving the cuts will be copied into the AOD | |
f70a1b5d | 60 | // |
643fea24 | 61 | // standard cut for non-muon tracks |
f70a1b5d | 62 | AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose"); |
63 | esdTrackCutsL->SetMinNClustersTPC(50); | |
64 | esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5); | |
65 | esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2); | |
66 | esdTrackCutsL->SetRequireTPCRefit(kTRUE); | |
67 | esdTrackCutsL->SetMinNsigmaToVertex(3); | |
68 | esdTrackCutsL->SetRequireSigmaToVertex(kTRUE); | |
69 | esdTrackCutsL->SetAcceptKingDaughters(kFALSE); | |
70 | // | |
643fea24 | 71 | // hard cuts for non-muon tracks |
f70a1b5d | 72 | AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard"); |
73 | esdTrackCutsH->SetMinNClustersTPC(100); | |
74 | esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0); | |
75 | esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2); | |
76 | esdTrackCutsH->SetRequireTPCRefit(kTRUE); | |
77 | esdTrackCutsH->SetMinNsigmaToVertex(2); | |
78 | esdTrackCutsH->SetRequireSigmaToVertex(kTRUE); | |
79 | esdTrackCutsH->SetAcceptKingDaughters(kFALSE); | |
80 | esdTrackCutsH->SetPRange(0.,2.); | |
81 | // | |
82 | // muon cuts | |
83 | AliESDMuonTrackCuts* esdMuonTrackCuts = new AliESDMuonTrackCuts("AliESDMuonTrackCuts", "test"); | |
643fea24 | 84 | esdMuonTrackCuts->SetPRange(0.,12.); |
85 | esdMuonTrackCuts->SetPtRange(0.,2.); // examples of kinematic cuts that can be applied | |
f70a1b5d | 86 | esdMuonTrackCuts->SetHistogramsOn(kTRUE); // methods to draw control histos |
87 | esdMuonTrackCuts->DefineHistograms(); | |
88 | esdMuonTrackCuts->DrawHistograms(); | |
89 | ||
643fea24 | 90 | // track filter (to reject tracks not surviving the previously defined cuts - |
91 | // refers to all particles apart from muons) | |
f70a1b5d | 92 | AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter"); |
93 | trackFilter->AddCuts(esdTrackCutsH); | |
94 | ||
643fea24 | 95 | // muon track filter (to reject muon tracks not surviving the previously defined cuts) |
f70a1b5d | 96 | AliAnalysisFilter* trackMuonFilter = new AliAnalysisFilter("trackMuonFilter"); |
97 | trackMuonFilter->AddCuts(esdMuonTrackCuts); | |
98 | ||
643fea24 | 99 | // ESD filter task to fill standard info in the output generic AOD |
f70a1b5d | 100 | AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter"); |
643fea24 | 101 | //esdfilter->SetTrackFilter(trackFilter); //uncomment to apply cuts on the tracks |
f70a1b5d | 102 | esdfilter->SetDebugLevel(10); |
103 | mgr->AddTask(esdfilter); | |
104 | ||
643fea24 | 105 | // ESD filter task filling muon info in the output generic AOD |
f70a1b5d | 106 | AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter"); |
643fea24 | 107 | //esdmuonfilter->SetTrackFilter(trackMuonFilter); //uncomment to apply cuts on the muon tracks |
f70a1b5d | 108 | mgr->AddTask(esdmuonfilter); |
109 | ||
643fea24 | 110 | // Tag Creator |
111 | AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator"); | |
112 | mgr->AddTask(tagTask); | |
113 | ||
114 | // Input container | |
8a546c82 | 115 | AliAnalysisDataContainer *cin_esd = mgr->GetCommonInputContainer(); |
f70a1b5d | 116 | // Output AOD container. |
8a546c82 | 117 | AliAnalysisDataContainer *cout_aod = mgr->GetCommonOutputContainer(); |
643fea24 | 118 | // Tag container |
119 | AliAnalysisDataContainer *cout_tags = mgr->CreateContainer("cTag",TTree::Class(), | |
120 | AliAnalysisManager::kOutputContainer, "AOD.tag.root"); | |
121 | ||
f70a1b5d | 122 | // Connect containers to tasks slots |
123 | mgr->ConnectInput (esdfilter, 0, cin_esd ); | |
124 | mgr->ConnectOutput (esdfilter, 0, cout_aod ); | |
125 | ||
126 | mgr->ConnectInput (esdmuonfilter, 0, cin_esd); | |
127 | mgr->ConnectOutput (esdmuonfilter, 0, cout_aod ); | |
128 | ||
643fea24 | 129 | mgr->ConnectInput (tagTask, 0, cin_esd); |
130 | mgr->ConnectOutput (tagTask, 1, cout_tags); | |
131 | ||
f70a1b5d | 132 | // |
133 | // Run the analysis | |
134 | // | |
135 | if (mgr->InitAnalysis()) { | |
136 | mgr->PrintStatus(); | |
643fea24 | 137 | mgr->StartAnalysis("local",chain,nev); |
f70a1b5d | 138 | } |
139 | } | |
140 | ||
141 | //______________________________________________________________________________ | |
142 | void SetupPar(char* pararchivename) | |
143 | { | |
144 | if (pararchivename) { | |
145 | char processline[1024]; | |
146 | sprintf(processline,".! tar xvzf %s.par",pararchivename); | |
147 | gROOT->ProcessLine(processline); | |
148 | TString ocwd = gSystem->WorkingDirectory(); | |
149 | gSystem->ChangeDirectory(pararchivename); | |
150 | ||
151 | // check for BUILD.sh and execute | |
152 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
153 | printf("*******************************\n"); | |
154 | printf("*** Building PAR archive ***\n"); | |
155 | printf("*******************************\n"); | |
156 | ||
157 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
158 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
159 | return -1; | |
160 | } | |
161 | } | |
162 | // check for SETUP.C and execute | |
163 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
164 | printf("*******************************\n"); | |
165 | printf("*** Setup PAR archive ***\n"); | |
166 | printf("*******************************\n"); | |
167 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
168 | } | |
169 | ||
170 | gSystem->ChangeDirectory(ocwd.Data()); | |
171 | printf("Current dir: %s\n", ocwd.Data()); | |
172 | } | |
173 | } |