PWGJE
[u/mrichter/AliRoot.git] / PWGJE / PWGJE / AliAnalysisTaskPartonDisc.cxx
1 /************************************************************************* 
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * 
3 *                                                                        * 
4 * Author: The ALICE Off-line Project.                                    * 
5 * Contributors are mentioned in the code where appropriate.              * 
6 *                                                                        * 
7 * Permission to use, copy, modify and distribute this software and its   * 
8 * documentation strictly for non-commercial purposes is hereby granted   * 
9 * without fee, provided that the above copyright notice appears in all   * 
10 * copies and that both the copyright notice and this permission notice   * 
11 * appear in the supporting documentation. The authors make no claims     * 
12 * about the suitability of this software for any purpose. It is          * 
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 ////////////////////////////////////////////////////////
17 //                                                    //
18 // Analysis task for parton discrimination studies    //
19 //                                                    // 
20 // Author:                                            //
21 // Hermes Leon Vargas  (hleon@ikf.uni-frankfurt.de)   //
22 //                                                    // 
23 ////////////////////////////////////////////////////////
24
25 #include "TROOT.h"
26 #include "TDirectory.h"
27 #include "TKey.h"
28 #include "TList.h"
29 #include "TSystem.h"
30 #include "TChain.h"
31 #include "TTree.h"
32 #include "TFile.h"
33 #include "TString.h"
34 #include "TH1F.h"
35 #include "TH1I.h"
36 #include "TH2F.h"
37 #include "TH2I.h"
38 #include "TH3F.h"
39 #include "TProfile.h"
40 #include "TCanvas.h"
41 #include "AliAnalysisTask.h"
42 #include "AliAnalysisManager.h"
43 #include "AliAODHandler.h"
44 #include "AliVEvent.h"
45 #include "AliAODEvent.h"
46 #include "AliAODInputHandler.h"
47 #include "AliVParticle.h"
48 #include "AliAODMCParticle.h"
49 #include "AliGenEventHeader.h"
50 #include "AliGenPythiaEventHeader.h"
51 #include "AliGenDPMjetEventHeader.h"
52 #include "AliAODMCHeader.h"
53 #include "AliMCEventHandler.h"
54 #include "AliMCEvent.h"
55 #include <algorithm> 
56 #include "AliLog.h"
57 #include "AliAODVertex.h"
58 #include "AliAODHeader.h"
59 #include "AliESDtrack.h"
60 #include "AliAnalysisHelperJetTasks.h"
61 #include "AliAnalysisTaskPartonDisc.h"
62 #include "AliAODVZERO.h"
63 #include "TRandom3.h"
64 #include "TDatime.h"
65
66 // Analysis task for parton discrimination
67
68 ClassImp(AliAnalysisTaskPartonDisc)
69
70 Double_t *AliAnalysisTaskPartonDisc::fgContainer = 0x0; 
71
72 //________________________________________________________________________
73 AliAnalysisTaskPartonDisc::AliAnalysisTaskPartonDisc() 
74   : AliAnalysisTaskSE(), fAOD(0), fUseAODMC(kFALSE), fPhojetMC(kFALSE), fBranchMC("jetsMC"), fBranchRec("jetsREC"), fBranchSecRec(""), fSqrts(0),  fNtX(0), fJetRadius(0.), fFlavorRadius(0.), fFilterBit(0xFF), fOutputList(0), fJetPt(0), fJetPtSec(0), fJetPtMC(0), fJetEta(0), fJetEtaSec(0), fJetPhi(0), fJetPhiSec(0), fJetEtaMC(0), fJetPhiMC(0), fPtAODMC(0), fPtAOD(0), fEtaAODMC(0), fPhiAODMC(0), fEtaAOD(0), fPhiAOD(0), fFlavor(0), fNJetsMC(0), fNJetsRD(0), fNJetsRDSeco(0), fJetsMultPtMC(0), fJetsMultPtRD(0), fNChTrRD(0), fProfNChTrRD(0), fFracQQ(0), fFracGQ(0), fFracGG(0), fFracOutGoingQQ(0), fFracOutGoingGQ(0), fFracOutGoingGG(0), fh1Xsec(0), fh1Trials(0), fMpdg(0), fProcessJetPt(0), fFlavorLead(0), fProcessLeadJetPt(0), fPDGMothLPart(0), fFlavProc(0), fAvgTrials(1), fUseAODJetInput(kFALSE), fMinTrackPtInNTX(0), fMaxTrackPtInNTX(0), fSCMRD(0), fMinpTVal(0), fZVertex(0), fh1Events(0), fUseOnlyMC(kFALSE), fCheckMCStatus(kTRUE), fEvtCount(0), fNAccJetsMC(0), fNAccJetsRD(0), fNAccJetsRDSeco(0), fEnablePrints(kFALSE), fRecJetPtInclusive(0), fMCJetPtInclusive(0), fRecJetPtLeading(0), fMCJetPtLeading(0), fSecRecJetPtInclusive(0), fSecRecJetPtLeading(0), fHasPerpCone(kTRUE), fEtaPerpCoord(0), fPhiPerpCoord(0), fPtPerpCoord(0), fJetEvent(kFALSE), fPerpCone(0), fNChTrMCPerp(0), fNChTrRecPerp(0), fSCMMCPerp(0), fSCMRecPerp(0), fIsHIevent(kFALSE), fCurrentJetMinPtNT90(0), fBckgSbsJet(0), fCurrentJetMinPtNT90Recalc(0), fNChTrCorrMCQuark(0), fNChTrCorrMCGluon(0), fNChTrCorrMCPerp(0), fIsPossibleToSubstBckg(kTRUE), fNChTrRecECorr(0), fNChTrRecPerpECorr(0), fRefMult(0), fCurrentJetCharge(0), fRefMultWOJet(0), fVZEROMult(0), fMultWOJetVZero(0), fVZero(0), fRefMultFullV0(0), fRefMultV0Corr(0), fFullV0V0Corr(0), fNTXV0MultPt(0), fNTXCBMultPt(0), fMinpTValUE(2.0), fRefMultFullV0UJ(0), fRefMultV0CorrUJ(0), fFullV0V0CorrUJ(0), fMultWOJetVZeroUJ(0), fRefMultWOJetUJ(0), fMaxpTValUE(2.0), fRefAODTrackCount(0), fRefAODTrackCountUJ(0), fTrackCountWOJet(0), fTrackCountWOJetUJ(0), fTrackCountWOJetUJMC(0), fFullV0V0CorrUJMC(0), fMinpTValMC(2.0), fIncExcR(0.0), fForceNotTR(kFALSE), fNotExtDiJEx(kFALSE), fMinTrackPtInNTXRecalc(0), fMaxTrackPtInNTXRecalc(0), fPtDistInJetConeRaw(0), fPtDistInPerpConeRaw(0), fPtInPerpCon(0), fMinTrackPtInNTXR(0), fMaxTrackPtInNTXR(0), fEventCent(0), fJetEtaAll(0), fJetEtaOnlyTPCcut(0), fNChTrRecECorrPPMult(0), fNChTrRecPerpECorrPPMult(0), fForceSkipSJ(kFALSE), fJetPtCentPbPbRaw(0), fJetPtCentPbPbCorr(0), fJetAcceptance(0.5), fIncreasingExcl(kFALSE), fTotTracksCone(0), fTotTracksInCone(0), fTTrackRandomRejection(0), fJTrackRandomRejection(0), fMinPtInGlobMult(0)
75 {
76   // Constructor
77
78   for(Int_t a=0; a<16;a++)
79     {
80       fJetFlags[a]=kTRUE;
81       if(a<12)
82         {
83           fNChTr[a]=0;
84           fHistPtParton[a]=0;
85           fSCM[a]=0;
86           if(a<8)
87             {
88               fNChTrRDMult[a]=0;
89               fNAccJetsRDMult[a]=0;
90               fTotalJetCharge[a]=0;
91               fSCMRDMult[a]=0;
92               fNChTrRDMultMC[a]=0;
93               fSCMRDMultMC[a]=0;
94               fNChTrRDMultSE[a]=0;
95               fNAccJetsRDMultSE[a]=0;
96               fTotalJetChargeSE[a]=0;
97               fSCMRDMultSE[a]=0;
98               fNChTrRDMultOJ[a]=0;
99               fSCMRDMultOJ[a]=0;
100               fNChTrRDMultSEOJ[a]=0;
101               fSCMRDMultSEOJ[a]=0;
102               fNChTrRDMultOJMC[a]=0;
103               fSCMRDMultOJMC[a]=0;
104               fNChTrRDMultSEOJMC[a]=0;
105               fSCMRDMultSEOJMC[a]=0;
106               fNChTrRecPerpMultSEOJ[a]=0;
107               fJEtaMCMultOJ[a]=0;  
108               fJEtaMCMultSEOJ[a]=0;
109               fJEtaRDMultOJ[a]=0;           
110               fJEtaRDMultSEOJ[a]=0;         
111               fJetPtMCMultOJ[a]=0;         
112               fJetPtMCMultSEOJ[a]=0;       
113               fJetPtRDMultOJ[a]=0;        
114               fJetPtRDMultSEOJ[a]=0;       
115               fEntriesQuark[a]=0;          
116               fEntriesGluon[a]=0;          
117             }
118           if(a<6)
119             {
120               fProcessPDG[a]=0;
121               fFragPion[a]=0;
122               fFragKaon[a]=0;
123               fFragProton[a]=0;
124               fFragChargedR4[a]=0;
125               fFragChargedR3[a]=0;
126               fFragChargedR2[a]=0;
127               fHistContainerR4[a]=0;
128               fHistContainerR3[a]=0;
129               fHistContainerR2[a]=0;
130               if(a<3)
131                 {
132                   fJetEtaJetPt[a]=0;
133                   if(a<2)
134                     {
135                       fFragCandidates[a]=0;
136                       fMinTrackPtInNTXh[a]=0;
137                       fMaxTrackPtInNTXh[a]=0; 
138                     }
139                 }
140             }
141         }
142     }
143 }
144 //________________________________________________________________________
145 AliAnalysisTaskPartonDisc::AliAnalysisTaskPartonDisc(const char *name) 
146   : AliAnalysisTaskSE(name), fAOD(0), fUseAODMC(kFALSE), fPhojetMC(kFALSE), fBranchMC("jetsMC"), fBranchRec("jetsREC"), fBranchSecRec(""), fSqrts(0),  fNtX(0), fJetRadius(0.), fFlavorRadius(0.), fFilterBit(0xFF), fOutputList(0), fJetPt(0), fJetPtSec(0), fJetPtMC(0), fJetEta(0), fJetEtaSec(0), fJetPhi(0), fJetPhiSec(0), fJetEtaMC(0), fJetPhiMC(0), fPtAODMC(0), fPtAOD(0), fEtaAODMC(0), fPhiAODMC(0), fEtaAOD(0), fPhiAOD(0), fFlavor(0), fNJetsMC(0), fNJetsRD(0), fNJetsRDSeco(0), fJetsMultPtMC(0), fJetsMultPtRD(0), fNChTrRD(0), fProfNChTrRD(0), fFracQQ(0), fFracGQ(0), fFracGG(0), fFracOutGoingQQ(0), fFracOutGoingGQ(0), fFracOutGoingGG(0), fh1Xsec(0), fh1Trials(0), fMpdg(0), fProcessJetPt(0), fFlavorLead(0), fProcessLeadJetPt(0), fPDGMothLPart(0), fFlavProc(0), fAvgTrials(1), fUseAODJetInput(kFALSE), fMinTrackPtInNTX(0), fMaxTrackPtInNTX(0), fSCMRD(0), fMinpTVal(0), fZVertex(0), fh1Events(0), fUseOnlyMC(kFALSE), fCheckMCStatus(kTRUE), fEvtCount(0), fNAccJetsMC(0), fNAccJetsRD(0), fNAccJetsRDSeco(0), fEnablePrints(kFALSE), fRecJetPtInclusive(0), fMCJetPtInclusive(0), fRecJetPtLeading(0), fMCJetPtLeading(0), fSecRecJetPtInclusive(0), fSecRecJetPtLeading(0), fHasPerpCone(kTRUE), fEtaPerpCoord(0), fPhiPerpCoord(0), fPtPerpCoord(0), fJetEvent(kFALSE), fPerpCone(0), fNChTrMCPerp(0), fNChTrRecPerp(0), fSCMMCPerp(0), fSCMRecPerp(0), fIsHIevent(kFALSE), fCurrentJetMinPtNT90(0), fBckgSbsJet(0), fCurrentJetMinPtNT90Recalc(0), fNChTrCorrMCQuark(0), fNChTrCorrMCGluon(0), fNChTrCorrMCPerp(0), fIsPossibleToSubstBckg(kTRUE), fNChTrRecECorr(0), fNChTrRecPerpECorr(0), fRefMult(0), fCurrentJetCharge(0), fRefMultWOJet(0), fVZEROMult(0), fMultWOJetVZero(0), fVZero(0), fRefMultFullV0(0), fRefMultV0Corr(0), fFullV0V0Corr(0), fNTXV0MultPt(0), fNTXCBMultPt(0), fMinpTValUE(2.0), fRefMultFullV0UJ(0), fRefMultV0CorrUJ(0), fFullV0V0CorrUJ(0), fMultWOJetVZeroUJ(0), fRefMultWOJetUJ(0), fMaxpTValUE(2.0), fRefAODTrackCount(0), fRefAODTrackCountUJ(0), fTrackCountWOJet(0), fTrackCountWOJetUJ(0), fTrackCountWOJetUJMC(0), fFullV0V0CorrUJMC(0), fMinpTValMC(2.0), fIncExcR(0.0), fForceNotTR(kFALSE), fNotExtDiJEx(kFALSE), fMinTrackPtInNTXRecalc(0), fMaxTrackPtInNTXRecalc(0), fPtDistInJetConeRaw(0), fPtDistInPerpConeRaw(0), fPtInPerpCon(0), fMinTrackPtInNTXR(0), fMaxTrackPtInNTXR(0), fEventCent(0), fJetEtaAll(0), fJetEtaOnlyTPCcut(0), fNChTrRecECorrPPMult(0), fNChTrRecPerpECorrPPMult(0), fForceSkipSJ(kFALSE), fJetPtCentPbPbRaw(0), fJetPtCentPbPbCorr(0), fJetAcceptance(0.5), fIncreasingExcl(kFALSE), fTotTracksCone(0), fTotTracksInCone(0), fTTrackRandomRejection(0), fJTrackRandomRejection(0), fMinPtInGlobMult(0)
147 {
148
149   // Constructor
150
151   for(Int_t a=0; a<16;a++)
152     {
153       fJetFlags[a]=kTRUE;
154       if(a<12)
155         {
156           fNChTr[a]=0;
157           fHistPtParton[a]=0;
158           fSCM[a]=0;
159           if(a<8)
160             {
161               fNChTrRDMult[a]=0;
162               fNAccJetsRDMult[a]=0;
163               fTotalJetCharge[a]=0;
164               fSCMRDMult[a]=0;
165               fNChTrRDMultMC[a]=0;
166               fSCMRDMultMC[a]=0;
167               fNChTrRDMultSE[a]=0;
168               fNAccJetsRDMultSE[a]=0;
169               fTotalJetChargeSE[a]=0;
170               fSCMRDMultSE[a]=0;
171               fNChTrRDMultOJ[a]=0;
172               fSCMRDMultOJ[a]=0;
173               fNChTrRDMultSEOJ[a]=0;
174               fSCMRDMultSEOJ[a]=0;
175               fNChTrRDMultOJMC[a]=0;
176               fSCMRDMultOJMC[a]=0;
177               fNChTrRDMultSEOJMC[a]=0;
178               fSCMRDMultSEOJMC[a]=0;
179               fNChTrRecPerpMultSEOJ[a]=0;               
180               fJEtaMCMultOJ[a]=0;  
181               fJEtaMCMultSEOJ[a]=0;
182               fJEtaRDMultOJ[a]=0;           
183               fJEtaRDMultSEOJ[a]=0;         
184               fJetPtMCMultOJ[a]=0;         
185               fJetPtMCMultSEOJ[a]=0;       
186               fJetPtRDMultOJ[a]=0;        
187               fJetPtRDMultSEOJ[a]=0;       
188               fEntriesQuark[a]=0;          
189               fEntriesGluon[a]=0;          
190             }
191           if(a<6)
192             {
193               fProcessPDG[a]=0;
194               fFragPion[a]=0;
195               fFragKaon[a]=0;
196               fFragProton[a]=0;
197               fFragChargedR4[a]=0;
198               fFragChargedR3[a]=0;
199               fFragChargedR2[a]=0;
200               fHistContainerR4[a]=0;
201               fHistContainerR3[a]=0;
202               fHistContainerR2[a]=0;
203               if(a<3)
204                 {
205                   fJetEtaJetPt[a]=0;
206                   if(a<2)
207                     {
208                       fFragCandidates[a]=0;
209                       fMinTrackPtInNTXh[a]=0;
210                       fMaxTrackPtInNTXh[a]=0; 
211                     }
212                 }
213             }
214         }
215     }
216
217   // Define input and output slots here
218   // Input slot #0 works with a TChain
219   DefineInput(0, TChain::Class());
220   // Output slot #0 id reserved by the base class for AOD
221   // Output slot #1 writes into a TH1 container
222   DefineOutput(1, TList::Class());
223 }
224 //________________________________________________________________________
225 Bool_t AliAnalysisTaskPartonDisc::UserNotify()
226 {
227   //
228   // read the cross sections
229   // and number of trials from pyxsec.root
230   // from AliAnalysisTaskJetSpectrum2
231   //
232
233   TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
234   Float_t xsection = 0;
235   Float_t ftrials  = 1;
236   Int_t nevents = 0;
237
238   fAvgTrials = 1;
239   if(tree)
240     {
241       TFile *curfile = tree->GetCurrentFile();
242       if (!curfile) 
243         {
244           Error("Notify","No current file");
245           return kFALSE;
246         }
247       if(!fh1Xsec||!fh1Trials)
248         {
249           Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
250           return kFALSE;
251         }
252       AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
253       fh1Xsec->Fill("<#sigma>",xsection);
254       // construct a poor man average trials (per event!?)
255       Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
256       if(ftrials>=nEntries && nEntries>0.)fAvgTrials = ftrials/nEntries;
257       // number of events read out to create the AOD
258       NumberOfReadEventsAOD(curfile->GetName(),nevents);
259       fh1Events->Fill("#sum{nevents}",nevents); //  filled once per file
260     }  
261   return kTRUE;
262
263 }
264 //________________________________________________________________________
265 void AliAnalysisTaskPartonDisc::UserCreateOutputObjects()
266 {
267   // Create histograms
268   // Called once  
269
270   fOutputList = new TList();
271   fOutputList->SetOwner(kTRUE);
272
273   fJetPt = new TH1F("fJetPt", "p_{T} distribution of reco jets", 60, 0., 300.);
274   fJetPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
275   fJetPt->GetYaxis()->SetTitle("dN/dp_{T} (c/GeV)");
276   fJetPt->Sumw2();
277   fOutputList->Add(fJetPt);
278
279   fJetPtSec = new TH1F("fJetPtSec", "p_{T} distribution of reco jets, seconday rec branch", 60, 0., 300.);
280   fJetPtSec->GetXaxis()->SetTitle("p_{T} (GeV/c)");
281   fJetPtSec->GetYaxis()->SetTitle("dN/dp_{T} (c/GeV)");
282   fJetPtSec->Sumw2();
283   fOutputList->Add(fJetPtSec);
284
285   fJetPtMC = new TH1F("fJetPtMC", "p_{T} distribution of mc jets", 60, 0., 300.);
286   fJetPtMC->GetXaxis()->SetTitle("p_{T} (GeV/c)");
287   fJetPtMC->GetYaxis()->SetTitle("dN/dp_{T} (c/GeV)");
288   fJetPtMC->Sumw2();
289   fOutputList->Add(fJetPtMC);
290
291   fJetEta = new TH2F("fJetEta", "Eta distribution of reconstructed jets", 50, -1.5, 1.5, 50, -1.5, 1.5);
292   fJetEta->GetXaxis()->SetTitle("#eta");
293   fJetEta->GetYaxis()->SetTitle("#eta");
294   fJetEta->Sumw2();
295   fOutputList->Add(fJetEta);
296
297   fJetEtaSec = new TH2F("fJetEtaSec", "Eta distribution of reconstructed jets, secondary branch", 50, -1.5, 1.5, 50, -1.5, 1.5);
298   fJetEtaSec->GetXaxis()->SetTitle("#eta");
299   fJetEtaSec->GetYaxis()->SetTitle("#eta");
300   fJetEtaSec->Sumw2();
301   fOutputList->Add(fJetEtaSec);
302
303   fJetPhi = new TH2F("fJetPhi", "Phi distribution of reconstructed jets", 50, 0., TMath::TwoPi(), 50, 0., TMath::TwoPi());
304   fJetPhi->GetXaxis()->SetTitle("#phi");
305   fJetPhi->GetYaxis()->SetTitle("#phi");
306   fJetPhi->Sumw2();
307   fOutputList->Add(fJetPhi);
308
309   fJetPhiSec = new TH2F("fJetPhiSec", "Phi distribution of reconstructed jets, secondary branch", 50, 0., TMath::TwoPi(), 50, 0., TMath::TwoPi());
310   fJetPhiSec->GetXaxis()->SetTitle("#phi");
311   fJetPhiSec->GetYaxis()->SetTitle("#phi");
312   fJetPhiSec->Sumw2();
313   fOutputList->Add(fJetPhiSec);
314
315   fJetEtaMC = new TH2F("fJetEtaMC", "Eta distribution of MC jets", 50, -1.5, 1.5, 50, -1.5, 1.5);
316   fJetEtaMC->GetXaxis()->SetTitle("#eta");
317   fJetEtaMC->GetYaxis()->SetTitle("#eta");
318   fJetEtaMC->Sumw2();
319   fOutputList->Add(fJetEtaMC);
320
321   fJetPhiMC = new TH2F("fJetPhiMC", "Phi distribution of MC jets", 50, 0., TMath::TwoPi(), 50, 0., TMath::TwoPi());
322   fJetPhiMC->GetXaxis()->SetTitle("#phi");
323   fJetPhiMC->GetYaxis()->SetTitle("#phi");
324   fJetPhiMC->Sumw2();
325   fOutputList->Add(fJetPhiMC);
326
327   fPtAODMC = new TH2F("fPtAODMC", "p_{T} distribution of mc tracks", 200, 0., 100., 200, 0., 100.);
328   fPtAODMC->GetXaxis()->SetTitle("p_{T} (GeV/c)");
329   fPtAODMC->GetYaxis()->SetTitle("p_{T} (GeV/c)");
330   fPtAODMC->Sumw2();
331   fOutputList->Add(fPtAODMC);
332
333   fPtAOD = new TH2F("fPtAOD", "p_{T} distribution of aod tracks", 200, 0., 100., 200, 0., 100.);
334   fPtAOD->GetXaxis()->SetTitle("p_{T} (GeV/c)");
335   fPtAOD->GetYaxis()->SetTitle("p_{T} (GeV/c)");
336   fPtAOD->Sumw2();
337   fOutputList->Add(fPtAOD);
338
339   fEtaAODMC = new TH2F("fEtaAODMC", "Eta distribution of MC aod tracks", 50, -1.5, 1.5, 50, -1.5, 1.5);
340   fEtaAODMC->GetXaxis()->SetTitle("#eta");
341   fEtaAODMC->GetYaxis()->SetTitle("#eta");
342   fEtaAODMC->Sumw2();
343   fOutputList->Add(fEtaAODMC);
344
345   fPhiAODMC = new TH2F("fPhiAODMC", "Phi distribution of MC aod tracks", 50, 0., TMath::TwoPi(), 50, 0., TMath::TwoPi());
346   fPhiAODMC->GetXaxis()->SetTitle("#phi");
347   fPhiAODMC->GetYaxis()->SetTitle("#phi");
348   fPhiAODMC->Sumw2();
349   fOutputList->Add(fPhiAODMC);
350
351   fEtaAOD = new TH2F("fEtaAOD", "Eta distribution of aod tracks", 50, -1.5, 1.5, 50, -1.5, 1.5);
352   fEtaAOD->GetXaxis()->SetTitle("#eta");
353   fEtaAOD->GetYaxis()->SetTitle("#eta");
354   fEtaAOD->Sumw2();
355   fOutputList->Add(fEtaAOD);
356
357   fPhiAOD = new TH2F("fPhiAOD", "Phi distribution of aod tracks", 50, 0.,TMath::TwoPi(), 50, 0.,TMath::TwoPi());
358   fPhiAOD->GetXaxis()->SetTitle("#phi");
359   fPhiAOD->GetYaxis()->SetTitle("#phi");
360   fPhiAOD->Sumw2();
361   fOutputList->Add(fPhiAOD);
362
363   fFlavor = new TH2F("fFlavor", "Flavor distribution of jets", 27, -5.5, 21.5, 60, 0., 300.);
364   fFlavor->GetXaxis()->SetTitle("PDG code");
365   fFlavor->GetYaxis()->SetTitle("p_{T}^{JET}");
366   fFlavor->Sumw2();
367   fOutputList->Add(fFlavor);
368
369   fNJetsMC = new TH2F("fNJetsMC", "Number of simulated jets per event, as a function of p_T", 101, -0.5, 100.5, 101, -0.5, 100.5);
370   fNJetsMC->GetXaxis()->SetTitle("Number of jets");
371   fNJetsMC->GetYaxis()->SetTitle("Number of jets");
372   fNJetsMC->Sumw2();
373   fOutputList->Add(fNJetsMC);
374
375   fNJetsRD = new TH2F("fNJetsRD", "Number of jets per event in real data", 101, -0.5, 100.5, 101, -0.5, 100.5);
376   fNJetsRD->GetXaxis()->SetTitle("Number of jets");
377   fNJetsRD->GetYaxis()->SetTitle("Number of jets");
378   fNJetsRD->Sumw2();
379   fOutputList->Add(fNJetsRD);
380
381   fNJetsRDSeco = new TH2F("fNJetsRDSeco", "Number of jets per event in real data, secondary branch", 101, -0.5, 100.5, 101, -0.5, 100.5);
382   fNJetsRDSeco->GetXaxis()->SetTitle("Number of jets");
383   fNJetsRDSeco->GetYaxis()->SetTitle("Number of jets");
384   fNJetsRDSeco->Sumw2();
385   fOutputList->Add(fNJetsRDSeco);
386
387   fJetsMultPtMC = new TH2F("fJetsMultPtMC", "Jet multiplicity associated to jet pT, as a function of p_T MC", 60, 0., 300., 7, -0.5, 6.5);
388   fJetsMultPtMC->GetXaxis()->SetTitle("p_{T}^{JET}");
389   fJetsMultPtMC->GetYaxis()->SetTitle("Number of jets");
390   fJetsMultPtMC->Sumw2();
391   fOutputList->Add(fJetsMultPtMC);
392
393   fJetsMultPtRD = new TH2F("fJetsMultPtRD", "Jet multiplicity associated to jet pT, as a function of p_T Reco Data",60, 0., 300., 7, -0.5, 6.5);
394   fJetsMultPtRD->GetXaxis()->SetTitle("p_{T}^{JET}");
395   fJetsMultPtRD->GetYaxis()->SetTitle("Number of jets");
396   fJetsMultPtRD->Sumw2();
397   fOutputList->Add(fJetsMultPtRD);
398
399   fNChTrRD = new TH2F("fNChTrRD","Number of tracks to recover transverse energy, jet_{p_{T}}",101,-0.5,100.5, 60, 0., 300.);
400   fNChTrRD->GetXaxis()->SetTitle("NTracks");
401   fNChTrRD->GetYaxis()->SetTitle("p_{T}^{JET}");
402   fNChTrRD->Sumw2();
403   fOutputList->Add(fNChTrRD);
404
405   fProfNChTrRD = new TProfile("fProfNChTrRD","Number of tracks to recover transverse energy, jet_{p_{T}}", 50, 0, 250);
406   fProfNChTrRD->GetXaxis()->SetTitle("p_{T}^{JET}");
407   fProfNChTrRD->GetYaxis()->SetTitle("NTracks");
408   fProfNChTrRD->Sumw2();
409   fOutputList->Add(fProfNChTrRD);
410
411   fFracQQ = new TH1F("fFracQQ","QQ",1000,0.,0.5);
412   fFracQQ->GetXaxis()->SetTitle("x_{T}");
413   fFracQQ->GetYaxis()->SetTitle("Entries");
414   fFracQQ->Sumw2();
415   fOutputList->Add(fFracQQ);
416
417   fFracGQ = new TH1F("fFracGQ","GQ",1000,0.,0.5);
418   fFracGQ->GetXaxis()->SetTitle("x_{T}");
419   fFracGQ->GetYaxis()->SetTitle("Entries");
420   fFracGQ->Sumw2();
421   fOutputList->Add(fFracGQ);
422
423   fFracGG = new TH1F("fFracGG","GG",1000,0.,0.5);
424   fFracGG->GetXaxis()->SetTitle("x_{T}");
425   fFracGG->GetYaxis()->SetTitle("Entries");
426   fFracGG->Sumw2();
427   fOutputList->Add(fFracGG);
428
429   fFracOutGoingQQ = new TH1F("fFracOutGoingQQ","QQ",1000,0.,0.5);
430   fFracOutGoingQQ->GetXaxis()->SetTitle("x_{T}");
431   fFracOutGoingQQ->GetYaxis()->SetTitle("Entries");
432   fFracOutGoingQQ->Sumw2();
433   fOutputList->Add(fFracOutGoingQQ);
434
435   fFracOutGoingGQ = new TH1F("fFracOutGoingGQ","GQ",1000,0.,0.5);
436   fFracOutGoingGQ->GetXaxis()->SetTitle("x_{T}");
437   fFracOutGoingGQ->GetYaxis()->SetTitle("Entries");
438   fFracOutGoingGQ->Sumw2();
439   fOutputList->Add(fFracOutGoingGQ);
440
441   fFracOutGoingGG = new TH1F("fFracOutGoingGG","GG",1000,0.,0.5);
442   fFracOutGoingGG->GetXaxis()->SetTitle("x_{T}");
443   fFracOutGoingGG->GetYaxis()->SetTitle("Entries");
444   fFracOutGoingGG->Sumw2();
445   fOutputList->Add(fFracOutGoingGG);
446
447   fh1Xsec =  new TProfile("h1Xsec","xsec from pyxsec.root",1,0,1);
448   fh1Xsec->SetXTitle("<#sigma>");
449   fh1Xsec->Sumw2();
450   fOutputList->Add(fh1Xsec);  
451
452   fh1Trials = new TH1F("h1Trials","trials from pyxsec.root",1,0,1);
453   fh1Trials->SetXTitle("#sum{ntrials}");
454   fh1Trials->Sumw2();
455   fOutputList->Add(fh1Trials);
456            
457   fProcessJetPt = new TH2F("fProcessJetPt","Pythia process number, jet_{p_{T}}",70, 0.5, 70.5, 60, 0., 300.);
458   fProcessJetPt->GetXaxis()->SetTitle("Pythia process");
459   fProcessJetPt->GetYaxis()->SetTitle("p_{T}^{JET}");
460   fProcessJetPt->Sumw2();
461   fOutputList->Add(fProcessJetPt);
462
463   fFlavorLead = new TH2F("fFlavorLead", "Flavor distribution of leading jets", 27, -5.5, 21.5, 60, 0., 300.);
464   fFlavorLead->GetXaxis()->SetTitle("PDG code");
465   fFlavorLead->GetYaxis()->SetTitle("p_{T}^{JET}");
466   fFlavorLead->Sumw2();
467   fOutputList->Add(fFlavorLead);
468
469   fProcessLeadJetPt = new TH2F("fProcessLeadJetPt","Pythia process number for leading, jet_{p_{T}}",70, 0.5, 70.5, 60, 0., 300.);
470   fProcessLeadJetPt->GetXaxis()->SetTitle("Pythia process");
471   fProcessLeadJetPt->GetYaxis()->SetTitle("p_{T}^{JET}");
472   fProcessLeadJetPt->Sumw2();
473   fOutputList->Add(fProcessLeadJetPt);
474  
475   fPDGMothLPart = new TH3F("fPDGMothLPart","Mother of leading parton, leading parton, jet p_{T}", 27, -5.5, 21.5, 27, -5.5, 21.5, 60, 0., 300.);
476   fPDGMothLPart->GetXaxis()->SetTitle("Mother of leading parton");
477   fPDGMothLPart->GetYaxis()->SetTitle("Leading parton");
478   fPDGMothLPart->GetZaxis()->SetTitle("p_{T}^{JET}");
479   fPDGMothLPart->Sumw2();
480   fOutputList->Add(fPDGMothLPart);
481   
482   fFlavProc = new TH2F("fFlavProc","Flavor, Flavor status code", 27, -5.5, 21.5, 101, -0.5, 100.5);
483   fFlavProc->GetXaxis()->SetTitle("Jet flavor");
484   fFlavProc->GetYaxis()->SetTitle("Parton status code");
485   fFlavProc->Sumw2();
486   fOutputList->Add(fFlavProc);
487
488   fSCMRD = new TH2F("fSCMRD","Second Central Moment, jet_{p_{T}}",200,0.,0.2, 60, 0., 300.);
489   fSCMRD->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
490   fSCMRD->GetYaxis()->SetTitle("p_{T}^{JET}");
491   fSCMRD->Sumw2();
492   fOutputList->Add(fSCMRD);
493  
494   fZVertex = new TH2F("fZVertex","Z vertex position, Z vertex position}",40,-20.,20., 40, -20., 20.);
495   fZVertex->GetXaxis()->SetTitle("Vertex z");
496   fZVertex->GetYaxis()->SetTitle("Vertex z");
497   fZVertex->Sumw2();
498   fOutputList->Add(fZVertex);
499
500   fh1Events = new TH1F("fh1Events","nevents from PWG4_JetTasksOutput.root",1,0,1);
501   fh1Events->SetXTitle("#sum{nevents}");
502   fh1Events->Sumw2();
503   fOutputList->Add(fh1Events);
504
505   fNAccJetsMC = new TH2F("fNAccJetsMC", "Number accepted simulated jets per event", 101, -0.5, 100.5, 101, -0.5, 100.5);
506   fNAccJetsMC->GetXaxis()->SetTitle("Number of jets");
507   fNAccJetsMC->GetYaxis()->SetTitle("Number of jets");
508   fNAccJetsMC->Sumw2();
509   fOutputList->Add(fNAccJetsMC);
510
511   fNAccJetsRD = new TH2F("fNAccJetsRD", "Number of accepted jets per event in real data", 101, -0.5, 100.5, 101, -0.5, 100.5);
512   fNAccJetsRD->GetXaxis()->SetTitle("Number of jets");
513   fNAccJetsRD->GetYaxis()->SetTitle("Number of jets");
514   fNAccJetsRD->Sumw2();
515   fOutputList->Add(fNAccJetsRD);
516
517   fNAccJetsRDSeco = new TH2F("fNAccJetsRDSeco", "Number of accepted jets per event in real data, secondary branch", 101, -0.5, 100.5, 101, -0.5, 100.5);
518   fNAccJetsRDSeco->GetXaxis()->SetTitle("Number of jets");
519   fNAccJetsRDSeco->GetYaxis()->SetTitle("Number of jets");
520   fNAccJetsRDSeco->Sumw2();
521   fOutputList->Add(fNAccJetsRDSeco);
522
523   fRecJetPtInclusive = new TH1F("fRecJetPtInclusive", "p_{T} distribution of inclusive reco jets", 60, 0., 300.);
524   fRecJetPtInclusive->GetXaxis()->SetTitle("p_{T} (GeV/c)");
525   fRecJetPtInclusive->GetYaxis()->SetTitle("d#sigma (mb)");
526   fRecJetPtInclusive->Sumw2();
527   fOutputList->Add(fRecJetPtInclusive);
528
529   fMCJetPtInclusive = new TH1F("fMCJetPtInclusive", "p_{T} distribution of inclusive MC jets", 60, 0., 300.);
530   fMCJetPtInclusive->GetXaxis()->SetTitle("p_{T} (GeV/c)");
531   fMCJetPtInclusive->GetYaxis()->SetTitle("d#sigma (mb)");
532   fMCJetPtInclusive->Sumw2();
533   fOutputList->Add(fMCJetPtInclusive);
534
535   fRecJetPtLeading = new TH1F("fRecJetPtLeading", "p_{T} distribution of leading reco jets", 60, 0., 300.);
536   fRecJetPtLeading->GetXaxis()->SetTitle("p_{T} (GeV/c)");
537   fRecJetPtLeading->GetYaxis()->SetTitle("d#sigma (mb)");
538   fRecJetPtLeading->Sumw2();
539   fOutputList->Add(fRecJetPtLeading);
540
541   fMCJetPtLeading = new TH1F("fMCJetPtLeading", "p_{T} distribution of leading MC jets", 60, 0., 300.);
542   fMCJetPtLeading->GetXaxis()->SetTitle("p_{T} (GeV/c)");
543   fMCJetPtLeading->GetYaxis()->SetTitle("d#sigma (mb)");
544   fMCJetPtLeading->Sumw2();
545   fOutputList->Add(fMCJetPtLeading);
546
547   fSecRecJetPtInclusive = new TH1F("fSecRecJetPtInclusive", "p_{T} distribution of inclusive reco jets (2nd branch)", 60, 0., 300.);
548   fSecRecJetPtInclusive->GetXaxis()->SetTitle("p_{T} (GeV/c)");
549   fSecRecJetPtInclusive->GetYaxis()->SetTitle("d#sigma (mb)");
550   fSecRecJetPtInclusive->Sumw2();
551   fOutputList->Add(fSecRecJetPtInclusive);
552
553   fSecRecJetPtLeading = new TH1F("fSecRecJetPtLeading", "p_{T} distribution of leading reco jets (2nd branch)", 60, 0., 300.);
554   fSecRecJetPtLeading->GetXaxis()->SetTitle("p_{T} (GeV/c)");
555   fSecRecJetPtLeading->GetYaxis()->SetTitle("d#sigma (mb)");
556   fSecRecJetPtLeading->Sumw2();
557   fOutputList->Add(fSecRecJetPtLeading);
558
559   fNChTrMCPerp = new TH2F("fNChTrMCPerp","Number of tracks to recover transverse energy of perp. cone, jet_{p_{T} MC}",101,-0.5,100.5, 60, 0., 300.);
560   fNChTrMCPerp->GetXaxis()->SetTitle("NTracks Perp");
561   fNChTrMCPerp->GetYaxis()->SetTitle("p_{T}^{MC JET}");
562   fNChTrMCPerp->Sumw2();
563   fOutputList->Add(fNChTrMCPerp);
564
565   fNChTrRecPerp = new TH2F("fNChTrRecPerp","Number of tracks to recover transverse energy of perp. cone, jet_{p_{T} Rec}",101,-0.5,100.5, 60, 0., 300.);
566   fNChTrRecPerp->GetXaxis()->SetTitle("NTracks Perp");
567   fNChTrRecPerp->GetYaxis()->SetTitle("p_{T}^{RECO JET}");
568   fNChTrRecPerp->Sumw2();
569   fOutputList->Add(fNChTrRecPerp);
570
571   fSCMMCPerp = new TH2F("fSCMMCPerp","Second Central Moment of perp. cone, jet_{p_{T} MC}",200,0.,0.2, 60, 0., 300.);
572   fSCMMCPerp->GetXaxis()->SetTitle("<#delta R_{c}^{2}> Perp");
573   fSCMMCPerp->GetYaxis()->SetTitle("p_{T}^{JET}");
574   fSCMMCPerp->Sumw2();
575   fOutputList->Add(fSCMMCPerp);
576
577   fSCMRecPerp = new TH2F("fSCMRecPerp","Second Central Moment of perp. cone, jet_{p_{T} Reco}",200,0.,0.2, 60, 0., 300.);
578   fSCMRecPerp->GetXaxis()->SetTitle("<#delta R_{c}^{2}> Perp");
579   fSCMRecPerp->GetYaxis()->SetTitle("p_{T}^{JET}");
580   fSCMRecPerp->Sumw2();
581   fOutputList->Add(fSCMRecPerp);
582
583   fNChTrCorrMCQuark = new TH2F("fNChTrCorrMCQuark","Number of tracks to recover corrected transverse energy, MC quarks",101,-0.5,100.5, 60, 0., 300.);
584   fNChTrCorrMCQuark->GetXaxis()->SetTitle("NTracks");
585   fNChTrCorrMCQuark->GetYaxis()->SetTitle("p_{T}^{MC Corr. JET}");
586   fNChTrCorrMCQuark->Sumw2();
587   fOutputList->Add(fNChTrCorrMCQuark);
588
589   fNChTrCorrMCGluon = new TH2F("fNChTrCorrMCGluon","Number of tracks to recover corrected transverse energy, MC gluons",101,-0.5,100.5, 60, 0., 300.);
590   fNChTrCorrMCGluon->GetXaxis()->SetTitle("NTracks");
591   fNChTrCorrMCGluon->GetYaxis()->SetTitle("p_{T}^{MC Corr. JET}");
592   fNChTrCorrMCGluon->Sumw2();
593   fOutputList->Add(fNChTrCorrMCGluon);
594
595   fNChTrCorrMCPerp = new TH2F("fNChTrCorrMCPerp","Number of tracks to recover perp. cone. after corrected jet pT",101,-0.5,100.5, 60, 0., 300.);
596   fNChTrCorrMCPerp->GetXaxis()->SetTitle("NTracks");
597   fNChTrCorrMCPerp->GetYaxis()->SetTitle("p_{T}^{MC Corr. JET}");
598   fNChTrCorrMCPerp->Sumw2();
599   fOutputList->Add(fNChTrCorrMCPerp);
600
601   // 9 selection bins: (nuevo)
602   // 1st. Proton collisions                  fill 1  Bin1 [0.5,1.5)
603   // 2nd. PbPb collisions, Bin  0-10         fill 2  Bin2 [1.5,2.5)
604   // 3rd. PbPb collisions, Bin 10-20         fill 3  Bin3 [2.5,3.5)
605   // 4rd. PbPb collisions, Bin 20-30         fill 4  Bin4 [3.5,4.5)
606   // 5th. PbPb collisions, Bin 30-40         fill 5  Bin5 [4.5,5.5)
607   // 6th. PbPb collisions, Bin 40-50         fill 6  Bin6 [5.5,6.5)
608   // 7th. PbPb collisions, Bin 50-60         fill 7  Bin7 [6.5,7.5)
609   // 8th. PbPb collisions, Bin 60-70         fill 8  Bin8 [7.5,8.5)
610   // 9th. PbPb collisions, Bin 70-80         fill 9  Bin9 [8.5,9.5)
611   // 10th. PbPb collisions, Bin 80-100.1    fill 10  Bin10 [9.5,10.5)
612
613   fNChTrRecECorr = new TH3F("fNChTrRecECorr","NTX in ener. corr. jet , corr. jet pT, centrality",101,-0.5,100.5, 60, 0., 300.,10,0.5,10.5);
614   fNChTrRecECorr->GetXaxis()->SetTitle("NTracks");
615   fNChTrRecECorr->GetYaxis()->SetTitle("p_{T}^{JET}");
616   fNChTrRecECorr->GetZaxis()->SetTitle("Selection Bin");
617   fNChTrRecECorr->Sumw2();
618   fOutputList->Add(fNChTrRecECorr);
619
620   fNChTrRecPerpECorr = new TH3F("fNChTrRecPerpECorr","Tracks above min in perp.cone , corr. jet pT, centrality",101,-0.5,100.5, 60, 0., 300.,10,0.5,10.5);
621   fNChTrRecPerpECorr->GetXaxis()->SetTitle("NTracks");
622   fNChTrRecPerpECorr->GetYaxis()->SetTitle("p_{T}^{JET}");
623   fNChTrRecPerpECorr->GetZaxis()->SetTitle("Selection Bin");
624   fNChTrRecPerpECorr->Sumw2();
625   fOutputList->Add(fNChTrRecPerpECorr);
626   
627   fRefMult = new TH1F("fRefMult", "Reference multiplicity in the AOD", 301, -0.5, 300.5);
628   fRefMult->GetXaxis()->SetTitle("Reference multiplicity");
629   fRefMult->Sumw2();
630   fOutputList->Add(fRefMult);
631
632   fRefMultWOJet = new TH2F("fRefMultWOJet", "Reference multiplicity in the AOD, multiplicity without jets", 301, -0.5, 300.5, 301, -0.5, 300.5);
633   fRefMultWOJet->GetXaxis()->SetTitle("Reference multiplicity");
634   fRefMultWOJet->GetYaxis()->SetTitle("Multiplicity without jets");
635   fRefMultWOJet->Sumw2();
636   fOutputList->Add(fRefMultWOJet);
637
638   fVZEROMult = new TH2F("fVZEROMult", "Multiplicity V0A and V0C", 501, -0.5, 500.5, 501, -0.5, 500.5);
639   fVZEROMult->GetXaxis()->SetTitle("Multiplicity V0A");
640   fVZEROMult->GetYaxis()->SetTitle("Multiplicity V0C");
641   fVZEROMult->Sumw2();
642   fOutputList->Add(fVZEROMult);
643
644   fMultWOJetVZero = new TH2F("fMultWOJetVZero", "Multiplicity without jets and VZERO mult.",301, -0.5, 300.5, 1001, -0.5, 1000.5);
645   fMultWOJetVZero->GetXaxis()->SetTitle("Multiplicity without jets TPC");
646   fMultWOJetVZero->GetYaxis()->SetTitle("Multiplicity full V0");
647   fMultWOJetVZero->Sumw2();
648   fOutputList->Add(fMultWOJetVZero);
649
650   fRefMultFullV0 = new TH2F("fRefMultFullV0", "Reference multiplicity in the AOD, multiplicity from full V0",301, -0.5, 300.5, 1001, -0.5, 1000.5);
651   fRefMultFullV0->GetXaxis()->SetTitle("Reference multiplicity in AOD");
652   fRefMultFullV0->GetYaxis()->SetTitle("Multiplicity full V0");
653   fRefMultFullV0->Sumw2();
654   fOutputList->Add(fRefMultFullV0);
655
656   fRefMultV0Corr = new TH2F("fRefMultV0Corr", "Reference multiplicity in the AOD, multiplicity from corrected V0",301, -0.5, 300.5, 1001, -0.5, 1000.5);
657   fRefMultV0Corr->GetXaxis()->SetTitle("Reference multiplicity in AOD");
658   fRefMultV0Corr->GetYaxis()->SetTitle("Multiplicity V0 no jets");
659   fRefMultV0Corr->Sumw2();
660   fOutputList->Add(fRefMultV0Corr);
661
662   fFullV0V0Corr = new TH2F("fFullV0V0Corr", "Multiplicity from full V0, multiplicity from corrected V0",1001, -0.5, 1000.5, 1001, -0.5, 1000.5);
663   fFullV0V0Corr->GetXaxis()->SetTitle("Multiplicity from full V0");
664   fFullV0V0Corr->GetYaxis()->SetTitle("Multiplicity V0 no jets");
665   fFullV0V0Corr->Sumw2();
666   fOutputList->Add(fFullV0V0Corr);
667
668   fNTXV0MultPt = new TH3F("fNTXV0MultPt", "NTX, Multiplicity from corrected V0, jet pT",101,-0.5,100.5, 1001, -0.5, 1000.5, 60, 0., 300.);
669   fNTXV0MultPt->GetXaxis()->SetTitle("NTracks");
670   fNTXV0MultPt->GetYaxis()->SetTitle("Multiplicity V0 no jets");
671   fNTXV0MultPt->GetZaxis()->SetTitle("p_{T}^{JET}");
672   fNTXV0MultPt->Sumw2();
673   fOutputList->Add(fNTXV0MultPt);
674
675   fNTXCBMultPt = new TH3F("fNTXCBMultPt", "NTX, Multiplicity from corrected Central Barrel, jet pT",101,-0.5,100.5, 301, -0.5, 300.5, 60, 0., 300.);
676   fNTXCBMultPt->GetXaxis()->SetTitle("NTracks");
677   fNTXCBMultPt->GetYaxis()->SetTitle("Multiplicity corrected Central Barrel");
678   fNTXCBMultPt->GetZaxis()->SetTitle("p_{T}^{JET}");
679   fNTXCBMultPt->Sumw2();
680   fOutputList->Add(fNTXCBMultPt);
681
682   fRefMultFullV0UJ = new TH2F("fRefMultFullV0UJ", "Reference multiplicity in the AOD, multiplicity from full V0, 1 jet event",301, -0.5, 300.5, 1001, -0.5, 1000.5);
683   fRefMultFullV0UJ->GetXaxis()->SetTitle("Reference multiplicity in AOD");
684   fRefMultFullV0UJ->GetYaxis()->SetTitle("Multiplicity full V0");
685   fRefMultFullV0UJ->Sumw2();
686   fOutputList->Add(fRefMultFullV0UJ);
687
688   fRefMultV0CorrUJ = new TH2F("fRefMultV0CorrUJ", "Reference multiplicity in the AOD, multiplicity from corrected V0, 1 jet event",301, -0.5, 300.5, 1001, -0.5, 1000.5);
689   fRefMultV0CorrUJ->GetXaxis()->SetTitle("Reference multiplicity in AOD");
690   fRefMultV0CorrUJ->GetYaxis()->SetTitle("Multiplicity V0 no jets");
691   fRefMultV0CorrUJ->Sumw2();
692   fOutputList->Add(fRefMultV0CorrUJ);
693
694   fFullV0V0CorrUJ = new TH2F("fFullV0V0CorrUJ", "Multiplicity from full V0, multiplicity from corrected V0, 1 jet event",1001, -0.5, 1000.5, 1001, -0.5, 1000.5);
695   fFullV0V0CorrUJ->GetXaxis()->SetTitle("Multiplicity from full V0");
696   fFullV0V0CorrUJ->GetYaxis()->SetTitle("Multiplicity V0 no jets");
697   fFullV0V0CorrUJ->Sumw2();
698   fOutputList->Add(fFullV0V0CorrUJ);
699
700   fMultWOJetVZeroUJ = new TH2F("fMultWOJetVZeroUJ", "Multiplicity without jets and VZERO mult., 1 jet event",301, -0.5, 300.5, 1001, -0.5, 1000.5);
701   fMultWOJetVZeroUJ->GetXaxis()->SetTitle("Multiplicity without jets TPC");
702   fMultWOJetVZeroUJ->GetYaxis()->SetTitle("Multiplicity full V0");
703   fMultWOJetVZeroUJ->Sumw2();
704   fOutputList->Add(fMultWOJetVZeroUJ);
705
706   fRefMultWOJetUJ = new TH2F("fRefMultWOJetUJ", "Reference multiplicity in the AOD, multiplicity without jets, 1 jet event", 301, -0.5, 300.5, 301, -0.5, 300.5);
707   fRefMultWOJetUJ->GetXaxis()->SetTitle("Reference multiplicity");
708   fRefMultWOJetUJ->GetYaxis()->SetTitle("Multiplicity without jets");
709   fRefMultWOJetUJ->Sumw2();
710   fOutputList->Add(fRefMultWOJetUJ);
711
712   fRefAODTrackCount = new TH2F("fRefAODTrackCount", "Reference multiplicity in the AOD, my own referece mult.", 301, -0.5, 300.5, 301, -0.5, 300.5);
713   fRefAODTrackCount->GetXaxis()->SetTitle("AOD Reference multiplicity");
714   fRefAODTrackCount->GetYaxis()->SetTitle("My Reference multiplicity");
715   fRefAODTrackCount->Sumw2();
716   fOutputList->Add(fRefAODTrackCount);
717
718   fRefAODTrackCountUJ = new TH2F("fRefAODTrackCountUJ", "Reference multiplicity in the AOD, my own referece mult., 1 jet event", 301, -0.5, 300.5, 301, -0.5, 300.5);
719   fRefAODTrackCountUJ->GetXaxis()->SetTitle("AOD Reference multiplicity");
720   fRefAODTrackCountUJ->GetYaxis()->SetTitle("My Reference multiplicity");
721   fRefAODTrackCountUJ->Sumw2();
722   fOutputList->Add(fRefAODTrackCountUJ);
723
724   fTrackCountWOJet = new TH2F("fTrackCountWOJet", "My own total referece mult., soft mult", 151, -0.5, 150.5, 151, -0.5, 150.5);
725   fTrackCountWOJet->GetXaxis()->SetTitle("Total TPC multiplicity");
726   fTrackCountWOJet->GetYaxis()->SetTitle("Soft TPC multiplicity");
727   fTrackCountWOJet->Sumw2();
728   fOutputList->Add(fTrackCountWOJet);
729
730   fTrackCountWOJetUJ = new TH2F("fTrackCountWOJetUJ", "My own total referece mult., soft mult, 1 jet", 151, -0.5, 150.5, 151, -0.5, 150.5);
731   fTrackCountWOJetUJ->GetXaxis()->SetTitle("Total TPC multiplicity");
732   fTrackCountWOJetUJ->GetYaxis()->SetTitle("Soft TPC multiplicity");
733   fTrackCountWOJetUJ->Sumw2();
734   fOutputList->Add(fTrackCountWOJetUJ);
735
736   fTrackCountWOJetUJMC = new TH2F("fTrackCountWOJetUJMC", "My own total referece mult., soft mult, 1 jet, MC!", 151, -0.5, 150.5, 151, -0.5, 150.5);
737   fTrackCountWOJetUJMC->GetXaxis()->SetTitle("Total TPC (eta) multiplicity");
738   fTrackCountWOJetUJMC->GetYaxis()->SetTitle("Soft TPC (eta) multiplicity");
739   fTrackCountWOJetUJMC->Sumw2();
740   fOutputList->Add(fTrackCountWOJetUJMC);
741
742   fFullV0V0CorrUJMC = new TH2F("fFullV0V0CorrUJMC", "Multiplicity from full V0, multiplicity from corrected V0, 1 jet event, MC!",1001, -0.5, 1000.5, 1001, -0.5, 1000.5);
743   fFullV0V0CorrUJMC->GetXaxis()->SetTitle("Multiplicity from full V0 (acceptance)");
744   fFullV0V0CorrUJMC->GetYaxis()->SetTitle("Multiplicity V0(acceptance) no jets");
745   fFullV0V0CorrUJMC->Sumw2();
746   fOutputList->Add(fFullV0V0CorrUJMC);
747
748   fMinTrackPtInNTXRecalc = new TH3F("fMinTrackPtInNTXRecalc", "Minimum track pT for the jets after pT correction, raw jet pT", 200, 0., 100., 60, 0., 300.,10,0.5,10.5);
749   fMinTrackPtInNTXRecalc->GetXaxis()->SetTitle("p_{T}^{TRACK} (GeV/c)");
750   fMinTrackPtInNTXRecalc->GetYaxis()->SetTitle("p_{T}^{JET} (GeV/c)");
751   fMinTrackPtInNTXRecalc->GetZaxis()->SetTitle("Selection Bin");  // 9 selections bins as fNChTrRecECorr
752   fMinTrackPtInNTXRecalc->Sumw2();
753   fOutputList->Add(fMinTrackPtInNTXRecalc);
754
755   fMaxTrackPtInNTXRecalc = new TH2F("fMaxTrackPtInNTXRecalc", "Maximum track pT for the jets after pT correction, raw jet pT", 200, 0., 100., 60, 0., 300.);
756   fMaxTrackPtInNTXRecalc->GetXaxis()->SetTitle("p_{T}^{TRACK} (GeV/c)");
757   fMaxTrackPtInNTXRecalc->GetYaxis()->SetTitle("p_{T}^{JET} (GeV/c)");
758   fMaxTrackPtInNTXRecalc->Sumw2();
759   fOutputList->Add(fMaxTrackPtInNTXRecalc);
760
761   fPtDistInJetConeRaw = new TH3F("fPtDistInJetConeRaw","pT of tracks in cone, raw jet pT bin, centrality", 200, 0., 100., 8, 0.5, 8.5, 10, 0.5, 10.5);
762   fPtDistInJetConeRaw->GetXaxis()->SetTitle("p_{T}^{TRACK} (GeV/c)");
763   fPtDistInJetConeRaw->GetYaxis()->SetTitle("p_{T}^{JET} Bin");
764   fPtDistInJetConeRaw->GetZaxis()->SetTitle("Centrality Bin");
765   fPtDistInJetConeRaw->Sumw2();
766   fOutputList->Add(fPtDistInJetConeRaw);
767
768   fPtDistInPerpConeRaw = new TH3F("fPtDistInPerpConeRaw","pT of tracks in cone, raw jet pT bin, centrality", 200, 0., 100., 8, 0.5, 8.5, 10, 0.5, 10.5);
769   fPtDistInPerpConeRaw->GetXaxis()->SetTitle("p_{T}^{TRACK} (GeV/c)");
770   fPtDistInPerpConeRaw->GetYaxis()->SetTitle("p_{T}^{JET} Bin");
771   fPtDistInPerpConeRaw->GetZaxis()->SetTitle("Centrality Bin");
772   fPtDistInPerpConeRaw->Sumw2();
773   fOutputList->Add(fPtDistInPerpConeRaw);
774
775   fPtInPerpCon = new TH3F("fPtInPerpCon","Summed pT of perpendicular cone, raw jet pT bin, centrality", 200, 0., 100., 8, 0.5, 8.5, 10, 0.5, 10.5);
776   fPtInPerpCon->GetXaxis()->SetTitle("p_{T}^{PERP.CONE} (GeV/c)");
777   fPtInPerpCon->GetYaxis()->SetTitle("p_{T}^{JET} Bin");
778   fPtInPerpCon->GetZaxis()->SetTitle("Centrality Bin");
779   fPtInPerpCon->Sumw2();
780   fOutputList->Add(fPtInPerpCon);
781
782   fJetEtaAll = new TH1F("fJetEtaAll", "Eta distribution of reconstructed jets, no cuts", 50, -1.5, 1.5);
783   fJetEtaAll->GetXaxis()->SetTitle("#eta");
784   fJetEtaAll->GetYaxis()->SetTitle("entries");
785   fJetEtaAll->Sumw2();
786   fOutputList->Add(fJetEtaAll);
787
788   fJetEtaOnlyTPCcut = new TH1F("fJetEtaOnlyTPCcut", "Eta distribution of reconstructed jets, only tpc acceptance cut", 50, -1.5, 1.5);
789   fJetEtaOnlyTPCcut->GetXaxis()->SetTitle("#eta");
790   fJetEtaOnlyTPCcut->GetYaxis()->SetTitle("entries");
791   fJetEtaOnlyTPCcut->Sumw2();
792   fOutputList->Add(fJetEtaOnlyTPCcut);
793
794   // 9 multiplicity bins
795   // 1st.     <5    TPC tracks       fill 1  Bin1 [0.5,1.5)
796   // 2nd. >= 5  <10 TPC tracks       fill 2  Bin2 [1.5,2.5)
797   // 3rd. >= 10 <15 TPC tracks       fill 3  Bin3 [2.5,3.5)
798   // 4rd. >= 15 <20 TPC tracks       fill 4  Bin4 [3.5,4.5)
799   // 5th. >= 20 <30 TPC tracks       fill 5  Bin5 [4.5,5.5)
800   // 6th. >= 30 <40 TPC tracks       fill 6  Bin6 [5.5,6.5)
801   // 7th. >= 40 <50 TPC tracks       fill 7  Bin7 [6.5,7.5)
802   // 8th.    >50    TPC tracks       fill 8  Bin8 [7.5,8.5)
803
804   fNChTrRecECorrPPMult = new TH3F("fNChTrRecECorrPPMult","NTX in ener. corr. jet , corr. jet pT, pp mult.",101,-0.5,100.5, 60, 0., 300.,8,0.5,8.5);
805   fNChTrRecECorrPPMult->GetXaxis()->SetTitle("NTracks_Corrected");
806   fNChTrRecECorrPPMult->GetYaxis()->SetTitle("p_{T}^{JET}");
807   fNChTrRecECorrPPMult->GetZaxis()->SetTitle("Multiplicity Bin");
808   fNChTrRecECorrPPMult->Sumw2();
809   fOutputList->Add(fNChTrRecECorrPPMult);
810
811   fNChTrRecPerpECorrPPMult = new TH3F("fNChTrRecPerpECorrPPMult","Tracks above min in perp.cone , corr. jet pT, centrality",101,-0.5,100.5, 60, 0., 300.,8,0.5,8.5);
812   fNChTrRecPerpECorrPPMult->GetXaxis()->SetTitle("NTracks_Corrected");
813   fNChTrRecPerpECorrPPMult->GetYaxis()->SetTitle("p_{T}^{JET}");
814   fNChTrRecPerpECorrPPMult->GetZaxis()->SetTitle("Multiplicity Bin");
815   fNChTrRecPerpECorrPPMult->Sumw2();
816   fOutputList->Add(fNChTrRecPerpECorrPPMult);
817
818   fJetPtCentPbPbRaw = new TH2F("fJetPtCentPbPbRaw", "raw p_{T} distribution of reco jets", 60, 0., 300.,10,0.5,10.5);
819   fJetPtCentPbPbRaw->GetXaxis()->SetTitle("p_{T} (GeV/c)");
820   fJetPtCentPbPbRaw->GetYaxis()->SetTitle("Selection Bin");
821   fJetPtCentPbPbRaw->Sumw2();
822   fOutputList->Add(fJetPtCentPbPbRaw);
823
824   fJetPtCentPbPbCorr = new TH2F("fJetPtCentPbPbCorr", "Corrected p_{T} distribution of reco jets", 60, 0., 300.,10,0.5,10.5);
825   fJetPtCentPbPbCorr->GetXaxis()->SetTitle("p_{T} (GeV/c)");
826   fJetPtCentPbPbCorr->GetYaxis()->SetTitle("Selection Bin");
827   fJetPtCentPbPbCorr->Sumw2();
828   fOutputList->Add(fJetPtCentPbPbCorr);
829
830   fTotTracksCone = new TH3F("fTotTracksCone","Total number of tracks in the cone, raw jet pT bin, centrality", 200, 0.5, 200.5, 8, 0.5, 8.5, 10, 0.5, 10.5);
831   fTotTracksCone->GetXaxis()->SetTitle("NTracks");
832   fTotTracksCone->GetYaxis()->SetTitle("p_{T}^{JET} Bin");
833   fTotTracksCone->GetZaxis()->SetTitle("Centrality Bin");
834   fTotTracksCone->Sumw2();
835   fOutputList->Add(fTotTracksCone);
836
837   for(Int_t ipt=0;ipt<12;ipt++)
838     {
839       fNChTr[ipt] = new TH2F(Form("fNChTr[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}",101,-0.5,100.5, 60, 0., 300.);
840       fNChTr[ipt]->GetXaxis()->SetTitle("NTracks");
841       fNChTr[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
842       fNChTr[ipt]->Sumw2();
843       fOutputList->Add(fNChTr[ipt]);
844
845       fHistPtParton[ipt] = new TH1F(Form("fHistPtParton[%i]",ipt),"pT distribution of jets",50,0.,250.);
846       fHistPtParton[ipt]->GetXaxis()->SetTitle("p_{T}^{JET}");
847       fHistPtParton[ipt]->GetYaxis()->SetTitle("Entries");
848       fHistPtParton[ipt]->Sumw2();
849       fOutputList->Add(fHistPtParton[ipt]);
850
851       fSCM[ipt] = new TH2F(Form("fSCM[%i]",ipt),"Second Central Moment, jet_{p_{T}}",200,0.,0.2, 60, 0., 300.);
852       fSCM[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
853       fSCM[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
854       fSCM[ipt]->Sumw2();
855       fOutputList->Add(fSCM[ipt]);
856
857       if(ipt<8) 
858         { 
859           fNChTrRDMult[ipt] = new TH2F(Form("fNChTrRDMult[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}",101,-0.5,100.5, 60, 0., 300.);
860           fNChTrRDMult[ipt]->GetXaxis()->SetTitle("NTracks");
861           fNChTrRDMult[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
862           fNChTrRDMult[ipt]->Sumw2();
863           fOutputList->Add(fNChTrRDMult[ipt]);
864           
865           fNAccJetsRDMult[ipt] = new TH1F(Form("fNAccJetsRDMult[%i]",ipt),"Number of accepted jets per event in real data", 101, -0.5, 100.5);
866           fNAccJetsRDMult[ipt]->GetXaxis()->SetTitle("Number of jets");
867           fNAccJetsRDMult[ipt]->Sumw2();
868           fOutputList->Add(fNAccJetsRDMult[ipt]);
869           
870           fTotalJetCharge[ipt] = new TH1F(Form("fTotalJetCharge[%i]",ipt),"Charge in the jet", 41, -20.5, 20.5);
871           fTotalJetCharge[ipt]->GetXaxis()->SetTitle("Charge in jet");
872           fTotalJetCharge[ipt]->Sumw2();
873           fOutputList->Add(fTotalJetCharge[ipt]);
874           
875           fSCMRDMult[ipt] = new TH2F(Form("fSCMRDMult[%i]",ipt),"Second Central Moment, jet_{p_{T}}",200,0.,0.2, 60, 0., 300.);
876           fSCMRDMult[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
877           fSCMRDMult[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
878           fSCMRDMult[ipt]->Sumw2();
879           fOutputList->Add(fSCMRDMult[ipt]);
880           
881           fNChTrRDMultMC[ipt] = new TH2F(Form("fNChTrRDMultMC[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}",101,-0.5,100.5, 60, 0., 300.);
882           fNChTrRDMultMC[ipt]->GetXaxis()->SetTitle("NTracks");
883           fNChTrRDMultMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
884           fNChTrRDMultMC[ipt]->Sumw2();
885           fOutputList->Add(fNChTrRDMultMC[ipt]);
886           
887           fSCMRDMultMC[ipt] = new TH2F(Form("fSCMRDMultMC[%i]",ipt),"Second Central Moment, jet_{p_{T}}",200,0.,0.2, 60, 0., 300.);
888           fSCMRDMultMC[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
889           fSCMRDMultMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
890           fSCMRDMultMC[ipt]->Sumw2();
891           fOutputList->Add(fSCMRDMultMC[ipt]);
892
893           //Second multiplicity estimator, removing jets and an area
894           fNChTrRDMultSE[ipt] = new TH2F(Form("fNChTrRDMultSE[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}",101,-0.5,100.5, 60, 0., 300.);
895           fNChTrRDMultSE[ipt]->GetXaxis()->SetTitle("NTracks");
896           fNChTrRDMultSE[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
897           fNChTrRDMultSE[ipt]->Sumw2();
898           fOutputList->Add(fNChTrRDMultSE[ipt]);
899           
900           fNAccJetsRDMultSE[ipt] = new TH1F(Form("fNAccJetsRDMultSE[%i]",ipt),"Number of accepted jets per event in real data", 101, -0.5, 100.5);
901           fNAccJetsRDMultSE[ipt]->GetXaxis()->SetTitle("Number of jets");
902           fNAccJetsRDMultSE[ipt]->Sumw2();
903           fOutputList->Add(fNAccJetsRDMultSE[ipt]);
904           
905           fTotalJetChargeSE[ipt] = new TH1F(Form("fTotalJetChargeSE[%i]",ipt),"Charge in the jet", 41, -20.5, 20.5);
906           fTotalJetChargeSE[ipt]->GetXaxis()->SetTitle("Charge in jet");
907           fTotalJetChargeSE[ipt]->Sumw2();
908           fOutputList->Add(fTotalJetChargeSE[ipt]);
909           
910           fSCMRDMultSE[ipt] = new TH2F(Form("fSCMRDMultSE[%i]",ipt),"Second Central Moment, jet_{p_{T}}",200,0.,0.2, 60, 0., 300.);
911           fSCMRDMultSE[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
912           fSCMRDMultSE[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
913           fSCMRDMultSE[ipt]->Sumw2();
914           fOutputList->Add(fSCMRDMultSE[ipt]);
915
916           fNChTrRDMultOJ[ipt] = new TH2F(Form("fNChTrRDMultOJ[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}, 1 jet}",101,-0.5,100.5, 60, 0., 300.);
917           fNChTrRDMultOJ[ipt]->GetXaxis()->SetTitle("NTracks");
918           fNChTrRDMultOJ[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
919           fNChTrRDMultOJ[ipt]->Sumw2();
920           fOutputList->Add(fNChTrRDMultOJ[ipt]);
921
922           fSCMRDMultOJ[ipt] = new TH2F(Form("fSCMRDMultOJ[%i]",ipt),"Second Central Moment, jet_{p_{T}}, 1 jet",200,0.,0.2, 60, 0., 300.);
923           fSCMRDMultOJ[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
924           fSCMRDMultOJ[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
925           fSCMRDMultOJ[ipt]->Sumw2();
926           fOutputList->Add(fSCMRDMultOJ[ipt]);
927
928           fNChTrRDMultSEOJ[ipt] = new TH2F(Form("fNChTrRDMultSEOJ[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}, 1 jet",101,-0.5,100.5, 60, 0., 300.);
929           fNChTrRDMultSEOJ[ipt]->GetXaxis()->SetTitle("NTracks");
930           fNChTrRDMultSEOJ[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
931           fNChTrRDMultSEOJ[ipt]->Sumw2();
932           fOutputList->Add(fNChTrRDMultSEOJ[ipt]);
933
934           fSCMRDMultSEOJ[ipt] = new TH2F(Form("fSCMRDMultSEOJ[%i]",ipt),"Second Central Moment, jet_{p_{T}}, 1 jet",200,0.,0.2, 60, 0., 300.);
935           fSCMRDMultSEOJ[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
936           fSCMRDMultSEOJ[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
937           fSCMRDMultSEOJ[ipt]->Sumw2();
938           fOutputList->Add(fSCMRDMultSEOJ[ipt]);
939
940           fNChTrRDMultOJMC[ipt] = new TH2F(Form("fNChTrRDMultOJMC[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}, 1 jet, MC}",101,-0.5,100.5, 60, 0., 300.);
941           fNChTrRDMultOJMC[ipt]->GetXaxis()->SetTitle("NTracks");
942           fNChTrRDMultOJMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
943           fNChTrRDMultOJMC[ipt]->Sumw2();
944           fOutputList->Add(fNChTrRDMultOJMC[ipt]);
945
946           fSCMRDMultOJMC[ipt] = new TH2F(Form("fSCMRDMultOJMC[%i]",ipt),"Second Central Moment, jet_{p_{T}}, 1 jet, MC",200,0.,0.2, 60, 0., 300.);
947           fSCMRDMultOJMC[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
948           fSCMRDMultOJMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
949           fSCMRDMultOJMC[ipt]->Sumw2();
950           fOutputList->Add(fSCMRDMultOJMC[ipt]);
951
952           fNChTrRDMultSEOJMC[ipt] = new TH2F(Form("fNChTrRDMultSEOJMC[%i]",ipt),"Number of tracks to recover transverse energy, jet_{p_{T}}, 1 jet, MC",101,-0.5,100.5, 60, 0., 300.);
953           fNChTrRDMultSEOJMC[ipt]->GetXaxis()->SetTitle("NTracks");
954           fNChTrRDMultSEOJMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
955           fNChTrRDMultSEOJMC[ipt]->Sumw2();
956           fOutputList->Add(fNChTrRDMultSEOJMC[ipt]);
957
958           fSCMRDMultSEOJMC[ipt] = new TH2F(Form("fSCMRDMultSEOJMC[%i]",ipt),"Second Central Moment, jet_{p_{T}}, 1 jet, MC",200,0.,0.2, 60, 0., 300.);
959           fSCMRDMultSEOJMC[ipt]->GetXaxis()->SetTitle("<#delta R_{c}^{2}>");
960           fSCMRDMultSEOJMC[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
961           fSCMRDMultSEOJMC[ipt]->Sumw2();
962           fOutputList->Add(fSCMRDMultSEOJMC[ipt]);
963
964           fNChTrRecPerpMultSEOJ[ipt] = new TH2F(Form("fNChTrRecPerpMultSEOJ[%i]",ipt),"Number of tracks above the min pT used in NTX_Raw, jet_{p_{T}}, 1 jet",101,-0.5,100.5, 60, 0., 300.);
965           fNChTrRecPerpMultSEOJ[ipt]->GetXaxis()->SetTitle("NTracks_{Exc.}");
966           fNChTrRecPerpMultSEOJ[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
967           fNChTrRecPerpMultSEOJ[ipt]->Sumw2();
968           fOutputList->Add(fNChTrRecPerpMultSEOJ[ipt]);
969
970           fJEtaMCMultOJ[ipt] = new TH1F(Form("fJEtaMCMultOJ[%i]",ipt), "Eta distribution of MC jets, V0-like mult. bins, 1 jet", 50, -1.5, 1.5);
971           fJEtaMCMultOJ[ipt]->GetXaxis()->SetTitle("#eta");
972           fJEtaMCMultOJ[ipt]->GetYaxis()->SetTitle("entries");
973           fJEtaMCMultOJ[ipt]->Sumw2();
974           fOutputList->Add(fJEtaMCMultOJ[ipt]);
975
976           fJEtaMCMultSEOJ[ipt] = new TH1F(Form("fJEtaMCMultSEOJ[%i]",ipt), "Eta distribution of MC jets, TPC-like mult. bins, 1 jet", 50, -1.5, 1.5);
977           fJEtaMCMultSEOJ[ipt]->GetXaxis()->SetTitle("#eta");
978           fJEtaMCMultSEOJ[ipt]->GetYaxis()->SetTitle("entries");
979           fJEtaMCMultSEOJ[ipt]->Sumw2();
980           fOutputList->Add(fJEtaMCMultSEOJ[ipt]);
981
982           fJEtaRDMultOJ[ipt] = new TH1F(Form("fJEtaRDMultOJ[%i]",ipt), "Eta distribution of reco jets, V0 mult. bins, 1 jet", 50, -1.5, 1.5);
983           fJEtaRDMultOJ[ipt]->GetXaxis()->SetTitle("#eta");
984           fJEtaRDMultOJ[ipt]->GetYaxis()->SetTitle("entries");
985           fJEtaRDMultOJ[ipt]->Sumw2();
986           fOutputList->Add(fJEtaRDMultOJ[ipt]);
987
988           fJEtaRDMultSEOJ[ipt] = new TH1F(Form("fJEtaRDMultSEOJ[%i]",ipt), "Eta distribution of reco jets, TPC mult. bins, 1 jet", 50, -1.5, 1.5);
989           fJEtaRDMultSEOJ[ipt]->GetXaxis()->SetTitle("#eta");
990           fJEtaRDMultSEOJ[ipt]->GetYaxis()->SetTitle("entries");
991           fJEtaRDMultSEOJ[ipt]->Sumw2();
992           fOutputList->Add(fJEtaRDMultSEOJ[ipt]);
993
994           fJetPtMCMultOJ[ipt] = new TH1F(Form("fJetPtMCMultOJ[%i]",ipt), "pT distribution of MC jets, V0-like mult. bins, 1 jet", 60, 0., 300.);
995           fJetPtMCMultOJ[ipt]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
996           fJetPtMCMultOJ[ipt]->GetYaxis()->SetTitle("entries");
997           fJetPtMCMultOJ[ipt]->Sumw2();
998           fOutputList->Add(fJetPtMCMultOJ[ipt]);
999
1000           fJetPtMCMultSEOJ[ipt] = new TH1F(Form("fJetPtMCMultSEOJ[%i]",ipt), "pT distribution of MC jets, TPC-like mult. bins, 1 jet", 60, 0., 300.);
1001           fJetPtMCMultSEOJ[ipt]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1002           fJetPtMCMultSEOJ[ipt]->GetYaxis()->SetTitle("entries");
1003           fJetPtMCMultSEOJ[ipt]->Sumw2();
1004           fOutputList->Add(fJetPtMCMultSEOJ[ipt]);
1005
1006           fJetPtRDMultOJ[ipt] = new TH1F(Form("fJetPtRDMultOJ[%i]",ipt), "pT distribution of reco jets, V0 mult. bins, 1 jet", 60, 0., 300.);
1007           fJetPtRDMultOJ[ipt]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1008           fJetPtRDMultOJ[ipt]->GetYaxis()->SetTitle("entries");
1009           fJetPtRDMultOJ[ipt]->Sumw2();
1010           fOutputList->Add(fJetPtRDMultOJ[ipt]);
1011
1012           fJetPtRDMultSEOJ[ipt] = new TH1F(Form("fJetPtRDMultSEOJ[%i]",ipt), "pT distribution of reco jets, TPC mult. bins, 1 jet", 60, 0., 300.);
1013           fJetPtRDMultSEOJ[ipt]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1014           fJetPtRDMultSEOJ[ipt]->GetYaxis()->SetTitle("entries");
1015           fJetPtRDMultSEOJ[ipt]->Sumw2();
1016           fOutputList->Add(fJetPtRDMultSEOJ[ipt]);
1017
1018           fEntriesQuark[ipt] = new TH2F(Form("fEntriesQuark[%i]",ipt),"NTX of quarks in multiplicity bins, 1 jet, MC",101,-0.5,100.5, 60, 0., 300.);
1019           fEntriesQuark[ipt]->GetXaxis()->SetTitle("NTracks");
1020           fEntriesQuark[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
1021           fEntriesQuark[ipt]->Sumw2();
1022           fOutputList->Add(fEntriesQuark[ipt]);
1023
1024           fEntriesGluon[ipt] = new TH2F(Form("fEntriesGluon[%i]",ipt),"NTX of gluons in multiplicity bins, 1 jet, MC",101,-0.5,100.5, 60, 0., 300.);
1025           fEntriesGluon[ipt]->GetXaxis()->SetTitle("NTracks");
1026           fEntriesGluon[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
1027           fEntriesGluon[ipt]->Sumw2();
1028           fOutputList->Add(fEntriesGluon[ipt]);
1029         } // end if <8
1030
1031       if(ipt<6)  // only entries for reconstructed || simulated jets
1032         { 
1033           fProcessPDG[ipt] = new TH2I(Form("fProcessPDG[%i]",ipt),"Pythia process and jet p_T", 60, 0., 300., 70, 0.5, 70.5);
1034           fProcessPDG[ipt]->GetXaxis()->SetTitle("p_{T}^{JET}");
1035           fProcessPDG[ipt]->GetYaxis()->SetTitle("Pythia process code");
1036           fProcessPDG[ipt]->Sumw2();
1037           fOutputList->Add(fProcessPDG[ipt]);
1038
1039           fFragPion[ipt] = new TH2F(Form("fFragPion[%i]",ipt),"Fragmentation in pions",35,0.,8.,50,0.,250.);
1040           fFragPion[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1041           fFragPion[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1042           fFragPion[ipt]->Sumw2();
1043           fOutputList->Add(fFragPion[ipt]);
1044           
1045           fFragKaon[ipt] = new TH2F(Form("fFragKaon[%i]",ipt),"Fragmentation in kaons",35,0.,8.,50,0.,250.);
1046           fFragKaon[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1047           fFragKaon[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1048           fFragKaon[ipt]->Sumw2();
1049           fOutputList->Add(fFragKaon[ipt]);
1050
1051           fFragProton[ipt] = new TH2F(Form("fFragProton[%i]",ipt),"Fragmentation in protons",35,0.,8.,50,0.,250.);
1052           fFragProton[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1053           fFragProton[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1054           fFragProton[ipt]->Sumw2();
1055           fOutputList->Add(fFragProton[ipt]);
1056
1057           fFragChargedR4[ipt] = new TH2F(Form("fFragChargedR4[%i]",ipt),"Fragmentation in charged particles",35,0.,8.,50,0.,250.);
1058           fFragChargedR4[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1059           fFragChargedR4[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1060           fFragChargedR4[ipt]->Sumw2();
1061           fOutputList->Add(fFragChargedR4[ipt]);
1062           
1063           fFragChargedR3[ipt] = new TH2F(Form("fFragChargedR3[%i]",ipt),"Fragmentation in charged particles",35,0.,8.,50,0.,250.);
1064           fFragChargedR3[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1065           fFragChargedR3[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1066           fFragChargedR3[ipt]->Sumw2();
1067           fOutputList->Add(fFragChargedR3[ipt]);
1068
1069           fFragChargedR2[ipt] = new TH2F(Form("fFragChargedR2[%i]",ipt),"Fragmentation in charged particles",35,0.,8.,50,0.,250.);
1070           fFragChargedR2[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1071           fFragChargedR2[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1072           fFragChargedR2[ipt]->Sumw2();
1073           fOutputList->Add(fFragChargedR2[ipt]);
1074
1075           // do not add the temporary containers
1076           fHistContainerR4[ipt] = new TH2F(Form("fHistContainerR4[%i]",ipt),"Temporary fragmentation in charged particles",35,0.,8.,50,0.,250.);
1077           fHistContainerR4[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1078           fHistContainerR4[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1079           fHistContainerR4[ipt]->Sumw2();
1080           
1081           fHistContainerR3[ipt] = new TH2F(Form("fHistContainerR3[%i]",ipt),"Temporary fragmentation in charged particles",35,0.,8.,50,0.,250.);
1082           fHistContainerR3[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1083           fHistContainerR3[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1084           fHistContainerR3[ipt]->Sumw2();
1085           
1086           fHistContainerR2[ipt] = new TH2F(Form("fHistContainerR2[%i]",ipt),"Temporary fragmentation in charged particles",35,0.,8.,50,0.,250.);
1087           fHistContainerR2[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1088           fHistContainerR2[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1089           fHistContainerR2[ipt]->Sumw2();
1090
1091           if(ipt<3)
1092             {
1093               fJetEtaJetPt[ipt] = new TH1F(Form("fJetEtaJetPt[%i]",ipt), "Eta distribution of reconstructed jets, all cut, with pT upper boundary", 50, -1.5, 1.5);
1094               fJetEtaJetPt[ipt]->GetXaxis()->SetTitle("#eta");
1095               fJetEtaJetPt[ipt]->GetYaxis()->SetTitle("entries");
1096               fJetEtaJetPt[ipt]->Sumw2();
1097               fOutputList->Add(fJetEtaJetPt[ipt]);
1098
1099               if(ipt<2)
1100                 {
1101                   fFragCandidates[ipt] = new TH2F(Form("fFragCandidates[%i]",ipt),"Parton identified candidates",35,0.,8.,50,0.,250.);
1102                   fFragCandidates[ipt]->GetXaxis()->SetTitle("#xi=ln[Jet_{E_{T}}/H_{p_{T}}]");
1103                   fFragCandidates[ipt]->GetYaxis()->SetTitle("Jet_{E_{T}}");
1104                   fFragCandidates[ipt]->Sumw2();
1105                   fOutputList->Add(fFragCandidates[ipt]);
1106                   
1107                   fMinTrackPtInNTXh[ipt] = new TH3F(Form("fMinTrackPtInNTXh[%i]",ipt), "Minimum track pT for the jets", 200, 0., 100., 60, 0., 300.,10,0.5,10.5);
1108                   fMinTrackPtInNTXh[ipt]->GetXaxis()->SetTitle("p_{T}^{TRACK}");
1109                   fMinTrackPtInNTXh[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
1110                   fMinTrackPtInNTXh[ipt]->GetZaxis()->SetTitle("Selection Bin"); //9 selection bins as fNChTrRecECorr
1111                   fMinTrackPtInNTXh[ipt]->Sumw2();
1112                   fOutputList->Add(fMinTrackPtInNTXh[ipt]);
1113                   
1114                   fMaxTrackPtInNTXh[ipt] = new TH2F(Form("fMaxTrackPtInNTXh[%i]",ipt), "Maximum track pT for the jets", 200, 0., 100., 60, 0., 300.);
1115                   fMaxTrackPtInNTXh[ipt]->GetXaxis()->SetTitle("p_{T}^{TRACK}");
1116                   fMaxTrackPtInNTXh[ipt]->GetYaxis()->SetTitle("p_{T}^{JET}");
1117                   fMaxTrackPtInNTXh[ipt]->Sumw2();
1118                   fOutputList->Add(fMaxTrackPtInNTXh[ipt]);  
1119                 } // index < 2 
1120             } // index < 3 
1121         } // index < 6 
1122     } // index < 12 
1123
1124   fPerpCone = new AliAODJet();
1125   fBckgSbsJet = new Double_t[3];
1126
1127   PostData(1, fOutputList); // Post data for ALL output slots >0 here, to get at least an empty histogram
1128 }
1129
1130 //________________________________________________________________________
1131 void AliAnalysisTaskPartonDisc::UserExec(Option_t *) 
1132 {
1133   // Main loop
1134   // Called for each event
1135
1136   //  fAOD
1137   if(fUseAODJetInput)
1138     {    
1139       fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
1140       if(!fAOD)
1141         {
1142           Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODJetInput);
1143           return;
1144         }
1145       // fetch the header
1146     }
1147   else
1148     {
1149       //  assume that the AOD is in the general output...
1150       fAOD  = AODEvent();
1151       if(!fAOD)
1152         {
1153           Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
1154           return;
1155         }
1156     }
1157
1158   // fin de test para fAOD
1159
1160   if(!fInputEvent)
1161     {
1162       Error("UserExec","No event found!");
1163       return;
1164     }
1165    
1166   AliAODHandler *aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1167   if(!aodHandler)
1168     {
1169       AliError("No AOD Handler!");
1170       return;
1171     }
1172
1173   fEventCent=900; //dummy val for debugging
1174
1175   if(fIsHIevent)
1176     {
1177       AliAODHeader *aodHeader = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
1178       if(!aodHeader) AliFatal("Not a standard AOD");
1179       fEventCent = aodHeader->GetCentrality();
1180     }
1181
1182   // Random number generator seeded per event
1183   TDatime dt;
1184   UInt_t curtime = dt.Get();
1185   UInt_t procid = gSystem->GetPid();
1186   UInt_t seed = curtime-procid;
1187   gRandom->SetSeed(seed);
1188
1189   // Jet eta exclusion
1190   if(fIncreasingExcl)
1191     fJetAcceptance = 0.5 - fIncExcR; // if the increase is 0.1 -> only jets within |eta|<0.4 
1192
1193   // First test of reference multiplicity
1194   AliAODHeader * header = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
1195   if(!header) AliFatal("Not a standard AOD");
1196
1197   Int_t refMultiplicity = header->GetRefMultiplicity();
1198   fRefMult->Fill(refMultiplicity);
1199
1200   // Multiplicity from V0 (V0A+V0C)
1201   fVZero = fAOD->GetVZEROData();
1202   Float_t multV0A = 0.0;
1203   Float_t multV0C = 0.0;
1204   Float_t multFullV0 = 0.0;
1205   if(fVZero)
1206     {
1207       multV0A = fVZero->GetMTotV0A();
1208       multV0C = fVZero->GetMTotV0C();
1209       multFullV0 = multV0A+multV0C; 
1210     }
1211   fVZEROMult->Fill(multV0A,multV0C);
1212
1213   fEvtCount++;
1214   Double_t jfr = fJetRadius;   // radius used during jet finding
1215   Int_t ntx = fNtX;   // NTX value
1216   const Int_t maxJetNum=6; // maximum number of generated jets to process
1217   AliAODJet genJets[6];  // containers for the
1218   AliAODJet recJets[6];  // correlation gen-reco
1219   Int_t nGenJets=0; 
1220   Int_t nRecJets=0;
1221   Int_t genJetsFlavor[6]={0};    // flavor of the generated jets
1222   Int_t evtype = 0; //pythia event type
1223   // Variables para la variable de estructura
1224   Double_t deltaPhiPt = 0.0;
1225   Double_t deltaEtaPt = 0.0;
1226   Double_t deltaPhiSqPt = 0.0;
1227   Double_t deltaEtaSqPt = 0.0;
1228   Double_t totalTrackPt = 0.0; 
1229   Double_t firstMomDeltPhi = 0.0;
1230   Double_t firstMomDeltEta = 0.0;
1231   Double_t secondMomDeltPhi = 0.0;
1232   Double_t secondMomDeltEta = 0.0;
1233   Double_t secondCentralPhi = 0.0;
1234   Double_t secondCentralEta = 0.0;
1235   Double_t secondCentralR = 0.0; 
1236
1237   // Variables para la variable de estructura
1238   // del cono perpendicular
1239   Double_t deltaPhiPtPerp = 0.0;
1240   Double_t deltaEtaPtPerp = 0.0;
1241   Double_t deltaPhiSqPtPerp = 0.0;
1242   Double_t deltaEtaSqPtPerp = 0.0;
1243   Double_t totalTrackPtPerp = 0.0;
1244   Double_t firstMomDeltPhiPerp = 0.0;
1245   Double_t firstMomDeltEtaPerp = 0.0;
1246   Double_t secondMomDeltPhiPerp = 0.0;
1247   Double_t secondMomDeltEtaPerp = 0.0;
1248   Double_t secondCentralPhiPerp = 0.0;
1249   Double_t secondCentralEtaPerp = 0.0;
1250   Double_t secondCentralRPerp = 0.0;  
1251
1252   Double_t perpendicularPt;
1253   Float_t px,py,pz,en; // jet 4-vector à la UA1
1254   Float_t pTbs, etabs, phibs; // energy corrected jet properties
1255
1256   // Process the MC info from the AOD
1257   if(fUseAODMC)
1258     {
1259       // Get the MC array
1260       TClonesArray *mcarray = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
1261       if(!mcarray)
1262         {
1263           AliError("ERROR:No MC info in the AOD input");
1264           return;
1265         } 
1266
1267       AliMCEvent* mcEvent = MCEvent();
1268       if(mcEvent)
1269         {
1270           if(!fPhojetMC) // if it is pythia
1271             evtype = GetMCEventType(mcEvent);
1272           // From pythia 6.2 manual pp 414
1273           // QCD Hard Processes
1274           // 11 f_{i}+f_{j} -> f_{i}+f_{j} com77, ben84, eic84, chi90 
1275           // 12 f_{i}+barf_{i} -> f_{k}+barf_{k}
1276           // 13 f_{i}+barf_{i} -> g+g
1277           // 28 f_{i}+g -> f_{i}+g
1278           // 53 g+g -> f_{k}+barf_{k}
1279           // 68 g+g -> g+g
1280           if(fPhojetMC) // if it is phojet
1281             evtype = GetPhojetEventType(mcEvent); 
1282         }
1283       if(!mcEvent) // if a pure AOD event
1284         {
1285           AliDebug(2,Form("%s:%d No MCEvent \n",(char*)__FILE__,__LINE__));  
1286           AliDebug(2,Form("Trying to get the MC header \n"));  
1287           AliAODMCHeader *genEvH = static_cast<AliAODMCHeader*>(fAOD->FindListObject("mcHeader"));
1288           if(!genEvH)
1289             {
1290               AliDebug(2,Form(" %s:%d No Pythia header!",(char*)__FILE__,__LINE__));  
1291               evtype = 0;
1292             }
1293           if(genEvH)
1294             evtype = genEvH->GetEventType();
1295         }   
1296       // Get the branch with the MC jets
1297       TClonesArray *aodMCJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchMC.Data()));
1298       if(!aodMCJets)
1299         {
1300           AliDebug(2,Form("%s:%d no MC Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchMC.Data()));  
1301           return;
1302         }
1303       AliDebug(2,Form("There are %d MC jets in this event\n", aodMCJets->GetEntries())); 
1304       Int_t mcjets =  aodMCJets->GetEntries();
1305       fNJetsMC->Fill(mcjets,mcjets); // number of jets FROM the branch, filled per event, this gives the event normalization...     
1306       HasOverlapedCones(aodMCJets); // Procedure for tagging usable jets
1307                                     // Up 16 jets are flagged
1308
1309       // Loop over AODMC physical primary charged particles
1310       // for the complete event
1311       Int_t tracksMC = mcarray->GetEntriesFast();         
1312       AliDebug(2,Form("There are %i tracks in the mcarray",tracksMC));  
1313       Double_t aodMCTrackEta = 0.0; 
1314       perpendicularPt = 0.0;
1315       px=0.0;
1316       py=0.0;
1317       pz=0.0;
1318       en=0.0;
1319       pTbs=0.0;
1320       etabs=0.0;
1321       phibs=0.0;
1322       fBckgSbsJet[0]=0.0;
1323       fBckgSbsJet[1]=0.0;
1324       fBckgSbsJet[2]=0.0;
1325       Int_t softRefMcNoJets = 0;
1326       Int_t myTotalMultiplicityMc = 0;
1327       Int_t v0LikeTotalMcMult = 0;
1328       Double_t randomNum = 0.;
1329       for(Int_t aodMCTrack = 0; aodMCTrack < tracksMC; aodMCTrack++ )
1330         {
1331           AliAODMCParticle *mctrackf = (AliAODMCParticle*) mcarray->At(aodMCTrack);
1332           if(!mctrackf) continue;
1333           if(!mctrackf->IsPhysicalPrimary()) continue;
1334           if(mctrackf->Charge()==0||mctrackf->Charge()==-99) continue;
1335           randomNum = gRandom->Rndm();
1336           if(randomNum<fTTrackRandomRejection) continue; //rechaza fTTrackRandomRejection
1337
1338           //Lo del V0, voy a contar particulas primarias cargadas
1339           if(mctrackf->Pt()>fMinpTValMC) // cut off en MC para MIPs
1340             {
1341               //V0A
1342               if(((mctrackf->Eta())>(2.8))&&((mctrackf->Eta())<(5.1)))
1343                 v0LikeTotalMcMult++;
1344               //V0C
1345               if(((mctrackf->Eta())>(-3.7))&&((mctrackf->Eta())<(-1.7)))
1346                 v0LikeTotalMcMult++;
1347             }
1348           //Fin de lo del V0
1349           aodMCTrackEta = TMath::Abs(mctrackf->Eta());
1350           if(aodMCTrackEta>0.9) continue;
1351           fPtAODMC->Fill(mctrackf->Pt(),mctrackf->Pt());
1352           fEtaAODMC->Fill(mctrackf->Eta(),mctrackf->Eta());
1353           fPhiAODMC->Fill(mctrackf->Phi(),mctrackf->Phi());
1354           if(fJetEvent) // if has an accepted jet, calculate the perpendicular cone
1355             {
1356               if(HasPerpendicularCone()) // If there is a perpendicular cone available
1357                 {
1358                   if(mctrackf->Pt()>fMinpTVal)
1359                     {
1360                     if(GetDeltaR(fEtaPerpCoord,fPhiPerpCoord,mctrackf->Eta(),mctrackf->Phi())<fJetRadius)
1361                       perpendicularPt = perpendicularPt + mctrackf->Pt();
1362                     }
1363                 }
1364             } // end IF jet event
1365           if(mctrackf->Pt()>fMinPtInGlobMult) // Min pT used in multiplicity estimation
1366             {
1367               myTotalMultiplicityMc++; // total multiplicity TPC like
1368               if(mctrackf->Pt()<fMinpTValUE) continue; // pT cut  fMinpTValUE
1369               if(mctrackf->Pt()>fMaxpTValUE) continue; // pT cut  fMaxpTValUE
1370               if(!IsTrackInsideExcludedArea(mctrackf->Eta(), mctrackf->Phi(), aodMCJets)) 
1371                 softRefMcNoJets++;
1372             }
1373         } // end loop over particles
1374
1375       Int_t correctedV0LikeMult= v0LikeTotalMcMult-GetV0LikeExcludedMultMC(aodMCJets,mcarray);
1376
1377       //estimadores
1378       if(mcjets==1) // correlation for only monojet events
1379         {
1380           fFullV0V0CorrUJMC->Fill(v0LikeTotalMcMult,correctedV0LikeMult);
1381           fTrackCountWOJetUJMC->Fill(myTotalMultiplicityMc,softRefMcNoJets); 
1382         }
1383
1384       if(fJetEvent) // if has an accepted jet, calculate the perpendicular cone
1385         {
1386           if(HasPerpendicularCone()) // If there is a perpendicular cone available
1387             {
1388               px = perpendicularPt*TMath::Cos(fPhiPerpCoord);
1389               py = perpendicularPt*TMath::Sin(fPhiPerpCoord);
1390               pz = perpendicularPt/TMath::Tan(2.0*TMath::ATan(TMath::Exp(-fEtaPerpCoord)));
1391               en = TMath::Sqrt(px*px + py*py + pz*pz);
1392               fPerpCone->SetPxPyPzE(px, py, pz, en);
1393             }
1394           if(!HasPerpendicularCone())
1395             AliDebug(2,"No perpendicular cone!!!");  
1396         }
1397
1398
1399       fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
1400  
1401       Int_t flavor = 0;     // flavor of the jet      
1402       Int_t nTracksPerc;    // ntx for the original jet
1403       Int_t nTracksPercBckgSubst;  // ntx for the energy corrected jet
1404       Double_t jetPt=0;
1405       Int_t pdgOfMCt;
1406       Float_t trackxi;
1407       Double_t jetXt;
1408       Double_t jetPts[7]={0};  // to store the pt of the jets
1409       Int_t mcJetCounter=0;    // counter of MC jets
1410       Int_t nTracksAboveThresholdPerp=0;  // n tracks of the perpendicular cone
1411       Int_t nTrUpThrPerpBckSubs=0;  // n tracks of the perpendicular cone, after the minimum pT recalculation
1412       fIsPossibleToSubstBckg = kTRUE; // Initialize before the loop
1413       if(fJetEvent) // si tiene jets validos
1414         {
1415           if(!HasPerpendicularCone()) // pero no encontro un cono perpendicular libre
1416             fIsPossibleToSubstBckg = kFALSE; // if not perpendicular cone, set to kFALSE, so no perpendicular calculations available
1417         }
1418       // Loop to fill a pT spectrum of the mc jets
1419       Int_t imcj=0; // index for montecarlo jets to correlate
1420       for (Int_t indxmc = 0; indxmc < mcjets; indxmc++) 
1421         {
1422           AliAODJet *mcjet = dynamic_cast<AliAODJet*>(aodMCJets->At(indxmc));
1423           if (!mcjet) 
1424             {
1425               AliDebug(2,Form("ERROR: Could not receive jet %d\n", indxmc));  
1426               continue;
1427             }
1428           
1429           ///////////////////////////////////////////////////////////////////////////////
1430           ///// Part for Chritians plot of inclusive and leading jets comp at 2.76 TeV //
1431           if(!IsInsideAcceptance(mcjet))  // old condition
1432             continue;
1433           if(indxmc==0) // leading jet
1434             fMCJetPtLeading->Fill(mcjet->Pt());
1435           fMCJetPtInclusive->Fill(mcjet->Pt()); // all
1436           ///// End of Christians Plot MC
1437           ///////////////////////////////////////////////////////////////////////////////
1438           
1439           if(indxmc>15)
1440             continue;
1441
1442           if(!fJetFlags[indxmc]) // If the jet is flaged kFALSE, not usable
1443             continue;
1444
1445           //Initialize variables for this jet
1446           //adiciones para la variable de estructura
1447           nTracksPerc = 0;
1448           nTracksPercBckgSubst = 0;
1449           fMinTrackPtInNTX=200.0;  //Initialize for each jet, overflown
1450           fMaxTrackPtInNTX=200.0;  //Initialize for each jet, overflown
1451           fMinTrackPtInNTXR=200.0;  //Initialize for each jet, overflown
1452           fMaxTrackPtInNTXR=200.0;  //Initialize for each jet, overflown
1453           deltaPhiPt = 0.0;
1454           deltaEtaPt = 0.0;
1455           deltaPhiSqPt = 0.0;
1456           deltaEtaSqPt = 0.0;
1457           totalTrackPt = 0.0;
1458           firstMomDeltPhi = 0.0;
1459           firstMomDeltEta = 0.0;
1460           secondMomDeltPhi = 0.0;
1461           secondMomDeltEta = 0.0;
1462           secondCentralPhi = 0.0;
1463           secondCentralEta = 0.0;
1464           secondCentralR = 0.0; 
1465           
1466           if(imcj<maxJetNum)
1467             genJets[imcj]= *mcjet;
1468           if(mcJetCounter<maxJetNum)
1469             jetPts[mcJetCounter]=mcjet->Pt();
1470           mcJetCounter++;  // number of jets in the acceptance
1471           jetPt = mcjet->Pt();
1472           flavor =  GetJetFlavour(mcjet,tracksMC,mcarray);
1473           if(imcj<maxJetNum)
1474             genJetsFlavor[imcj] = flavor;
1475           fJetPtMC->Fill(mcjet->Pt());
1476           fJetEtaMC->Fill(mcjet->Eta(),mcjet->Eta());
1477           fJetPhiMC->Fill(mcjet->Phi(),mcjet->Phi());
1478           fFlavor->Fill(flavor,jetPt);
1479           AliDebug(4,Form("Sabor del jet con pt=%f es :%d \n",jetPt,flavor)); 
1480           nTracksPerc = GetNumberOfMcChargedTracks(ntx,mcjet,tracksMC,mcarray,jfr); // este fija el min track pT, si es posible substraer el bckg
1481           if(fIsPossibleToSubstBckg&&!IsEqualRel(fCurrentJetMinPtNT90, 7000.)) //calculating only if there is a perpendicular cone available //IsEqualRel(jetpT, 0.0) //fCurrentJetMinPtNT90!=7000.
1482             {                                                     //and only if the method worked
1483               AliDebug(4,Form("For this jet and I have a perpendicular cone available")); 
1484               // Aqui lo que debo contar es el numero de tracks arriba del min pT del jet correspondiente
1485               // que es fCurrentJetMinPtNT90
1486               nTracksAboveThresholdPerp = GetNMcChargedTracksAboveThreshold(fPerpCone,tracksMC,mcarray,jfr);
1487             }
1488           // Corrected jet (pT)
1489           if(fIsPossibleToSubstBckg)   // for the current jet 
1490             {                                
1491               pTbs= mcjet->Pt()-fPerpCone->Pt();
1492               etabs= mcjet->Eta();
1493               phibs= mcjet->Phi();
1494               fBckgSbsJet[0]=pTbs; //pT
1495               fBckgSbsJet[1]=etabs; //eta
1496               fBckgSbsJet[2]=phibs; //phi
1497               // Now re-calculate nt90 for the energy corrected jet
1498               nTracksPercBckgSubst = GetRecalcNTXMc(ntx,mcjet,tracksMC,mcarray,jfr);
1499               // Now re-calculate the perpendicular cone NT90 background
1500               if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.)) //calculating for the current jet, if the previos method worked //!IsEqualRel(fCurrentJetMinPtNT90, 7000.) //fCurrentJetMinPtNT90Recalc!=7000.
1501                 {
1502                   // Aqui lo que debo contar es el numero de tracks arriba del min pT del jet correspondiente
1503                   // despues de la correccion de energia del jet
1504                   nTrUpThrPerpBckSubs = GetRecalcNMcChTrUpThr(fPerpCone,tracksMC,mcarray,jfr);
1505                 }
1506             }
1507
1508           //check cross sections incoming partons
1509           jetXt= 2*jetPt/fSqrts;
1510           if(evtype==11||evtype==12||evtype==13) //QQ
1511             fFracQQ->Fill(jetXt);
1512           if(evtype==28) //GQ
1513             fFracGQ->Fill(jetXt);
1514           if(evtype==53||evtype==68) //GG
1515             fFracGG->Fill(jetXt);
1516
1517           //check cross sections outgoing partons
1518           if(evtype==11||evtype==12||evtype==53) //QQ
1519             fFracOutGoingQQ->Fill(jetXt);
1520           if(evtype==28) //GQ
1521             fFracOutGoingGQ->Fill(jetXt);
1522           if(evtype==13||evtype==68) //GG
1523             fFracOutGoingGG->Fill(jetXt);
1524
1525           fProcessJetPt->Fill(evtype,jetPt);  // pythia process, filled for each jet in acceptance
1526
1527           //Fill jet flavor as a function of pT and the pythia process but only leading jet
1528           if(imcj==0)  //leading jet
1529             {
1530               fFlavorLead->Fill(flavor,jetPt);
1531               fProcessLeadJetPt->Fill(evtype,jetPt); 
1532             }
1533           AliDebug(4,Form("Before the check of comparison")); 
1534           // To check tracks related to this MC jet
1535           // RefTracks check
1536           Bool_t rTrkFlagMC = kFALSE;
1537           Int_t trkinmcjet = mcjet->GetRefTracks()->GetEntriesFast();
1538           if(trkinmcjet!=0&&!fForceNotTR)
1539             rTrkFlagMC = kTRUE;
1540           AliDebug(4,Form("Number of tracks in RefTracks MC jet:%i \n",trkinmcjet));  
1541           if(rTrkFlagMC)  // If there are tracks refs available
1542             {
1543               AliDebug(4,Form("Checking composition in MC with track refs")); 
1544               for(Int_t aodMCT = 0; aodMCT < trkinmcjet; aodMCT++ )
1545                 {
1546                   pdgOfMCt=0;
1547                   trackxi=0;
1548                   AliAODMCParticle *mctrack = (AliAODMCParticle*) mcjet->GetRefTracks()->At(aodMCT);
1549                   if(!mctrack) continue;
1550                   if(!mctrack->IsPhysicalPrimary()) continue;
1551                   if(mctrack->Charge()==0||mctrack->Charge()==-99) continue;
1552                   if(mctrack->Pt()<fMinpTVal) continue; // MC no cut in the case of track reference, should be in, NO, cut anyhow to be safe
1553                   randomNum = gRandom->Rndm();
1554                   if(randomNum<fJTrackRandomRejection) continue; //rechaza fJTrackRandomRejection
1555                   deltaPhiPt += DeltaPhiMC(mcjet, mctrack)*mctrack->Pt();
1556                   deltaEtaPt += DeltaEtaMC(mcjet, mctrack)*mctrack->Pt();
1557                   deltaPhiSqPt += DeltaPhiSqMC(mcjet, mctrack)*mctrack->Pt();
1558                   deltaEtaSqPt += DeltaEtaSqMC(mcjet, mctrack)*mctrack->Pt();
1559                   totalTrackPt += mctrack->Pt();
1560
1561                   pdgOfMCt=abs(mctrack->GetPdgCode());
1562                   if(!IsEqualRel(mctrack->Pt(), 0.0)) //!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.) // mctrack->Pt()!=0
1563                     trackxi= log(jetPt/mctrack->Pt());
1564                   switch(abs(flavor))
1565                     {
1566                     case 1:
1567                       if(pdgOfMCt==321)
1568                         fFragKaon[0]->Fill(trackxi,jetPt);
1569                       if(pdgOfMCt==211)
1570                         fFragPion[0]->Fill(trackxi,jetPt);
1571                       if(pdgOfMCt==2212)
1572                         fFragProton[0]->Fill(trackxi,jetPt);
1573                       break;
1574                     case 2:
1575                       if(pdgOfMCt==321)
1576                         fFragKaon[1]->Fill(trackxi,jetPt);
1577                       if(pdgOfMCt==211)
1578                         fFragPion[1]->Fill(trackxi,jetPt);
1579                       if(pdgOfMCt==2212)
1580                         fFragProton[1]->Fill(trackxi,jetPt);
1581                       break;
1582                     case 3:
1583                       if(pdgOfMCt==321)
1584                         fFragKaon[2]->Fill(trackxi,jetPt);
1585                       if(pdgOfMCt==211)
1586                         fFragPion[2]->Fill(trackxi,jetPt);
1587                       if(pdgOfMCt==2212)
1588                         fFragProton[2]->Fill(trackxi,jetPt);
1589                       break;
1590                     case 4:
1591                       if(pdgOfMCt==321)
1592                         fFragKaon[3]->Fill(trackxi,jetPt);
1593                       if(pdgOfMCt==211)
1594                         fFragPion[3]->Fill(trackxi,jetPt);
1595                       if(pdgOfMCt==2212)
1596                         fFragProton[3]->Fill(trackxi,jetPt);
1597                       break;
1598                     case 5:
1599                       if(pdgOfMCt==321)
1600                         fFragKaon[4]->Fill(trackxi,jetPt);
1601                       if(pdgOfMCt==211)
1602                         fFragPion[4]->Fill(trackxi,jetPt);
1603                       if(pdgOfMCt==2212)
1604                         fFragProton[4]->Fill(trackxi,jetPt);
1605                       break;
1606                     case 21:
1607                       if(pdgOfMCt==321)
1608                         fFragKaon[5]->Fill(trackxi,jetPt);
1609                       if(pdgOfMCt==211)
1610                         fFragPion[5]->Fill(trackxi,jetPt);
1611                       if(pdgOfMCt==2212)
1612                         fFragProton[5]->Fill(trackxi,jetPt);
1613                       break;          
1614                     default:
1615                       break;
1616                     } // end switch flavor
1617                 }// end loop over AODMC particles of trackrefs
1618               if(!IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) //totalTrackPt!=0.0
1619                 {
1620                   firstMomDeltPhi = deltaPhiPt/totalTrackPt;
1621                   firstMomDeltEta = deltaEtaPt/totalTrackPt;
1622                   secondMomDeltPhi = deltaPhiSqPt/totalTrackPt;
1623                   secondMomDeltEta = deltaEtaSqPt/totalTrackPt;
1624                   secondCentralPhi = secondMomDeltPhi - firstMomDeltPhi*firstMomDeltPhi;
1625                   secondCentralEta = secondMomDeltEta - firstMomDeltEta*firstMomDeltEta;
1626                   secondCentralR = secondCentralPhi + secondCentralEta;
1627                 } // end if totalTrackPt!=0.0
1628               if(IsEqualRel(totalTrackPt, 0.0))  //totalTrackPt==0.0
1629                 secondCentralR = 10.0; //overflow
1630             }// end version with ref tracks (flag check)
1631             
1632           if(!rTrkFlagMC)  // No ref tracks available
1633             {
1634               AliDebug(4,Form("Checking composition in MC without track refs")); 
1635               for(Int_t aodMCT = 0; aodMCT < tracksMC; aodMCT++ )
1636                 {
1637                   pdgOfMCt=0;
1638                   trackxi=0;
1639                   AliAODMCParticle *mctrack = (AliAODMCParticle*) mcarray->At(aodMCT);
1640                   if(!mctrack) continue;
1641                   if(!mctrack->IsPhysicalPrimary()) continue;
1642                   if(mctrack->Charge()==0||mctrack->Charge()==-99) continue;
1643                   if(!IsMCTrackInsideThisJet(mctrack, mcjet, jfr)) continue;
1644                   if(mctrack->Pt()<fMinpTVal) continue; // MC: HERE PT CUT, NO TRACK REF
1645                   randomNum = gRandom->Rndm();
1646                   if(randomNum<fJTrackRandomRejection) continue; //rechaza fJTrackRandomRejection
1647                   deltaPhiPt += DeltaPhiMC(mcjet, mctrack)*mctrack->Pt();
1648                   deltaEtaPt += DeltaEtaMC(mcjet, mctrack)*mctrack->Pt();
1649                   deltaPhiSqPt += DeltaPhiSqMC(mcjet, mctrack)*mctrack->Pt();
1650                   deltaEtaSqPt += DeltaEtaSqMC(mcjet, mctrack)*mctrack->Pt();
1651                   totalTrackPt += mctrack->Pt();
1652
1653                   pdgOfMCt=abs(mctrack->GetPdgCode());
1654                   if(!IsEqualRel(mctrack->Pt(), 0.0)) //!IsEqualRel(mctrack->Pt(), 0.0) // mctrack->Pt()!=0
1655                     trackxi= log(jetPt/mctrack->Pt());
1656                   switch(flavor)
1657                     {
1658                     case 1:
1659                       if(pdgOfMCt==321)
1660                         fFragKaon[0]->Fill(trackxi,jetPt);
1661                       if(pdgOfMCt==211)
1662                         fFragPion[0]->Fill(trackxi,jetPt);
1663                       if(pdgOfMCt==2212)
1664                         fFragProton[0]->Fill(trackxi,jetPt);
1665                       break;
1666                     case 2:
1667                       if(pdgOfMCt==321)
1668                         fFragKaon[1]->Fill(trackxi,jetPt);
1669                       if(pdgOfMCt==211)
1670                         fFragPion[1]->Fill(trackxi,jetPt);
1671                       if(pdgOfMCt==2212)
1672                         fFragProton[1]->Fill(trackxi,jetPt);
1673                       break;
1674                     case 3:
1675                       if(pdgOfMCt==321)
1676                         fFragKaon[2]->Fill(trackxi,jetPt);
1677                       if(pdgOfMCt==211)
1678                         fFragPion[2]->Fill(trackxi,jetPt);
1679                       if(pdgOfMCt==2212)
1680                         fFragProton[2]->Fill(trackxi,jetPt);
1681                       break;
1682                     case 4:
1683                       if(pdgOfMCt==321)
1684                         fFragKaon[3]->Fill(trackxi,jetPt);
1685                       if(pdgOfMCt==211)
1686                         fFragPion[3]->Fill(trackxi,jetPt);
1687                       if(pdgOfMCt==2212)
1688                         fFragProton[3]->Fill(trackxi,jetPt);
1689                       break;
1690                     case 5:
1691                       if(pdgOfMCt==321)
1692                         fFragKaon[4]->Fill(trackxi,jetPt);
1693                       if(pdgOfMCt==211)
1694                         fFragPion[4]->Fill(trackxi,jetPt);
1695                       if(pdgOfMCt==2212)
1696                         fFragProton[4]->Fill(trackxi,jetPt);
1697                       break;
1698                     case 21:
1699                       if(pdgOfMCt==321)
1700                         fFragKaon[5]->Fill(trackxi,jetPt);
1701                       if(pdgOfMCt==211)
1702                         fFragPion[5]->Fill(trackxi,jetPt);
1703                       if(pdgOfMCt==2212)
1704                     fFragProton[5]->Fill(trackxi,jetPt);
1705                       break;          
1706                     default:
1707                       break;
1708                     } // end switch flavor
1709                 }// end loop over AODMC particles
1710               if(!IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPt!=0.0
1711                 {
1712                   firstMomDeltPhi = deltaPhiPt/totalTrackPt;
1713                   firstMomDeltEta = deltaEtaPt/totalTrackPt;
1714                   secondMomDeltPhi = deltaPhiSqPt/totalTrackPt;
1715                   secondMomDeltEta = deltaEtaSqPt/totalTrackPt;
1716                   secondCentralPhi = secondMomDeltPhi - firstMomDeltPhi*firstMomDeltPhi;
1717                   secondCentralEta = secondMomDeltEta - firstMomDeltEta*firstMomDeltEta;
1718                   secondCentralR = secondCentralPhi + secondCentralEta;
1719                 } // end if totalTrackPt!=0.0
1720               if(IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) //totalTrackPt==0.0
1721                 secondCentralR = 10.0; //overflow
1722             } //End old version (no ref tracks)
1723
1724           if(fIsPossibleToSubstBckg)
1725             {
1726               // To make sure, re-initialize
1727               deltaPhiPtPerp = 0.0;
1728               deltaEtaPtPerp = 0.0;
1729               deltaPhiSqPtPerp = 0.0;
1730               deltaEtaSqPtPerp = 0.0;
1731               totalTrackPtPerp = 0.0;
1732               firstMomDeltPhiPerp = 0.0;
1733               firstMomDeltEtaPerp = 0.0;
1734               secondMomDeltPhiPerp = 0.0;
1735               secondMomDeltEtaPerp = 0.0;
1736               secondCentralPhiPerp = 0.0;
1737               secondCentralEtaPerp = 0.0;
1738               secondCentralRPerp = 0.0;
1739
1740               AliDebug(4,Form("Checking SCM in MC for the perpendicular cone")); 
1741               for(Int_t aodMCperp = 0; aodMCperp < tracksMC; aodMCperp++ )
1742                 {
1743                   AliAODMCParticle *mctrackperp = (AliAODMCParticle*) mcarray->At(aodMCperp);
1744                   if(!mctrackperp) continue;
1745                   if(!mctrackperp->IsPhysicalPrimary()) continue;
1746                   if(mctrackperp->Charge()==0||mctrackperp->Charge()==-99) continue;
1747                   if(!IsMCTrackInsideThisJet(mctrackperp, fPerpCone, jfr)) continue;
1748                   if(mctrackperp->Pt()<fMinpTVal) continue; // MC: HERE PT CUT   
1749                   randomNum = gRandom->Rndm();
1750                   if(randomNum<fJTrackRandomRejection) continue; //rechaza fJTrackRandomRejection
1751                   deltaPhiPtPerp += DeltaPhiMC(fPerpCone, mctrackperp)*mctrackperp->Pt();
1752                   deltaEtaPtPerp += DeltaEtaMC(fPerpCone, mctrackperp)*mctrackperp->Pt();
1753                   deltaPhiSqPtPerp += DeltaPhiSqMC(fPerpCone, mctrackperp)*mctrackperp->Pt();
1754                   deltaEtaSqPtPerp += DeltaEtaSqMC(fPerpCone, mctrackperp)*mctrackperp->Pt();
1755                   totalTrackPtPerp += mctrackperp->Pt();
1756                 }// end loop over AODMC particles
1757               if(!IsEqualRel(totalTrackPtPerp, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPtPerp!=0.0
1758                 {
1759                   firstMomDeltPhiPerp = deltaPhiPtPerp/totalTrackPtPerp;
1760                   firstMomDeltEtaPerp = deltaEtaPtPerp/totalTrackPtPerp;
1761                   secondMomDeltPhiPerp = deltaPhiSqPtPerp/totalTrackPtPerp;
1762                   secondMomDeltEtaPerp = deltaEtaSqPtPerp/totalTrackPtPerp;
1763                   secondCentralPhiPerp = secondMomDeltPhiPerp - firstMomDeltPhiPerp*firstMomDeltPhiPerp;
1764                   secondCentralEtaPerp = secondMomDeltEtaPerp - firstMomDeltEtaPerp*firstMomDeltEtaPerp;
1765                   secondCentralRPerp = secondCentralPhiPerp + secondCentralEtaPerp;
1766                 } // end if totalTrackPt!=0.0
1767               if(IsEqualRel(totalTrackPtPerp, 0.0)) //!IsEqualRel(totalTrackPtPerp, 0.0) //totalTrackPtPerp==0.0
1768                 secondCentralRPerp = 10.0; //overflow
1769             }
1770           ///// end of adding the SCM for the perpendicular cone
1771
1772           if(mcjets==1) // if only one jet in the whole event, and inside acceptance
1773             {
1774               // reference multiplicity stuff in pp, also filled in PbPb, but does not matter.
1775               // set to: V0 like corrected multiplicity: correctedV0LikeMult
1776               if(correctedV0LikeMult<25)
1777                 {
1778                   fNChTrRDMultOJMC[0]->Fill(nTracksPerc,jetPt);
1779                   fSCMRDMultOJMC[0]->Fill(secondCentralR,jetPt);
1780                   fJEtaMCMultOJ[0]->Fill(mcjet->Eta());
1781                   fJetPtMCMultOJ[0]->Fill(mcjet->Pt());
1782                 }
1783               if(correctedV0LikeMult>=25&&correctedV0LikeMult<50)
1784                 {
1785                   fNChTrRDMultOJMC[1]->Fill(nTracksPerc,jetPt);
1786                   fSCMRDMultOJMC[1]->Fill(secondCentralR,jetPt);
1787                   fJEtaMCMultOJ[1]->Fill(mcjet->Eta());
1788                   fJetPtMCMultOJ[1]->Fill(mcjet->Pt());
1789                 }
1790               if(correctedV0LikeMult>=50&&correctedV0LikeMult<90)
1791                 {
1792                   fNChTrRDMultOJMC[2]->Fill(nTracksPerc,jetPt);
1793                   fSCMRDMultOJMC[2]->Fill(secondCentralR,jetPt);
1794                   fJEtaMCMultOJ[2]->Fill(mcjet->Eta());
1795                   fJetPtMCMultOJ[2]->Fill(mcjet->Pt());
1796                 }
1797               if(correctedV0LikeMult>=90&&correctedV0LikeMult<120)
1798                 {
1799                   fNChTrRDMultOJMC[3]->Fill(nTracksPerc,jetPt);
1800                   fSCMRDMultOJMC[3]->Fill(secondCentralR,jetPt);
1801                   fJEtaMCMultOJ[3]->Fill(mcjet->Eta());
1802                   fJetPtMCMultOJ[3]->Fill(mcjet->Pt());
1803                 }
1804               if(correctedV0LikeMult>=120&&correctedV0LikeMult<150)
1805                 {
1806                   fNChTrRDMultOJMC[4]->Fill(nTracksPerc,jetPt);
1807                   fSCMRDMultOJMC[4]->Fill(secondCentralR,jetPt);
1808                   fJEtaMCMultOJ[4]->Fill(mcjet->Eta());
1809                   fJetPtMCMultOJ[4]->Fill(mcjet->Pt());
1810                 }
1811               if(correctedV0LikeMult>=150&&correctedV0LikeMult<200)
1812                 {
1813                   fNChTrRDMultOJMC[5]->Fill(nTracksPerc,jetPt);
1814                   fSCMRDMultOJMC[5]->Fill(secondCentralR,jetPt);
1815                   fJEtaMCMultOJ[5]->Fill(mcjet->Eta());
1816                   fJetPtMCMultOJ[5]->Fill(mcjet->Pt());
1817                 }
1818               if(correctedV0LikeMult>=200&&correctedV0LikeMult<300)
1819                 {
1820                   fNChTrRDMultOJMC[6]->Fill(nTracksPerc,jetPt);
1821                   fSCMRDMultOJMC[6]->Fill(secondCentralR,jetPt);
1822                   fJEtaMCMultOJ[6]->Fill(mcjet->Eta());
1823                   fJetPtMCMultOJ[6]->Fill(mcjet->Pt());
1824                 }
1825               if(correctedV0LikeMult>=300)
1826                 {
1827                   fNChTrRDMultOJMC[7]->Fill(nTracksPerc,jetPt);
1828                   fSCMRDMultOJMC[7]->Fill(secondCentralR,jetPt);
1829                   fJEtaMCMultOJ[7]->Fill(mcjet->Eta());
1830                   fJetPtMCMultOJ[7]->Fill(mcjet->Pt());
1831                 }
1832               //Results for inclusive jets
1833               // 2nd. Reference: set to: TPC tracks minus jet, minus dijet area
1834               if(softRefMcNoJets<5)
1835                 {
1836                   fNChTrRDMultSEOJMC[0]->Fill(nTracksPerc,jetPt);
1837                   fSCMRDMultSEOJMC[0]->Fill(secondCentralR,jetPt);
1838                   fJEtaMCMultSEOJ[0]->Fill(mcjet->Eta());
1839                   fJetPtMCMultSEOJ[0]->Fill(mcjet->Pt());
1840                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1841                     fEntriesQuark[0]->Fill(nTracksPerc,jetPt);
1842                   if(abs(flavor)==21) //if gluon jet
1843                     fEntriesGluon[0]->Fill(nTracksPerc,jetPt);
1844                 }
1845               if(softRefMcNoJets>=5&&softRefMcNoJets<10)
1846                 {
1847                   fNChTrRDMultSEOJMC[1]->Fill(nTracksPerc,jetPt);
1848                   fSCMRDMultSEOJMC[1]->Fill(secondCentralR,jetPt);
1849                   fJEtaMCMultSEOJ[1]->Fill(mcjet->Eta());
1850                   fJetPtMCMultSEOJ[1]->Fill(mcjet->Pt()); 
1851                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1852                     fEntriesQuark[1]->Fill(nTracksPerc,jetPt);
1853                   if(abs(flavor)==21) //if gluon jet
1854                     fEntriesGluon[1]->Fill(nTracksPerc,jetPt);
1855                 }
1856               if(softRefMcNoJets>=10&&softRefMcNoJets<15)
1857                 {
1858                   fNChTrRDMultSEOJMC[2]->Fill(nTracksPerc,jetPt);
1859                   fSCMRDMultSEOJMC[2]->Fill(secondCentralR,jetPt);
1860                   fJEtaMCMultSEOJ[2]->Fill(mcjet->Eta());
1861                   fJetPtMCMultSEOJ[2]->Fill(mcjet->Pt());
1862                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1863                     fEntriesQuark[2]->Fill(nTracksPerc,jetPt);
1864                   if(abs(flavor)==21) //if gluon jet
1865                     fEntriesGluon[2]->Fill(nTracksPerc,jetPt);
1866                 }
1867               if(softRefMcNoJets>=15&&softRefMcNoJets<20)
1868                 {
1869                   fNChTrRDMultSEOJMC[3]->Fill(nTracksPerc,jetPt);
1870                   fSCMRDMultSEOJMC[3]->Fill(secondCentralR,jetPt);
1871                   fJEtaMCMultSEOJ[3]->Fill(mcjet->Eta());
1872                   fJetPtMCMultSEOJ[3]->Fill(mcjet->Pt());
1873                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1874                     fEntriesQuark[3]->Fill(nTracksPerc,jetPt);
1875                   if(abs(flavor)==21) //if gluon jet
1876                     fEntriesGluon[3]->Fill(nTracksPerc,jetPt);
1877                 }
1878               if(softRefMcNoJets>=20&&softRefMcNoJets<30)
1879                 {
1880                   fNChTrRDMultSEOJMC[4]->Fill(nTracksPerc,jetPt);
1881                   fSCMRDMultSEOJMC[4]->Fill(secondCentralR,jetPt);
1882                   fJEtaMCMultSEOJ[4]->Fill(mcjet->Eta());
1883                   fJetPtMCMultSEOJ[4]->Fill(mcjet->Pt());
1884                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1885                     fEntriesQuark[4]->Fill(nTracksPerc,jetPt);
1886                   if(abs(flavor)==21) //if gluon jet
1887                     fEntriesGluon[4]->Fill(nTracksPerc,jetPt);
1888                 }
1889               if(softRefMcNoJets>=30&&softRefMcNoJets<40)
1890                 {
1891                   fNChTrRDMultSEOJMC[5]->Fill(nTracksPerc,jetPt);
1892                   fSCMRDMultSEOJMC[5]->Fill(secondCentralR,jetPt);
1893                   fJEtaMCMultSEOJ[5]->Fill(mcjet->Eta());
1894                   fJetPtMCMultSEOJ[5]->Fill(mcjet->Pt());
1895                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1896                     fEntriesQuark[5]->Fill(nTracksPerc,jetPt);
1897                   if(abs(flavor)==21) //if gluon jet
1898                     fEntriesGluon[5]->Fill(nTracksPerc,jetPt);
1899                 }
1900               if(softRefMcNoJets>=40&&softRefMcNoJets<50)
1901                 {
1902                   fNChTrRDMultSEOJMC[6]->Fill(nTracksPerc,jetPt);
1903                   fSCMRDMultSEOJMC[6]->Fill(secondCentralR,jetPt);
1904                   fJEtaMCMultSEOJ[6]->Fill(mcjet->Eta());
1905                   fJetPtMCMultSEOJ[6]->Fill(mcjet->Pt());
1906                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1907                     fEntriesQuark[6]->Fill(nTracksPerc,jetPt);
1908                   if(abs(flavor)==21) //if gluon jet
1909                     fEntriesGluon[6]->Fill(nTracksPerc,jetPt);
1910                 }
1911               if(softRefMcNoJets>=50)
1912                 {           
1913                   fNChTrRDMultSEOJMC[7]->Fill(nTracksPerc,jetPt);
1914                   fSCMRDMultSEOJMC[7]->Fill(secondCentralR,jetPt);
1915                   fJEtaMCMultSEOJ[7]->Fill(mcjet->Eta());
1916                   fJetPtMCMultSEOJ[7]->Fill(mcjet->Pt());
1917                   if(abs(flavor)==1||abs(flavor)==2||abs(flavor)==3||abs(flavor)==4||abs(flavor)==5) //if quark jet
1918                     fEntriesQuark[7]->Fill(nTracksPerc,jetPt);
1919                   if(abs(flavor)==21) //if gluon jet
1920                     fEntriesGluon[7]->Fill(nTracksPerc,jetPt);
1921                 }
1922             }
1923           //End results for inclusive jets,starts parton by parton
1924           
1925           switch(abs(flavor))
1926             {
1927             case 1:
1928               fNChTr[0]->Fill(nTracksPerc,jetPt);
1929               fProcessPDG[0]->Fill(jetPt,evtype);
1930               fHistPtParton[0]->Fill(jetPt);
1931               fSCM[0]->Fill(secondCentralR,jetPt);
1932               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
1933               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
1934               if(fIsPossibleToSubstBckg)
1935                 {
1936                   fNChTrCorrMCQuark->Fill(nTracksPercBckgSubst,pTbs); 
1937                   fSCMMCPerp->Fill(secondCentralR,jetPt);
1938                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.)) //!IsEqualRel(mctrack->Pt(), 0.0) // fCurrentJetMinPtNT90!=7000.
1939                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
1940                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.)) // !IsEqualRel(fCurrentJetMinPtNT90, 7000.) // fCurrentJetMinPtNT90Recalc!=7000.
1941                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
1942                 }
1943               break;
1944             case 2:
1945               fNChTr[1]->Fill(nTracksPerc,jetPt);
1946               fProcessPDG[1]->Fill(jetPt,evtype);
1947               fHistPtParton[1]->Fill(jetPt);
1948               fSCM[1]->Fill(secondCentralR,jetPt);
1949               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
1950               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
1951               if(fIsPossibleToSubstBckg)
1952                 {
1953                   fNChTrCorrMCQuark->Fill(nTracksPercBckgSubst,pTbs); 
1954                   fSCMMCPerp->Fill(secondCentralR,jetPt);
1955                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
1956                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
1957                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
1958                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
1959                 }
1960               break;
1961             case 3:
1962               fNChTr[2]->Fill(nTracksPerc,jetPt);
1963               fProcessPDG[2]->Fill(jetPt,evtype);
1964               fHistPtParton[2]->Fill(jetPt);
1965               fSCM[2]->Fill(secondCentralR,jetPt);
1966               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
1967               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
1968               if(fIsPossibleToSubstBckg)
1969                 {
1970                   fNChTrCorrMCQuark->Fill(nTracksPercBckgSubst,pTbs); 
1971                   fSCMMCPerp->Fill(secondCentralR,jetPt);
1972                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
1973                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
1974                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
1975                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
1976                 }
1977               break;
1978             case 4:
1979               fNChTr[3]->Fill(nTracksPerc,jetPt);
1980               fProcessPDG[3]->Fill(jetPt,evtype);
1981               fHistPtParton[3]->Fill(jetPt);
1982               fSCM[3]->Fill(secondCentralR,jetPt);
1983               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
1984               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
1985               if(fIsPossibleToSubstBckg)
1986                 {
1987                   fNChTrCorrMCQuark->Fill(nTracksPercBckgSubst,pTbs); 
1988                   fSCMMCPerp->Fill(secondCentralR,jetPt);
1989                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
1990                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
1991                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
1992                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
1993                 }
1994               break;
1995             case 5:
1996               fNChTr[4]->Fill(nTracksPerc,jetPt);
1997               fProcessPDG[4]->Fill(jetPt,evtype);
1998               fHistPtParton[4]->Fill(jetPt);
1999               fSCM[4]->Fill(secondCentralR,jetPt);
2000               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
2001               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
2002               if(fIsPossibleToSubstBckg)
2003                 {
2004                   fNChTrCorrMCQuark->Fill(nTracksPercBckgSubst,pTbs); 
2005                   fSCMMCPerp->Fill(secondCentralR,jetPt);
2006                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2007                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
2008                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
2009                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
2010                 }
2011               break;
2012             case 21:
2013               fNChTr[5]->Fill(nTracksPerc,jetPt);
2014               fProcessPDG[5]->Fill(jetPt,evtype);
2015               fHistPtParton[5]->Fill(jetPt);
2016               fSCM[5]->Fill(secondCentralR,jetPt);
2017               fMinTrackPtInNTXh[0]->Fill(fMinTrackPtInNTX,jetPt,1); // 0 for pp MC
2018               fMaxTrackPtInNTXh[0]->Fill(fMaxTrackPtInNTX,jetPt); // 0 for MC
2019               if(fIsPossibleToSubstBckg)
2020                 {
2021                   fNChTrCorrMCGluon->Fill(nTracksPercBckgSubst,pTbs); 
2022                   fSCMMCPerp->Fill(secondCentralR,jetPt);
2023                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2024                     fNChTrMCPerp->Fill(nTracksAboveThresholdPerp,jetPt);
2025                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
2026                     fNChTrCorrMCPerp->Fill(nTrUpThrPerpBckSubs,pTbs);
2027                 }
2028               break;          
2029             default:
2030               break;
2031             }
2032           AliDebug(4,Form("Sabor del jet numero:%d es: %d y se necesitaron %d tracks \n",indxmc,flavor,nTracksPerc)); 
2033           imcj++;
2034         } // MC jets for cycle
2035       nGenJets=imcj;
2036       for(Int_t u=0 ; u<mcJetCounter  ;u++)
2037         {
2038           if(u<7)
2039             fJetsMultPtMC->Fill(jetPts[u],mcJetCounter);
2040         }
2041       // if(fEnablePrints)
2042       //  {
2043       //   if(mcJetCounter>=3)
2044       //    printf("%i Jets inside acceptance at event number:%i \n",mcJetCounter,fEvtCount-1);
2045       //  }
2046       fNAccJetsMC->Fill(mcJetCounter,mcJetCounter);
2047     } // end if MC info in AOD
2048   
2049   if(!fUseOnlyMC) 
2050     {  
2051       // Primero que todo, debe de ir la seleccion de eventos reconstruidos:
2052       // 1. Que tenga un vertice reconstruido dentro de 10 cm.
2053       // Vertex info for reconstructed events
2054       AliAODVertex *pvx = fAOD->GetPrimaryVertex();
2055       if(!pvx)
2056         {
2057           AliError("No primary vertex!");
2058           return;
2059         }
2060       if(TMath::Abs(pvx->GetZ())>10.) // if the event vertex is larger than 10 cm, reject
2061         return;
2062       fZVertex->Fill(pvx->GetZ(),pvx->GetZ()); // vertex, provide number of accepted events as entries for reco jets
2063
2064       ///////////////////////////////////////
2065       // SECONDARY RECO BRANCH STUFF       // 
2066       // Get the secondary branch with the reconstructed jets 
2067       if(fBranchSecRec!="")
2068         {
2069           AliDebug(4,Form("fBranchSecRec was not default \n")); 
2070           TClonesArray *aodSecRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchSecRec.Data()));
2071           if(!aodSecRecJets)
2072             {
2073               AliError(Form("%s:%d no reconstructed Secondary Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchSecRec.Data())); 
2074               return;  //stop the analysis
2075             }
2076           AliDebug(4,Form("There are %d reconstructed jets from the secondary branch in this event \n", aodSecRecJets->GetEntries())); 
2077           Int_t recojetsSEC =  aodSecRecJets->GetEntries();
2078           fNJetsRDSeco->Fill(recojetsSEC,recojetsSEC);  // number of jets in the secondary branch
2079
2080           HasOverlapedCones(aodSecRecJets); // Procedure for tagging usable jets
2081                                             // Up 16 jets are flagged
2082           
2083           AliDebug(4,"Antes de realizar el loop jets reconstruidos del segundo branch \n"); 
2084           Int_t secondjetacccounter = 0;
2085           for (Int_t IDXS = 0; IDXS < recojetsSEC; IDXS++) 
2086             {
2087               AliDebug(4,Form("Number of current jet:%i \n",IDXS));
2088               AliAODJet *rjetsec = dynamic_cast<AliAODJet*>(aodSecRecJets->At(IDXS));
2089               if (!rjetsec) 
2090                 {
2091                   AliDebug(2,Form("ERROR: Could not receive jet %d from the second branch\n", IDXS)); 
2092                   continue;
2093                 }
2094               
2095               ///////////////////////////////////////////////////////////////////////////////
2096               ///// Part for Chritians plot of inclusive and leading jets comp at 2.76 TeV //
2097               if(!IsInsideAcceptance(rjetsec))  // old condition
2098                 continue;
2099               if(IDXS==0) // leading jet
2100                 fSecRecJetPtLeading->Fill(rjetsec->Pt());
2101               fSecRecJetPtInclusive->Fill(rjetsec->Pt()); // all
2102               ///// End of Christians Plot reco 2nd branch
2103               ///////////////////////////////////////////////////////////////////////////////
2104
2105               if(IDXS>15)
2106                 continue;
2107
2108               if(!fJetFlags[IDXS]) // If the jet is flaged kFALSE, not usable
2109                 continue;
2110
2111               fJetPtSec->Fill(rjetsec->Pt());
2112               fJetEtaSec->Fill(rjetsec->Eta(),rjetsec->Eta());
2113               fJetPhiSec->Fill(rjetsec->Phi(),rjetsec->Phi());
2114               secondjetacccounter++;
2115             }
2116           fNAccJetsRDSeco->Fill(secondjetacccounter,secondjetacccounter);
2117         }
2118       // END OF SECONDARY BRANCH STUFF     //
2119       ///////////////////////////////////////
2120
2121       // Get the branch with the reconstructed jets
2122       TClonesArray *aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRec.Data()));
2123       if(!aodRecJets)
2124         {
2125           AliError(Form("%s:%d no reconstructed Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchRec.Data())); 
2126           return;
2127         }
2128       
2129       AliDebug(4,Form("There are %d reconstructed jets in this event\n", aodRecJets->GetEntries())); 
2130       Int_t recojets =  aodRecJets->GetEntries();
2131       fNJetsRD->Fill(recojets,recojets); // numero de jets directamente del branch
2132
2133       HasOverlapedCones(aodRecJets); // Procedure for tagging usable jets
2134                                     // Up 16 jets are flagged
2135
2136       AliDebug(4,"Antes de realizar el loop sobre AOD tracks \n"); 
2137       // Loop over AOD tracks
2138       Int_t tracksAOD = fAOD->GetNumberOfTracks(); 
2139       AliDebug(4,Form("Numero de tracks en el AOD:%d \n",tracksAOD));
2140       Double_t aodtracketa = 0.0;
2141       perpendicularPt = 0.0;
2142       px=0.0;
2143       py=0.0;
2144       pz=0.0;
2145       en=0.0;
2146       pTbs=0.0;
2147       etabs=0.0;
2148       phibs=0.0;
2149       fBckgSbsJet[0]=0.0;
2150       fBckgSbsJet[1]=0.0;
2151       fBckgSbsJet[2]=0.0;
2152       Int_t refNJMult = 0;
2153       Int_t myTotalMultRef = 0; 
2154       Int_t myTotalSoftMultRef = 0; 
2155       for(Int_t aodT = 0; aodT < tracksAOD; aodT++ )
2156         {
2157           AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(aodT));
2158           if(!aodtrack) AliFatal("Not a standard AOD");
2159           if(!aodtrack) continue;
2160           aodtracketa = TMath::Abs(aodtrack->Eta());
2161           if(aodtracketa>0.9) continue;
2162           if(!aodtrack->TestFilterBit(fFilterBit)) continue; //track filter selection
2163           fEtaAOD->Fill(aodtrack->Eta(),aodtrack->Eta());
2164           fPhiAOD->Fill(aodtrack->Phi(),aodtrack->Phi());
2165           fPtAOD->Fill(aodtrack->Pt(),aodtrack->Pt());
2166           if(fJetEvent) // if has an accepted jet, calculate the perpendicular cone
2167             {
2168               if(HasPerpendicularCone()) // If there is a perpendicular cone available
2169                 {
2170                   if(aodtrack->Pt()>fMinpTVal)
2171                     {
2172                       if(GetDeltaR(fEtaPerpCoord,fPhiPerpCoord,aodtrack->Eta(),aodtrack->Phi())<fJetRadius)
2173                         perpendicularPt = perpendicularPt + aodtrack->Pt();
2174                     }
2175                 }
2176             } // end if jet event
2177           //Total TPC multiplicity of primaries
2178           if(aodtrack->Pt()>fMinPtInGlobMult) // Min pT used in multiplicity estimation
2179             {
2180               myTotalMultRef++;
2181               if(aodtrack->Pt()<fMinpTValUE) continue; // pT cut  fMinpTValUE
2182               if(aodtrack->Pt()>fMaxpTValUE) continue; // pT cut  fMaxpTValUE
2183               myTotalSoftMultRef++;  
2184               if(!IsTrackInsideExcludedArea(aodtrack->Eta(), aodtrack->Phi(), aodRecJets)) 
2185                 refNJMult++;
2186             }
2187         } // end track loop over the event...
2188
2189       fRefMultWOJet->Fill(refMultiplicity,refNJMult); 
2190       fMultWOJetVZero->Fill(refNJMult,multFullV0);
2191       Double_t v0CorrMult = multFullV0 - GetV0ExcludedMultiplicity(aodRecJets);
2192       fRefMultFullV0->Fill(refMultiplicity,multFullV0);
2193       fRefMultV0Corr->Fill(refMultiplicity,v0CorrMult);
2194       fFullV0V0Corr->Fill(multFullV0,v0CorrMult);
2195       fRefAODTrackCount->Fill(refMultiplicity,myTotalMultRef);
2196       fTrackCountWOJet->Fill(myTotalMultRef,refNJMult);
2197
2198       if(recojets==1) // correlation for only monojet events
2199         {
2200           fRefMultFullV0UJ->Fill(refMultiplicity,multFullV0);
2201           fRefMultV0CorrUJ->Fill(refMultiplicity,v0CorrMult);
2202           fFullV0V0CorrUJ->Fill(multFullV0,v0CorrMult);
2203           fMultWOJetVZeroUJ->Fill(refNJMult,multFullV0);
2204           fRefMultWOJetUJ->Fill(refMultiplicity,refNJMult);
2205           fRefAODTrackCountUJ->Fill(refMultiplicity,myTotalMultRef);
2206           fTrackCountWOJetUJ->Fill(myTotalMultRef,refNJMult); 
2207         }
2208
2209       if(fJetEvent) // if has an accepted jet, calculate the perpendicular cone
2210         {
2211           if(HasPerpendicularCone()) // If there is a perpendicular cone available
2212             {
2213               px = perpendicularPt*TMath::Cos(fPhiPerpCoord);
2214               py = perpendicularPt*TMath::Sin(fPhiPerpCoord);
2215               pz = perpendicularPt/TMath::Tan(2.0*TMath::ATan(TMath::Exp(-fEtaPerpCoord)));
2216               en = TMath::Sqrt(px*px + py*py + pz*pz);
2217               fPerpCone->SetPxPyPzE(px, py, pz, en);
2218             }
2219         }
2220             
2221       // Loop to fill a pT spectrum of the reco jets
2222       Int_t irecj=0; // index for reconstructed jets to correlate
2223       Int_t nrectracks[6]={0};
2224       Double_t ptrecjet[6]={0};
2225       Double_t scmr[6]={0};
2226       Double_t aodtrackxi=0;
2227       Int_t ntxreco;
2228       Int_t nTRecAboveThresholdPerp=0; 
2229       Int_t ntxrecoRecalc;
2230       Int_t nTRecAboveThresholdPerpRecalc=0; 
2231             
2232       for(Int_t i=0; i<6; i++) // Reset per event
2233         {
2234           fHistContainerR4[i]->Reset();
2235           fHistContainerR3[i]->Reset();
2236           fHistContainerR2[i]->Reset();
2237         }
2238       
2239       Double_t jetPtsR[7]={0};  // to store the pt of the jets
2240       Int_t rJetCounter=0;    // counter of accepted reco jets 
2241       fIsPossibleToSubstBckg = kTRUE; // Initialize before the loop
2242       if(fJetEvent) // si tiene jets validos
2243         {
2244           if(!HasPerpendicularCone()) // pero no encontro un cono perpendicular libre
2245             fIsPossibleToSubstBckg = kFALSE; // if not perpendicular cone, set to kFALSE, so no perpendicular calculations available
2246         }
2247       
2248       AliDebug(4,"Antes de realizar el loop jets reconstruidos \n"); 
2249       for (Int_t indxrec = 0; indxrec < recojets; indxrec++) 
2250         {
2251           AliDebug(4,Form("Number of current jet:%i \n",indxrec));
2252           ntxreco = 0;
2253           ntxrecoRecalc = 0;
2254           fMinTrackPtInNTX=200.0;  //Initialize for each jet, overflown
2255           fMaxTrackPtInNTX=200.0;  //Initialize for each jet, overflown
2256           fMinTrackPtInNTXR=200.0;  //Initialize for each jet, overflown
2257           fMaxTrackPtInNTXR=200.0;  //Initialize for each jet, overflown
2258           deltaPhiPt = 0.0;
2259           deltaEtaPt = 0.0;
2260           deltaPhiSqPt = 0.0;
2261           deltaEtaSqPt = 0.0;
2262           totalTrackPt = 0.0;
2263           firstMomDeltPhi = 0.0;
2264           firstMomDeltEta = 0.0;
2265           secondMomDeltPhi = 0.0;
2266           secondMomDeltEta = 0.0;
2267           secondCentralPhi = 0.0;
2268           secondCentralEta = 0.0;
2269           secondCentralR = 0.0;
2270           fTotTracksInCone=0; // Underflown at initialization per jet
2271
2272           AliAODJet *rjet = dynamic_cast<AliAODJet*>(aodRecJets->At(indxrec));
2273           if (!rjet) 
2274             {
2275               AliDebug(2,Form("ERROR: Could not receive jet %d\n", indxrec)); 
2276               continue;
2277             }
2278           fJetEtaAll->Fill(rjet->Eta());// all jets
2279
2280           ///////////////////////////////////////////////////////////////////////////////
2281           ///// Part for Chritians plot of inclusive and leading jets comp at 2.76 TeV //
2282           if(!IsInsideAcceptance(rjet))  // old condition
2283             continue;
2284           if(indxrec==0) // leading jet
2285             fRecJetPtLeading->Fill(rjet->Pt());
2286           fRecJetPtInclusive->Fill(rjet->Pt()); // all
2287           fJetEtaOnlyTPCcut->Fill(rjet->Eta());// only eta acceptance cut for TPC
2288           ///// End of Christians Plot reco
2289           ///////////////////////////////////////////////////////////////////////////////
2290
2291           if(indxrec>15)
2292             continue;
2293
2294           if(!fJetFlags[indxrec]) // If the jet is flaged kFALSE, not usable
2295             continue;
2296           
2297           AliDebug(4,Form("Jet #%i is in the acceptance \n",indxrec));
2298           if(rJetCounter<7)
2299             jetPtsR[rJetCounter]=rjet->Pt();
2300           rJetCounter++;
2301           fJetPt->Fill(rjet->Pt());
2302           fJetEta->Fill(rjet->Eta(),rjet->Eta());
2303           fJetPhi->Fill(rjet->Phi(),rjet->Phi());
2304
2305           if(rjet->Pt()>10.)
2306             fJetEtaJetPt[0]->Fill(rjet->Eta());
2307           if(rjet->Pt()>30.)
2308             fJetEtaJetPt[1]->Fill(rjet->Eta());
2309           if(rjet->Pt()>50.)
2310             fJetEtaJetPt[2]->Fill(rjet->Eta());
2311           
2312           // Reco RefTracks check
2313           Bool_t rTrkFlagRec = kFALSE;
2314           Int_t trkinrecjet = rjet->GetRefTracks()->GetEntriesFast();
2315           if(trkinrecjet!=0&&!fForceNotTR)
2316             rTrkFlagRec = kTRUE;
2317           AliDebug(4,Form("Number of tracks in RefTracks reco jet:%i \n",trkinrecjet));
2318           if(rTrkFlagRec)
2319             {
2320               // Check the properties of the tracks in this jet with track refs
2321               AliDebug(4,Form("Checking composition in Reco jets with track refs")); 
2322               for(Int_t aodT = 0; aodT <trkinrecjet; aodT++ )
2323                 {
2324                   aodtrackxi=0;
2325                   AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(rjet->GetRefTracks()->At(aodT));
2326                   if(!aodtrack)
2327                     {
2328                       AliError("Error, no AOD Track!");
2329                       continue;
2330                     }
2331                   if(!aodtrack->TestFilterBit(fFilterBit))
2332                     {
2333                       //                      printf("Rejecting track from track refs due to wrong filterbit! \n");
2334                       continue; //track filter selection
2335                     }
2336                   deltaPhiPt += DeltaPhiTrack(rjet, aodtrack)*aodtrack->Pt();
2337                   deltaEtaPt += DeltaEtaTrack(rjet, aodtrack)*aodtrack->Pt();
2338                   deltaPhiSqPt += DeltaPhiSqTrack(rjet, aodtrack)*aodtrack->Pt();
2339                   deltaEtaSqPt += DeltaEtaSqTrack(rjet, aodtrack)*aodtrack->Pt();
2340                   totalTrackPt += aodtrack->Pt();
2341                   fTotTracksInCone++; // Counting tracks                  
2342                   if(!IsEqualRel(aodtrack->Pt(), 0.0)) //!IsEqualRel(totalTrackPtPerp, 0.0) //aodtrack->Pt()!=0
2343                     aodtrackxi= log(rjet->Pt()/aodtrack->Pt());
2344                   if(irecj<maxJetNum)
2345                     {
2346                       fHistContainerR4[irecj]->Fill(aodtrackxi,rjet->Pt());
2347                       if(!IsTrackInsideThisJet(aodtrack, rjet, 0.3)) continue;
2348                       fHistContainerR3[irecj]->Fill(aodtrackxi,rjet->Pt());
2349                       if(!IsTrackInsideThisJet(aodtrack, rjet, 0.2)) continue;
2350                       fHistContainerR2[irecj]->Fill(aodtrackxi,rjet->Pt());
2351                     }       
2352                 } //end loop over track references
2353               if(!IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0)  // totalTrackPt!=0.0
2354                 {
2355                   firstMomDeltPhi = deltaPhiPt/totalTrackPt;
2356                   firstMomDeltEta = deltaEtaPt/totalTrackPt;
2357                   secondMomDeltPhi = deltaPhiSqPt/totalTrackPt;
2358                   secondMomDeltEta = deltaEtaSqPt/totalTrackPt;
2359                   secondCentralPhi = secondMomDeltPhi - firstMomDeltPhi*firstMomDeltPhi;
2360                   secondCentralEta = secondMomDeltEta - firstMomDeltEta*firstMomDeltEta;
2361                   secondCentralR = secondCentralPhi + secondCentralEta;
2362                 } // end if totalTrackPt!=0.0
2363               if(IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPt==0.0
2364                 secondCentralR = 10.0; //overflow value
2365             } // end if there are track references
2366           
2367           if(!rTrkFlagRec)
2368             {
2369               // Check properties of the tracks in this jet without track refs
2370               AliDebug(4,Form("Checking composition in Reco jets without track refs")); 
2371               for(Int_t aodT = 0; aodT < tracksAOD; aodT++ )
2372                 {
2373                   AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(aodT));
2374                   if(!aodtrack) AliFatal("Not a standard AOD");
2375                   if(!aodtrack) continue;
2376                   if(!IsTrackInsideThisJet(aodtrack, rjet, jfr)) continue;
2377                   if(!aodtrack->TestFilterBit(fFilterBit)) continue; //track filter selection
2378                   if(aodtrack->Pt()<fMinpTVal) continue; //DATA: PT CUT
2379                   deltaPhiPt += DeltaPhiTrack(rjet, aodtrack)*aodtrack->Pt();
2380                   deltaEtaPt += DeltaEtaTrack(rjet, aodtrack)*aodtrack->Pt();
2381                   deltaPhiSqPt += DeltaPhiSqTrack(rjet, aodtrack)*aodtrack->Pt();
2382                   deltaEtaSqPt += DeltaEtaSqTrack(rjet, aodtrack)*aodtrack->Pt();
2383                   totalTrackPt += aodtrack->Pt();
2384                   fTotTracksInCone++; // Counting tracks          
2385                   if(!IsEqualRel(aodtrack->Pt(), 0.0)) //!IsEqualRel(totalTrackPt, 0.0) //aodtrack->Pt()!=0
2386                     aodtrackxi= log(rjet->Pt()/aodtrack->Pt());
2387                   if(irecj<maxJetNum)
2388                     {
2389                       fHistContainerR4[irecj]->Fill(aodtrackxi,rjet->Pt());
2390                       if(!IsTrackInsideThisJet(aodtrack, rjet, 0.3)) continue;
2391                       fHistContainerR3[irecj]->Fill(aodtrackxi,rjet->Pt());
2392                       if(!IsTrackInsideThisJet(aodtrack, rjet, 0.2)) continue;
2393                       fHistContainerR2[irecj]->Fill(aodtrackxi,rjet->Pt());
2394                     }
2395                 } // end loop over tracks
2396               if(!IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) //totalTrackPt!=0.0
2397                 {
2398                   firstMomDeltPhi = deltaPhiPt/totalTrackPt;
2399                   firstMomDeltEta = deltaEtaPt/totalTrackPt;
2400                   secondMomDeltPhi = deltaPhiSqPt/totalTrackPt;
2401                   secondMomDeltEta = deltaEtaSqPt/totalTrackPt;
2402                   secondCentralPhi = secondMomDeltPhi - firstMomDeltPhi*firstMomDeltPhi;
2403                   secondCentralEta = secondMomDeltEta - firstMomDeltEta*firstMomDeltEta;
2404                   secondCentralR = secondCentralPhi + secondCentralEta;
2405                 } // end if totalTrackPt!=0.0 
2406               if(IsEqualRel(totalTrackPt, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPt==0.0
2407                 secondCentralR = 10.0; //overflow value
2408             } // end of no track references
2409           //Esto es lo anterior, toma al jet como es, y calcula NT90      
2410           ntxreco=GetNumberOfChargedTracks(ntx,rjet, tracksAOD, fAOD, jfr); // this call fixes the minimum pT track
2411           //Y aqui calcula cuantos tracks se necesitan arriba del threshold establecido en la linea anterior
2412           //esto debe ser para cada jet. Lo unico que se calcula una sola vez es el cono perpendicular  
2413           if(fIsPossibleToSubstBckg&&!IsEqualRel(fCurrentJetMinPtNT90, 7000.)) //and only if the method worked
2414             nTRecAboveThresholdPerp = GetNRecChargedTracksAboveThreshold(fPerpCone,tracksAOD, fAOD,jfr); //here one changes NTX
2415
2416           // correct the jet pT
2417           if(fIsPossibleToSubstBckg) // If there is a perpendicular cone available, substract backg and fill the new jet pT
2418             {
2419               pTbs= rjet->Pt()-fPerpCone->Pt();
2420               etabs= rjet->Eta();
2421               phibs= rjet->Phi();
2422               fBckgSbsJet[0]=pTbs; //pT
2423               fBckgSbsJet[1]=etabs; //eta
2424               fBckgSbsJet[2]=phibs; //phi
2425               // Now re-calculate nt90 for the energy corrected jet
2426               ntxrecoRecalc = GetRecalcNTXRec(ntx,rjet, tracksAOD, fAOD, jfr); //This call saves the new min pT
2427               // Now re-calculate the perpendicular cone NT90 background
2428               if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.)) //calculating for the current jet, if the previous method worked
2429                 nTRecAboveThresholdPerpRecalc = GetRecalcNRecChTrUpThr(fPerpCone,tracksAOD, fAOD,jfr);
2430             }
2431
2432           // SCM perpendicular cone
2433           if(fIsPossibleToSubstBckg)
2434             {
2435               // To make sure, re-initialize
2436               deltaPhiPtPerp = 0.0;
2437               deltaEtaPtPerp = 0.0;
2438               deltaPhiSqPtPerp = 0.0;
2439               deltaEtaSqPtPerp = 0.0;
2440               totalTrackPtPerp = 0.0;
2441               firstMomDeltPhiPerp = 0.0;
2442               firstMomDeltEtaPerp = 0.0;
2443               secondMomDeltPhiPerp = 0.0;
2444               secondMomDeltEtaPerp = 0.0;
2445               secondCentralPhiPerp = 0.0;
2446               secondCentralEtaPerp = 0.0;
2447               secondCentralRPerp = 0.0;
2448               AliDebug(4,Form("Checking SCM of perpendicular cone in Reco jets")); 
2449               for(Int_t aodTperp = 0; aodTperp < tracksAOD; aodTperp++ )
2450                 { //fPerpCone
2451                   AliAODTrack *aodtrackperprec = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(aodTperp));
2452                   if(!aodtrackperprec) AliFatal("Not a standard AOD");
2453                   if(!aodtrackperprec) continue;
2454                   if(!IsTrackInsideThisJet(aodtrackperprec, fPerpCone, jfr)) continue;
2455                   if(!aodtrackperprec->TestFilterBit(fFilterBit)) continue; //track filter selection
2456                   if(aodtrackperprec->Pt()<fMinpTVal) continue; //DATA: PT CUT
2457                   deltaPhiPtPerp += DeltaPhiTrack(fPerpCone, aodtrackperprec)*aodtrackperprec->Pt();
2458                   deltaEtaPtPerp += DeltaEtaTrack(fPerpCone, aodtrackperprec)*aodtrackperprec->Pt();
2459                   deltaPhiSqPtPerp += DeltaPhiSqTrack(fPerpCone, aodtrackperprec)*aodtrackperprec->Pt();
2460                   deltaEtaSqPtPerp += DeltaEtaSqTrack(fPerpCone, aodtrackperprec)*aodtrackperprec->Pt();
2461                   totalTrackPtPerp += aodtrackperprec->Pt();
2462                 } // end loop over tracks
2463               if(!IsEqualRel(totalTrackPtPerp, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPtPerp!=0.0
2464                 {
2465                   firstMomDeltPhiPerp = deltaPhiPtPerp/totalTrackPtPerp;
2466                   firstMomDeltEtaPerp = deltaEtaPtPerp/totalTrackPtPerp;
2467                   secondMomDeltPhiPerp = deltaPhiSqPtPerp/totalTrackPtPerp;
2468                   secondMomDeltEtaPerp = deltaEtaSqPtPerp/totalTrackPtPerp;
2469                   secondCentralPhiPerp = secondMomDeltPhiPerp - firstMomDeltPhiPerp*firstMomDeltPhiPerp;
2470                   secondCentralEtaPerp = secondMomDeltEtaPerp - firstMomDeltEtaPerp*firstMomDeltEtaPerp;
2471                   secondCentralRPerp = secondCentralPhiPerp + secondCentralEtaPerp;
2472                 } // end if totalTrackPt!=0.0
2473               if(IsEqualRel(totalTrackPtPerp, 0.0)) //!IsEqualRel(totalTrackPt, 0.0) // totalTrackPtPerp==0.0
2474                 secondCentralRPerp = 10.0; //overflow
2475             } 
2476
2477           ///// end of adding the SCM for the perpendicular cone
2478
2479           if(irecj<maxJetNum)
2480             {
2481               recJets[irecj]= *rjet;
2482               nrectracks[irecj] = ntxreco;
2483               ptrecjet[irecj] = rjet->Pt();
2484               scmr[irecj] = secondCentralR;
2485               AliDebug(4,Form("Para el jet reco num: %d se necesitaron %d tracks \n",irecj,nrectracks[irecj])); 
2486             }
2487           AliDebug(4,"Before filling the histograms for this jet \n");
2488           fNChTrRD->Fill(ntxreco,rjet->Pt());
2489           fSCMRD->Fill(secondCentralR,rjet->Pt());
2490           fProfNChTrRD->Fill(rjet->Pt(),ntxreco);
2491
2492           fNTXV0MultPt->Fill(ntxreco,v0CorrMult,rjet->Pt());
2493           fNTXCBMultPt->Fill(ntxreco,refNJMult,rjet->Pt());
2494
2495           //refNJMult
2496           // reference multiplicity stuff in pp, also filled in PbPb, but does not matter.
2497           // set to: V0 corrected multiplicity: v0CorrMult
2498           if(v0CorrMult<25)
2499             {
2500               fNChTrRDMult[0]->Fill(ntxreco,rjet->Pt());
2501               fSCMRDMult[0]->Fill(secondCentralR,rjet->Pt());
2502               fTotalJetCharge[0]->Fill(fCurrentJetCharge);
2503               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2504                 {
2505                   fNChTrRDMultOJ[0]->Fill(ntxreco,rjet->Pt());
2506                   fSCMRDMultOJ[0]->Fill(secondCentralR,rjet->Pt());
2507                   fJEtaRDMultOJ[0]->Fill(rjet->Eta());
2508                   fJetPtRDMultOJ[0]->Fill(rjet->Pt());
2509                 }
2510             }
2511           if(v0CorrMult>=25&&v0CorrMult<50)
2512             {
2513               fNChTrRDMult[1]->Fill(ntxreco,rjet->Pt());
2514               fSCMRDMult[1]->Fill(secondCentralR,rjet->Pt());
2515               fTotalJetCharge[1]->Fill(fCurrentJetCharge);
2516               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2517                 {
2518                   fNChTrRDMultOJ[1]->Fill(ntxreco,rjet->Pt());
2519                   fSCMRDMultOJ[1]->Fill(secondCentralR,rjet->Pt());
2520                   fJEtaRDMultOJ[1]->Fill(rjet->Eta());
2521                   fJetPtRDMultOJ[1]->Fill(rjet->Pt());
2522                 }
2523             }
2524           if(v0CorrMult>=50&&v0CorrMult<90)
2525             {
2526               fNChTrRDMult[2]->Fill(ntxreco,rjet->Pt());
2527               fSCMRDMult[2]->Fill(secondCentralR,rjet->Pt());
2528               fTotalJetCharge[2]->Fill(fCurrentJetCharge);
2529               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2530                 {
2531                   fNChTrRDMultOJ[2]->Fill(ntxreco,rjet->Pt());
2532                   fSCMRDMultOJ[2]->Fill(secondCentralR,rjet->Pt());
2533                   fJEtaRDMultOJ[2]->Fill(rjet->Eta());
2534                   fJetPtRDMultOJ[2]->Fill(rjet->Pt());
2535                 }
2536             }
2537           if(v0CorrMult>=90&&v0CorrMult<120)
2538             {
2539               fNChTrRDMult[3]->Fill(ntxreco,rjet->Pt());
2540               fSCMRDMult[3]->Fill(secondCentralR,rjet->Pt());
2541               fTotalJetCharge[3]->Fill(fCurrentJetCharge);
2542               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2543                 {
2544                   fNChTrRDMultOJ[3]->Fill(ntxreco,rjet->Pt());
2545                   fSCMRDMultOJ[3]->Fill(secondCentralR,rjet->Pt());
2546                   fJEtaRDMultOJ[3]->Fill(rjet->Eta());
2547                   fJetPtRDMultOJ[3]->Fill(rjet->Pt());
2548                 }
2549             }
2550           if(v0CorrMult>=120&&v0CorrMult<150)
2551             {
2552               fNChTrRDMult[4]->Fill(ntxreco,rjet->Pt());
2553               fSCMRDMult[4]->Fill(secondCentralR,rjet->Pt());
2554               fTotalJetCharge[4]->Fill(fCurrentJetCharge);
2555               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2556                 {
2557                   fNChTrRDMultOJ[4]->Fill(ntxreco,rjet->Pt());
2558                   fSCMRDMultOJ[4]->Fill(secondCentralR,rjet->Pt());
2559                   fJEtaRDMultOJ[4]->Fill(rjet->Eta());
2560                   fJetPtRDMultOJ[4]->Fill(rjet->Pt());
2561                 }
2562             }
2563           if(v0CorrMult>=150&&v0CorrMult<200)
2564             {
2565               fNChTrRDMult[5]->Fill(ntxreco,rjet->Pt());
2566               fSCMRDMult[5]->Fill(secondCentralR,rjet->Pt());
2567               fTotalJetCharge[5]->Fill(fCurrentJetCharge);
2568               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2569                 {
2570                   fNChTrRDMultOJ[5]->Fill(ntxreco,rjet->Pt());
2571                   fSCMRDMultOJ[5]->Fill(secondCentralR,rjet->Pt());
2572                   fJEtaRDMultOJ[5]->Fill(rjet->Eta());
2573                   fJetPtRDMultOJ[5]->Fill(rjet->Pt());
2574                 }
2575             }
2576           if(v0CorrMult>=200&&v0CorrMult<300)
2577             {
2578               fNChTrRDMult[6]->Fill(ntxreco,rjet->Pt());
2579               fSCMRDMult[6]->Fill(secondCentralR,rjet->Pt());
2580               fTotalJetCharge[6]->Fill(fCurrentJetCharge);
2581               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2582                 {
2583                   fNChTrRDMultOJ[6]->Fill(ntxreco,rjet->Pt());
2584                   fSCMRDMultOJ[6]->Fill(secondCentralR,rjet->Pt());
2585                   fJEtaRDMultOJ[6]->Fill(rjet->Eta());
2586                   fJetPtRDMultOJ[6]->Fill(rjet->Pt());
2587                 }
2588             }
2589           if(v0CorrMult>=300)
2590             {
2591               fNChTrRDMult[7]->Fill(ntxreco,rjet->Pt());
2592               fSCMRDMult[7]->Fill(secondCentralR,rjet->Pt());
2593               fTotalJetCharge[7]->Fill(fCurrentJetCharge);
2594               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2595                 {
2596                   fNChTrRDMultOJ[7]->Fill(ntxreco,rjet->Pt());
2597                   fSCMRDMultOJ[7]->Fill(secondCentralR,rjet->Pt());
2598                   fJEtaRDMultOJ[7]->Fill(rjet->Eta());
2599                   fJetPtRDMultOJ[7]->Fill(rjet->Pt());
2600                 }
2601             }
2602
2603           // 2nd. Reference: set to: TPC tracks minus jet, minus dijet area
2604           if(refNJMult<5) //&&refNJMult>1
2605             {
2606               fNChTrRDMultSE[0]->Fill(ntxreco,rjet->Pt());
2607               fSCMRDMultSE[0]->Fill(secondCentralR,rjet->Pt());
2608               fTotalJetChargeSE[0]->Fill(fCurrentJetCharge);
2609               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2610                 {
2611                   fNChTrRDMultSEOJ[0]->Fill(ntxreco,rjet->Pt());
2612                   fSCMRDMultSEOJ[0]->Fill(secondCentralR,rjet->Pt());
2613                   fJEtaRDMultSEOJ[0]->Fill(rjet->Eta());
2614                   fJetPtRDMultSEOJ[0]->Fill(rjet->Pt());
2615                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2616                     fNChTrRecPerpMultSEOJ[0]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2617                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2618                     {
2619                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,1); //filling mult bin
2620                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,1); //filling mult bin
2621                     }
2622                 }
2623             }
2624           if(refNJMult>=5&&refNJMult<10)
2625             {
2626               fNChTrRDMultSE[1]->Fill(ntxreco,rjet->Pt());
2627               fSCMRDMultSE[1]->Fill(secondCentralR,rjet->Pt());
2628               fTotalJetChargeSE[1]->Fill(fCurrentJetCharge);
2629               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2630                 {
2631                   fNChTrRDMultSEOJ[1]->Fill(ntxreco,rjet->Pt());
2632                   fSCMRDMultSEOJ[1]->Fill(secondCentralR,rjet->Pt());
2633                   fJEtaRDMultSEOJ[1]->Fill(rjet->Eta());
2634                   fJetPtRDMultSEOJ[1]->Fill(rjet->Pt());
2635                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2636                     fNChTrRecPerpMultSEOJ[1]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2637                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2638                     {
2639                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,2); //filling mult bin
2640                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,2); //filling mult bin
2641                     }
2642                 }
2643             }
2644           if(refNJMult>=10&&refNJMult<15)
2645             {
2646               fNChTrRDMultSE[2]->Fill(ntxreco,rjet->Pt());
2647               fSCMRDMultSE[2]->Fill(secondCentralR,rjet->Pt());
2648               fTotalJetChargeSE[2]->Fill(fCurrentJetCharge);
2649               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2650                 {
2651                   fNChTrRDMultSEOJ[2]->Fill(ntxreco,rjet->Pt());
2652                   fSCMRDMultSEOJ[2]->Fill(secondCentralR,rjet->Pt());
2653                   fJEtaRDMultSEOJ[2]->Fill(rjet->Eta());
2654                   fJetPtRDMultSEOJ[2]->Fill(rjet->Pt());
2655                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2656                     fNChTrRecPerpMultSEOJ[2]->Fill(nTRecAboveThresholdPerp,rjet->Pt()); 
2657                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2658                     {
2659                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,3); //filling mult bin
2660                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,3); //filling mult bin
2661                     } 
2662                 }
2663             }
2664           if(refNJMult>=15&&refNJMult<20)
2665             {
2666               fNChTrRDMultSE[3]->Fill(ntxreco,rjet->Pt());
2667               fSCMRDMultSE[3]->Fill(secondCentralR,rjet->Pt());
2668               fTotalJetChargeSE[3]->Fill(fCurrentJetCharge);
2669               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2670                 {
2671                   fNChTrRDMultSEOJ[3]->Fill(ntxreco,rjet->Pt());
2672                   fSCMRDMultSEOJ[3]->Fill(secondCentralR,rjet->Pt());
2673                   fJEtaRDMultSEOJ[3]->Fill(rjet->Eta());
2674                   fJetPtRDMultSEOJ[3]->Fill(rjet->Pt());
2675                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2676                     fNChTrRecPerpMultSEOJ[3]->Fill(nTRecAboveThresholdPerp,rjet->Pt()); 
2677                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2678                     {
2679                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,4); //filling mult bin
2680                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,4); //filling mult bin
2681                     } 
2682                 }
2683             }
2684           if(refNJMult>=20&&refNJMult<30)
2685             {
2686               fNChTrRDMultSE[4]->Fill(ntxreco,rjet->Pt());
2687               fSCMRDMultSE[4]->Fill(secondCentralR,rjet->Pt());
2688               fTotalJetChargeSE[4]->Fill(fCurrentJetCharge);
2689               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2690                 {
2691                   fNChTrRDMultSEOJ[4]->Fill(ntxreco,rjet->Pt());
2692                   fSCMRDMultSEOJ[4]->Fill(secondCentralR,rjet->Pt());
2693                   fJEtaRDMultSEOJ[4]->Fill(rjet->Eta());
2694                   fJetPtRDMultSEOJ[4]->Fill(rjet->Pt());
2695                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2696                     fNChTrRecPerpMultSEOJ[4]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2697                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2698                     {
2699                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,5); //filling mult bin
2700                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,5); //filling mult bin
2701                     }
2702                 }
2703             }
2704           if(refNJMult>=30&&refNJMult<40)
2705             {
2706               fNChTrRDMultSE[5]->Fill(ntxreco,rjet->Pt());
2707               fSCMRDMultSE[5]->Fill(secondCentralR,rjet->Pt());
2708               fTotalJetChargeSE[5]->Fill(fCurrentJetCharge);
2709               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2710                 {
2711                   fNChTrRDMultSEOJ[5]->Fill(ntxreco,rjet->Pt());
2712                   fSCMRDMultSEOJ[5]->Fill(secondCentralR,rjet->Pt());
2713                   fJEtaRDMultSEOJ[5]->Fill(rjet->Eta());
2714                   fJetPtRDMultSEOJ[5]->Fill(rjet->Pt());
2715                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2716                     fNChTrRecPerpMultSEOJ[5]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2717                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2718                     {
2719                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,6); //filling mult bin
2720                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,6); //filling mult bin
2721                     }
2722                 }
2723             }
2724           if(refNJMult>=40&&refNJMult<50)
2725             {
2726               fNChTrRDMultSE[6]->Fill(ntxreco,rjet->Pt());
2727               fSCMRDMultSE[6]->Fill(secondCentralR,rjet->Pt());
2728               fTotalJetChargeSE[6]->Fill(fCurrentJetCharge);
2729               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2730                 {
2731                   fNChTrRDMultSEOJ[6]->Fill(ntxreco,rjet->Pt());
2732                   fSCMRDMultSEOJ[6]->Fill(secondCentralR,rjet->Pt());
2733                   fJEtaRDMultSEOJ[6]->Fill(rjet->Eta());
2734                   fJetPtRDMultSEOJ[6]->Fill(rjet->Pt());
2735                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2736                     fNChTrRecPerpMultSEOJ[6]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2737                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2738                     {
2739                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,7); //filling mult bin
2740                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,7); //filling mult bin
2741                     }
2742                 }
2743             }
2744           if(refNJMult>=50)
2745             {
2746               fNChTrRDMultSE[7]->Fill(ntxreco,rjet->Pt());
2747               fSCMRDMultSE[7]->Fill(secondCentralR,rjet->Pt());
2748               fTotalJetChargeSE[7]->Fill(fCurrentJetCharge);
2749               if(recojets==1) // if only one jet in the whole event, and inside acceptance
2750                 {
2751                   fNChTrRDMultSEOJ[7]->Fill(ntxreco,rjet->Pt());
2752                   fSCMRDMultSEOJ[7]->Fill(secondCentralR,rjet->Pt());
2753                   fJEtaRDMultSEOJ[7]->Fill(rjet->Eta());
2754                   fJetPtRDMultSEOJ[7]->Fill(rjet->Pt());
2755                   if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2756                     fNChTrRecPerpMultSEOJ[7]->Fill(nTRecAboveThresholdPerp,rjet->Pt());  
2757                   if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2758                     {
2759                       fNChTrRecECorrPPMult->Fill(ntxrecoRecalc,pTbs,8); //filling mult bin
2760                       fNChTrRecPerpECorrPPMult->Fill(nTRecAboveThresholdPerpRecalc,pTbs,8); //filling mult bin
2761                     }
2762                 }
2763             }
2764
2765           if(fIsPossibleToSubstBckg) // if it was possible to calculate a perpendicular cone
2766             {
2767               if(!IsEqualRel(fCurrentJetMinPtNT90, 7000.))
2768                 fNChTrRecPerp->Fill(nTRecAboveThresholdPerp,rjet->Pt());  // these are my previous histos
2769               fSCMRecPerp->Fill(secondCentralRPerp,rjet->Pt());  // this are my previous histos
2770               if(!fIsHIevent) //if is a proton proton event
2771                 {
2772                   fNChTrRecECorr->Fill(ntxrecoRecalc,pTbs,1); //filling proton bin
2773                   if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
2774                     {
2775                       fNChTrRecPerpECorr->Fill(nTRecAboveThresholdPerpRecalc,pTbs,1); //filling proton bin
2776                       if((rjet->Pt()>10.)&&(rjet->Pt()<20.))
2777                         {
2778                           fPtInPerpCon->Fill(fPerpCone->Pt(),1,1);
2779                           fTotTracksCone->Fill(fTotTracksInCone,1,1);
2780                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 1);
2781                         }
2782                       if((rjet->Pt()>20.)&&(rjet->Pt()<30.))
2783                         {
2784                           fPtInPerpCon->Fill(fPerpCone->Pt(),2,1);
2785                           fTotTracksCone->Fill(fTotTracksInCone,2,1);
2786                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 2);
2787                         }
2788                       if((rjet->Pt()>30.)&&(rjet->Pt()<40.))
2789                         {
2790                           fPtInPerpCon->Fill(fPerpCone->Pt(),3,1);
2791                           fTotTracksCone->Fill(fTotTracksInCone,3,1);
2792                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 3);
2793                         }
2794                       if((rjet->Pt()>40.)&&(rjet->Pt()<50.))
2795                         {
2796                           fPtInPerpCon->Fill(fPerpCone->Pt(),4,1);
2797                           fTotTracksCone->Fill(fTotTracksInCone,4,1);
2798                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 4);
2799                         }
2800                       if((rjet->Pt()>50.)&&(rjet->Pt()<60.))
2801                         {
2802                           fPtInPerpCon->Fill(fPerpCone->Pt(),5,1);
2803                           fTotTracksCone->Fill(fTotTracksInCone,5,1);
2804                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 5);
2805                         }
2806                       if((rjet->Pt()>60.)&&(rjet->Pt()<70.))
2807                         {
2808                           fPtInPerpCon->Fill(fPerpCone->Pt(),6,1);
2809                           fTotTracksCone->Fill(fTotTracksInCone,6,1);
2810                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 6);
2811                         }
2812                       if((rjet->Pt()>70.)&&(rjet->Pt()<80.))
2813                         {
2814                           fPtInPerpCon->Fill(fPerpCone->Pt(),7,1);
2815                           fTotTracksCone->Fill(fTotTracksInCone,7,1);
2816                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 7);
2817                         }
2818                       if((rjet->Pt()>80.)&&(rjet->Pt()<90.))
2819                         {
2820                           fPtInPerpCon->Fill(fPerpCone->Pt(),8,1); 
2821                           fTotTracksCone->Fill(fTotTracksInCone,8,1);
2822                           FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 1, 8);
2823                         }
2824                     }
2825                 }
2826               if(fIsHIevent) //if is a PbPb event     
2827                 {
2828                   if(fEventCent>=0&&fEventCent<10.)
2829                     {
2830                       fNChTrRecECorr->Fill(ntxrecoRecalc,pTbs,2); //filling first centrality bin
2831                       fJetPtCentPbPbRaw->Fill(rjet->Pt(),2); 
2832                       fJetPtCentPbPbCorr->Fill(pTbs,2); 
2833                       if(!IsEqualRel(fCurrentJetMinPtNT90Recalc, 7000.))
2834                         {
2835                           fNChTrRecPerpECorr->Fill(nTRecAboveThresholdPerpRecalc,pTbs,2); //filling first centrality bin
2836                           fMinTrackPtInNTXRecalc->Fill(fMinTrackPtInNTXR,rjet->Pt(),2); 
2837                           fMinTrackPtInNTXh[1]->Fill(fMinTrackPtInNTX,rjet->Pt(),2); 
2838                           if((rjet->Pt()>10.)&&(rjet->Pt()<20.))
2839                             {
2840                               fPtInPerpCon->Fill(fPerpCone->Pt(),1,2);
2841                               fTotTracksCone->Fill(fTotTracksInCone,1,2);
2842                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 1);
2843                             }
2844                           if((rjet->Pt()>20.)&&(rjet->Pt()<30.))
2845                             {
2846                               fPtInPerpCon->Fill(fPerpCone->Pt(),2,2);
2847                               fTotTracksCone->Fill(fTotTracksInCone,2,2);
2848                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 2);
2849                             }
2850                           if((rjet->Pt()>30.)&&(rjet->Pt()<40.))
2851                             {
2852                               fPtInPerpCon->Fill(fPerpCone->Pt(),3,2);
2853                               fTotTracksCone->Fill(fTotTracksInCone,3,2);
2854                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 3);
2855                             }
2856                           if((rjet->Pt()>40.)&&(rjet->Pt()<50.))
2857                             {
2858                               fPtInPerpCon->Fill(fPerpCone->Pt(),4,2);
2859                               fTotTracksCone->Fill(fTotTracksInCone,4,2);
2860                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 4);
2861                             }
2862                           if((rjet->Pt()>50.)&&(rjet->Pt()<60.))
2863                             {
2864                               fPtInPerpCon->Fill(fPerpCone->Pt(),5,2);
2865                               fTotTracksCone->Fill(fTotTracksInCone,5,2);
2866                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 5);
2867                             }
2868                           if((rjet->Pt()>60.)&&(rjet->Pt()<70.))
2869                             {
2870                               fPtInPerpCon->Fill(fPerpCone->Pt(),6,2);
2871                               fTotTracksCone->Fill(fTotTracksInCone,6,2);
2872                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 6);
2873                             }
2874                           if((rjet->Pt()>70.)&&(rjet->Pt()<80.))
2875                             {
2876                               fPtInPerpCon->Fill(fPerpCone->Pt(),7,2);
2877                               fTotTracksCone->Fill(fTotTracksInCone,7,2);
2878                               FillPerpConeHisto(fPtDistInPerpConeRaw, tracksAOD, fAOD, 2, 7);
2879                             }
2880                           if((rjet->Pt()>80.)&&(rjet->Pt()<90.))
2881                           &nb