Added possibility to run without reading the MC (Andrea)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSECharmFraction.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 // Class AliAnalysisTaskSECharmFraction
19 // AliAnalysisTaskSE for the extraction of the fraction of prompt charm
20 // using the charm hadron impact parameter to the primary vertex
21 //
22 // Author: Andrea Rossi, andrea.rossi@ts.infn.it
23 /////////////////////////////////////////////////////////////
24
25
26 #include <TH1F.h>
27 #include <TH2F.h>
28 #include <TDatabasePDG.h>
29 #include <TMath.h>
30 #include <TROOT.h>
31
32 #include "AliAnalysisManager.h"
33 #include "AliAODHandler.h"
34 #include "AliAODEvent.h"
35 #include "AliAODRecoDecayHF2Prong.h"
36 #include "AliAODRecoDecayHF.h"
37 #include "AliAODRecoDecay.h"
38 #include "AliAODTrack.h"
39 #include "AliAODVertex.h"
40 #include "AliAODMCParticle.h"
41 #include "AliAODMCHeader.h"
42 #include "AliAnalysisVertexingHF.h"
43 #include "AliAnalysisTaskSECharmFraction.h"
44
45
46 class TCanvas;
47 class TTree;
48 class TChain;
49 class AliAODInputHandler;
50 class AliAnalysisManager;
51 class AliAnalysisTaskSE;
52
53
54 ClassImp(AliAnalysisTaskSECharmFraction)
55  
56 //________________________________________________________________________
57   AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction() 
58     : AliAnalysisTaskSE(),
59       fVHFloose(0),
60       fVHFtight(0),
61       fReadMC(kFALSE),
62       fmD0PDG(),
63       fnbins(),
64       fptbins(0),
65       fAcceptanceCuts(),
66       fsignalInvMassCut(),
67       flargeInvMassCut(),
68       fsidebandInvMassCut(),
69       fsidebandInvMassWindow(),
70       fUseMC(kTRUE),
71       fNentries(0),
72       fSignalType(0),
73       fSignalTypeLsCuts(0),
74       fSignalTypeTghCuts(0),
75       flistNoCutsSignal(0),
76       flistNoCutsBack(0),
77       flistNoCutsFromB(0),
78       flistNoCutsFromDstar(0),
79       flistNoCutsOther(0),
80       flistLsCutsSignal(0),
81       flistLsCutsBack(0),
82       flistLsCutsFromB(0),
83       flistLsCutsFromDstar(0),
84       flistLsCutsOther(0),
85       flistTghCutsSignal(0),
86       flistTghCutsBack(0),
87       flistTghCutsFromB(0),
88       flistTghCutsFromDstar(0),
89       flistTghCutsOther(0)
90    
91 {
92   //Default constructor
93 }
94 //________________________________________________________________________
95   AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name) 
96     : AliAnalysisTaskSE(name),
97       fVHFloose(0),
98       fVHFtight(0),
99       fReadMC(kFALSE),
100       fmD0PDG(),
101       fnbins(),
102       fptbins(0),
103       fAcceptanceCuts(),
104       fsignalInvMassCut(),
105       flargeInvMassCut(),
106       fsidebandInvMassCut(),
107       fsidebandInvMassWindow(),
108       fUseMC(kTRUE),
109       fNentries(0),
110       fSignalType(0),
111       fSignalTypeLsCuts(0),
112       fSignalTypeTghCuts(0),
113       flistNoCutsSignal(0),
114       flistNoCutsBack(0),
115       flistNoCutsFromB(0),
116       flistNoCutsFromDstar(0),
117       flistNoCutsOther(0),
118       flistLsCutsSignal(0),
119       flistLsCutsBack(0),
120       flistLsCutsFromB(0),
121       flistLsCutsFromDstar(0),
122       flistLsCutsOther(0),
123       flistTghCutsSignal(0),
124       flistTghCutsBack(0),
125       flistTghCutsFromB(0),
126       flistTghCutsFromDstar(0),
127       flistTghCutsOther(0)
128    
129 {
130   // Constructor
131  
132   // Define input and output slots here
133   // Input slot #0 works with a TChain
134   // Output slot #0 writes into a TH1 container
135
136   //Standard pt bin
137   fnbins=4;
138   fptbins=new Double_t[fnbins+1];
139   fptbins[0]=0.;
140   fptbins[1]=1.;
141   fptbins[2]=3.;
142   fptbins[3]=5.;
143   fptbins[4]=1000.;
144   //fAcceptanceCuts=new Double_t[3];
145   SetAcceptanceCut();
146   SetStandardMassSelection();
147   DefineOutput(1, TH1F::Class());
148   DefineOutput(2, TH1F::Class());
149   DefineOutput(3, TH1F::Class());
150   DefineOutput(4, TH1F::Class());
151   for(Int_t j=5;j<20;j++){
152     DefineOutput(j, TList::Class());
153   }
154
155
156 }
157
158
159 AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name,Int_t nptbins,Double_t *ptbins) 
160   : AliAnalysisTaskSE(name),
161     fVHFloose(0),
162     fVHFtight(0),
163     fReadMC(kFALSE),
164     fmD0PDG(),
165     fnbins(),
166     fptbins(0),
167     fAcceptanceCuts(),
168     fsignalInvMassCut(),
169     flargeInvMassCut(),
170     fsidebandInvMassCut(),
171     fsidebandInvMassWindow(),
172     fUseMC(kTRUE),
173     fNentries(0),
174     fSignalType(0),
175     fSignalTypeLsCuts(0),
176     fSignalTypeTghCuts(0),
177     flistNoCutsSignal(0),
178     flistNoCutsBack(0),
179     flistNoCutsFromB(0),
180     flistNoCutsFromDstar(0),
181     flistNoCutsOther(0),
182     flistLsCutsSignal(0),
183     flistLsCutsBack(0),
184     flistLsCutsFromB(0),
185     flistLsCutsFromDstar(0),
186     flistLsCutsOther(0),
187     flistTghCutsSignal(0),
188     flistTghCutsBack(0),
189     flistTghCutsFromB(0),
190     flistTghCutsFromDstar(0),
191     flistTghCutsOther(0)
192 {
193   // Constructor
194   // ptbins must be of dimension nptbins +1
195   
196   SetNPtBins(nptbins,ptbins);
197   SetStandardMassSelection();
198   //  fAcceptanceCuts=new Double_t[3];
199   SetAcceptanceCut();
200   // Define input and output slots here
201  
202   // Output slot #0 writes into a TH1 container
203   DefineOutput(1, TH1F::Class());
204   DefineOutput(2, TH1F::Class());
205   DefineOutput(3, TH1F::Class());
206   DefineOutput(4, TH1F::Class());
207   for(Int_t j=5;j<20;j++){
208
209     DefineOutput(j, TList::Class());
210   }
211
212  
213 }
214
215 //________________________________________________________________________
216 AliAnalysisTaskSECharmFraction::~AliAnalysisTaskSECharmFraction()
217 { //Destructor 
218   
219   if (fVHFtight) {
220     delete fVHFtight;
221     fVHFtight = 0;
222   }
223   if (fVHFloose) {
224     delete fVHFloose;
225     fVHFloose = 0;
226   }
227   if(fptbins){
228     delete fptbins;
229     fptbins =0;
230   }
231   /*  if(fAcceptanceCuts){
232     delete fAcceptanceCuts;
233     fAcceptanceCuts=0;
234     }*/
235   if (fNentries) {
236     delete fNentries;
237     fNentries = 0;
238   }   
239   if (fSignalType) {
240     delete fSignalType;
241     fSignalType = 0;
242   } 
243   if (fSignalTypeLsCuts) {
244     delete fSignalTypeLsCuts;
245     fSignalTypeLsCuts = 0;
246   } 
247   if (fSignalTypeTghCuts) {
248     delete fSignalTypeTghCuts;
249     fSignalTypeTghCuts = 0;
250   } 
251   if(flistNoCutsSignal){
252     delete flistNoCutsSignal;
253     flistNoCutsSignal=0;
254   }
255   if(flistNoCutsBack){
256     delete flistNoCutsBack;
257     flistNoCutsBack=0;
258   }
259   if(flistNoCutsFromB){
260     delete flistNoCutsFromB;
261     flistNoCutsFromB=0;
262   }
263   if(flistNoCutsFromDstar){
264     delete flistNoCutsFromDstar;
265     flistNoCutsFromDstar=0;
266   }
267   if(flistNoCutsOther){
268     delete flistNoCutsOther;
269     flistNoCutsOther=0;
270   }
271   
272  if(flistLsCutsSignal){
273     delete flistLsCutsSignal;
274     flistLsCutsSignal=0;
275   }
276   if(flistLsCutsBack){
277     delete flistLsCutsBack;
278     flistLsCutsBack=0;
279   }
280   if(flistLsCutsFromB){
281     delete flistLsCutsFromB;
282     flistLsCutsFromB=0;
283   }
284   if(flistLsCutsFromDstar){
285     delete flistLsCutsFromDstar;
286     flistLsCutsFromDstar=0;
287   }
288   if(flistLsCutsOther){
289     delete flistLsCutsOther;
290     flistLsCutsOther=0;
291   }
292   
293  if(flistTghCutsSignal){
294     delete flistTghCutsSignal;
295     flistTghCutsSignal=0;
296   }
297   if(flistTghCutsBack){
298     delete flistTghCutsBack;
299     flistTghCutsBack=0;
300   }
301   if(flistTghCutsFromB){
302     delete flistTghCutsFromB;
303     flistTghCutsFromB=0;
304   }
305   if(flistTghCutsFromDstar){
306     delete flistTghCutsFromDstar;
307     flistTghCutsFromDstar=0;
308   }
309   if(flistTghCutsOther){
310     delete flistTghCutsOther;
311     flistTghCutsOther=0;
312   }
313   
314   
315 }  
316
317
318 //________________________________________________________________________
319 void AliAnalysisTaskSECharmFraction::Init()
320 {
321   // Initialization
322   
323   if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
324   fmD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
325   
326   gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
327   
328   // 2 sets of dedidcated cuts -- defined in UserExec
329   //  the config file and the way the cuts are set is for further development
330   //   (to be interfaced with AliAnalsysTaskSETuneCuts)
331
332   fVHFtight = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
333   fVHFloose = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");  
334   if(!fptbins){
335     //SET STANDARD PT BINNING
336     fnbins=4;
337     fptbins=new Double_t[fnbins+1];
338     fptbins[0]=0.;
339     fptbins[1]=1.;
340     fptbins[2]=3.;
341     fptbins[3]=5.;
342     fptbins[4]=1000.;
343   }
344   return;
345 }
346
347 //________________________________________________________________________
348 void AliAnalysisTaskSECharmFraction::UserCreateOutputObjects()
349 {
350   // Create histograms
351   // Called once
352   
353   // ################ NAMING SCHEME ###################################
354   //            LISTS NAMING SCHEME
355   // "list" + cut selection string + MC selection string
356   //      cut strings:  "NC" =nocuts, "LSC"= loose cuts, "TGHC"= tight cuts
357   //      MC sel. strings: "sign"= D0 from c quark
358   //                       "fromDstar" = D0 from Dstar from c quark
359   //                       "fromB"= D0from B decay (->from b quark) + D0from Dstar from B
360   //                       "back"= backgroun, generic except the cas "other"
361   //                       "other"= background case for candidates made of a pion and a kaon coming from the same D0 (in 4 prong) or from D+
362   //
363   //           HISTS NAMING SCHEME 
364   // 
365   //  "h" + specific name + cut selection string + MC selection string + (InvMass region string) + (pt string)
366   //
367   //        cut selection strings    = those for lists
368   //        MC selection strings     = those for lists
369   //        inv mass region strings  : "PM" or "SB" for global properties and pt integrated histos
370   //                                   "_PkMss" or "_SBMss" for impact par. pt dependent histos
371   //                   pt string     : "_pt" + integer number of ptbin
372   //
373   //###################################################################
374
375   TString namehist;
376   TString titlehist;
377   TString strnamept,strtitlept;
378  
379   fNentries=new TH1F("nentriesChFr", "Look at the number of entries! = number of AODs", 2,1.,2.);
380   fSignalType=new TH1F("hsignaltype", "Histo for type of MC signal", 21,-1.,20.);
381   fSignalTypeLsCuts=new TH1F("hsignaltypeLsCuts", "Histo for type of MC signal with loose cuts", 21,-1.,20.);
382   fSignalTypeTghCuts=new TH1F("hsignaltypeTghCuts", "Histo for type of MC signal with tight cuts", 21,-1.,20.);
383
384   //##########  DEFINE THE TLISTS ##################
385   
386   flistNoCutsSignal = new TList();
387   flistNoCutsSignal->SetOwner();
388   flistNoCutsSignal->SetName("listNCsign");
389
390   flistNoCutsBack = new TList();
391   flistNoCutsBack->SetOwner();
392   flistNoCutsBack->SetName("listNCback");
393
394   flistNoCutsFromB = new TList();
395   flistNoCutsFromB->SetOwner();
396   flistNoCutsFromB->SetName("listNCfromB");
397
398   flistNoCutsFromDstar = new TList();
399   flistNoCutsFromDstar->SetOwner();
400   flistNoCutsFromDstar->SetName("listNCfromDstar");
401
402   flistNoCutsOther = new TList();
403   flistNoCutsOther->SetOwner();
404   flistNoCutsOther->SetName("listNCother");
405
406
407   flistLsCutsSignal = new TList();
408   flistLsCutsSignal->SetOwner();
409   flistLsCutsSignal->SetName("listLSCsign");
410
411   flistLsCutsBack = new TList();
412   flistLsCutsBack->SetOwner();
413   flistLsCutsBack->SetName("listLSCback");
414
415   flistLsCutsFromB = new TList();
416   flistLsCutsFromB->SetOwner();
417   flistLsCutsFromB->SetName("listLSCfromB");
418
419   flistLsCutsFromDstar = new TList();
420   flistLsCutsFromDstar->SetOwner();
421   flistLsCutsFromDstar->SetName("listLSCfromDstar");
422
423   flistLsCutsOther = new TList();
424   flistLsCutsOther->SetOwner();
425   flistLsCutsOther->SetName("listLSCother");
426
427
428   flistTghCutsSignal = new TList();
429   flistTghCutsSignal->SetOwner();
430   flistTghCutsSignal->SetName("listTGHCsign");
431
432   flistTghCutsBack = new TList();
433   flistTghCutsBack->SetOwner();
434   flistTghCutsBack->SetName("listTGHCback");
435
436   flistTghCutsFromB = new TList();
437   flistTghCutsFromB->SetOwner();
438   flistTghCutsFromB->SetName("listTGHCfromB");
439
440   flistTghCutsFromDstar = new TList();
441   flistTghCutsFromDstar->SetOwner();
442   flistTghCutsFromDstar->SetName("listTGHCfromDstar");
443
444   flistTghCutsOther = new TList();
445   flistTghCutsOther->SetOwner();
446   flistTghCutsOther->SetName("listTGHCother");
447
448
449
450
451   //################################################################################################
452   //                                                                                               #
453   //                         HISTOS FOR NO CUTS CASE                                               #
454   //                                                                                               #
455   //################################################################################################
456
457
458   //############ NO CUTS SIGNAL HISTOGRAMS ###############
459   //
460   // ####### global properties histo ############
461
462   TH2F *hCPtaVSd0d0NCsign=new TH2F("hCPtaVSd0d0NCsign","hCPtaVSd0d0_NoCuts_Signal",1000,-100000.,100000.,100,0.,1.);
463   TH1F *hSecVtxZNCsign=new TH1F("hSecVtxZNCsign","hSecVtxZ_NoCuts_Signal",1000,-8.,8.);
464   TH1F *hSecVtxXNCsign=new TH1F("hSecVtxXNCsign","hSecVtxX_NoCuts_Signal",1000,-3000.,3000.);
465   TH1F *hSecVtxYNCsign=new TH1F("hSecVtxYNCsign","hSecVtxY_NoCuts_Signal",1000,-3000.,3000.);
466   TH2F *hSecVtxXYNCsign=new TH2F("hSecVtxXYNCsign","hSecVtxXY_NoCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
467   TH1F *hSecVtxPhiNCsign=new TH1F("hSecVtxPhiNCsign","hSecVtxPhi_NoCuts_Signal",180,-180.1,180.1);
468   TH1F *hCPtaNCsign=new TH1F("hCPtaNCsign","hCPta_NoCuts_Signal",100,0.,1.);
469   TH1F *hd0xd0NCsign=new TH1F("hd0xd0NCsign","hd0xd0_NoCuts_Signal",1000,-100000.,100000.);
470   TH1F *hMassTrueNCsign=new TH1F("hMassTrueNCsign","D^{0} MC inv. Mass No Cuts Signal(All momenta)",600,1.600,2.200);
471   TH1F *hMassNCsign=new TH1F("hMassNCsign","D^{0} inv. Mass No Cuts Signal (All momenta)",600,1.600,2.200);
472   hMassNCsign->Sumw2();
473   TH1F *hMassTrueNCsignPM=new TH1F("hMassTrueNCsignPM","D^{0} MC inv. Mass No Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
474   TH1F *hMassNCsignPM=new TH1F("hMassNCsignPM","D^{0} inv. Mass No Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
475   hMassNCsignPM->Sumw2();
476
477   TH1F *hMassTrueNCsignSB=new TH1F("hMassTrueNCsignSB","D^{0} MC inv. Mass in Side Bands No Cuts Signal(All momenta)",600,1.600,2.200);
478   TH1F *hMassNCsignSB=new TH1F("hMassNCsignSB","D^{0} inv. Mass in Side Bands No Cuts Signal (All momenta)",600,1.600,2.200);
479   hMassNCsignSB->Sumw2();
480
481   flistNoCutsSignal->Add(hCPtaVSd0d0NCsign);
482   flistNoCutsSignal->Add(hSecVtxZNCsign);
483   flistNoCutsSignal->Add(hSecVtxYNCsign);
484   flistNoCutsSignal->Add(hSecVtxXNCsign);
485   flistNoCutsSignal->Add(hSecVtxXYNCsign);
486   flistNoCutsSignal->Add(hSecVtxPhiNCsign);
487   flistNoCutsSignal->Add(hCPtaNCsign);
488   flistNoCutsSignal->Add(hd0xd0NCsign);
489   flistNoCutsSignal->Add(hMassTrueNCsign);
490   flistNoCutsSignal->Add(hMassNCsign);
491   flistNoCutsSignal->Add(hMassTrueNCsignPM);
492   flistNoCutsSignal->Add(hMassNCsignPM);
493   flistNoCutsSignal->Add(hMassTrueNCsignSB);
494   flistNoCutsSignal->Add(hMassNCsignSB);
495
496   // ####### d0 D0 histos ############
497   TH1F *hd0D0NCsignPM = new TH1F("hd0D0NCsignPM","D^{0} impact par. plot , No Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
498   hd0D0NCsignPM->SetXTitle("Impact parameter [#mum]");
499   hd0D0NCsignPM->SetYTitle("Entries");
500
501   TH1F *hd0D0VtxTrueNCsignPM = new TH1F("hd0D0VtxTrueNCsignPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
502   hd0D0VtxTrueNCsignPM->SetXTitle("Impact parameter [#mum]");
503   hd0D0VtxTrueNCsignPM->SetYTitle("Entries");
504
505   TH1F *hMCd0D0NCsignPM = new TH1F("hMCd0D0NCsignPM","D^{0} impact par. plot, No Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
506   hMCd0D0NCsignPM->SetXTitle("MC Impact parameter [#mum]");
507   hMCd0D0NCsignPM->SetYTitle("Entries");
508
509   TH1F *hd0D0NCsignSB = new TH1F("hd0D0NCsignSB","D^{0} impact par. plot , No Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
510   hd0D0NCsignSB->SetXTitle("Impact parameter [#mum]");
511   hd0D0NCsignSB->SetYTitle("Entries");
512
513   TH1F *hd0D0VtxTrueNCsignSB = new TH1F("hd0D0VtxTrueNCsignSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
514   hd0D0VtxTrueNCsignSB->SetXTitle("Impact parameter [#mum]");
515   hd0D0VtxTrueNCsignSB->SetYTitle("Entries");
516
517   TH1F *hMCd0D0NCsignSB = new TH1F("hMCd0D0NCsignSB","D^{0} impact par. plot, No Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
518   hMCd0D0NCsignSB->SetXTitle("MC Impact parameter [#mum]");
519   hMCd0D0NCsignSB->SetYTitle("Entries");
520
521   flistNoCutsSignal->Add(hd0D0NCsignPM);
522   flistNoCutsSignal->Add(hd0D0VtxTrueNCsignPM);
523   flistNoCutsSignal->Add(hMCd0D0NCsignPM);
524   flistNoCutsSignal->Add(hd0D0NCsignSB);
525   flistNoCutsSignal->Add(hd0D0VtxTrueNCsignSB);
526   flistNoCutsSignal->Add(hMCd0D0NCsignSB);
527   
528   TH1F **hd0D0ptNCsignPM=new TH1F*[fnbins];
529   TH1F **hMCd0D0ptNCsignPM=new TH1F*[fnbins];
530   TH1F ** hd0D0VtxTrueptNCsignPM=new TH1F*[fnbins];
531   TH1F **hd0D0ptNCsignSB=new TH1F*[fnbins];
532   TH1F **hMCd0D0ptNCsignSB=new TH1F*[fnbins];
533   TH1F ** hd0D0VtxTrueptNCsignSB=new TH1F*[fnbins];
534   namehist="hd0D0ptNCsign_";
535   titlehist="D^{0} impact par. plot, No Cuts, Signal, ";
536   for(Int_t i=0;i<fnbins;i++){
537     strnamept=namehist;
538     strnamept.Append("PkMss_pt");
539     strnamept+=i;
540
541     strtitlept=titlehist;
542     strtitlept.Append(" Mass Peak, ");
543     strtitlept+=fptbins[i];
544     strtitlept.Append("<= pt <");
545     strtitlept+=fptbins[i+1];
546     strtitlept.Append(" [GeV/c]");
547     
548     hd0D0ptNCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
549     hd0D0ptNCsignPM[i]->SetXTitle("Impact parameter [#mum] ");
550     hd0D0ptNCsignPM[i]->SetYTitle("Entries");
551     flistNoCutsSignal->Add(hd0D0ptNCsignPM[i]);
552
553     strnamept.ReplaceAll("hd0D0","hMCd0D0");
554     hMCd0D0ptNCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
555     hMCd0D0ptNCsignPM[i]->SetXTitle("MC Impact parameter [#mum] ");
556     hMCd0D0ptNCsignPM[i]->SetYTitle("Entries");
557     flistNoCutsSignal->Add(hMCd0D0ptNCsignPM[i]);
558  
559
560     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
561     hd0D0VtxTrueptNCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
562     hd0D0VtxTrueptNCsignPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
563     hd0D0VtxTrueptNCsignPM[i]->SetYTitle("Entries");
564     flistNoCutsSignal->Add(hd0D0VtxTrueptNCsignPM[i]);
565     
566     strnamept=namehist;
567     strnamept.Append("SBMss_pt");
568     strnamept+=i;
569
570     strtitlept=titlehist;
571     strtitlept.Append(" Side Bands, ");
572     strtitlept+=fptbins[i];
573     strtitlept.Append("<= pt <");
574     strtitlept+=fptbins[i+1];
575     strtitlept.Append(" [GeV/c]");
576     
577     hd0D0ptNCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
578     hd0D0ptNCsignSB[i]->SetXTitle("Impact parameter [#mum] ");
579     hd0D0ptNCsignSB[i]->SetYTitle("Entries");
580     flistNoCutsSignal->Add(hd0D0ptNCsignSB[i]);
581
582     strnamept.ReplaceAll("hd0D0","hMCd0D0");
583     hMCd0D0ptNCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
584     hMCd0D0ptNCsignSB[i]->SetXTitle("MC Impact parameter [#mum] ");
585     hMCd0D0ptNCsignSB[i]->SetYTitle("Entries");
586     flistNoCutsSignal->Add(hMCd0D0ptNCsignSB[i]);
587
588     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
589     hd0D0VtxTrueptNCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
590     hd0D0VtxTrueptNCsignSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
591     hd0D0VtxTrueptNCsignSB[i]->SetYTitle("Entries");
592     flistNoCutsSignal->Add(hd0D0VtxTrueptNCsignSB[i]);
593   }
594
595
596   //############ NO CUTS BACKGROUND HISTOGRAMS ###########
597   //
598   //   ######## global properties histos #######
599   TH2F *hCPtaVSd0d0NCback=new TH2F("hCPtaVSd0d0NCback","hCPtaVSd0d0_NoCuts_Background",1000,-100000.,100000.,100,0.,1.);
600   TH1F *hSecVtxZNCback=new TH1F("hSecVtxZNCback","hSecVtxZ_NoCuts_Background",1000,-8.,8.);
601   TH1F *hSecVtxXNCback=new TH1F("hSecVtxXNCback","hSecVtxX_NoCuts_Background",1000,-3000.,3000.);
602   TH1F *hSecVtxYNCback=new TH1F("hSecVtxYNCback","hSecVtxY_NoCuts_Background",1000,-3000.,3000.);
603   TH2F *hSecVtxXYNCback=new TH2F("hSecVtxXYNCback","hSecVtxXY_NoCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
604   TH1F *hSecVtxPhiNCback=new TH1F("hSecVtxPhiNCback","hSecVtxPhi_NoCuts_Background",180,-180.1,180.1);
605   TH1F *hCPtaNCback=new TH1F("hCPtaNCback","hCPta_NoCuts_Background",100,0.,1.);
606   TH1F *hd0xd0NCback=new TH1F("hd0xd0NCback","hd0xd0_NoCuts_Background",1000,-100000.,100000.);
607   TH1F *hMassTrueNCback=new TH1F("hMassTrueNCback","D^{0} MC inv. Mass No Cuts Background(All momenta)",600,1.600,2.200);
608   TH1F *hMassNCback=new TH1F("hMassNCback","D^{0} inv. Mass No Cuts Background (All momenta)",600,1.600,2.200);
609   hMassNCback->Sumw2();
610   TH1F *hMassTrueNCbackPM=new TH1F("hMassTrueNCbackPM","D^{0} MC inv. Mass No Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
611   TH1F *hMassNCbackPM=new TH1F("hMassNCbackPM","D^{0} inv. Mass No Cuts Background (All momenta), MassPeak",600,1.600,2.200);
612   hMassNCbackPM->Sumw2();
613   TH1F *hMassTrueNCbackSB=new TH1F("hMassTrueNCbackSB","D^{0} MC inv. Mass in Side Bands No Cuts Background(All momenta)",600,1.600,2.200);
614   TH1F *hMassNCbackSB=new TH1F("hMassNCbackSB","D^{0} inv. Mass in Side Bands No Cuts Background (All momenta)",600,1.600,2.200);
615   hMassNCbackSB->Sumw2();
616
617   flistNoCutsBack->Add(hCPtaVSd0d0NCback);
618   flistNoCutsBack->Add(hSecVtxZNCback);
619   flistNoCutsBack->Add(hSecVtxYNCback);
620   flistNoCutsBack->Add(hSecVtxXNCback);
621   flistNoCutsBack->Add(hSecVtxXYNCback);
622   flistNoCutsBack->Add(hSecVtxPhiNCback);
623   flistNoCutsBack->Add(hCPtaNCback);
624   flistNoCutsBack->Add(hd0xd0NCback);
625   flistNoCutsBack->Add(hMassTrueNCback);
626   flistNoCutsBack->Add(hMassNCback);
627   flistNoCutsBack->Add(hMassTrueNCbackPM);
628   flistNoCutsBack->Add(hMassNCbackPM);
629   flistNoCutsBack->Add(hMassTrueNCbackSB);
630   flistNoCutsBack->Add(hMassNCbackSB);
631
632
633   // ####### d0 D0 histos ############
634   
635  TH1F *hd0D0NCbackPM = new TH1F("hd0D0NCbackPM","D^{0} impact par. plot , No Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
636   hd0D0NCbackPM->SetXTitle("Impact parameter [#mum]");
637   hd0D0NCbackPM->SetYTitle("Entries");
638
639   TH1F *hd0D0VtxTrueNCbackPM = new TH1F("hd0D0VtxTrueNCbackPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
640   hd0D0VtxTrueNCbackPM->SetXTitle("Impact parameter [#mum]");
641   hd0D0VtxTrueNCbackPM->SetYTitle("Entries");
642
643   TH1F *hMCd0D0NCbackPM = new TH1F("hMCd0D0NCbackPM","D^{0} impact par. plot, No Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
644   hMCd0D0NCbackPM->SetXTitle("MC Impact parameter [#mum]");
645   hMCd0D0NCbackPM->SetYTitle("Entries");
646
647   TH1F *hd0D0NCbackSB = new TH1F("hd0D0NCbackSB","D^{0} impact par. plot , No Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
648   hd0D0NCbackSB->SetXTitle("Impact parameter [#mum]");
649   hd0D0NCbackSB->SetYTitle("Entries");
650
651   TH1F *hd0D0VtxTrueNCbackSB = new TH1F("hd0D0VtxTrueNCbackSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
652   hd0D0VtxTrueNCbackSB->SetXTitle("Impact parameter [#mum]");
653   hd0D0VtxTrueNCbackSB->SetYTitle("Entries");
654
655   TH1F *hMCd0D0NCbackSB = new TH1F("hMCd0D0NCbackSB","D^{0} impact par. plot, No Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
656   hMCd0D0NCbackSB->SetXTitle("MC Impact parameter [#mum]");
657   hMCd0D0NCbackSB->SetYTitle("Entries");
658
659   flistNoCutsBack->Add(hd0D0NCbackPM);
660   flistNoCutsBack->Add(hd0D0VtxTrueNCbackPM);
661   flistNoCutsBack->Add(hMCd0D0NCbackPM);
662   flistNoCutsBack->Add(hd0D0NCbackSB);
663   flistNoCutsBack->Add(hd0D0VtxTrueNCbackSB);
664   flistNoCutsBack->Add(hMCd0D0NCbackSB);
665   
666   TH1F **hd0D0ptNCbackPM=new TH1F*[fnbins];
667   TH1F **hMCd0D0ptNCbackPM=new TH1F*[fnbins];
668   TH1F ** hd0D0VtxTrueptNCbackPM=new TH1F*[fnbins];
669   TH1F **hd0D0ptNCbackSB=new TH1F*[fnbins];
670   TH1F **hMCd0D0ptNCbackSB=new TH1F*[fnbins];
671   TH1F ** hd0D0VtxTrueptNCbackSB=new TH1F*[fnbins];
672   namehist="hd0D0ptNCback_";
673   titlehist="D^{0} impact par. plot, No Cuts, Background, ";
674   for(Int_t i=0;i<fnbins;i++){
675     strnamept=namehist;
676     strnamept.Append("PkMss_pt");
677     strnamept+=i;
678
679     strtitlept=titlehist;
680     strtitlept.Append(" Mass Peak, ");
681     strtitlept+=fptbins[i];
682     strtitlept.Append("<= pt <");
683     strtitlept+=fptbins[i+1];
684     strtitlept.Append(" [GeV/c]");
685     
686     hd0D0ptNCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
687     hd0D0ptNCbackPM[i]->SetXTitle("Impact parameter [#mum] ");
688     hd0D0ptNCbackPM[i]->SetYTitle("Entries");
689     flistNoCutsBack->Add(hd0D0ptNCbackPM[i]);
690
691     strnamept.ReplaceAll("hd0D0","hMCd0D0");
692     hMCd0D0ptNCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
693     hMCd0D0ptNCbackPM[i]->SetXTitle("MC Impact parameter [#mum] ");
694     hMCd0D0ptNCbackPM[i]->SetYTitle("Entries");
695     flistNoCutsBack->Add(hMCd0D0ptNCbackPM[i]);
696  
697
698     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
699     hd0D0VtxTrueptNCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
700     hd0D0VtxTrueptNCbackPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
701     hd0D0VtxTrueptNCbackPM[i]->SetYTitle("Entries");
702     flistNoCutsBack->Add(hd0D0VtxTrueptNCbackPM[i]);
703     
704     strnamept=namehist;
705     strnamept.Append("SBMss_pt");
706     strnamept+=i;
707
708     strtitlept=titlehist;
709     strtitlept.Append(" Side Bands, ");
710     strtitlept+=fptbins[i];
711     strtitlept.Append("<= pt <");
712     strtitlept+=fptbins[i+1];
713     strtitlept.Append(" [GeV/c]");
714     
715     hd0D0ptNCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
716     hd0D0ptNCbackSB[i]->SetXTitle("Impact parameter [#mum] ");
717     hd0D0ptNCbackSB[i]->SetYTitle("Entries");
718     flistNoCutsBack->Add(hd0D0ptNCbackSB[i]);
719
720     strnamept.ReplaceAll("hd0D0","hMCd0D0");
721     hMCd0D0ptNCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
722     hMCd0D0ptNCbackSB[i]->SetXTitle("MC Impact parameter [#mum] ");
723     hMCd0D0ptNCbackSB[i]->SetYTitle("Entries");
724     flistNoCutsBack->Add(hMCd0D0ptNCbackSB[i]);
725
726     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
727     hd0D0VtxTrueptNCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
728     hd0D0VtxTrueptNCbackSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
729     hd0D0VtxTrueptNCbackSB[i]->SetYTitle("Entries");
730     flistNoCutsBack->Add(hd0D0VtxTrueptNCbackSB[i]);
731   }
732
733
734
735  //############ NO CUTS FROMB HISTOGRAMS ###########
736   //
737   //#######  global properties histos
738
739   TH2F *hCPtaVSd0d0NCfromB=new TH2F("hCPtaVSd0d0NCfromB","hCPtaVSd0d0_NoCuts_FromB",1000,-100000.,100000.,100,0.,1.);
740   TH1F *hSecVtxZNCfromB=new TH1F("hSecVtxZNCfromB","hSecVtxZ_NoCuts_FromB",1000,-8.,8.);
741   TH1F *hSecVtxXNCfromB=new TH1F("hSecVtxXNCfromB","hSecVtxX_NoCuts_FromB",1000,-3000.,3000.);
742   TH1F *hSecVtxYNCfromB=new TH1F("hSecVtxYNCfromB","hSecVtxY_NoCuts_FromB",1000,-3000.,3000.);
743   TH2F *hSecVtxXYNCfromB=new TH2F("hSecVtxXYNCfromB","hSecVtxXY_NoCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
744   TH1F *hSecVtxPhiNCfromB=new TH1F("hSecVtxPhiNCfromB","hSecVtxPhi_NoCuts_FromB",180,-180.1,180.1);
745   TH1F *hCPtaNCfromB=new TH1F("hCPtaNCfromB","hCPta_NoCuts_FromB",100,0.,1.);
746   TH1F *hd0xd0NCfromB=new TH1F("hd0xd0NCfromB","hd0xd0_NoCuts_FromB",1000,-100000.,100000.);
747   TH1F *hMassTrueNCfromB=new TH1F("hMassTrueNCfromB","D^{0} MC inv. Mass No Cuts FromB(All momenta)",600,1.600,2.200);
748   TH1F *hMassNCfromB=new TH1F("hMassNCfromB","D^{0} inv. Mass No Cuts FromB (All momenta)",600,1.600,2.200);
749   hMassNCfromB->Sumw2();
750   TH1F *hMassTrueNCfromBPM=new TH1F("hMassTrueNCfromBPM","D^{0} MC inv. Mass No Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
751   TH1F *hMassNCfromBPM=new TH1F("hMassNCfromBPM","D^{0} inv. Mass No Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
752   hMassNCfromB->Sumw2();
753   TH1F *hMassTrueNCfromBSB=new TH1F("hMassTrueNCfromBSB","D^{0} MC inv. Mass in Side Bands No Cuts FromB(All momenta)",600,1.600,2.200);
754   TH1F *hMassNCfromBSB=new TH1F("hMassNCfromBSB","D^{0} inv. Mass in Side Bands No Cuts FromB (All momenta)",600,1.600,2.200);
755   hMassNCfromBSB->Sumw2();
756
757   flistNoCutsFromB->Add(hCPtaVSd0d0NCfromB);
758   flistNoCutsFromB->Add(hSecVtxZNCfromB);
759   flistNoCutsFromB->Add(hSecVtxYNCfromB);
760   flistNoCutsFromB->Add(hSecVtxXNCfromB);
761   flistNoCutsFromB->Add(hSecVtxXYNCfromB);
762   flistNoCutsFromB->Add(hSecVtxPhiNCfromB);
763   flistNoCutsFromB->Add(hCPtaNCfromB);
764   flistNoCutsFromB->Add(hd0xd0NCfromB);
765   flistNoCutsFromB->Add(hMassTrueNCfromB);
766   flistNoCutsFromB->Add(hMassNCfromB);
767   flistNoCutsFromB->Add(hMassTrueNCfromBPM);
768   flistNoCutsFromB->Add(hMassNCfromBPM);
769   flistNoCutsFromB->Add(hMassTrueNCfromBSB);
770   flistNoCutsFromB->Add(hMassNCfromBSB);
771
772   // ######### d0 D0 histos ##############
773   TH1F *hd0D0NCfromBPM = new TH1F("hd0D0NCfromBPM","D^{0} impact par. plot , No Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
774   hd0D0NCfromBPM->SetXTitle("Impact parameter [#mum]");
775   hd0D0NCfromBPM->SetYTitle("Entries");
776
777   TH1F *hd0D0VtxTrueNCfromBPM = new TH1F("hd0D0VtxTrueNCfromBPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
778   hd0D0VtxTrueNCfromBPM->SetXTitle("Impact parameter [#mum]");
779   hd0D0VtxTrueNCfromBPM->SetYTitle("Entries");
780
781   TH1F *hMCd0D0NCfromBPM = new TH1F("hMCd0D0NCfromBPM","D^{0} impact par. plot, No Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
782   hMCd0D0NCfromBPM->SetXTitle("MC Impact parameter [#mum]");
783   hMCd0D0NCfromBPM->SetYTitle("Entries");
784
785   TH1F *hd0D0NCfromBSB = new TH1F("hd0D0NCfromBSB","D^{0} impact par. plot , No Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
786   hd0D0NCfromBSB->SetXTitle("Impact parameter [#mum]");
787   hd0D0NCfromBSB->SetYTitle("Entries");
788
789   TH1F *hd0D0VtxTrueNCfromBSB = new TH1F("hd0D0VtxTrueNCfromBSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
790   hd0D0VtxTrueNCfromBSB->SetXTitle("Impact parameter [#mum]");
791   hd0D0VtxTrueNCfromBSB->SetYTitle("Entries");
792
793   TH1F *hMCd0D0NCfromBSB = new TH1F("hMCd0D0NCfromBSB","D^{0} impact par. plot, No Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
794   hMCd0D0NCfromBSB->SetXTitle("MC Impact parameter [#mum]");
795   hMCd0D0NCfromBSB->SetYTitle("Entries");
796
797   flistNoCutsFromB->Add(hd0D0NCfromBPM);
798   flistNoCutsFromB->Add(hd0D0VtxTrueNCfromBPM);
799   flistNoCutsFromB->Add(hMCd0D0NCfromBPM);
800   flistNoCutsFromB->Add(hd0D0NCfromBSB);
801   flistNoCutsFromB->Add(hd0D0VtxTrueNCfromBSB);
802   flistNoCutsFromB->Add(hMCd0D0NCfromBSB);
803   
804   TH1F **hd0D0ptNCfromBPM=new TH1F*[fnbins];
805   TH1F **hMCd0D0ptNCfromBPM=new TH1F*[fnbins];
806   TH1F ** hd0D0VtxTrueptNCfromBPM=new TH1F*[fnbins];
807   TH1F **hd0D0ptNCfromBSB=new TH1F*[fnbins];
808   TH1F **hMCd0D0ptNCfromBSB=new TH1F*[fnbins];
809   TH1F ** hd0D0VtxTrueptNCfromBSB=new TH1F*[fnbins];
810   namehist="hd0D0ptNCfromB_";
811   titlehist="D^{0} impact par. plot, No Cuts, FromB, ";
812   for(Int_t i=0;i<fnbins;i++){
813     strnamept=namehist;
814     strnamept.Append("PkMss_pt");
815     strnamept+=i;
816
817     strtitlept=titlehist;
818     strtitlept.Append(" Mass Peak, ");
819     strtitlept+=fptbins[i];
820     strtitlept.Append("<= pt <");
821     strtitlept+=fptbins[i+1];
822     strtitlept.Append(" [GeV/c]");
823     
824     hd0D0ptNCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
825     hd0D0ptNCfromBPM[i]->SetXTitle("Impact parameter [#mum] ");
826     hd0D0ptNCfromBPM[i]->SetYTitle("Entries");
827     flistNoCutsFromB->Add(hd0D0ptNCfromBPM[i]);
828
829     strnamept.ReplaceAll("hd0D0","hMCd0D0");
830     hMCd0D0ptNCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
831     hMCd0D0ptNCfromBPM[i]->SetXTitle("MC Impact parameter [#mum] ");
832     hMCd0D0ptNCfromBPM[i]->SetYTitle("Entries");
833     flistNoCutsFromB->Add(hMCd0D0ptNCfromBPM[i]);
834  
835
836     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
837     hd0D0VtxTrueptNCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
838     hd0D0VtxTrueptNCfromBPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
839     hd0D0VtxTrueptNCfromBPM[i]->SetYTitle("Entries");
840     flistNoCutsFromB->Add(hd0D0VtxTrueptNCfromBPM[i]);
841     
842     strnamept=namehist;
843     strnamept.Append("SBMss_pt");
844     strnamept+=i;
845
846     strtitlept=titlehist;
847     strtitlept.Append(" Side Bands, ");
848     strtitlept+=fptbins[i];
849     strtitlept.Append("<= pt <");
850     strtitlept+=fptbins[i+1];
851     strtitlept.Append(" [GeV/c]");
852     
853     hd0D0ptNCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
854     hd0D0ptNCfromBSB[i]->SetXTitle("Impact parameter [#mum] ");
855     hd0D0ptNCfromBSB[i]->SetYTitle("Entries");
856     flistNoCutsFromB->Add(hd0D0ptNCfromBSB[i]);
857
858     strnamept.ReplaceAll("hd0D0","hMCd0D0");
859     hMCd0D0ptNCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
860     hMCd0D0ptNCfromBSB[i]->SetXTitle("MC Impact parameter [#mum] ");
861     hMCd0D0ptNCfromBSB[i]->SetYTitle("Entries");
862     flistNoCutsFromB->Add(hMCd0D0ptNCfromBSB[i]);
863
864     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
865     hd0D0VtxTrueptNCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
866     hd0D0VtxTrueptNCfromBSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
867     hd0D0VtxTrueptNCfromBSB[i]->SetYTitle("Entries");
868     flistNoCutsFromB->Add(hd0D0VtxTrueptNCfromBSB[i]);
869   }
870
871
872
873   //############ NO CUTS FROM DSTAR HISTOGRAMS ###########
874   //
875   //#############  global properties histos #######
876
877   TH2F *hCPtaVSd0d0NCfromDstar=new TH2F("hCPtaVSd0d0NCfromDstar","hCPtaVSd0d0_NoCuts_FromDStar",1000,-100000.,100000.,100,0.,1.);
878   TH1F *hSecVtxZNCfromDstar=new TH1F("hSecVtxZNCfromDstar","hSecVtxZ_NoCuts_FromDStar",1000,-8.,8.);
879   TH1F *hSecVtxXNCfromDstar=new TH1F("hSecVtxXNCfromDstar","hSecVtxX_NoCuts_FromDStar",1000,-3000.,3000.);
880   TH1F *hSecVtxYNCfromDstar=new TH1F("hSecVtxYNCfromDstar","hSecVtxY_NoCuts_FromDStar",1000,-3000.,3000.);
881   TH2F *hSecVtxXYNCfromDstar=new TH2F("hSecVtxXYNCfromDstar","hSecVtxXY_NoCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
882   TH1F *hSecVtxPhiNCfromDstar=new TH1F("hSecVtxPhiNCfromDstar","hSecVtxPhi_NoCuts_FromDStar",180,-180.1,180.1);
883   TH1F *hCPtaNCfromDstar=new TH1F("hCPtaNCfromDstar","hCPta_NoCuts_FromDStar",100,0.,1.);
884   TH1F *hd0xd0NCfromDstar=new TH1F("hd0xd0NCfromDstar","hd0xd0_NoCuts_FromDStar",1000,-100000.,100000.);
885   TH1F *hMassTrueNCfromDstar=new TH1F("hMassTrueNCfromDstar","D^{0} MC inv. Mass No Cuts FromDStar(All momenta)",600,1.600,2.200);
886   TH1F *hMassNCfromDstar=new TH1F("hMassNCfromDstar","D^{0} inv. Mass No Cuts FromDStar (All momenta)",600,1.600,2.200);
887   hMassNCfromDstar->Sumw2();
888   TH1F *hMassTrueNCfromDstarPM=new TH1F("hMassTrueNCfromDstarPM","D^{0} MC inv. Mass No Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
889   TH1F *hMassNCfromDstarPM=new TH1F("hMassNCfromDstarPM","D^{0} inv. Mass No Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
890   hMassNCfromDstarPM->Sumw2();
891   TH1F *hMassTrueNCfromDstarSB=new TH1F("hMassTrueNCfromDstarSB","D^{0} MC inv. Mass in Side Bands No Cuts FromDStar(All momenta)",600,1.600,2.200);
892   TH1F *hMassNCfromDstarSB=new TH1F("hMassNCfromDstarSB","D^{0} inv. Mass in Side Bands No Cuts FromDStar (All momenta)",600,1.600,2.200);
893   hMassNCfromDstarSB->Sumw2();
894
895   flistNoCutsFromDstar->Add(hCPtaVSd0d0NCfromDstar);
896   flistNoCutsFromDstar->Add(hSecVtxZNCfromDstar);
897   flistNoCutsFromDstar->Add(hSecVtxYNCfromDstar);
898   flistNoCutsFromDstar->Add(hSecVtxXNCfromDstar);
899   flistNoCutsFromDstar->Add(hSecVtxXYNCfromDstar);
900   flistNoCutsFromDstar->Add(hSecVtxPhiNCfromDstar);
901   flistNoCutsFromDstar->Add(hCPtaNCfromDstar);
902   flistNoCutsFromDstar->Add(hd0xd0NCfromDstar);
903   flistNoCutsFromDstar->Add(hMassTrueNCfromDstar);
904   flistNoCutsFromDstar->Add(hMassNCfromDstar);
905   flistNoCutsFromDstar->Add(hMassTrueNCfromDstarPM);
906   flistNoCutsFromDstar->Add(hMassNCfromDstarPM);
907   flistNoCutsFromDstar->Add(hMassTrueNCfromDstarSB);
908   flistNoCutsFromDstar->Add(hMassNCfromDstarSB);
909
910   //########## d0 D0 histos #############  
911   TH1F *hd0D0NCfromDstPM = new TH1F("hd0D0NCfromDstarPM","D^{0} impact par. plot , No Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
912   hd0D0NCfromDstPM->SetXTitle("Impact parameter [#mum]");
913   hd0D0NCfromDstPM->SetYTitle("Entries");
914
915   TH1F *hd0D0VtxTrueNCfromDstPM = new TH1F("hd0D0VtxTrueNCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
916   hd0D0VtxTrueNCfromDstPM->SetXTitle("Impact parameter [#mum]");
917   hd0D0VtxTrueNCfromDstPM->SetYTitle("Entries");
918
919   TH1F *hMCd0D0NCfromDstPM = new TH1F("hMCd0D0NCfromDstarPM","D^{0} impact par. plot, No Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
920   hMCd0D0NCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
921   hMCd0D0NCfromDstPM->SetYTitle("Entries");
922
923   TH1F *hd0D0NCfromDstSB = new TH1F("hd0D0NCfromDstarSB","D^{0} impact par. plot , No Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
924   hd0D0NCfromDstSB->SetXTitle("Impact parameter [#mum]");
925   hd0D0NCfromDstSB->SetYTitle("Entries");
926
927   TH1F *hd0D0VtxTrueNCfromDstSB = new TH1F("hd0D0VtxTrueNCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
928   hd0D0VtxTrueNCfromDstSB->SetXTitle("Impact parameter [#mum]");
929   hd0D0VtxTrueNCfromDstSB->SetYTitle("Entries");
930
931   TH1F *hMCd0D0NCfromDstSB = new TH1F("hMCd0D0NCfromDstarSB","D^{0} impact par. plot, No Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
932   hMCd0D0NCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
933   hMCd0D0NCfromDstSB->SetYTitle("Entries");
934
935   flistNoCutsFromDstar->Add(hd0D0NCfromDstPM);
936   flistNoCutsFromDstar->Add(hd0D0VtxTrueNCfromDstPM);
937   flistNoCutsFromDstar->Add(hMCd0D0NCfromDstPM);
938   flistNoCutsFromDstar->Add(hd0D0NCfromDstSB);
939   flistNoCutsFromDstar->Add(hd0D0VtxTrueNCfromDstSB);
940   flistNoCutsFromDstar->Add(hMCd0D0NCfromDstSB);
941   
942   TH1F **hd0D0ptNCfromDstPM=new TH1F*[fnbins];
943   TH1F **hMCd0D0ptNCfromDstPM=new TH1F*[fnbins];
944   TH1F ** hd0D0VtxTrueptNCfromDstPM=new TH1F*[fnbins];
945   TH1F **hd0D0ptNCfromDstSB=new TH1F*[fnbins];
946   TH1F **hMCd0D0ptNCfromDstSB=new TH1F*[fnbins];
947   TH1F ** hd0D0VtxTrueptNCfromDstSB=new TH1F*[fnbins];
948   namehist="hd0D0ptNCfromDstar_";
949   titlehist="D^{0} impact par. plot, No Cuts, FromDStar, ";
950   for(Int_t i=0;i<fnbins;i++){
951     strnamept=namehist;
952     strnamept.Append("PkMss_pt");
953     strnamept+=i;
954
955     strtitlept=titlehist;
956     strtitlept.Append(" Mass Peak, ");
957     strtitlept+=fptbins[i];
958     strtitlept.Append("<= pt <");
959     strtitlept+=fptbins[i+1];
960     strtitlept.Append(" [GeV/c]");
961     
962     hd0D0ptNCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
963     hd0D0ptNCfromDstPM[i]->SetXTitle("Impact parameter [#mum] ");
964     hd0D0ptNCfromDstPM[i]->SetYTitle("Entries");
965     flistNoCutsFromDstar->Add(hd0D0ptNCfromDstPM[i]);
966
967     strnamept.ReplaceAll("hd0D0","hMCd0D0");
968     hMCd0D0ptNCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
969     hMCd0D0ptNCfromDstPM[i]->SetXTitle("MC Impact parameter [#mum] ");
970     hMCd0D0ptNCfromDstPM[i]->SetYTitle("Entries");
971     flistNoCutsFromDstar->Add(hMCd0D0ptNCfromDstPM[i]);
972  
973
974     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
975     hd0D0VtxTrueptNCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
976     hd0D0VtxTrueptNCfromDstPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
977     hd0D0VtxTrueptNCfromDstPM[i]->SetYTitle("Entries");
978     flistNoCutsFromDstar->Add(hd0D0VtxTrueptNCfromDstPM[i]);
979     
980     strnamept=namehist;
981     strnamept.Append("SBMss_pt");
982     strnamept+=i;
983
984     strtitlept=titlehist;
985     strtitlept.Append(" Side Bands, ");
986     strtitlept+=fptbins[i];
987     strtitlept.Append("<= pt <");
988     strtitlept+=fptbins[i+1];
989     strtitlept.Append(" [GeV/c]");
990     
991     hd0D0ptNCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
992     hd0D0ptNCfromDstSB[i]->SetXTitle("Impact parameter [#mum] ");
993     hd0D0ptNCfromDstSB[i]->SetYTitle("Entries");
994     flistNoCutsFromDstar->Add(hd0D0ptNCfromDstSB[i]);
995
996     strnamept.ReplaceAll("hd0D0","hMCd0D0");
997     hMCd0D0ptNCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
998     hMCd0D0ptNCfromDstSB[i]->SetXTitle("MC Impact parameter [#mum] ");
999     hMCd0D0ptNCfromDstSB[i]->SetYTitle("Entries");
1000     flistNoCutsFromDstar->Add(hMCd0D0ptNCfromDstSB[i]);
1001
1002     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1003     hd0D0VtxTrueptNCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1004     hd0D0VtxTrueptNCfromDstSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1005     hd0D0VtxTrueptNCfromDstSB[i]->SetYTitle("Entries");
1006     flistNoCutsFromDstar->Add(hd0D0VtxTrueptNCfromDstSB[i]);
1007   }
1008
1009
1010   //############ NO CUTS OTHER HISTOGRAMS ###########
1011   //
1012   //########### global properties histos ###########
1013
1014   TH2F *hCPtaVSd0d0NCother=new TH2F("hCPtaVSd0d0NCother","hCPtaVSd0d0_NoCuts_other",1000,-100000.,100000.,100,0.,1.);
1015   TH1F *hSecVtxZNCother=new TH1F("hSecVtxZNCother","hSecVtxZ_NoCuts_other",1000,-8.,8.);
1016   TH1F *hSecVtxXNCother=new TH1F("hSecVtxXNCother","hSecVtxX_NoCuts_other",1000,-3000.,3000.);
1017   TH1F *hSecVtxYNCother=new TH1F("hSecVtxYNCother","hSecVtxY_NoCuts_other",1000,-3000.,3000.);
1018   TH2F *hSecVtxXYNCother=new TH2F("hSecVtxXYNCother","hSecVtxXY_NoCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
1019   TH1F *hSecVtxPhiNCother=new TH1F("hSecVtxPhiNCother","hSecVtxPhi_NoCuts_other",180,-180.1,180.1);
1020   TH1F *hCPtaNCother=new TH1F("hCPtaNCother","hCPta_NoCuts_other",100,0.,1.);
1021   TH1F *hd0xd0NCother=new TH1F("hd0xd0NCother","hd0xd0_NoCuts_other",1000,-100000.,100000.);
1022   TH1F *hMassTrueNCother=new TH1F("hMassTrueNCother","D^{0} MC inv. Mass No Cuts other(All momenta)",600,1.600,2.200);
1023   TH1F *hMassNCother=new TH1F("hMassNCother","D^{0} inv. Mass No Cuts other (All momenta)",600,1.600,2.200);
1024   hMassNCother->Sumw2();
1025   TH1F *hMassTrueNCotherPM=new TH1F("hMassTrueNCotherPM","D^{0} MC inv. Mass No Cuts Other, Mass Peak. (All momenta)",600,1.600,2.200);
1026   TH1F *hMassNCotherPM=new TH1F("hMassNCotherPM","D^{0} inv. Mass No Cuts Other (All momenta), MassPeak",600,1.600,2.200);
1027   hMassNCotherPM->Sumw2();
1028   TH1F *hMassTrueNCotherSB=new TH1F("hMassTrueNCotherSB","D^{0} MC inv. Mass in Side Bands No Cuts other(All momenta)",600,1.600,2.200);
1029   TH1F *hMassNCotherSB=new TH1F("hMassNCotherSB","D^{0} inv. Mass in Side Bands No Cuts other (All momenta)",600,1.600,2.200);
1030   hMassNCotherSB->Sumw2();
1031
1032   flistNoCutsOther->Add(hCPtaVSd0d0NCother);
1033   flistNoCutsOther->Add(hSecVtxZNCother);
1034   flistNoCutsOther->Add(hSecVtxYNCother);
1035   flistNoCutsOther->Add(hSecVtxXNCother);
1036   flistNoCutsOther->Add(hSecVtxXYNCother);
1037   flistNoCutsOther->Add(hSecVtxPhiNCother);
1038   flistNoCutsOther->Add(hCPtaNCother);
1039   flistNoCutsOther->Add(hd0xd0NCother);
1040   flistNoCutsOther->Add(hMassTrueNCother);
1041   flistNoCutsOther->Add(hMassNCother);
1042   flistNoCutsOther->Add(hMassTrueNCotherPM);
1043   flistNoCutsOther->Add(hMassNCotherPM);
1044   flistNoCutsOther->Add(hMassTrueNCotherSB);
1045   flistNoCutsOther->Add(hMassNCotherSB);
1046
1047   //############# d0 D0 histos ###############à
1048   TH1F *hd0D0NCotherPM = new TH1F("hd0D0NCotherPM","D^{0} impact par. plot , No Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1049   hd0D0NCotherPM->SetXTitle("Impact parameter [#mum]");
1050   hd0D0NCotherPM->SetYTitle("Entries");
1051
1052   TH1F *hd0D0VtxTrueNCotherPM = new TH1F("hd0D0VtxTrueNCotherPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1053   hd0D0VtxTrueNCotherPM->SetXTitle("Impact parameter [#mum]");
1054   hd0D0VtxTrueNCotherPM->SetYTitle("Entries");
1055
1056   TH1F *hMCd0D0NCotherPM = new TH1F("hMCd0D0NCotherPM","D^{0} impact par. plot, No Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
1057   hMCd0D0NCotherPM->SetXTitle("MC Impact parameter [#mum]");
1058   hMCd0D0NCotherPM->SetYTitle("Entries");
1059
1060   TH1F *hd0D0NCotherSB = new TH1F("hd0D0NCotherSB","D^{0} impact par. plot , No Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1061   hd0D0NCotherSB->SetXTitle("Impact parameter [#mum]");
1062   hd0D0NCotherSB->SetYTitle("Entries");
1063
1064   TH1F *hd0D0VtxTrueNCotherSB = new TH1F("hd0D0VtxTrueNCotherSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1065   hd0D0VtxTrueNCotherSB->SetXTitle("Impact parameter [#mum]");
1066   hd0D0VtxTrueNCotherSB->SetYTitle("Entries");
1067
1068   TH1F *hMCd0D0NCotherSB = new TH1F("hMCd0D0NCotherSB","D^{0} impact par. plot, No Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
1069   hMCd0D0NCotherSB->SetXTitle("MC Impact parameter [#mum]");
1070   hMCd0D0NCotherSB->SetYTitle("Entries");
1071
1072   flistNoCutsOther->Add(hd0D0NCotherPM);
1073   flistNoCutsOther->Add(hd0D0VtxTrueNCotherPM);
1074   flistNoCutsOther->Add(hMCd0D0NCotherPM);
1075   flistNoCutsOther->Add(hd0D0NCotherSB);
1076   flistNoCutsOther->Add(hd0D0VtxTrueNCotherSB);
1077   flistNoCutsOther->Add(hMCd0D0NCotherSB);
1078   
1079   TH1F **hd0D0ptNCotherPM=new TH1F*[fnbins];
1080   TH1F **hMCd0D0ptNCotherPM=new TH1F*[fnbins];
1081   TH1F ** hd0D0VtxTrueptNCotherPM=new TH1F*[fnbins];
1082   TH1F **hd0D0ptNCotherSB=new TH1F*[fnbins];
1083   TH1F **hMCd0D0ptNCotherSB=new TH1F*[fnbins];
1084   TH1F ** hd0D0VtxTrueptNCotherSB=new TH1F*[fnbins];
1085   namehist="hd0D0ptNCother_";
1086   titlehist="D^{0} impact par. plot, No Cuts, Other, ";
1087   for(Int_t i=0;i<fnbins;i++){
1088     strnamept=namehist;
1089     strnamept.Append("PkMss_pt");
1090     strnamept+=i;
1091
1092     strtitlept=titlehist;
1093     strtitlept.Append(" Mass Peak, ");
1094     strtitlept+=fptbins[i];
1095     strtitlept.Append("<= pt <");
1096     strtitlept+=fptbins[i+1];
1097     strtitlept.Append(" [GeV/c]");
1098     
1099     hd0D0ptNCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1100     hd0D0ptNCotherPM[i]->SetXTitle("Impact parameter [#mum] ");
1101     hd0D0ptNCotherPM[i]->SetYTitle("Entries");
1102     flistNoCutsOther->Add(hd0D0ptNCotherPM[i]);
1103
1104     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1105     hMCd0D0ptNCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1106     hMCd0D0ptNCotherPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1107     hMCd0D0ptNCotherPM[i]->SetYTitle("Entries");
1108     flistNoCutsOther->Add(hMCd0D0ptNCotherPM[i]);
1109  
1110
1111     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1112     hd0D0VtxTrueptNCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1113     hd0D0VtxTrueptNCotherPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1114     hd0D0VtxTrueptNCotherPM[i]->SetYTitle("Entries");
1115     flistNoCutsOther->Add(hd0D0VtxTrueptNCotherPM[i]);
1116     
1117     strnamept=namehist;
1118     strnamept.Append("SBMss_pt");
1119     strnamept+=i;
1120
1121     strtitlept=titlehist;
1122     strtitlept.Append(" Side Bands, ");
1123     strtitlept+=fptbins[i];
1124     strtitlept.Append("<= pt <");
1125     strtitlept+=fptbins[i+1];
1126     strtitlept.Append(" [GeV/c]");
1127     
1128     hd0D0ptNCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1129     hd0D0ptNCotherSB[i]->SetXTitle("Impact parameter [#mum] ");
1130     hd0D0ptNCotherSB[i]->SetYTitle("Entries");
1131     flistNoCutsOther->Add(hd0D0ptNCotherSB[i]);
1132
1133     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1134     hMCd0D0ptNCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1135     hMCd0D0ptNCotherSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1136     hMCd0D0ptNCotherSB[i]->SetYTitle("Entries");
1137     flistNoCutsOther->Add(hMCd0D0ptNCotherSB[i]);
1138
1139     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1140     hd0D0VtxTrueptNCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1141     hd0D0VtxTrueptNCotherSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1142     hd0D0VtxTrueptNCotherSB[i]->SetYTitle("Entries");
1143     flistNoCutsOther->Add(hd0D0VtxTrueptNCotherSB[i]);
1144   }
1145
1146
1147   //################################################################################################
1148   //                                                                                               #
1149   //                         HISTOS FOR LOOSE CUTS                                                 #
1150   //                                                                                               #
1151   //################################################################################################
1152
1153   //############ LOOSE CUTS SIGNAL HISTOGRAMS ###############
1154   //
1155   // ####### global properties histo ############
1156
1157   TH2F *hCPtaVSd0d0LSCsign=new TH2F("hCPtaVSd0d0LSCsign","hCPtaVSd0d0_LooseCuts_Signal",1000,-100000.,100000.,100,0.,1.);
1158   TH1F *hSecVtxZLSCsign=new TH1F("hSecVtxZLSCsign","hSecVtxZ_LooseCuts_Signal",1000,-8.,8.);
1159   TH1F *hSecVtxXLSCsign=new TH1F("hSecVtxXLSCsign","hSecVtxX_LooseCuts_Signal",1000,-3000.,3000.);
1160   TH1F *hSecVtxYLSCsign=new TH1F("hSecVtxYLSCsign","hSecVtxY_LooseCuts_Signal",1000,-3000.,3000.);
1161   TH2F *hSecVtxXYLSCsign=new TH2F("hSecVtxXYLSCsign","hSecVtxXY_LooseCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
1162   TH1F *hSecVtxPhiLSCsign=new TH1F("hSecVtxPhiLSCsign","hSecVtxPhi_LooseCuts_Signal",180,-180.1,180.1);
1163   TH1F *hCPtaLSCsign=new TH1F("hCPtaLSCsign","hCPta_LooseCuts_Signal",100,0.,1.);
1164   TH1F *hd0xd0LSCsign=new TH1F("hd0xd0LSCsign","hd0xd0_LooseCuts_Signal",1000,-100000.,100000.);
1165   TH1F *hMassTrueLSCsign=new TH1F("hMassTrueLSCsign","D^{0} MC inv. Mass Loose Cuts Signal(All momenta)",600,1.600,2.200);
1166   TH1F *hMassLSCsign=new TH1F("hMassLSCsign","D^{0} inv. Mass Loose Cuts Signal (All momenta)",600,1.600,2.200);
1167   hMassLSCsign->Sumw2();
1168   TH1F *hMassTrueLSCsignPM=new TH1F("hMassTrueLSCsignPM","D^{0} MC inv. Mass Loose Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
1169   TH1F *hMassLSCsignPM=new TH1F("hMassLSCsignPM","D^{0} inv. Mass Loose Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
1170   hMassLSCsignPM->Sumw2();
1171   TH1F *hMassTrueLSCsignSB=new TH1F("hMassTrueLSCsignSB","D^{0} MC inv. Mass in Side Bands Loose Cuts Signal(All momenta)",600,1.600,2.200);
1172   TH1F *hMassLSCsignSB=new TH1F("hMassLSCsignSB","D^{0} inv. Mass in Side Bands Loose Cuts Signal (All momenta)",600,1.600,2.200);
1173   hMassLSCsignSB->Sumw2();
1174
1175   flistLsCutsSignal->Add(hCPtaVSd0d0LSCsign);
1176   flistLsCutsSignal->Add(hSecVtxZLSCsign);
1177   flistLsCutsSignal->Add(hSecVtxYLSCsign);
1178   flistLsCutsSignal->Add(hSecVtxXLSCsign);
1179   flistLsCutsSignal->Add(hSecVtxXYLSCsign);
1180   flistLsCutsSignal->Add(hSecVtxPhiLSCsign);
1181   flistLsCutsSignal->Add(hCPtaLSCsign);
1182   flistLsCutsSignal->Add(hd0xd0LSCsign);
1183   flistLsCutsSignal->Add(hMassTrueLSCsign);
1184   flistLsCutsSignal->Add(hMassLSCsign);
1185   flistLsCutsSignal->Add(hMassTrueLSCsignPM);
1186   flistLsCutsSignal->Add(hMassLSCsignPM);
1187   flistLsCutsSignal->Add(hMassTrueLSCsignSB);
1188   flistLsCutsSignal->Add(hMassLSCsignSB);
1189
1190   // ####### d0 D0 histos ############
1191   TH1F *hd0D0LSCsignPM = new TH1F("hd0D0LSCsignPM","D^{0} impact par. plot , Loose Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1192   hd0D0LSCsignPM->SetXTitle("Impact parameter [#mum]");
1193   hd0D0LSCsignPM->SetYTitle("Entries");
1194
1195   TH1F *hd0D0VtxTrueLSCsignPM = new TH1F("hd0D0VtxTrueLSCsignPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1196   hd0D0VtxTrueLSCsignPM->SetXTitle("Impact parameter [#mum]");
1197   hd0D0VtxTrueLSCsignPM->SetYTitle("Entries");
1198
1199   TH1F *hMCd0D0LSCsignPM = new TH1F("hMCd0D0LSCsignPM","D^{0} impact par. plot, Loose Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
1200   hMCd0D0LSCsignPM->SetXTitle("MC Impact parameter [#mum]");
1201   hMCd0D0LSCsignPM->SetYTitle("Entries");
1202
1203   TH1F *hd0D0LSCsignSB = new TH1F("hd0D0LSCsignSB","D^{0} impact par. plot , Loose Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1204   hd0D0LSCsignSB->SetXTitle("Impact parameter [#mum]");
1205   hd0D0LSCsignSB->SetYTitle("Entries");
1206
1207   TH1F *hd0D0VtxTrueLSCsignSB = new TH1F("hd0D0VtxTrueLSCsignSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1208   hd0D0VtxTrueLSCsignSB->SetXTitle("Impact parameter [#mum]");
1209   hd0D0VtxTrueLSCsignSB->SetYTitle("Entries");
1210
1211   TH1F *hMCd0D0LSCsignSB = new TH1F("hMCd0D0LSCsignSB","D^{0} impact par. plot, Loose Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
1212   hMCd0D0LSCsignSB->SetXTitle("MC Impact parameter [#mum]");
1213   hMCd0D0LSCsignSB->SetYTitle("Entries");
1214
1215   flistLsCutsSignal->Add(hd0D0LSCsignPM);
1216   flistLsCutsSignal->Add(hd0D0VtxTrueLSCsignPM);
1217   flistLsCutsSignal->Add(hMCd0D0LSCsignPM);
1218   flistLsCutsSignal->Add(hd0D0LSCsignSB);
1219   flistLsCutsSignal->Add(hd0D0VtxTrueLSCsignSB);
1220   flistLsCutsSignal->Add(hMCd0D0LSCsignSB);
1221   
1222   TH1F **hd0D0ptLSCsignPM=new TH1F*[fnbins];
1223   TH1F **hMCd0D0ptLSCsignPM=new TH1F*[fnbins];
1224   TH1F ** hd0D0VtxTrueptLSCsignPM=new TH1F*[fnbins];
1225   TH1F **hd0D0ptLSCsignSB=new TH1F*[fnbins];
1226   TH1F **hMCd0D0ptLSCsignSB=new TH1F*[fnbins];
1227   TH1F ** hd0D0VtxTrueptLSCsignSB=new TH1F*[fnbins];
1228   namehist="hd0D0ptLSCsign_";
1229   titlehist="D^{0} impact par. plot, Loose Cuts, Signal, ";
1230   for(Int_t i=0;i<fnbins;i++){
1231     strnamept=namehist;
1232     strnamept.Append("PkMss_pt");
1233     strnamept+=i;
1234
1235     strtitlept=titlehist;
1236     strtitlept.Append(" Mass Peak, ");
1237     strtitlept+=fptbins[i];
1238     strtitlept.Append("<= pt <");
1239     strtitlept+=fptbins[i+1];
1240     strtitlept.Append(" [GeV/c]");
1241     
1242     hd0D0ptLSCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1243     hd0D0ptLSCsignPM[i]->SetXTitle("Impact parameter [#mum] ");
1244     hd0D0ptLSCsignPM[i]->SetYTitle("Entries");
1245     flistLsCutsSignal->Add(hd0D0ptLSCsignPM[i]);
1246
1247     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1248     hMCd0D0ptLSCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1249     hMCd0D0ptLSCsignPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1250     hMCd0D0ptLSCsignPM[i]->SetYTitle("Entries");
1251     flistLsCutsSignal->Add(hMCd0D0ptLSCsignPM[i]);
1252  
1253
1254     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1255     hd0D0VtxTrueptLSCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1256     hd0D0VtxTrueptLSCsignPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1257     hd0D0VtxTrueptLSCsignPM[i]->SetYTitle("Entries");
1258     flistLsCutsSignal->Add(hd0D0VtxTrueptLSCsignPM[i]);
1259     
1260     strnamept=namehist;
1261     strnamept.Append("SBMss_pt");
1262     strnamept+=i;
1263
1264     strtitlept=titlehist;
1265     strtitlept.Append(" Side Bands, ");
1266     strtitlept+=fptbins[i];
1267     strtitlept.Append("<= pt <");
1268     strtitlept+=fptbins[i+1];
1269     strtitlept.Append(" [GeV/c]");
1270     
1271     hd0D0ptLSCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1272     hd0D0ptLSCsignSB[i]->SetXTitle("Impact parameter [#mum] ");
1273     hd0D0ptLSCsignSB[i]->SetYTitle("Entries");
1274     flistLsCutsSignal->Add(hd0D0ptLSCsignSB[i]);
1275
1276     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1277     hMCd0D0ptLSCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1278     hMCd0D0ptLSCsignSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1279     hMCd0D0ptLSCsignSB[i]->SetYTitle("Entries");
1280     flistLsCutsSignal->Add(hMCd0D0ptLSCsignSB[i]);
1281
1282     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1283     hd0D0VtxTrueptLSCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1284     hd0D0VtxTrueptLSCsignSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1285     hd0D0VtxTrueptLSCsignSB[i]->SetYTitle("Entries");
1286     flistLsCutsSignal->Add(hd0D0VtxTrueptLSCsignSB[i]);
1287   }
1288
1289
1290   //############ LOOSE CUTS BACKGROUND HISTOGRAMS ###########
1291   //
1292   //   ######## global properties histos #######
1293   TH2F *hCPtaVSd0d0LSCback=new TH2F("hCPtaVSd0d0LSCback","hCPtaVSd0d0_LooseCuts_Background",1000,-100000.,100000.,100,0.,1.);
1294   TH1F *hSecVtxZLSCback=new TH1F("hSecVtxZLSCback","hSecVtxZ_LooseCuts_Background",1000,-8.,8.);
1295   TH1F *hSecVtxXLSCback=new TH1F("hSecVtxXLSCback","hSecVtxX_LooseCuts_Background",1000,-3000.,3000.);
1296   TH1F *hSecVtxYLSCback=new TH1F("hSecVtxYLSCback","hSecVtxY_LooseCuts_Background",1000,-3000.,3000.);
1297   TH2F *hSecVtxXYLSCback=new TH2F("hSecVtxXYLSCback","hSecVtxXY_LooseCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
1298   TH1F *hSecVtxPhiLSCback=new TH1F("hSecVtxPhiLSCback","hSecVtxPhi_LooseCuts_Background",180,-180.1,180.1);
1299   TH1F *hCPtaLSCback=new TH1F("hCPtaLSCback","hCPta_LooseCuts_Background",100,0.,1.);
1300   TH1F *hd0xd0LSCback=new TH1F("hd0xd0LSCback","hd0xd0_LooseCuts_Background",1000,-100000.,100000.);
1301   TH1F *hMassTrueLSCback=new TH1F("hMassTrueLSCback","D^{0} MC inv. Mass Loose Cuts Background(All momenta)",600,1.600,2.200);
1302   TH1F *hMassLSCback=new TH1F("hMassLSCback","D^{0} inv. Mass Loose Cuts Background (All momenta)",600,1.600,2.200);
1303   hMassLSCback->Sumw2();
1304   TH1F *hMassTrueLSCbackPM=new TH1F("hMassTrueLSCbackPM","D^{0} MC inv. Mass Loose Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
1305   TH1F *hMassLSCbackPM=new TH1F("hMassLSCbackPM","D^{0} inv. Mass Loose Cuts Background (All momenta), MassPeak",600,1.600,2.200);
1306   hMassLSCbackPM->Sumw2();
1307   TH1F *hMassTrueLSCbackSB=new TH1F("hMassTrueLSCbackSB","D^{0} MC inv. Mass in Side Bands Loose Cuts Background(All momenta)",600,1.600,2.200);
1308   TH1F *hMassLSCbackSB=new TH1F("hMassLSCbackSB","D^{0} inv. Mass in Side Bands Loose Cuts Background (All momenta)",600,1.600,2.200);
1309   hMassLSCbackSB->Sumw2();
1310
1311   flistLsCutsBack->Add(hCPtaVSd0d0LSCback);
1312   flistLsCutsBack->Add(hSecVtxZLSCback);
1313   flistLsCutsBack->Add(hSecVtxYLSCback);
1314   flistLsCutsBack->Add(hSecVtxXLSCback);
1315   flistLsCutsBack->Add(hSecVtxXYLSCback);
1316   flistLsCutsBack->Add(hSecVtxPhiLSCback);
1317   flistLsCutsBack->Add(hCPtaLSCback);
1318   flistLsCutsBack->Add(hd0xd0LSCback);
1319   flistLsCutsBack->Add(hMassTrueLSCback);
1320   flistLsCutsBack->Add(hMassLSCback);
1321   flistLsCutsBack->Add(hMassTrueLSCbackPM);
1322   flistLsCutsBack->Add(hMassLSCbackPM);
1323   flistLsCutsBack->Add(hMassTrueLSCbackSB);
1324   flistLsCutsBack->Add(hMassLSCbackSB);
1325
1326
1327   // ####### d0 D0 histos ############
1328   
1329  TH1F *hd0D0LSCbackPM = new TH1F("hd0D0LSCbackPM","D^{0} impact par. plot , Loose Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1330   hd0D0LSCbackPM->SetXTitle("Impact parameter [#mum]");
1331   hd0D0LSCbackPM->SetYTitle("Entries");
1332
1333   TH1F *hd0D0VtxTrueLSCbackPM = new TH1F("hd0D0VtxTrueLSCbackPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1334   hd0D0VtxTrueLSCbackPM->SetXTitle("Impact parameter [#mum]");
1335   hd0D0VtxTrueLSCbackPM->SetYTitle("Entries");
1336
1337   TH1F *hMCd0D0LSCbackPM = new TH1F("hMCd0D0LSCbackPM","D^{0} impact par. plot, Loose Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
1338   hMCd0D0LSCbackPM->SetXTitle("MC Impact parameter [#mum]");
1339   hMCd0D0LSCbackPM->SetYTitle("Entries");
1340
1341   TH1F *hd0D0LSCbackSB = new TH1F("hd0D0LSCbackSB","D^{0} impact par. plot , Loose Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1342   hd0D0LSCbackSB->SetXTitle("Impact parameter [#mum]");
1343   hd0D0LSCbackSB->SetYTitle("Entries");
1344
1345   TH1F *hd0D0VtxTrueLSCbackSB = new TH1F("hd0D0VtxTrueLSCbackSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1346   hd0D0VtxTrueLSCbackSB->SetXTitle("Impact parameter [#mum]");
1347   hd0D0VtxTrueLSCbackSB->SetYTitle("Entries");
1348
1349   TH1F *hMCd0D0LSCbackSB = new TH1F("hMCd0D0LSCbackSB","D^{0} impact par. plot, Loose Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
1350   hMCd0D0LSCbackSB->SetXTitle("MC Impact parameter [#mum]");
1351   hMCd0D0LSCbackSB->SetYTitle("Entries");
1352
1353   flistLsCutsBack->Add(hd0D0LSCbackPM);
1354   flistLsCutsBack->Add(hd0D0VtxTrueLSCbackPM);
1355   flistLsCutsBack->Add(hMCd0D0LSCbackPM);
1356   flistLsCutsBack->Add(hd0D0LSCbackSB);
1357   flistLsCutsBack->Add(hd0D0VtxTrueLSCbackSB);
1358   flistLsCutsBack->Add(hMCd0D0LSCbackSB);
1359   
1360   TH1F **hd0D0ptLSCbackPM=new TH1F*[fnbins];
1361   TH1F **hMCd0D0ptLSCbackPM=new TH1F*[fnbins];
1362   TH1F ** hd0D0VtxTrueptLSCbackPM=new TH1F*[fnbins];
1363   TH1F **hd0D0ptLSCbackSB=new TH1F*[fnbins];
1364   TH1F **hMCd0D0ptLSCbackSB=new TH1F*[fnbins];
1365   TH1F ** hd0D0VtxTrueptLSCbackSB=new TH1F*[fnbins];
1366   namehist="hd0D0ptLSCback_";
1367   titlehist="D^{0} impact par. plot, Loose Cuts, Background, ";
1368   for(Int_t i=0;i<fnbins;i++){
1369     strnamept=namehist;
1370     strnamept.Append("PkMss_pt");
1371     strnamept+=i;
1372
1373     strtitlept=titlehist;
1374     strtitlept.Append(" Mass Peak, ");
1375     strtitlept+=fptbins[i];
1376     strtitlept.Append("<= pt <");
1377     strtitlept+=fptbins[i+1];
1378     strtitlept.Append(" [GeV/c]");
1379     
1380     hd0D0ptLSCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1381     hd0D0ptLSCbackPM[i]->SetXTitle("Impact parameter [#mum] ");
1382     hd0D0ptLSCbackPM[i]->SetYTitle("Entries");
1383     flistLsCutsBack->Add(hd0D0ptLSCbackPM[i]);
1384
1385     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1386     hMCd0D0ptLSCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1387     hMCd0D0ptLSCbackPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1388     hMCd0D0ptLSCbackPM[i]->SetYTitle("Entries");
1389     flistLsCutsBack->Add(hMCd0D0ptLSCbackPM[i]);
1390  
1391
1392     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1393     hd0D0VtxTrueptLSCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1394     hd0D0VtxTrueptLSCbackPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1395     hd0D0VtxTrueptLSCbackPM[i]->SetYTitle("Entries");
1396     flistLsCutsBack->Add(hd0D0VtxTrueptLSCbackPM[i]);
1397     
1398     strnamept=namehist;
1399     strnamept.Append("SBMss_pt");
1400     strnamept+=i;
1401
1402     strtitlept=titlehist;
1403     strtitlept.Append(" Side Bands, ");
1404     strtitlept+=fptbins[i];
1405     strtitlept.Append("<= pt <");
1406     strtitlept+=fptbins[i+1];
1407     strtitlept.Append(" [GeV/c]");
1408     
1409     hd0D0ptLSCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1410     hd0D0ptLSCbackSB[i]->SetXTitle("Impact parameter [#mum] ");
1411     hd0D0ptLSCbackSB[i]->SetYTitle("Entries");
1412     flistLsCutsBack->Add(hd0D0ptLSCbackSB[i]);
1413
1414     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1415     hMCd0D0ptLSCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1416     hMCd0D0ptLSCbackSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1417     hMCd0D0ptLSCbackSB[i]->SetYTitle("Entries");
1418     flistLsCutsBack->Add(hMCd0D0ptLSCbackSB[i]);
1419
1420     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1421     hd0D0VtxTrueptLSCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1422     hd0D0VtxTrueptLSCbackSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1423     hd0D0VtxTrueptLSCbackSB[i]->SetYTitle("Entries");
1424     flistLsCutsBack->Add(hd0D0VtxTrueptLSCbackSB[i]);
1425   }
1426
1427
1428
1429  //############ LOOSE CUTS FROMB HISTOGRAMS ###########
1430   //
1431   //#######  global properties histos
1432
1433   TH2F *hCPtaVSd0d0LSCfromB=new TH2F("hCPtaVSd0d0LSCfromB","hCPtaVSd0d0_LooseCuts_FromB",1000,-100000.,100000.,100,0.,1.);
1434   TH1F *hSecVtxZLSCfromB=new TH1F("hSecVtxZLSCfromB","hSecVtxZ_LooseCuts_FromB",1000,-8.,8.);
1435   TH1F *hSecVtxXLSCfromB=new TH1F("hSecVtxXLSCfromB","hSecVtxX_LooseCuts_FromB",1000,-3000.,3000.);
1436   TH1F *hSecVtxYLSCfromB=new TH1F("hSecVtxYLSCfromB","hSecVtxY_LooseCuts_FromB",1000,-3000.,3000.);
1437   TH2F *hSecVtxXYLSCfromB=new TH2F("hSecVtxXYLSCfromB","hSecVtxXY_LooseCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
1438   TH1F *hSecVtxPhiLSCfromB=new TH1F("hSecVtxPhiLSCfromB","hSecVtxPhi_LooseCuts_FromB",180,-180.1,180.1);
1439   TH1F *hCPtaLSCfromB=new TH1F("hCPtaLSCfromB","hCPta_LooseCuts_FromB",100,0.,1.);
1440   TH1F *hd0xd0LSCfromB=new TH1F("hd0xd0LSCfromB","hd0xd0_LooseCuts_FromB",1000,-100000.,100000.);
1441   TH1F *hMassTrueLSCfromB=new TH1F("hMassTrueLSCfromB","D^{0} MC inv. Mass Loose Cuts FromB(All momenta)",600,1.600,2.200);
1442   TH1F *hMassLSCfromB=new TH1F("hMassLSCfromB","D^{0} inv. Mass Loose Cuts FromB (All momenta)",600,1.600,2.200);
1443   hMassLSCfromB->Sumw2();
1444   TH1F *hMassTrueLSCfromBPM=new TH1F("hMassTrueLSCfromBPM","D^{0} MC inv. Mass Loose Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
1445   TH1F *hMassLSCfromBPM=new TH1F("hMassLSCfromBPM","D^{0} inv. Mass Loose Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
1446   hMassLSCfromBPM->Sumw2();
1447   TH1F *hMassTrueLSCfromBSB=new TH1F("hMassTrueLSCfromBSB","D^{0} MC inv. Mass in Side Bands Loose Cuts FromB(All momenta)",600,1.600,2.200);
1448   TH1F *hMassLSCfromBSB=new TH1F("hMassLSCfromBSB","D^{0} inv. Mass in Side Bands Loose Cuts FromB (All momenta)",600,1.600,2.200);
1449   hMassLSCfromBSB->Sumw2();
1450
1451   flistLsCutsFromB->Add(hCPtaVSd0d0LSCfromB);
1452   flistLsCutsFromB->Add(hSecVtxZLSCfromB);
1453   flistLsCutsFromB->Add(hSecVtxYLSCfromB);
1454   flistLsCutsFromB->Add(hSecVtxXLSCfromB);
1455   flistLsCutsFromB->Add(hSecVtxXYLSCfromB);
1456   flistLsCutsFromB->Add(hSecVtxPhiLSCfromB);
1457   flistLsCutsFromB->Add(hCPtaLSCfromB);
1458   flistLsCutsFromB->Add(hd0xd0LSCfromB);
1459   flistLsCutsFromB->Add(hMassTrueLSCfromB);
1460   flistLsCutsFromB->Add(hMassLSCfromB);
1461   flistLsCutsFromB->Add(hMassTrueLSCfromBPM);
1462   flistLsCutsFromB->Add(hMassLSCfromBPM);
1463   flistLsCutsFromB->Add(hMassTrueLSCfromBSB);
1464   flistLsCutsFromB->Add(hMassLSCfromBSB);
1465
1466   // ######### d0 D0 histos ##############
1467   TH1F *hd0D0LSCfromBPM = new TH1F("hd0D0LSCfromBPM","D^{0} impact par. plot , Loose Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1468   hd0D0LSCfromBPM->SetXTitle("Impact parameter [#mum]");
1469   hd0D0LSCfromBPM->SetYTitle("Entries");
1470
1471   TH1F *hd0D0VtxTrueLSCfromBPM = new TH1F("hd0D0VtxTrueLSCfromBPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1472   hd0D0VtxTrueLSCfromBPM->SetXTitle("Impact parameter [#mum]");
1473   hd0D0VtxTrueLSCfromBPM->SetYTitle("Entries");
1474
1475   TH1F *hMCd0D0LSCfromBPM = new TH1F("hMCd0D0LSCfromBPM","D^{0} impact par. plot, Loose Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
1476   hMCd0D0LSCfromBPM->SetXTitle("MC Impact parameter [#mum]");
1477   hMCd0D0LSCfromBPM->SetYTitle("Entries");
1478
1479   TH1F *hd0D0LSCfromBSB = new TH1F("hd0D0LSCfromBSB","D^{0} impact par. plot , Loose Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1480   hd0D0LSCfromBSB->SetXTitle("Impact parameter [#mum]");
1481   hd0D0LSCfromBSB->SetYTitle("Entries");
1482
1483   TH1F *hd0D0VtxTrueLSCfromBSB = new TH1F("hd0D0VtxTrueLSCfromBSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1484   hd0D0VtxTrueLSCfromBSB->SetXTitle("Impact parameter [#mum]");
1485   hd0D0VtxTrueLSCfromBSB->SetYTitle("Entries");
1486
1487   TH1F *hMCd0D0LSCfromBSB = new TH1F("hMCd0D0LSCfromBSB","D^{0} impact par. plot, Loose Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
1488   hMCd0D0LSCfromBSB->SetXTitle("MC Impact parameter [#mum]");
1489   hMCd0D0LSCfromBSB->SetYTitle("Entries");
1490
1491   flistLsCutsFromB->Add(hd0D0LSCfromBPM);
1492   flistLsCutsFromB->Add(hd0D0VtxTrueLSCfromBPM);
1493   flistLsCutsFromB->Add(hMCd0D0LSCfromBPM);
1494   flistLsCutsFromB->Add(hd0D0LSCfromBSB);
1495   flistLsCutsFromB->Add(hd0D0VtxTrueLSCfromBSB);
1496   flistLsCutsFromB->Add(hMCd0D0LSCfromBSB);
1497   
1498   TH1F **hd0D0ptLSCfromBPM=new TH1F*[fnbins];
1499   TH1F **hMCd0D0ptLSCfromBPM=new TH1F*[fnbins];
1500   TH1F ** hd0D0VtxTrueptLSCfromBPM=new TH1F*[fnbins];
1501   TH1F **hd0D0ptLSCfromBSB=new TH1F*[fnbins];
1502   TH1F **hMCd0D0ptLSCfromBSB=new TH1F*[fnbins];
1503   TH1F ** hd0D0VtxTrueptLSCfromBSB=new TH1F*[fnbins];
1504   namehist="hd0D0ptLSCfromB_";
1505   titlehist="D^{0} impact par. plot, Loose Cuts, FromB, ";
1506   for(Int_t i=0;i<fnbins;i++){
1507     strnamept=namehist;
1508     strnamept.Append("PkMss_pt");
1509     strnamept+=i;
1510
1511     strtitlept=titlehist;
1512     strtitlept.Append(" Mass Peak, ");
1513     strtitlept+=fptbins[i];
1514     strtitlept.Append("<= pt <");
1515     strtitlept+=fptbins[i+1];
1516     strtitlept.Append(" [GeV/c]");
1517     
1518     hd0D0ptLSCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1519     hd0D0ptLSCfromBPM[i]->SetXTitle("Impact parameter [#mum] ");
1520     hd0D0ptLSCfromBPM[i]->SetYTitle("Entries");
1521     flistLsCutsFromB->Add(hd0D0ptLSCfromBPM[i]);
1522
1523     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1524     hMCd0D0ptLSCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1525     hMCd0D0ptLSCfromBPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1526     hMCd0D0ptLSCfromBPM[i]->SetYTitle("Entries");
1527     flistLsCutsFromB->Add(hMCd0D0ptLSCfromBPM[i]);
1528  
1529
1530     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1531     hd0D0VtxTrueptLSCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1532     hd0D0VtxTrueptLSCfromBPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1533     hd0D0VtxTrueptLSCfromBPM[i]->SetYTitle("Entries");
1534     flistLsCutsFromB->Add(hd0D0VtxTrueptLSCfromBPM[i]);
1535     
1536     strnamept=namehist;
1537     strnamept.Append("SBMss_pt");
1538     strnamept+=i;
1539
1540     strtitlept=titlehist;
1541     strtitlept.Append(" Side Bands, ");
1542     strtitlept+=fptbins[i];
1543     strtitlept.Append("<= pt <");
1544     strtitlept+=fptbins[i+1];
1545     strtitlept.Append(" [GeV/c]");
1546     
1547     hd0D0ptLSCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1548     hd0D0ptLSCfromBSB[i]->SetXTitle("Impact parameter [#mum] ");
1549     hd0D0ptLSCfromBSB[i]->SetYTitle("Entries");
1550     flistLsCutsFromB->Add(hd0D0ptLSCfromBSB[i]);
1551
1552     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1553     hMCd0D0ptLSCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1554     hMCd0D0ptLSCfromBSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1555     hMCd0D0ptLSCfromBSB[i]->SetYTitle("Entries");
1556     flistLsCutsFromB->Add(hMCd0D0ptLSCfromBSB[i]);
1557
1558     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1559     hd0D0VtxTrueptLSCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1560     hd0D0VtxTrueptLSCfromBSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1561     hd0D0VtxTrueptLSCfromBSB[i]->SetYTitle("Entries");
1562     flistLsCutsFromB->Add(hd0D0VtxTrueptLSCfromBSB[i]);
1563   }
1564
1565
1566
1567  //############ LOOSE CUTS FROM DSTAR HISTOGRAMS ###########
1568  //
1569   //############## global properties histos
1570   TH2F *hCPtaVSd0d0LSCfromDstar=new TH2F("hCPtaVSd0d0LSCfromDstar","hCPtaVSd0d0_LooseCuts_FromDStar",1000,-100000.,100000.,100,0.,1.);
1571   TH1F *hSecVtxZLSCfromDstar=new TH1F("hSecVtxZLSCfromDstar","hSecVtxZ_LooseCuts_FromDStar",1000,-8.,8.);
1572   TH1F *hSecVtxXLSCfromDstar=new TH1F("hSecVtxXLSCfromDstar","hSecVtxX_LooseCuts_FromDStar",1000,-3000.,3000.);
1573   TH1F *hSecVtxYLSCfromDstar=new TH1F("hSecVtxYLSCfromDstar","hSecVtxY_LooseCuts_FromDStar",1000,-3000.,3000.);
1574   TH2F *hSecVtxXYLSCfromDstar=new TH2F("hSecVtxXYLSCfromDstar","hSecVtxXY_LooseCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
1575   TH1F *hSecVtxPhiLSCfromDstar=new TH1F("hSecVtxPhiLSCfromDstar","hSecVtxPhi_LooseCuts_FromDStar",180,-180.1,180.1);
1576   TH1F *hCPtaLSCfromDstar=new TH1F("hCPtaLSCfromDstar","hCPta_LooseCuts_FromDStar",100,0.,1.);
1577   TH1F *hd0xd0LSCfromDstar=new TH1F("hd0xd0LSCfromDstar","hd0xd0_LooseCuts_FromDStar",1000,-100000.,100000.);
1578   TH1F *hMassTrueLSCfromDstar=new TH1F("hMassTrueLSCfromDstar","D^{0} MC inv. Mass Loose Cuts FromDStar(All momenta)",600,1.600,2.200);
1579   TH1F *hMassLSCfromDstar=new TH1F("hMassLSCfromDstar","D^{0} inv. Mass Loose Cuts FromDStar (All momenta)",600,1.600,2.200);
1580   hMassLSCfromDstar->Sumw2();
1581   TH1F *hMassTrueLSCfromDstarPM=new TH1F("hMassTrueLSCfromDstarPM","D^{0} MC inv. Mass Loose Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
1582   TH1F *hMassLSCfromDstarPM=new TH1F("hMassLSCfromDstarPM","D^{0} inv. Mass Loose Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
1583   hMassLSCfromDstarPM->Sumw2();
1584   TH1F *hMassTrueLSCfromDstarSB=new TH1F("hMassTrueLSCfromDstarSB","D^{0} MC inv. Mass in Side Bands Loose Cuts FromDStar(All momenta)",600,1.600,2.200);
1585   TH1F *hMassLSCfromDstarSB=new TH1F("hMassLSCfromDstarSB","D^{0} inv. Mass in Side Bands Loose Cuts FromDStar (All momenta)",600,1.600,2.200);
1586   hMassLSCfromDstarSB->Sumw2();
1587
1588   flistLsCutsFromDstar->Add(hCPtaVSd0d0LSCfromDstar);
1589   flistLsCutsFromDstar->Add(hSecVtxZLSCfromDstar);
1590   flistLsCutsFromDstar->Add(hSecVtxYLSCfromDstar);
1591   flistLsCutsFromDstar->Add(hSecVtxXLSCfromDstar);
1592   flistLsCutsFromDstar->Add(hSecVtxXYLSCfromDstar);
1593   flistLsCutsFromDstar->Add(hSecVtxPhiLSCfromDstar);
1594   flistLsCutsFromDstar->Add(hCPtaLSCfromDstar);
1595   flistLsCutsFromDstar->Add(hd0xd0LSCfromDstar);
1596   flistLsCutsFromDstar->Add(hMassTrueLSCfromDstar);
1597   flistLsCutsFromDstar->Add(hMassLSCfromDstar);
1598  flistLsCutsFromDstar->Add(hMassTrueLSCfromDstarPM);
1599   flistLsCutsFromDstar->Add(hMassLSCfromDstarPM);
1600   flistLsCutsFromDstar->Add(hMassTrueLSCfromDstarSB);
1601   flistLsCutsFromDstar->Add(hMassLSCfromDstarSB);
1602
1603   //########## d0 D0 histos #############  
1604   TH1F *hd0D0LSCfromDstPM = new TH1F("hd0D0LSCfromDstarPM","D^{0} impact par. plot , Loose Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1605   hd0D0LSCfromDstPM->SetXTitle("Impact parameter [#mum]");
1606   hd0D0LSCfromDstPM->SetYTitle("Entries");
1607
1608   TH1F *hd0D0VtxTrueLSCfromDstPM = new TH1F("hd0D0VtxTrueLSCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1609   hd0D0VtxTrueLSCfromDstPM->SetXTitle("Impact parameter [#mum]");
1610   hd0D0VtxTrueLSCfromDstPM->SetYTitle("Entries");
1611
1612   TH1F *hMCd0D0LSCfromDstPM = new TH1F("hMCd0D0LSCfromDstarPM","D^{0} impact par. plot, Loose Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
1613   hMCd0D0LSCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
1614   hMCd0D0LSCfromDstPM->SetYTitle("Entries");
1615
1616   TH1F *hd0D0LSCfromDstSB = new TH1F("hd0D0LSCfromDstarSB","D^{0} impact par. plot , Loose Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1617   hd0D0LSCfromDstSB->SetXTitle("Impact parameter [#mum]");
1618   hd0D0LSCfromDstSB->SetYTitle("Entries");
1619
1620   TH1F *hd0D0VtxTrueLSCfromDstSB = new TH1F("hd0D0VtxTrueLSCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1621   hd0D0VtxTrueLSCfromDstSB->SetXTitle("Impact parameter [#mum]");
1622   hd0D0VtxTrueLSCfromDstSB->SetYTitle("Entries");
1623
1624   TH1F *hMCd0D0LSCfromDstSB = new TH1F("hMCd0D0LSCfromDstarSB","D^{0} impact par. plot, Loose Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
1625   hMCd0D0LSCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
1626   hMCd0D0LSCfromDstSB->SetYTitle("Entries");
1627
1628   flistLsCutsFromDstar->Add(hd0D0LSCfromDstPM);
1629   flistLsCutsFromDstar->Add(hd0D0VtxTrueLSCfromDstPM);
1630   flistLsCutsFromDstar->Add(hMCd0D0LSCfromDstPM);
1631   flistLsCutsFromDstar->Add(hd0D0LSCfromDstSB);
1632   flistLsCutsFromDstar->Add(hd0D0VtxTrueLSCfromDstSB);
1633   flistLsCutsFromDstar->Add(hMCd0D0LSCfromDstSB);
1634   
1635   TH1F **hd0D0ptLSCfromDstPM=new TH1F*[fnbins];
1636   TH1F **hMCd0D0ptLSCfromDstPM=new TH1F*[fnbins];
1637   TH1F ** hd0D0VtxTrueptLSCfromDstPM=new TH1F*[fnbins];
1638   TH1F **hd0D0ptLSCfromDstSB=new TH1F*[fnbins];
1639   TH1F **hMCd0D0ptLSCfromDstSB=new TH1F*[fnbins];
1640   TH1F ** hd0D0VtxTrueptLSCfromDstSB=new TH1F*[fnbins];
1641   namehist="hd0D0ptLSCfromDstar_";
1642   titlehist="D^{0} impact par. plot, Loose Cuts, FromDStar, ";
1643   for(Int_t i=0;i<fnbins;i++){
1644     strnamept=namehist;
1645     strnamept.Append("PkMss_pt");
1646     strnamept+=i;
1647
1648     strtitlept=titlehist;
1649     strtitlept.Append(" Mass Peak, ");
1650     strtitlept+=fptbins[i];
1651     strtitlept.Append("<= pt <");
1652     strtitlept+=fptbins[i+1];
1653     strtitlept.Append(" [GeV/c]");
1654     
1655     hd0D0ptLSCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1656     hd0D0ptLSCfromDstPM[i]->SetXTitle("Impact parameter [#mum] ");
1657     hd0D0ptLSCfromDstPM[i]->SetYTitle("Entries");
1658     flistLsCutsFromDstar->Add(hd0D0ptLSCfromDstPM[i]);
1659
1660     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1661     hMCd0D0ptLSCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1662     hMCd0D0ptLSCfromDstPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1663     hMCd0D0ptLSCfromDstPM[i]->SetYTitle("Entries");
1664     flistLsCutsFromDstar->Add(hMCd0D0ptLSCfromDstPM[i]);
1665  
1666
1667     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1668     hd0D0VtxTrueptLSCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1669     hd0D0VtxTrueptLSCfromDstPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1670     hd0D0VtxTrueptLSCfromDstPM[i]->SetYTitle("Entries");
1671     flistLsCutsFromDstar->Add(hd0D0VtxTrueptLSCfromDstPM[i]);
1672     
1673     strnamept=namehist;
1674     strnamept.Append("SBMss_pt");
1675     strnamept+=i;
1676
1677     strtitlept=titlehist;
1678     strtitlept.Append(" Side Bands, ");
1679     strtitlept+=fptbins[i];
1680     strtitlept.Append("<= pt <");
1681     strtitlept+=fptbins[i+1];
1682     strtitlept.Append(" [GeV/c]");
1683     
1684     hd0D0ptLSCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1685     hd0D0ptLSCfromDstSB[i]->SetXTitle("Impact parameter [#mum] ");
1686     hd0D0ptLSCfromDstSB[i]->SetYTitle("Entries");
1687     flistLsCutsFromDstar->Add(hd0D0ptLSCfromDstSB[i]);
1688
1689     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1690     hMCd0D0ptLSCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1691     hMCd0D0ptLSCfromDstSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1692     hMCd0D0ptLSCfromDstSB[i]->SetYTitle("Entries");
1693     flistLsCutsFromDstar->Add(hMCd0D0ptLSCfromDstSB[i]);
1694
1695     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1696     hd0D0VtxTrueptLSCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1697     hd0D0VtxTrueptLSCfromDstSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1698     hd0D0VtxTrueptLSCfromDstSB[i]->SetYTitle("Entries");
1699     flistLsCutsFromDstar->Add(hd0D0VtxTrueptLSCfromDstSB[i]);
1700   }
1701
1702
1703   //############ LOOSE CUTS OTHER HISTOGRAMS ###########
1704   //
1705   //########### global properties histos ###########
1706
1707   TH2F *hCPtaVSd0d0LSCother=new TH2F("hCPtaVSd0d0LSCother","hCPtaVSd0d0_LooseCuts_other",1000,-100000.,100000.,100,0.,1.);
1708   TH1F *hSecVtxZLSCother=new TH1F("hSecVtxZLSCother","hSecVtxZ_LooseCuts_other",1000,-8.,8.);
1709   TH1F *hSecVtxXLSCother=new TH1F("hSecVtxXLSCother","hSecVtxX_LooseCuts_other",1000,-3000.,3000.);
1710   TH1F *hSecVtxYLSCother=new TH1F("hSecVtxYLSCother","hSecVtxY_LooseCuts_other",1000,-3000.,3000.);
1711   TH2F *hSecVtxXYLSCother=new TH2F("hSecVtxXYLSCother","hSecVtxXY_LooseCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
1712   TH1F *hSecVtxPhiLSCother=new TH1F("hSecVtxPhiLSCother","hSecVtxPhi_LooseCuts_other",180,-180.1,180.1);
1713   TH1F *hCPtaLSCother=new TH1F("hCPtaLSCother","hCPta_LooseCuts_other",100,0.,1.);
1714   TH1F *hd0xd0LSCother=new TH1F("hd0xd0LSCother","hd0xd0_LooseCuts_other",1000,-100000.,100000.);
1715   TH1F *hMassTrueLSCother=new TH1F("hMassTrueLSCother","D^{0} MC inv. Mass Loose Cuts other(All momenta)",600,1.600,2.200);
1716   TH1F *hMassLSCother=new TH1F("hMassLSCother","D^{0} inv. Mass Loose Cuts other (All momenta)",600,1.600,2.200);
1717   hMassLSCother->Sumw2();
1718   TH1F *hMassTrueLSCotherPM=new TH1F("hMassTrueLSCotherPM","D^{0} MC inv. Mass Loose Cuts other, Mass Peak. (All momenta)",600,1.600,2.200);
1719   TH1F *hMassLSCotherPM=new TH1F("hMassLSCotherPM","D^{0} inv. Mass Loose Cuts other (All momenta), MassPeak",600,1.600,2.200);
1720   hMassLSCotherPM->Sumw2();
1721   TH1F *hMassTrueLSCotherSB=new TH1F("hMassTrueLSCotherSB","D^{0} MC inv. Mass in Side Bands Loose Cuts other(All momenta)",600,1.600,2.200);
1722   TH1F *hMassLSCotherSB=new TH1F("hMassLSCotherSB","D^{0} inv. Mass in Side Bands Loose Cuts other (All momenta)",600,1.600,2.200);
1723   hMassLSCotherSB->Sumw2();
1724
1725   flistLsCutsOther->Add(hCPtaVSd0d0LSCother);
1726   flistLsCutsOther->Add(hSecVtxZLSCother);
1727   flistLsCutsOther->Add(hSecVtxYLSCother);
1728   flistLsCutsOther->Add(hSecVtxXLSCother);
1729   flistLsCutsOther->Add(hSecVtxXYLSCother);
1730   flistLsCutsOther->Add(hSecVtxPhiLSCother);
1731   flistLsCutsOther->Add(hCPtaLSCother);
1732   flistLsCutsOther->Add(hd0xd0LSCother);
1733   flistLsCutsOther->Add(hMassTrueLSCother);
1734   flistLsCutsOther->Add(hMassLSCother);
1735   flistLsCutsOther->Add(hMassTrueLSCotherPM);
1736   flistLsCutsOther->Add(hMassLSCotherPM);
1737   flistLsCutsOther->Add(hMassTrueLSCotherSB);
1738   flistLsCutsOther->Add(hMassLSCotherSB);
1739
1740   //############# d0 D0 histos ###############à
1741   TH1F *hd0D0LSCotherPM = new TH1F("hd0D0LSCotherPM","D^{0} impact par. plot , Loose Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1742   hd0D0LSCotherPM->SetXTitle("Impact parameter [#mum]");
1743   hd0D0LSCotherPM->SetYTitle("Entries");
1744
1745   TH1F *hd0D0VtxTrueLSCotherPM = new TH1F("hd0D0VtxTrueLSCotherPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1746   hd0D0VtxTrueLSCotherPM->SetXTitle("Impact parameter [#mum]");
1747   hd0D0VtxTrueLSCotherPM->SetYTitle("Entries");
1748
1749   TH1F *hMCd0D0LSCotherPM = new TH1F("hMCd0D0LSCotherPM","D^{0} impact par. plot, Loose Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
1750   hMCd0D0LSCotherPM->SetXTitle("MC Impact parameter [#mum]");
1751   hMCd0D0LSCotherPM->SetYTitle("Entries");
1752
1753   TH1F *hd0D0LSCotherSB = new TH1F("hd0D0LSCotherSB","D^{0} impact par. plot , Loose Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1754   hd0D0LSCotherSB->SetXTitle("Impact parameter [#mum]");
1755   hd0D0LSCotherSB->SetYTitle("Entries");
1756
1757   TH1F *hd0D0VtxTrueLSCotherSB = new TH1F("hd0D0VtxTrueLSCotherSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
1758   hd0D0VtxTrueLSCotherSB->SetXTitle("Impact parameter [#mum]");
1759   hd0D0VtxTrueLSCotherSB->SetYTitle("Entries");
1760
1761   TH1F *hMCd0D0LSCotherSB = new TH1F("hMCd0D0LSCotherSB","D^{0} impact par. plot, Loose Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
1762   hMCd0D0LSCotherSB->SetXTitle("MC Impact parameter [#mum]");
1763   hMCd0D0LSCotherSB->SetYTitle("Entries");
1764
1765   flistLsCutsOther->Add(hd0D0LSCotherPM);
1766   flistLsCutsOther->Add(hd0D0VtxTrueLSCotherPM);
1767   flistLsCutsOther->Add(hMCd0D0LSCotherPM);
1768   flistLsCutsOther->Add(hd0D0LSCotherSB);
1769   flistLsCutsOther->Add(hd0D0VtxTrueLSCotherSB);
1770   flistLsCutsOther->Add(hMCd0D0LSCotherSB);
1771   
1772   TH1F **hd0D0ptLSCotherPM=new TH1F*[fnbins];
1773   TH1F **hMCd0D0ptLSCotherPM=new TH1F*[fnbins];
1774   TH1F ** hd0D0VtxTrueptLSCotherPM=new TH1F*[fnbins];
1775   TH1F **hd0D0ptLSCotherSB=new TH1F*[fnbins];
1776   TH1F **hMCd0D0ptLSCotherSB=new TH1F*[fnbins];
1777   TH1F ** hd0D0VtxTrueptLSCotherSB=new TH1F*[fnbins];
1778   namehist="hd0D0ptLSCother_";
1779   titlehist="D^{0} impact par. plot, Loose Cuts, Other, ";
1780   for(Int_t i=0;i<fnbins;i++){
1781     strnamept=namehist;
1782     strnamept.Append("PkMss_pt");
1783     strnamept+=i;
1784
1785     strtitlept=titlehist;
1786     strtitlept.Append(" Mass Peak, ");
1787     strtitlept+=fptbins[i];
1788     strtitlept.Append("<= pt <");
1789     strtitlept+=fptbins[i+1];
1790     strtitlept.Append(" [GeV/c]");
1791     
1792     hd0D0ptLSCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1793     hd0D0ptLSCotherPM[i]->SetXTitle("Impact parameter [#mum] ");
1794     hd0D0ptLSCotherPM[i]->SetYTitle("Entries");
1795     flistLsCutsOther->Add(hd0D0ptLSCotherPM[i]);
1796
1797     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1798     hMCd0D0ptLSCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1799     hMCd0D0ptLSCotherPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1800     hMCd0D0ptLSCotherPM[i]->SetYTitle("Entries");
1801     flistLsCutsOther->Add(hMCd0D0ptLSCotherPM[i]);
1802  
1803
1804     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1805     hd0D0VtxTrueptLSCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1806     hd0D0VtxTrueptLSCotherPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1807     hd0D0VtxTrueptLSCotherPM[i]->SetYTitle("Entries");
1808     flistLsCutsOther->Add(hd0D0VtxTrueptLSCotherPM[i]);
1809     
1810     strnamept=namehist;
1811     strnamept.Append("SBMss_pt");
1812     strnamept+=i;
1813
1814     strtitlept=titlehist;
1815     strtitlept.Append(" Side Bands, ");
1816     strtitlept+=fptbins[i];
1817     strtitlept.Append("<= pt <");
1818     strtitlept+=fptbins[i+1];
1819     strtitlept.Append(" [GeV/c]");
1820     
1821     hd0D0ptLSCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1822     hd0D0ptLSCotherSB[i]->SetXTitle("Impact parameter [#mum] ");
1823     hd0D0ptLSCotherSB[i]->SetYTitle("Entries");
1824     flistLsCutsOther->Add(hd0D0ptLSCotherSB[i]);
1825
1826     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1827     hMCd0D0ptLSCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1828     hMCd0D0ptLSCotherSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1829     hMCd0D0ptLSCotherSB[i]->SetYTitle("Entries");
1830     flistLsCutsOther->Add(hMCd0D0ptLSCotherSB[i]);
1831
1832     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1833     hd0D0VtxTrueptLSCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1834     hd0D0VtxTrueptLSCotherSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1835     hd0D0VtxTrueptLSCotherSB[i]->SetYTitle("Entries");
1836     flistLsCutsOther->Add(hd0D0VtxTrueptLSCotherSB[i]);
1837   }
1838
1839
1840
1841
1842   //################################################################################################
1843   //                                                                                               #
1844   //                         HISTOS FOR TIGHT CUTS                                                 #
1845   //                                                                                               #
1846   //################################################################################################
1847
1848   //############ TIGHT CUTS SIGNAL HISTOGRAMS ###############
1849   //
1850   // ####### global properties histo ############
1851
1852   TH2F *hCPtaVSd0d0TGHCsign=new TH2F("hCPtaVSd0d0TGHCsign","hCPtaVSd0d0_TightCuts_Signal",1000,-100000.,100000.,100,0.,1.);
1853   TH1F *hSecVtxZTGHCsign=new TH1F("hSecVtxZTGHCsign","hSecVtxZ_TightCuts_Signal",1000,-8.,8.);
1854   TH1F *hSecVtxXTGHCsign=new TH1F("hSecVtxXTGHCsign","hSecVtxX_TightCuts_Signal",1000,-3000.,3000.);
1855   TH1F *hSecVtxYTGHCsign=new TH1F("hSecVtxYTGHCsign","hSecVtxY_TightCuts_Signal",1000,-3000.,3000.);
1856   TH2F *hSecVtxXYTGHCsign=new TH2F("hSecVtxXYTGHCsign","hSecVtxXY_TightCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
1857   TH1F *hSecVtxPhiTGHCsign=new TH1F("hSecVtxPhiTGHCsign","hSecVtxPhi_TightCuts_Signal",180,-180.1,180.1);
1858   TH1F *hCPtaTGHCsign=new TH1F("hCPtaTGHCsign","hCPta_TightCuts_Signal",100,0.,1.);
1859   TH1F *hd0xd0TGHCsign=new TH1F("hd0xd0TGHCsign","hd0xd0_TightCuts_Signal",1000,-100000.,100000.);
1860   TH1F *hMassTrueTGHCsign=new TH1F("hMassTrueTGHCsign","D^{0} MC inv. Mass Tight Cuts Signal(All momenta)",600,1.600,2.200);
1861   TH1F *hMassTGHCsign=new TH1F("hMassTGHCsign","D^{0} inv. Mass Tight Cuts Signal (All momenta)",600,1.600,2.200);
1862   hMassTGHCsign->Sumw2();
1863   TH1F *hMassTrueTGHCsignPM=new TH1F("hMassTrueTGHCsignPM","D^{0} MC inv. Mass Tight Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
1864   TH1F *hMassTGHCsignPM=new TH1F("hMassTGHCsignPM","D^{0} inv. Mass Tight Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
1865   hMassTGHCsignPM->Sumw2();
1866   TH1F *hMassTrueTGHCsignSB=new TH1F("hMassTrueTGHCsignSB","D^{0} MC inv. Mass in Side Bands Tight Cuts Signal(All momenta)",600,1.600,2.200);
1867   TH1F *hMassTGHCsignSB=new TH1F("hMassTGHCsignSB","D^{0} inv. Mass in Side Bands Tight Cuts Signal (All momenta)",600,1.600,2.200);
1868   hMassTGHCsignSB->Sumw2();
1869
1870   flistTghCutsSignal->Add(hCPtaVSd0d0TGHCsign);
1871   flistTghCutsSignal->Add(hSecVtxZTGHCsign);
1872   flistTghCutsSignal->Add(hSecVtxYTGHCsign);
1873   flistTghCutsSignal->Add(hSecVtxXTGHCsign);
1874   flistTghCutsSignal->Add(hSecVtxXYTGHCsign);
1875   flistTghCutsSignal->Add(hSecVtxPhiTGHCsign);
1876   flistTghCutsSignal->Add(hCPtaTGHCsign);
1877   flistTghCutsSignal->Add(hd0xd0TGHCsign);
1878   flistTghCutsSignal->Add(hMassTrueTGHCsign);
1879   flistTghCutsSignal->Add(hMassTGHCsign);
1880   flistTghCutsSignal->Add(hMassTrueTGHCsignPM);
1881   flistTghCutsSignal->Add(hMassTGHCsignPM);
1882   flistTghCutsSignal->Add(hMassTrueTGHCsignSB);
1883   flistTghCutsSignal->Add(hMassTGHCsignSB);
1884
1885   // ####### d0 D0 histos ############
1886   TH1F *hd0D0TGHCsignPM = new TH1F("hd0D0TGHCsignPM","D^{0} impact par. plot , Tight Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1887   hd0D0TGHCsignPM->SetXTitle("Impact parameter [#mum]");
1888   hd0D0TGHCsignPM->SetYTitle("Entries");
1889
1890   TH1F *hd0D0VtxTrueTGHCsignPM = new TH1F("hd0D0VtxTrueTGHCsignPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1891   hd0D0VtxTrueTGHCsignPM->SetXTitle("Impact parameter [#mum]");
1892   hd0D0VtxTrueTGHCsignPM->SetYTitle("Entries");
1893
1894   TH1F *hMCd0D0TGHCsignPM = new TH1F("hMCd0D0TGHCsignPM","D^{0} impact par. plot, Tight Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
1895   hMCd0D0TGHCsignPM->SetXTitle("MC Impact parameter [#mum]");
1896   hMCd0D0TGHCsignPM->SetYTitle("Entries");
1897
1898   TH1F *hd0D0TGHCsignSB = new TH1F("hd0D0TGHCsignSB","D^{0} impact par. plot , Tight Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1899   hd0D0TGHCsignSB->SetXTitle("Impact parameter [#mum]");
1900   hd0D0TGHCsignSB->SetYTitle("Entries");
1901
1902   TH1F *hd0D0VtxTrueTGHCsignSB = new TH1F("hd0D0VtxTrueTGHCsignSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
1903   hd0D0VtxTrueTGHCsignSB->SetXTitle("Impact parameter [#mum]");
1904   hd0D0VtxTrueTGHCsignSB->SetYTitle("Entries");
1905
1906   TH1F *hMCd0D0TGHCsignSB = new TH1F("hMCd0D0TGHCsignSB","D^{0} impact par. plot, Tight Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
1907   hMCd0D0TGHCsignSB->SetXTitle("MC Impact parameter [#mum]");
1908   hMCd0D0TGHCsignSB->SetYTitle("Entries");
1909
1910   flistTghCutsSignal->Add(hd0D0TGHCsignPM);
1911   flistTghCutsSignal->Add(hd0D0VtxTrueTGHCsignPM);
1912   flistTghCutsSignal->Add(hMCd0D0TGHCsignPM);
1913   flistTghCutsSignal->Add(hd0D0TGHCsignSB);
1914   flistTghCutsSignal->Add(hd0D0VtxTrueTGHCsignSB);
1915   flistTghCutsSignal->Add(hMCd0D0TGHCsignSB);
1916   
1917   TH1F **hd0D0ptTGHCsignPM=new TH1F*[fnbins];
1918   TH1F **hMCd0D0ptTGHCsignPM=new TH1F*[fnbins];
1919   TH1F ** hd0D0VtxTrueptTGHCsignPM=new TH1F*[fnbins];
1920   TH1F **hd0D0ptTGHCsignSB=new TH1F*[fnbins];
1921   TH1F **hMCd0D0ptTGHCsignSB=new TH1F*[fnbins];
1922   TH1F ** hd0D0VtxTrueptTGHCsignSB=new TH1F*[fnbins];
1923   namehist="hd0D0ptTGHCsign_";
1924   titlehist="D^{0} impact par. plot, Tight Cuts, Signal, ";
1925   for(Int_t i=0;i<fnbins;i++){
1926     strnamept=namehist;
1927     strnamept.Append("PkMss_pt");
1928     strnamept+=i;
1929
1930     strtitlept=titlehist;
1931     strtitlept.Append(" Mass Peak, ");
1932     strtitlept+=fptbins[i];
1933     strtitlept.Append("<= pt <");
1934     strtitlept+=fptbins[i+1];
1935     strtitlept.Append(" [GeV/c]");
1936     
1937     hd0D0ptTGHCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1938     hd0D0ptTGHCsignPM[i]->SetXTitle("Impact parameter [#mum] ");
1939     hd0D0ptTGHCsignPM[i]->SetYTitle("Entries");
1940     flistTghCutsSignal->Add(hd0D0ptTGHCsignPM[i]);
1941
1942     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1943     hMCd0D0ptTGHCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1944     hMCd0D0ptTGHCsignPM[i]->SetXTitle("MC Impact parameter [#mum] ");
1945     hMCd0D0ptTGHCsignPM[i]->SetYTitle("Entries");
1946     flistTghCutsSignal->Add(hMCd0D0ptTGHCsignPM[i]);
1947  
1948
1949     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1950     hd0D0VtxTrueptTGHCsignPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1951     hd0D0VtxTrueptTGHCsignPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1952     hd0D0VtxTrueptTGHCsignPM[i]->SetYTitle("Entries");
1953     flistTghCutsSignal->Add(hd0D0VtxTrueptTGHCsignPM[i]);
1954     
1955     strnamept=namehist;
1956     strnamept.Append("SBMss_pt");
1957     strnamept+=i;
1958
1959     strtitlept=titlehist;
1960     strtitlept.Append(" Side Bands, ");
1961     strtitlept+=fptbins[i];
1962     strtitlept.Append("<= pt <");
1963     strtitlept+=fptbins[i+1];
1964     strtitlept.Append(" [GeV/c]");
1965     
1966     hd0D0ptTGHCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1967     hd0D0ptTGHCsignSB[i]->SetXTitle("Impact parameter [#mum] ");
1968     hd0D0ptTGHCsignSB[i]->SetYTitle("Entries");
1969     flistTghCutsSignal->Add(hd0D0ptTGHCsignSB[i]);
1970
1971     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1972     hMCd0D0ptTGHCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1973     hMCd0D0ptTGHCsignSB[i]->SetXTitle("MC Impact parameter [#mum] ");
1974     hMCd0D0ptTGHCsignSB[i]->SetYTitle("Entries");
1975     flistTghCutsSignal->Add(hMCd0D0ptTGHCsignSB[i]);
1976
1977     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1978     hd0D0VtxTrueptTGHCsignSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1979     hd0D0VtxTrueptTGHCsignSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1980     hd0D0VtxTrueptTGHCsignSB[i]->SetYTitle("Entries");
1981     flistTghCutsSignal->Add(hd0D0VtxTrueptTGHCsignSB[i]);
1982   }
1983
1984
1985   //############ TIGHT CUTS BACKGROUND HISTOGRAMS ###########
1986   //
1987   //   ######## global properties histos #######
1988   TH2F *hCPtaVSd0d0TGHCback=new TH2F("hCPtaVSd0d0TGHCback","hCPtaVSd0d0_TightCuts_Background",1000,-100000.,100000.,100,0.,1.);
1989   TH1F *hSecVtxZTGHCback=new TH1F("hSecVtxZTGHCback","hSecVtxZ_TightCuts_Background",1000,-8.,8.);
1990   TH1F *hSecVtxXTGHCback=new TH1F("hSecVtxXTGHCback","hSecVtxX_TightCuts_Background",1000,-3000.,3000.);
1991   TH1F *hSecVtxYTGHCback=new TH1F("hSecVtxYTGHCback","hSecVtxY_TightCuts_Background",1000,-3000.,3000.);
1992   TH2F *hSecVtxXYTGHCback=new TH2F("hSecVtxXYTGHCback","hSecVtxXY_TightCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
1993   TH1F *hSecVtxPhiTGHCback=new TH1F("hSecVtxPhiTGHCback","hSecVtxPhi_TightCuts_Background",180,-180.1,180.1);
1994   TH1F *hCPtaTGHCback=new TH1F("hCPtaTGHCback","hCPta_TightCuts_Background",100,0.,1.);
1995   TH1F *hd0xd0TGHCback=new TH1F("hd0xd0TGHCback","hd0xd0_TightCuts_Background",1000,-100000.,100000.);
1996   TH1F *hMassTrueTGHCback=new TH1F("hMassTrueTGHCback","D^{0} MC inv. Mass Tight Cuts Background(All momenta)",600,1.600,2.200);
1997   TH1F *hMassTGHCback=new TH1F("hMassTGHCback","D^{0} inv. Mass Tight Cuts Background (All momenta)",600,1.600,2.200);
1998   hMassTGHCback->Sumw2();
1999   TH1F *hMassTrueTGHCbackPM=new TH1F("hMassTrueTGHCbackPM","D^{0} MC inv. Mass Tight Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
2000   TH1F *hMassTGHCbackPM=new TH1F("hMassTGHCbackPM","D^{0} inv. Mass Tight Cuts Background (All momenta), MassPeak",600,1.600,2.200);
2001   hMassTGHCbackPM->Sumw2();
2002   TH1F *hMassTrueTGHCbackSB=new TH1F("hMassTrueTGHCbackSB","D^{0} MC inv. Mass in Side Bands Tight Cuts Backgrround(All momenta)",600,1.600,2.200);
2003   TH1F *hMassTGHCbackSB=new TH1F("hMassTGHCbackSB","D^{0} inv. Mass in Side Bands Tight Cuts Background (All momenta)",600,1.600,2.200);
2004   hMassTGHCbackSB->Sumw2();
2005
2006   flistTghCutsBack->Add(hCPtaVSd0d0TGHCback);
2007   flistTghCutsBack->Add(hSecVtxZTGHCback);
2008   flistTghCutsBack->Add(hSecVtxYTGHCback);
2009   flistTghCutsBack->Add(hSecVtxXTGHCback);
2010   flistTghCutsBack->Add(hSecVtxXYTGHCback);
2011   flistTghCutsBack->Add(hSecVtxPhiTGHCback);
2012   flistTghCutsBack->Add(hCPtaTGHCback);
2013   flistTghCutsBack->Add(hd0xd0TGHCback);
2014   flistTghCutsBack->Add(hMassTrueTGHCback);
2015   flistTghCutsBack->Add(hMassTGHCback);
2016   flistTghCutsBack->Add(hMassTrueTGHCbackPM);
2017   flistTghCutsBack->Add(hMassTGHCbackPM);
2018   flistTghCutsBack->Add(hMassTrueTGHCbackSB);
2019   flistTghCutsBack->Add(hMassTGHCbackSB);
2020
2021
2022   // ####### d0 D0 histos ############
2023   
2024  TH1F *hd0D0TGHCbackPM = new TH1F("hd0D0TGHCbackPM","D^{0} impact par. plot , Tight Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2025   hd0D0TGHCbackPM->SetXTitle("Impact parameter [#mum]");
2026   hd0D0TGHCbackPM->SetYTitle("Entries");
2027
2028   TH1F *hd0D0VtxTrueTGHCbackPM = new TH1F("hd0D0VtxTrueTGHCbackPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2029   hd0D0VtxTrueTGHCbackPM->SetXTitle("Impact parameter [#mum]");
2030   hd0D0VtxTrueTGHCbackPM->SetYTitle("Entries");
2031
2032   TH1F *hMCd0D0TGHCbackPM = new TH1F("hMCd0D0TGHCbackPM","D^{0} impact par. plot, Tight Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
2033   hMCd0D0TGHCbackPM->SetXTitle("MC Impact parameter [#mum]");
2034   hMCd0D0TGHCbackPM->SetYTitle("Entries");
2035
2036   TH1F *hd0D0TGHCbackSB = new TH1F("hd0D0TGHCbackSB","D^{0} impact par. plot , Tight Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2037   hd0D0TGHCbackSB->SetXTitle("Impact parameter [#mum]");
2038   hd0D0TGHCbackSB->SetYTitle("Entries");
2039
2040   TH1F *hd0D0VtxTrueTGHCbackSB = new TH1F("hd0D0VtxTrueTGHCbackSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2041   hd0D0VtxTrueTGHCbackSB->SetXTitle("Impact parameter [#mum]");
2042   hd0D0VtxTrueTGHCbackSB->SetYTitle("Entries");
2043
2044   TH1F *hMCd0D0TGHCbackSB = new TH1F("hMCd0D0TGHCbackSB","D^{0} impact par. plot, Tight Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
2045   hMCd0D0TGHCbackSB->SetXTitle("MC Impact parameter [#mum]");
2046   hMCd0D0TGHCbackSB->SetYTitle("Entries");
2047
2048   flistTghCutsBack->Add(hd0D0TGHCbackPM);
2049   flistTghCutsBack->Add(hd0D0VtxTrueTGHCbackPM);
2050   flistTghCutsBack->Add(hMCd0D0TGHCbackPM);
2051   flistTghCutsBack->Add(hd0D0TGHCbackSB);
2052   flistTghCutsBack->Add(hd0D0VtxTrueTGHCbackSB);
2053   flistTghCutsBack->Add(hMCd0D0TGHCbackSB);
2054   
2055   TH1F **hd0D0ptTGHCbackPM=new TH1F*[fnbins];
2056   TH1F **hMCd0D0ptTGHCbackPM=new TH1F*[fnbins];
2057   TH1F ** hd0D0VtxTrueptTGHCbackPM=new TH1F*[fnbins];
2058   TH1F **hd0D0ptTGHCbackSB=new TH1F*[fnbins];
2059   TH1F **hMCd0D0ptTGHCbackSB=new TH1F*[fnbins];
2060   TH1F ** hd0D0VtxTrueptTGHCbackSB=new TH1F*[fnbins];
2061   namehist="hd0D0ptTGHCback_";
2062   titlehist="D^{0} impact par. plot, Tight Cuts, Background, ";
2063   for(Int_t i=0;i<fnbins;i++){
2064     strnamept=namehist;
2065     strnamept.Append("PkMss_pt");
2066     strnamept+=i;
2067
2068     strtitlept=titlehist;
2069     strtitlept.Append(" Mass Peak, ");
2070     strtitlept+=fptbins[i];
2071     strtitlept.Append("<= pt <");
2072     strtitlept+=fptbins[i+1];
2073     strtitlept.Append(" [GeV/c]");
2074     
2075     hd0D0ptTGHCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2076     hd0D0ptTGHCbackPM[i]->SetXTitle("Impact parameter [#mum] ");
2077     hd0D0ptTGHCbackPM[i]->SetYTitle("Entries");
2078     flistTghCutsBack->Add(hd0D0ptTGHCbackPM[i]);
2079
2080     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2081     hMCd0D0ptTGHCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2082     hMCd0D0ptTGHCbackPM[i]->SetXTitle("MC Impact parameter [#mum] ");
2083     hMCd0D0ptTGHCbackPM[i]->SetYTitle("Entries");
2084     flistTghCutsBack->Add(hMCd0D0ptTGHCbackPM[i]);
2085  
2086
2087     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2088     hd0D0VtxTrueptTGHCbackPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2089     hd0D0VtxTrueptTGHCbackPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2090     hd0D0VtxTrueptTGHCbackPM[i]->SetYTitle("Entries");
2091     flistTghCutsBack->Add(hd0D0VtxTrueptTGHCbackPM[i]);
2092     
2093     strnamept=namehist;
2094     strnamept.Append("SBMss_pt");
2095     strnamept+=i;
2096
2097     strtitlept=titlehist;
2098     strtitlept.Append(" Side Bands, ");
2099     strtitlept+=fptbins[i];
2100     strtitlept.Append("<= pt <");
2101     strtitlept+=fptbins[i+1];
2102     strtitlept.Append(" [GeV/c]");
2103     
2104     hd0D0ptTGHCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2105     hd0D0ptTGHCbackSB[i]->SetXTitle("Impact parameter [#mum] ");
2106     hd0D0ptTGHCbackSB[i]->SetYTitle("Entries");
2107     flistTghCutsBack->Add(hd0D0ptTGHCbackSB[i]);
2108
2109     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2110     hMCd0D0ptTGHCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2111     hMCd0D0ptTGHCbackSB[i]->SetXTitle("MC Impact parameter [#mum] ");
2112     hMCd0D0ptTGHCbackSB[i]->SetYTitle("Entries");
2113     flistTghCutsBack->Add(hMCd0D0ptTGHCbackSB[i]);
2114
2115     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2116     hd0D0VtxTrueptTGHCbackSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2117     hd0D0VtxTrueptTGHCbackSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2118     hd0D0VtxTrueptTGHCbackSB[i]->SetYTitle("Entries");
2119     flistTghCutsBack->Add(hd0D0VtxTrueptTGHCbackSB[i]);
2120   }
2121
2122
2123
2124  //############ TIGHT CUTS FROMB HISTOGRAMS ###########
2125   //
2126   //#######  global properties histos
2127
2128   TH2F *hCPtaVSd0d0TGHCfromB=new TH2F("hCPtaVSd0d0TGHCfromB","hCPtaVSd0d0_TightCuts_FromB",1000,-100000.,100000.,100,0.,1.);
2129   TH1F *hSecVtxZTGHCfromB=new TH1F("hSecVtxZTGHCfromB","hSecVtxZ_TightCuts_FromB",1000,-8.,8.);
2130   TH1F *hSecVtxXTGHCfromB=new TH1F("hSecVtxXTGHCfromB","hSecVtxX_TightCuts_FromB",1000,-3000.,3000.);
2131   TH1F *hSecVtxYTGHCfromB=new TH1F("hSecVtxYTGHCfromB","hSecVtxY_TightCuts_FromB",1000,-3000.,3000.);
2132   TH2F *hSecVtxXYTGHCfromB=new TH2F("hSecVtxXYTGHCfromB","hSecVtxXY_TightCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
2133   TH1F *hSecVtxPhiTGHCfromB=new TH1F("hSecVtxPhiTGHCfromB","hSecVtxPhi_TightCuts_FromB",180,-180.1,180.1);
2134   TH1F *hCPtaTGHCfromB=new TH1F("hCPtaTGHCfromB","hCPta_TightCuts_FromB",100,0.,1.);
2135   TH1F *hd0xd0TGHCfromB=new TH1F("hd0xd0TGHCfromB","hd0xd0_TightCuts_FromB",1000,-100000.,100000.);
2136   TH1F *hMassTrueTGHCfromB=new TH1F("hMassTrueTGHCfromB","D^{0} MC inv. Mass Tight Cuts FromB(All momenta)",600,1.600,2.200);
2137   TH1F *hMassTGHCfromB=new TH1F("hMassTGHCfromB","D^{0} inv. Mass Tight Cuts FromB (All momenta)",600,1.600,2.200);
2138   hMassTGHCfromB->Sumw2();
2139   TH1F *hMassTrueTGHCfromBPM=new TH1F("hMassTrueTGHCfromBPM","D^{0} MC inv. Mass Tight Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
2140   TH1F *hMassTGHCfromBPM=new TH1F("hMassTGHCfromBPM","D^{0} inv. Mass Tight Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
2141   hMassTGHCfromBPM->Sumw2();
2142   TH1F *hMassTrueTGHCfromBSB=new TH1F("hMassTrueTGHCfromBSB","D^{0} MC inv. Mass in Side Bands Tight Cuts FromB(All momenta)",600,1.600,2.200);
2143   TH1F *hMassTGHCfromBSB=new TH1F("hMassTGHCfromBSB","D^{0} inv. Mass in Side Bands Tight Cuts FromB (All momenta)",600,1.600,2.200);
2144   hMassTGHCfromBSB->Sumw2();
2145
2146   flistTghCutsFromB->Add(hCPtaVSd0d0TGHCfromB);
2147   flistTghCutsFromB->Add(hSecVtxZTGHCfromB);
2148   flistTghCutsFromB->Add(hSecVtxYTGHCfromB);
2149   flistTghCutsFromB->Add(hSecVtxXTGHCfromB);
2150   flistTghCutsFromB->Add(hSecVtxXYTGHCfromB);
2151   flistTghCutsFromB->Add(hSecVtxPhiTGHCfromB);
2152   flistTghCutsFromB->Add(hCPtaTGHCfromB);
2153   flistTghCutsFromB->Add(hd0xd0TGHCfromB);
2154   flistTghCutsFromB->Add(hMassTrueTGHCfromB);
2155   flistTghCutsFromB->Add(hMassTGHCfromB);
2156   flistTghCutsFromB->Add(hMassTrueTGHCfromBPM);
2157   flistTghCutsFromB->Add(hMassTGHCfromBPM);
2158   flistTghCutsFromB->Add(hMassTrueTGHCfromBSB);
2159   flistTghCutsFromB->Add(hMassTGHCfromBSB);
2160
2161   // ######### d0 D0 histos ##############
2162   TH1F *hd0D0TGHCfromBPM = new TH1F("hd0D0TGHCfromBPM","D^{0} impact par. plot , Tight Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
2163   hd0D0TGHCfromBPM->SetXTitle("Impact parameter [#mum]");
2164   hd0D0TGHCfromBPM->SetYTitle("Entries");
2165
2166   TH1F *hd0D0VtxTrueTGHCfromBPM = new TH1F("hd0D0VtxTrueTGHCfromBPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
2167   hd0D0VtxTrueTGHCfromBPM->SetXTitle("Impact parameter [#mum]");
2168   hd0D0VtxTrueTGHCfromBPM->SetYTitle("Entries");
2169
2170   TH1F *hMCd0D0TGHCfromBPM = new TH1F("hMCd0D0TGHCfromBPM","D^{0} impact par. plot, Tight Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
2171   hMCd0D0TGHCfromBPM->SetXTitle("MC Impact parameter [#mum]");
2172   hMCd0D0TGHCfromBPM->SetYTitle("Entries");
2173
2174   TH1F *hd0D0TGHCfromBSB = new TH1F("hd0D0TGHCfromBSB","D^{0} impact par. plot , Tight Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
2175   hd0D0TGHCfromBSB->SetXTitle("Impact parameter [#mum]");
2176   hd0D0TGHCfromBSB->SetYTitle("Entries");
2177
2178   TH1F *hd0D0VtxTrueTGHCfromBSB = new TH1F("hd0D0VtxTrueTGHCfromBSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
2179   hd0D0VtxTrueTGHCfromBSB->SetXTitle("Impact parameter [#mum]");
2180   hd0D0VtxTrueTGHCfromBSB->SetYTitle("Entries");
2181
2182   TH1F *hMCd0D0TGHCfromBSB = new TH1F("hMCd0D0TGHCfromBSB","D^{0} impact par. plot, Tight Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
2183   hMCd0D0TGHCfromBSB->SetXTitle("MC Impact parameter [#mum]");
2184   hMCd0D0TGHCfromBSB->SetYTitle("Entries");
2185
2186   flistTghCutsFromB->Add(hd0D0TGHCfromBPM);
2187   flistTghCutsFromB->Add(hd0D0VtxTrueTGHCfromBPM);
2188   flistTghCutsFromB->Add(hMCd0D0TGHCfromBPM);
2189   flistTghCutsFromB->Add(hd0D0TGHCfromBSB);
2190   flistTghCutsFromB->Add(hd0D0VtxTrueTGHCfromBSB);
2191   flistTghCutsFromB->Add(hMCd0D0TGHCfromBSB);
2192   
2193   TH1F **hd0D0ptTGHCfromBPM=new TH1F*[fnbins];
2194   TH1F **hMCd0D0ptTGHCfromBPM=new TH1F*[fnbins];
2195   TH1F ** hd0D0VtxTrueptTGHCfromBPM=new TH1F*[fnbins];
2196   TH1F **hd0D0ptTGHCfromBSB=new TH1F*[fnbins];
2197   TH1F **hMCd0D0ptTGHCfromBSB=new TH1F*[fnbins];
2198   TH1F ** hd0D0VtxTrueptTGHCfromBSB=new TH1F*[fnbins];
2199   namehist="hd0D0ptTGHCfromB_";
2200   titlehist="D^{0} impact par. plot, Tight Cuts, FromB, ";
2201   for(Int_t i=0;i<fnbins;i++){
2202     strnamept=namehist;
2203     strnamept.Append("PkMss_pt");
2204     strnamept+=i;
2205
2206     strtitlept=titlehist;
2207     strtitlept.Append(" Mass Peak, ");
2208     strtitlept+=fptbins[i];
2209     strtitlept.Append("<= pt <");
2210     strtitlept+=fptbins[i+1];
2211     strtitlept.Append(" [GeV/c]");
2212     
2213     hd0D0ptTGHCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2214     hd0D0ptTGHCfromBPM[i]->SetXTitle("Impact parameter [#mum] ");
2215     hd0D0ptTGHCfromBPM[i]->SetYTitle("Entries");
2216     flistTghCutsFromB->Add(hd0D0ptTGHCfromBPM[i]);
2217
2218     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2219     hMCd0D0ptTGHCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2220     hMCd0D0ptTGHCfromBPM[i]->SetXTitle("MC Impact parameter [#mum] ");
2221     hMCd0D0ptTGHCfromBPM[i]->SetYTitle("Entries");
2222     flistTghCutsFromB->Add(hMCd0D0ptTGHCfromBPM[i]);
2223  
2224
2225     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2226     hd0D0VtxTrueptTGHCfromBPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2227     hd0D0VtxTrueptTGHCfromBPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2228     hd0D0VtxTrueptTGHCfromBPM[i]->SetYTitle("Entries");
2229     flistTghCutsFromB->Add(hd0D0VtxTrueptTGHCfromBPM[i]);
2230     
2231     strnamept=namehist;
2232     strnamept.Append("SBMss_pt");
2233     strnamept+=i;
2234
2235     strtitlept=titlehist;
2236     strtitlept.Append(" Side Bands, ");
2237     strtitlept+=fptbins[i];
2238     strtitlept.Append("<= pt <");
2239     strtitlept+=fptbins[i+1];
2240     strtitlept.Append(" [GeV/c]");
2241     
2242     hd0D0ptTGHCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2243     hd0D0ptTGHCfromBSB[i]->SetXTitle("Impact parameter [#mum] ");
2244     hd0D0ptTGHCfromBSB[i]->SetYTitle("Entries");
2245     flistTghCutsFromB->Add(hd0D0ptTGHCfromBSB[i]);
2246
2247     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2248     hMCd0D0ptTGHCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2249     hMCd0D0ptTGHCfromBSB[i]->SetXTitle("MC Impact parameter [#mum] ");
2250     hMCd0D0ptTGHCfromBSB[i]->SetYTitle("Entries");
2251     flistTghCutsFromB->Add(hMCd0D0ptTGHCfromBSB[i]);
2252
2253     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2254     hd0D0VtxTrueptTGHCfromBSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2255     hd0D0VtxTrueptTGHCfromBSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2256     hd0D0VtxTrueptTGHCfromBSB[i]->SetYTitle("Entries");
2257     flistTghCutsFromB->Add(hd0D0VtxTrueptTGHCfromBSB[i]);
2258   }
2259
2260
2261
2262  //############ TIGHT CUTS FROM DSTAR HISTOGRAMS ###########
2263  //
2264   //############## global properties histos
2265   TH2F *hCPtaVSd0d0TGHCfromDstar=new TH2F("hCPtaVSd0d0TGHCfromDstar","hCPtaVSd0d0_TightCuts_FromDStar",1000,-100000.,100000.,100,0.,1.);
2266   TH1F *hSecVtxZTGHCfromDstar=new TH1F("hSecVtxZTGHCfromDstar","hSecVtxZ_TightCuts_FromDStar",1000,-8.,8.);
2267   TH1F *hSecVtxXTGHCfromDstar=new TH1F("hSecVtxXTGHCfromDstar","hSecVtxX_TightCuts_FromDStar",1000,-3000.,3000.);
2268   TH1F *hSecVtxYTGHCfromDstar=new TH1F("hSecVtxYTGHCfromDstar","hSecVtxY_TightCuts_FromDStar",1000,-3000.,3000.);
2269   TH2F *hSecVtxXYTGHCfromDstar=new TH2F("hSecVtxXYTGHCfromDstar","hSecVtxXY_TightCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
2270   TH1F *hSecVtxPhiTGHCfromDstar=new TH1F("hSecVtxPhiTGHCfromDstar","hSecVtxPhi_TightCuts_FromDStar",180,-180.1,180.1);
2271   TH1F *hCPtaTGHCfromDstar=new TH1F("hCPtaTGHCfromDstar","hCPta_TightCuts_FromDStar",100,0.,1.);
2272   TH1F *hd0xd0TGHCfromDstar=new TH1F("hd0xd0TGHCfromDstar","hd0xd0_TightCuts_FromDStar",1000,-100000.,100000.);
2273   TH1F *hMassTrueTGHCfromDstar=new TH1F("hMassTrueTGHCfromDstar","D^{0} MC inv. Mass Tight Cuts FromDStar(All momenta)",600,1.600,2.200);
2274   TH1F *hMassTGHCfromDstar=new TH1F("hMassTGHCfromDstar","D^{0} inv. Mass Tight Cuts FromDStar (All momenta)",600,1.600,2.200);
2275   hMassTGHCfromDstar->Sumw2();
2276   TH1F *hMassTrueTGHCfromDstarPM=new TH1F("hMassTrueTGHCfromDstarPM","D^{0} MC inv. Mass Tight Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
2277   TH1F *hMassTGHCfromDstarPM=new TH1F("hMassTGHCfromDstarPM","D^{0} inv. Mass Tight Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
2278   hMassTGHCfromDstarPM->Sumw2();
2279   TH1F *hMassTrueTGHCfromDstarSB=new TH1F("hMassTrueTGHCfromDstarSB","D^{0} MC inv. Mass in Side Bands Tight Cuts FromDStar(All momenta)",600,1.600,2.200);
2280   TH1F *hMassTGHCfromDstarSB=new TH1F("hMassTGHCfromDstarSB","D^{0} inv. Mass in Side Bands Tight Cuts FromDStar (All momenta)",600,1.600,2.200);
2281   hMassTGHCfromDstarSB->Sumw2();
2282
2283   flistTghCutsFromDstar->Add(hCPtaVSd0d0TGHCfromDstar);
2284   flistTghCutsFromDstar->Add(hSecVtxZTGHCfromDstar);
2285   flistTghCutsFromDstar->Add(hSecVtxYTGHCfromDstar);
2286   flistTghCutsFromDstar->Add(hSecVtxXTGHCfromDstar);
2287   flistTghCutsFromDstar->Add(hSecVtxXYTGHCfromDstar);
2288   flistTghCutsFromDstar->Add(hSecVtxPhiTGHCfromDstar);
2289   flistTghCutsFromDstar->Add(hCPtaTGHCfromDstar);
2290   flistTghCutsFromDstar->Add(hd0xd0TGHCfromDstar);
2291   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstar);
2292   flistTghCutsFromDstar->Add(hMassTGHCfromDstar);
2293   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstarPM);
2294   flistTghCutsFromDstar->Add(hMassTGHCfromDstarPM);
2295   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstarSB);
2296   flistTghCutsFromDstar->Add(hMassTGHCfromDstarSB);
2297
2298   //########## d0 D0 histos #############  
2299   TH1F *hd0D0TGHCfromDstPM = new TH1F("hd0D0TGHCfromDstarPM","D^{0} impact par. plot , Tight Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
2300   hd0D0TGHCfromDstPM->SetXTitle("Impact parameter [#mum]");
2301   hd0D0TGHCfromDstPM->SetYTitle("Entries");
2302
2303   TH1F *hd0D0VtxTrueTGHCfromDstPM = new TH1F("hd0D0VtxTrueTGHCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
2304   hd0D0VtxTrueTGHCfromDstPM->SetXTitle("Impact parameter [#mum]");
2305   hd0D0VtxTrueTGHCfromDstPM->SetYTitle("Entries");
2306
2307   TH1F *hMCd0D0TGHCfromDstPM = new TH1F("hMCd0D0TGHCfromDstarPM","D^{0} impact par. plot, Tight Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
2308   hMCd0D0TGHCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
2309   hMCd0D0TGHCfromDstPM->SetYTitle("Entries");
2310
2311   TH1F *hd0D0TGHCfromDstSB = new TH1F("hd0D0TGHCfromDstarSB","D^{0} impact par. plot , Tight Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
2312   hd0D0TGHCfromDstSB->SetXTitle("Impact parameter [#mum]");
2313   hd0D0TGHCfromDstSB->SetYTitle("Entries");
2314
2315   TH1F *hd0D0VtxTrueTGHCfromDstSB = new TH1F("hd0D0VtxTrueTGHCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
2316   hd0D0VtxTrueTGHCfromDstSB->SetXTitle("Impact parameter [#mum]");
2317   hd0D0VtxTrueTGHCfromDstSB->SetYTitle("Entries");
2318
2319   TH1F *hMCd0D0TGHCfromDstSB = new TH1F("hMCd0D0TGHCfromDstarSB","D^{0} impact par. plot, Tight Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
2320   hMCd0D0TGHCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
2321   hMCd0D0TGHCfromDstSB->SetYTitle("Entries");
2322
2323   flistTghCutsFromDstar->Add(hd0D0TGHCfromDstPM);
2324   flistTghCutsFromDstar->Add(hd0D0VtxTrueTGHCfromDstPM);
2325   flistTghCutsFromDstar->Add(hMCd0D0TGHCfromDstPM);
2326   flistTghCutsFromDstar->Add(hd0D0TGHCfromDstSB);
2327   flistTghCutsFromDstar->Add(hd0D0VtxTrueTGHCfromDstSB);
2328   flistTghCutsFromDstar->Add(hMCd0D0TGHCfromDstSB);
2329   
2330   TH1F **hd0D0ptTGHCfromDstPM=new TH1F*[fnbins];
2331   TH1F **hMCd0D0ptTGHCfromDstPM=new TH1F*[fnbins];
2332   TH1F ** hd0D0VtxTrueptTGHCfromDstPM=new TH1F*[fnbins];
2333   TH1F **hd0D0ptTGHCfromDstSB=new TH1F*[fnbins];
2334   TH1F **hMCd0D0ptTGHCfromDstSB=new TH1F*[fnbins];
2335   TH1F ** hd0D0VtxTrueptTGHCfromDstSB=new TH1F*[fnbins];
2336   namehist="hd0D0ptTGHCfromDstar_";
2337   titlehist="D^{0} impact par. plot, Tight Cuts, FromDStar, ";
2338   for(Int_t i=0;i<fnbins;i++){
2339     strnamept=namehist;
2340     strnamept.Append("PkMss_pt");
2341     strnamept+=i;
2342
2343     strtitlept=titlehist;
2344     strtitlept.Append(" Mass Peak, ");
2345     strtitlept+=fptbins[i];
2346     strtitlept.Append("<= pt <");
2347     strtitlept+=fptbins[i+1];
2348     strtitlept.Append(" [GeV/c]");
2349     
2350     hd0D0ptTGHCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2351     hd0D0ptTGHCfromDstPM[i]->SetXTitle("Impact parameter [#mum] ");
2352     hd0D0ptTGHCfromDstPM[i]->SetYTitle("Entries");
2353     flistTghCutsFromDstar->Add(hd0D0ptTGHCfromDstPM[i]);
2354
2355     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2356     hMCd0D0ptTGHCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2357     hMCd0D0ptTGHCfromDstPM[i]->SetXTitle("MC Impact parameter [#mum] ");
2358     hMCd0D0ptTGHCfromDstPM[i]->SetYTitle("Entries");
2359     flistTghCutsFromDstar->Add(hMCd0D0ptTGHCfromDstPM[i]);
2360  
2361
2362     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2363     hd0D0VtxTrueptTGHCfromDstPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2364     hd0D0VtxTrueptTGHCfromDstPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2365     hd0D0VtxTrueptTGHCfromDstPM[i]->SetYTitle("Entries");
2366     flistTghCutsFromDstar->Add(hd0D0VtxTrueptTGHCfromDstPM[i]);
2367     
2368     strnamept=namehist;
2369     strnamept.Append("SBMss_pt");
2370     strnamept+=i;
2371
2372     strtitlept=titlehist;
2373     strtitlept.Append(" Side Bands, ");
2374     strtitlept+=fptbins[i];
2375     strtitlept.Append("<= pt <");
2376     strtitlept+=fptbins[i+1];
2377     strtitlept.Append(" [GeV/c]");
2378     
2379     hd0D0ptTGHCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2380     hd0D0ptTGHCfromDstSB[i]->SetXTitle("Impact parameter [#mum] ");
2381     hd0D0ptTGHCfromDstSB[i]->SetYTitle("Entries");
2382     flistTghCutsFromDstar->Add(hd0D0ptTGHCfromDstSB[i]);
2383
2384     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2385     hMCd0D0ptTGHCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2386     hMCd0D0ptTGHCfromDstSB[i]->SetXTitle("MC Impact parameter [#mum] ");
2387     hMCd0D0ptTGHCfromDstSB[i]->SetYTitle("Entries");
2388     flistTghCutsFromDstar->Add(hMCd0D0ptTGHCfromDstSB[i]);
2389
2390     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2391     hd0D0VtxTrueptTGHCfromDstSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2392     hd0D0VtxTrueptTGHCfromDstSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2393     hd0D0VtxTrueptTGHCfromDstSB[i]->SetYTitle("Entries");
2394     flistTghCutsFromDstar->Add(hd0D0VtxTrueptTGHCfromDstSB[i]);
2395   }
2396
2397
2398   //############ TIGHT CUTS OTHER HISTOGRAMS ###########
2399   //
2400   //########### global properties histos ###########
2401
2402   TH2F *hCPtaVSd0d0TGHCother=new TH2F("hCPtaVSd0d0TGHCother","hCPtaVSd0d0_TightCuts_other",1000,-100000.,100000.,100,0.,1.);
2403   TH1F *hSecVtxZTGHCother=new TH1F("hSecVtxZTGHCother","hSecVtxZ_TightCuts_other",1000,-8.,8.);
2404   TH1F *hSecVtxXTGHCother=new TH1F("hSecVtxXTGHCother","hSecVtxX_TightCuts_other",1000,-3000.,3000.);
2405   TH1F *hSecVtxYTGHCother=new TH1F("hSecVtxYTGHCother","hSecVtxY_TightCuts_other",1000,-3000.,3000.);
2406   TH2F *hSecVtxXYTGHCother=new TH2F("hSecVtxXYTGHCother","hSecVtxXY_TightCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
2407   TH1F *hSecVtxPhiTGHCother=new TH1F("hSecVtxPhiTGHCother","hSecVtxPhi_TightCuts_other",180,-180.1,180.1);
2408   TH1F *hCPtaTGHCother=new TH1F("hCPtaTGHCother","hCPta_TightCuts_other",100,0.,1.);
2409   TH1F *hd0xd0TGHCother=new TH1F("hd0xd0TGHCother","hd0xd0_TightCuts_other",1000,-100000.,100000.);
2410   TH1F *hMassTrueTGHCother=new TH1F("hMassTrueTGHCother","D^{0} MC inv. Mass Tight Cuts other(All momenta)",600,1.600,2.200);
2411   TH1F *hMassTGHCother=new TH1F("hMassTGHCother","D^{0} inv. Mass Tight Cuts other (All momenta)",600,1.600,2.200);
2412   hMassTGHCother->Sumw2();
2413   TH1F *hMassTrueTGHCotherPM=new TH1F("hMassTrueTGHCotherPM","D^{0} MC inv. Mass Tight Cuts other, Mass Peak. (All momenta)",600,1.600,2.200);
2414   TH1F *hMassTGHCotherPM=new TH1F("hMassTGHCotherPM","D^{0} inv. Mass Tight Cuts other (All momenta), MassPeak",600,1.600,2.200);
2415   hMassTGHCotherPM->Sumw2();
2416   TH1F *hMassTrueTGHCotherSB=new TH1F("hMassTrueTGHCotherSB","D^{0} MC inv. Mass in Side Bands Tight Cuts other(All momenta)",600,1.600,2.200);
2417   TH1F *hMassTGHCotherSB=new TH1F("hMassTGHCotherSB","D^{0} inv. Mass in Side Bands Tight Cuts other (All momenta)",600,1.600,2.200);
2418   hMassTGHCotherSB->Sumw2();
2419
2420   flistTghCutsOther->Add(hCPtaVSd0d0TGHCother);
2421   flistTghCutsOther->Add(hSecVtxZTGHCother);
2422   flistTghCutsOther->Add(hSecVtxYTGHCother);
2423   flistTghCutsOther->Add(hSecVtxXTGHCother);
2424   flistTghCutsOther->Add(hSecVtxXYTGHCother);
2425   flistTghCutsOther->Add(hSecVtxPhiTGHCother);
2426   flistTghCutsOther->Add(hCPtaTGHCother);
2427   flistTghCutsOther->Add(hd0xd0TGHCother);
2428   flistTghCutsOther->Add(hMassTrueTGHCother);
2429   flistTghCutsOther->Add(hMassTGHCother);
2430   flistTghCutsOther->Add(hMassTrueTGHCotherPM);
2431   flistTghCutsOther->Add(hMassTGHCotherPM);
2432   flistTghCutsOther->Add(hMassTrueTGHCotherSB);
2433   flistTghCutsOther->Add(hMassTGHCotherSB);
2434
2435   //############# d0 D0 histos ###############à
2436   TH1F *hd0D0TGHCotherPM = new TH1F("hd0D0TGHCotherPM","D^{0} impact par. plot , Tight Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2437   hd0D0TGHCotherPM->SetXTitle("Impact parameter [#mum]");
2438   hd0D0TGHCotherPM->SetYTitle("Entries");
2439
2440   TH1F *hd0D0VtxTrueTGHCotherPM = new TH1F("hd0D0VtxTrueTGHCotherPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2441   hd0D0VtxTrueTGHCotherPM->SetXTitle("Impact parameter [#mum]");
2442   hd0D0VtxTrueTGHCotherPM->SetYTitle("Entries");
2443
2444   TH1F *hMCd0D0TGHCotherPM = new TH1F("hMCd0D0TGHCotherPM","D^{0} impact par. plot, Tight Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
2445   hMCd0D0TGHCotherPM->SetXTitle("MC Impact parameter [#mum]");
2446   hMCd0D0TGHCotherPM->SetYTitle("Entries");
2447
2448   TH1F *hd0D0TGHCotherSB = new TH1F("hd0D0TGHCotherSB","D^{0} impact par. plot , Tight Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2449   hd0D0TGHCotherSB->SetXTitle("Impact parameter [#mum]");
2450   hd0D0TGHCotherSB->SetYTitle("Entries");
2451
2452   TH1F *hd0D0VtxTrueTGHCotherSB = new TH1F("hd0D0VtxTrueTGHCotherSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2453   hd0D0VtxTrueTGHCotherSB->SetXTitle("Impact parameter [#mum]");
2454   hd0D0VtxTrueTGHCotherSB->SetYTitle("Entries");
2455
2456   TH1F *hMCd0D0TGHCotherSB = new TH1F("hMCd0D0TGHCotherSB","D^{0} impact par. plot, Tight Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
2457   hMCd0D0TGHCotherSB->SetXTitle("MC Impact parameter [#mum]");
2458   hMCd0D0TGHCotherSB->SetYTitle("Entries");
2459
2460   flistTghCutsOther->Add(hd0D0TGHCotherPM);
2461   flistTghCutsOther->Add(hd0D0VtxTrueTGHCotherPM);
2462   flistTghCutsOther->Add(hMCd0D0TGHCotherPM);
2463   flistTghCutsOther->Add(hd0D0TGHCotherSB);
2464   flistTghCutsOther->Add(hd0D0VtxTrueTGHCotherSB);
2465   flistTghCutsOther->Add(hMCd0D0TGHCotherSB);
2466   
2467   TH1F **hd0D0ptTGHCotherPM=new TH1F*[fnbins];
2468   TH1F **hMCd0D0ptTGHCotherPM=new TH1F*[fnbins];
2469   TH1F ** hd0D0VtxTrueptTGHCotherPM=new TH1F*[fnbins];
2470   TH1F **hd0D0ptTGHCotherSB=new TH1F*[fnbins];
2471   TH1F **hMCd0D0ptTGHCotherSB=new TH1F*[fnbins];
2472   TH1F ** hd0D0VtxTrueptTGHCotherSB=new TH1F*[fnbins];
2473   namehist="hd0D0ptTGHCother_";
2474   titlehist="D^{0} impact par. plot, Tight Cuts, Other, ";
2475   for(Int_t i=0;i<fnbins;i++){
2476     strnamept=namehist;
2477     strnamept.Append("PkMss_pt");
2478     strnamept+=i;
2479
2480     strtitlept=titlehist;
2481     strtitlept.Append(" Mass Peak, ");
2482     strtitlept+=fptbins[i];
2483     strtitlept.Append("<= pt <");
2484     strtitlept+=fptbins[i+1];
2485     strtitlept.Append(" [GeV/c]");
2486     
2487     hd0D0ptTGHCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2488     hd0D0ptTGHCotherPM[i]->SetXTitle("Impact parameter [#mum] ");
2489     hd0D0ptTGHCotherPM[i]->SetYTitle("Entries");
2490     flistTghCutsOther->Add(hd0D0ptTGHCotherPM[i]);
2491
2492     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2493     hMCd0D0ptTGHCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2494     hMCd0D0ptTGHCotherPM[i]->SetXTitle("MC Impact parameter [#mum] ");
2495     hMCd0D0ptTGHCotherPM[i]->SetYTitle("Entries");
2496     flistTghCutsOther->Add(hMCd0D0ptTGHCotherPM[i]);
2497  
2498
2499     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2500     hd0D0VtxTrueptTGHCotherPM[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2501     hd0D0VtxTrueptTGHCotherPM[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2502     hd0D0VtxTrueptTGHCotherPM[i]->SetYTitle("Entries");
2503     flistTghCutsOther->Add(hd0D0VtxTrueptTGHCotherPM[i]);
2504     
2505     strnamept=namehist;
2506     strnamept.Append("SBMss_pt");
2507     strnamept+=i;
2508
2509     strtitlept=titlehist;
2510     strtitlept.Append(" Side Bands, ");
2511     strtitlept+=fptbins[i];
2512     strtitlept.Append("<= pt <");
2513     strtitlept+=fptbins[i+1];
2514     strtitlept.Append(" [GeV/c]");
2515     
2516     hd0D0ptTGHCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2517     hd0D0ptTGHCotherSB[i]->SetXTitle("Impact parameter [#mum] ");
2518     hd0D0ptTGHCotherSB[i]->SetYTitle("Entries");
2519     flistTghCutsOther->Add(hd0D0ptTGHCotherSB[i]);
2520
2521     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2522     hMCd0D0ptTGHCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2523     hMCd0D0ptTGHCotherSB[i]->SetXTitle("MC Impact parameter [#mum] ");
2524     hMCd0D0ptTGHCotherSB[i]->SetYTitle("Entries");
2525     flistTghCutsOther->Add(hMCd0D0ptTGHCotherSB[i]);
2526
2527     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2528     hd0D0VtxTrueptTGHCotherSB[i] = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2529     hd0D0VtxTrueptTGHCotherSB[i]->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2530     hd0D0VtxTrueptTGHCotherSB[i]->SetYTitle("Entries");
2531     flistTghCutsOther->Add(hd0D0VtxTrueptTGHCotherSB[i]);
2532   }
2533
2534   
2535 }
2536
2537
2538
2539 //________________________________________________________________________
2540 void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
2541 {
2542   // Execute analysis for current event:
2543   // heavy flavor candidates association to MC truth
2544   
2545   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
2546
2547   TClonesArray *arrayD0toKpi=0;
2548
2549   if(!aod && AODEvent() && IsStandardAOD()) {
2550     // In case there is an AOD handler writing a standard AOD, use the AOD 
2551     // event in memory rather than the input (ESD) event.    
2552     aod = dynamic_cast<AliAODEvent*> (AODEvent());
2553     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
2554     // have to taken from the AOD event hold by the AliAODExtension
2555     AliAODHandler* aodHandler = (AliAODHandler*) 
2556       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
2557     if(aodHandler->GetExtensions()) {
2558       AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
2559       AliAODEvent *aodFromExt = ext->GetAOD();
2560       arrayD0toKpi=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
2561     }
2562   } else {
2563     arrayD0toKpi=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
2564   }
2565
2566   if(!arrayD0toKpi) {
2567     Printf("AliAnalysisTaskSECharmFraction::UserExec: D0toKpi branch not found!\n");
2568     return;
2569   }
2570   
2571   // AOD primary vertex
2572   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
2573   TClonesArray *arrayMC=0;
2574   AliAODMCHeader *aodmcHeader=0;
2575   Double_t vtxTrue[3];
2576   
2577   if(fReadMC){
2578     // load MC particles
2579     arrayMC = 
2580       (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
2581     if(!arrayMC) {
2582       Printf("AliAnalysisTaskSECharmFraction::UserExec: MC particles branch not found!\n");
2583       return;
2584     }
2585     
2586     // load MC header
2587     aodmcHeader = 
2588       (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
2589     if(!aodmcHeader) {
2590       Printf("AliAnalysisTaskSECharmFraction::UserExec: MC header branch not found!\n");
2591       return;
2592     }
2593     
2594     // MC primary vertex
2595     aodmcHeader->GetVertex(vtxTrue);
2596   }    
2597   if (!aod) {
2598     Printf("ERROR: aod not available");
2599     return;
2600   }
2601   
2602   //histogram filled with 1 for every AOD
2603   fNentries->Fill(1);
2604   PostData(1,fNentries);
2605   
2606
2607   //Printf("There are %d tracks in this event", aod->GetNumberOfTracks());
2608   //  Int_t nTotHF=0,nTotDstar=0,nTot3Prong=0;
2609   Int_t nTotD0toKpi=0;
2610   Int_t okd0tight,okd0bartight,okd0loose,okd0barloose;
2611   Bool_t isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,isSideBand;
2612   Bool_t isinacceptance;
2613   Int_t signallevel=-1;
2614   Int_t ptbin; 
2615   //  const  Int_t nptbins=10;
2616   Double_t invMassD0,invMassD0bar,ptD0,massmumtrue;
2617   
2618  
2619   AliAODRecoDecayHF *aodDMC=0;// to be used to create a fake true sec vertex
2620   // make trkIDtoEntry register (temporary)
2621   Int_t trkIDtoEntry[100000];
2622   for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
2623     AliAODTrack *track = aod->GetTrack(it);
2624     if(track->GetID()<0) {
2625       //printf("Track ID <0, id= %d\n",track->GetID());
2626       return;
2627     }
2628     trkIDtoEntry[track->GetID()]=it;
2629   }
2630   
2631   
2632   // loop over D0->Kpi candidates
2633   Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
2634   nTotD0toKpi += nD0toKpi;
2635   //    cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
2636   
2637   for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
2638     if(aodDMC)delete aodDMC;
2639       
2640     isPeakD0=kFALSE;
2641     isPeakD0bar=kFALSE;
2642     isSideBandD0=kFALSE;
2643     isSideBandD0bar=kFALSE;
2644     isSideBand=kFALSE;
2645     isinacceptance=kFALSE;
2646     okd0tight=0;
2647     okd0bartight=0;
2648     okd0loose=0;
2649     okd0barloose=0;
2650   
2651     signallevel=-1;
2652     
2653
2654     AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
2655     Bool_t unsetvtx=kFALSE;
2656     if(!d->GetOwnPrimaryVtx()) {
2657       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
2658       unsetvtx=kTRUE;
2659     }
2660       
2661     
2662     //####### DATA SELECTION ####################################
2663     //
2664     // ######## CHECK FOR ACCEPTANCE ##########
2665     ptD0=d->Pt();
2666     isinacceptance = (TMath::Abs(d->EtaProng(0))<fAcceptanceCuts[0]&&TMath::Abs(d->EtaProng(1))<fAcceptanceCuts[0]); //eta acceptance
2667     
2668     //######## INVARIANT MASS SELECTION ###############
2669     CheckInvMassD0(d,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar);
2670     if((isSideBandD0||isSideBandD0bar)&&!(isPeakD0||isPeakD0bar))isSideBand=kTRUE;// TEMPORARY, NOT DONE IN THE METHOD CALLED ABOVE ONLY FOR FURTHER SIDE BAND STUDY
2671   
2672     // INVESTIGATE SIGNAL TYPE : ACCESS TO MC INFORMATION
2673     if(fReadMC){
2674       aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue);
2675     }
2676     else signallevel=0;
2677     if(!isinacceptance)signallevel=9;
2678     fSignalType->Fill(signallevel);
2679   
2680     // END OF BACKGROUND TYPE SELECTION
2681
2682     // NOW APPLY CUTS
2683     //NO CUTS CASE IS FOR FREE
2684     
2685     // CHECK TIGHTER CUTS 
2686     ptbin=SetStandardCuts(ptD0,flargeInvMassCut);
2687     d->SelectD0(fVHFtight->GetD0toKpiCuts(),okd0tight,okd0bartight);
2688     if(((isPeakD0&&okd0tight)||(isPeakD0bar&&okd0bartight))&&isinacceptance)fSignalTypeTghCuts->Fill(signallevel);
2689     
2690     // CHECK LOOSER CUTS 
2691     ptbin=SetStandardCuts(ptD0,flargeInvMassCut);
2692     d->SelectD0(fVHFloose->GetD0toKpiCuts(),okd0loose,okd0barloose);
2693     if(((isPeakD0&&okd0loose)||(isPeakD0bar&&okd0barloose))&&isinacceptance)fSignalTypeLsCuts->Fill(signallevel);
2694    
2695     
2696     //###################    FILL HISTOS      ########################
2697     //################################################################
2698     //
2699     //######## improvement: SPEED HERE CAN BE IMPROVED: CALCULATE ONCE AND FOR ALL 
2700     //            CANDIDATE VARIABLES   
2701
2702     //NO CUTS Case: force okD0 and okD0bar = kTRUE
2703     if(signallevel==1||signallevel==0)FillHistos(d,flistNoCutsSignal,ptbin,kTRUE,kTRUE,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2704     else if(signallevel==2)FillHistos(d,flistNoCutsFromDstar,ptbin,kTRUE,kTRUE,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2705     else if(signallevel==3||signallevel==4)FillHistos(d,flistNoCutsFromB,ptbin,kTRUE,kTRUE,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2706     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10||signallevel==9)FillHistos(d,flistNoCutsBack,ptbin,kTRUE,kTRUE,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2707     else if(signallevel==5||signallevel==6)FillHistos(d,flistNoCutsOther,ptbin,kTRUE,kTRUE,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2708
2709     //LOOSE CUTS Case
2710     if(signallevel==1||signallevel==0)FillHistos(d,flistLsCutsSignal,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2711     else if(signallevel==2)FillHistos(d,flistLsCutsFromDstar,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2712     else if(signallevel==3||signallevel==4)FillHistos(d,flistLsCutsFromB,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2713     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10)FillHistos(d,flistLsCutsBack,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2714     else if(signallevel==5||signallevel==6)FillHistos(d,flistLsCutsOther,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2715
2716     //TIGHT CUTS Case
2717     if(signallevel==1||signallevel==0)FillHistos(d,flistTghCutsSignal,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2718     else if(signallevel==2)FillHistos(d,flistTghCutsFromDstar,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2719     else if(signallevel==3||signallevel==4)FillHistos(d,flistTghCutsFromB,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2720     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10)FillHistos(d,flistTghCutsBack,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2721     else if(signallevel==5||signallevel==6)FillHistos(d,flistTghCutsOther,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBand,massmumtrue,aodDMC,vtxTrue);
2722     
2723     
2724     if(aodDMC){
2725       delete aodDMC;
2726       aodDMC=0;
2727     }
2728     
2729     if(unsetvtx) d->UnsetOwnPrimaryVtx();
2730     
2731   }
2732   
2733   // ####################### POST OUTPUT TLIST DATA #########################
2734   // ####### histo for #AOD entries already posted
2735   
2736   PostData(2,fSignalType);
2737   PostData(3,fSignalTypeLsCuts);
2738   PostData(4,fSignalTypeTghCuts);
2739   PostData(5,flistNoCutsSignal);
2740   PostData(6,flistNoCutsBack);
2741   PostData(7,flistNoCutsFromB);
2742   PostData(8,flistNoCutsFromDstar);
2743   PostData(9,flistNoCutsOther);
2744   PostData(10,flistLsCutsSignal);
2745   PostData(11,flistLsCutsBack);
2746   PostData(12,flistLsCutsFromB);
2747   PostData(13,flistLsCutsFromDstar);
2748   PostData(14,flistLsCutsOther);
2749   PostData(15,flistTghCutsSignal);
2750   PostData(16,flistTghCutsBack);
2751   PostData(17,flistTghCutsFromB);
2752   PostData(18,flistTghCutsFromDstar);
2753   PostData(19,flistTghCutsOther);
2754
2755   return;
2756 }
2757
2758 //_________________________________________
2759 Int_t AliAnalysisTaskSECharmFraction::SetStandardCuts(Double_t pt,Double_t invMassCut){
2760   //#############
2761   // TEMPORARY: to be change in :
2762   //             for(j<nptbins)
2763   //                       if pt < standardptbin[j+1]
2764   //                            SetCuts, bin=j
2765   //                            break 
2766   //                            
2767   // the way the cuts are set is for further development
2768   //   (to be interfaced with AliAnalsysTaskSETuneCuts)
2769   //
2770   // Cuts: 
2771   // 0 = inv. mass half width [GeV]
2772   // 1 = dca [cm]
2773   // 2 = cosThetaStar
2774   // 3 = pTK [GeV/c]
2775   // 4 = pTPi [GeV/c]
2776   // 5 = d0K [cm]   upper limit!
2777   // 6 = d0Pi [cm]  upper limit!
2778   // 7 = d0d0 [cm^2]
2779   // 8 = cosThetaPoint
2780
2781   Int_t ptbin=-1;
2782   if (pt>0. && pt<=1.) {
2783     ptbin=0;
2784     fVHFtight->SetD0toKpiCuts(invMassCut,0.04,0.8,0.5,0.5,0.05,0.05,-0.0002,0.5);
2785     fVHFloose->SetD0toKpiCuts(invMassCut,0.04,0.8,0.5,0.5,0.05,0.05,-0.00025,0.7);
2786   }
2787   
2788   if(pt>1. && pt<=3.) {
2789     ptbin=1;  
2790     fVHFtight->SetD0toKpiCuts(invMassCut,0.03,0.8,0.6,0.6,0.05,0.05,-0.0002,0.6);
2791     fVHFloose->SetD0toKpiCuts(invMassCut,0.02,0.8,0.7,0.7,1,1,-0.00025,0.8);
2792     //printf("I'm in the bin %d\n",ptbin);
2793   }
2794   
2795   if(pt>3. && pt<=5.){
2796     ptbin=2;  
2797     fVHFtight->SetD0toKpiCuts(invMassCut,0.02,0.8,0.7,0.7,0.05,0.05,-0.0001,0.8);
2798     fVHFloose->SetD0toKpiCuts(invMassCut,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.8);
2799     //printf("I'm in the bin %d\n",ptbin);
2800   }
2801   if(pt>5.){
2802     ptbin=3;
2803     fVHFtight->SetD0toKpiCuts(invMassCut,0.02,0.8,0.7,0.7,0.05,0.05,-0.00005,0.8);
2804     fVHFloose->SetD0toKpiCuts(invMassCut,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.9);
2805   }//if(pt>5)
2806   return ptbin;
2807 }
2808
2809 //__________________________________________________________
2810 void AliAnalysisTaskSECharmFraction::CheckInvMassD0(AliAODRecoDecayHF2Prong *d,Double_t &invMassD0,Double_t &invMassD0bar,Bool_t &isPeakD0,Bool_t &isPeakD0bar,Bool_t &isSideBandD0,Bool_t &isSideBandD0bar){
2811   //Check wheter the candidate inv. mass is compatible with signal or sideband inv. mass selection
2812       
2813   d->InvMassD0(invMassD0,invMassD0bar);
2814   //CHECK if ISPEAK 
2815   if(TMath::Abs(invMassD0-fmD0PDG)<fsignalInvMassCut)isPeakD0=kTRUE;
2816   if(TMath::Abs(invMassD0bar-fmD0PDG)<fsignalInvMassCut)isPeakD0bar=kTRUE;
2817   //CHECK if ISSIDEBAND: no constraint is present between signal region definition and side band definition
2818   // ######## TO BE CHANGED the distinction between sidebandD0 and sidebandD0bar is meaningless 
2819   //               and it is present only for side band region study (see which inv mass has the D0(D0bar) 
2820   //               in case the D0bar(D0) is in the sideband) #######
2821   if(TMath::Abs(invMassD0-fmD0PDG)>fsidebandInvMassCut&&TMath::Abs(invMassD0-fmD0PDG)<fsidebandInvMassCut+fsidebandInvMassWindow){
2822     isSideBandD0=kTRUE;
2823   }
2824   if(TMath::Abs(invMassD0bar-fmD0PDG)>fsidebandInvMassCut&&TMath::Abs(invMassD0bar-fmD0PDG)<fsidebandInvMassCut+fsidebandInvMassWindow){
2825     isSideBandD0bar=kTRUE;
2826   }
2827   
2828 }
2829         
2830
2831
2832 //_______________________
2833 AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::GetD0toKPiSignalType(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx){
2834   //THIS METHOD CHECK THE TYPE OF SIGNAL/BACKGROUND THE CANDIDATE IS. 
2835   //  IF (!AND ONLY IF) THE TWO DAUGHTERS COME FROM A COMMONE MOTHER A FAKE TRUE SECONDARY VERTEX IS CONSTRUCTED (aodDMC)  
2836   //
2837   // THE FOLLOWING SCHEME IS ADOPTED: signaltype is set to
2838                         //  1:signal (D0 prompt); 2: signal D0 from Dstar; 3: D0 fromB 4: D0 from Dstar fromB
2839                         // then background categories: -1: one or both daughters is a fake track
2840                         //                             5: both daughters come from a D meson != D0
2841                         //                             6: both daughters come from a D0->4prongs  
2842                         //                             7: both daughetrs are primaries
2843                         //                             8: generic background (can include one of the previous if desired)
2844                         //                             9: daughters out of acceptance
2845                         //                            10: pathologic cases (not clear)
2846                         //                            11: end of the method without output
2847                         //                            12: different result than MatchToMC method
2848
2849   AliAODMCParticle *mum1=0;
2850   AliAODMCParticle *b1=0,*b2=0;
2851   AliAODMCParticle *grandmoth1=0;
2852   massMumTrue=-1;
2853   
2854   Int_t pdgmum,dglabels[2],matchtoMC;
2855   Int_t pdgdaughters[2]={211,321};
2856   // get daughter AOD tracks
2857   AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
2858   AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
2859   AliAODRecoDecayHF *aodDMC=0;
2860   if(!trk0 || !trk1){
2861     AliDebug(2,"Delete tracks I AM \n");
2862   
2863     signaltype=-1;
2864     return aodDMC;
2865    
2866   }
2867   dglabels[0]=trk0->GetLabel();
2868   dglabels[1]=trk1->GetLabel();
2869   if(dglabels[0]==-1||dglabels[1]==-1){
2870     AliDebug(2,"HERE I AM \n");
2871
2872     //fake tracks
2873     
2874     signaltype=-1;
2875     return aodDMC;
2876
2877   }
2878   //      printf("Before entering the MC checks \n");
2879   
2880   b1=(AliAODMCParticle*)arrayMC->At(trk0->GetLabel());
2881   b2=(AliAODMCParticle*)arrayMC->At(trk1->GetLabel());
2882   
2883   if(b1->GetMother()==-1||b2->GetMother()==-1){
2884     //Tracks with no mother  ????? FAKE DECAY VERTEX
2885  
2886     
2887     signaltype=10;
2888     return aodDMC;
2889   }
2890   
2891   mum1=(AliAODMCParticle*)arrayMC->At(b1->GetMother());
2892   //  mum2=(AliAODMCParticle*)arrayMC->At(b2->GetMother());//FOR FURTHER USE
2893   
2894   if(b1->GetMother()!=b2->GetMother()){
2895     //Check the label of the mother is the same
2896     // NOT SAME MOTHER
2897    
2898
2899     signaltype=8;
2900     return aodDMC;
2901   }
2902   massMumTrue=mum1->GetCalcMass();
2903   
2904   matchtoMC=d->MatchToMC(421,arrayMC,2,pdgdaughters);
2905   aodDMC=ConstructFakeTrueSecVtx(b1,b2,mum1,primaryVtx);
2906  
2907   if(aodDMC){
2908     signaltype=10;
2909     return aodDMC;
2910   }
2911
2912   // if((mum1->GetPdgCode()!=mum2->GetPdgCode()))continue; //Check the mother is the same particle
2913   // printf("Particle codes: tr1: %d, tr2: %d, mum1: %d, mum 2: %d \n",b1->GetPdgCode(),b2->GetPdgCode(),mum1->GetPdgCode(),mum2->GetPdgCode());
2914   if(!((TMath::Abs(b1->GetPdgCode())==321&&TMath::Abs(b1->GetPdgCode())!=211)||(TMath::Abs(b1->GetPdgCode())==211&&TMath::Abs(b1->GetPdgCode()!=321)))){
2915     // Not a Kaon and a Pion
2916    
2917     signaltype=8;
2918     return aodDMC;
2919   }
2920   
2921   pdgmum=mum1->GetPdgCode();
2922   if(TMath::Abs(pdgmum)!=421){
2923     if(TMath::Abs(pdgmum)==411||TMath::Abs(pdgmum)==431||TMath::Abs(pdgmum)==443){
2924       // IT IS A SECONDARY VERTEX FROM CHARM BUT NOT A D0
2925       
2926       signaltype=5;
2927       return aodDMC;
2928     }
2929     else {
2930        signaltype=8;
2931        return aodDMC;
2932     }
2933   }
2934
2935   if(mum1->GetDaughter(1)-mum1->GetDaughter(0)+1!=2){
2936     // from D0 but NOT A 2 PRONG DECAY
2937     signaltype=6;
2938     return aodDMC;
2939    
2940   }
2941   
2942   if(mum1->GetMother()==-1){
2943     // A particle coming from nothing
2944     signaltype=10;
2945     return aodDMC;
2946     
2947   }
2948   Bool_t isfromDstar=kFALSE;
2949   //  matchtoMC=d->MatchToMC(421,arrayMC,2,pdgdaughters);
2950   grandmoth1=(AliAODMCParticle*)arrayMC->At(mum1->GetMother());
2951   if(TMath::Abs(grandmoth1->GetPdgCode())==413||TMath::Abs(grandmoth1->GetPdgCode())==423)isfromDstar=kTRUE;// D0 COMING FROM A D0*
2952   
2953   /*
2954   //CHECK FOR CABIBBO SUPPRESSED DECAY
2955   Int_t isCabibSup=0,pdgKaon;
2956  
2957   pdgKaon=b1->GetPdgCode();
2958   if(TMath::Abs(pdgKaon)!=321)pdgKaon=b2->GetPdgCode();
2959   if(pdgmum>0&&pdgKaon>0)isCabibSup=1;
2960   if(pdgmum<0&&pdgKaon<0)isCabibSup=1;
2961   if(isCabibSup){
2962     signaltype=0;
2963     return aodDMC;
2964   }
2965   */
2966   //      if(fcheckMCD0){//THIS CHECK IS NEEDED TO AVOID POSSIBLE FAILURE IN THE SECOND WHILE, FOR DEBUGGING
2967   while(TMath::Abs(grandmoth1->GetPdgCode())!=4&&TMath::Abs(grandmoth1->GetPdgCode())!=5){
2968     if(grandmoth1->GetMother()==-1){
2969       //### THE FOLLOWING IN CASE OF DEBUGGING ##########à
2970       /*printf("mother=-1, pdgcode: %d \n",grandmoth1->GetPdgCode());
2971         Int_t son=grandmoth1->GetDaughter(0);
2972         sonpart=(AliAODMCParticle*)arrayMC->At(son);
2973         while(TMath::Abs(sonpart->GetPdgCode())!=421){
2974         printf("mother=-1, pdgcode: %d \n",sonpart->GetPdgCode());
2975         son++;
2976         sonpart=(AliAODMCParticle*)arrayMC->At(son);
2977         }*/
2978    
2979       signaltype=10;
2980       return aodDMC;
2981     }
2982     grandmoth1=(AliAODMCParticle*)arrayMC->At(grandmoth1->GetMother());
2983   }
2984   
2985   if(TMath::Abs(grandmoth1->GetPdgCode())==4){
2986     if(matchtoMC!=-1){
2987       
2988       if(isfromDstar)signaltype=2;
2989       else signaltype=1;
2990       return aodDMC;
2991     }
2992     else {
2993       signaltype=12;
2994       return aodDMC;
2995       
2996     }
2997   }
2998   else if(TMath::Abs(grandmoth1->GetPdgCode())==5){
2999     if(matchtoMC!=-1){
3000       if(isfromDstar)signaltype=4;
3001       else signaltype=3;
3002       return aodDMC;
3003       
3004     }
3005     else {
3006      
3007       signaltype=12;
3008       return aodDMC;
3009     }
3010   }
3011   signaltype=11;// JUST FOR SAFETY: SHOULD NEVER REACH THIS POINT
3012   return aodDMC;
3013   //  return 11;
3014 }
3015
3016 //___________________________________
3017 AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::ConstructFakeTrueSecVtx(const AliAODMCParticle *b1, const AliAODMCParticle *b2, const AliAODMCParticle *mum,Double_t *primaryVtxTrue){
3018   // CONSTRUCT A FAKE TRUE SECONDARY VERTEX (aodDMC)  
3019   //!!!NOTE THAT ONLY ONE MOTHER IS CONSIDERED: THE METHOD REQUIRES THE DAUGHTERS COME FROM THE SAME MOTHER !!
3020   if(!b1 || !b2)return 0;
3021   if(!mum)return 0;
3022   Double_t pD[3],xD[3],pXtrTrue[2],pYtrTrue[2],pZtrTrue[2],xtr1[3],xtr2[3];
3023   Int_t charge[2]={0,0};
3024   if(b1->Charge()==-1)charge[0]=1;
3025   else {
3026     if(b2->Charge()==-1){
3027       //printf("Same charges for prongs \n");
3028       return 0;
3029     }
3030     charge[1]=1;
3031   }
3032   
3033   pXtrTrue[charge[0]]=b1->Px();
3034   pYtrTrue[charge[0]]=b1->Py();
3035   pZtrTrue[charge[0]]=b1->Pz();
3036   if(!b1->XvYvZv(xtr1)){
3037     return 0;
3038   }
3039   
3040   pXtrTrue[charge[1]]=b2->Px();
3041   pYtrTrue[charge[1]]=b2->Py();
3042   pZtrTrue[charge[1]]=b2->Pz();
3043   
3044   if(!mum->PxPyPz(pD)){
3045     //printf("!D from B:Get momentum failed \n");
3046     return 0;
3047   }
3048   if(!mum->XvYvZv(xD)){
3049     //printf("!D from B:Get position failed \n");
3050     return 0;
3051   }
3052   /* ############ THIS HAPPENS FROM TIME TO TIME: NUMERIC PROBLEM KNOWN #################
3053      if(pXtrTrue[0]+pXtrTrue[1]!=pD[0]){
3054      }*/
3055   
3056   
3057   if(!b2->XvYvZv(xtr2)){
3058     return 0;
3059   }
3060   Double_t d0dummy[2]={0.,0.};//TEMPORARY : dummy d0 for AliAODRecoDeay constructor
3061   AliAODRecoDecayHF* aodDMC=new AliAODRecoDecayHF(primaryVtxTrue,xD,2,0,pXtrTrue,pYtrTrue,pZtrTrue,d0dummy);
3062   
3063   /*   ######## THE FOLLOWINF FOR DEBUGGING ############
3064        Printf("testing the Fake vertex: SecVtxX: %f, Px: %f, Py: %f, Pz:%f \n ",aodDMC->GetSecVtxX(),aodDMC->Px(),aodDMC->Py(),aodDMC->Pz());
3065        Printf("pD: x=%f, y=%f,z=%f\n",pD[0],pD[1],pD[2]);
3066        Printf("Daughters :px1:%f, px2:%f \n",pXtrTrue[0],pXtrTrue[1]);
3067        Printf("Daughters :py1:%f, py2:%f \n",pYtrTrue[0],pYtrTrue[1]);
3068        Printf("Daughters :pz1:%f, pz2:%f \n",pZtrTrue[0],pZtrTrue[1]);
3069        Printf("Mother pdg: %d",mum->GetPdgCode());
3070        Printf("Impact Par Prod: %f\n",aodDMC->ImpParXY());
3071   */
3072
3073   return aodDMC;
3074 }
3075
3076 //________________________________________________________
3077 Bool_t AliAnalysisTaskSECharmFraction::FillHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Int_t okD0,Int_t okD0bar,Double_t invMassD0,Double_t invMassD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBand,Double_t massmumtrue,AliAODRecoDecayHF *aodDMC,Double_t *vtxTrue){//FILL THE HISTOGRAMS: TAKE THE HISTOS FROM THE list NAME
3078
3079   
3080   if((!okD0)&&(!okD0bar))return kTRUE;
3081   
3082   // ######### Get Standard label for hist in tlist ###############
3083   TString namehist=list->GetName(),str;
3084   namehist.ReplaceAll("list","");
3085
3086   //  ######### Global properties histos #################
3087   // ####### take care: only for candidates which pass the cuts !! not for side band ########
3088   if((isPeakD0&&okD0)||(isPeakD0bar&&okD0bar)){
3089     str="hCPtaVSd0d0";
3090     str.Append(namehist.Data());
3091     ((TH1F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
3092     
3093     str="hSecVtxZ";
3094     str.Append(namehist.Data());
3095     ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxZ());
3096     
3097     str="hSecVtxX";
3098     str.Append(namehist.Data());
3099     ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxX()*10000.);
3100     
3101     str="hSecVtxY";
3102     str.Append(namehist.Data());
3103     ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxY()*10000.);
3104     
3105     str="hSecVtxXY";
3106     str.Append(namehist.Data());
3107     ((TH2F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxX()*10000.,d->GetSecVtxY()*10000.);
3108     
3109     str="hSecVtxPhi";
3110     str.Append(namehist.Data());
3111     ((TH1F*)list->FindObject(str.Data()))->Fill(TMath::ATan2(d->GetSecVtxY()*10000.,d->GetSecVtxX()*10000.)*TMath::RadToDeg());
3112     
3113     str="hCPta";
3114     str.Append(namehist.Data());
3115     ((TH1F*)list->FindObject(str.Data()))->Fill(d->CosPointingAngle());
3116     
3117     str="hd0xd0";
3118     str.Append(namehist.Data());
3119     ((TH1F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0());
3120   }
3121   
3122   
3123   //  ######### Invariant mass histos #################
3124   str="hMass";
3125   str.Append(namehist.Data());
3126   ((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
3127   ((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
3128    
3129       
3130   if(isPeakD0||isPeakD0bar){
3131     str="hMass";
3132     str.Append(namehist.Data());
3133     str.Append("PM");
3134     if(isPeakD0&&okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
3135     if(isPeakD0bar&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
3136   }
3137   if(isSideBand){
3138     str="hMass";
3139     str.Append(namehist.Data());
3140     str.Append("SB");
3141     if(okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
3142     if(okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
3143   }
3144   if(fReadMC){
3145     if(massmumtrue>0.){
3146       str="hMassTrue";
3147       str.Append(namehist.Data());
3148       ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
3149       
3150       if(isPeakD0||isPeakD0bar){
3151         str="hMassTrue";
3152         str.Append(namehist.Data());
3153         str.Append("PM");
3154         ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
3155       }
3156       if(isSideBand){
3157         str="hMassTrue";
3158         str.Append(namehist.Data());
3159         str.Append("SB");
3160         ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
3161       }
3162     }
3163   }
3164   // ################ D0 Impact Parameter Histos #####################
3165   if((isPeakD0&&okD0)||(isPeakD0bar&&okD0bar)){
3166     str="hd0D0";
3167     str.Append(namehist.Data());
3168     str.Append("PM");
3169     ((TH1F*)list->FindObject(str.Data()))->Fill(d->ImpParXY()*10000.);
3170     
3171     str="hd0D0pt";
3172     str.Append(namehist.Data());
3173     str.Append("_PkMss_pt");
3174     str+=ptbin;
3175     ((TH1F*)list->FindObject(str.Data()))->Fill(d->ImpParXY()*10000.);
3176      
3177