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