updates on track cuts (D. Sakata)
[u/mrichter/AliRoot.git] / PWGJE / UserTasks / AliAnalysisTaskJetHadronCorrelation.cxx
1 //#include <string.h>\r
2 //#include <TStyle.h>\r
3 #include <list>\r
4 #include <string>\r
5 \r
6 #include "TTree.h"\r
7 #include "TCanvas.h"\r
8 #include "AliAnalysisTask.h"\r
9 #include "AliInputEventHandler.h"\r
10 #include "AliESDtrack.h"\r
11 #include "AliAODVertex.h"\r
12 #include "AliAODCluster.h"\r
13 \r
14 #include <TROOT.h>\r
15 #include <TRandom.h>\r
16 #include <TSystem.h>\r
17 #include <TInterpreter.h>\r
18 #include <TChain.h>\r
19 #include <TFile.h>\r
20 #include <TKey.h>\r
21 #include <TH1F.h>\r
22 #include <TH2F.h>\r
23 #include <TH3F.h>\r
24 #include <TProfile.h>\r
25 #include <TList.h>\r
26 #include <TLorentzVector.h>\r
27 #include <TClonesArray.h>\r
28 #include <TRefArray.h>\r
29 \r
30 #include "TDatabasePDG.h"\r
31 #include "AliAnalysisManager.h"\r
32 #include "AliJetFinder.h"\r
33 #include "AliJetHeader.h"\r
34 #include "AliJetReader.h"\r
35 #include "AliJetReaderHeader.h"\r
36 #include "AliUA1JetHeaderV1.h"\r
37 #include "AliSISConeJetHeader.h"\r
38 #include "AliESDEvent.h"\r
39 #include "AliAODEvent.h"\r
40 #include "AliAODHandler.h"\r
41 #include "AliAODInputHandler.h"\r
42 #include "AliAODTrack.h"\r
43 #include "AliAODMCParticle.h"\r
44 #include "AliAODJet.h"\r
45 #include "AliAODJetEventBackground.h"\r
46 #include "AliMCParticle.h"\r
47 #include "AliAODMCParticle.h"\r
48 #include "AliMCEventHandler.h"\r
49 #include "AliMCEvent.h"\r
50 #include "AliStack.h"\r
51 \r
52 #include "AliAODHeader.h"\r
53 #include "AliAODMCHeader.h"\r
54 //#include "AliGenPythiaEventHeader.h"\r
55 #include "AliJetKineReaderHeader.h"\r
56 #include "AliGenCocktailEventHeader.h"\r
57 #include "AliInputEventHandler.h"\r
58 #include "AliGenEventHeader.h"\r
59 #include "AliGenDPMjetEventHeader.h"\r
60 \r
61 #include "AliAnalysisTaskJetHadronCorrelation.h"\r
62 #include "AliAnalysisTaskPhiCorrelations.h"\r
63 //#include "AliAnalysisHelperJetTasks.h"\r
64 #include "AliPWG4HighPtQAMC.h"\r
65 \r
66 using std::cout;\r
67 using std::endl;\r
68 \r
69 ClassImp(AliAnalysisTaskJetHadronCorrelation)\r
70 \r
71                                 //________________________________________________________________________\r
72                                 AliAnalysisTaskJetHadronCorrelation::AliAnalysisTaskJetHadronCorrelation():\r
73                                                                 AliAnalysisTaskSE(),\r
74                                                                 fUseAODInput(kFALSE),\r
75                                                                 fJetBranch("jets"),\r
76                                                                 fNonStdFile(""),\r
77                                                                 fAODIn(0x0),\r
78                                                                 fAODOut(0x0),\r
79                                                                 fAODExtension(0x0),\r
80                                                                 JFAlg("ANTIKT"),         \r
81                                                                 Radius(0.4),\r
82                                                                 Filtermask(272),\r
83                                                                 BackM(0),\r
84                                                                 TrackPtcut(0.15),\r
85                                                                 SkipCone(0),\r
86                                                                 IsMC(kTRUE),\r
87                                                                 JetEScale(1.),\r
88                                                                 TrackEScale(1.),\r
89                                                                 fxsec(0.),\r
90                                                                 ftrial(1.),\r
91                                                                 fHistList(0x0), // Output list\r
92                                                                 fH1Events(0x0),\r
93                                                                 fH1Xsec(0x0),\r
94                                                                 fH1Trials(0x0),\r
95                                                                 fH1Track_pt              (0x0),\r
96                                                                 fH1Track_phi             (0x0),\r
97                                                                 fH1Track_eta             (0x0),\r
98                                                                 fH1MCTrack_pt            (0x0),\r
99                                                                 fH1MCTrack_phi           (0x0),\r
100                                                                 fH1MCTrack_eta           (0x0),\r
101                                                                 fH1MCPrimTrack_pt        (0x0),\r
102                                                                 fH1MCPrimTrack_phi       (0x0),\r
103                                                                 fH1MCPrimTrack_eta       (0x0),\r
104                                                                 fH1Jet_pt                (0x0),\r
105                                                                 fH1Jet_phi               (0x0),\r
106                                                                 fH1Jet_eta               (0x0),\r
107                                                                 fH1leadJet_pt            (0x0),\r
108                                                                 fH1leadJet_pt_dijet      (0x0),\r
109                                                                 fH1subJet_pt_dijet       (0x0),\r
110                                                                 fH1JetMC_pt              (0x0),\r
111                                                                 fH1leadJetMC_pt          (0x0),\r
112                                                                 fH1leadJetMC_pt_dijet    (0x0),\r
113                                                                 fH1subJetMC_pt_dijet     (0x0),\r
114                                                                 fH2JetsJet_dphi          (0x0),\r
115                                                                 fH2JetsJet_deta          (0x0),\r
116                                                                 fH2JetsJet_Aj            (0x0),\r
117                                                                 fH2JetsJet_pt            (0x0),\r
118                                                                 fH2JetsJetMC_dphi        (0x0),\r
119                                                                 fH2JetsJetMC_deta        (0x0),\r
120                                                                 fH2JetsJetMC_Aj          (0x0),\r
121                                                                 fH2JetsJetMC_pt          (0x0),\r
122                                                                 fH2Mult_Mtrack           (0x0),\r
123                                                                 fH2Mult_Mlead            (0x0),\r
124                                                                 fH2Mult_Mjet             (0x0),\r
125                                                                 fH2Mult_Njet             (0x0),\r
126                                                                 fH2Mult_Aj               (0x0),\r
127                                                                 fH2Mlead_Aj              (0x0),\r
128                                                                 fH2Jet_pt_Mlead          (0x0),\r
129                                                                 fH2Jet_pt_Munder         (0x0),\r
130                                                                 fH2leadJetMCptResolution (0x0),\r
131                                                                 fH2TrackMCptResolution   (0x0),\r
132                                                                 fH2TrackMCptEfficiency   (0x0),\r
133                                                                 fH2AjCorrelation_MCRec   (0x0),\r
134                                                                 fH2MleadCorrelation_MCRec(0x0)\r
135 {\r
136                                 for(int j=0;j<5;j++){\r
137                                                                 fH1ndiJ_ediv                             [j]=0;\r
138                                                                 fH1Aj                                    [j]=0;\r
139                                                                 fH1Mlead                                 [j]=0;\r
140                                                                 fH1leadJetMC_dphiResolution              [j]=0;\r
141                                                                 fH1subJetMC_dphiResolution               [j]=0;\r
142                                                                 fH1leadJetMC_Efficiency                  [j]=0;\r
143                                                                 fH1subJetMC_Efficiency                   [j]=0;\r
144                                                                 for(int k=0;k<5;k++){\r
145                                                                                                 fH1JetHadron_dphi_ediv           [j][k]=0;\r
146                                                                                                 fH1JetHadron_dphi_tptweight_ediv [j][k]=0;\r
147                                                                                                 fH1JetHadron_dphi_tJptweight_ediv[j][k]=0;\r
148                                                                                                 fH1JetHadronMC_dphi_ediv           [j][k]=0;\r
149                                                                                                 fH1JetHadronMC_dphi_tptweight_ediv [j][k]=0;\r
150                                                                                                 fH1JetHadronMC_dphi_tJptweight_ediv[j][k]=0;\r
151                                                                                                 fH1JetHadronMCPrim_dphi_ediv           [j][k]=0;\r
152                                                                                                 fH1JetHadronMCPrim_dphi_tptweight_ediv [j][k]=0;\r
153                                                                                                 fH1JetHadronMCPrim_dphi_tJptweight_ediv[j][k]=0;\r
154                                                                 }\r
155                                 }\r
156                                 for(int j=0;j<3;j++){\r
157                                                                 fH1ndiJ_2040Mlead                               [j]=0;\r
158                                                                 fH1ndiJ_2040Aj                                  [j]=0;\r
159                                                                 for(int k=0;k<5;k++){\r
160                                                                                                 fH1JetHadron_dphi_tptweight2040_Mleaddep[j][k]=0;\r
161                                                                                                 fH1JetHadron_dphi_tptweight2040_Ajdep   [j][k]=0;\r
162                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Mleaddep[j][k]=0;\r
163                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Ajdep   [j][k]=0;\r
164                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep[j][k]=0;\r
165                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep   [j][k]=0;\r
166                                                                 }\r
167                                 }\r
168                                 // Default constructor\r
169 }\r
170 \r
171 //________________________________________________________________________\r
172 AliAnalysisTaskJetHadronCorrelation::AliAnalysisTaskJetHadronCorrelation(const char *name):\r
173                                 AliAnalysisTaskSE(name),\r
174                                 fUseAODInput(kFALSE),\r
175                                 fJetBranch("jets"),\r
176                                 fNonStdFile(""),\r
177                                 fAODIn(0x0), \r
178                                 fAODOut(0x0), \r
179                                 fAODExtension(0x0),\r
180                                 JFAlg("ANTIKT"),         \r
181                                 Radius(0.4),\r
182                                 Filtermask(272),\r
183                                 BackM(0),\r
184                                 TrackPtcut(0.15),\r
185                                 SkipCone(0),\r
186                                 IsMC(kTRUE),\r
187                                 JetEScale(1.),\r
188                                 TrackEScale(1.),\r
189                                 fxsec(0.),\r
190                                 ftrial(1.),\r
191                                 fHistList(0x0), // Output list\r
192 \r
193                                 fH1Events(0x0),\r
194                                 fH1Xsec(0x0),\r
195                                 fH1Trials(0x0),\r
196                                 fH1Track_pt              (0x0),\r
197                                 fH1Track_phi             (0x0),\r
198                                 fH1Track_eta             (0x0),\r
199                                 fH1MCTrack_pt            (0x0),\r
200                                 fH1MCTrack_phi           (0x0),\r
201                                 fH1MCTrack_eta           (0x0),\r
202                                 fH1MCPrimTrack_pt        (0x0),\r
203                                 fH1MCPrimTrack_phi       (0x0),\r
204                                 fH1MCPrimTrack_eta       (0x0),\r
205                                 fH1Jet_pt                (0x0),\r
206                                 fH1Jet_phi               (0x0),\r
207                                 fH1Jet_eta               (0x0),\r
208                                 fH1leadJet_pt            (0x0),\r
209                                 fH1leadJet_pt_dijet      (0x0),\r
210                                 fH1subJet_pt_dijet       (0x0),\r
211                                 fH1JetMC_pt              (0x0),\r
212                                 fH1leadJetMC_pt          (0x0),\r
213                                 fH1leadJetMC_pt_dijet    (0x0),\r
214                                 fH1subJetMC_pt_dijet     (0x0),\r
215                                 fH2JetsJet_dphi          (0x0),\r
216                                 fH2JetsJet_deta          (0x0),\r
217                                 fH2JetsJet_Aj            (0x0),\r
218                                 fH2JetsJet_pt            (0x0),\r
219                                 fH2JetsJetMC_dphi        (0x0),\r
220                                 fH2JetsJetMC_deta        (0x0),\r
221                                 fH2JetsJetMC_Aj          (0x0),\r
222                                 fH2JetsJetMC_pt          (0x0),\r
223                                 fH2Mult_Mtrack           (0x0),\r
224                                 fH2Mult_Mlead            (0x0),\r
225                                 fH2Mult_Mjet             (0x0),\r
226                                 fH2Mult_Njet             (0x0),\r
227                                 fH2Mult_Aj               (0x0),\r
228                                 fH2Mlead_Aj              (0x0),\r
229                                 fH2Jet_pt_Mlead          (0x0),\r
230                                 fH2Jet_pt_Munder         (0x0),\r
231                                 fH2leadJetMCptResolution (0x0),\r
232                                 fH2TrackMCptResolution   (0x0),\r
233                                 fH2TrackMCptEfficiency   (0x0),\r
234                                 fH2AjCorrelation_MCRec   (0x0),\r
235                                 fH2MleadCorrelation_MCRec(0x0)\r
236 {\r
237 \r
238                                 for(int j=0;j<5;j++){\r
239                                                                 fH1ndiJ_ediv                             [j]=0;\r
240                                                                 fH1Aj                                    [j]=0;\r
241                                                                 fH1Mlead                                 [j]=0;\r
242                                                                 fH1leadJetMC_dphiResolution              [j]=0;\r
243                                                                 fH1subJetMC_dphiResolution               [j]=0;\r
244                                                                 fH1leadJetMC_Efficiency                  [j]=0;\r
245                                                                 fH1subJetMC_Efficiency                   [j]=0;\r
246                                                                 for(int k=0;k<5;k++){\r
247                                                                                                 fH1JetHadron_dphi_ediv           [j][k]=0;\r
248                                                                                                 fH1JetHadron_dphi_tptweight_ediv [j][k]=0;\r
249                                                                                                 fH1JetHadron_dphi_tJptweight_ediv[j][k]=0;\r
250                                                                                                 fH1JetHadronMC_dphi_ediv           [j][k]=0;\r
251                                                                                                 fH1JetHadronMC_dphi_tptweight_ediv [j][k]=0;\r
252                                                                                                 fH1JetHadronMC_dphi_tJptweight_ediv[j][k]=0;\r
253                                                                                                 fH1JetHadronMCPrim_dphi_ediv           [j][k]=0;\r
254                                                                                                 fH1JetHadronMCPrim_dphi_tptweight_ediv [j][k]=0;\r
255                                                                                                 fH1JetHadronMCPrim_dphi_tJptweight_ediv[j][k]=0;\r
256                                                                 }\r
257                                 }\r
258                                 for(int j=0;j<3;j++){\r
259                                                                 fH1ndiJ_2040Mlead                               [j]=0;\r
260                                                                 fH1ndiJ_2040Aj                                  [j]=0;\r
261                                                                 for(int k=0;k<5;k++){\r
262                                                                                                 fH1JetHadron_dphi_tptweight2040_Mleaddep[j][k]=0;\r
263                                                                                                 fH1JetHadron_dphi_tptweight2040_Ajdep   [j][k]=0;\r
264                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Mleaddep[j][k]=0;\r
265                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Ajdep   [j][k]=0;\r
266                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep[j][k]=0;\r
267                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep   [j][k]=0;\r
268                                                                 }\r
269                                 }\r
270 \r
271                                 // Default constructor\r
272                                 // Constructor\r
273                                 // Define input and output slots here\r
274                                 // Input slot #0 works with a TChain\r
275                                 DefineInput(0, TChain::Class());\r
276                                 // Output slot #0 id reserved by the base class for AOD\r
277                                 // Output slot #1 writes into a TH1 container\r
278                                 DefineOutput(1, TList::Class());\r
279 }\r
280 \r
281 //________________________________________________________________________\r
282 void AliAnalysisTaskJetHadronCorrelation::UserCreateOutputObjects()\r
283 {\r
284                                 // Create histograms\r
285                                 // Called once\r
286 \r
287                                 fHistList = new TList();fHistList->SetOwner(kTRUE); cout<<"TList is created for output "<<endl;\r
288                                 //if (!fHistList){ fHistList = new TList();fHistList->SetOwner(kTRUE); cout<<"TList is created for output "<<endl;}\r
289 \r
290                                 Bool_t oldStatus = TH1::AddDirectoryStatus();\r
291                                 TH1::AddDirectory(kFALSE);\r
292                                 Float_t pi=TMath::Pi();\r
293 \r
294 \r
295                                 char *histname;\r
296 \r
297                                 fH1Events                  = new TH1F    ("Events"        ,"Events"            ,1,0,1);\r
298                                 fH1Xsec                    = new TProfile("Xsec"          ,"Xsec"              ,1,0,1);\r
299                                 fH1Trials                  = new TH1F    ("Trials"        ,"Trials"            ,1,0,1);\r
300 \r
301                                 fH1Track_pt                = new TH1F("Track_pt"          ,"Track_pt"          ,200,0,200);\r
302                                 fH1Track_phi               = new TH1F("Track_phi"         ,"Track_phi"         ,100,0,2*pi);\r
303                                 fH1Track_eta               = new TH1F("Track_eta"         ,"Track_eta"         ,100,-1.,1);\r
304                                 fH1MCTrack_pt              = new TH1F("MCTrack_pt"        ,"MCTrack_pt"        ,200,0,200);\r
305                                 fH1MCTrack_phi             = new TH1F("MCTrack_phi"       ,"MCTrack_phi"       ,100,0,2*pi);\r
306                                 fH1MCTrack_eta             = new TH1F("MCTrack_eta"       ,"MCTrack_eta"       ,100,-1.,1);\r
307                                 fH1MCPrimTrack_pt          = new TH1F("MCPrimTrack_pt"    ,"MCPrimTrack_pt"    ,200,0,200);\r
308                                 fH1MCPrimTrack_phi         = new TH1F("MCPrimTrack_phi"   ,"MCPrimTrack_phi"   ,100,0,2*pi);\r
309                                 fH1MCPrimTrack_eta         = new TH1F("MCPrimTrack_eta"   ,"MCPrimTrack_eta"   ,100,-1.,1);\r
310                                 fH1Jet_pt                  = new TH1F("Jet_pt"            ,"Jet_pt"            ,200,0,200);\r
311                                 fH1Jet_phi                 = new TH1F("Jet_phi"           ,"Jet_pt"            ,100,0,2*pi);\r
312                                 fH1Jet_eta                 = new TH1F("Jet_eta"           ,"Jet_pt"            ,100,-1.,1);\r
313                                 fH1leadJet_pt              = new TH1F("leadJet_pt"        ,"leadJet_pt"        ,200,0,200);\r
314                                 fH1leadJet_pt_dijet        = new TH1F("leadJet_pt_dijet"  ,"leadJet_pt_dijet"  ,200,0,200);\r
315                                 fH1subJet_pt_dijet         = new TH1F("subJet_pt_dijet"   ,"subJet_pt_dijet"   ,200,0,200);\r
316                                 fH1JetMC_pt                = new TH1F("JetMC_pt"          ,"JetMC_pt"          ,200,0,200);\r
317                                 fH1leadJetMC_pt            = new TH1F("leadJetMC_pt"      ,"leadJetMC_pt"      ,200,0,200);\r
318                                 fH1leadJetMC_pt_dijet      = new TH1F("leadJetMC_pt_dijet","leadJetMC_pt_dijet",200,0,200);\r
319                                 fH1subJetMC_pt_dijet       = new TH1F("subJetMC_pt_dijet" ,"subJetMC_pt_dijet" ,200,0,200);\r
320                                 fH2JetsJet_dphi            = new TH2F("JetsJet_dphi"      ,"JetsJet_dphi"      ,200,0,200,100,-2*pi,2*pi);\r
321                                 fH2JetsJet_deta            = new TH2F("JetsJet_deta"      ,"JetsJet_deta"      ,200,0,200,100,-1.5,1.5);\r
322                                 fH2JetsJet_Aj              = new TH2F("JetsJet_Aj"        ,"JetsJet_Aj"        ,200,0,200,100,0,1.2);\r
323                                 fH2JetsJet_pt              = new TH2F("JetsJet_pt"        ,"JetsJet_pt"        ,200,0,200,200,0,200);\r
324                                 fH2JetsJetMC_dphi          = new TH2F("JetsJetMC_dphi"    ,"JetsJetMC_dphi"    ,200,0,200,100,-2*pi,2*pi);\r
325                                 fH2JetsJetMC_deta          = new TH2F("JetsJetMC_deta"    ,"JetsJetMC_deta"    ,200,0,200,100,-1.5,1.5);\r
326                                 fH2JetsJetMC_Aj            = new TH2F("JetsJetMC_Aj"      ,"JetsJetMC_Aj"      ,200,0,200,100,0,1.2);\r
327                                 fH2JetsJetMC_pt            = new TH2F("JetsJetMC_pt"      ,"JetsJetMC_pt"      ,200,0,200,200,0,200);\r
328                                 fH2Mult_Mtrack             = new TH2F("Mult_Mtrack"       ,"Mult_Mtrack"       ,50,0,250,50,0,250); \r
329                                 fH2Mult_Mlead              = new TH2F("Mult_Mlead"        ,"Mult_Mlead"        ,50,0,250,25,0,25);   \r
330                                 fH2Mult_Mjet               = new TH2F("Mult_Mjet"         ,"Mult_Mjet"         ,50,0,250,50,0,100);  \r
331                                 fH2Mult_Njet               = new TH2F("Mult_Njet"         ,"Mult_Njet"         ,50,0,250,50,0,50);   \r
332                                 fH2Mult_Aj                 = new TH2F("Mult_Aj"           ,"Mult_Aj"           ,50,0,250,25,0,1.2);  \r
333                                 fH2Mlead_Aj                = new TH2F("Mlead_Aj"          ,"Mlead_Aj"          ,25,0,25,25,0,1.2);   \r
334                                 fH2Jet_pt_Mlead            = new TH2F("Jet_pt_Mlead"      ,"Jet_pt_Mlead"      ,50,0,200,25,0,25);   \r
335                                 fH2Jet_pt_Munder           = new TH2F("Jet_pt_Munder"     ,"Jet_pt_Munder"     ,50,0,200,25,0,5);    \r
336                                 fH2leadJetMCptResolution   = new TH2F("leadJetMCptResolution" ,"leadJetMCptResolution" ,200,0,200,200,0,200);    \r
337                                 fH2TrackMCptResolution     = new TH2F("TrackMCptResolution"   ,"TrackMCptResolution"   ,200,0,200,200,0,200);    \r
338                                 fH2TrackMCptEfficiency     = new TH2F("TrackMCptEfficiency"   ,"TrackMCptEfficiency"   ,200,0,200,100,0,1.2);    \r
339                                 fH2AjCorrelation_MCRec     = new TH2F("AjCorrelation_MCRec"   ,"AjCorrelation_MCRec"   ,60,0,1.2,60,0,1.2);    \r
340                                 fH2MleadCorrelation_MCRec  = new TH2F("MleadCorrelation_MCRec","MleadCorrelation_MCRec",60,0,60,60,0,60);    \r
341 \r
342                                 for(int j=0;j<5;j++){\r
343                                                                 histname = Form("ndiJ_ediv%d",j);\r
344                                                                 fH1ndiJ_ediv[j]= new TH1F(histname,histname,1,1,2);\r
345                                                                 histname        = Form("Aj%d",j);                    \r
346                                                                 fH1Aj[j]    = new TH1F(histname,histname,50,0,1.2);  \r
347                                                                 histname        = Form("Mlead%d",j);                 \r
348                                                                 fH1Mlead[j] = new TH1F(histname,histname,50,0,50);   \r
349                                                                 histname = Form("leadJetMC_dphiResolution%d",j);\r
350                                                                 fH1leadJetMC_dphiResolution[j] = new TH1F(histname,histname,200,-2*pi,2*pi);\r
351                                                                 histname = Form("subJetMC_dphiResolution%d",j);\r
352                                                                 fH1subJetMC_dphiResolution[j] = new TH1F(histname,histname,200,-2*pi,2*pi);\r
353                                                                 histname = Form("leadJetMC_Efficiency%d",j);\r
354                                                                 fH1leadJetMC_Efficiency[j] = new TH1F(histname,histname,100,0,1.2);\r
355                                                                 histname = Form("subJetMC_Efficiency%d",j);\r
356                                                                 fH1subJetMC_Efficiency[j] = new TH1F(histname,histname,100,0,1.2);\r
357                                                                 for(int k=0;k<5;k++){\r
358                                                                                                 histname = Form("JetHadron_dphi_ediv%d%d",j,k);\r
359                                                                                                 fH1JetHadron_dphi_ediv             [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
360                                                                                                 histname = Form("JetHadron_dphi_tptweight_ediv%d%d",j,k);\r
361                                                                                                 fH1JetHadron_dphi_tptweight_ediv   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
362                                                                                                 histname = Form("JetHadron_dphi_tJptweight_ediv%d%d",j,k);\r
363                                                                                                 fH1JetHadron_dphi_tJptweight_ediv  [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
364                                                                                                 histname = Form("JetHadronMC_dphi_ediv%d%d",j,k);\r
365                                                                                                 fH1JetHadronMC_dphi_ediv             [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
366                                                                                                 histname = Form("JetHadronMC_dphi_tptweight_ediv%d%d",j,k);\r
367                                                                                                 fH1JetHadronMC_dphi_tptweight_ediv   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
368                                                                                                 histname = Form("JetHadronMC_dphi_tJptweight_ediv%d%d",j,k);\r
369                                                                                                 fH1JetHadronMC_dphi_tJptweight_ediv  [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
370                                                                                                 histname = Form("JetHadronMCPrim_dphi_ediv%d%d",j,k);\r
371                                                                                                 fH1JetHadronMCPrim_dphi_ediv             [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
372                                                                                                 histname = Form("JetHadronMCPrim_dphi_tptweight_ediv%d%d",j,k);\r
373                                                                                                 fH1JetHadronMCPrim_dphi_tptweight_ediv   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
374                                                                                                 histname = Form("JetHadronMCPrim_dphi_tJptweight_ediv%d%d",j,k);\r
375                                                                                                 fH1JetHadronMCPrim_dphi_tJptweight_ediv  [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
376                                                                 }\r
377                                 }\r
378                                 for(int j=0;j<3;j++){\r
379                                                                 histname = Form("ndiJ_2040Mlead%d",j);\r
380                                                                 fH1ndiJ_2040Mlead[j]= new TH1F(histname,histname,1,1,2);\r
381                                                                 histname = Form("ndiJ_2040Aj%d",j);\r
382                                                                 fH1ndiJ_2040Aj[j]= new TH1F(histname,histname,1,1,2);\r
383                                                                 for(int k=0;k<5;k++){\r
384                                                                                                 histname = Form("JetHadron_dphi_tptweight2040_Mleaddep%d%d",j,k);\r
385                                                                                                 fH1JetHadron_dphi_tptweight2040_Mleaddep   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
386                                                                                                 histname = Form("JetHadron_dphi_tptweight2040_Ajdep%d%d",j,k);\r
387                                                                                                 fH1JetHadron_dphi_tptweight2040_Ajdep      [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
388                                                                                                 histname = Form("JetHadronMC_dphi_tptweight2040_Mleaddep%d%d",j,k);\r
389                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Mleaddep   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
390                                                                                                 histname = Form("JetHadronMC_dphi_tptweight2040_Ajdep%d%d",j,k);\r
391                                                                                                 fH1JetHadronMC_dphi_tptweight2040_Ajdep      [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
392                                                                                                 histname = Form("JetHadronMCPrim_dphi_tptweight2040_Mleaddep%d%d",j,k);\r
393                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep   [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
394                                                                                                 histname = Form("JetHadronMCPrim_dphi_tptweight2040_Ajdep%d%d",j,k);\r
395                                                                                                 fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep      [j][k]= new TH1F(histname,histname,200,-1./2.*pi,3./2.*pi);\r
396                                                                 }\r
397                                 }\r
398 \r
399 \r
400                                 if(IsMC){\r
401                                                                 fHistList->Add(fH1Events            );\r
402                                                                 fHistList->Add(fH1Xsec              );\r
403                                                                 fHistList->Add(fH1Trials            );\r
404                                                                 fHistList->Add(fH1Track_pt          );\r
405                                                                 fHistList->Add(fH1Track_phi         );\r
406                                                                 fHistList->Add(fH1Track_eta         );\r
407                                                                 fHistList->Add(fH1MCTrack_pt        );\r
408                                                                 fHistList->Add(fH1MCTrack_phi       );\r
409                                                                 fHistList->Add(fH1MCTrack_eta       );\r
410                                                                 fHistList->Add(fH1MCPrimTrack_pt    );\r
411                                                                 fHistList->Add(fH1MCPrimTrack_phi   );\r
412                                                                 fHistList->Add(fH1MCPrimTrack_eta   );\r
413                                                                 fHistList->Add(fH1Jet_pt            );\r
414                                                                 fHistList->Add(fH1Jet_phi           );\r
415                                                                 fHistList->Add(fH1Jet_eta           );\r
416                                                                 fHistList->Add(fH1leadJet_pt        );\r
417                                                                 fHistList->Add(fH1leadJet_pt_dijet  );\r
418                                                                 fHistList->Add(fH1subJet_pt_dijet   );\r
419                                                                 fHistList->Add(fH1JetMC_pt          );\r
420                                                                 fHistList->Add(fH1leadJetMC_pt      );\r
421                                                                 fHistList->Add(fH1leadJetMC_pt_dijet);\r
422                                                                 fHistList->Add(fH1subJetMC_pt_dijet );\r
423                                                                 fHistList->Add(fH2JetsJet_dphi      );\r
424                                                                 fHistList->Add(fH2JetsJet_deta      );\r
425                                                                 fHistList->Add(fH2JetsJet_Aj        );\r
426                                                                 fHistList->Add(fH2JetsJet_pt        );\r
427                                                                 fHistList->Add(fH2JetsJetMC_dphi    );\r
428                                                                 fHistList->Add(fH2JetsJetMC_deta    );\r
429                                                                 fHistList->Add(fH2JetsJetMC_Aj      );\r
430                                                                 fHistList->Add(fH2JetsJetMC_pt      );\r
431                                                                 fHistList->Add(fH2Mult_Mtrack       );\r
432                                                                 fHistList->Add(fH2Mult_Mlead        ); \r
433                                                                 fHistList->Add(fH2Mult_Mjet         );  \r
434                                                                 fHistList->Add(fH2Mult_Njet         );  \r
435                                                                 fHistList->Add(fH2Mult_Aj           );    \r
436                                                                 fHistList->Add(fH2Mlead_Aj          );   \r
437                                                                 fHistList->Add(fH2Jet_pt_Mlead      );   \r
438                                                                 fHistList->Add(fH2Jet_pt_Munder     );  \r
439                                                                 fHistList->Add(fH2leadJetMCptResolution );\r
440                                                                 fHistList->Add(fH2TrackMCptResolution   );\r
441                                                                 fHistList->Add(fH2TrackMCptEfficiency   );\r
442                                                                 fHistList->Add(fH2AjCorrelation_MCRec   );\r
443                                                                 fHistList->Add(fH2MleadCorrelation_MCRec);\r
444                                                                 for(int j=0;j<5;j++){\r
445                                                                                                 fHistList->Add(fH1ndiJ_ediv                        [j]);\r
446                                                                                                 fHistList->Add(fH1Aj                               [j]);\r
447                                                                                                 fHistList->Add(fH1Mlead                            [j]);\r
448                                                                                                 fHistList->Add(fH1leadJetMC_dphiResolution         [j]);\r
449                                                                                                 fHistList->Add(fH1subJetMC_dphiResolution          [j]);\r
450                                                                                                 fHistList->Add(fH1leadJetMC_Efficiency             [j]);\r
451                                                                                                 fHistList->Add(fH1subJetMC_Efficiency              [j]);\r
452                                                                                                 for(int k=0;k<5;k++){\r
453                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_ediv               [j][k]);\r
454                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight_ediv     [j][k]);\r
455                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tJptweight_ediv    [j][k]);\r
456                                                                                                                                 fHistList->Add(fH1JetHadronMC_dphi_ediv               [j][k]);\r
457                                                                                                                                 fHistList->Add(fH1JetHadronMC_dphi_tptweight_ediv     [j][k]);\r
458                                                                                                                                 fHistList->Add(fH1JetHadronMC_dphi_tJptweight_ediv    [j][k]);\r
459                                                                                                                                 fHistList->Add(fH1JetHadronMCPrim_dphi_ediv               [j][k]);\r
460                                                                                                                                 fHistList->Add(fH1JetHadronMCPrim_dphi_tptweight_ediv     [j][k]);\r
461                                                                                                                                 fHistList->Add(fH1JetHadronMCPrim_dphi_tJptweight_ediv    [j][k]);\r
462                                                                                                 }\r
463                                                                 }\r
464                                                                 for(int j=0;j<3;j++){\r
465                                                                                                 fHistList->Add(fH1ndiJ_2040Mlead    [j]);\r
466                                                                                                 fHistList->Add(fH1ndiJ_2040Aj       [j]);\r
467                                                                                                 for(int k=0;k<5;k++){\r
468                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight2040_Mleaddep     [j][k]);\r
469                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight2040_Ajdep        [j][k]);\r
470                                                                                                                                 fHistList->Add(fH1JetHadronMC_dphi_tptweight2040_Mleaddep     [j][k]);\r
471                                                                                                                                 fHistList->Add(fH1JetHadronMC_dphi_tptweight2040_Ajdep        [j][k]);\r
472                                                                                                                                 fHistList->Add(fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep     [j][k]);\r
473                                                                                                                                 fHistList->Add(fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep        [j][k]);\r
474                                                                                                 }\r
475                                                                 }\r
476                                 }\r
477                                 else{\r
478                                                                 fHistList->Add(fH1Events            );\r
479                                                                 fHistList->Add(fH1Track_pt          );\r
480                                                                 fHistList->Add(fH1Track_phi         );\r
481                                                                 fHistList->Add(fH1Track_eta         );\r
482                                                                 fHistList->Add(fH1Jet_pt            );\r
483                                                                 fHistList->Add(fH1Jet_phi           );\r
484                                                                 fHistList->Add(fH1Jet_eta           );\r
485                                                                 fHistList->Add(fH1leadJet_pt        );\r
486                                                                 fHistList->Add(fH1leadJet_pt_dijet  );\r
487                                                                 fHistList->Add(fH1subJet_pt_dijet   );\r
488                                                                 fHistList->Add(fH2JetsJet_dphi      );\r
489                                                                 fHistList->Add(fH2JetsJet_deta      );\r
490                                                                 fHistList->Add(fH2JetsJet_Aj        );\r
491                                                                 fHistList->Add(fH2JetsJet_pt        );\r
492                                                                 fHistList->Add(fH2Mult_Mtrack       );\r
493                                                                 fHistList->Add(fH2Mult_Mlead        ); \r
494                                                                 fHistList->Add(fH2Mult_Mjet         );  \r
495                                                                 fHistList->Add(fH2Mult_Njet         );  \r
496                                                                 fHistList->Add(fH2Mult_Aj           );    \r
497                                                                 fHistList->Add(fH2Mlead_Aj          );   \r
498                                                                 fHistList->Add(fH2Jet_pt_Mlead      );   \r
499                                                                 fHistList->Add(fH2Jet_pt_Munder     );  \r
500                                                                 for(int j=0;j<5;j++){\r
501                                                                                                 fHistList->Add(fH1ndiJ_ediv                        [j]);\r
502                                                                                                 fHistList->Add(fH1Aj                               [j]);\r
503                                                                                                 fHistList->Add(fH1Mlead                            [j]);\r
504                                                                                                 for(int k=0;k<5;k++){\r
505                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_ediv               [j][k]);\r
506                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight_ediv     [j][k]);\r
507                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tJptweight_ediv    [j][k]);\r
508                                                                                                 }\r
509                                                                 }\r
510                                                                 for(int j=0;j<3;j++){\r
511                                                                                                 fHistList->Add(fH1ndiJ_2040Mlead    [j]);\r
512                                                                                                 fHistList->Add(fH1ndiJ_2040Aj       [j]);\r
513                                                                                                 for(int k=0;k<5;k++){\r
514                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight2040_Mleaddep     [j][k]);\r
515                                                                                                                                 fHistList->Add(fH1JetHadron_dphi_tptweight2040_Ajdep        [j][k]);\r
516                                                                                                 }\r
517                                                                 }\r
518                                 }\r
519 \r
520                                 // =========== Switch on Sumw2 for all histos ===========\r
521                                 for (Int_t i=0; i<fHistList->GetEntries(); ++i) \r
522                                 {\r
523                                                                 TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));\r
524                                                                 if (h1)\r
525                                                                 {\r
526                                                                                                 h1->Sumw2();\r
527                                                                                                 continue;\r
528                                                                 }\r
529                                                                 THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i));\r
530                                                                 if(hn)hn->Sumw2();\r
531                                 }\r
532                                 TH1::AddDirectory(oldStatus);\r
533 \r
534                                 PostData(1,fHistList);\r
535 }\r
536 \r
537 \r
538 //----------------------------------------------------------------------                                                 \r
539 void AliAnalysisTaskJetHadronCorrelation::Init()\r
540 {\r
541                                 // Initialization                                                                                                    \r
542                                 if (fDebug) printf("AnalysisTaskJetHadronCorrelation::Init() \n");\r
543 \r
544 }\r
545 \r
546 Bool_t AliAnalysisTaskJetHadronCorrelation::Notify()\r
547 {\r
548 \r
549 \r
550                                 fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());\r
551                                 fAODOut = AODEvent();\r
552                                 if(fNonStdFile.Length()!=0){\r
553                                                                 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());\r
554                                                                 fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0);\r
555                                                                 if(fAODExtension){\r
556                                                                                                 if(fDebug>1)Printf("AODExtension found for %s ",fNonStdFile.Data());\r
557                                                                 }\r
558                                 }\r
559 \r
560                                 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();\r
561                                 fxsec=0;\r
562                                 ftrial=1;\r
563 \r
564                                 if(tree){\r
565                                                                 TFile *curfile = tree->GetCurrentFile();\r
566                                                                 if(!curfile){\r
567                                                                                                 Error("Notify","No current file");\r
568                                                                                                 return kFALSE;\r
569                                                                 }\r
570                                                                 if(IsMC){\r
571                                                                                                 AliPWG4HighPtQAMC::PythiaInfoFromFile(curfile->GetName(),fxsec,ftrial);\r
572                                                                                                 fH1Xsec  ->Fill(0.,fxsec);\r
573                                                                                                 fH1Trials->Fill(0.,ftrial);\r
574                                                                 }\r
575 \r
576                                 }\r
577 \r
578                                 printf("Reading File %s ",fInputHandler->GetTree()->GetCurrentFile()->GetName());\r
579                                 return kTRUE;\r
580 }\r
581 void AliAnalysisTaskJetHadronCorrelation::FinishTaskOutput()\r
582 {\r
583 }\r
584 \r
585 \r
586 \r
587 //________________________________________________________________________\r
588 void AliAnalysisTaskJetHadronCorrelation::UserExec(Option_t *) \r
589 {\r
590 \r
591 \r
592                                 // Main loop (called each event)\r
593                                 // Execute analysis for current event\r
594 \r
595                                 AliAODEvent *fAOD;\r
596                                 TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
597                                 if( handler && handler->InheritsFrom("AliAODInputHandler") ) {\r
598                                                                 fAOD  =  ((AliAODInputHandler*)handler)->GetEvent();\r
599                                                                 if(fUseAODInput) fAODIn = fAOD;\r
600                                                                 if (fDebug > 1)  Printf("%s:%d AOD event from input", (char*)__FILE__,__LINE__);\r
601                                 }\r
602                                 else {\r
603                                                                 handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();\r
604                                                                 if( handler && handler->InheritsFrom("AliAODHandler") ) {\r
605                                                                                                 fAOD = ((AliAODHandler*)handler)->GetAOD();\r
606                                                                                                 fAODIn = fAOD;\r
607                                                                                                 if (fDebug > 1)  Printf("%s:%d AOD event from output", (char*)__FILE__,__LINE__);\r
608                                                                 }\r
609                                 }\r
610 \r
611                                 if(!fAODIn && !fUseAODInput){ // case we have AOD in input & output and want jets from output\r
612                                                                 TObject* outHandler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();\r
613                                                                 if( outHandler && outHandler->InheritsFrom("AliAODHandler") ) {\r
614                                                                                                 fAODIn = ((AliAODHandler*)outHandler)->GetAOD();\r
615                                                                                                 if (fDebug > 1)  Printf("%s:%d jets from output AOD", (char*)__FILE__,__LINE__);\r
616                                                                 }\r
617                                 }\r
618                                 if (!fAODIn) {\r
619                                                                 Printf("ERROR %s : fAODIn not available",(char*)__FILE__);\r
620                                                                 return;\r
621                                 }\r
622 \r
623                                 AliInputEventHandler* inputHandler = (AliInputEventHandler*)\r
624                                                                 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());\r
625                                 if(!(inputHandler->IsEventSelected() & AliVEvent::kAny)){\r
626                                                                 if (fDebug > 1 ) Printf(" Trigger Selection: event REJECTED ... ");\r
627                                                                 return;\r
628                                 }\r
629                                 fH1Events->Fill(0);\r
630 \r
631                                 AliAODHeader* aliH = dynamic_cast <AliAODHeader*> (fAODIn->GetHeader());\r
632                                 if(!aliH){\r
633                                                                 Printf("ERROR: AliAODHeader not available");\r
634                                                                 return;\r
635                                 }\r
636                                 double Mult = aliH->GetRefMultiplicity();\r
637 \r
638                                 // start jet analysis  -------------------------Init.\r
639                                 Float_t pi=TMath::Pi();\r
640 \r
641                                 Double_t Jet_pt   [20][5000];\r
642                                 Double_t Jet_phi  [20][5000];\r
643                                 Double_t Jet_eta  [20][5000];\r
644                                 Double_t Jet_area [20][5000];\r
645                                 Double_t subJet_pt [20][5000];\r
646                                 Double_t subJet_eta[20][5000];\r
647                                 Double_t Track_n  ;\r
648                                 Double_t Track_pt [5000];\r
649                                 Double_t Track_eta[5000];\r
650                                 Double_t Track_phi[5000];\r
651                                 Double_t MCTrack_n  ;\r
652                                 Double_t MCTrack_pt [5000];\r
653                                 Double_t MCTrack_eta[5000];\r
654                                 Double_t MCTrack_phi[5000];\r
655 \r
656                                 Track_n=0;MCTrack_n=0;\r
657                                 for(int i=0;i<20;i++){\r
658                                                                 for(int j=0;j<1000;j++){\r
659                                                                                                 Jet_pt[i][j]=0.;\r
660                                                                                                 Jet_phi[i][j]=999.;\r
661                                                                                                 Jet_eta[i][j]=999.;\r
662                                                                                                 Jet_area[i][j]=999.;\r
663                                                                                                 subJet_pt[i][j]=0.;\r
664                                                                                                 subJet_eta[i][j]=999.;\r
665                                                                                                 Track_pt [j]=0.;\r
666                                                                                                 Track_phi[j]=999.;\r
667                                                                                                 Track_eta[j]=999.;\r
668                                                                                                 MCTrack_pt [j]=0.;\r
669                                                                                                 MCTrack_phi[j]=999.;\r
670                                                                                                 MCTrack_eta[j]=999.;\r
671                                                                 }\r
672                                 }\r
673 \r
674                                 int nLJetAOD=999; double ptLJetAOD=0;double phiLJetAOD=999.;double etaLJetAOD=999.;double ptsLJetAOD=0;double phisLJetAOD=900.;double etasLJetAOD=900.;\r
675                                 int nLJetMC2=999; double ptLJetMC2=0;double phiLJetMC2=999.;double etaLJetMC2=999.;double ptsLJetMC2=0;double phisLJetMC2=900.;double etasLJetMC2=900.;\r
676                                 int nLJetMC =999; double ptLJetMC =0;double phiLJetMC =999.;double etaLJetMC =999.;double ptsLJetMC =0;double phisLJetMC =900.;double etasLJetMC =900.;\r
677                                 bool findLJetAOD=false;\r
678                                 bool findLJetMC2=false;\r
679                                 bool findDiJet=false,findDiJetMC=false;\r
680                                 int nLJet = 999;\r
681                                 int Mjet_tot =0;\r
682                                 int Njet_tot =0;\r
683 \r
684                                 double Aj=99.,AjMC=99.;\r
685                                 double Mlead=99.,MleadMC=99.;\r
686                                 int    Munder=99.;\r
687 \r
688                                 ////--------------------------------------------------------------------Init.\r
689 \r
690 \r
691                                 TString cAdd = "";\r
692                                 cAdd += Form("%02d_",(int)((Radius+0.01)*10.));\r
693                                 cAdd += Form("B%d",(int)BackM);\r
694                                 cAdd += Form("_Filter%05d",Filtermask);\r
695                                 cAdd += Form("_Cut%05d",(int)(1000.*TrackPtcut));\r
696                                 cAdd += Form("_Skip%02d",SkipCone);\r
697                                 TString Branchname_gen,Branchname_gen2,Branchname_rec;\r
698                                 Branchname_gen  = Form("clustersAODMC_%s%s",JFAlg.Data(),cAdd.Data());\r
699                                 Branchname_gen2 = Form("clustersAODMC2_%s%s",JFAlg.Data(),cAdd.Data());\r
700                                 Branchname_rec  = Form("clustersAOD_%s%s",JFAlg.Data(),cAdd.Data());\r
701 \r
702 \r
703                                 for(int algorithm=0;algorithm<3;algorithm++){\r
704 \r
705                                                                 if(algorithm==0)fJetBranch   = Branchname_rec.Data();\r
706                                                                 if(algorithm==1)fJetBranch   = Branchname_gen2.Data();\r
707                                                                 if(algorithm==2)fJetBranch   = Branchname_gen.Data();\r
708 \r
709                                                                 if((!IsMC&&(algorithm==1||algorithm==2)))continue;\r
710 \r
711                                                                 TClonesArray* jets = dynamic_cast <TClonesArray*> (fAODIn->FindListObject(fJetBranch.Data()));\r
712                                                                 if(!jets){\r
713                                                                                                 printf(" Tere are no Branch named %s \n",fJetBranch.Data());\r
714                                                                                                 continue;\r
715                                                                 }\r
716                                                                 Int_t nj = jets->GetEntriesFast();\r
717                                                                 if (fDebug) printf("There are %5d jets in the event \n", nj);\r
718                                                                 AliAODJet* jetsAOD;\r
719                                                                 //Find Leading Jet -------------------------------------------------------\r
720                                                                 for(int njet =0;njet<nj;njet++){\r
721                                                                                                 jetsAOD = (AliAODJet*) (jets->At(njet));\r
722                                                                                                 Jet_pt   [algorithm][njet] = jetsAOD->Pt()*JetEScale;\r
723                                                                                                 Jet_phi  [algorithm][njet] = jetsAOD->Phi();  \r
724                                                                                                 Jet_eta  [algorithm][njet] = jetsAOD->Eta();\r
725                                                                                                 Jet_area [algorithm][njet] = jetsAOD->EffectiveAreaCharged();\r
726 \r
727                                                                                                 TRefArray *reftracks = jetsAOD->GetRefTracks();\r
728                                                                                                 if(algorithm==0){if(Jet_pt[algorithm][njet]>1.)Mjet_tot +=  reftracks->GetEntriesFast();Njet_tot++;}\r
729                                                                                                 double eta_cut_Jet=0.5;\r
730                                                                                                 if((TMath::Abs(Jet_eta[algorithm][njet])<eta_cut_Jet)&&(Jet_pt[algorithm][njet]>10.)){\r
731                                                                                                                                 if(algorithm==0){\r
732                                                                                                                                                                 fH1Jet_pt ->Fill(Jet_pt [algorithm][njet]);  \r
733                                                                                                                                                                 fH1Jet_phi->Fill(Jet_phi[algorithm][njet]);  \r
734                                                                                                                                                                 fH1Jet_eta->Fill(Jet_eta[algorithm][njet]);  \r
735                                                                                                                                                                 if(Jet_pt[algorithm][njet]>ptLJetAOD){\r
736                                                                                                                                                                                                 findLJetAOD=true;\r
737                                                                                                                                                                                                 nLJetAOD=njet;ptLJetAOD=Jet_pt[algorithm][njet];phiLJetAOD=Jet_phi[algorithm][njet];etaLJetAOD=Jet_eta[algorithm][njet];\r
738                                                                                                                                                                 }\r
739                                                                                                                                 }\r
740                                                                                                                                 if(algorithm==1){\r
741                                                                                                                                                                 fH1JetMC_pt->Fill(Jet_pt[algorithm][njet]);  \r
742                                                                                                                                                                 if(Jet_pt[algorithm][njet]>ptLJetMC2){\r
743                                                                                                                                                                                                 findLJetMC2=true;\r
744                                                                                                                                                                                                 nLJetMC2=njet;ptLJetMC2=Jet_pt[algorithm][njet];phiLJetMC2=Jet_phi[algorithm][njet];etaLJetMC2=Jet_eta[algorithm][njet];\r
745                                                                                                                                                                 }\r
746                                                                                                                                 }\r
747                                                                                                                                 if(algorithm==2){\r
748                                                                                                                                                                 if(Jet_pt[algorithm][njet]>ptLJetMC){\r
749                                                                                                                                                                                                 nLJetMC=njet;ptLJetMC=Jet_pt[algorithm][njet];phiLJetMC=Jet_phi[algorithm][njet];etaLJetMC=Jet_eta[algorithm][njet];\r
750                                                                                                                                                                 }\r
751                                                                                                                                 }\r
752                                                                                                 }\r
753                                                                 }//njet loop\r
754                                                                 if(algorithm==0){nLJet=nLJetAOD;fH1leadJet_pt  ->Fill(Jet_pt[algorithm][nLJet]);}\r
755                                                                 if(algorithm==1){nLJet=nLJetMC2;fH1leadJetMC_pt->Fill(Jet_pt[algorithm][nLJet]);}\r
756                                                                 if(algorithm==2){nLJet=nLJetMC;}\r
757                                                                 if(findLJetAOD&&(algorithm==0)){\r
758                                                                                                 jetsAOD = (AliAODJet*) (jets->At(nLJet));\r
759                                                                                                 TRefArray *reftracks = jetsAOD->GetRefTracks();\r
760                                                                                                 Mlead = reftracks->GetEntriesFast();\r
761                                                                 }\r
762                                                                 if(findLJetMC2&&(algorithm==1)){\r
763                                                                                                 jetsAOD = (AliAODJet*) (jets->At(nLJetMC2));\r
764                                                                                                 TRefArray *reftracks = jetsAOD->GetRefTracks();\r
765                                                                                                 MleadMC = reftracks->GetEntriesFast();\r
766                                                                 }\r
767                                                                 //----------------------------------------------------------- Leading Jet\r
768                                                                 if(nj<2)continue;\r
769                                                                 //Find Sub leading Jet ==================================================\r
770                                                                 for(int njet=0;njet<nj;njet++){\r
771                                                                                                 if(njet==nLJet)continue;\r
772                                                                                                 jetsAOD = (AliAODJet *)jets->At(njet);\r
773                                                                                                 subJet_pt [algorithm][njet] = jetsAOD->Pt()*JetEScale;\r
774                                                                                                 subJet_eta[algorithm][njet] = jetsAOD->Eta();\r
775                                                                                                 double eta_cut_Jet=0.5;\r
776                                                                                                 if((TMath::Abs(subJet_eta[algorithm][njet])<eta_cut_Jet) && (subJet_pt[algorithm][njet]>10.)){\r
777                                                                                                                                 if(subJet_pt[algorithm][njet]>ptsLJetAOD&&algorithm==0){\r
778                                                                                                                                                                 ptsLJetAOD=Jet_pt[algorithm][njet];phisLJetAOD=Jet_phi[algorithm][njet];etasLJetAOD=Jet_eta[algorithm][njet];\r
779                                                                                                                                 }\r
780                                                                                                                                 if(subJet_pt[algorithm][njet]>ptsLJetMC2 &&algorithm==1){\r
781                                                                                                                                                                 ptsLJetMC2=Jet_pt[algorithm][njet];phisLJetMC2=Jet_phi[algorithm][njet];etasLJetMC2=Jet_eta[algorithm][njet];\r
782                                                                                                                                 }\r
783                                                                                                                                 if(subJet_pt[algorithm][njet]>ptsLJetMC &&algorithm==2){\r
784                                                                                                                                                                 ptsLJetMC =Jet_pt[algorithm][njet];phisLJetMC =Jet_phi[algorithm][njet];etasLJetMC =Jet_eta[algorithm][njet];\r
785                                                                                                                                 }\r
786                                                                                                 }\r
787                                                                 }\r
788                                                                 //====================================================== Sub leading Jet \r
789 \r
790                                                                 double Leading_pt=0.;double Leading_phi=999.;double Leading_eta=999.;double sLeading_pt=0.;double sLeading_phi=999.;double sLeading_eta=999.;\r
791                                                                 if(algorithm==0){Leading_pt=ptLJetAOD;Leading_phi=phiLJetAOD;Leading_eta=etaLJetAOD;sLeading_pt=ptsLJetAOD;sLeading_phi=phisLJetAOD;sLeading_eta=etasLJetAOD;}\r
792                                                                 if(algorithm==1){Leading_pt=ptLJetMC2;Leading_phi=phiLJetMC2;Leading_eta=etaLJetMC2;sLeading_pt=ptsLJetMC2;sLeading_phi=phisLJetMC2;sLeading_eta=etasLJetMC2;}\r
793                                                                 if(algorithm==2){Leading_pt=ptLJetMC ;Leading_phi=phiLJetMC ;Leading_eta=etaLJetMC ;sLeading_pt=ptsLJetMC ;sLeading_phi=phisLJetMC ;sLeading_eta=etasLJetMC ;}\r
794 \r
795                                                                 ////Di-Jet event trigger +++++++++++++++++++++++++++++++++++++++++++++++\r
796                                                                 double DPhi = DeltaPhi(Leading_phi,sLeading_phi);\r
797                                                                 double DEta = Leading_eta-sLeading_eta;\r
798                                                                 if(algorithm==0){\r
799                                                                                                 fH2JetsJet_dphi->Fill(Leading_pt,DPhi);\r
800                                                                                                 fH2JetsJet_deta->Fill(Leading_pt,DEta);\r
801                                                                 }\r
802                                                                 if(algorithm==1){\r
803                                                                                                 fH2JetsJetMC_dphi->Fill(Leading_pt,DPhi);\r
804                                                                                                 fH2JetsJetMC_deta->Fill(Leading_pt,DEta);\r
805                                                                 }\r
806                                                                 if((TMath::Cos(DPhi)<-0.5)&&(Leading_pt>10.)&&(sLeading_pt>10.)){\r
807                                                                                                 if(algorithm==0)Aj   = (Leading_pt-sLeading_pt)/(Leading_pt+sLeading_pt);\r
808                                                                                                 if(algorithm==1)AjMC = (Leading_pt-sLeading_pt)/(Leading_pt+sLeading_pt);\r
809                                                                                                 if(algorithm==0){\r
810                                                                                                                                 fH1subJet_pt_dijet ->Fill(sLeading_pt);\r
811                                                                                                                                 fH1leadJet_pt_dijet->Fill(Leading_pt);\r
812                                                                                                                                 fH2JetsJet_Aj      ->Fill(Leading_pt,Aj);\r
813                                                                                                                                 fH2JetsJet_pt      ->Fill(Leading_pt,sLeading_pt);\r
814                                                                                                                                 fH2Mult_Aj         ->Fill(Mult,Aj); \r
815                                                                                                                                 fH2Mlead_Aj        ->Fill(Mlead,Aj);\r
816                                                                                                                                 for(int eb=0;eb<5;eb++){\r
817                                                                                                                                                                 if(TMath::Abs(Leading_pt -10.-20.*(eb))<10.){\r
818                                                                                                                                                                                                 fH1Aj[eb]   ->Fill(Aj);\r
819                                                                                                                                                                 }\r
820                                                                                                                                 }\r
821                                                                                                 }\r
822                                                                                                 if(algorithm==1){\r
823                                                                                                                                 fH1leadJetMC_pt_dijet->Fill(Leading_pt);\r
824                                                                                                                                 fH1subJetMC_pt_dijet ->Fill(sLeading_pt);\r
825                                                                                                                                 fH2JetsJetMC_Aj      ->Fill(Leading_pt,AjMC);\r
826                                                                                                                                 fH2JetsJetMC_pt      ->Fill(Leading_pt,sLeading_pt);\r
827                                                                                                                                 findDiJetMC=true;\r
828                                                                                                 }\r
829                                                                                                 findDiJet=true;\r
830 \r
831                                                                 }\r
832                                                                 ////+++++++++++++++++++++++++++++++++++++++++++++++ Di-Jet event trigger \r
833 \r
834                                                                 //if(algorithm==1){//IDEAL Jet-Hadron Correlation\r
835                                                                 //                              if((findDiJet)&&(Leading_pt>10.)&&(sLeading_pt>10.)){\r
836                                                                 //                                                              double eta_cut_Jet=0.5;\r
837                                                                 //                                                              if(TMath::Abs(Leading_eta)<eta_cut_Jet){\r
838                                                                 //                                                                                              for(int eb=0;eb<5;eb++){\r
839                                                                 //                                                                                                                              if(TMath::Abs(Leading_pt -10.-20.*(eb))<10.){   //<------------------------- Change Condition\r
840                                                                 //                                                                                                                                                              fH1ndiJMCIdeal_ediv[eb]->Fill(1);\r
841                                                                 //                                                                                                                                                              if(eb==1){\r
842                                                                 //                                                                                                                                                                                              if((0<Mlead)&&Mlead<7)              {fH1ndiJMCIdeal_2040Mlead[0]->Fill(1);}\r
843                                                                 //                                                                                                                                                                                              else if((7<=Mlead)&&(Mlead<10))     {fH1ndiJMCIdeal_2040Mlead[1]->Fill(1);}\r
844                                                                 //                                                                                                                                                                                              else                                {fH1ndiJMCIdeal_2040Mlead[2]->Fill(1);}\r
845                                                                 //                                                                                                                                                                                              if((0<Aj)&&(Aj<0.19))               {fH1ndiJMCIdeal_2040Aj   [0]->Fill(1);}\r
846                                                                 //                                                                                                                                                                                              else if((0.19<=Aj)&&(Aj<0.38))      {fH1ndiJMCIdeal_2040Aj   [1]->Fill(1);}\r
847                                                                 //                                                                                                                                                                                              else                                {fH1ndiJMCIdeal_2040Aj   [2]->Fill(1);}\r
848                                                                 //                                                                                                                                                              }\r
849                                                                 //                                                                                                                                                              fH1MleadMCIdeal[eb]->Fill(Mlead);\r
850                                                                 //                                                                                                                                                              fH1AjIdeal[eb]   ->Fill(Aj);\r
851                                                                 //                                                                                                                                                              //MC Track\r
852                                                                 //                                                                                                                                                              TClonesArray* mctracks = dynamic_cast <TClonesArray*> (fAODIn->GetList()->FindObject(AliAODMCParticle::StdBranchName()));\r
853                                                                 //                                                                                                                                                              if(!mctracks){\r
854                                                                 //                                                                                                                                                                                              if (fDebug > 1)  Printf("%s:%d could not get AODMCtracks", (char*)__FILE__,__LINE__);\r
855                                                                 //                                                                                                                                                                                              continue;\r
856                                                                 //                                                                                                                                                              }\r
857                                                                 //                                                                                                                                                              Int_t ntmc = mctracks->GetEntriesFast();\r
858                                                                 //                                                                                                                                                              AliAODMCParticle* trackMCAOD;\r
859                                                                 //                                                                                                                                                              int lastprim=0;\r
860                                                                 //                                                                                                                                                              for(int ntrack =0;ntrack<ntmc;ntrack++){\r
861                                                                 //                                                                                                                                                                                              trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
862                                                                 //                                                                                                                                                                                              if((trackMCAOD->IsPhysicalPrimary())==1)lastprim=ntrack;\r
863                                                                 //                                                                                                                                                              }\r
864                                                                 //                                                                                                                                                              for(int ntrack =0;ntrack<ntmc;ntrack++){\r
865                                                                 //                                                                                                                                                                                              trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
866                                                                 //                                                                                                                                                                                              if((trackMCAOD->IsPhysicalPrimary())&&(trackMCAOD->Charge())){// for Physical particles\r
867                                                                 //                                                                                                                                                                                                                              double DelPhi = DeltaPhi(Leading_phi,trackMCAOD->Phi());\r
868                                                                 //                                                                                                                                                                                                                              if(TMath::Abs(trackMCAOD->Era())<0.9){\r
869                                                                 //                                                                                                                                                                                                                                                              for(int teb=0;teb<5;teb++){\r
870                                                                 //                                                                                                                                                                                                                                                                                              if(teb==0){if(!( trackMCAOD->Pt()>0.15))continue;}\r
871                                                                 //                                                                                                                                                                                                                                                                                              if(teb==1){if(!((trackMCAOD->Pt()<1.5)&&(trackMCAOD->Pt()>0.15)))continue;}\r
872                                                                 //                                                                                                                                                                                                                                                                                              if(teb==2){if(!((trackMCAOD->Pt()<3.0)&&(trackMCAOD->Pt()>1.5)))continue;}\r
873                                                                 //                                                                                                                                                                                                                                                                                              if(teb==3){if(!((trackMCAOD->Pt()<4.5)&&(trackMCAOD->Pt()>3.0)))continue;}\r
874                                                                 //                                                                                                                                                                                                                                                                                              if(teb==4){if(!( trackMCAOD->Pt()>4.5))continue;}\r
875                                                                 //                                                                                                                                                                                                                                                                                              fH1JetHadronMCIdeal_dphi_ediv                [eb][teb]->Fill(DelPhi); \r
876                                                                 //                                                                                                                                                                                                                                                                                              fH1JetHadronMCIdeal_dphi_tptweight_ediv      [eb][teb]->Fill(DelPhi,trackMCAOD->Pt());\r
877                                                                 //                                                                                                                                                                                                                                                                                              fH1JetHadronMCIdeal_dphi_tJptweight_ediv     [eb][teb]->Fill(DelPhi,trackMCAOD->Pt()/Leading_pt);\r
878                                                                 //                                                                                                                                                                                                                                                                                              if(eb==1){\r
879                                                                 //                                                                                                                                                                                                                                                                                                                              if((0<Mlead)&&Mlead<7)         {fH1JetHadronMCIdeal_dphi_tptweight2040_Mleaddep[0][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
880                                                                 //                                                                                                                                                                                                                                                                                                                              else if((7<=Mlead)&&(Mlead<10)){fH1JetHadronMCIdeal_dphi_tptweight2040_Mleaddep[1][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
881                                                                 //                                                                                                                                                                                                                                                                                                                              else                           {fH1JetHadronMCIdeal_dphi_tptweight2040_Mleaddep[2][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
882                                                                 //                                                                                                                                                                                                                                                                                                                              if((0<Aj)&&(Aj<0.19))          {fH1JetHadronMCIdeal_dphi_tptweight2040_Ajdep   [0][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
883                                                                 //                                                                                                                                                                                                                                                                                                                              else if((0.19<=Aj)&&(Aj<0.38)) {fH1JetHadronMCIdeal_dphi_tptweight2040_Ajdep   [1][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
884                                                                 //                                                                                                                                                                                                                                                                                                                              else                           {fH1JetHadronMCIdeal_dphi_tptweight2040_Ajdep   [2][teb]->Fill(DelPhi,trackMCAOD->Pt());}\r
885                                                                 //                                                                                                                                                                                                                                                                                              }\r
886                                                                 //                                                                                                                                                                                                                                                              }\r
887                                                                 //                                                                                                                                                                                                                              }\r
888                                                                 //                                                                                                                                                                                              }\r
889                                                                 //                                                                                                                                                              }//Track Loop\r
890                                                                 //                                                                                                                              }\r
891                                                                 //                                                                                              }\r
892                                                                 //                                                              }\r
893                                                                 //                              }\r
894                                                                 //}\r
895 \r
896                                                                 if(algorithm!=0)continue;// for only data & reconstructed Jets\r
897 \r
898                                                                 //count number of tracks@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \r
899                                                                 //Reconstructed Track\r
900                                                                 TClonesArray* tracks = dynamic_cast <TClonesArray*> (fAODIn->GetTracks());\r
901                                                                 if(!tracks){\r
902                                                                                                 if (fDebug > 1)  Printf("%s:%d could not get AODtracks", (char*)__FILE__,__LINE__);\r
903                                                                                                 continue;\r
904                                                                 }\r
905 \r
906                                                                 Bool_t TrackEff[5000];\r
907                                                                 for(int i=0;i<5000;i++){\r
908                                                                                                 TrackEff[i]=false;\r
909                                                                 }\r
910                                                                 Int_t nt = fAODIn->GetNumberOfTracks();\r
911                                                                 AliAODTrack* trackAOD=NULL;\r
912                                                                 for(int ntrack =0;ntrack<nt;ntrack++){\r
913                                                                                                 trackAOD = (AliAODTrack*) (tracks->At(ntrack));\r
914                                                                                                 Bool_t bgoodT=false;\r
915                                                                                                 if(Filtermask!=272){if(trackAOD->TestFilterMask(Filtermask))bgoodT=true;}\r
916                                                                                                 else               {if(trackAOD->IsHybridGlobalConstrainedGlobal())bgoodT=true;} //for hybrid Track cuts\r
917                                                                                                 if(!bgoodT)continue;\r
918                                                                                                 if(TMath::Abs(trackAOD->Eta())<0.9){\r
919                                                                                                                                 Track_n++;\r
920                                                                                                                                 fH1Track_pt ->Fill(trackAOD->Pt()*TrackEScale);\r
921                                                                                                                                 fH1Track_phi->Fill(trackAOD->Phi());\r
922                                                                                                                                 fH1Track_eta->Fill(trackAOD->Eta());\r
923                                                                                                                                 if(IsMC){\r
924                                                                                                                                                                 // track pt resplution-------------------\r
925                                                                                                                                                                 Int_t MCID = TMath::Abs(trackAOD->GetLabel());\r
926                                                                                                                                                                 TClonesArray* mctracks = dynamic_cast <TClonesArray*> (fAODIn->GetList()->FindObject(AliAODMCParticle::StdBranchName()));\r
927                                                                                                                                                                 if(!mctracks){\r
928                                                                                                                                                                                                 if (fDebug > 1)  Printf("%s:%d could not get AODMCtracks", (char*)__FILE__,__LINE__);\r
929                                                                                                                                                                                                 continue;\r
930                                                                                                                                                                 }\r
931                                                                                                                                                                 AliAODMCParticle *trackMCAOD = (AliAODMCParticle*) mctracks->At(MCID);\r
932                                                                                                                                                                 fH2TrackMCptResolution->Fill(trackMCAOD->Pt(),trackAOD->Pt());\r
933                                                                                                                                                                 TrackEff[MCID]=true;\r
934                                                                                                                                                                 // --------------------------------------\r
935                                                                                                                                 }\r
936                                                                                                 }\r
937                                                                 }\r
938                                                                 if(IsMC){// still under construction\r
939                                                                                                 //MC Track\r
940                                                                                                 TClonesArray* mctracks = dynamic_cast <TClonesArray*> (fAODIn->GetList()->FindObject(AliAODMCParticle::StdBranchName()));\r
941                                                                                                 if(!mctracks){\r
942                                                                                                                                 if (fDebug > 1)  Printf("%s:%d could not get AODMCtracks", (char*)__FILE__,__LINE__);\r
943                                                                                                                                 continue;\r
944                                                                                                 }\r
945                                                                                                 Int_t ntmc = mctracks->GetEntriesFast();\r
946                                                                                                 AliAODMCParticle* trackMCAOD;\r
947                                                                                                 int lastprim=0;\r
948                                                                                                 for(int ntrack =0;ntrack<ntmc;ntrack++){\r
949                                                                                                                                 trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
950                                                                                                                                 if((trackMCAOD->IsPhysicalPrimary())==1)lastprim=ntrack;\r
951                                                                                                 }\r
952                                                                                                 for(int ntrack =0;ntrack<ntmc;ntrack++){\r
953                                                                                                                                 trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
954                                                                                                                                 if((trackMCAOD->GetPdgCode()>10)&&((trackMCAOD->GetMother())>1)&&(ntrack>lastprim)&&(trackMCAOD->Charge())){// for Decay particles\r
955                                                                                                                                                                 fH1MCTrack_pt ->Fill(trackMCAOD->Pt());\r
956                                                                                                                                                                 fH1MCTrack_phi->Fill(trackMCAOD->Phi());\r
957                                                                                                                                                                 fH1MCTrack_eta->Fill(trackMCAOD->Eta());\r
958                                                                                                                                                                 if(TrackEff[ntrack])fH2TrackMCptEfficiency->Fill(trackMCAOD->Pt(),1);\r
959                                                                                                                                                                 else                fH2TrackMCptEfficiency->Fill(trackMCAOD->Pt(),0);\r
960                                                                                                                                 }\r
961                                                                                                                                 if((trackMCAOD->IsPhysicalPrimary())&&(trackMCAOD->Charge())){// for Physical particles\r
962                                                                                                                                                                 MCTrack_n++;\r
963                                                                                                                                                                 fH1MCTrack_pt ->Fill(trackMCAOD->Pt());\r
964                                                                                                                                                                 fH1MCTrack_phi->Fill(trackMCAOD->Phi());\r
965                                                                                                                                                                 fH1MCTrack_eta->Fill(trackMCAOD->Eta());\r
966                                                                                                                                                                 fH1MCPrimTrack_pt ->Fill(trackMCAOD->Pt());\r
967                                                                                                                                                                 fH1MCPrimTrack_phi->Fill(trackMCAOD->Phi());\r
968                                                                                                                                                                 fH1MCPrimTrack_eta->Fill(trackMCAOD->Eta());\r
969                                                                                                                                                                 if(TrackEff[ntrack])fH2TrackMCptEfficiency->Fill(trackMCAOD->Pt(),1);\r
970                                                                                                                                                                 else                fH2TrackMCptEfficiency->Fill(trackMCAOD->Pt(),0);\r
971                                                                                                                                 }\r
972                                                                                                 }\r
973                                                                 }//still under construction\r
974                                                                 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  count number of tracks\r
975 \r
976                                                                 //Jet-Hadron Correlation###############################################\r
977                                                                 if((findDiJet)&&(Leading_pt>10.)&&(sLeading_pt>10.)){\r
978                                                                                                 double eta_cut_Jet=0.5;\r
979                                                                                                 if(TMath::Abs(Leading_eta)<eta_cut_Jet){\r
980                                                                                                                                 for(int eb=0;eb<5;eb++){\r
981                                                                                                                                                                 if(TMath::Abs(Leading_pt -10.-20.*(eb))<10.){\r
982                                                                                                                                                                                                 fH1ndiJ_ediv[eb]->Fill(1);\r
983                                                                                                                                                                                                 if(eb==1){\r
984                                                                                                                                                                                                                                 if((0<Mlead)&&Mlead<7)              {fH1ndiJ_2040Mlead[0]->Fill(1);}\r
985                                                                                                                                                                                                                                 else if((7<=Mlead)&&(Mlead<10))     {fH1ndiJ_2040Mlead[1]->Fill(1);}\r
986                                                                                                                                                                                                                                 else                                {fH1ndiJ_2040Mlead[2]->Fill(1);}\r
987                                                                                                                                                                                                                                 if((0<Aj)&&(Aj<0.19))               {fH1ndiJ_2040Aj   [0]->Fill(1);}\r
988                                                                                                                                                                                                                                 else if((0.19<=Aj)&&(Aj<0.38))      {fH1ndiJ_2040Aj   [1]->Fill(1);}\r
989                                                                                                                                                                                                                                 else                                {fH1ndiJ_2040Aj   [2]->Fill(1);}\r
990                                                                                                                                                                                                 }\r
991                                                                                                                                                                                                 fH1Mlead[eb]->Fill(Mlead);\r
992                                                                                                                                                                                                 for(int ntrack =0;ntrack<nt;ntrack++){\r
993                                                                                                                                                                                                                                 trackAOD = (AliAODTrack*) (fAODIn->GetTrack(ntrack));\r
994                                                                                                                                                                                                                                 Bool_t bgoodT=false;\r
995                                                                                                                                                                                                                                 if(Filtermask!=272){if(trackAOD->TestFilterMask(Filtermask))bgoodT=true;}\r
996                                                                                                                                                                                                                                 else{               if(trackAOD->IsHybridGlobalConstrainedGlobal())bgoodT=true;} //for hybrid Track cuts\r
997                                                                                                                                                                                                                                 if(!bgoodT)continue;\r
998                                                                                                                                                                                                                                 Track_pt   [ntrack]      = trackAOD->Pt()*TrackEScale;\r
999                                                                                                                                                                                                                                 Track_phi  [ntrack]      = trackAOD->Phi();\r
1000                                                                                                                                                                                                                                 Track_eta  [ntrack]      = trackAOD->Eta();\r
1001                                                                                                                                                                                                                                 double DelPhi = DeltaPhi(Leading_phi,Track_phi[ntrack]);\r
1002                                                                                                                                                                                                                                 if(TMath::Abs(Track_eta[ntrack])<0.9){\r
1003                                                                                                                                                                                                                                                                 if((TMath::Abs(DelPhi-pi/2.)<pi/8.)||((DelPhi+pi/2.)<pi/8.)||(TMath::Abs(DelPhi-3./2.*pi)<pi/8.))Munder++;\r
1004                                                                                                                                                                                                                                                                 for(int teb=0;teb<5;teb++){\r
1005                                                                                                                                                                                                                                                                                                 if(teb==0){if(!( Track_pt[ntrack]>0.15))continue;}\r
1006                                                                                                                                                                                                                                                                                                 if(teb==1){if(!((Track_pt[ntrack]<1.5)&&(Track_pt[ntrack]>0.15)))continue;}\r
1007                                                                                                                                                                                                                                                                                                 if(teb==2){if(!((Track_pt[ntrack]<3.0)&&(Track_pt[ntrack]>1.5)))continue;}\r
1008                                                                                                                                                                                                                                                                                                 if(teb==3){if(!((Track_pt[ntrack]<4.5)&&(Track_pt[ntrack]>3.0)))continue;}\r
1009                                                                                                                                                                                                                                                                                                 if(teb==4){if(!( Track_pt[ntrack]>4.5))continue;}\r
1010                                                                                                                                                                                                                                                                                                 fH1JetHadron_dphi_ediv                [eb][teb]->Fill(DelPhi); \r
1011                                                                                                                                                                                                                                                                                                 fH1JetHadron_dphi_tptweight_ediv      [eb][teb]->Fill(DelPhi,Track_pt[ntrack]);\r
1012                                                                                                                                                                                                                                                                                                 fH1JetHadron_dphi_tJptweight_ediv     [eb][teb]->Fill(DelPhi,Track_pt[ntrack]/Leading_pt);\r
1013                                                                                                                                                                                                                                                                                                 if(eb==1){\r
1014                                                                                                                                                                                                                                                                                                                                 if((0<Mlead)&&Mlead<7)         {fH1JetHadron_dphi_tptweight2040_Mleaddep[0][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1015                                                                                                                                                                                                                                                                                                                                 else if((7<=Mlead)&&(Mlead<10)){fH1JetHadron_dphi_tptweight2040_Mleaddep[1][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1016                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadron_dphi_tptweight2040_Mleaddep[2][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1017                                                                                                                                                                                                                                                                                                                                 if((0<Aj)&&(Aj<0.19))          {fH1JetHadron_dphi_tptweight2040_Ajdep   [0][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1018                                                                                                                                                                                                                                                                                                                                 else if((0.19<=Aj)&&(Aj<0.38)) {fH1JetHadron_dphi_tptweight2040_Ajdep   [1][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1019                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadron_dphi_tptweight2040_Ajdep   [2][teb]->Fill(DelPhi,Track_pt[ntrack]);}\r
1020                                                                                                                                                                                                                                                                                                 }\r
1021                                                                                                                                                                                                                                                                 }\r
1022                                                                                                                                                                                                                                 }\r
1023                                                                                                                                                                                                 }//Track Loop\r
1024                                                                                                                                                                                                 if(IsMC){// still under construction\r
1025                                                                                                                                                                                                                                 //MC Track\r
1026                                                                                                                                                                                                                                 TClonesArray* mctracks = dynamic_cast <TClonesArray*> (fAODIn->GetList()->FindObject(AliAODMCParticle::StdBranchName()));\r
1027                                                                                                                                                                                                                                 if(!mctracks){\r
1028                                                                                                                                                                                                                                                                 if (fDebug > 1)  Printf("%s:%d could not get AODMCtracks", (char*)__FILE__,__LINE__);\r
1029                                                                                                                                                                                                                                                                 continue;\r
1030                                                                                                                                                                                                                                 }\r
1031                                                                                                                                                                                                                                 Int_t ntmc = mctracks->GetEntriesFast();\r
1032                                                                                                                                                                                                                                 AliAODMCParticle* trackMCAOD;\r
1033                                                                                                                                                                                                                                 int lastprim=0;\r
1034                                                                                                                                                                                                                                 for(int ntrack =0;ntrack<ntmc;ntrack++){\r
1035                                                                                                                                                                                                                                                                 trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
1036                                                                                                                                                                                                                                                                 if((trackMCAOD->IsPhysicalPrimary())==1)lastprim=ntrack;\r
1037                                                                                                                                                                                                                                 }\r
1038                                                                                                                                                                                                                                 for(int ntrack =0;ntrack<ntmc;ntrack++){\r
1039                                                                                                                                                                                                                                                                 trackMCAOD = (AliAODMCParticle*) (mctracks->At(ntrack));\r
1040                                                                                                                                                                                                                                                                 if((trackMCAOD->GetPdgCode()>10)&&((trackMCAOD->GetMother())>1)&&(ntrack>lastprim)&&(trackMCAOD->Charge())){// for Decay particles\r
1041                                                                                                                                                                                                                                                                                                 MCTrack_pt   [ntrack]      = trackMCAOD->Pt();\r
1042                                                                                                                                                                                                                                                                                                 MCTrack_phi  [ntrack]      = trackMCAOD->Phi();\r
1043                                                                                                                                                                                                                                                                                                 MCTrack_eta  [ntrack]      = trackMCAOD->Eta();\r
1044                                                                                                                                                                                                                                                                                                 double DelPhi = DeltaPhi(Leading_phi,MCTrack_phi[ntrack]);\r
1045                                                                                                                                                                                                                                                                                                 if(TMath::Abs(MCTrack_eta[ntrack])<0.9){\r
1046                                                                                                                                                                                                                                                                                                                                 for(int teb=0;teb<5;teb++){\r
1047                                                                                                                                                                                                                                                                                                                                                                 if(teb==0){if(!( MCTrack_pt[ntrack]>0.15))continue;}\r
1048                                                                                                                                                                                                                                                                                                                                                                 if(teb==1){if(!((MCTrack_pt[ntrack]<1.5)&&(MCTrack_pt[ntrack]>0.15)))continue;}\r
1049                                                                                                                                                                                                                                                                                                                                                                 if(teb==2){if(!((MCTrack_pt[ntrack]<3.0)&&(MCTrack_pt[ntrack]>1.5)))continue;}\r
1050                                                                                                                                                                                                                                                                                                                                                                 if(teb==3){if(!((MCTrack_pt[ntrack]<4.5)&&(MCTrack_pt[ntrack]>3.0)))continue;}\r
1051                                                                                                                                                                                                                                                                                                                                                                 if(teb==4){if(!( MCTrack_pt[ntrack]>4.5))continue;}\r
1052                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_ediv                [eb][teb]->Fill(DelPhi); \r
1053                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_tptweight_ediv      [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);\r
1054                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_tJptweight_ediv     [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]/Leading_pt);\r
1055                                                                                                                                                                                                                                                                                                                                                                 if(eb==1){\r
1056                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Mlead)&&Mlead<7)         {fH1JetHadronMC_dphi_tptweight2040_Mleaddep[0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1057                                                                                                                                                                                                                                                                                                                                                                                                 else if((7<=Mlead)&&(Mlead<10)){fH1JetHadronMC_dphi_tptweight2040_Mleaddep[1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1058                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMC_dphi_tptweight2040_Mleaddep[2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1059                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Aj)&&(Aj<0.19))          {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1060                                                                                                                                                                                                                                                                                                                                                                                                 else if((0.19<=Aj)&&(Aj<0.38)) {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1061                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1062                                                                                                                                                                                                                                                                                                                                                                 }\r
1063                                                                                                                                                                                                                                                                                                                                 }\r
1064                                                                                                                                                                                                                                                                                                 }\r
1065                                                                                                                                                                                                                                                                 }\r
1066                                                                                                                                                                                                                                                                 if((trackMCAOD->IsPhysicalPrimary())&&(trackMCAOD->Charge())){// for Physical particles\r
1067                                                                                                                                                                                                                                                                                                 MCTrack_pt   [ntrack]      = trackMCAOD->Pt();\r
1068                                                                                                                                                                                                                                                                                                 MCTrack_phi  [ntrack]      = trackMCAOD->Phi();\r
1069                                                                                                                                                                                                                                                                                                 MCTrack_eta  [ntrack]      = trackMCAOD->Eta();\r
1070                                                                                                                                                                                                                                                                                                 double DelPhi = DeltaPhi(Leading_phi,MCTrack_phi[ntrack]);\r
1071                                                                                                                                                                                                                                                                                                 if(TMath::Abs(MCTrack_eta[ntrack])<0.9){\r
1072                                                                                                                                                                                                                                                                                                                                 for(int teb=0;teb<5;teb++){\r
1073                                                                                                                                                                                                                                                                                                                                                                 if(teb==0){if(!( MCTrack_pt[ntrack]>0.15))continue;}\r
1074                                                                                                                                                                                                                                                                                                                                                                 if(teb==1){if(!((MCTrack_pt[ntrack]<1.5)&&(MCTrack_pt[ntrack]>0.15)))continue;}\r
1075                                                                                                                                                                                                                                                                                                                                                                 if(teb==2){if(!((MCTrack_pt[ntrack]<3.0)&&(MCTrack_pt[ntrack]>1.5)))continue;}\r
1076                                                                                                                                                                                                                                                                                                                                                                 if(teb==3){if(!((MCTrack_pt[ntrack]<4.5)&&(MCTrack_pt[ntrack]>3.0)))continue;}\r
1077                                                                                                                                                                                                                                                                                                                                                                 if(teb==4){if(!( MCTrack_pt[ntrack]>4.5))continue;}\r
1078                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_ediv                [eb][teb]->Fill(DelPhi); \r
1079                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_tptweight_ediv      [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);\r
1080                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMC_dphi_tJptweight_ediv     [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]/Leading_pt);\r
1081                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMCPrim_dphi_ediv                [eb][teb]->Fill(DelPhi); \r
1082                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMCPrim_dphi_tptweight_ediv      [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);\r
1083                                                                                                                                                                                                                                                                                                                                                                 fH1JetHadronMCPrim_dphi_tJptweight_ediv     [eb][teb]->Fill(DelPhi,MCTrack_pt[ntrack]/Leading_pt);\r
1084                                                                                                                                                                                                                                                                                                                                                                 if(eb==1){\r
1085                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Mlead)&&Mlead<7)         {fH1JetHadronMC_dphi_tptweight2040_Mleaddep[0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1086                                                                                                                                                                                                                                                                                                                                                                                                 else if((7<=Mlead)&&(Mlead<10)){fH1JetHadronMC_dphi_tptweight2040_Mleaddep[1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1087                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMC_dphi_tptweight2040_Mleaddep[2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1088                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Aj)&&(Aj<0.19))          {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1089                                                                                                                                                                                                                                                                                                                                                                                                 else if((0.19<=Aj)&&(Aj<0.38)) {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1090                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMC_dphi_tptweight2040_Ajdep   [2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1091 \r
1092                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Mlead)&&Mlead<7)         {fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep[0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1093                                                                                                                                                                                                                                                                                                                                                                                                 else if((7<=Mlead)&&(Mlead<10)){fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep[1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1094                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMCPrim_dphi_tptweight2040_Mleaddep[2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1095                                                                                                                                                                                                                                                                                                                                                                                                 if((0<Aj)&&(Aj<0.19))          {fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep   [0][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1096                                                                                                                                                                                                                                                                                                                                                                                                 else if((0.19<=Aj)&&(Aj<0.38)) {fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep   [1][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1097                                                                                                                                                                                                                                                                                                                                                                                                 else                           {fH1JetHadronMCPrim_dphi_tptweight2040_Ajdep   [2][teb]->Fill(DelPhi,MCTrack_pt[ntrack]);}\r
1098                                                                                                                                                                                                                                                                                                                                                                 }\r
1099                                                                                                                                                                                                                                                                                                                                 }\r
1100                                                                                                                                                                                                                                                                                                 }\r
1101                                                                                                                                                                                                                                                                 }\r
1102                                                                                                                                                                                                                                 }\r
1103                                                                                                                                                                                                 }//still under construction\r
1104                                                                                                                                                                 }\r
1105                                                                                                                                 }// Momentum Loop Jet\r
1106                                                                                                                                 fH2Jet_pt_Munder   ->Fill(Leading_pt,(double)Munder/(1.8*pi/2.)*Jet_area[0][nLJet]);\r
1107                                                                                                                                 fH2Jet_pt_Mlead    ->Fill(Leading_pt,Mlead);\r
1108                                                                                                 }//eta cut\r
1109                                                                 }// Di-Jet\r
1110                                                                 //############################################### Jet-Hadron Correlation\r
1111                                 }// algorithm LOOP\r
1112                                 if(IsMC){\r
1113                                                                 for(int eb=0;eb<5;eb++){\r
1114                                                                                                 double DPhi,DEta;\r
1115                                                                                                 if(TMath::Abs(ptLJetAOD -10.-20.*(eb))<10.){\r
1116                                                                                                                                 DPhi = DeltaPhi(phiLJetMC,phiLJetAOD);\r
1117                                                                                                                                 DEta = etaLJetMC-etaLJetAOD;\r
1118                                                                                                                                 fH1leadJetMC_dphiResolution[eb]->Fill(DPhi);\r
1119                                                                                                                                 if(sqrt(pow(DPhi,2)+pow(DEta,2))<0.4)fH1leadJetMC_Efficiency[eb]->Fill(1);\r
1120                                                                                                                                 else                                 fH1leadJetMC_Efficiency[eb]->Fill(0);\r
1121                                                                                                                                 DPhi = DeltaPhi(phisLJetMC,phisLJetAOD);\r
1122                                                                                                                                 DEta = etasLJetMC-etasLJetAOD;\r
1123                                                                                                                                 fH1subJetMC_dphiResolution[eb]->Fill(DPhi);\r
1124                                                                                                                                 if(sqrt(pow(DPhi,2)+pow(DEta,2))<0.4)fH1subJetMC_Efficiency[eb]->Fill(1);\r
1125                                                                                                                                 else                                 fH1subJetMC_Efficiency[eb]->Fill(0);\r
1126                                                                                                                                 DPhi = DeltaPhi(phiLJetMC2,phiLJetAOD);\r
1127                                                                                                                                 DEta = etaLJetMC2-etaLJetAOD;\r
1128 \r
1129                                                                                                                                 if(sqrt(pow(DPhi,2)+pow(DEta,2))<0.4)fH2leadJetMCptResolution->Fill(ptLJetMC2,ptLJetAOD);\r
1130                                                                                                                                 if(findDiJetMC)fH2AjCorrelation_MCRec   ->Fill(AjMC,Aj);\r
1131                                                                                                                                 if(findDiJetMC)fH2MleadCorrelation_MCRec->Fill(MleadMC,Mlead);\r
1132                                                                                                 }\r
1133                                                                 }\r
1134                                 }\r
1135                                 else{\r
1136                                                                 fH2Mult_Mtrack->Fill(Mult,Track_n); \r
1137                                                                 fH2Mult_Mjet  ->Fill(Mult,Mjet_tot);\r
1138                                                                 fH2Mult_Njet  ->Fill(Mult,Njet_tot);\r
1139                                                                 if(findLJetAOD)fH2Mult_Mlead ->Fill(Mult,Mlead);   \r
1140                                 }\r
1141 \r
1142                                 PostData(1, fHistList);\r
1143                                 return;\r
1144 }      \r
1145 \r
1146 //________________________________________________________________________\r
1147 void AliAnalysisTaskJetHadronCorrelation::Terminate(Option_t *){\r
1148                                 // Terminate analysis\r
1149                                 if (fDebug) printf("AnalysisTaskPt: Terminate() \n");\r
1150 }\r
1151 \r
1152 Double_t AliAnalysisTaskJetHadronCorrelation::DeltaPhi(Double_t phi1,Double_t phi2){\r
1153                                 Float_t pi=TMath::Pi();\r
1154                                 Double_t dphi = phi1-phi2;\r
1155                                 if     (dphi<(-1./2*pi))dphi = dphi +2*pi;\r
1156                                 else if(dphi>( 3./2*pi))dphi = dphi -2*pi;\r
1157                                 return dphi;\r
1158 }\r