]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.cxx
Merge branch 'master_patch'
[u/mrichter/AliRoot.git] / PWGHF / 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@pd.infn.it
23 /////////////////////////////////////////////////////////////
24
25
26 #include <TH1F.h>
27 #include <TH2F.h>
28 #include <TH3F.h>
29 #include <TF1.h>
30 #include <THnSparse.h>
31 #include <TDatabasePDG.h>
32 #include <TMath.h>
33 #include <TROOT.h>
34 #include "AliAODEvent.h"
35 #include "AliAODRecoDecayHF2Prong.h"
36 #include "AliAODRecoDecayHF.h"
37 #include "AliAODRecoDecay.h"
38 #include "AliAnalysisDataSlot.h"
39 #include "AliAnalysisDataContainer.h"
40 #include "AliAODTrack.h"
41 #include "AliAODHandler.h"
42 #include "AliESDtrack.h"
43 #include "AliAODVertex.h"
44 #include "AliESDVertex.h"
45 #include "AliVertexerTracks.h"
46 #include "AliAODMCParticle.h"
47 #include "AliAODPid.h"
48 #include "AliTPCPIDResponse.h"
49 #include "AliAODMCHeader.h"
50 #include "AliAnalysisVertexingHF.h"
51 #include "AliAnalysisTaskSECharmFraction.h"
52 #include "AliRDHFCutsD0toKpi.h"
53 #include "AliAODInputHandler.h"
54 #include "AliAnalysisManager.h"
55 #include "AliNormalizationCounter.h"
56 #include "AliVertexingHFUtils.h"
57
58 class TCanvas;
59 class TTree;
60 class TChain;
61 class AliAnalysisTaskSE;
62
63
64 ClassImp(AliAnalysisTaskSECharmFraction)
65  
66 //________________________________________________________________________
67 AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction() 
68 : AliAnalysisTaskSE(),
69   fCutsLoose(0),
70   fCutsTight(0),
71   fFastAnalysis(1),  
72   fReadMC(kFALSE),
73   fcheckD0Bit(kTRUE),
74   fsplitMassD0D0bar(kTRUE),
75   fLikeSign(kFALSE),
76   fusePID(kTRUE),
77   fmD0PDG(),
78   fnbins(1),
79   fptbins(0),
80   fNtrMaxforVtx(-1),
81   fptAll(),                          
82   fptAllSq(),                        
83   fptMax(),
84   fAcceptanceCuts(),
85   fsignalInvMassCut(),
86   flargeInvMassCut(),
87   fsidebandInvMassCut(),
88   fsidebandInvMassWindow(),
89   fUseMC(kTRUE),
90   fCleanCandOwnVtx(kFALSE),
91   fNentries(0),
92   fSignalType(0),
93   fSignalTypeLsCuts(0),
94   fSignalTypeTghCuts(0),
95   fCounter(0),
96   flistMCproperties(0),
97   flistNoCutsSignal(0),
98   flistNoCutsBack(0),
99   flistNoCutsFromB(0),
100   flistNoCutsFromDstar(0),
101   flistNoCutsOther(0),
102   flistLsCutsSignal(0),
103   flistLsCutsBack(0),
104   flistLsCutsFromB(0),
105   flistLsCutsFromDstar(0),
106   flistLsCutsOther(0),
107   flistTghCutsSignal(0),
108   flistTghCutsBack(0),
109   flistTghCutsFromB(0),
110   flistTghCutsFromDstar(0),
111   flistTghCutsOther(0),
112   fVertUtil(0),
113   fselectForUpgrade(0),  
114   fskipEventSelection(kFALSE),
115   fZvtxUpgr(10.),
116   fWeightPt(0x0)
117 {
118   //Default constructor
119 }
120 //________________________________________________________________________
121   AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name) 
122     : AliAnalysisTaskSE(name),
123       fCutsLoose(0x0),
124       fCutsTight(0x0),
125       fFastAnalysis(1),
126       fReadMC(kFALSE),
127       fcheckD0Bit(kTRUE),
128       fsplitMassD0D0bar(kTRUE),
129       fLikeSign(kFALSE),
130       fusePID(kTRUE),
131       fmD0PDG(),
132       fnbins(1),
133       fptbins(0),
134       fNtrMaxforVtx(-1),
135       fptAll(),                          
136       fptAllSq(),                        
137       fptMax(),
138       fAcceptanceCuts(),
139       fsignalInvMassCut(-1.),
140       flargeInvMassCut(-1.),
141       fsidebandInvMassCut(-1.),
142       fsidebandInvMassWindow(-1.),
143       fUseMC(kFALSE),
144       fCleanCandOwnVtx(kFALSE),
145       fNentries(0),
146       fSignalType(0),
147       fSignalTypeLsCuts(0),
148       fSignalTypeTghCuts(0),
149       fCounter(0),
150       flistMCproperties(0),
151       flistNoCutsSignal(0),
152       flistNoCutsBack(0),
153       flistNoCutsFromB(0),
154       flistNoCutsFromDstar(0),
155       flistNoCutsOther(0),
156       flistLsCutsSignal(0),
157       flistLsCutsBack(0),
158       flistLsCutsFromB(0),
159       flistLsCutsFromDstar(0),
160       flistLsCutsOther(0),
161       flistTghCutsSignal(0),
162       flistTghCutsBack(0),
163       flistTghCutsFromB(0),
164       flistTghCutsFromDstar(0),
165       flistTghCutsOther(0),
166       fVertUtil(0),
167       fselectForUpgrade(0),
168       fskipEventSelection(kFALSE),
169       fZvtxUpgr(10.),
170       fWeightPt(0x0)
171   {
172     // Constructor
173     
174     // Define input and output slots here
175     // Input slot #0 works with a TChain
176     // Output slot #0 writes into a TH1 container
177
178   //Standard pt bin
179   fnbins=SetStandardCuts();// THIS TO SET NBINS AND BINNING
180  
181   DefineOutput(1, TH1F::Class());
182   DefineOutput(2, TH1F::Class());
183   DefineOutput(3, TH1F::Class());
184   DefineOutput(4, TH1F::Class());
185   DefineOutput(5, AliNormalizationCounter::Class());
186
187   for(Int_t j=6;j<22;j++){
188     DefineOutput(j, TList::Class());
189   }
190   fVertUtil=new AliVertexingHFUtils();
191   // Output slot for the Cut Objects 
192   DefineOutput(22,AliRDHFCutsD0toKpi::Class());  //My private output
193   DefineOutput(23,AliRDHFCutsD0toKpi::Class());  //My private output
194
195 }
196
197
198 AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name,AliRDHFCutsD0toKpi *cutsA,AliRDHFCutsD0toKpi *cutsB) 
199   : AliAnalysisTaskSE(name),
200     fCutsLoose(0),
201     fCutsTight(0),
202     fFastAnalysis(1),
203     fReadMC(kFALSE),
204     fcheckD0Bit(kTRUE),
205     fsplitMassD0D0bar(kTRUE),
206     fLikeSign(kFALSE),
207     fusePID(kTRUE),
208     fmD0PDG(),
209     fnbins(1),
210     fptbins(0),
211     fNtrMaxforVtx(-1),
212     fptAll(),                          
213     fptAllSq(),                        
214     fptMax(),
215     fAcceptanceCuts(),
216     fsignalInvMassCut(-1.),
217     flargeInvMassCut(-1.),
218     fsidebandInvMassCut(-1.),
219     fsidebandInvMassWindow(-1.),
220     fUseMC(kFALSE),
221     fCleanCandOwnVtx(kFALSE),
222     fNentries(0),
223     fSignalType(0),
224     fSignalTypeLsCuts(0),
225     fSignalTypeTghCuts(0),
226     fCounter(0),
227     flistMCproperties(0),
228     flistNoCutsSignal(0),
229     flistNoCutsBack(0),
230     flistNoCutsFromB(0),
231     flistNoCutsFromDstar(0),
232     flistNoCutsOther(0),
233     flistLsCutsSignal(0),
234     flistLsCutsBack(0),
235     flistLsCutsFromB(0),
236     flistLsCutsFromDstar(0),
237     flistLsCutsOther(0),
238     flistTghCutsSignal(0),
239     flistTghCutsBack(0),
240     flistTghCutsFromB(0),
241     flistTghCutsFromDstar(0),
242     flistTghCutsOther(0),
243     fVertUtil(0),
244     fselectForUpgrade(0),
245     fskipEventSelection(kFALSE),
246     fZvtxUpgr(10.),
247     fWeightPt(0x0)
248 {
249   // Constructor
250   if(fCutsTight){
251     delete fCutsTight;fCutsTight=NULL;
252   }
253   if(fCutsLoose){
254     delete fCutsLoose;fCutsLoose=NULL;
255   }
256   
257   //Check consistency between sets of cuts:
258   if(cutsA->GetNPtBins()!=cutsB->GetNPtBins()){
259     printf("Different number of pt bins between the two sets of cuts: SWITCH TO STANDARD CUTS \n");
260     fnbins=SetStandardCuts();
261   }
262   else{
263     fCutsTight=new AliRDHFCutsD0toKpi(*cutsA);
264     fCutsLoose=new AliRDHFCutsD0toKpi(*cutsB);
265     for(Int_t j=0;j<cutsA->GetNPtBins();j++){
266       if(TMath::Abs(cutsA->GetPtBinLimits()[j]-cutsB->GetPtBinLimits()[j])>1.e-7){
267         printf("Different pt bin limits in the two set of cuts: use the first as reference \n");
268         fCutsLoose->SetPtBins(cutsA->GetNPtBins(),cutsA->GetPtBinLimits());
269         break;
270       }     
271     }
272     SetPtBins(fCutsTight->GetNPtBins(),fCutsTight->GetPtBinLimits());   
273   }
274
275   fVertUtil=new AliVertexingHFUtils();
276   // Output slot #0 writes into a TH1 container
277   DefineOutput(1, TH1F::Class());
278   DefineOutput(2, TH1F::Class());
279   DefineOutput(3, TH1F::Class());
280   DefineOutput(4, TH1F::Class());
281   DefineOutput(5, AliNormalizationCounter::Class());
282
283   for(Int_t j=6;j<22;j++){
284
285     DefineOutput(j, TList::Class());
286   }
287  // Output slot for the Cut Objects 
288   DefineOutput(22,AliRDHFCutsD0toKpi::Class());  //My private output
289   DefineOutput(23,AliRDHFCutsD0toKpi::Class());  //My private output
290  
291 }
292
293 //________________________________________________________________________
294 AliAnalysisTaskSECharmFraction::~AliAnalysisTaskSECharmFraction()
295 { //Destructor 
296   
297   if (fCutsTight) {   
298     delete fCutsTight;
299     fCutsTight = 0;
300   }
301   if (fCutsLoose) {  
302     delete fCutsLoose;
303     fCutsLoose = 0;
304   }
305   if(fptbins){
306     delete fptbins;
307     fptbins =0;
308   }
309   /*  if(fAcceptanceCuts){
310     delete fAcceptanceCuts;
311     fAcceptanceCuts=0;
312     }*/
313   if (fNentries) {
314     delete fNentries;
315     fNentries = 0;
316   }   
317   if (fSignalType) {
318     delete fSignalType;
319     fSignalType = 0;
320   } 
321   if (fSignalTypeLsCuts) {
322     delete fSignalTypeLsCuts;
323     fSignalTypeLsCuts = 0;
324   } 
325   if (fSignalTypeTghCuts) {
326     delete fSignalTypeTghCuts;
327     fSignalTypeTghCuts = 0;
328   } 
329   
330   if (fCounter) {
331     delete fCounter;
332     fCounter = 0;
333   } 
334   
335   if(flistMCproperties){
336     flistMCproperties->Delete();
337     delete flistMCproperties;
338     flistMCproperties=0;
339   }
340   
341   if(flistNoCutsSignal){
342     flistNoCutsSignal->Delete();
343     delete flistNoCutsSignal;
344     flistNoCutsSignal=0;
345   }
346   if(flistNoCutsBack){
347     flistNoCutsBack->Delete();
348     delete flistNoCutsBack;
349     flistNoCutsBack=0;
350   }
351   if(flistNoCutsFromB){
352     flistNoCutsFromB->Delete();
353     delete flistNoCutsFromB;
354     flistNoCutsFromB=0;
355   }
356   if(flistNoCutsFromDstar){
357     flistNoCutsFromDstar->Delete();
358     delete flistNoCutsFromDstar;
359     flistNoCutsFromDstar=0;
360   }
361   if(flistNoCutsOther){
362     flistNoCutsOther->Delete();
363     delete flistNoCutsOther;
364     flistNoCutsOther=0;
365   }
366   
367  if(flistLsCutsSignal){
368    flistLsCutsSignal->Delete();
369     delete flistLsCutsSignal;
370     flistLsCutsSignal=0;
371   }
372   if(flistLsCutsBack){
373     flistLsCutsBack->Delete();
374     delete flistLsCutsBack;
375     flistLsCutsBack=0;
376   }
377   if(flistLsCutsFromB){
378     flistLsCutsFromB->Delete();
379     delete flistLsCutsFromB;
380     flistLsCutsFromB=0;
381   }
382   if(flistLsCutsFromDstar){
383     flistLsCutsFromDstar->Delete();
384     delete flistLsCutsFromDstar;
385     flistLsCutsFromDstar=0;
386   }
387   if(flistLsCutsOther){
388     flistLsCutsOther->Delete();
389     delete flistLsCutsOther;
390     flistLsCutsOther=0;
391   }
392   
393  if(flistTghCutsSignal){
394    flistTghCutsSignal->Delete();
395     delete flistTghCutsSignal;
396     flistTghCutsSignal=0;
397   }
398   if(flistTghCutsBack){
399     flistTghCutsBack->Delete();
400     delete flistTghCutsBack;
401     flistTghCutsBack=0;
402   }
403   if(flistTghCutsFromB){
404     flistTghCutsFromB->Delete();
405     delete flistTghCutsFromB;
406     flistTghCutsFromB=0;
407   }
408   if(flistTghCutsFromDstar){
409     flistTghCutsFromDstar->Delete();
410     delete flistTghCutsFromDstar;
411     flistTghCutsFromDstar=0;
412   }
413   if(flistTghCutsOther){
414     flistTghCutsOther->Delete();
415     delete flistTghCutsOther;
416     flistTghCutsOther=0;
417   }
418   delete fWeightPt;
419   delete   fVertUtil;
420 }  
421
422
423 //________________________________________________________________________
424 void AliAnalysisTaskSECharmFraction::Init()
425 {
426   // Initialization
427   
428   if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
429   fmD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
430   
431   //  gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
432   // gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/D0fromBSetCuts.C");
433   // 2 sets of dedicated cuts: fCutsTight is assumed as the standard cut object
434   
435   // SetAcceptanceCut();
436   if(fNtrMaxforVtx<0)SetNMaxTrForVtx(3); //DEFAULT : NO SELECTION
437   if(fsignalInvMassCut<0.||flargeInvMassCut<0.||fsidebandInvMassCut<0.||fsidebandInvMassWindow<0.){
438     printf("AliAnalysisTaskSECharmFraction: Not All info for mass selection provided: switch to default values \n");
439     SetStandardMassSelection();
440   }
441   
442   AliRDHFCutsD0toKpi* copyfCutsTight=new AliRDHFCutsD0toKpi(*fCutsTight);
443   const char* nameoutputTight=GetOutputSlot(22)->GetContainer()->GetName();
444   copyfCutsTight->SetName(nameoutputTight);
445   AliRDHFCutsD0toKpi* copyfCutsLoose=new AliRDHFCutsD0toKpi(*fCutsLoose);
446   const char* nameoutputLoose=GetOutputSlot(23)->GetContainer()->GetName();
447   copyfCutsLoose->SetName(nameoutputLoose);
448
449   // Post the data
450   PostData(22,copyfCutsTight);  
451   PostData(23,copyfCutsLoose);
452   
453   
454   fCleanCandOwnVtx=kFALSE;
455   if(fCutsTight->GetIsPrimaryWithoutDaughters()^fCutsLoose->GetIsPrimaryWithoutDaughters()) {
456     printf("Two cut objects have different selection for primary vertex recalculation w/o daughters:\n Dangerous for variable drawing!! \n");   
457   }
458   else{
459     if(fCutsTight->GetIsPrimaryWithoutDaughters()){
460       fCleanCandOwnVtx=kTRUE;
461       fCutsTight->SetRemoveDaughtersFromPrim(kFALSE);
462       fCutsLoose->SetRemoveDaughtersFromPrim(kFALSE);
463     }
464   }
465    
466
467
468   
469   return;
470 }
471
472 //________________________________________________________________________
473 void AliAnalysisTaskSECharmFraction::UserCreateOutputObjects()
474 {
475   // Create histograms
476   // Called once
477   
478   // ################ NAMING SCHEME ###################################
479   //            LISTS NAMING SCHEME
480   // "list" + cut selection string + MC selection string
481   //      cut strings:  "NC" =nocuts, "LSC"= loose cuts, "TGHC"= tight cuts
482   //      MC sel. strings: "sign"= D0 from c quark
483   //                       "fromDstar" = D0 from Dstar from c quark
484   //                       "fromB"= D0from B decay (->from b quark) + D0from Dstar from B
485   //                       "back"= backgroun, generic except the cas "other"
486   //                       "other"= background case for candidates made of a pion and a kaon coming from the same D0 (in 4 prong) or from D+
487   //
488   //           HISTS NAMING SCHEME 
489   // 
490   //  "h" + specific name + cut selection string + MC selection string + (InvMass region string) + (pt string)
491   //
492   //        cut selection strings    = those for lists
493   //        MC selection strings     = those for lists
494   //        inv mass region strings  : "PM" or "SB" for global properties and pt integrated histos
495   //                                   "_PkMss" or "_SBMss" for impact par. pt dependent histos
496   //                   pt string     : "_pt" + integer number of ptbin
497   //
498   //###################################################################
499
500   TString namehist;
501   TString titlehist;
502   TString strnamept,strtitlept;
503   Printf("INSIDE USER CREATE \n");
504   
505   // fNentries=new TH1F("nentriesChFr", "Look at the number of entries! = number of AODs", 2,1.,2.);
506   
507   fNentries=new TH1F("nentriesChFr", "Analyzed sample properties", 21,-0.5,20.5);
508
509   fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
510
511   fNentries->GetXaxis()->SetBinLabel(2,"nEvTGHTsel");
512   fNentries->GetXaxis()->SetBinLabel(3,"nEvTGHTPile-up Rej");
513   fNentries->GetXaxis()->SetBinLabel(4,"nEvTGHTGoodVtxS");
514   fNentries->GetXaxis()->SetBinLabel(5,"nEvTGHTRejVtxZ");
515   fNentries->GetXaxis()->SetBinLabel(6,"nTracksTGHTEv");
516   fNentries->GetXaxis()->SetBinLabel(7,"nCandTGHTEv");
517   fNentries->GetXaxis()->SetBinLabel(8,"nCandSelTGHTEv");
518   fNentries->GetXaxis()->SetBinLabel(20,"nUnexpErrorTGHT");
519
520   fNentries->GetXaxis()->SetBinLabel(9,"nEvLSsel");
521   fNentries->GetXaxis()->SetBinLabel(10,"nEvLSPile-up Rej");
522   fNentries->GetXaxis()->SetBinLabel(11,"nEvLSGoodVtxS");
523   fNentries->GetXaxis()->SetBinLabel(12,"nEvLSRejVtxZ");
524   fNentries->GetXaxis()->SetBinLabel(13,"nTracksLSEv");
525   fNentries->GetXaxis()->SetBinLabel(14,"nCandLSEv");
526   fNentries->GetXaxis()->SetBinLabel(15,"nCandSelLSEv");
527   fNentries->GetXaxis()->SetBinLabel(21,"nUnexpErrorTGHT");
528
529   /*   -----------------  NOT ACTIVATED YET ------------------
530     fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
531     fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
532     fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
533     fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
534     fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
535     fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
536     fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
537     fNentries->GetXaxis()->SetBinLabel(12,"K");
538     fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
539     fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
540     fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
541   */
542
543   fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
544
545   fSignalType=new TH1F("hsignaltype", "Histo for type of MC signal", 61,-1.,60.);
546   fSignalTypeLsCuts=new TH1F("hsignaltypeLsCuts", "Histo for type of MC signal with loose cuts", 61,-1.,60.);
547   fSignalTypeTghCuts=new TH1F("hsignaltypeTghCuts", "Histo for type of MC signal with tight cuts", 61,-1.,60.);
548
549
550
551   fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
552   fCounter->Init(); 
553
554   //##########  DEFINE THE TLISTS ##################
555   flistMCproperties=new TList();
556   flistMCproperties->SetOwner();
557   flistMCproperties->SetName("listMCproperties");
558
559   flistNoCutsSignal = new TList();
560   flistNoCutsSignal->SetOwner();
561   flistNoCutsSignal->SetName("listNCsign");
562
563   flistNoCutsBack = new TList();
564   flistNoCutsBack->SetOwner();
565   flistNoCutsBack->SetName("listNCback");
566
567   flistNoCutsFromB = new TList();
568   flistNoCutsFromB->SetOwner();
569   flistNoCutsFromB->SetName("listNCfromB");
570
571   flistNoCutsFromDstar = new TList();
572   flistNoCutsFromDstar->SetOwner();
573   flistNoCutsFromDstar->SetName("listNCfromDstar");
574
575   flistNoCutsOther = new TList();
576   flistNoCutsOther->SetOwner();
577   flistNoCutsOther->SetName("listNCother");
578
579
580   flistLsCutsSignal = new TList();
581   flistLsCutsSignal->SetOwner();
582   flistLsCutsSignal->SetName("listLSCsign");
583
584   flistLsCutsBack = new TList();
585   flistLsCutsBack->SetOwner();
586   flistLsCutsBack->SetName("listLSCback");
587
588   flistLsCutsFromB = new TList();
589   flistLsCutsFromB->SetOwner();
590   flistLsCutsFromB->SetName("listLSCfromB");
591
592   flistLsCutsFromDstar = new TList();
593   flistLsCutsFromDstar->SetOwner();
594   flistLsCutsFromDstar->SetName("listLSCfromDstar");
595
596   flistLsCutsOther = new TList();
597   flistLsCutsOther->SetOwner();
598   flistLsCutsOther->SetName("listLSCother");
599
600
601   flistTghCutsSignal = new TList();
602   flistTghCutsSignal->SetOwner();
603   flistTghCutsSignal->SetName("listTGHCsign");
604
605   flistTghCutsBack = new TList();
606   flistTghCutsBack->SetOwner();
607   flistTghCutsBack->SetName("listTGHCback");
608
609   flistTghCutsFromB = new TList();
610   flistTghCutsFromB->SetOwner();
611   flistTghCutsFromB->SetName("listTGHCfromB");
612
613   flistTghCutsFromDstar = new TList();
614   flistTghCutsFromDstar->SetOwner();
615   flistTghCutsFromDstar->SetName("listTGHCfromDstar");
616
617   flistTghCutsOther = new TList();
618   flistTghCutsOther->SetOwner();
619   flistTghCutsOther->SetName("listTGHCother");
620
621
622
623   Float_t ptbinsD0arr[35]={0.,0.1,0.2,0.3,0.4,0.5,0.6,0.8,1.,1.25,1.5,1.75,2.,2.3,2.6,3.,3.5,4.,4.5,5.,5.5,6.,7.,8.,9.,10.,12.,14.,16.,20.,25.,30.,40.,50.,100.};
624   Float_t dumbinning[201];
625   for(Int_t j=0;j<201;j++){
626     dumbinning[j]=(Float_t)j*0.5;
627   }
628
629   // DEFINE EDGES FOR SPARSE HISTOS
630   const Int_t nPtbinsForSparse=91;//nuber of edges, -1 to get number of bins
631   Double_t ptbinsForNsparse[nPtbinsForSparse];//Binning in pt: step: 0.2 GeV/c up to 8 GeV/c, 0.5 Upto 20, 1 GeV/c up to 40, 5 upt to 70-> 8/0.2+12/0.5+20/1.+30./5
632   Double_t pT=0;
633   Double_t massbins[186],impparbins[401];  
634   Double_t massHypoBins[4]={1.,2.,3.,4.};
635   Int_t nbinsSparse[5]={185,185,nPtbinsForSparse-1,400,3};
636   for(Int_t nBins=0;nBins<nPtbinsForSparse;nBins++){    
637     ptbinsForNsparse[nBins]=pT;
638     if(pT<8.)pT+=0.2;
639     else if(pT<20)pT+=0.5;
640     else if(pT<40)pT+=1;
641     else if(pT<70)pT+=5.;  
642   }  
643   for(Int_t nBins=0;nBins<186;nBins++){
644     massbins[nBins]=1.680+nBins*(2.050-1.680)/185.;
645   }
646   for(Int_t nBins=0;nBins<401;nBins++){
647     impparbins[nBins]=-1000+nBins*(2000.)/400.;
648   }
649
650   
651   // Lxy and CosPointXY study
652   Int_t nbinsSparsCxyLxy[4]={84,fCutsTight->GetNPtBins(),10,20}; 
653   Double_t binLowLimitSparseCxyLxy[4]={1.680,fCutsTight->GetPtBinLimits()[0],0.99,0.};// Use OverFlow/UnderFlow to get other cases
654   Double_t binUpLimitSparseCxyLxy[4]={2.100,fCutsTight->GetPtBinLimits()[fCutsTight->GetNPtBins()],1.,20.};
655   Double_t *ptbinlimitsCxyLxy=new Double_t[fCutsTight->GetNPtBins()+1];
656   for(Int_t nBins=0;nBins<=fCutsTight->GetNPtBins();nBins++){
657     ptbinlimitsCxyLxy[nBins]=fCutsTight->GetPtBinLimits()[nBins];
658   }
659   
660
661   //################################################################################################
662   //                                                                                               #
663   //                HISTO FOR MC PROPERTIES OF D0, c quarks and B mesons                           #
664   //                                                                                               # 
665   //################################################################################################
666   TH1F *hMCcquarkAllPt=new TH1F("hMCcquarkAllPt","c quark Pt (all cquarks produced)",34,ptbinsD0arr);
667   TH1F *hMCcquarkAllEta=new TH1F("hMCcquarkAllEta","c quark Eta (all cquarks produced)",50,-3.,3.);
668   TH1F *hMCcquarkAllEnergy=new TH1F("hMCcquarkAllEnergy","c quark Pt (all cquarks produced)",200,0.,100.);
669   TH1F *hMCcquarkNdaught=new TH1F("hMCcquarkNdaught","N cquark daughters (all cquarks produced)",100,0.,100.);
670   TH1F *hMCD0fromcPt=new TH1F("hMCD0fromcPt","D0 from c Pt",34,ptbinsD0arr);
671   TH1F *hMCD0fromcEta=new TH1F("hMCD0fromcEta","D0 from c Eta",50,-3.,3.);
672   TH1F *hMCD0fromcEnergy=new TH1F("hMCD0fromcEnergy","D0 from c Energy",200,0.,100.);
673   
674   TH2F *hMCD0VscquarkPt=new TH2F("hMCD0VscquarkPt","D0 pt Vs cquark pt",34,ptbinsD0arr,34,ptbinsD0arr);
675   TH2F *hMCD0VscquarkEnergy=new TH2F("hMCD0VscquarkEnergy","D0 Energy Vs cquark Energy",200,0.,50.,200,0.,50.);
676   TH1F *hMCD0deltacquarkEnergy=new TH1F("hMCD0deltacquarkEnergy","Fractional D0 Energy w.r.t. cquark Energy",20,0.,1.);
677   TH1F *hMCD0EnergyVsAvcquarkDaughtEn=new TH1F("hMCD0EnergyVsAvcquarkDaughtEn","#Delta(E^{D^0}-E_{avg})/E_{cquark}",40,-1.,1.);
678   TH1F *hMCD0cquarkAngle=new TH1F("hMCD0cquarkAngle","cosine of the angle between D0 and c quark particle",40,-1.,1.);
679   TH2F *hMCD0cquarkAngleEnergy=new TH2F("hMCD0cquarkAngleEnergy","cosine of the angle between D0 and c quark particle as a function of Energy",25,0.,50.,40,-1.,1.);
680
681   TH1I *hMCfromBpdgB=new TH1I("hMCfromBpdgB","hMCfromBpdgB",10000,0.,10000);
682   TH1F *hMCBhadrPt=new TH1F("hMCBhadrPt","B hadr Pt",34,ptbinsD0arr);
683   TH1F *hMCBhadrEta=new TH1F("hMCBhadrEta","B hadr Eta",50,-3.,3.);
684   TH1F *hMCBhadrEnergy=new TH1F("hMCBhadrEnergy","B hadr Pt",200,0.,100.);
685   TH1F *hMCBhadrNdaught=new TH1F("hMCBhadrNdaught","N Bhadr daughters",100,0.,100.);
686   TH1F *hMCD0fromBPt=new TH1F("hMCD0fromBPt","D0 from B Pt",34,ptbinsD0arr);
687   TH1F *hMCD0fromBEta=new TH1F("hMCD0fromBEta","D0 from B Eta",50,-3.,3.);
688   TH1F *hMCD0fromBEnergy=new TH1F("hMCD0fromBEnergy","D0 from B Energy",200,0.,100.);
689
690   TH2F *hMCD0VsBhadrPt=new TH2F("hMCD0VsBhadrPt","D0 pt Vs Bhadr pt",34,ptbinsD0arr,34,ptbinsD0arr);
691   TH2F *hMCD0VsBhadrEnergy=new TH2F("hMCD0VsBhadrEnergy","D0 Energy Vs Bhadr Energy",200,0.,50.,200,0.,50.);
692   TH1F *hMCD0deltaBhadrEnergy=new TH1F("hMCD0deltaBhadrEnergy","Fractional D0 Energy w.r.t. Bhadr Energy",20,0.,1.);
693   TH1F *hMCD0EnergyVsAvBDaughtEn=new TH1F("hMCD0EnergyVsAvBDaughtEn","#Delta(E^{D^0}-E_{avg})/E_{Bahdr}",40,-1.,1.);
694   TH1F *hMCD0BhadrAngle=new TH1F("hMCD0BhadrAngle","cosine of the angle between D0 and Bhadr particle",40,-1.,1.);
695   TH2F *hMCD0BhadrAngleEnergy=new TH2F("hMCD0BhadrAngleEnergy","cosine of the angle between D0 and Bhadr particle as a function of Energy",25,0.,50.,40,-1.,1.);
696
697   TH1I *hMCPartFound=new TH1I("hMCPartFound","1=c,2=D0,3=fromBall,4=fromBmeson,5=fromBbaryon",6,0,6); 
698  
699
700   flistMCproperties->Add(hMCcquarkAllPt);
701   flistMCproperties->Add(hMCcquarkAllEta);
702   flistMCproperties->Add(hMCcquarkAllEnergy);
703   flistMCproperties->Add(hMCcquarkNdaught);
704   flistMCproperties->Add(hMCD0fromcPt);
705   flistMCproperties->Add(hMCD0fromcEta);
706   flistMCproperties->Add(hMCD0fromcEnergy);
707   flistMCproperties->Add(hMCD0VscquarkPt);
708   flistMCproperties->Add(hMCD0VscquarkEnergy);
709   flistMCproperties->Add(hMCD0deltacquarkEnergy);
710   flistMCproperties->Add(hMCD0EnergyVsAvcquarkDaughtEn);
711   flistMCproperties->Add(hMCD0cquarkAngle);
712   flistMCproperties->Add(hMCD0cquarkAngleEnergy);
713   
714   flistMCproperties->Add(hMCfromBpdgB);
715   flistMCproperties->Add(hMCBhadrPt);
716   flistMCproperties->Add(hMCBhadrEta);
717   flistMCproperties->Add(hMCBhadrEnergy);
718   flistMCproperties->Add(hMCBhadrNdaught);
719   flistMCproperties->Add(hMCD0fromBPt);
720   flistMCproperties->Add(hMCD0fromBEta);
721   flistMCproperties->Add(hMCD0fromBEnergy);
722   flistMCproperties->Add(hMCD0VsBhadrPt);
723   flistMCproperties->Add(hMCD0VsBhadrEnergy);
724   flistMCproperties->Add(hMCD0deltaBhadrEnergy);
725   flistMCproperties->Add(hMCD0EnergyVsAvBDaughtEn);
726   flistMCproperties->Add(hMCD0BhadrAngle);
727   flistMCproperties->Add(hMCD0BhadrAngleEnergy);
728   flistMCproperties->Add(hMCPartFound);
729
730   //################################################################################################
731   //                                                                                               #
732   //                         HISTOS FOR NO CUTS CASE                                               #
733   //                                                                                               #
734   //################################################################################################
735   Printf("AFTER MC HISTOS \n");
736
737   //############ NO CUTS SIGNAL HISTOGRAMS ###############
738   //
739   // ####### global properties histo ############
740
741   TH2F *hCPtaVSd0d0NCsign=new TH2F("hCPtaVSd0d0NCsign","hCPtaVSd0d0_NoCuts_Signal",1000,-100000.,100000.,100,-1.,1.);
742   TH1F *hSecVtxZNCsign=new TH1F("hSecVtxZNCsign","hSecVtxZ_NoCuts_Signal",1000,-8.,8.);
743   TH1F *hSecVtxXNCsign=new TH1F("hSecVtxXNCsign","hSecVtxX_NoCuts_Signal",1000,-3000.,3000.);
744   TH1F *hSecVtxYNCsign=new TH1F("hSecVtxYNCsign","hSecVtxY_NoCuts_Signal",1000,-3000.,3000.);
745   TH2F *hSecVtxXYNCsign=new TH2F("hSecVtxXYNCsign","hSecVtxXY_NoCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
746   TH1F *hSecVtxPhiNCsign=new TH1F("hSecVtxPhiNCsign","hSecVtxPhi_NoCuts_Signal",180,-180.1,180.1);
747   TH1F *hd0singlTrackNCsign=new TH1F("hd0singlTrackNCsign","hd0singlTrackNoCuts_Signal",1000,-5000.,5000.);
748   TH1F *hCPtaNCsign=new TH1F("hCPtaNCsign","hCPta_NoCuts_Signal",100,-1.,1.);
749   TH1F *hd0xd0NCsign=new TH1F("hd0xd0NCsign","hd0xd0_NoCuts_Signal",1000,-100000.,100000.);
750   TH1F *hMassTrueNCsign=new TH1F("hMassTrueNCsign","D^{0} MC inv. Mass No Cuts Signal(All momenta)",600,1.600,2.200);
751   TH1F *hMassNCsign=new TH1F("hMassNCsign","D^{0} inv. Mass No Cuts Signal (All momenta)",600,1.600,2.200);
752   hMassNCsign->Sumw2();
753   TH1F *hMassTrueNCsignPM=new TH1F("hMassTrueNCsignPM","D^{0} MC inv. Mass No Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
754   TH1F *hMassNCsignPM=new TH1F("hMassNCsignPM","D^{0} inv. Mass No Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
755   hMassNCsignPM->Sumw2();
756
757   TH1F *hMassTrueNCsignSB=new TH1F("hMassTrueNCsignSB","D^{0} MC inv. Mass in Side Bands No Cuts Signal(All momenta)",600,1.600,2.200);
758   TH1F *hMassNCsignSB=new TH1F("hMassNCsignSB","D^{0} inv. Mass in Side Bands No Cuts Signal (All momenta)",600,1.600,2.200);
759   hMassNCsignSB->Sumw2();
760
761   flistNoCutsSignal->Add(hCPtaVSd0d0NCsign);
762   flistNoCutsSignal->Add(hSecVtxZNCsign);
763   flistNoCutsSignal->Add(hSecVtxYNCsign);
764   flistNoCutsSignal->Add(hSecVtxXNCsign);
765   flistNoCutsSignal->Add(hSecVtxXYNCsign);
766   flistNoCutsSignal->Add(hSecVtxPhiNCsign);
767   flistNoCutsSignal->Add(hd0singlTrackNCsign);
768   flistNoCutsSignal->Add(hCPtaNCsign);
769   flistNoCutsSignal->Add(hd0xd0NCsign);
770   flistNoCutsSignal->Add(hMassTrueNCsign);
771   flistNoCutsSignal->Add(hMassNCsign);
772   flistNoCutsSignal->Add(hMassTrueNCsignPM);
773   flistNoCutsSignal->Add(hMassNCsignPM);
774   flistNoCutsSignal->Add(hMassTrueNCsignSB);
775   flistNoCutsSignal->Add(hMassNCsignSB);
776   
777   //%%% NEW HISTOS %%%%%%%%%%%%%%%%
778   TH1F *hdcaNCsign=new TH1F("hdcaNCsign","hdca_NoCuts_Signal",100,0.,1000.);
779   hdcaNCsign->SetXTitle("dca   [#mum]");
780   hdcaNCsign->SetYTitle("Entries");
781   TH1F *hcosthetastarNCsign=new TH1F("hcosthetastarNCsign","hCosThetaStar_NoCuts_Signal",50,-1.,1.);
782   hcosthetastarNCsign->SetXTitle("cos #theta^{*}");
783   hcosthetastarNCsign->SetYTitle("Entries");
784   TH1F *hptD0NCsign=new TH1F("hptD0NCsign","D^{0} transverse momentum distribution",34,ptbinsD0arr);
785   hptD0NCsign->SetXTitle("p_{t}  [GeV/c]");
786   hptD0NCsign->SetYTitle("Entries");
787   TH1F *hptD0VsMaxPtNCsign=new TH1F("hptD0VsMaxPtNCsign","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
788   TH2F *hptD0PTallsqrtNCsign=new TH2F("hptD0PTallsqrtNCsign","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
789   TH2F *hptD0PTallNCsign=new TH2F("hptD0PTallNCsign","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
790   TH2F *hptD0vsptBNCsign=new TH2F("hptD0vsptBNCsign","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
791   TH2F *hpD0vspBNCsign=new TH2F("hpD0vspBNCsign","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
792   TH2F *hptD0vsptcquarkNCsign=new TH2F("hptD0vsptcquarkNCsign","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
793   TH2F *hpD0vspcquarkNCsign=new TH2F("hpD0vspcquarkNCsign","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
794   flistNoCutsSignal->Add(hdcaNCsign);
795   flistNoCutsSignal->Add(hcosthetastarNCsign);
796   flistNoCutsSignal->Add(hptD0NCsign);
797   flistNoCutsSignal->Add(hptD0VsMaxPtNCsign);
798   flistNoCutsSignal->Add(hptD0PTallsqrtNCsign);
799   flistNoCutsSignal->Add(hptD0PTallNCsign);
800   flistNoCutsSignal->Add(hptD0vsptBNCsign);
801   flistNoCutsSignal->Add(hpD0vspBNCsign);
802   flistNoCutsSignal->Add(hptD0vsptcquarkNCsign);
803   flistNoCutsSignal->Add(hpD0vspcquarkNCsign);
804
805   TH1F *hd0zD0ptNCsign;
806   TH1F *hInvMassD0NCsign,*hInvMassD0barNCsign;
807   TH2F *hInvMassPtNCsign=new TH2F("hInvMassPtNCsign","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
808   flistNoCutsSignal->Add(hInvMassPtNCsign);
809
810   TH3F *hInvMassPtSelSignOnlyNCsign=new TH3F("hInvMassPtSelSignOnlyNCsign","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
811   flistNoCutsSignal->Add(hInvMassPtSelSignOnlyNCsign);
812   TH3F *hInvMassPtSelReflOnlyNCsign=new TH3F("hInvMassPtSelReflOnlyNCsign","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
813   flistNoCutsSignal->Add(hInvMassPtSelReflOnlyNCsign);
814
815   THnSparseF *hSparseNCsign=new THnSparseF("hSparseNCsign","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
816   hSparseNCsign->SetBinEdges(0,massbins);
817   hSparseNCsign->SetBinEdges(1,massbins);
818   hSparseNCsign->SetBinEdges(2,ptbinsForNsparse);
819   hSparseNCsign->SetBinEdges(3,impparbins);
820   hSparseNCsign->SetBinEdges(4,massHypoBins); 
821   flistNoCutsSignal->Add(hSparseNCsign);
822
823
824
825
826   THnSparseF *hSparseCxyLxyNCsign=new THnSparseF("hSparseCxyLxyNCsign","Candidate Mass;massD0;Pt;CosXY;Lxy",4,nbinsSparsCxyLxy,binLowLimitSparseCxyLxy,binUpLimitSparseCxyLxy);
827   hSparseCxyLxyNCsign->SetBinEdges(1,ptbinlimitsCxyLxy);
828   hSparseCxyLxyNCsign->GetAxis(0)->SetName("mass");
829   hSparseCxyLxyNCsign->GetAxis(0)->SetTitle("Invariant Mass (K#pi) [GeV/c^{2}]");
830   hSparseCxyLxyNCsign->GetAxis(1)->SetName("pt");
831   hSparseCxyLxyNCsign->GetAxis(1)->SetTitle("p_{t} [GeV/c]");
832   hSparseCxyLxyNCsign->GetAxis(2)->SetName("CosPointXY");
833   hSparseCxyLxyNCsign->GetAxis(2)->SetTitle("Cos#theta_{point}^{XY}");
834   hSparseCxyLxyNCsign->GetAxis(3)->SetName("NormDecLengthXY");
835   hSparseCxyLxyNCsign->GetAxis(3)->SetTitle("Normalized XY decay length");
836   
837   flistNoCutsSignal->Add(hSparseCxyLxyNCsign);
838
839   
840
841   TH1F *hetaNCsign;
842   TH1F *hCosPDPBNCsign;
843   TH1F *hCosPcPDNCsign;
844   // ADDITIONAL HISTOS
845   TH2F *hd0D0VSd0xd0NCsignpt;
846   TH2F *hangletracksVSd0xd0NCsignpt;
847   TH2F *hangletracksVSd0D0NCsignpt;
848   TH1F *hd0xd0NCsignpt;
849   // AZIMUHAL HISTOS
850   TH1F *hPhiHistPMNCsignpt,*hPhiHistSBNCsignpt;
851
852   
853   TH2F *hTOFpidNCsign=new TH2F("hTOFpidNCsign","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
854   flistNoCutsSignal->Add(hTOFpidNCsign);
855  
856   
857
858   //##################
859   for(Int_t i=0;i<fnbins;i++){
860     //Printf("INSIDE HISTOS CREATION LOOP: %d \n",fnbins);
861     
862     namehist="hPhiHistPMNCsign_pt";
863     namehist+=i;
864     titlehist="Azimuthal correlation No Cuts Sign PM ptbin=";
865     titlehist+=i;
866     hPhiHistPMNCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
867     hPhiHistPMNCsignpt->Sumw2();
868     flistNoCutsSignal->Add(hPhiHistPMNCsignpt);
869
870     namehist="hPhiHistSBNCsign_pt";
871     namehist+=i;
872     titlehist="Azimuthal correlation No Cuts Sign SB ptbin=";
873     titlehist+=i;
874     hPhiHistSBNCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
875     hPhiHistSBNCsignpt->Sumw2();
876     flistNoCutsSignal->Add(hPhiHistSBNCsignpt);
877     
878
879     namehist="hd0zD0ptNCsign_pt";
880     namehist+=i;
881     titlehist="d0(z) No Cuts Signalm ptbin=";
882     titlehist+=i;
883     hd0zD0ptNCsign=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
884     hd0zD0ptNCsign->SetXTitle("d_{0}(z)    [#mum]");
885     hd0zD0ptNCsign->SetYTitle("Entries");
886     flistNoCutsSignal->Add(hd0zD0ptNCsign);
887
888     namehist="hInvMassD0NCsign_pt";
889     namehist+=i;
890     titlehist="Invariant Mass D0 No Cuts Signal ptbin=";
891     titlehist+=i;
892     hInvMassD0NCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
893     hInvMassD0NCsign->SetXTitle("Invariant Mass    [GeV]");
894     hInvMassD0NCsign->SetYTitle("Entries");
895     flistNoCutsSignal->Add(hInvMassD0NCsign);
896
897
898     namehist="hInvMassD0barNCsign_pt";
899     namehist+=i;
900     titlehist="Invariant Mass D0bar No Cuts Signal ptbin=";
901     titlehist+=i;
902     hInvMassD0barNCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
903     hInvMassD0barNCsign->SetXTitle("Invariant Mass    [GeV]");
904     hInvMassD0barNCsign->SetYTitle("Entries");
905     flistNoCutsSignal->Add(hInvMassD0barNCsign);
906
907
908     namehist="hetaNCsign_pt";
909     namehist+=i;
910     titlehist="eta No Cuts Signal ptbin=";
911     titlehist+=i;
912     hetaNCsign=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
913     hetaNCsign->SetXTitle("Pseudorapidity");
914     hetaNCsign->SetYTitle("Entries");
915     flistNoCutsSignal->Add(hetaNCsign);
916
917     namehist="hCosPDPBNCsign_pt";
918     namehist+=i;
919     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
920     titlehist+=i;
921     hCosPDPBNCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
922     hCosPDPBNCsign->SetXTitle("Cosine between D0 momentum and B momentum");
923     hCosPDPBNCsign->SetYTitle("Entries");
924     flistNoCutsSignal->Add(hCosPDPBNCsign);
925
926     namehist="hCosPcPDNCsign_pt";
927     namehist+=i;
928     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
929     titlehist+=i;
930     hCosPcPDNCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
931     hCosPcPDNCsign->SetXTitle("Cosine between c quark momentum and D0 momentum");
932     hCosPcPDNCsign->SetYTitle("Entries");
933     flistNoCutsSignal->Add(hCosPcPDNCsign);
934     
935
936     // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
937     namehist="hd0xd0NCsign_pt";
938     namehist+=i;
939     titlehist="d0xd0 No Cuts Signal ptbin=";
940     titlehist+=i;
941     hd0xd0NCsignpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
942     hd0xd0NCsignpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
943     hd0xd0NCsignpt->SetYTitle("Entries");
944     flistNoCutsSignal->Add(hd0xd0NCsignpt);
945
946
947     namehist="hd0D0VSd0xd0NCsign_pt";
948     namehist+=i;
949     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Signal ptbin=";
950     titlehist+=i;
951     hd0D0VSd0xd0NCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
952     hd0D0VSd0xd0NCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
953     hd0D0VSd0xd0NCsignpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
954     flistNoCutsSignal->Add(hd0D0VSd0xd0NCsignpt);
955     
956     
957     namehist="hangletracksVSd0xd0NCsign_pt";
958     namehist+=i;
959     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Signal ptbin=";
960     titlehist+=i;
961     hangletracksVSd0xd0NCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
962     hangletracksVSd0xd0NCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
963     hangletracksVSd0xd0NCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
964     flistNoCutsSignal->Add(hangletracksVSd0xd0NCsignpt);
965     
966
967     namehist="hangletracksVSd0D0NCsign_pt";
968     namehist+=i;
969     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} No Cuts Signal ptbin=";
970     titlehist+=i;
971     hangletracksVSd0D0NCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
972     hangletracksVSd0D0NCsignpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
973     hangletracksVSd0D0NCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
974     flistNoCutsSignal->Add(hangletracksVSd0D0NCsignpt);
975
976   }
977   Printf("AFTER LOOP HISTOS CREATION \n");
978   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
979   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
980
981   // ####### d0 D0 histos ############
982   TH1F *hd0D0NCsignPM = new TH1F("hd0D0NCsignPM","D^{0} impact par. plot , No Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
983   hd0D0NCsignPM->SetXTitle("Impact parameter [#mum]");
984   hd0D0NCsignPM->SetYTitle("Entries");
985
986   TH1F *hd0D0VtxTrueNCsignPM = new TH1F("hd0D0VtxTrueNCsignPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
987   hd0D0VtxTrueNCsignPM->SetXTitle("Impact parameter [#mum]");
988   hd0D0VtxTrueNCsignPM->SetYTitle("Entries");
989
990   TH1F *hMCd0D0NCsignPM = new TH1F("hMCd0D0NCsignPM","D^{0} impact par. plot, No Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
991   hMCd0D0NCsignPM->SetXTitle("MC Impact parameter [#mum]");
992   hMCd0D0NCsignPM->SetYTitle("Entries");
993
994   TH1F *hd0D0NCsignSB = new TH1F("hd0D0NCsignSB","D^{0} impact par. plot , No Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
995   hd0D0NCsignSB->SetXTitle("Impact parameter [#mum]");
996   hd0D0NCsignSB->SetYTitle("Entries");
997
998   TH1F *hd0D0VtxTrueNCsignSB = new TH1F("hd0D0VtxTrueNCsignSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
999   hd0D0VtxTrueNCsignSB->SetXTitle("Impact parameter [#mum]");
1000   hd0D0VtxTrueNCsignSB->SetYTitle("Entries");
1001
1002   TH1F *hMCd0D0NCsignSB = new TH1F("hMCd0D0NCsignSB","D^{0} impact par. plot, No Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
1003   hMCd0D0NCsignSB->SetXTitle("MC Impact parameter [#mum]");
1004   hMCd0D0NCsignSB->SetYTitle("Entries");
1005
1006   flistNoCutsSignal->Add(hd0D0NCsignPM);
1007   flistNoCutsSignal->Add(hd0D0VtxTrueNCsignPM);
1008   flistNoCutsSignal->Add(hMCd0D0NCsignPM);
1009   flistNoCutsSignal->Add(hd0D0NCsignSB);
1010   flistNoCutsSignal->Add(hd0D0VtxTrueNCsignSB);
1011   flistNoCutsSignal->Add(hMCd0D0NCsignSB);
1012   
1013   TH1F *hd0D0ptNCsignPM;
1014   TH1F *hMCd0D0ptNCsignPM;
1015   TH1F *hd0D0VtxTrueptNCsignPM;
1016   TH1F *hd0D0ptNCsignSB;
1017   TH1F *hMCd0D0ptNCsignSB;
1018   TH1F *hd0D0VtxTrueptNCsignSB;
1019   namehist="hd0D0ptNCsign_";
1020   titlehist="D^{0} impact par. plot, No Cuts, Signal, ";
1021   for(Int_t i=0;i<fnbins;i++){
1022     //Printf("IN HISTOS CREATION USING PTBINS VALUES for NAMES \n");
1023     strnamept=namehist;
1024     strnamept.Append("PkMss_pt");
1025     strnamept+=i;
1026
1027     strtitlept=titlehist;
1028     strtitlept.Append(" Mass Peak, ");
1029
1030     strtitlept+=fptbins[i];
1031     //Printf("IN HISTOS CREATION USING PTBINS VALUES for NAMES %d: %f\n",i,fptbins[i]);
1032     strtitlept.Append("<= pt <");
1033     strtitlept+=fptbins[i+1];
1034     strtitlept.Append(" [GeV/c]");
1035     
1036     hd0D0ptNCsignPM= new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1037     hd0D0ptNCsignPM->SetXTitle("Impact parameter [#mum] ");
1038     hd0D0ptNCsignPM->SetYTitle("Entries");
1039     flistNoCutsSignal->Add(hd0D0ptNCsignPM);
1040
1041     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1042     hMCd0D0ptNCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1043     hMCd0D0ptNCsignPM->SetXTitle("MC Impact parameter [#mum] ");
1044     hMCd0D0ptNCsignPM->SetYTitle("Entries");
1045     flistNoCutsSignal->Add(hMCd0D0ptNCsignPM);
1046  
1047
1048     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1049     hd0D0VtxTrueptNCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1050     hd0D0VtxTrueptNCsignPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1051     hd0D0VtxTrueptNCsignPM->SetYTitle("Entries");
1052     flistNoCutsSignal->Add(hd0D0VtxTrueptNCsignPM);
1053     
1054     strnamept=namehist;
1055     strnamept.Append("SBMss_pt");
1056     strnamept+=i;
1057
1058     strtitlept=titlehist;
1059     strtitlept.Append(" Side Bands, ");
1060     strtitlept+=fptbins[i];
1061     strtitlept.Append("<= pt <");
1062     strtitlept+=fptbins[i+1];
1063     strtitlept.Append(" [GeV/c]");
1064     
1065     hd0D0ptNCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1066     hd0D0ptNCsignSB->SetXTitle("Impact parameter [#mum] ");
1067     hd0D0ptNCsignSB->SetYTitle("Entries");
1068     flistNoCutsSignal->Add(hd0D0ptNCsignSB);
1069
1070     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1071     hMCd0D0ptNCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1072     hMCd0D0ptNCsignSB->SetXTitle("MC Impact parameter [#mum] ");
1073     hMCd0D0ptNCsignSB->SetYTitle("Entries");
1074     flistNoCutsSignal->Add(hMCd0D0ptNCsignSB);
1075
1076     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1077     hd0D0VtxTrueptNCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1078     hd0D0VtxTrueptNCsignSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1079     hd0D0VtxTrueptNCsignSB->SetYTitle("Entries");
1080     flistNoCutsSignal->Add(hd0D0VtxTrueptNCsignSB);
1081   }
1082
1083   //Printf("AFTER SIGNAL HISTOS CREATION for NOCUTS\n");
1084
1085
1086   //############ NO CUTS BACKGROUND HISTOGRAMS ###########
1087   //
1088   //   ######## global properties histos #######
1089   TH2F *hCPtaVSd0d0NCback=new TH2F("hCPtaVSd0d0NCback","hCPtaVSd0d0_NoCuts_Background",1000,-100000.,100000.,100,-1.,1.);
1090   TH1F *hSecVtxZNCback=new TH1F("hSecVtxZNCback","hSecVtxZ_NoCuts_Background",1000,-8.,8.);
1091   TH1F *hSecVtxXNCback=new TH1F("hSecVtxXNCback","hSecVtxX_NoCuts_Background",1000,-3000.,3000.);
1092   TH1F *hSecVtxYNCback=new TH1F("hSecVtxYNCback","hSecVtxY_NoCuts_Background",1000,-3000.,3000.);
1093   TH2F *hSecVtxXYNCback=new TH2F("hSecVtxXYNCback","hSecVtxXY_NoCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
1094   TH1F *hSecVtxPhiNCback=new TH1F("hSecVtxPhiNCback","hSecVtxPhi_NoCuts_Background",180,-180.1,180.1);
1095   TH1F *hd0singlTrackNCback=new TH1F("hd0singlTrackNCback","hd0singlTrackNoCuts_Back",1000,-5000.,5000.);
1096   TH1F *hCPtaNCback=new TH1F("hCPtaNCback","hCPta_NoCuts_Background",100,-1.,1.);
1097   TH1F *hd0xd0NCback=new TH1F("hd0xd0NCback","hd0xd0_NoCuts_Background",1000,-100000.,100000.);
1098   TH1F *hMassTrueNCback=new TH1F("hMassTrueNCback","D^{0} MC inv. Mass No Cuts Background(All momenta)",600,1.600,2.200);
1099   TH1F *hMassNCback=new TH1F("hMassNCback","D^{0} inv. Mass No Cuts Background (All momenta)",600,1.600,2.200);
1100   hMassNCback->Sumw2();
1101   TH1F *hMassTrueNCbackPM=new TH1F("hMassTrueNCbackPM","D^{0} MC inv. Mass No Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
1102   TH1F *hMassNCbackPM=new TH1F("hMassNCbackPM","D^{0} inv. Mass No Cuts Background (All momenta), MassPeak",600,1.600,2.200);
1103   hMassNCbackPM->Sumw2();
1104   TH1F *hMassTrueNCbackSB=new TH1F("hMassTrueNCbackSB","D^{0} MC inv. Mass in Side Bands No Cuts Background(All momenta)",600,1.600,2.200);
1105   TH1F *hMassNCbackSB=new TH1F("hMassNCbackSB","D^{0} inv. Mass in Side Bands No Cuts Background (All momenta)",600,1.600,2.200);
1106   hMassNCbackSB->Sumw2();
1107
1108   flistNoCutsBack->Add(hCPtaVSd0d0NCback);
1109   flistNoCutsBack->Add(hSecVtxZNCback);
1110   flistNoCutsBack->Add(hSecVtxYNCback);
1111   flistNoCutsBack->Add(hSecVtxXNCback);
1112   flistNoCutsBack->Add(hSecVtxXYNCback);
1113   flistNoCutsBack->Add(hSecVtxPhiNCback);
1114   flistNoCutsBack->Add(hd0singlTrackNCback);
1115   flistNoCutsBack->Add(hCPtaNCback);
1116   flistNoCutsBack->Add(hd0xd0NCback);
1117   flistNoCutsBack->Add(hMassTrueNCback);
1118   flistNoCutsBack->Add(hMassNCback);
1119   flistNoCutsBack->Add(hMassTrueNCbackPM);
1120   flistNoCutsBack->Add(hMassNCbackPM);
1121   flistNoCutsBack->Add(hMassTrueNCbackSB);
1122   flistNoCutsBack->Add(hMassNCbackSB);
1123
1124
1125  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
1126   TH1F *hdcaNCback=new TH1F("hdcaNCback","hdca_NoCuts_Backgr",100,0.,1000.);
1127   hdcaNCback->SetXTitle("dca   [#mum]");
1128   hdcaNCback->SetYTitle("Entries");
1129   TH1F *hcosthetastarNCback=new TH1F("hcosthetastarNCback","hCosThetaStar_NoCuts_Backgr",50,-1.,1.);
1130   hcosthetastarNCback->SetXTitle("cos #theta^{*}");
1131   hcosthetastarNCback->SetYTitle("Entries");
1132   TH1F *hptD0NCback=new TH1F("hptD0NCback","D^{0} transverse momentum distribution",34,ptbinsD0arr);
1133   hptD0NCback->SetXTitle("p_{t}  [GeV/c]");
1134   hptD0NCback->SetYTitle("Entries");
1135   TH1F *hptD0VsMaxPtNCback=new TH1F("hptD0VsMaxPtNCback","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
1136   TH2F *hptD0PTallsqrtNCback=new TH2F("hptD0PTallsqrtNCback","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
1137   TH2F *hptD0PTallNCback=new TH2F("hptD0PTallNCback","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
1138   TH2F *hptD0vsptBNCback=new TH2F("hptD0vsptBNCback","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1139   TH2F *hpD0vspBNCback=new TH2F("hpD0vspBNCback","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1140   TH2F *hptD0vsptcquarkNCback=new TH2F("hptD0vsptcquarkNCback","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1141   TH2F *hpD0vspcquarkNCback=new TH2F("hpD0vspcquarkNCback","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1142   flistNoCutsBack->Add(hdcaNCback);
1143   flistNoCutsBack->Add(hcosthetastarNCback);
1144   flistNoCutsBack->Add(hptD0NCback);
1145   flistNoCutsBack->Add(hptD0VsMaxPtNCback);
1146   flistNoCutsBack->Add(hptD0PTallsqrtNCback);
1147   flistNoCutsBack->Add(hptD0PTallNCback);
1148   flistNoCutsBack->Add(hptD0vsptBNCback);
1149   flistNoCutsBack->Add(hpD0vspBNCback);
1150   flistNoCutsBack->Add(hptD0vsptcquarkNCback);
1151   flistNoCutsBack->Add(hpD0vspcquarkNCback);
1152  
1153   TH1F *hd0zD0ptNCback;
1154   TH1F *hInvMassD0NCback,*hInvMassD0barNCback;
1155   TH2F *hInvMassPtNCback=new TH2F("hInvMassPtNCback","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
1156   THnSparseF *hSparseNCback=new THnSparseF("hSparseNCback","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
1157   hSparseNCback->SetBinEdges(0,massbins);
1158   hSparseNCback->SetBinEdges(1,massbins);
1159   hSparseNCback->SetBinEdges(2,ptbinsForNsparse);
1160   hSparseNCback->SetBinEdges(3,impparbins);
1161   hSparseNCback->SetBinEdges(4,massHypoBins); 
1162   flistNoCutsBack->Add(hSparseNCback);
1163
1164   TH1F *hetaNCback;
1165   TH1F *hCosPDPBNCback;
1166   TH1F *hCosPcPDNCback;
1167    // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1168   TH2F *hd0D0VSd0xd0NCbackpt;
1169   TH2F *hangletracksVSd0xd0NCbackpt;
1170   TH2F *hangletracksVSd0D0NCbackpt;
1171   TH1F *hd0xd0NCbackpt;
1172   flistNoCutsBack->Add(hInvMassPtNCback);
1173
1174   TH2F *hTOFpidNCback=new TH2F("hTOFpidNCback","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
1175   flistNoCutsBack->Add(hTOFpidNCback);
1176
1177   for(Int_t i=0;i<fnbins;i++){
1178     namehist="hd0zD0ptNCback_pt";
1179     namehist+=i;
1180     titlehist="d0(z) No Cuts Backgrm ptbin=";
1181     titlehist+=i;
1182     hd0zD0ptNCback=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
1183     hd0zD0ptNCback->SetXTitle("d_{0}(z)    [#mum]");
1184     hd0zD0ptNCback->SetYTitle("Entries");
1185     flistNoCutsBack->Add(hd0zD0ptNCback);
1186
1187     namehist="hInvMassD0NCback_pt";
1188     namehist+=i;
1189     titlehist="Invariant Mass No Cuts Backgr ptbin=";
1190     titlehist+=i;
1191     hInvMassD0NCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1192     hInvMassD0NCback->SetXTitle("Invariant Mass    [GeV]");
1193     hInvMassD0NCback->SetYTitle("Entries");
1194     flistNoCutsBack->Add(hInvMassD0NCback);
1195
1196     
1197     namehist="hInvMassD0barNCback_pt";
1198     namehist+=i;
1199     titlehist="Invariant Mass D0bar No Cuts Back ptbin=";
1200     titlehist+=i;
1201     hInvMassD0barNCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1202     hInvMassD0barNCback->SetXTitle("Invariant Mass    [GeV]");
1203     hInvMassD0barNCback->SetYTitle("Entries");
1204     flistNoCutsBack->Add(hInvMassD0barNCback);
1205
1206
1207     namehist="hetaNCback_pt";
1208     namehist+=i;
1209     titlehist="eta No Cuts Backgr ptbin=";
1210     titlehist+=i;
1211     hetaNCback=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
1212     hetaNCback->SetXTitle("Pseudorapidity");
1213     hetaNCback->SetYTitle("Entries");
1214     flistNoCutsBack->Add(hetaNCback);
1215
1216     namehist="hCosPDPBNCback_pt";
1217     namehist+=i;
1218     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
1219     titlehist+=i;
1220     hCosPDPBNCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1221     hCosPDPBNCback->SetXTitle("Cosine between D0 momentum and B momentum");
1222     hCosPDPBNCback->SetYTitle("Entries");
1223     flistNoCutsBack->Add(hCosPDPBNCback);
1224
1225     namehist="hCosPcPDNCback_pt";
1226     namehist+=i;
1227     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
1228     titlehist+=i;
1229     hCosPcPDNCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1230     hCosPcPDNCback->SetXTitle("Cosine between c quark momentum and D0 momentum");
1231     hCosPcPDNCback->SetYTitle("Entries");
1232     flistNoCutsBack->Add(hCosPcPDNCback);
1233
1234
1235     // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1236     namehist="hd0xd0NCback_pt";
1237     namehist+=i;
1238     titlehist="d0xd0 No Cuts Background ptbin=";
1239     titlehist+=i;
1240     hd0xd0NCbackpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
1241     hd0xd0NCbackpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
1242     hd0xd0NCbackpt->SetYTitle("Entries");
1243     flistNoCutsBack->Add(hd0xd0NCbackpt);
1244
1245
1246     namehist="hd0D0VSd0xd0NCback_pt";
1247     namehist+=i;
1248     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Back ptbin=";
1249     titlehist+=i;
1250     hd0D0VSd0xd0NCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
1251     hd0D0VSd0xd0NCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1252     hd0D0VSd0xd0NCbackpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
1253     flistNoCutsBack->Add(hd0D0VSd0xd0NCbackpt);
1254     
1255     
1256     namehist="hangletracksVSd0xd0NCback_pt";
1257     namehist+=i;
1258     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Back ptbin=";
1259     titlehist+=i;
1260     hangletracksVSd0xd0NCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
1261     hangletracksVSd0xd0NCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1262     hangletracksVSd0xd0NCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
1263     flistNoCutsBack->Add(hangletracksVSd0xd0NCbackpt);
1264     
1265
1266     namehist="hangletracksVSd0D0NCback_pt";
1267     namehist+=i;
1268     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} No Cuts Back ptbin=";
1269     titlehist+=i;
1270     hangletracksVSd0D0NCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
1271     hangletracksVSd0D0NCbackpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
1272     hangletracksVSd0D0NCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
1273     flistNoCutsBack->Add(hangletracksVSd0D0NCbackpt);
1274
1275
1276     
1277   }
1278   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
1279   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1280
1281
1282
1283   // ####### d0 D0 histos ############
1284   
1285  TH1F *hd0D0NCbackPM = new TH1F("hd0D0NCbackPM","D^{0} impact par. plot , No Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1286   hd0D0NCbackPM->SetXTitle("Impact parameter [#mum]");
1287   hd0D0NCbackPM->SetYTitle("Entries");
1288
1289   TH1F *hd0D0VtxTrueNCbackPM = new TH1F("hd0D0VtxTrueNCbackPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1290   hd0D0VtxTrueNCbackPM->SetXTitle("Impact parameter [#mum]");
1291   hd0D0VtxTrueNCbackPM->SetYTitle("Entries");
1292
1293   TH1F *hMCd0D0NCbackPM = new TH1F("hMCd0D0NCbackPM","D^{0} impact par. plot, No Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
1294   hMCd0D0NCbackPM->SetXTitle("MC Impact parameter [#mum]");
1295   hMCd0D0NCbackPM->SetYTitle("Entries");
1296
1297   TH1F *hd0D0NCbackSB = new TH1F("hd0D0NCbackSB","D^{0} impact par. plot , No Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1298   hd0D0NCbackSB->SetXTitle("Impact parameter [#mum]");
1299   hd0D0NCbackSB->SetYTitle("Entries");
1300
1301   TH1F *hd0D0VtxTrueNCbackSB = new TH1F("hd0D0VtxTrueNCbackSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
1302   hd0D0VtxTrueNCbackSB->SetXTitle("Impact parameter [#mum]");
1303   hd0D0VtxTrueNCbackSB->SetYTitle("Entries");
1304
1305   TH1F *hMCd0D0NCbackSB = new TH1F("hMCd0D0NCbackSB","D^{0} impact par. plot, No Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
1306   hMCd0D0NCbackSB->SetXTitle("MC Impact parameter [#mum]");
1307   hMCd0D0NCbackSB->SetYTitle("Entries");
1308
1309   flistNoCutsBack->Add(hd0D0NCbackPM);
1310   flistNoCutsBack->Add(hd0D0VtxTrueNCbackPM);
1311   flistNoCutsBack->Add(hMCd0D0NCbackPM);
1312   flistNoCutsBack->Add(hd0D0NCbackSB);
1313   flistNoCutsBack->Add(hd0D0VtxTrueNCbackSB);
1314   flistNoCutsBack->Add(hMCd0D0NCbackSB);
1315   
1316   TH1F *hd0D0ptNCbackPM;
1317   TH1F *hMCd0D0ptNCbackPM;
1318   TH1F *hd0D0VtxTrueptNCbackPM;
1319   TH1F *hd0D0ptNCbackSB;
1320   TH1F *hMCd0D0ptNCbackSB;
1321   TH1F *hd0D0VtxTrueptNCbackSB;
1322   namehist="hd0D0ptNCback_";
1323   titlehist="D^{0} impact par. plot, No Cuts, Background, ";
1324   for(Int_t i=0;i<fnbins;i++){
1325     strnamept=namehist;
1326     strnamept.Append("PkMss_pt");
1327     strnamept+=i;
1328
1329     strtitlept=titlehist;
1330     strtitlept.Append(" Mass Peak, ");
1331     strtitlept+=fptbins[i];
1332     strtitlept.Append("<= pt <");
1333     strtitlept+=fptbins[i+1];
1334     strtitlept.Append(" [GeV/c]");
1335     
1336     hd0D0ptNCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1337     hd0D0ptNCbackPM->SetXTitle("Impact parameter [#mum] ");
1338     hd0D0ptNCbackPM->SetYTitle("Entries");
1339     flistNoCutsBack->Add(hd0D0ptNCbackPM);
1340
1341     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1342     hMCd0D0ptNCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1343     hMCd0D0ptNCbackPM->SetXTitle("MC Impact parameter [#mum] ");
1344     hMCd0D0ptNCbackPM->SetYTitle("Entries");
1345     flistNoCutsBack->Add(hMCd0D0ptNCbackPM);
1346  
1347
1348     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1349     hd0D0VtxTrueptNCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1350     hd0D0VtxTrueptNCbackPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1351     hd0D0VtxTrueptNCbackPM->SetYTitle("Entries");
1352     flistNoCutsBack->Add(hd0D0VtxTrueptNCbackPM);
1353     
1354     strnamept=namehist;
1355     strnamept.Append("SBMss_pt");
1356     strnamept+=i;
1357
1358     strtitlept=titlehist;
1359     strtitlept.Append(" Side Bands, ");
1360     strtitlept+=fptbins[i];
1361     strtitlept.Append("<= pt <");
1362     strtitlept+=fptbins[i+1];
1363     strtitlept.Append(" [GeV/c]");
1364     
1365     hd0D0ptNCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1366     hd0D0ptNCbackSB->SetXTitle("Impact parameter [#mum] ");
1367     hd0D0ptNCbackSB->SetYTitle("Entries");
1368     flistNoCutsBack->Add(hd0D0ptNCbackSB);
1369
1370     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1371     hMCd0D0ptNCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1372     hMCd0D0ptNCbackSB->SetXTitle("MC Impact parameter [#mum] ");
1373     hMCd0D0ptNCbackSB->SetYTitle("Entries");
1374     flistNoCutsBack->Add(hMCd0D0ptNCbackSB);
1375
1376     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1377     hd0D0VtxTrueptNCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1378     hd0D0VtxTrueptNCbackSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1379     hd0D0VtxTrueptNCbackSB->SetYTitle("Entries");
1380     flistNoCutsBack->Add(hd0D0VtxTrueptNCbackSB);
1381   }
1382
1383
1384
1385  //############ NO CUTS FROMB HISTOGRAMS ###########
1386   //
1387   //#######  global properties histos
1388
1389   TH2F *hCPtaVSd0d0NCfromB=new TH2F("hCPtaVSd0d0NCfromB","hCPtaVSd0d0_NoCuts_FromB",1000,-100000.,100000.,100,-1.,1.);
1390   TH1F *hSecVtxZNCfromB=new TH1F("hSecVtxZNCfromB","hSecVtxZ_NoCuts_FromB",1000,-8.,8.);
1391   TH1F *hSecVtxXNCfromB=new TH1F("hSecVtxXNCfromB","hSecVtxX_NoCuts_FromB",1000,-3000.,3000.);
1392   TH1F *hSecVtxYNCfromB=new TH1F("hSecVtxYNCfromB","hSecVtxY_NoCuts_FromB",1000,-3000.,3000.);
1393   TH2F *hSecVtxXYNCfromB=new TH2F("hSecVtxXYNCfromB","hSecVtxXY_NoCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
1394   TH1F *hSecVtxPhiNCfromB=new TH1F("hSecVtxPhiNCfromB","hSecVtxPhi_NoCuts_FromB",180,-180.1,180.1);
1395   TH1F *hd0singlTrackNCfromB=new TH1F("hd0singlTrackNCfromB","hd0singlTrackNoCuts_FromB",1000,-5000.,5000.);
1396   TH1F *hCPtaNCfromB=new TH1F("hCPtaNCfromB","hCPta_NoCuts_FromB",100,-1.,1.);
1397   TH1F *hd0xd0NCfromB=new TH1F("hd0xd0NCfromB","hd0xd0_NoCuts_FromB",1000,-100000.,100000.);
1398   TH1F *hMassTrueNCfromB=new TH1F("hMassTrueNCfromB","D^{0} MC inv. Mass No Cuts FromB(All momenta)",600,1.600,2.200);
1399   TH1F *hMassNCfromB=new TH1F("hMassNCfromB","D^{0} inv. Mass No Cuts FromB (All momenta)",600,1.600,2.200);
1400   hMassNCfromB->Sumw2();
1401   TH1F *hMassTrueNCfromBPM=new TH1F("hMassTrueNCfromBPM","D^{0} MC inv. Mass No Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
1402   TH1F *hMassNCfromBPM=new TH1F("hMassNCfromBPM","D^{0} inv. Mass No Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
1403   hMassNCfromB->Sumw2();
1404   TH1F *hMassTrueNCfromBSB=new TH1F("hMassTrueNCfromBSB","D^{0} MC inv. Mass in Side Bands No Cuts FromB(All momenta)",600,1.600,2.200);
1405   TH1F *hMassNCfromBSB=new TH1F("hMassNCfromBSB","D^{0} inv. Mass in Side Bands No Cuts FromB (All momenta)",600,1.600,2.200);
1406   hMassNCfromBSB->Sumw2();
1407
1408   flistNoCutsFromB->Add(hCPtaVSd0d0NCfromB);
1409   flistNoCutsFromB->Add(hSecVtxZNCfromB);
1410   flistNoCutsFromB->Add(hSecVtxYNCfromB);
1411   flistNoCutsFromB->Add(hSecVtxXNCfromB);
1412   flistNoCutsFromB->Add(hSecVtxXYNCfromB);
1413   flistNoCutsFromB->Add(hSecVtxPhiNCfromB);
1414   flistNoCutsFromB->Add(hd0singlTrackNCfromB);
1415   flistNoCutsFromB->Add(hCPtaNCfromB);
1416   flistNoCutsFromB->Add(hd0xd0NCfromB);
1417   flistNoCutsFromB->Add(hMassTrueNCfromB);
1418   flistNoCutsFromB->Add(hMassNCfromB);
1419   flistNoCutsFromB->Add(hMassTrueNCfromBPM);
1420   flistNoCutsFromB->Add(hMassNCfromBPM);
1421   flistNoCutsFromB->Add(hMassTrueNCfromBSB);
1422   flistNoCutsFromB->Add(hMassNCfromBSB);
1423
1424
1425
1426
1427
1428  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
1429   TH1F *hdcaNCfromB=new TH1F("hdcaNCfromB","hdca_NoCuts_FromB",100,0.,1000.);
1430   hdcaNCfromB->SetXTitle("dca   [#mum]");
1431   hdcaNCfromB->SetYTitle("Entries");
1432   TH1F *hcosthetastarNCfromB=new TH1F("hcosthetastarNCfromB","hCosThetaStar_NoCuts_FromB",50,-1.,1.);
1433   hcosthetastarNCfromB->SetXTitle("cos #theta^{*}");
1434   hcosthetastarNCfromB->SetYTitle("Entries");
1435   TH1F *hptD0NCfromB=new TH1F("hptD0NCfromB","D^{0} transverse momentum distribution",34,ptbinsD0arr);
1436   hptD0NCfromB->SetXTitle("p_{t}  [GeV/c]");
1437   hptD0NCfromB->SetYTitle("Entries");
1438   TH1F *hptD0VsMaxPtNCfromB=new TH1F("hptD0VsMaxPtNCfromB","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
1439   TH2F *hptD0PTallsqrtNCfromB=new TH2F("hptD0PTallsqrtNCfromB","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
1440   TH2F *hptD0PTallNCfromB=new TH2F("hptD0PTallNCfromB","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
1441   TH2F *hptD0vsptBNCfromB=new TH2F("hptD0vsptBNCfromB","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1442   TH2F *hpD0vspBNCfromB=new TH2F("hpD0vspBNCfromB","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1443   TH2F *hptD0vsptcquarkNCfromB=new TH2F("hptD0vsptcquarkNCfromB","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1444   TH2F *hpD0vspcquarkNCfromB=new TH2F("hpD0vspcquarkNCfromB","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1445   flistNoCutsFromB->Add(hdcaNCfromB);
1446   flistNoCutsFromB->Add(hcosthetastarNCfromB);
1447   flistNoCutsFromB->Add(hptD0NCfromB);
1448   flistNoCutsFromB->Add(hptD0VsMaxPtNCfromB);
1449   flistNoCutsFromB->Add(hptD0PTallsqrtNCfromB);
1450   flistNoCutsFromB->Add(hptD0PTallNCfromB);
1451   flistNoCutsFromB->Add(hptD0vsptBNCfromB);
1452   flistNoCutsFromB->Add(hpD0vspBNCfromB);
1453   flistNoCutsFromB->Add(hptD0vsptcquarkNCfromB);
1454   flistNoCutsFromB->Add(hpD0vspcquarkNCfromB);
1455  
1456   TH1F *hd0zD0ptNCfromB;
1457   TH1F *hInvMassD0NCfromB,*hInvMassD0barNCfromB;
1458   TH2F *hInvMassPtNCfromB=new TH2F("hInvMassPtNCfromB","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
1459   TH3F *hInvMassPtSelSignOnlyNCfromB=new TH3F("hInvMassPtSelSignOnlyNCfromB","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
1460   flistNoCutsFromB->Add(hInvMassPtSelSignOnlyNCfromB);
1461   TH3F *hInvMassPtSelReflOnlyNCfromB=new TH3F("hInvMassPtSelReflOnlyNCfromB","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
1462   flistNoCutsFromB->Add(hInvMassPtSelReflOnlyNCfromB);
1463
1464   THnSparseF *hSparseNCfromB=new THnSparseF("hSparseNCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
1465   hSparseNCfromB->SetBinEdges(0,massbins);
1466   hSparseNCfromB->SetBinEdges(1,massbins);
1467   hSparseNCfromB->SetBinEdges(2,ptbinsForNsparse);
1468   hSparseNCfromB->SetBinEdges(3,impparbins);
1469   hSparseNCfromB->SetBinEdges(4,massHypoBins); 
1470   flistNoCutsFromB->Add(hSparseNCfromB);
1471
1472
1473
1474   THnSparseF *hSparseRecoNCfromB=new THnSparseF("hSparseRecoNCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
1475   hSparseRecoNCfromB->SetBinEdges(0,massbins);
1476   hSparseRecoNCfromB->SetBinEdges(1,massbins);
1477   hSparseRecoNCfromB->SetBinEdges(2,ptbinsForNsparse);
1478   hSparseRecoNCfromB->SetBinEdges(3,impparbins);
1479   hSparseRecoNCfromB->SetBinEdges(4,massHypoBins); 
1480   flistNoCutsFromB->Add(hSparseRecoNCfromB);
1481
1482
1483   TH1F *hetaNCfromB;
1484   TH1F *hCosPDPBNCfromB;
1485   TH1F *hCosPcPDNCfromB;
1486
1487    // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1488   TH2F *hd0D0VSd0xd0NCfromBpt;
1489   TH2F *hangletracksVSd0xd0NCfromBpt;
1490   TH2F *hangletracksVSd0D0NCfromBpt;
1491   TH1F *hd0xd0NCfromBpt;
1492   flistNoCutsFromB->Add(hInvMassPtNCfromB);
1493
1494   TH2F *hTOFpidNCfromB=new TH2F("hTOFpidNCfromB","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
1495   flistNoCutsFromB->Add(hTOFpidNCfromB);
1496
1497   for(Int_t i=0;i<fnbins;i++){
1498     namehist="hd0zD0ptNCfromB_pt";
1499     namehist+=i;
1500     titlehist="d0(z) No Cuts FromB ptbin=";
1501     titlehist+=i;
1502     hd0zD0ptNCfromB=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
1503     hd0zD0ptNCfromB->SetXTitle("d_{0}(z)    [#mum]");
1504     hd0zD0ptNCfromB->SetYTitle("Entries");
1505     flistNoCutsFromB->Add(hd0zD0ptNCfromB);
1506
1507     namehist="hInvMassD0NCfromB_pt";
1508     namehist+=i;
1509     titlehist="Invariant Mass No Cuts FromB ptbin=";
1510     titlehist+=i;
1511     hInvMassD0NCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1512     hInvMassD0NCfromB->SetXTitle("Invariant Mass    [GeV]");
1513     hInvMassD0NCfromB->SetYTitle("Entries");
1514     flistNoCutsFromB->Add(hInvMassD0NCfromB);
1515
1516
1517     namehist="hInvMassD0barNCfromB_pt";
1518     namehist+=i;
1519     titlehist="Invariant Mass D0bar No Cuts FromB ptbin=";
1520     titlehist+=i;
1521     hInvMassD0barNCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1522     hInvMassD0barNCfromB->SetXTitle("Invariant Mass    [GeV]");
1523     hInvMassD0barNCfromB->SetYTitle("Entries");
1524     flistNoCutsFromB->Add(hInvMassD0barNCfromB);
1525
1526
1527
1528     namehist="hetaNCfromB_pt";
1529     namehist+=i;
1530     titlehist="eta No Cuts FromB ptbin=";
1531     titlehist+=i;
1532     hetaNCfromB=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
1533     hetaNCfromB->SetXTitle("Pseudorapidity");
1534     hetaNCfromB->SetYTitle("Entries");
1535     flistNoCutsFromB->Add(hetaNCfromB);
1536
1537     namehist="hCosPDPBNCfromB_pt";
1538     namehist+=i;
1539     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
1540     titlehist+=i;
1541     hCosPDPBNCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1542     hCosPDPBNCfromB->SetXTitle("Cosine between D0 momentum and B momentum");
1543     hCosPDPBNCfromB->SetYTitle("Entries");
1544     flistNoCutsFromB->Add(hCosPDPBNCfromB);
1545
1546     namehist="hCosPcPDNCfromB_pt";
1547     namehist+=i;
1548     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
1549     titlehist+=i;
1550     hCosPcPDNCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1551     hCosPcPDNCfromB->SetXTitle("Cosine between c quark momentum and D0 momentum");
1552     hCosPcPDNCfromB->SetYTitle("Entries");
1553     flistNoCutsFromB->Add(hCosPcPDNCfromB);
1554
1555 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1556     namehist="hd0xd0NCfromB_pt";
1557     namehist+=i;
1558     titlehist="d0xd0 No Cuts FromB ptbin=";
1559     titlehist+=i;
1560     hd0xd0NCfromBpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
1561     hd0xd0NCfromBpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
1562     hd0xd0NCfromBpt->SetYTitle("Entries");
1563     flistNoCutsFromB->Add(hd0xd0NCfromBpt);
1564
1565
1566     namehist="hd0D0VSd0xd0NCfromB_pt";
1567     namehist+=i;
1568     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} No Cuts FromB ptbin=";
1569     titlehist+=i;
1570     hd0D0VSd0xd0NCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
1571     hd0D0VSd0xd0NCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1572     hd0D0VSd0xd0NCfromBpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
1573     flistNoCutsFromB->Add(hd0D0VSd0xd0NCfromBpt);
1574     
1575     
1576     namehist="hangletracksVSd0xd0NCfromB_pt";
1577     namehist+=i;
1578     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} No Cuts FromB ptbin=";
1579     titlehist+=i;
1580     hangletracksVSd0xd0NCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
1581     hangletracksVSd0xd0NCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1582     hangletracksVSd0xd0NCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
1583     flistNoCutsFromB->Add(hangletracksVSd0xd0NCfromBpt);
1584     
1585
1586     namehist="hangletracksVSd0D0NCfromB_pt";
1587     namehist+=i;
1588     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} No Cuts FromB ptbin=";
1589     titlehist+=i;
1590     hangletracksVSd0D0NCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
1591     hangletracksVSd0D0NCfromBpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
1592     hangletracksVSd0D0NCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
1593     flistNoCutsFromB->Add(hangletracksVSd0D0NCfromBpt);
1594
1595     
1596   }
1597   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
1598   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1599
1600
1601
1602   // ######### d0 D0 histos ##############
1603   TH1F *hd0D0NCfromBPM = new TH1F("hd0D0NCfromBPM","D^{0} impact par. plot , No Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1604   hd0D0NCfromBPM->SetXTitle("Impact parameter [#mum]");
1605   hd0D0NCfromBPM->SetYTitle("Entries");
1606
1607   TH1F *hd0D0VtxTrueNCfromBPM = new TH1F("hd0D0VtxTrueNCfromBPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1608   hd0D0VtxTrueNCfromBPM->SetXTitle("Impact parameter [#mum]");
1609   hd0D0VtxTrueNCfromBPM->SetYTitle("Entries");
1610
1611   TH1F *hMCd0D0NCfromBPM = new TH1F("hMCd0D0NCfromBPM","D^{0} impact par. plot, No Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
1612   hMCd0D0NCfromBPM->SetXTitle("MC Impact parameter [#mum]");
1613   hMCd0D0NCfromBPM->SetYTitle("Entries");
1614
1615   TH1F *hd0D0NCfromBSB = new TH1F("hd0D0NCfromBSB","D^{0} impact par. plot , No Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1616   hd0D0NCfromBSB->SetXTitle("Impact parameter [#mum]");
1617   hd0D0NCfromBSB->SetYTitle("Entries");
1618
1619   TH1F *hd0D0VtxTrueNCfromBSB = new TH1F("hd0D0VtxTrueNCfromBSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
1620   hd0D0VtxTrueNCfromBSB->SetXTitle("Impact parameter [#mum]");
1621   hd0D0VtxTrueNCfromBSB->SetYTitle("Entries");
1622
1623   TH1F *hMCd0D0NCfromBSB = new TH1F("hMCd0D0NCfromBSB","D^{0} impact par. plot, No Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
1624   hMCd0D0NCfromBSB->SetXTitle("MC Impact parameter [#mum]");
1625   hMCd0D0NCfromBSB->SetYTitle("Entries");
1626
1627   flistNoCutsFromB->Add(hd0D0NCfromBPM);
1628   flistNoCutsFromB->Add(hd0D0VtxTrueNCfromBPM);
1629   flistNoCutsFromB->Add(hMCd0D0NCfromBPM);
1630   flistNoCutsFromB->Add(hd0D0NCfromBSB);
1631   flistNoCutsFromB->Add(hd0D0VtxTrueNCfromBSB);
1632   flistNoCutsFromB->Add(hMCd0D0NCfromBSB);
1633   
1634   TH1F *hd0D0ptNCfromBPM;
1635   TH1F *hMCd0D0ptNCfromBPM;
1636   TH1F *hd0D0VtxTrueptNCfromBPM;
1637   TH1F *hd0D0ptNCfromBSB;
1638   TH1F *hMCd0D0ptNCfromBSB;
1639   TH1F *hd0D0VtxTrueptNCfromBSB;
1640   namehist="hd0D0ptNCfromB_";
1641   titlehist="D^{0} impact par. plot, No Cuts, FromB, ";
1642   for(Int_t i=0;i<fnbins;i++){
1643     strnamept=namehist;
1644     strnamept.Append("PkMss_pt");
1645     strnamept+=i;
1646
1647     strtitlept=titlehist;
1648     strtitlept.Append(" Mass Peak, ");
1649     strtitlept+=fptbins[i];
1650     strtitlept.Append("<= pt <");
1651     strtitlept+=fptbins[i+1];
1652     strtitlept.Append(" [GeV/c]");
1653     
1654     hd0D0ptNCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1655     hd0D0ptNCfromBPM->SetXTitle("Impact parameter [#mum] ");
1656     hd0D0ptNCfromBPM->SetYTitle("Entries");
1657     flistNoCutsFromB->Add(hd0D0ptNCfromBPM);
1658
1659     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1660     hMCd0D0ptNCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1661     hMCd0D0ptNCfromBPM->SetXTitle("MC Impact parameter [#mum] ");
1662     hMCd0D0ptNCfromBPM->SetYTitle("Entries");
1663     flistNoCutsFromB->Add(hMCd0D0ptNCfromBPM);
1664  
1665
1666     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1667     hd0D0VtxTrueptNCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1668     hd0D0VtxTrueptNCfromBPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1669     hd0D0VtxTrueptNCfromBPM->SetYTitle("Entries");
1670     flistNoCutsFromB->Add(hd0D0VtxTrueptNCfromBPM);
1671     
1672     strnamept=namehist;
1673     strnamept.Append("SBMss_pt");
1674     strnamept+=i;
1675
1676     strtitlept=titlehist;
1677     strtitlept.Append(" Side Bands, ");
1678     strtitlept+=fptbins[i];
1679     strtitlept.Append("<= pt <");
1680     strtitlept+=fptbins[i+1];
1681     strtitlept.Append(" [GeV/c]");
1682     
1683     hd0D0ptNCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1684     hd0D0ptNCfromBSB->SetXTitle("Impact parameter [#mum] ");
1685     hd0D0ptNCfromBSB->SetYTitle("Entries");
1686     flistNoCutsFromB->Add(hd0D0ptNCfromBSB);
1687
1688     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1689     hMCd0D0ptNCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1690     hMCd0D0ptNCfromBSB->SetXTitle("MC Impact parameter [#mum] ");
1691     hMCd0D0ptNCfromBSB->SetYTitle("Entries");
1692     flistNoCutsFromB->Add(hMCd0D0ptNCfromBSB);
1693
1694     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1695     hd0D0VtxTrueptNCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1696     hd0D0VtxTrueptNCfromBSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1697     hd0D0VtxTrueptNCfromBSB->SetYTitle("Entries");
1698     flistNoCutsFromB->Add(hd0D0VtxTrueptNCfromBSB);
1699   }
1700
1701
1702
1703   //############ NO CUTS FROM DSTAR HISTOGRAMS ###########
1704   //
1705   //#############  global properties histos #######
1706
1707   TH2F *hCPtaVSd0d0NCfromDstar=new TH2F("hCPtaVSd0d0NCfromDstar","hCPtaVSd0d0_NoCuts_FromDStar",1000,-100000.,100000.,100,-1.,1.);
1708   TH1F *hSecVtxZNCfromDstar=new TH1F("hSecVtxZNCfromDstar","hSecVtxZ_NoCuts_FromDStar",1000,-8.,8.);
1709   TH1F *hSecVtxXNCfromDstar=new TH1F("hSecVtxXNCfromDstar","hSecVtxX_NoCuts_FromDStar",1000,-3000.,3000.);
1710   TH1F *hSecVtxYNCfromDstar=new TH1F("hSecVtxYNCfromDstar","hSecVtxY_NoCuts_FromDStar",1000,-3000.,3000.);
1711   TH2F *hSecVtxXYNCfromDstar=new TH2F("hSecVtxXYNCfromDstar","hSecVtxXY_NoCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
1712   TH1F *hSecVtxPhiNCfromDstar=new TH1F("hSecVtxPhiNCfromDstar","hSecVtxPhi_NoCuts_FromDStar",180,-180.1,180.1);
1713   TH1F *hd0singlTrackNCfromDstar=new TH1F("hd0singlTrackNCfromDstar","hd0singlTrackNoCuts_fromDstar",1000,-5000.,5000.);
1714   TH1F *hCPtaNCfromDstar=new TH1F("hCPtaNCfromDstar","hCPta_NoCuts_FromDStar",100,-1.,1.);
1715   TH1F *hd0xd0NCfromDstar=new TH1F("hd0xd0NCfromDstar","hd0xd0_NoCuts_FromDStar",1000,-100000.,100000.);
1716   TH1F *hMassTrueNCfromDstar=new TH1F("hMassTrueNCfromDstar","D^{0} MC inv. Mass No Cuts FromDStar(All momenta)",600,1.600,2.200);
1717   TH1F *hMassNCfromDstar=new TH1F("hMassNCfromDstar","D^{0} inv. Mass No Cuts FromDStar (All momenta)",600,1.600,2.200);
1718   hMassNCfromDstar->Sumw2();
1719   TH1F *hMassTrueNCfromDstarPM=new TH1F("hMassTrueNCfromDstarPM","D^{0} MC inv. Mass No Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
1720   TH1F *hMassNCfromDstarPM=new TH1F("hMassNCfromDstarPM","D^{0} inv. Mass No Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
1721   hMassNCfromDstarPM->Sumw2();
1722   TH1F *hMassTrueNCfromDstarSB=new TH1F("hMassTrueNCfromDstarSB","D^{0} MC inv. Mass in Side Bands No Cuts FromDStar(All momenta)",600,1.600,2.200);
1723   TH1F *hMassNCfromDstarSB=new TH1F("hMassNCfromDstarSB","D^{0} inv. Mass in Side Bands No Cuts FromDStar (All momenta)",600,1.600,2.200);
1724   hMassNCfromDstarSB->Sumw2();
1725
1726   flistNoCutsFromDstar->Add(hCPtaVSd0d0NCfromDstar);
1727   flistNoCutsFromDstar->Add(hSecVtxZNCfromDstar);
1728   flistNoCutsFromDstar->Add(hSecVtxYNCfromDstar);
1729   flistNoCutsFromDstar->Add(hSecVtxXNCfromDstar);
1730   flistNoCutsFromDstar->Add(hSecVtxXYNCfromDstar);
1731   flistNoCutsFromDstar->Add(hSecVtxPhiNCfromDstar);
1732   flistNoCutsFromDstar->Add(hd0singlTrackNCfromDstar);
1733   flistNoCutsFromDstar->Add(hCPtaNCfromDstar);
1734   flistNoCutsFromDstar->Add(hd0xd0NCfromDstar);
1735   flistNoCutsFromDstar->Add(hMassTrueNCfromDstar);
1736   flistNoCutsFromDstar->Add(hMassNCfromDstar);
1737   flistNoCutsFromDstar->Add(hMassTrueNCfromDstarPM);
1738   flistNoCutsFromDstar->Add(hMassNCfromDstarPM);
1739   flistNoCutsFromDstar->Add(hMassTrueNCfromDstarSB);
1740   flistNoCutsFromDstar->Add(hMassNCfromDstarSB);
1741
1742
1743
1744
1745 //%%% NEW HISTOS %%%%%%%%%%%%%%%%
1746   TH1F *hdcaNCfromDstar=new TH1F("hdcaNCfromDstar","hdca_NoCuts_FromDstar",100,0.,1000.);
1747   hdcaNCfromDstar->SetXTitle("dca   [#mum]");
1748   hdcaNCfromDstar->SetYTitle("Entries");
1749   TH1F *hcosthetastarNCfromDstar=new TH1F("hcosthetastarNCfromDstar","hCosThetaStar_NoCuts_FromDstar",50,-1.,1.);
1750   hcosthetastarNCfromDstar->SetXTitle("cos #theta^{*}");
1751   hcosthetastarNCfromDstar->SetYTitle("Entries");
1752   TH1F *hptD0NCfromDstar=new TH1F("hptD0NCfromDstar","D^{0} transverse momentum distribution",34,ptbinsD0arr);
1753   hptD0NCfromDstar->SetXTitle("p_{t}  [GeV/c]");
1754   hptD0NCfromDstar->SetYTitle("Entries");
1755   TH1F *hptD0VsMaxPtNCfromDstar=new TH1F("hptD0VsMaxPtNCfromDstar","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
1756   TH2F *hptD0PTallsqrtNCfromDstar=new TH2F("hptD0PTallsqrtNCfromDstar","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
1757   TH2F *hptD0PTallNCfromDstar=new TH2F("hptD0PTallNCfromDstar","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
1758   TH2F *hptD0vsptBNCfromDstar=new TH2F("hptD0vsptBNCfromDstar","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1759   TH2F *hpD0vspBNCfromDstar=new TH2F("hpD0vspBNCfromDstar","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1760   TH2F *hptD0vsptcquarkNCfromDstar=new TH2F("hptD0vsptcquarkNCfromDstar","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1761   TH2F *hpD0vspcquarkNCfromDstar=new TH2F("hpD0vspcquarkNCfromDstar","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
1762   flistNoCutsFromDstar->Add(hdcaNCfromDstar);
1763   flistNoCutsFromDstar->Add(hcosthetastarNCfromDstar);
1764   flistNoCutsFromDstar->Add(hptD0NCfromDstar);
1765   flistNoCutsFromDstar->Add(hptD0VsMaxPtNCfromDstar);
1766   flistNoCutsFromDstar->Add(hptD0PTallsqrtNCfromDstar);
1767   flistNoCutsFromDstar->Add(hptD0PTallNCfromDstar);
1768   flistNoCutsFromDstar->Add(hptD0vsptBNCfromDstar);
1769   flistNoCutsFromDstar->Add(hpD0vspBNCfromDstar);
1770   flistNoCutsFromDstar->Add(hptD0vsptcquarkNCfromDstar);
1771   flistNoCutsFromDstar->Add(hpD0vspcquarkNCfromDstar);
1772  
1773   TH1F *hd0zD0ptNCfromDstar;
1774   TH1F *hInvMassD0NCfromDstar,*hInvMassD0barNCfromDstar;
1775   TH2F *hInvMassPtNCfromDstar=new TH2F("hInvMassPtNCfromDstar","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
1776   TH3F *hInvMassPtSelSignOnlyNCfromDstar=new TH3F("hInvMassPtSelSignOnlyNCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
1777   flistNoCutsFromDstar->Add(hInvMassPtSelSignOnlyNCfromDstar);
1778   TH3F *hInvMassPtSelReflOnlyNCfromDstar=new TH3F("hInvMassPtSelReflOnlyNCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
1779   flistNoCutsFromDstar->Add(hInvMassPtSelReflOnlyNCfromDstar);
1780
1781   THnSparseF *hSparseNCfromDstar=new THnSparseF("hSparseNCfromDstar","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
1782   hSparseNCfromDstar->SetBinEdges(0,massbins);
1783   hSparseNCfromDstar->SetBinEdges(1,massbins);
1784   hSparseNCfromDstar->SetBinEdges(2,ptbinsForNsparse);
1785   hSparseNCfromDstar->SetBinEdges(3,impparbins);
1786   hSparseNCfromDstar->SetBinEdges(4,massHypoBins); 
1787   flistNoCutsFromDstar->Add(hSparseNCfromDstar);
1788   TH1F *hetaNCfromDstar;
1789   TH1F *hCosPDPBNCfromDstar;
1790   TH1F *hCosPcPDNCfromDstar;
1791   flistNoCutsFromDstar->Add(hInvMassPtNCfromDstar);
1792   // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1793   TH2F *hd0D0VSd0xd0NCfromDstarpt;
1794   TH2F *hangletracksVSd0xd0NCfromDstarpt;
1795   TH2F *hangletracksVSd0D0NCfromDstarpt;
1796   TH1F *hd0xd0NCfromDstarpt;
1797
1798   TH2F *hTOFpidNCfromDstar=new TH2F("hTOFpidNCfromDstar","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
1799   flistNoCutsFromDstar->Add(hTOFpidNCfromDstar);
1800
1801   for(Int_t i=0;i<fnbins;i++){
1802     namehist="hd0zD0ptNCfromDstar_pt";
1803     namehist+=i;
1804     titlehist="d0(z) No Cuts FromDstarm ptbin=";
1805     titlehist+=i;
1806     hd0zD0ptNCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
1807     hd0zD0ptNCfromDstar->SetXTitle("d_{0}(z)    [#mum]");
1808     hd0zD0ptNCfromDstar->SetYTitle("Entries");
1809     flistNoCutsFromDstar->Add(hd0zD0ptNCfromDstar);
1810
1811     namehist="hInvMassD0NCfromDstar_pt";
1812     namehist+=i;
1813     titlehist="Invariant Mass No Cuts FromDstar ptbin=";
1814     titlehist+=i;
1815     hInvMassD0NCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1816     hInvMassD0NCfromDstar->SetXTitle("Invariant Mass    [GeV]");
1817     hInvMassD0NCfromDstar->SetYTitle("Entries");
1818     flistNoCutsFromDstar->Add(hInvMassD0NCfromDstar);
1819
1820
1821    namehist="hInvMassD0barNCfromDstar_pt";
1822     namehist+=i;
1823     titlehist="Invariant Mass D0bar No Cuts FromDstar ptbin=";
1824     titlehist+=i;
1825     hInvMassD0barNCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
1826     hInvMassD0barNCfromDstar->SetXTitle("Invariant Mass    [GeV]");
1827     hInvMassD0barNCfromDstar->SetYTitle("Entries");
1828     flistNoCutsFromDstar->Add(hInvMassD0barNCfromDstar);
1829
1830
1831
1832     namehist="hetaNCfromDstar_pt";
1833     namehist+=i;
1834     titlehist="eta No Cuts FromDstar ptbin=";
1835     titlehist+=i;
1836     hetaNCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
1837     hetaNCfromDstar->SetXTitle("Pseudorapidity");
1838     hetaNCfromDstar->SetYTitle("Entries");
1839     flistNoCutsFromDstar->Add(hetaNCfromDstar);
1840
1841     namehist="hCosPDPBNCfromDstar_pt";
1842     namehist+=i;
1843     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
1844     titlehist+=i;
1845     hCosPDPBNCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1846     hCosPDPBNCfromDstar->SetXTitle("Cosine between D0 momentum and B momentum");
1847     hCosPDPBNCfromDstar->SetYTitle("Entries");
1848     flistNoCutsFromDstar->Add(hCosPDPBNCfromDstar);
1849
1850     namehist="hCosPcPDNCfromDstar_pt";
1851     namehist+=i;
1852     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
1853     titlehist+=i;
1854     hCosPcPDNCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
1855     hCosPcPDNCfromDstar->SetXTitle("Cosine between c quark momentum and D0 momentum");
1856     hCosPcPDNCfromDstar->SetYTitle("Entries");
1857     flistNoCutsFromDstar->Add(hCosPcPDNCfromDstar);
1858   
1859  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
1860     namehist="hd0xd0NCfromDstar_pt";
1861     namehist+=i;
1862     titlehist="d0xd0 No Cuts FromDstar ptbin=";
1863     titlehist+=i;
1864     hd0xd0NCfromDstarpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
1865     hd0xd0NCfromDstarpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
1866     hd0xd0NCfromDstarpt->SetYTitle("Entries");
1867     flistNoCutsFromDstar->Add(hd0xd0NCfromDstarpt);
1868
1869
1870     namehist="hd0D0VSd0xd0NCfromDstar_pt";
1871     namehist+=i;
1872     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} No Cuts FromDstar ptbin=";
1873     titlehist+=i;
1874     hd0D0VSd0xd0NCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
1875     hd0D0VSd0xd0NCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1876     hd0D0VSd0xd0NCfromDstarpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
1877     flistNoCutsFromDstar->Add(hd0D0VSd0xd0NCfromDstarpt);
1878     
1879     
1880     namehist="hangletracksVSd0xd0NCfromDstar_pt";
1881     namehist+=i;
1882     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} No Cuts FromDstar ptbin=";
1883     titlehist+=i;
1884     hangletracksVSd0xd0NCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
1885     hangletracksVSd0xd0NCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
1886     hangletracksVSd0xd0NCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
1887     flistNoCutsFromDstar->Add(hangletracksVSd0xd0NCfromDstarpt);
1888     
1889
1890     namehist="hangletracksVSd0D0NCfromDstar_pt";
1891     namehist+=i;
1892     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} No Cuts FromDstar ptbin=";
1893     titlehist+=i;
1894     hangletracksVSd0D0NCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
1895     hangletracksVSd0D0NCfromDstarpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
1896     hangletracksVSd0D0NCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
1897     flistNoCutsFromDstar->Add(hangletracksVSd0D0NCfromDstarpt);
1898   
1899   }
1900   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
1901   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1902
1903
1904   //########## d0 D0 histos #############  
1905   TH1F *hd0D0NCfromDstPM = new TH1F("hd0D0NCfromDstarPM","D^{0} impact par. plot , No Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1906   hd0D0NCfromDstPM->SetXTitle("Impact parameter [#mum]");
1907   hd0D0NCfromDstPM->SetYTitle("Entries");
1908
1909   TH1F *hd0D0VtxTrueNCfromDstPM = new TH1F("hd0D0VtxTrueNCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1910   hd0D0VtxTrueNCfromDstPM->SetXTitle("Impact parameter [#mum]");
1911   hd0D0VtxTrueNCfromDstPM->SetYTitle("Entries");
1912
1913   TH1F *hMCd0D0NCfromDstPM = new TH1F("hMCd0D0NCfromDstarPM","D^{0} impact par. plot, No Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
1914   hMCd0D0NCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
1915   hMCd0D0NCfromDstPM->SetYTitle("Entries");
1916
1917   TH1F *hd0D0NCfromDstSB = new TH1F("hd0D0NCfromDstarSB","D^{0} impact par. plot , No Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1918   hd0D0NCfromDstSB->SetXTitle("Impact parameter [#mum]");
1919   hd0D0NCfromDstSB->SetYTitle("Entries");
1920
1921   TH1F *hd0D0VtxTrueNCfromDstSB = new TH1F("hd0D0VtxTrueNCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
1922   hd0D0VtxTrueNCfromDstSB->SetXTitle("Impact parameter [#mum]");
1923   hd0D0VtxTrueNCfromDstSB->SetYTitle("Entries");
1924
1925   TH1F *hMCd0D0NCfromDstSB = new TH1F("hMCd0D0NCfromDstarSB","D^{0} impact par. plot, No Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
1926   hMCd0D0NCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
1927   hMCd0D0NCfromDstSB->SetYTitle("Entries");
1928
1929   flistNoCutsFromDstar->Add(hd0D0NCfromDstPM);
1930   flistNoCutsFromDstar->Add(hd0D0VtxTrueNCfromDstPM);
1931   flistNoCutsFromDstar->Add(hMCd0D0NCfromDstPM);
1932   flistNoCutsFromDstar->Add(hd0D0NCfromDstSB);
1933   flistNoCutsFromDstar->Add(hd0D0VtxTrueNCfromDstSB);
1934   flistNoCutsFromDstar->Add(hMCd0D0NCfromDstSB);
1935   
1936   TH1F *hd0D0ptNCfromDstPM;
1937   TH1F *hMCd0D0ptNCfromDstPM;
1938   TH1F *hd0D0VtxTrueptNCfromDstPM;
1939   TH1F *hd0D0ptNCfromDstSB;
1940   TH1F *hMCd0D0ptNCfromDstSB;
1941   TH1F *hd0D0VtxTrueptNCfromDstSB;
1942   namehist="hd0D0ptNCfromDstar_";
1943   titlehist="D^{0} impact par. plot, No Cuts, FromDStar, ";
1944   for(Int_t i=0;i<fnbins;i++){
1945     strnamept=namehist;
1946     strnamept.Append("PkMss_pt");
1947     strnamept+=i;
1948
1949     strtitlept=titlehist;
1950     strtitlept.Append(" Mass Peak, ");
1951     strtitlept+=fptbins[i];
1952     strtitlept.Append("<= pt <");
1953     strtitlept+=fptbins[i+1];
1954     strtitlept.Append(" [GeV/c]");
1955     
1956     hd0D0ptNCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1957     hd0D0ptNCfromDstPM->SetXTitle("Impact parameter [#mum] ");
1958     hd0D0ptNCfromDstPM->SetYTitle("Entries");
1959     flistNoCutsFromDstar->Add(hd0D0ptNCfromDstPM);
1960
1961     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1962     hMCd0D0ptNCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1963     hMCd0D0ptNCfromDstPM->SetXTitle("MC Impact parameter [#mum] ");
1964     hMCd0D0ptNCfromDstPM->SetYTitle("Entries");
1965     flistNoCutsFromDstar->Add(hMCd0D0ptNCfromDstPM);
1966  
1967
1968     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1969     hd0D0VtxTrueptNCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1970     hd0D0VtxTrueptNCfromDstPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1971     hd0D0VtxTrueptNCfromDstPM->SetYTitle("Entries");
1972     flistNoCutsFromDstar->Add(hd0D0VtxTrueptNCfromDstPM);
1973     
1974     strnamept=namehist;
1975     strnamept.Append("SBMss_pt");
1976     strnamept+=i;
1977
1978     strtitlept=titlehist;
1979     strtitlept.Append(" Side Bands, ");
1980     strtitlept+=fptbins[i];
1981     strtitlept.Append("<= pt <");
1982     strtitlept+=fptbins[i+1];
1983     strtitlept.Append(" [GeV/c]");
1984     
1985     hd0D0ptNCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1986     hd0D0ptNCfromDstSB->SetXTitle("Impact parameter [#mum] ");
1987     hd0D0ptNCfromDstSB->SetYTitle("Entries");
1988     flistNoCutsFromDstar->Add(hd0D0ptNCfromDstSB);
1989
1990     strnamept.ReplaceAll("hd0D0","hMCd0D0");
1991     hMCd0D0ptNCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1992     hMCd0D0ptNCfromDstSB->SetXTitle("MC Impact parameter [#mum] ");
1993     hMCd0D0ptNCfromDstSB->SetYTitle("Entries");
1994     flistNoCutsFromDstar->Add(hMCd0D0ptNCfromDstSB);
1995
1996     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
1997     hd0D0VtxTrueptNCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
1998     hd0D0VtxTrueptNCfromDstSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
1999     hd0D0VtxTrueptNCfromDstSB->SetYTitle("Entries");
2000     flistNoCutsFromDstar->Add(hd0D0VtxTrueptNCfromDstSB);
2001   }
2002
2003
2004   //############ NO CUTS OTHER HISTOGRAMS ###########
2005   //
2006   //########### global properties histos ###########
2007
2008   TH2F *hCPtaVSd0d0NCother=new TH2F("hCPtaVSd0d0NCother","hCPtaVSd0d0_NoCuts_other",1000,-100000.,100000.,100,-1.,1.);
2009   TH1F *hSecVtxZNCother=new TH1F("hSecVtxZNCother","hSecVtxZ_NoCuts_other",1000,-8.,8.);
2010   TH1F *hSecVtxXNCother=new TH1F("hSecVtxXNCother","hSecVtxX_NoCuts_other",1000,-3000.,3000.);
2011   TH1F *hSecVtxYNCother=new TH1F("hSecVtxYNCother","hSecVtxY_NoCuts_other",1000,-3000.,3000.);
2012   TH2F *hSecVtxXYNCother=new TH2F("hSecVtxXYNCother","hSecVtxXY_NoCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
2013   TH1F *hSecVtxPhiNCother=new TH1F("hSecVtxPhiNCother","hSecVtxPhi_NoCuts_other",180,-180.1,180.1);
2014   TH1F *hd0singlTrackNCother=new TH1F("hd0singlTrackNCother","hd0singlTrackNoCuts_Other",1000,-5000.,5000.);
2015   TH1F *hCPtaNCother=new TH1F("hCPtaNCother","hCPta_NoCuts_other",100,-1.,1.);
2016   TH1F *hd0xd0NCother=new TH1F("hd0xd0NCother","hd0xd0_NoCuts_other",1000,-100000.,100000.);
2017   TH1F *hMassTrueNCother=new TH1F("hMassTrueNCother","D^{0} MC inv. Mass No Cuts other(All momenta)",600,1.600,2.200);
2018   TH1F *hMassNCother=new TH1F("hMassNCother","D^{0} inv. Mass No Cuts other (All momenta)",600,1.600,2.200);
2019   hMassNCother->Sumw2();
2020   TH1F *hMassTrueNCotherPM=new TH1F("hMassTrueNCotherPM","D^{0} MC inv. Mass No Cuts Other, Mass Peak. (All momenta)",600,1.600,2.200);
2021   TH1F *hMassNCotherPM=new TH1F("hMassNCotherPM","D^{0} inv. Mass No Cuts Other (All momenta), MassPeak",600,1.600,2.200);
2022   hMassNCotherPM->Sumw2();
2023   TH1F *hMassTrueNCotherSB=new TH1F("hMassTrueNCotherSB","D^{0} MC inv. Mass in Side Bands No Cuts other(All momenta)",600,1.600,2.200);
2024   TH1F *hMassNCotherSB=new TH1F("hMassNCotherSB","D^{0} inv. Mass in Side Bands No Cuts other (All momenta)",600,1.600,2.200);
2025   hMassNCotherSB->Sumw2();
2026
2027   flistNoCutsOther->Add(hCPtaVSd0d0NCother);
2028   flistNoCutsOther->Add(hSecVtxZNCother);
2029   flistNoCutsOther->Add(hSecVtxYNCother);
2030   flistNoCutsOther->Add(hSecVtxXNCother);
2031   flistNoCutsOther->Add(hSecVtxXYNCother);
2032   flistNoCutsOther->Add(hSecVtxPhiNCother);
2033   flistNoCutsOther->Add(hd0singlTrackNCother);
2034   flistNoCutsOther->Add(hCPtaNCother);
2035   flistNoCutsOther->Add(hd0xd0NCother);
2036   flistNoCutsOther->Add(hMassTrueNCother);
2037   flistNoCutsOther->Add(hMassNCother);
2038   flistNoCutsOther->Add(hMassTrueNCotherPM);
2039   flistNoCutsOther->Add(hMassNCotherPM);
2040   flistNoCutsOther->Add(hMassTrueNCotherSB);
2041   flistNoCutsOther->Add(hMassNCotherSB);
2042
2043
2044
2045  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
2046   TH1F *hdcaNCother=new TH1F("hdcaNCother","hdca_NoCuts_Other",100,0.,1000.);
2047   hdcaNCother->SetXTitle("dca   [#mum]");
2048   hdcaNCother->SetYTitle("Entries");
2049   TH1F *hcosthetastarNCother=new TH1F("hcosthetastarNCother","hCosThetaStar_NoCuts_Other",50,-1.,1.);
2050   hcosthetastarNCother->SetXTitle("cos #theta^{*}");
2051   hcosthetastarNCother->SetYTitle("Entries");
2052   TH1F *hptD0NCother=new TH1F("hptD0NCother","D^{0} transverse momentum distribution",34,ptbinsD0arr);
2053   hptD0NCother->SetXTitle("p_{t}  [GeV/c]");
2054   hptD0NCother->SetYTitle("Entries");
2055   TH1F *hptD0VsMaxPtNCother=new TH1F("hptD0VsMaxPtNCother","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
2056   TH2F *hptD0PTallsqrtNCother=new TH2F("hptD0PTallsqrtNCother","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
2057   TH2F *hptD0PTallNCother=new TH2F("hptD0PTallNCother","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
2058   TH2F *hptD0vsptBNCother=new TH2F("hptD0vsptBNCother","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2059   TH2F *hpD0vspBNCother=new TH2F("hpD0vspBNCother","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2060   TH2F *hptD0vsptcquarkNCother=new TH2F("hptD0vsptcquarkNCother","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2061   TH2F *hpD0vspcquarkNCother=new TH2F("hpD0vspcquarkNCother","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2062   flistNoCutsOther->Add(hdcaNCother);
2063   flistNoCutsOther->Add(hcosthetastarNCother);
2064   flistNoCutsOther->Add(hptD0NCother);
2065   flistNoCutsOther->Add(hptD0VsMaxPtNCother);
2066   flistNoCutsOther->Add(hptD0PTallsqrtNCother);
2067   flistNoCutsOther->Add(hptD0PTallNCother);
2068   flistNoCutsOther->Add(hptD0vsptBNCother);
2069   flistNoCutsOther->Add(hpD0vspBNCother);
2070   flistNoCutsOther->Add(hptD0vsptcquarkNCother);
2071   flistNoCutsOther->Add(hpD0vspcquarkNCother);
2072
2073   TH1F *hd0zD0ptNCother;
2074   TH1F *hInvMassD0NCother,*hInvMassD0barNCother;
2075   TH2F *hInvMassPtNCother=new TH2F("hInvMassPtNCother","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
2076   THnSparseF *hSparseNCother=new THnSparseF("hSparseNCother","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
2077   hSparseNCother->SetBinEdges(0,massbins);
2078   hSparseNCother->SetBinEdges(1,massbins);
2079   hSparseNCother->SetBinEdges(2,ptbinsForNsparse);
2080   hSparseNCother->SetBinEdges(3,impparbins);
2081   hSparseNCother->SetBinEdges(4,massHypoBins); 
2082   flistNoCutsOther->Add(hSparseNCother);
2083   TH1F *hetaNCother;
2084   TH1F *hCosPDPBNCother;
2085   TH1F *hCosPcPDNCother;
2086   flistNoCutsOther->Add(hInvMassPtNCother);
2087   // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2088   TH2F *hd0D0VSd0xd0NCotherpt;
2089   TH2F *hangletracksVSd0xd0NCotherpt;
2090   TH2F *hangletracksVSd0D0NCotherpt;
2091   TH1F *hd0xd0NCotherpt;
2092
2093   TH2F *hTOFpidNCother=new TH2F("hTOFpidNCother","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
2094   flistNoCutsOther->Add(hTOFpidNCother);
2095
2096   for(Int_t i=0;i<fnbins;i++){
2097     namehist="hd0zD0ptNCother_pt";
2098     namehist+=i;
2099     titlehist="d0(z) No Cuts Otherm ptbin=";
2100     titlehist+=i;
2101     hd0zD0ptNCother=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
2102     hd0zD0ptNCother->SetXTitle("d_{0}(z)    [#mum]");
2103     hd0zD0ptNCother->SetYTitle("Entries");
2104     flistNoCutsOther->Add(hd0zD0ptNCother);
2105
2106     namehist="hInvMassD0NCother_pt";
2107     namehist+=i;
2108     titlehist="Invariant Mass No Cuts Other ptbin=";
2109     titlehist+=i;
2110     hInvMassD0NCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2111     hInvMassD0NCother->SetXTitle("Invariant Mass    [GeV]");
2112     hInvMassD0NCother->SetYTitle("Entries");
2113     flistNoCutsOther->Add(hInvMassD0NCother);
2114
2115
2116    namehist="hInvMassD0barNCother_pt";
2117     namehist+=i;
2118     titlehist="Invariant Mass D0bar No Cuts Other ptbin=";
2119     titlehist+=i;
2120     hInvMassD0barNCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2121     hInvMassD0barNCother->SetXTitle("Invariant Mass    [GeV]");
2122     hInvMassD0barNCother->SetYTitle("Entries");
2123     flistNoCutsOther->Add(hInvMassD0barNCother);
2124
2125
2126     namehist="hetaNCother_pt";
2127     namehist+=i;
2128     titlehist="eta No Cuts Other ptbin=";
2129     titlehist+=i;
2130     hetaNCother=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
2131     hetaNCother->SetXTitle("Pseudorapidity");
2132     hetaNCother->SetYTitle("Entries");
2133     flistNoCutsOther->Add(hetaNCother);
2134
2135     namehist="hCosPDPBNCother_pt";
2136     namehist+=i;
2137     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
2138     titlehist+=i;
2139     hCosPDPBNCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2140     hCosPDPBNCother->SetXTitle("Cosine between D0 momentum and B momentum");
2141     hCosPDPBNCother->SetYTitle("Entries");
2142     flistNoCutsOther->Add(hCosPDPBNCother);
2143
2144     namehist="hCosPcPDNCother_pt";
2145     namehist+=i;
2146     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
2147     titlehist+=i;
2148     hCosPcPDNCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2149     hCosPcPDNCother->SetXTitle("Cosine between c quark momentum and D0 momentum");
2150     hCosPcPDNCother->SetYTitle("Entries");
2151     flistNoCutsOther->Add(hCosPcPDNCother);
2152     
2153
2154  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2155     namehist="hd0xd0NCother_pt";
2156     namehist+=i;
2157     titlehist="d0xd0 No Cuts Other ptbin=";
2158     titlehist+=i;
2159     hd0xd0NCotherpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
2160     hd0xd0NCotherpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
2161     hd0xd0NCotherpt->SetYTitle("Entries");
2162     flistNoCutsOther->Add(hd0xd0NCotherpt);
2163
2164
2165     namehist="hd0D0VSd0xd0NCother_pt";
2166     namehist+=i;
2167     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Other ptbin=";
2168     titlehist+=i;
2169     hd0D0VSd0xd0NCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
2170     hd0D0VSd0xd0NCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2171     hd0D0VSd0xd0NCotherpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
2172     flistNoCutsOther->Add(hd0D0VSd0xd0NCotherpt);
2173     
2174     
2175     namehist="hangletracksVSd0xd0NCother_pt";
2176     namehist+=i;
2177     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} No Cuts Other ptbin=";
2178     titlehist+=i;
2179     hangletracksVSd0xd0NCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
2180     hangletracksVSd0xd0NCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2181     hangletracksVSd0xd0NCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
2182     flistNoCutsOther->Add(hangletracksVSd0xd0NCotherpt);
2183     
2184
2185     namehist="hangletracksVSd0D0NCother_pt";
2186     namehist+=i;
2187     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} No Cuts Other ptbin=";
2188     titlehist+=i;
2189     hangletracksVSd0D0NCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
2190     hangletracksVSd0D0NCotherpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
2191     hangletracksVSd0D0NCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
2192     flistNoCutsOther->Add(hangletracksVSd0D0NCotherpt);
2193
2194   }
2195   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
2196   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2197
2198
2199
2200
2201   //############# d0 D0 histos ###############à
2202   TH1F *hd0D0NCotherPM = new TH1F("hd0D0NCotherPM","D^{0} impact par. plot , No Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2203   hd0D0NCotherPM->SetXTitle("Impact parameter [#mum]");
2204   hd0D0NCotherPM->SetYTitle("Entries");
2205
2206   TH1F *hd0D0VtxTrueNCotherPM = new TH1F("hd0D0VtxTrueNCotherPM","D^{0} impact par. w.r.t. True Vtx, No Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2207   hd0D0VtxTrueNCotherPM->SetXTitle("Impact parameter [#mum]");
2208   hd0D0VtxTrueNCotherPM->SetYTitle("Entries");
2209
2210   TH1F *hMCd0D0NCotherPM = new TH1F("hMCd0D0NCotherPM","D^{0} impact par. plot, No Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
2211   hMCd0D0NCotherPM->SetXTitle("MC Impact parameter [#mum]");
2212   hMCd0D0NCotherPM->SetYTitle("Entries");
2213
2214   TH1F *hd0D0NCotherSB = new TH1F("hd0D0NCotherSB","D^{0} impact par. plot , No Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2215   hd0D0NCotherSB->SetXTitle("Impact parameter [#mum]");
2216   hd0D0NCotherSB->SetYTitle("Entries");
2217
2218   TH1F *hd0D0VtxTrueNCotherSB = new TH1F("hd0D0VtxTrueNCotherSB","D^{0} impact par. w.r.t. True Vtx, No Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
2219   hd0D0VtxTrueNCotherSB->SetXTitle("Impact parameter [#mum]");
2220   hd0D0VtxTrueNCotherSB->SetYTitle("Entries");
2221
2222   TH1F *hMCd0D0NCotherSB = new TH1F("hMCd0D0NCotherSB","D^{0} impact par. plot, No Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
2223   hMCd0D0NCotherSB->SetXTitle("MC Impact parameter [#mum]");
2224   hMCd0D0NCotherSB->SetYTitle("Entries");
2225
2226   flistNoCutsOther->Add(hd0D0NCotherPM);
2227   flistNoCutsOther->Add(hd0D0VtxTrueNCotherPM);
2228   flistNoCutsOther->Add(hMCd0D0NCotherPM);
2229   flistNoCutsOther->Add(hd0D0NCotherSB);
2230   flistNoCutsOther->Add(hd0D0VtxTrueNCotherSB);
2231   flistNoCutsOther->Add(hMCd0D0NCotherSB);
2232   
2233   TH1F *hd0D0ptNCotherPM;
2234   TH1F *hMCd0D0ptNCotherPM;
2235   TH1F *hd0D0VtxTrueptNCotherPM;
2236   TH1F *hd0D0ptNCotherSB;
2237   TH1F *hMCd0D0ptNCotherSB;
2238   TH1F *hd0D0VtxTrueptNCotherSB;
2239   namehist="hd0D0ptNCother_";
2240   titlehist="D^{0} impact par. plot, No Cuts, Other, ";
2241   for(Int_t i=0;i<fnbins;i++){
2242     strnamept=namehist;
2243     strnamept.Append("PkMss_pt");
2244     strnamept+=i;
2245
2246     strtitlept=titlehist;
2247     strtitlept.Append(" Mass Peak, ");
2248     strtitlept+=fptbins[i];
2249     strtitlept.Append("<= pt <");
2250     strtitlept+=fptbins[i+1];
2251     strtitlept.Append(" [GeV/c]");
2252     
2253     hd0D0ptNCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2254     hd0D0ptNCotherPM->SetXTitle("Impact parameter [#mum] ");
2255     hd0D0ptNCotherPM->SetYTitle("Entries");
2256     flistNoCutsOther->Add(hd0D0ptNCotherPM);
2257
2258     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2259     hMCd0D0ptNCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2260     hMCd0D0ptNCotherPM->SetXTitle("MC Impact parameter [#mum] ");
2261     hMCd0D0ptNCotherPM->SetYTitle("Entries");
2262     flistNoCutsOther->Add(hMCd0D0ptNCotherPM);
2263  
2264
2265     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2266     hd0D0VtxTrueptNCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2267     hd0D0VtxTrueptNCotherPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2268     hd0D0VtxTrueptNCotherPM->SetYTitle("Entries");
2269     flistNoCutsOther->Add(hd0D0VtxTrueptNCotherPM);
2270     
2271     strnamept=namehist;
2272     strnamept.Append("SBMss_pt");
2273     strnamept+=i;
2274
2275     strtitlept=titlehist;
2276     strtitlept.Append(" Side Bands, ");
2277     strtitlept+=fptbins[i];
2278     strtitlept.Append("<= pt <");
2279     strtitlept+=fptbins[i+1];
2280     strtitlept.Append(" [GeV/c]");
2281     
2282     hd0D0ptNCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2283     hd0D0ptNCotherSB->SetXTitle("Impact parameter [#mum] ");
2284     hd0D0ptNCotherSB->SetYTitle("Entries");
2285     flistNoCutsOther->Add(hd0D0ptNCotherSB);
2286
2287     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2288     hMCd0D0ptNCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2289     hMCd0D0ptNCotherSB->SetXTitle("MC Impact parameter [#mum] ");
2290     hMCd0D0ptNCotherSB->SetYTitle("Entries");
2291     flistNoCutsOther->Add(hMCd0D0ptNCotherSB);
2292
2293     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2294     hd0D0VtxTrueptNCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2295     hd0D0VtxTrueptNCotherSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2296     hd0D0VtxTrueptNCotherSB->SetYTitle("Entries");
2297     flistNoCutsOther->Add(hd0D0VtxTrueptNCotherSB);
2298   }
2299
2300
2301   //################################################################################################
2302   //                                                                                               #
2303   //                         HISTOS FOR LOOSE CUTS                                                 #
2304   //                                                                                               #
2305   //################################################################################################
2306
2307   //############ LOOSE CUTS SIGNAL HISTOGRAMS ###############
2308   //
2309   // ####### global properties histo ############
2310
2311   TH2F *hCPtaVSd0d0LSCsign=new TH2F("hCPtaVSd0d0LSCsign","hCPtaVSd0d0_LooseCuts_Signal",1000,-100000.,100000.,100,-1.,1.);
2312   TH1F *hSecVtxZLSCsign=new TH1F("hSecVtxZLSCsign","hSecVtxZ_LooseCuts_Signal",1000,-8.,8.);
2313   TH1F *hSecVtxXLSCsign=new TH1F("hSecVtxXLSCsign","hSecVtxX_LooseCuts_Signal",1000,-3000.,3000.);
2314   TH1F *hSecVtxYLSCsign=new TH1F("hSecVtxYLSCsign","hSecVtxY_LooseCuts_Signal",1000,-3000.,3000.);
2315   TH2F *hSecVtxXYLSCsign=new TH2F("hSecVtxXYLSCsign","hSecVtxXY_LooseCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
2316   TH1F *hSecVtxPhiLSCsign=new TH1F("hSecVtxPhiLSCsign","hSecVtxPhi_LooseCuts_Signal",180,-180.1,180.1);
2317   TH1F *hd0singlTrackLSCsign=new TH1F("hd0singlTrackLSCsign","hd0singlTrackLooseCuts_Signal",1000,-5000.,5000.);
2318   TH1F *hCPtaLSCsign=new TH1F("hCPtaLSCsign","hCPta_LooseCuts_Signal",100,-1.,1.);
2319   TH1F *hd0xd0LSCsign=new TH1F("hd0xd0LSCsign","hd0xd0_LooseCuts_Signal",1000,-100000.,100000.);
2320   TH1F *hMassTrueLSCsign=new TH1F("hMassTrueLSCsign","D^{0} MC inv. Mass Loose Cuts Signal(All momenta)",600,1.600,2.200);
2321   TH1F *hMassLSCsign=new TH1F("hMassLSCsign","D^{0} inv. Mass Loose Cuts Signal (All momenta)",600,1.600,2.200);
2322   hMassLSCsign->Sumw2();
2323   TH1F *hMassTrueLSCsignPM=new TH1F("hMassTrueLSCsignPM","D^{0} MC inv. Mass Loose Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
2324   TH1F *hMassLSCsignPM=new TH1F("hMassLSCsignPM","D^{0} inv. Mass Loose Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
2325   hMassLSCsignPM->Sumw2();
2326   TH1F *hMassTrueLSCsignSB=new TH1F("hMassTrueLSCsignSB","D^{0} MC inv. Mass in Side Bands Loose Cuts Signal(All momenta)",600,1.600,2.200);
2327   TH1F *hMassLSCsignSB=new TH1F("hMassLSCsignSB","D^{0} inv. Mass in Side Bands Loose Cuts Signal (All momenta)",600,1.600,2.200);
2328   hMassLSCsignSB->Sumw2();
2329
2330   flistLsCutsSignal->Add(hCPtaVSd0d0LSCsign);
2331   flistLsCutsSignal->Add(hSecVtxZLSCsign);
2332   flistLsCutsSignal->Add(hSecVtxYLSCsign);
2333   flistLsCutsSignal->Add(hSecVtxXLSCsign);
2334   flistLsCutsSignal->Add(hSecVtxXYLSCsign);
2335   flistLsCutsSignal->Add(hSecVtxPhiLSCsign);
2336   flistLsCutsSignal->Add(hd0singlTrackLSCsign);
2337   flistLsCutsSignal->Add(hCPtaLSCsign);
2338   flistLsCutsSignal->Add(hd0xd0LSCsign);
2339   flistLsCutsSignal->Add(hMassTrueLSCsign);
2340   flistLsCutsSignal->Add(hMassLSCsign);
2341   flistLsCutsSignal->Add(hMassTrueLSCsignPM);
2342   flistLsCutsSignal->Add(hMassLSCsignPM);
2343   flistLsCutsSignal->Add(hMassTrueLSCsignSB);
2344   flistLsCutsSignal->Add(hMassLSCsignSB);
2345
2346
2347   //%%% NEW HISTOS %%%%%%%%%%%%%%%%
2348   TH1F *hdcaLSCsign=new TH1F("hdcaLSCsign","hdca_LooseCuts_Sign",100,0.,1000.);
2349   hdcaLSCsign->SetXTitle("dca   [#mum]");
2350   hdcaLSCsign->SetYTitle("Entries");
2351   TH1F *hcosthetastarLSCsign=new TH1F("hcosthetastarLSCsign","hCosThetaStar_LooseCuts_Sign",50,-1.,1.);
2352   hcosthetastarLSCsign->SetXTitle("cos #theta^{*}");
2353   hcosthetastarLSCsign->SetYTitle("Entries");
2354   TH1F *hptD0LSCsign=new TH1F("hptD0LSCsign","D^{0} transverse momentum distribution",34,ptbinsD0arr);
2355   hptD0LSCsign->SetXTitle("p_{t}  [GeV/c]");
2356   hptD0LSCsign->SetYTitle("Entries");
2357   TH1F *hptD0VsMaxPtLSCsign=new TH1F("hptD0VsMaxPtLSCsign","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
2358   TH2F *hptD0PTallsqrtLSCsign=new TH2F("hptD0PTallsqrtLSCsign","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
2359   TH2F *hptD0PTallLSCsign=new TH2F("hptD0PTallLSCsign","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
2360   TH2F *hptD0vsptBLSCsign=new TH2F("hptD0vsptBLSCsign","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2361   TH2F *hpD0vspBLSCsign=new TH2F("hpD0vspBLSCsign","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2362   TH2F *hptD0vsptcquarkLSCsign=new TH2F("hptD0vsptcquarkLSCsign","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2363   TH2F *hpD0vspcquarkLSCsign=new TH2F("hpD0vspcquarkLSCsign","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2364   flistLsCutsSignal->Add(hdcaLSCsign);
2365   flistLsCutsSignal->Add(hcosthetastarLSCsign);
2366   flistLsCutsSignal->Add(hptD0LSCsign);
2367   flistLsCutsSignal->Add(hptD0VsMaxPtLSCsign);
2368   flistLsCutsSignal->Add(hptD0PTallsqrtLSCsign);
2369   flistLsCutsSignal->Add(hptD0PTallLSCsign);
2370   flistLsCutsSignal->Add(hptD0vsptBLSCsign);
2371   flistLsCutsSignal->Add(hpD0vspBLSCsign);
2372   flistLsCutsSignal->Add(hptD0vsptcquarkLSCsign);
2373   flistLsCutsSignal->Add(hpD0vspcquarkLSCsign);
2374  
2375   TH1F *hd0zD0ptLSCsign;
2376   TH1F *hInvMassD0LSCsign,*hInvMassD0barLSCsign;
2377   TH2F *hInvMassPtLSCsign=new TH2F("hInvMassPtLSCsign","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
2378   TH3F *hInvMassPtSelSignOnlyLSCsign=new TH3F("hInvMassPtSelSignOnlyLSCsign","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
2379   flistLsCutsSignal->Add(hInvMassPtSelSignOnlyLSCsign);
2380   TH3F *hInvMassPtSelReflOnlyLSCsign=new TH3F("hInvMassPtSelReflOnlyLSCsign","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
2381   flistLsCutsSignal->Add(hInvMassPtSelReflOnlyLSCsign);
2382
2383   THnSparseF *hSparseLSCsign=new THnSparseF("hSparseLSCsign","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
2384   hSparseLSCsign->SetBinEdges(0,massbins);
2385   hSparseLSCsign->SetBinEdges(1,massbins);
2386   hSparseLSCsign->SetBinEdges(2,ptbinsForNsparse);
2387   hSparseLSCsign->SetBinEdges(3,impparbins);
2388   hSparseLSCsign->SetBinEdges(4,massHypoBins); 
2389   flistLsCutsSignal->Add(hSparseLSCsign);
2390   TH1F *hetaLSCsign;
2391   TH1F *hCosPDPBLSCsign;
2392   TH1F *hCosPcPDLSCsign;
2393   flistLsCutsSignal->Add(hInvMassPtLSCsign);
2394
2395
2396   
2397   THnSparseF *hSparseCxyLxyLSCsign=new THnSparseF("hSparseCxyLxyLSCsign","Candidate Mass;massD0;Pt;CosXY;Lxy",4,nbinsSparsCxyLxy,binLowLimitSparseCxyLxy,binUpLimitSparseCxyLxy);
2398   hSparseCxyLxyLSCsign->SetBinEdges(1,ptbinlimitsCxyLxy); 
2399   hSparseCxyLxyLSCsign->GetAxis(0)->SetName("mass");
2400   hSparseCxyLxyLSCsign->GetAxis(0)->SetTitle("Invariant Mass (K#pi) [GeV/c^{2}]");
2401   hSparseCxyLxyLSCsign->GetAxis(1)->SetName("pt");
2402   hSparseCxyLxyLSCsign->GetAxis(1)->SetTitle("p_{t} [GeV/c]");
2403   hSparseCxyLxyLSCsign->GetAxis(2)->SetName("CosPointXY");
2404   hSparseCxyLxyLSCsign->GetAxis(2)->SetTitle("Cos#theta_{point}^{XY}");
2405   hSparseCxyLxyLSCsign->GetAxis(3)->SetName("NormDecLengthXY");
2406   hSparseCxyLxyLSCsign->GetAxis(3)->SetTitle("Normalized XY decay length");
2407
2408   flistLsCutsSignal->Add(hSparseCxyLxyLSCsign);
2409   // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2410   TH2F *hd0D0VSd0xd0LSCsignpt;
2411   TH2F *hangletracksVSd0xd0LSCsignpt;
2412   TH2F *hangletracksVSd0D0LSCsignpt;
2413   TH1F *hd0xd0LSCsignpt;
2414   TH1F *hPhiHistPMLSCsignpt,*hPhiHistSBLSCsignpt;
2415
2416   TH2F *hTOFpidLSCsign=new TH2F("hTOFpidLSCsign","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
2417   flistLsCutsSignal->Add(hTOFpidLSCsign);
2418
2419   for(Int_t i=0;i<fnbins;i++){
2420  
2421     namehist="hPhiHistPMLSCsign_pt";
2422     namehist+=i;
2423     titlehist="Azimuthal correlation LS Cuts Sign PM ptbin=";
2424     titlehist+=i;
2425     hPhiHistPMLSCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
2426     hPhiHistPMLSCsignpt->Sumw2();
2427     flistLsCutsSignal->Add(hPhiHistPMLSCsignpt);
2428
2429     namehist="hPhiHistSBLSCsign_pt";
2430     namehist+=i;
2431     titlehist="Azimuthal correlation LS Cuts Sign SB ptbin=";
2432     titlehist+=i;
2433     hPhiHistSBLSCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
2434     hPhiHistSBLSCsignpt->Sumw2();
2435     flistLsCutsSignal->Add(hPhiHistSBLSCsignpt);
2436
2437   
2438
2439     namehist="hd0zD0ptLSCsign_pt";
2440     namehist+=i;
2441     titlehist="d0(z) Loose Cuts Signm ptbin=";
2442     titlehist+=i;
2443     hd0zD0ptLSCsign=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
2444     hd0zD0ptLSCsign->SetXTitle("d_{0}(z)    [#mum]");
2445     hd0zD0ptLSCsign->SetYTitle("Entries");
2446     flistLsCutsSignal->Add(hd0zD0ptLSCsign);
2447
2448     namehist="hInvMassD0LSCsign_pt";
2449     namehist+=i;
2450     titlehist="Invariant Mass Loose Cuts Sign ptbin=";
2451     titlehist+=i;
2452     hInvMassD0LSCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2453     hInvMassD0LSCsign->SetXTitle("Invariant Mass    [GeV]");
2454     hInvMassD0LSCsign->SetYTitle("Entries");
2455     flistLsCutsSignal->Add(hInvMassD0LSCsign);
2456
2457
2458     namehist="hInvMassD0barLSCsign_pt";
2459     namehist+=i;
2460     titlehist="Invariant Mass D0bar Loose Cuts Signal ptbin=";
2461     titlehist+=i;
2462     hInvMassD0barLSCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2463     hInvMassD0barLSCsign->SetXTitle("Invariant Mass    [GeV]");
2464     hInvMassD0barLSCsign->SetYTitle("Entries");
2465     flistLsCutsSignal->Add(hInvMassD0barLSCsign);
2466
2467     namehist="hetaLSCsign_pt";
2468     namehist+=i;
2469     titlehist="eta Loose Cuts Sign ptbin=";
2470     titlehist+=i;
2471     hetaLSCsign=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
2472     hetaLSCsign->SetXTitle("Pseudorapidity");
2473     hetaLSCsign->SetYTitle("Entries");
2474     flistLsCutsSignal->Add(hetaLSCsign);
2475
2476     namehist="hCosPDPBLSCsign_pt";
2477     namehist+=i;
2478     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
2479     titlehist+=i;
2480     hCosPDPBLSCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2481     hCosPDPBLSCsign->SetXTitle("Cosine between D0 momentum and B momentum");
2482     hCosPDPBLSCsign->SetYTitle("Entries");
2483     flistLsCutsSignal->Add(hCosPDPBLSCsign);
2484
2485     namehist="hCosPcPDLSCsign_pt";
2486     namehist+=i;
2487     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
2488     titlehist+=i;
2489     hCosPcPDLSCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2490     hCosPcPDLSCsign->SetXTitle("Cosine between c quark momentum and D0 momentum");
2491     hCosPcPDLSCsign->SetYTitle("Entries");
2492     flistLsCutsSignal->Add(hCosPcPDLSCsign);
2493
2494
2495  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2496     namehist="hd0xd0LSCsign_pt";
2497     namehist+=i;
2498     titlehist="d0xd0 Loose Cuts Sign ptbin=";
2499     titlehist+=i;
2500     hd0xd0LSCsignpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
2501     hd0xd0LSCsignpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
2502     hd0xd0LSCsignpt->SetYTitle("Entries");
2503     flistLsCutsSignal->Add(hd0xd0LSCsignpt);
2504
2505
2506     namehist="hd0D0VSd0xd0LSCsign_pt";
2507     namehist+=i;
2508     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Sign ptbin=";
2509     titlehist+=i;
2510     hd0D0VSd0xd0LSCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
2511     hd0D0VSd0xd0LSCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2512     hd0D0VSd0xd0LSCsignpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
2513     flistLsCutsSignal->Add(hd0D0VSd0xd0LSCsignpt);
2514     
2515     
2516     namehist="hangletracksVSd0xd0LSCsign_pt";
2517     namehist+=i;
2518     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Sign ptbin=";
2519     titlehist+=i;
2520     hangletracksVSd0xd0LSCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
2521     hangletracksVSd0xd0LSCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2522     hangletracksVSd0xd0LSCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
2523     flistLsCutsSignal->Add(hangletracksVSd0xd0LSCsignpt);
2524     
2525
2526     namehist="hangletracksVSd0D0LSCsign_pt";
2527     namehist+=i;
2528     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Loose Cuts Sign ptbin=";
2529     titlehist+=i;
2530     hangletracksVSd0D0LSCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
2531     hangletracksVSd0D0LSCsignpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
2532     hangletracksVSd0D0LSCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
2533     flistLsCutsSignal->Add(hangletracksVSd0D0LSCsignpt);
2534
2535     
2536   }
2537   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
2538   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2539
2540
2541   // ####### d0 D0 histos ############
2542   TH1F *hd0D0LSCsignPM = new TH1F("hd0D0LSCsignPM","D^{0} impact par. plot , Loose Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
2543   hd0D0LSCsignPM->SetXTitle("Impact parameter [#mum]");
2544   hd0D0LSCsignPM->SetYTitle("Entries");
2545
2546   TH1F *hd0D0VtxTrueLSCsignPM = new TH1F("hd0D0VtxTrueLSCsignPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
2547   hd0D0VtxTrueLSCsignPM->SetXTitle("Impact parameter [#mum]");
2548   hd0D0VtxTrueLSCsignPM->SetYTitle("Entries");
2549
2550   TH1F *hMCd0D0LSCsignPM = new TH1F("hMCd0D0LSCsignPM","D^{0} impact par. plot, Loose Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
2551   hMCd0D0LSCsignPM->SetXTitle("MC Impact parameter [#mum]");
2552   hMCd0D0LSCsignPM->SetYTitle("Entries");
2553
2554   TH1F *hd0D0LSCsignSB = new TH1F("hd0D0LSCsignSB","D^{0} impact par. plot , Loose Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
2555   hd0D0LSCsignSB->SetXTitle("Impact parameter [#mum]");
2556   hd0D0LSCsignSB->SetYTitle("Entries");
2557
2558   TH1F *hd0D0VtxTrueLSCsignSB = new TH1F("hd0D0VtxTrueLSCsignSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
2559   hd0D0VtxTrueLSCsignSB->SetXTitle("Impact parameter [#mum]");
2560   hd0D0VtxTrueLSCsignSB->SetYTitle("Entries");
2561
2562   TH1F *hMCd0D0LSCsignSB = new TH1F("hMCd0D0LSCsignSB","D^{0} impact par. plot, Loose Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
2563   hMCd0D0LSCsignSB->SetXTitle("MC Impact parameter [#mum]");
2564   hMCd0D0LSCsignSB->SetYTitle("Entries");
2565
2566   flistLsCutsSignal->Add(hd0D0LSCsignPM);
2567   flistLsCutsSignal->Add(hd0D0VtxTrueLSCsignPM);
2568   flistLsCutsSignal->Add(hMCd0D0LSCsignPM);
2569   flistLsCutsSignal->Add(hd0D0LSCsignSB);
2570   flistLsCutsSignal->Add(hd0D0VtxTrueLSCsignSB);
2571   flistLsCutsSignal->Add(hMCd0D0LSCsignSB);
2572   
2573   TH1F *hd0D0ptLSCsignPM;
2574   TH1F *hMCd0D0ptLSCsignPM;
2575   TH1F *hd0D0VtxTrueptLSCsignPM;
2576   TH1F *hd0D0ptLSCsignSB;
2577   TH1F *hMCd0D0ptLSCsignSB;
2578   TH1F *hd0D0VtxTrueptLSCsignSB;
2579   namehist="hd0D0ptLSCsign_";
2580   titlehist="D^{0} impact par. plot, Loose Cuts, Signal, ";
2581   for(Int_t i=0;i<fnbins;i++){
2582     strnamept=namehist;
2583     strnamept.Append("PkMss_pt");
2584     strnamept+=i;
2585
2586     strtitlept=titlehist;
2587     strtitlept.Append(" Mass Peak, ");
2588     strtitlept+=fptbins[i];
2589     strtitlept.Append("<= pt <");
2590     strtitlept+=fptbins[i+1];
2591     strtitlept.Append(" [GeV/c]");
2592     
2593     hd0D0ptLSCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2594     hd0D0ptLSCsignPM->SetXTitle("Impact parameter [#mum] ");
2595     hd0D0ptLSCsignPM->SetYTitle("Entries");
2596     flistLsCutsSignal->Add(hd0D0ptLSCsignPM);
2597
2598     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2599     hMCd0D0ptLSCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2600     hMCd0D0ptLSCsignPM->SetXTitle("MC Impact parameter [#mum] ");
2601     hMCd0D0ptLSCsignPM->SetYTitle("Entries");
2602     flistLsCutsSignal->Add(hMCd0D0ptLSCsignPM);
2603  
2604
2605     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2606     hd0D0VtxTrueptLSCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2607     hd0D0VtxTrueptLSCsignPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2608     hd0D0VtxTrueptLSCsignPM->SetYTitle("Entries");
2609     flistLsCutsSignal->Add(hd0D0VtxTrueptLSCsignPM);
2610     
2611     strnamept=namehist;
2612     strnamept.Append("SBMss_pt");
2613     strnamept+=i;
2614
2615     strtitlept=titlehist;
2616     strtitlept.Append(" Side Bands, ");
2617     strtitlept+=fptbins[i];
2618     strtitlept.Append("<= pt <");
2619     strtitlept+=fptbins[i+1];
2620     strtitlept.Append(" [GeV/c]");
2621     
2622     hd0D0ptLSCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2623     hd0D0ptLSCsignSB->SetXTitle("Impact parameter [#mum] ");
2624     hd0D0ptLSCsignSB->SetYTitle("Entries");
2625     flistLsCutsSignal->Add(hd0D0ptLSCsignSB);
2626
2627     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2628     hMCd0D0ptLSCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2629     hMCd0D0ptLSCsignSB->SetXTitle("MC Impact parameter [#mum] ");
2630     hMCd0D0ptLSCsignSB->SetYTitle("Entries");
2631     flistLsCutsSignal->Add(hMCd0D0ptLSCsignSB);
2632
2633     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2634     hd0D0VtxTrueptLSCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2635     hd0D0VtxTrueptLSCsignSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2636     hd0D0VtxTrueptLSCsignSB->SetYTitle("Entries");
2637     flistLsCutsSignal->Add(hd0D0VtxTrueptLSCsignSB);
2638   }
2639
2640
2641   //############ LOOSE CUTS BACKGROUND HISTOGRAMS ###########
2642   //
2643   //   ######## global properties histos #######
2644   TH2F *hCPtaVSd0d0LSCback=new TH2F("hCPtaVSd0d0LSCback","hCPtaVSd0d0_LooseCuts_Background",1000,-100000.,100000.,100,-1.,1.);
2645   TH1F *hSecVtxZLSCback=new TH1F("hSecVtxZLSCback","hSecVtxZ_LooseCuts_Background",1000,-8.,8.);
2646   TH1F *hSecVtxXLSCback=new TH1F("hSecVtxXLSCback","hSecVtxX_LooseCuts_Background",1000,-3000.,3000.);
2647   TH1F *hSecVtxYLSCback=new TH1F("hSecVtxYLSCback","hSecVtxY_LooseCuts_Background",1000,-3000.,3000.);
2648   TH2F *hSecVtxXYLSCback=new TH2F("hSecVtxXYLSCback","hSecVtxXY_LooseCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
2649   TH1F *hSecVtxPhiLSCback=new TH1F("hSecVtxPhiLSCback","hSecVtxPhi_LooseCuts_Background",180,-180.1,180.1);
2650   TH1F *hd0singlTrackLSCback=new TH1F("hd0singlTrackLSCback","hd0singlTrackLooseCuts_Back",1000,-5000.,5000.);
2651   TH1F *hCPtaLSCback=new TH1F("hCPtaLSCback","hCPta_LooseCuts_Background",100,-1.,1.);
2652   TH1F *hd0xd0LSCback=new TH1F("hd0xd0LSCback","hd0xd0_LooseCuts_Background",1000,-100000.,100000.);
2653   TH1F *hMassTrueLSCback=new TH1F("hMassTrueLSCback","D^{0} MC inv. Mass Loose Cuts Background(All momenta)",600,1.600,2.200);
2654   TH1F *hMassLSCback=new TH1F("hMassLSCback","D^{0} inv. Mass Loose Cuts Background (All momenta)",600,1.600,2.200);
2655   hMassLSCback->Sumw2();
2656   TH1F *hMassTrueLSCbackPM=new TH1F("hMassTrueLSCbackPM","D^{0} MC inv. Mass Loose Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
2657   TH1F *hMassLSCbackPM=new TH1F("hMassLSCbackPM","D^{0} inv. Mass Loose Cuts Background (All momenta), MassPeak",600,1.600,2.200);
2658   hMassLSCbackPM->Sumw2();
2659   TH1F *hMassTrueLSCbackSB=new TH1F("hMassTrueLSCbackSB","D^{0} MC inv. Mass in Side Bands Loose Cuts Background(All momenta)",600,1.600,2.200);
2660   TH1F *hMassLSCbackSB=new TH1F("hMassLSCbackSB","D^{0} inv. Mass in Side Bands Loose Cuts Background (All momenta)",600,1.600,2.200);
2661   hMassLSCbackSB->Sumw2();
2662
2663   flistLsCutsBack->Add(hCPtaVSd0d0LSCback);
2664   flistLsCutsBack->Add(hSecVtxZLSCback);
2665   flistLsCutsBack->Add(hSecVtxYLSCback);
2666   flistLsCutsBack->Add(hSecVtxXLSCback);
2667   flistLsCutsBack->Add(hSecVtxXYLSCback);
2668   flistLsCutsBack->Add(hSecVtxPhiLSCback);
2669   flistLsCutsBack->Add(hd0singlTrackLSCback);
2670   flistLsCutsBack->Add(hCPtaLSCback);
2671   flistLsCutsBack->Add(hd0xd0LSCback);
2672   flistLsCutsBack->Add(hMassTrueLSCback);
2673   flistLsCutsBack->Add(hMassLSCback);
2674   flistLsCutsBack->Add(hMassTrueLSCbackPM);
2675   flistLsCutsBack->Add(hMassLSCbackPM);
2676   flistLsCutsBack->Add(hMassTrueLSCbackSB);
2677   flistLsCutsBack->Add(hMassLSCbackSB);
2678
2679
2680
2681
2682
2683
2684
2685
2686  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
2687   TH1F *hdcaLSCback=new TH1F("hdcaLSCback","hdca_LooseCuts_Backgr",100,0.,1000.);
2688   hdcaLSCback->SetXTitle("dca   [#mum]");
2689   hdcaLSCback->SetYTitle("Entries");
2690   TH1F *hcosthetastarLSCback=new TH1F("hcosthetastarLSCback","hCosThetaStar_LooseCuts_Backgr",50,-1.,1.);
2691   hcosthetastarLSCback->SetXTitle("cos #theta^{*}");
2692   hcosthetastarLSCback->SetYTitle("Entries");
2693   TH1F *hptD0LSCback=new TH1F("hptD0LSCback","D^{0} transverse momentum distribution",34,ptbinsD0arr);
2694   hptD0LSCback->SetXTitle("p_{t}  [GeV/c]");
2695   hptD0LSCback->SetYTitle("Entries");
2696   TH1F *hptD0VsMaxPtLSCback=new TH1F("hptD0VsMaxPtLSCback","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
2697   TH2F *hptD0PTallsqrtLSCback=new TH2F("hptD0PTallsqrtLSCback","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
2698   TH2F *hptD0PTallLSCback=new TH2F("hptD0PTallLSCback","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
2699   TH2F *hptD0vsptBLSCback=new TH2F("hptD0vsptBLSCback","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2700   TH2F *hpD0vspBLSCback=new TH2F("hpD0vspBLSCback","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2701   TH2F *hptD0vsptcquarkLSCback=new TH2F("hptD0vsptcquarkLSCback","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2702   TH2F *hpD0vspcquarkLSCback=new TH2F("hpD0vspcquarkLSCback","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
2703   flistLsCutsBack->Add(hdcaLSCback);
2704   flistLsCutsBack->Add(hcosthetastarLSCback);
2705   flistLsCutsBack->Add(hptD0LSCback);
2706   flistLsCutsBack->Add(hptD0VsMaxPtLSCback);
2707   flistLsCutsBack->Add(hptD0PTallsqrtLSCback);
2708   flistLsCutsBack->Add(hptD0PTallLSCback);
2709   flistLsCutsBack->Add(hptD0vsptBLSCback);
2710   flistLsCutsBack->Add(hpD0vspBLSCback);
2711   flistLsCutsBack->Add(hptD0vsptcquarkLSCback);
2712   flistLsCutsBack->Add(hpD0vspcquarkLSCback);
2713  
2714   TH1F *hd0zD0ptLSCback;
2715   TH1F *hInvMassD0LSCback,*hInvMassD0barLSCback;
2716   TH2F *hInvMassPtLSCback=new TH2F("hInvMassPtLSCback","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
2717   THnSparseF *hSparseLSCback=new THnSparseF("hSparseLSCback","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
2718   hSparseLSCback->SetBinEdges(0,massbins);
2719   hSparseLSCback->SetBinEdges(1,massbins);
2720   hSparseLSCback->SetBinEdges(2,ptbinsForNsparse);
2721   hSparseLSCback->SetBinEdges(3,impparbins);
2722   hSparseLSCback->SetBinEdges(4,massHypoBins); 
2723   flistLsCutsBack->Add(hSparseLSCback);
2724   TH1F *hetaLSCback;
2725   TH1F *hCosPDPBLSCback;
2726   TH1F *hCosPcPDLSCback;
2727   flistLsCutsBack->Add(hInvMassPtLSCback);
2728  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2729   TH2F *hd0D0VSd0xd0LSCbackpt;
2730   TH2F *hangletracksVSd0xd0LSCbackpt;
2731   TH2F *hangletracksVSd0D0LSCbackpt;
2732   TH1F *hd0xd0LSCbackpt;
2733
2734   TH2F *hTOFpidLSCback=new TH2F("hTOFpidLSCback","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
2735   flistLsCutsBack->Add(hTOFpidLSCback);
2736
2737   for(Int_t i=0;i<fnbins;i++){
2738     namehist="hd0zD0ptLSCback_pt";
2739     namehist+=i;
2740     titlehist="d0(z) Loose Cuts Backgr ptbin=";
2741     titlehist+=i;
2742     hd0zD0ptLSCback=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
2743     hd0zD0ptLSCback->SetXTitle("d_{0}(z)    [#mum]");
2744     hd0zD0ptLSCback->SetYTitle("Entries");
2745     flistLsCutsBack->Add(hd0zD0ptLSCback);
2746
2747     namehist="hInvMassD0LSCback_pt";
2748     namehist+=i;
2749     titlehist="Invariant Mass Loose Cuts Backgr ptbin=";
2750     titlehist+=i;
2751     hInvMassD0LSCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2752     hInvMassD0LSCback->SetXTitle("Invariant Mass    [GeV]");
2753     hInvMassD0LSCback->SetYTitle("Entries");
2754     flistLsCutsBack->Add(hInvMassD0LSCback);
2755     
2756     namehist="hInvMassD0barLSCback_pt";
2757     namehist+=i;
2758     titlehist="Invariant Mass D0bar Loose Cuts Back ptbin=";
2759     titlehist+=i;
2760     hInvMassD0barLSCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
2761     hInvMassD0barLSCback->SetXTitle("Invariant Mass    [GeV]");
2762     hInvMassD0barLSCback->SetYTitle("Entries");
2763     flistLsCutsBack->Add(hInvMassD0barLSCback);
2764
2765
2766     namehist="hetaLSCback_pt";
2767     namehist+=i;
2768     titlehist="eta Loose Cuts Backgr ptbin=";
2769     titlehist+=i;
2770     hetaLSCback=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
2771     hetaLSCback->SetXTitle("Pseudorapidity");
2772     hetaLSCback->SetYTitle("Entries");
2773     flistLsCutsBack->Add(hetaLSCback);
2774
2775     namehist="hCosPDPBLSCback_pt";
2776     namehist+=i;
2777     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
2778     titlehist+=i;
2779     hCosPDPBLSCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2780     hCosPDPBLSCback->SetXTitle("Cosine between D0 momentum and B momentum");
2781     hCosPDPBLSCback->SetYTitle("Entries");
2782     flistLsCutsBack->Add(hCosPDPBLSCback);
2783
2784     namehist="hCosPcPDLSCback_pt";
2785     namehist+=i;
2786     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
2787     titlehist+=i;
2788     hCosPcPDLSCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
2789     hCosPcPDLSCback->SetXTitle("Cosine between c quark momentum and D0 momentum");
2790     hCosPcPDLSCback->SetYTitle("Entries");
2791     flistLsCutsBack->Add(hCosPcPDLSCback);
2792
2793  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
2794     namehist="hd0xd0LSCback_pt";
2795     namehist+=i;
2796     titlehist="d0xd0 Loose Cuts Back ptbin=";
2797     titlehist+=i;
2798     hd0xd0LSCbackpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
2799     hd0xd0LSCbackpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
2800     hd0xd0LSCbackpt->SetYTitle("Entries");
2801     flistLsCutsBack->Add(hd0xd0LSCbackpt);
2802
2803
2804     namehist="hd0D0VSd0xd0LSCback_pt";
2805     namehist+=i;
2806     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Back ptbin=";
2807     titlehist+=i;
2808     hd0D0VSd0xd0LSCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
2809     hd0D0VSd0xd0LSCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2810     hd0D0VSd0xd0LSCbackpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
2811     flistLsCutsBack->Add(hd0D0VSd0xd0LSCbackpt);
2812     
2813     
2814     namehist="hangletracksVSd0xd0LSCback_pt";
2815     namehist+=i;
2816     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Back ptbin=";
2817     titlehist+=i;
2818     hangletracksVSd0xd0LSCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
2819     hangletracksVSd0xd0LSCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
2820     hangletracksVSd0xd0LSCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
2821     flistLsCutsBack->Add(hangletracksVSd0xd0LSCbackpt);
2822     
2823
2824     namehist="hangletracksVSd0D0LSCback_pt";
2825     namehist+=i;
2826     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Loose Cuts Back ptbin=";
2827     titlehist+=i;
2828     hangletracksVSd0D0LSCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
2829     hangletracksVSd0D0LSCbackpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
2830     hangletracksVSd0D0LSCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
2831     flistLsCutsBack->Add(hangletracksVSd0D0LSCbackpt);
2832     
2833   }
2834   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
2835   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2836
2837
2838
2839
2840
2841
2842
2843   // ####### d0 D0 histos ############
2844   
2845  TH1F *hd0D0LSCbackPM = new TH1F("hd0D0LSCbackPM","D^{0} impact par. plot , Loose Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2846   hd0D0LSCbackPM->SetXTitle("Impact parameter [#mum]");
2847   hd0D0LSCbackPM->SetYTitle("Entries");
2848
2849   TH1F *hd0D0VtxTrueLSCbackPM = new TH1F("hd0D0VtxTrueLSCbackPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2850   hd0D0VtxTrueLSCbackPM->SetXTitle("Impact parameter [#mum]");
2851   hd0D0VtxTrueLSCbackPM->SetYTitle("Entries");
2852
2853   TH1F *hMCd0D0LSCbackPM = new TH1F("hMCd0D0LSCbackPM","D^{0} impact par. plot, Loose Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
2854   hMCd0D0LSCbackPM->SetXTitle("MC Impact parameter [#mum]");
2855   hMCd0D0LSCbackPM->SetYTitle("Entries");
2856
2857   TH1F *hd0D0LSCbackSB = new TH1F("hd0D0LSCbackSB","D^{0} impact par. plot , Loose Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2858   hd0D0LSCbackSB->SetXTitle("Impact parameter [#mum]");
2859   hd0D0LSCbackSB->SetYTitle("Entries");
2860
2861   TH1F *hd0D0VtxTrueLSCbackSB = new TH1F("hd0D0VtxTrueLSCbackSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
2862   hd0D0VtxTrueLSCbackSB->SetXTitle("Impact parameter [#mum]");
2863   hd0D0VtxTrueLSCbackSB->SetYTitle("Entries");
2864
2865   TH1F *hMCd0D0LSCbackSB = new TH1F("hMCd0D0LSCbackSB","D^{0} impact par. plot, Loose Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
2866   hMCd0D0LSCbackSB->SetXTitle("MC Impact parameter [#mum]");
2867   hMCd0D0LSCbackSB->SetYTitle("Entries");
2868
2869   flistLsCutsBack->Add(hd0D0LSCbackPM);
2870   flistLsCutsBack->Add(hd0D0VtxTrueLSCbackPM);
2871   flistLsCutsBack->Add(hMCd0D0LSCbackPM);
2872   flistLsCutsBack->Add(hd0D0LSCbackSB);
2873   flistLsCutsBack->Add(hd0D0VtxTrueLSCbackSB);
2874   flistLsCutsBack->Add(hMCd0D0LSCbackSB);
2875   
2876   TH1F *hd0D0ptLSCbackPM;
2877   TH1F *hMCd0D0ptLSCbackPM;
2878   TH1F *hd0D0VtxTrueptLSCbackPM;
2879   TH1F *hd0D0ptLSCbackSB;
2880   TH1F *hMCd0D0ptLSCbackSB;
2881   TH1F *hd0D0VtxTrueptLSCbackSB;
2882   namehist="hd0D0ptLSCback_";
2883   titlehist="D^{0} impact par. plot, Loose Cuts, Background, ";
2884   for(Int_t i=0;i<fnbins;i++){
2885     strnamept=namehist;
2886     strnamept.Append("PkMss_pt");
2887     strnamept+=i;
2888
2889     strtitlept=titlehist;
2890     strtitlept.Append(" Mass Peak, ");
2891     strtitlept+=fptbins[i];
2892     strtitlept.Append("<= pt <");
2893     strtitlept+=fptbins[i+1];
2894     strtitlept.Append(" [GeV/c]");
2895     
2896     hd0D0ptLSCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2897     hd0D0ptLSCbackPM->SetXTitle("Impact parameter [#mum] ");
2898     hd0D0ptLSCbackPM->SetYTitle("Entries");
2899     flistLsCutsBack->Add(hd0D0ptLSCbackPM);
2900
2901     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2902     hMCd0D0ptLSCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2903     hMCd0D0ptLSCbackPM->SetXTitle("MC Impact parameter [#mum] ");
2904     hMCd0D0ptLSCbackPM->SetYTitle("Entries");
2905     flistLsCutsBack->Add(hMCd0D0ptLSCbackPM);
2906  
2907
2908     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2909     hd0D0VtxTrueptLSCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2910     hd0D0VtxTrueptLSCbackPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2911     hd0D0VtxTrueptLSCbackPM->SetYTitle("Entries");
2912     flistLsCutsBack->Add(hd0D0VtxTrueptLSCbackPM);
2913     
2914     strnamept=namehist;
2915     strnamept.Append("SBMss_pt");
2916     strnamept+=i;
2917
2918     strtitlept=titlehist;
2919     strtitlept.Append(" Side Bands, ");
2920     strtitlept+=fptbins[i];
2921     strtitlept.Append("<= pt <");
2922     strtitlept+=fptbins[i+1];
2923     strtitlept.Append(" [GeV/c]");
2924     
2925     hd0D0ptLSCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2926     hd0D0ptLSCbackSB->SetXTitle("Impact parameter [#mum] ");
2927     hd0D0ptLSCbackSB->SetYTitle("Entries");
2928     flistLsCutsBack->Add(hd0D0ptLSCbackSB);
2929
2930     strnamept.ReplaceAll("hd0D0","hMCd0D0");
2931     hMCd0D0ptLSCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2932     hMCd0D0ptLSCbackSB->SetXTitle("MC Impact parameter [#mum] ");
2933     hMCd0D0ptLSCbackSB->SetYTitle("Entries");
2934     flistLsCutsBack->Add(hMCd0D0ptLSCbackSB);
2935
2936     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
2937     hd0D0VtxTrueptLSCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
2938     hd0D0VtxTrueptLSCbackSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
2939     hd0D0VtxTrueptLSCbackSB->SetYTitle("Entries");
2940     flistLsCutsBack->Add(hd0D0VtxTrueptLSCbackSB);
2941   }
2942
2943
2944
2945  //############ LOOSE CUTS FROMB HISTOGRAMS ###########
2946   //
2947   //#######  global properties histos
2948
2949   TH2F *hCPtaVSd0d0LSCfromB=new TH2F("hCPtaVSd0d0LSCfromB","hCPtaVSd0d0_LooseCuts_FromB",1000,-100000.,100000.,100,-1.,1.);
2950   TH1F *hSecVtxZLSCfromB=new TH1F("hSecVtxZLSCfromB","hSecVtxZ_LooseCuts_FromB",1000,-8.,8.);
2951   TH1F *hSecVtxXLSCfromB=new TH1F("hSecVtxXLSCfromB","hSecVtxX_LooseCuts_FromB",1000,-3000.,3000.);
2952   TH1F *hSecVtxYLSCfromB=new TH1F("hSecVtxYLSCfromB","hSecVtxY_LooseCuts_FromB",1000,-3000.,3000.);
2953   TH2F *hSecVtxXYLSCfromB=new TH2F("hSecVtxXYLSCfromB","hSecVtxXY_LooseCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
2954   TH1F *hSecVtxPhiLSCfromB=new TH1F("hSecVtxPhiLSCfromB","hSecVtxPhi_LooseCuts_FromB",180,-180.1,180.1);
2955   TH1F *hd0singlTrackLSCfromB=new TH1F("hd0singlTrackLSCfromB","hd0singlTrackLooseCuts_FromB",1000,-5000.,5000.);
2956   TH1F *hCPtaLSCfromB=new TH1F("hCPtaLSCfromB","hCPta_LooseCuts_FromB",100,-1.,1.);
2957   TH1F *hd0xd0LSCfromB=new TH1F("hd0xd0LSCfromB","hd0xd0_LooseCuts_FromB",1000,-100000.,100000.);
2958   TH1F *hMassTrueLSCfromB=new TH1F("hMassTrueLSCfromB","D^{0} MC inv. Mass Loose Cuts FromB(All momenta)",600,1.600,2.200);
2959   TH1F *hMassLSCfromB=new TH1F("hMassLSCfromB","D^{0} inv. Mass Loose Cuts FromB (All momenta)",600,1.600,2.200);
2960   hMassLSCfromB->Sumw2();
2961   TH1F *hMassTrueLSCfromBPM=new TH1F("hMassTrueLSCfromBPM","D^{0} MC inv. Mass Loose Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
2962   TH1F *hMassLSCfromBPM=new TH1F("hMassLSCfromBPM","D^{0} inv. Mass Loose Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
2963   hMassLSCfromBPM->Sumw2();
2964   TH1F *hMassTrueLSCfromBSB=new TH1F("hMassTrueLSCfromBSB","D^{0} MC inv. Mass in Side Bands Loose Cuts FromB(All momenta)",600,1.600,2.200);
2965   TH1F *hMassLSCfromBSB=new TH1F("hMassLSCfromBSB","D^{0} inv. Mass in Side Bands Loose Cuts FromB (All momenta)",600,1.600,2.200);
2966   hMassLSCfromBSB->Sumw2();
2967
2968   flistLsCutsFromB->Add(hCPtaVSd0d0LSCfromB);
2969   flistLsCutsFromB->Add(hSecVtxZLSCfromB);
2970   flistLsCutsFromB->Add(hSecVtxYLSCfromB);
2971   flistLsCutsFromB->Add(hSecVtxXLSCfromB);
2972   flistLsCutsFromB->Add(hSecVtxXYLSCfromB);
2973   flistLsCutsFromB->Add(hSecVtxPhiLSCfromB);
2974   flistLsCutsFromB->Add(hd0singlTrackLSCfromB);
2975   flistLsCutsFromB->Add(hCPtaLSCfromB);
2976   flistLsCutsFromB->Add(hd0xd0LSCfromB);
2977   flistLsCutsFromB->Add(hMassTrueLSCfromB);
2978   flistLsCutsFromB->Add(hMassLSCfromB);
2979   flistLsCutsFromB->Add(hMassTrueLSCfromBPM);
2980   flistLsCutsFromB->Add(hMassLSCfromBPM);
2981   flistLsCutsFromB->Add(hMassTrueLSCfromBSB);
2982   flistLsCutsFromB->Add(hMassLSCfromBSB);
2983
2984
2985
2986
2987  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
2988   TH1F *hdcaLSCfromB=new TH1F("hdcaLSCfromB","hdca_LooseCuts_FromB",100,0.,1000.);
2989   hdcaLSCfromB->SetXTitle("dca   [#mum]");
2990   hdcaLSCfromB->SetYTitle("Entries");
2991   TH1F *hcosthetastarLSCfromB=new TH1F("hcosthetastarLSCfromB","hCosThetaStar_LooseCuts_FromB",50,-1.,1.);
2992   hcosthetastarLSCfromB->SetXTitle("cos #theta^{*}");
2993   hcosthetastarLSCfromB->SetYTitle("Entries");
2994   TH1F *hptD0LSCfromB=new TH1F("hptD0LSCfromB","D^{0} transverse momentum distribution",34,ptbinsD0arr);
2995   hptD0LSCfromB->SetXTitle("p_{t}  [GeV/c]");
2996   hptD0LSCfromB->SetYTitle("Entries");
2997   TH1F *hptD0VsMaxPtLSCfromB=new TH1F("hptD0VsMaxPtLSCfromB","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
2998   TH2F *hptD0PTallsqrtLSCfromB=new TH2F("hptD0PTallsqrtLSCfromB","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
2999   TH2F *hptD0PTallLSCfromB=new TH2F("hptD0PTallLSCfromB","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
3000   TH2F *hptD0vsptBLSCfromB=new TH2F("hptD0vsptBLSCfromB","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3001   TH2F *hpD0vspBLSCfromB=new TH2F("hpD0vspBLSCfromB","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3002   TH2F *hptD0vsptcquarkLSCfromB=new TH2F("hptD0vsptcquarkLSCfromB","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3003   TH2F *hpD0vspcquarkLSCfromB=new TH2F("hpD0vspcquarkLSCfromB","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3004   flistLsCutsFromB->Add(hdcaLSCfromB);
3005   flistLsCutsFromB->Add(hcosthetastarLSCfromB);
3006   flistLsCutsFromB->Add(hptD0LSCfromB);
3007   flistLsCutsFromB->Add(hptD0VsMaxPtLSCfromB);
3008   flistLsCutsFromB->Add(hptD0PTallsqrtLSCfromB);
3009   flistLsCutsFromB->Add(hptD0PTallLSCfromB);
3010   flistLsCutsFromB->Add(hptD0vsptBLSCfromB);
3011   flistLsCutsFromB->Add(hpD0vspBLSCfromB);
3012   flistLsCutsFromB->Add(hptD0vsptcquarkLSCfromB);
3013   flistLsCutsFromB->Add(hpD0vspcquarkLSCfromB);
3014  
3015   TH1F *hd0zD0ptLSCfromB;
3016   TH1F *hInvMassD0LSCfromB,*hInvMassD0barLSCfromB;
3017   TH2F *hInvMassPtLSCfromB=new TH2F("hInvMassPtLSCfromB","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
3018
3019   TH3F *hInvMassPtSelSignOnlyLSCfromB=new TH3F("hInvMassPtSelSignOnlyLSCfromB","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3020   flistLsCutsFromB->Add(hInvMassPtSelSignOnlyLSCfromB);
3021   TH3F *hInvMassPtSelReflOnlyLSCfromB=new TH3F("hInvMassPtSelReflOnlyLSCfromB","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3022   flistLsCutsFromB->Add(hInvMassPtSelReflOnlyLSCfromB);
3023
3024   THnSparseF *hSparseLSCfromB=new THnSparseF("hSparseLSCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
3025   hSparseLSCfromB->SetBinEdges(0,massbins);
3026   hSparseLSCfromB->SetBinEdges(1,massbins);
3027   hSparseLSCfromB->SetBinEdges(2,ptbinsForNsparse);
3028   hSparseLSCfromB->SetBinEdges(3,impparbins);
3029   hSparseLSCfromB->SetBinEdges(4,massHypoBins); 
3030   flistLsCutsFromB->Add(hSparseLSCfromB);
3031
3032
3033   THnSparseF *hSparseRecoLSCfromB=new THnSparseF("hSparseRecoLSCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
3034   hSparseRecoLSCfromB->SetBinEdges(0,massbins);
3035   hSparseRecoLSCfromB->SetBinEdges(1,massbins);
3036   hSparseRecoLSCfromB->SetBinEdges(2,ptbinsForNsparse);
3037   hSparseRecoLSCfromB->SetBinEdges(3,impparbins);
3038   hSparseRecoLSCfromB->SetBinEdges(4,massHypoBins); 
3039   flistLsCutsFromB->Add(hSparseRecoLSCfromB);
3040
3041
3042   TH1F *hetaLSCfromB;
3043   TH1F *hCosPDPBLSCfromB;
3044   TH1F *hCosPcPDLSCfromB;
3045   flistLsCutsFromB->Add(hInvMassPtLSCfromB);
3046    // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3047   TH2F *hd0D0VSd0xd0LSCfromBpt;
3048   TH2F *hangletracksVSd0xd0LSCfromBpt;
3049   TH2F *hangletracksVSd0D0LSCfromBpt;
3050   TH1F *hd0xd0LSCfromBpt;
3051
3052
3053   TH2F *hTOFpidLSCfromB=new TH2F("hTOFpidLSCfromB","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
3054   flistLsCutsFromB->Add(hTOFpidLSCfromB);
3055
3056   for(Int_t i=0;i<fnbins;i++){
3057     namehist="hd0zD0ptLSCfromB_pt";
3058     namehist+=i;
3059     titlehist="d0(z) Loose Cuts FromBm ptbin=";
3060     titlehist+=i;
3061     hd0zD0ptLSCfromB=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
3062     hd0zD0ptLSCfromB->SetXTitle("d_{0}(z)    [#mum]");
3063     hd0zD0ptLSCfromB->SetYTitle("Entries");
3064     flistLsCutsFromB->Add(hd0zD0ptLSCfromB);
3065
3066     namehist="hInvMassD0LSCfromB_pt";
3067     namehist+=i;
3068     titlehist="Invariant Mass Loose Cuts FromB ptbin=";
3069     titlehist+=i;
3070     hInvMassD0LSCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3071     hInvMassD0LSCfromB->SetXTitle("Invariant Mass    [GeV]");
3072     hInvMassD0LSCfromB->SetYTitle("Entries");
3073     flistLsCutsFromB->Add(hInvMassD0LSCfromB);
3074
3075     namehist="hInvMassD0barLSCfromB_pt";
3076     namehist+=i;
3077     titlehist="Invariant Mass D0bar Loose Cuts FromB ptbin=";
3078     titlehist+=i;
3079     hInvMassD0barLSCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3080     hInvMassD0barLSCfromB->SetXTitle("Invariant Mass    [GeV]");
3081     hInvMassD0barLSCfromB->SetYTitle("Entries");
3082     flistLsCutsFromB->Add(hInvMassD0barLSCfromB);
3083
3084     namehist="hetaLSCfromB_pt";
3085     namehist+=i;
3086     titlehist="eta Loose Cuts FromB ptbin=";
3087     titlehist+=i;
3088     hetaLSCfromB=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
3089     hetaLSCfromB->SetXTitle("Pseudorapidity");
3090     hetaLSCfromB->SetYTitle("Entries");
3091     flistLsCutsFromB->Add(hetaLSCfromB);
3092
3093     namehist="hCosPDPBLSCfromB_pt";
3094     namehist+=i;
3095     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
3096     titlehist+=i;
3097     hCosPDPBLSCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3098     hCosPDPBLSCfromB->SetXTitle("Cosine between D0 momentum and B momentum");
3099     hCosPDPBLSCfromB->SetYTitle("Entries");
3100     flistLsCutsFromB->Add(hCosPDPBLSCfromB);
3101
3102     namehist="hCosPcPDLSCfromB_pt";
3103     namehist+=i;
3104     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
3105     titlehist+=i;
3106     hCosPcPDLSCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3107     hCosPcPDLSCfromB->SetXTitle("Cosine between c quark momentum and D0 momentum");
3108     hCosPcPDLSCfromB->SetYTitle("Entries");
3109     flistLsCutsFromB->Add(hCosPcPDLSCfromB);
3110
3111  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3112     namehist="hd0xd0LSCfromB_pt";
3113     namehist+=i;
3114     titlehist="d0xd0 Loose Cuts FromB ptbin=";
3115     titlehist+=i;
3116     hd0xd0LSCfromBpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
3117     hd0xd0LSCfromBpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
3118     hd0xd0LSCfromBpt->SetYTitle("Entries");
3119     flistLsCutsFromB->Add(hd0xd0LSCfromBpt);
3120
3121
3122     namehist="hd0D0VSd0xd0LSCfromB_pt";
3123     namehist+=i;
3124     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts FromB ptbin=";
3125     titlehist+=i;
3126     hd0D0VSd0xd0LSCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
3127     hd0D0VSd0xd0LSCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3128     hd0D0VSd0xd0LSCfromBpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
3129     flistLsCutsFromB->Add(hd0D0VSd0xd0LSCfromBpt);
3130     
3131     
3132     namehist="hangletracksVSd0xd0LSCfromB_pt";
3133     namehist+=i;
3134     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts FromB ptbin=";
3135     titlehist+=i;
3136     hangletracksVSd0xd0LSCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
3137     hangletracksVSd0xd0LSCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3138     hangletracksVSd0xd0LSCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
3139     flistLsCutsFromB->Add(hangletracksVSd0xd0LSCfromBpt);
3140     
3141
3142     namehist="hangletracksVSd0D0LSCfromB_pt";
3143     namehist+=i;
3144     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Loose Cuts FromB ptbin=";
3145     titlehist+=i;
3146     hangletracksVSd0D0LSCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
3147     hangletracksVSd0D0LSCfromBpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
3148     hangletracksVSd0D0LSCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
3149     flistLsCutsFromB->Add(hangletracksVSd0D0LSCfromBpt);
3150     
3151   }
3152   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
3153   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3154
3155
3156
3157
3158
3159   // ######### d0 D0 histos ##############
3160   TH1F *hd0D0LSCfromBPM = new TH1F("hd0D0LSCfromBPM","D^{0} impact par. plot , Loose Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
3161   hd0D0LSCfromBPM->SetXTitle("Impact parameter [#mum]");
3162   hd0D0LSCfromBPM->SetYTitle("Entries");
3163
3164   TH1F *hd0D0VtxTrueLSCfromBPM = new TH1F("hd0D0VtxTrueLSCfromBPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
3165   hd0D0VtxTrueLSCfromBPM->SetXTitle("Impact parameter [#mum]");
3166   hd0D0VtxTrueLSCfromBPM->SetYTitle("Entries");
3167
3168   TH1F *hMCd0D0LSCfromBPM = new TH1F("hMCd0D0LSCfromBPM","D^{0} impact par. plot, Loose Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
3169   hMCd0D0LSCfromBPM->SetXTitle("MC Impact parameter [#mum]");
3170   hMCd0D0LSCfromBPM->SetYTitle("Entries");
3171
3172   TH1F *hd0D0LSCfromBSB = new TH1F("hd0D0LSCfromBSB","D^{0} impact par. plot , Loose Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
3173   hd0D0LSCfromBSB->SetXTitle("Impact parameter [#mum]");
3174   hd0D0LSCfromBSB->SetYTitle("Entries");
3175
3176   TH1F *hd0D0VtxTrueLSCfromBSB = new TH1F("hd0D0VtxTrueLSCfromBSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
3177   hd0D0VtxTrueLSCfromBSB->SetXTitle("Impact parameter [#mum]");
3178   hd0D0VtxTrueLSCfromBSB->SetYTitle("Entries");
3179
3180   TH1F *hMCd0D0LSCfromBSB = new TH1F("hMCd0D0LSCfromBSB","D^{0} impact par. plot, Loose Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
3181   hMCd0D0LSCfromBSB->SetXTitle("MC Impact parameter [#mum]");
3182   hMCd0D0LSCfromBSB->SetYTitle("Entries");
3183
3184   flistLsCutsFromB->Add(hd0D0LSCfromBPM);
3185   flistLsCutsFromB->Add(hd0D0VtxTrueLSCfromBPM);
3186   flistLsCutsFromB->Add(hMCd0D0LSCfromBPM);
3187   flistLsCutsFromB->Add(hd0D0LSCfromBSB);
3188   flistLsCutsFromB->Add(hd0D0VtxTrueLSCfromBSB);
3189   flistLsCutsFromB->Add(hMCd0D0LSCfromBSB);
3190   
3191   TH1F *hd0D0ptLSCfromBPM;
3192   TH1F *hMCd0D0ptLSCfromBPM;
3193   TH1F *hd0D0VtxTrueptLSCfromBPM;
3194   TH1F *hd0D0ptLSCfromBSB;
3195   TH1F *hMCd0D0ptLSCfromBSB;
3196   TH1F *hd0D0VtxTrueptLSCfromBSB;
3197   namehist="hd0D0ptLSCfromB_";
3198   titlehist="D^{0} impact par. plot, Loose Cuts, FromB, ";
3199   for(Int_t i=0;i<fnbins;i++){
3200     strnamept=namehist;
3201     strnamept.Append("PkMss_pt");
3202     strnamept+=i;
3203
3204     strtitlept=titlehist;
3205     strtitlept.Append(" Mass Peak, ");
3206     strtitlept+=fptbins[i];
3207     strtitlept.Append("<= pt <");
3208     strtitlept+=fptbins[i+1];
3209     strtitlept.Append(" [GeV/c]");
3210     
3211     hd0D0ptLSCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3212     hd0D0ptLSCfromBPM->SetXTitle("Impact parameter [#mum] ");
3213     hd0D0ptLSCfromBPM->SetYTitle("Entries");
3214     flistLsCutsFromB->Add(hd0D0ptLSCfromBPM);
3215
3216     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3217     hMCd0D0ptLSCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3218     hMCd0D0ptLSCfromBPM->SetXTitle("MC Impact parameter [#mum] ");
3219     hMCd0D0ptLSCfromBPM->SetYTitle("Entries");
3220     flistLsCutsFromB->Add(hMCd0D0ptLSCfromBPM);
3221  
3222
3223     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3224     hd0D0VtxTrueptLSCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3225     hd0D0VtxTrueptLSCfromBPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3226     hd0D0VtxTrueptLSCfromBPM->SetYTitle("Entries");
3227     flistLsCutsFromB->Add(hd0D0VtxTrueptLSCfromBPM);
3228     
3229     strnamept=namehist;
3230     strnamept.Append("SBMss_pt");
3231     strnamept+=i;
3232
3233     strtitlept=titlehist;
3234     strtitlept.Append(" Side Bands, ");
3235     strtitlept+=fptbins[i];
3236     strtitlept.Append("<= pt <");
3237     strtitlept+=fptbins[i+1];
3238     strtitlept.Append(" [GeV/c]");
3239     
3240     hd0D0ptLSCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3241     hd0D0ptLSCfromBSB->SetXTitle("Impact parameter [#mum] ");
3242     hd0D0ptLSCfromBSB->SetYTitle("Entries");
3243     flistLsCutsFromB->Add(hd0D0ptLSCfromBSB);
3244
3245     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3246     hMCd0D0ptLSCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3247     hMCd0D0ptLSCfromBSB->SetXTitle("MC Impact parameter [#mum] ");
3248     hMCd0D0ptLSCfromBSB->SetYTitle("Entries");
3249     flistLsCutsFromB->Add(hMCd0D0ptLSCfromBSB);
3250
3251     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3252     hd0D0VtxTrueptLSCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3253     hd0D0VtxTrueptLSCfromBSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3254     hd0D0VtxTrueptLSCfromBSB->SetYTitle("Entries");
3255     flistLsCutsFromB->Add(hd0D0VtxTrueptLSCfromBSB);
3256   }
3257
3258
3259
3260  //############ LOOSE CUTS FROM DSTAR HISTOGRAMS ###########
3261  //
3262   //############## global properties histos
3263   TH2F *hCPtaVSd0d0LSCfromDstar=new TH2F("hCPtaVSd0d0LSCfromDstar","hCPtaVSd0d0_LooseCuts_FromDStar",1000,-100000.,100000.,100,-1.,1.);
3264   TH1F *hSecVtxZLSCfromDstar=new TH1F("hSecVtxZLSCfromDstar","hSecVtxZ_LooseCuts_FromDStar",1000,-8.,8.);
3265   TH1F *hSecVtxXLSCfromDstar=new TH1F("hSecVtxXLSCfromDstar","hSecVtxX_LooseCuts_FromDStar",1000,-3000.,3000.);
3266   TH1F *hSecVtxYLSCfromDstar=new TH1F("hSecVtxYLSCfromDstar","hSecVtxY_LooseCuts_FromDStar",1000,-3000.,3000.);
3267   TH2F *hSecVtxXYLSCfromDstar=new TH2F("hSecVtxXYLSCfromDstar","hSecVtxXY_LooseCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
3268   TH1F *hSecVtxPhiLSCfromDstar=new TH1F("hSecVtxPhiLSCfromDstar","hSecVtxPhi_LooseCuts_FromDStar",180,-180.1,180.1);
3269   TH1F *hd0singlTrackLSCfromDstar=new TH1F("hd0singlTrackLSCfromDstar","hd0singlTrackLooseCuts_FromDstar",1000,-5000.,5000.);
3270   TH1F *hCPtaLSCfromDstar=new TH1F("hCPtaLSCfromDstar","hCPta_LooseCuts_FromDStar",100,-1.,1.);
3271   TH1F *hd0xd0LSCfromDstar=new TH1F("hd0xd0LSCfromDstar","hd0xd0_LooseCuts_FromDStar",1000,-100000.,100000.);
3272   TH1F *hMassTrueLSCfromDstar=new TH1F("hMassTrueLSCfromDstar","D^{0} MC inv. Mass Loose Cuts FromDStar(All momenta)",600,1.600,2.200);
3273   TH1F *hMassLSCfromDstar=new TH1F("hMassLSCfromDstar","D^{0} inv. Mass Loose Cuts FromDStar (All momenta)",600,1.600,2.200);
3274   hMassLSCfromDstar->Sumw2();
3275   TH1F *hMassTrueLSCfromDstarPM=new TH1F("hMassTrueLSCfromDstarPM","D^{0} MC inv. Mass Loose Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
3276   TH1F *hMassLSCfromDstarPM=new TH1F("hMassLSCfromDstarPM","D^{0} inv. Mass Loose Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
3277   hMassLSCfromDstarPM->Sumw2();
3278   TH1F *hMassTrueLSCfromDstarSB=new TH1F("hMassTrueLSCfromDstarSB","D^{0} MC inv. Mass in Side Bands Loose Cuts FromDStar(All momenta)",600,1.600,2.200);
3279   TH1F *hMassLSCfromDstarSB=new TH1F("hMassLSCfromDstarSB","D^{0} inv. Mass in Side Bands Loose Cuts FromDStar (All momenta)",600,1.600,2.200);
3280   hMassLSCfromDstarSB->Sumw2();
3281
3282   flistLsCutsFromDstar->Add(hCPtaVSd0d0LSCfromDstar);
3283   flistLsCutsFromDstar->Add(hSecVtxZLSCfromDstar);
3284   flistLsCutsFromDstar->Add(hSecVtxYLSCfromDstar);
3285   flistLsCutsFromDstar->Add(hSecVtxXLSCfromDstar);
3286   flistLsCutsFromDstar->Add(hSecVtxXYLSCfromDstar);
3287   flistLsCutsFromDstar->Add(hSecVtxPhiLSCfromDstar);
3288   flistLsCutsFromDstar->Add(hd0singlTrackLSCfromDstar);
3289   flistLsCutsFromDstar->Add(hCPtaLSCfromDstar);
3290   flistLsCutsFromDstar->Add(hd0xd0LSCfromDstar);
3291   flistLsCutsFromDstar->Add(hMassTrueLSCfromDstar);
3292   flistLsCutsFromDstar->Add(hMassLSCfromDstar);
3293   flistLsCutsFromDstar->Add(hMassTrueLSCfromDstarPM);
3294   flistLsCutsFromDstar->Add(hMassLSCfromDstarPM);
3295   flistLsCutsFromDstar->Add(hMassTrueLSCfromDstarSB);
3296   flistLsCutsFromDstar->Add(hMassLSCfromDstarSB);
3297
3298
3299
3300
3301
3302
3303
3304  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
3305   TH1F *hdcaLSCfromDstar=new TH1F("hdcaLSCfromDstar","hdca_LooseCuts_FromDstar",100,0.,1000.);
3306   hdcaLSCfromDstar->SetXTitle("dca   [#mum]");
3307   hdcaLSCfromDstar->SetYTitle("Entries");
3308   TH1F *hcosthetastarLSCfromDstar=new TH1F("hcosthetastarLSCfromDstar","hCosThetaStar_LooseCuts_FromDstar",50,-1.,1.);
3309   hcosthetastarLSCfromDstar->SetXTitle("cos #theta^{*}");
3310   hcosthetastarLSCfromDstar->SetYTitle("Entries");
3311   TH1F *hptD0LSCfromDstar=new TH1F("hptD0LSCfromDstar","D^{0} transverse momentum distribution",34,ptbinsD0arr);
3312   hptD0LSCfromDstar->SetXTitle("p_{t}  [GeV/c]");
3313   hptD0LSCfromDstar->SetYTitle("Entries");
3314   TH1F *hptD0VsMaxPtLSCfromDstar=new TH1F("hptD0VsMaxPtLSCfromDstar","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
3315   TH2F *hptD0PTallsqrtLSCfromDstar=new TH2F("hptD0PTallsqrtLSCfromDstar","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
3316   TH2F *hptD0PTallLSCfromDstar=new TH2F("hptD0PTallLSCfromDstar","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
3317   TH2F *hptD0vsptBLSCfromDstar=new TH2F("hptD0vsptBLSCfromDstar","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3318   TH2F *hpD0vspBLSCfromDstar=new TH2F("hpD0vspBLSCfromDstar","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3319   TH2F *hptD0vsptcquarkLSCfromDstar=new TH2F("hptD0vsptcquarkLSCfromDstar","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3320   TH2F *hpD0vspcquarkLSCfromDstar=new TH2F("hpD0vspcquarkLSCfromDstar","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3321   flistLsCutsFromDstar->Add(hdcaLSCfromDstar);
3322   flistLsCutsFromDstar->Add(hcosthetastarLSCfromDstar);
3323   flistLsCutsFromDstar->Add(hptD0LSCfromDstar);
3324   flistLsCutsFromDstar->Add(hptD0VsMaxPtLSCfromDstar);
3325   flistLsCutsFromDstar->Add(hptD0PTallsqrtLSCfromDstar);
3326   flistLsCutsFromDstar->Add(hptD0PTallLSCfromDstar);
3327   flistLsCutsFromDstar->Add(hptD0vsptBLSCfromDstar);
3328   flistLsCutsFromDstar->Add(hpD0vspBLSCfromDstar);
3329   flistLsCutsFromDstar->Add(hptD0vsptcquarkLSCfromDstar);
3330   flistLsCutsFromDstar->Add(hpD0vspcquarkLSCfromDstar);
3331  
3332   TH1F *hd0zD0ptLSCfromDstar;
3333   TH1F *hInvMassD0LSCfromDstar,*hInvMassD0barLSCfromDstar;
3334   TH2F *hInvMassPtLSCfromDstar=new TH2F("hInvMassPtLSCfromDstar","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
3335   TH3F *hInvMassPtSelSignOnlyLSCfromDstar=new TH3F("hInvMassPtSelSignOnlyLSCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3336   flistLsCutsFromDstar->Add(hInvMassPtSelSignOnlyLSCfromDstar);
3337   TH3F *hInvMassPtSelReflOnlyLSCfromDstar=new TH3F("hInvMassPtSelReflOnlyLSCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3338   flistLsCutsFromDstar->Add(hInvMassPtSelReflOnlyLSCfromDstar);
3339
3340   THnSparseF *hSparseLSCfromDstar=new THnSparseF("hSparseLSCfromDstar","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
3341   hSparseLSCfromDstar->SetBinEdges(0,massbins);
3342   hSparseLSCfromDstar->SetBinEdges(1,massbins);
3343   hSparseLSCfromDstar->SetBinEdges(2,ptbinsForNsparse);
3344   hSparseLSCfromDstar->SetBinEdges(3,impparbins);
3345   hSparseLSCfromDstar->SetBinEdges(4,massHypoBins); 
3346   flistLsCutsFromDstar->Add(hSparseLSCfromDstar);
3347   TH1F *hetaLSCfromDstar;
3348   TH1F *hCosPDPBLSCfromDstar;
3349   TH1F *hCosPcPDLSCfromDstar;
3350   flistLsCutsFromDstar->Add(hInvMassPtLSCfromDstar);
3351   // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3352   TH2F *hd0D0VSd0xd0LSCfromDstarpt;
3353   TH2F *hangletracksVSd0xd0LSCfromDstarpt;
3354   TH2F *hangletracksVSd0D0LSCfromDstarpt;
3355   TH1F *hd0xd0LSCfromDstarpt;
3356
3357   TH2F *hTOFpidLSCfromDstar=new TH2F("hTOFpidLSCfromDstar","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
3358   flistLsCutsFromDstar->Add(hTOFpidLSCfromDstar);
3359
3360   for(Int_t i=0;i<fnbins;i++){
3361     namehist="hd0zD0ptLSCfromDstar_pt";
3362     namehist+=i;
3363     titlehist="d0(z) Loose Cuts FromDstarm ptbin=";
3364     titlehist+=i;
3365     hd0zD0ptLSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
3366     hd0zD0ptLSCfromDstar->SetXTitle("d_{0}(z)    [#mum]");
3367     hd0zD0ptLSCfromDstar->SetYTitle("Entries");
3368     flistLsCutsFromDstar->Add(hd0zD0ptLSCfromDstar);
3369
3370     namehist="hInvMassD0LSCfromDstar_pt";
3371     namehist+=i;
3372     titlehist="Invariant Mass Loose Cuts FromDstar ptbin=";
3373     titlehist+=i;
3374     hInvMassD0LSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3375     hInvMassD0LSCfromDstar->SetXTitle("Invariant Mass    [GeV]");
3376     hInvMassD0LSCfromDstar->SetYTitle("Entries");
3377     flistLsCutsFromDstar->Add(hInvMassD0LSCfromDstar);
3378
3379     namehist="hInvMassD0barLSCfromDstar_pt";
3380     namehist+=i;
3381     titlehist="Invariant Mass D0bar Loose Cuts FromDstar ptbin=";
3382     titlehist+=i;
3383     hInvMassD0barLSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3384     hInvMassD0barLSCfromDstar->SetXTitle("Invariant Mass    [GeV]");
3385     hInvMassD0barLSCfromDstar->SetYTitle("Entries");
3386     flistLsCutsFromDstar->Add(hInvMassD0barLSCfromDstar);
3387
3388     namehist="hetaLSCfromDstar_pt";
3389     namehist+=i;
3390     titlehist="eta Loose Cuts FromDstar ptbin=";
3391     titlehist+=i;
3392     hetaLSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
3393     hetaLSCfromDstar->SetXTitle("Pseudorapidity");
3394     hetaLSCfromDstar->SetYTitle("Entries");
3395     flistLsCutsFromDstar->Add(hetaLSCfromDstar);
3396
3397     namehist="hCosPDPBLSCfromDstar_pt";
3398     namehist+=i;
3399     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
3400     titlehist+=i;
3401     hCosPDPBLSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3402     hCosPDPBLSCfromDstar->SetXTitle("Cosine between D0 momentum and B momentum");
3403     hCosPDPBLSCfromDstar->SetYTitle("Entries");
3404     flistLsCutsFromDstar->Add(hCosPDPBLSCfromDstar);
3405
3406     namehist="hCosPcPDLSCfromDstar_pt";
3407     namehist+=i;
3408     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
3409     titlehist+=i;
3410     hCosPcPDLSCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3411     hCosPcPDLSCfromDstar->SetXTitle("Cosine between c quark momentum and D0 momentum");
3412     hCosPcPDLSCfromDstar->SetYTitle("Entries");
3413     flistLsCutsFromDstar->Add(hCosPcPDLSCfromDstar);
3414     
3415  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3416     namehist="hd0xd0LSCfromDstar_pt";
3417     namehist+=i;
3418     titlehist="d0xd0 Loose Cuts FromDstar ptbin=";
3419     titlehist+=i;
3420     hd0xd0LSCfromDstarpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
3421     hd0xd0LSCfromDstarpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
3422     hd0xd0LSCfromDstarpt->SetYTitle("Entries");
3423     flistLsCutsFromDstar->Add(hd0xd0LSCfromDstarpt);
3424
3425
3426     namehist="hd0D0VSd0xd0LSCfromDstar_pt";
3427     namehist+=i;
3428     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts FromDstar ptbin=";
3429     titlehist+=i;
3430     hd0D0VSd0xd0LSCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
3431     hd0D0VSd0xd0LSCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3432     hd0D0VSd0xd0LSCfromDstarpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
3433     flistLsCutsFromDstar->Add(hd0D0VSd0xd0LSCfromDstarpt);
3434     
3435     
3436     namehist="hangletracksVSd0xd0LSCfromDstar_pt";
3437     namehist+=i;
3438     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts FromDstar ptbin=";
3439     titlehist+=i;
3440     hangletracksVSd0xd0LSCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
3441     hangletracksVSd0xd0LSCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3442     hangletracksVSd0xd0LSCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
3443     flistLsCutsFromDstar->Add(hangletracksVSd0xd0LSCfromDstarpt);
3444     
3445
3446     namehist="hangletracksVSd0D0LSCfromDstar_pt";
3447     namehist+=i;
3448     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Loose Cuts FromDstar ptbin=";
3449     titlehist+=i;
3450     hangletracksVSd0D0LSCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
3451     hangletracksVSd0D0LSCfromDstarpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
3452     hangletracksVSd0D0LSCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
3453     flistLsCutsFromDstar->Add(hangletracksVSd0D0LSCfromDstarpt);
3454
3455
3456   }
3457   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
3458   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3459
3460
3461
3462
3463
3464
3465   //########## d0 D0 histos #############  
3466   TH1F *hd0D0LSCfromDstPM = new TH1F("hd0D0LSCfromDstarPM","D^{0} impact par. plot , Loose Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
3467   hd0D0LSCfromDstPM->SetXTitle("Impact parameter [#mum]");
3468   hd0D0LSCfromDstPM->SetYTitle("Entries");
3469
3470   TH1F *hd0D0VtxTrueLSCfromDstPM = new TH1F("hd0D0VtxTrueLSCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
3471   hd0D0VtxTrueLSCfromDstPM->SetXTitle("Impact parameter [#mum]");
3472   hd0D0VtxTrueLSCfromDstPM->SetYTitle("Entries");
3473
3474   TH1F *hMCd0D0LSCfromDstPM = new TH1F("hMCd0D0LSCfromDstarPM","D^{0} impact par. plot, Loose Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
3475   hMCd0D0LSCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
3476   hMCd0D0LSCfromDstPM->SetYTitle("Entries");
3477
3478   TH1F *hd0D0LSCfromDstSB = new TH1F("hd0D0LSCfromDstarSB","D^{0} impact par. plot , Loose Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
3479   hd0D0LSCfromDstSB->SetXTitle("Impact parameter [#mum]");
3480   hd0D0LSCfromDstSB->SetYTitle("Entries");
3481
3482   TH1F *hd0D0VtxTrueLSCfromDstSB = new TH1F("hd0D0VtxTrueLSCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
3483   hd0D0VtxTrueLSCfromDstSB->SetXTitle("Impact parameter [#mum]");
3484   hd0D0VtxTrueLSCfromDstSB->SetYTitle("Entries");
3485
3486   TH1F *hMCd0D0LSCfromDstSB = new TH1F("hMCd0D0LSCfromDstarSB","D^{0} impact par. plot, Loose Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
3487   hMCd0D0LSCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
3488   hMCd0D0LSCfromDstSB->SetYTitle("Entries");
3489
3490   flistLsCutsFromDstar->Add(hd0D0LSCfromDstPM);
3491   flistLsCutsFromDstar->Add(hd0D0VtxTrueLSCfromDstPM);
3492   flistLsCutsFromDstar->Add(hMCd0D0LSCfromDstPM);
3493   flistLsCutsFromDstar->Add(hd0D0LSCfromDstSB);
3494   flistLsCutsFromDstar->Add(hd0D0VtxTrueLSCfromDstSB);
3495   flistLsCutsFromDstar->Add(hMCd0D0LSCfromDstSB);
3496   
3497   TH1F *hd0D0ptLSCfromDstPM;
3498   TH1F *hMCd0D0ptLSCfromDstPM;
3499   TH1F *hd0D0VtxTrueptLSCfromDstPM;
3500   TH1F *hd0D0ptLSCfromDstSB;
3501   TH1F *hMCd0D0ptLSCfromDstSB;
3502   TH1F *hd0D0VtxTrueptLSCfromDstSB;
3503   namehist="hd0D0ptLSCfromDstar_";
3504   titlehist="D^{0} impact par. plot, Loose Cuts, FromDStar, ";
3505   for(Int_t i=0;i<fnbins;i++){
3506     strnamept=namehist;
3507     strnamept.Append("PkMss_pt");
3508     strnamept+=i;
3509
3510     strtitlept=titlehist;
3511     strtitlept.Append(" Mass Peak, ");
3512     strtitlept+=fptbins[i];
3513     strtitlept.Append("<= pt <");
3514     strtitlept+=fptbins[i+1];
3515     strtitlept.Append(" [GeV/c]");
3516     
3517     hd0D0ptLSCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3518     hd0D0ptLSCfromDstPM->SetXTitle("Impact parameter [#mum] ");
3519     hd0D0ptLSCfromDstPM->SetYTitle("Entries");
3520     flistLsCutsFromDstar->Add(hd0D0ptLSCfromDstPM);
3521
3522     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3523     hMCd0D0ptLSCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3524     hMCd0D0ptLSCfromDstPM->SetXTitle("MC Impact parameter [#mum] ");
3525     hMCd0D0ptLSCfromDstPM->SetYTitle("Entries");
3526     flistLsCutsFromDstar->Add(hMCd0D0ptLSCfromDstPM);
3527  
3528
3529     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3530     hd0D0VtxTrueptLSCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3531     hd0D0VtxTrueptLSCfromDstPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3532     hd0D0VtxTrueptLSCfromDstPM->SetYTitle("Entries");
3533     flistLsCutsFromDstar->Add(hd0D0VtxTrueptLSCfromDstPM);
3534     
3535     strnamept=namehist;
3536     strnamept.Append("SBMss_pt");
3537     strnamept+=i;
3538
3539     strtitlept=titlehist;
3540     strtitlept.Append(" Side Bands, ");
3541     strtitlept+=fptbins[i];
3542     strtitlept.Append("<= pt <");
3543     strtitlept+=fptbins[i+1];
3544     strtitlept.Append(" [GeV/c]");
3545     
3546     hd0D0ptLSCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3547     hd0D0ptLSCfromDstSB->SetXTitle("Impact parameter [#mum] ");
3548     hd0D0ptLSCfromDstSB->SetYTitle("Entries");
3549     flistLsCutsFromDstar->Add(hd0D0ptLSCfromDstSB);
3550
3551     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3552     hMCd0D0ptLSCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3553     hMCd0D0ptLSCfromDstSB->SetXTitle("MC Impact parameter [#mum] ");
3554     hMCd0D0ptLSCfromDstSB->SetYTitle("Entries");
3555     flistLsCutsFromDstar->Add(hMCd0D0ptLSCfromDstSB);
3556
3557     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3558     hd0D0VtxTrueptLSCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3559     hd0D0VtxTrueptLSCfromDstSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3560     hd0D0VtxTrueptLSCfromDstSB->SetYTitle("Entries");
3561     flistLsCutsFromDstar->Add(hd0D0VtxTrueptLSCfromDstSB);
3562   }
3563
3564
3565   //############ LOOSE CUTS OTHER HISTOGRAMS ###########
3566   //
3567   //########### global properties histos ###########
3568
3569   TH2F *hCPtaVSd0d0LSCother=new TH2F("hCPtaVSd0d0LSCother","hCPtaVSd0d0_LooseCuts_other",1000,-100000.,100000.,100,-1.,1.);
3570   TH1F *hSecVtxZLSCother=new TH1F("hSecVtxZLSCother","hSecVtxZ_LooseCuts_other",1000,-8.,8.);
3571   TH1F *hSecVtxXLSCother=new TH1F("hSecVtxXLSCother","hSecVtxX_LooseCuts_other",1000,-3000.,3000.);
3572   TH1F *hSecVtxYLSCother=new TH1F("hSecVtxYLSCother","hSecVtxY_LooseCuts_other",1000,-3000.,3000.);
3573   TH2F *hSecVtxXYLSCother=new TH2F("hSecVtxXYLSCother","hSecVtxXY_LooseCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
3574   TH1F *hSecVtxPhiLSCother=new TH1F("hSecVtxPhiLSCother","hSecVtxPhi_LooseCuts_other",180,-180.1,180.1);
3575   TH1F *hd0singlTrackLSCother=new TH1F("hd0singlTrackLSCother","hd0singlTrackLooseCuts_Other",1000,-5000.,5000.);
3576   TH1F *hCPtaLSCother=new TH1F("hCPtaLSCother","hCPta_LooseCuts_other",100,-1.,1.);
3577   TH1F *hd0xd0LSCother=new TH1F("hd0xd0LSCother","hd0xd0_LooseCuts_other",1000,-100000.,100000.);
3578   TH1F *hMassTrueLSCother=new TH1F("hMassTrueLSCother","D^{0} MC inv. Mass Loose Cuts other(All momenta)",600,1.600,2.200);
3579   TH1F *hMassLSCother=new TH1F("hMassLSCother","D^{0} inv. Mass Loose Cuts other (All momenta)",600,1.600,2.200);
3580   hMassLSCother->Sumw2();
3581   TH1F *hMassTrueLSCotherPM=new TH1F("hMassTrueLSCotherPM","D^{0} MC inv. Mass Loose Cuts other, Mass Peak. (All momenta)",600,1.600,2.200);
3582   TH1F *hMassLSCotherPM=new TH1F("hMassLSCotherPM","D^{0} inv. Mass Loose Cuts other (All momenta), MassPeak",600,1.600,2.200);
3583   hMassLSCotherPM->Sumw2();
3584   TH1F *hMassTrueLSCotherSB=new TH1F("hMassTrueLSCotherSB","D^{0} MC inv. Mass in Side Bands Loose Cuts other(All momenta)",600,1.600,2.200);
3585   TH1F *hMassLSCotherSB=new TH1F("hMassLSCotherSB","D^{0} inv. Mass in Side Bands Loose Cuts other (All momenta)",600,1.600,2.200);
3586   hMassLSCotherSB->Sumw2();
3587
3588   flistLsCutsOther->Add(hCPtaVSd0d0LSCother);
3589   flistLsCutsOther->Add(hSecVtxZLSCother);
3590   flistLsCutsOther->Add(hSecVtxYLSCother);
3591   flistLsCutsOther->Add(hSecVtxXLSCother);
3592   flistLsCutsOther->Add(hSecVtxXYLSCother);
3593   flistLsCutsOther->Add(hSecVtxPhiLSCother);
3594   flistLsCutsOther->Add(hd0singlTrackLSCother);
3595   flistLsCutsOther->Add(hCPtaLSCother);
3596   flistLsCutsOther->Add(hd0xd0LSCother);
3597   flistLsCutsOther->Add(hMassTrueLSCother);
3598   flistLsCutsOther->Add(hMassLSCother);
3599   flistLsCutsOther->Add(hMassTrueLSCotherPM);
3600   flistLsCutsOther->Add(hMassLSCotherPM);
3601   flistLsCutsOther->Add(hMassTrueLSCotherSB);
3602   flistLsCutsOther->Add(hMassLSCotherSB);
3603
3604
3605
3606
3607  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
3608   TH1F *hdcaLSCother=new TH1F("hdcaLSCother","hdca_LooseCuts_Other",100,0.,1000.);
3609   hdcaLSCother->SetXTitle("dca   [#mum]");
3610   hdcaLSCother->SetYTitle("Entries");
3611   TH1F *hcosthetastarLSCother=new TH1F("hcosthetastarLSCother","hCosThetaStar_LooseCuts_Other",50,-1.,1.);
3612   hcosthetastarLSCother->SetXTitle("cos #theta^{*}");
3613   hcosthetastarLSCother->SetYTitle("Entries");
3614   TH1F *hptD0LSCother=new TH1F("hptD0LSCother","D^{0} transverse momentum distribution",34,ptbinsD0arr);
3615   hptD0LSCother->SetXTitle("p_{t}  [GeV/c]");
3616   hptD0LSCother->SetYTitle("Entries");
3617   TH1F *hptD0VsMaxPtLSCother=new TH1F("hptD0VsMaxPtLSCother","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
3618   TH2F *hptD0PTallsqrtLSCother=new TH2F("hptD0PTallsqrtLSCother","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
3619   TH2F *hptD0PTallLSCother=new TH2F("hptD0PTallLSCother","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
3620   TH2F *hptD0vsptBLSCother=new TH2F("hptD0vsptBLSCother","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3621   TH2F *hpD0vspBLSCother=new TH2F("hpD0vspBLSCother","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3622   TH2F *hptD0vsptcquarkLSCother=new TH2F("hptD0vsptcquarkLSCother","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3623   TH2F *hpD0vspcquarkLSCother=new TH2F("hpD0vspcquarkLSCother","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3624   flistLsCutsOther->Add(hdcaLSCother);
3625   flistLsCutsOther->Add(hcosthetastarLSCother);
3626   flistLsCutsOther->Add(hptD0LSCother);
3627   flistLsCutsOther->Add(hptD0VsMaxPtLSCother);
3628   flistLsCutsOther->Add(hptD0PTallsqrtLSCother);
3629   flistLsCutsOther->Add(hptD0PTallLSCother);
3630   flistLsCutsOther->Add(hptD0vsptBLSCother);
3631   flistLsCutsOther->Add(hpD0vspBLSCother);
3632   flistLsCutsOther->Add(hptD0vsptcquarkLSCother);
3633   flistLsCutsOther->Add(hpD0vspcquarkLSCother);
3634
3635   TH1F *hd0zD0ptLSCother;
3636   TH1F *hInvMassD0LSCother,*hInvMassD0barLSCother;
3637   TH2F *hInvMassPtLSCother=new TH2F("hInvMassPtLSCother","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
3638   THnSparseF *hSparseLSCother=new THnSparseF("hSparseLSCother","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
3639   hSparseLSCother->SetBinEdges(0,massbins);
3640   hSparseLSCother->SetBinEdges(1,massbins);
3641   hSparseLSCother->SetBinEdges(2,ptbinsForNsparse);
3642   hSparseLSCother->SetBinEdges(3,impparbins);
3643   hSparseLSCother->SetBinEdges(4,massHypoBins); 
3644   flistLsCutsOther->Add(hSparseLSCother);
3645   TH1F *hetaLSCother;
3646   TH1F *hCosPDPBLSCother;
3647   TH1F *hCosPcPDLSCother;
3648   flistLsCutsOther->Add(hInvMassPtLSCother);
3649  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3650   TH2F *hd0D0VSd0xd0LSCotherpt;
3651   TH2F *hangletracksVSd0xd0LSCotherpt;
3652   TH2F *hangletracksVSd0D0LSCotherpt;
3653   TH1F *hd0xd0LSCotherpt;
3654
3655   TH2F *hTOFpidLSCother=new TH2F("hTOFpidLSCother","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
3656   flistLsCutsOther->Add(hTOFpidLSCother);
3657
3658   for(Int_t i=0;i<fnbins;i++){
3659     namehist="hd0zD0ptLSCother_pt";
3660     namehist+=i;
3661     titlehist="d0(z) Loose Cuts Otherm ptbin=";
3662     titlehist+=i;
3663     hd0zD0ptLSCother=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
3664     hd0zD0ptLSCother->SetXTitle("d_{0}(z)    [#mum]");
3665     hd0zD0ptLSCother->SetYTitle("Entries");
3666     flistLsCutsOther->Add(hd0zD0ptLSCother);
3667
3668     namehist="hInvMassD0LSCother_pt";
3669     namehist+=i;
3670     titlehist="Invariant Mass Loose Cuts Other ptbin=";
3671     titlehist+=i;
3672     hInvMassD0LSCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3673     hInvMassD0LSCother->SetXTitle("Invariant Mass    [GeV]");
3674     hInvMassD0LSCother->SetYTitle("Entries");
3675     flistLsCutsOther->Add(hInvMassD0LSCother);
3676
3677     namehist="hInvMassD0barLSCother_pt";
3678     namehist+=i;
3679     titlehist="Invariant Mass D0bar Loose Cuts Other ptbin=";
3680     titlehist+=i;
3681     hInvMassD0barLSCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
3682     hInvMassD0barLSCother->SetXTitle("Invariant Mass    [GeV]");
3683     hInvMassD0barLSCother->SetYTitle("Entries");
3684     flistLsCutsOther->Add(hInvMassD0barLSCother);
3685
3686     namehist="hetaLSCother_pt";
3687     namehist+=i;
3688     titlehist="eta Loose Cuts Other ptbin=";
3689     titlehist+=i;
3690     hetaLSCother=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
3691     hetaLSCother->SetXTitle("Pseudorapidity");
3692     hetaLSCother->SetYTitle("Entries");
3693     flistLsCutsOther->Add(hetaLSCother);
3694
3695     namehist="hCosPDPBLSCother_pt";
3696     namehist+=i;
3697     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
3698     titlehist+=i;
3699     hCosPDPBLSCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3700     hCosPDPBLSCother->SetXTitle("Cosine between D0 momentum and B momentum");
3701     hCosPDPBLSCother->SetYTitle("Entries");
3702     flistLsCutsOther->Add(hCosPDPBLSCother);
3703
3704     namehist="hCosPcPDLSCother_pt";
3705     namehist+=i;
3706     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
3707     titlehist+=i;
3708     hCosPcPDLSCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
3709     hCosPcPDLSCother->SetXTitle("Cosine between c quark momentum and D0 momentum");
3710     hCosPcPDLSCother->SetYTitle("Entries");
3711     flistLsCutsOther->Add(hCosPcPDLSCother);
3712
3713  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3714     namehist="hd0xd0LSCother_pt";
3715     namehist+=i;
3716     titlehist="d0xd0 Loose Cuts Other ptbin=";
3717     titlehist+=i;
3718     hd0xd0LSCotherpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
3719     hd0xd0LSCotherpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
3720     hd0xd0LSCotherpt->SetYTitle("Entries");
3721     flistLsCutsOther->Add(hd0xd0LSCotherpt);
3722
3723
3724     namehist="hd0D0VSd0xd0LSCother_pt";
3725     namehist+=i;
3726     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Other ptbin=";
3727     titlehist+=i;
3728     hd0D0VSd0xd0LSCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
3729     hd0D0VSd0xd0LSCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3730     hd0D0VSd0xd0LSCotherpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
3731     flistLsCutsOther->Add(hd0D0VSd0xd0LSCotherpt);
3732     
3733     
3734     namehist="hangletracksVSd0xd0LSCother_pt";
3735     namehist+=i;
3736     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Loose Cuts Other ptbin=";
3737     titlehist+=i;
3738     hangletracksVSd0xd0LSCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
3739     hangletracksVSd0xd0LSCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
3740     hangletracksVSd0xd0LSCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
3741     flistLsCutsOther->Add(hangletracksVSd0xd0LSCotherpt);
3742     
3743
3744     namehist="hangletracksVSd0D0LSCother_pt";
3745     namehist+=i;
3746     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Loose Cuts Other ptbin=";
3747     titlehist+=i;
3748     hangletracksVSd0D0LSCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
3749     hangletracksVSd0D0LSCotherpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
3750     hangletracksVSd0D0LSCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
3751     flistLsCutsOther->Add(hangletracksVSd0D0LSCotherpt);
3752
3753     
3754   }
3755   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
3756   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3757
3758
3759
3760   //############# d0 D0 histos ###############à
3761   TH1F *hd0D0LSCotherPM = new TH1F("hd0D0LSCotherPM","D^{0} impact par. plot , Loose Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
3762   hd0D0LSCotherPM->SetXTitle("Impact parameter [#mum]");
3763   hd0D0LSCotherPM->SetYTitle("Entries");
3764
3765   TH1F *hd0D0VtxTrueLSCotherPM = new TH1F("hd0D0VtxTrueLSCotherPM","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
3766   hd0D0VtxTrueLSCotherPM->SetXTitle("Impact parameter [#mum]");
3767   hd0D0VtxTrueLSCotherPM->SetYTitle("Entries");
3768
3769   TH1F *hMCd0D0LSCotherPM = new TH1F("hMCd0D0LSCotherPM","D^{0} impact par. plot, Loose Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
3770   hMCd0D0LSCotherPM->SetXTitle("MC Impact parameter [#mum]");
3771   hMCd0D0LSCotherPM->SetYTitle("Entries");
3772
3773   TH1F *hd0D0LSCotherSB = new TH1F("hd0D0LSCotherSB","D^{0} impact par. plot , Loose Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
3774   hd0D0LSCotherSB->SetXTitle("Impact parameter [#mum]");
3775   hd0D0LSCotherSB->SetYTitle("Entries");
3776
3777   TH1F *hd0D0VtxTrueLSCotherSB = new TH1F("hd0D0VtxTrueLSCotherSB","D^{0} impact par. w.r.t. True Vtx, Loose Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
3778   hd0D0VtxTrueLSCotherSB->SetXTitle("Impact parameter [#mum]");
3779   hd0D0VtxTrueLSCotherSB->SetYTitle("Entries");
3780
3781   TH1F *hMCd0D0LSCotherSB = new TH1F("hMCd0D0LSCotherSB","D^{0} impact par. plot, Loose Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
3782   hMCd0D0LSCotherSB->SetXTitle("MC Impact parameter [#mum]");
3783   hMCd0D0LSCotherSB->SetYTitle("Entries");
3784
3785   flistLsCutsOther->Add(hd0D0LSCotherPM);
3786   flistLsCutsOther->Add(hd0D0VtxTrueLSCotherPM);
3787   flistLsCutsOther->Add(hMCd0D0LSCotherPM);
3788   flistLsCutsOther->Add(hd0D0LSCotherSB);
3789   flistLsCutsOther->Add(hd0D0VtxTrueLSCotherSB);
3790   flistLsCutsOther->Add(hMCd0D0LSCotherSB);
3791   
3792   TH1F *hd0D0ptLSCotherPM;
3793   TH1F *hMCd0D0ptLSCotherPM;
3794   TH1F *hd0D0VtxTrueptLSCotherPM;
3795   TH1F *hd0D0ptLSCotherSB;
3796   TH1F *hMCd0D0ptLSCotherSB;
3797   TH1F *hd0D0VtxTrueptLSCotherSB;
3798   namehist="hd0D0ptLSCother_";
3799   titlehist="D^{0} impact par. plot, Loose Cuts, Other, ";
3800   for(Int_t i=0;i<fnbins;i++){
3801     strnamept=namehist;
3802     strnamept.Append("PkMss_pt");
3803     strnamept+=i;
3804
3805     strtitlept=titlehist;
3806     strtitlept.Append(" Mass Peak, ");
3807     strtitlept+=fptbins[i];
3808     strtitlept.Append("<= pt <");
3809     strtitlept+=fptbins[i+1];
3810     strtitlept.Append(" [GeV/c]");
3811     
3812     hd0D0ptLSCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3813     hd0D0ptLSCotherPM->SetXTitle("Impact parameter [#mum] ");
3814     hd0D0ptLSCotherPM->SetYTitle("Entries");
3815     flistLsCutsOther->Add(hd0D0ptLSCotherPM);
3816
3817     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3818     hMCd0D0ptLSCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3819     hMCd0D0ptLSCotherPM->SetXTitle("MC Impact parameter [#mum] ");
3820     hMCd0D0ptLSCotherPM->SetYTitle("Entries");
3821     flistLsCutsOther->Add(hMCd0D0ptLSCotherPM);
3822  
3823
3824     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3825     hd0D0VtxTrueptLSCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3826     hd0D0VtxTrueptLSCotherPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3827     hd0D0VtxTrueptLSCotherPM->SetYTitle("Entries");
3828     flistLsCutsOther->Add(hd0D0VtxTrueptLSCotherPM);
3829     
3830     strnamept=namehist;
3831     strnamept.Append("SBMss_pt");
3832     strnamept+=i;
3833
3834     strtitlept=titlehist;
3835     strtitlept.Append(" Side Bands, ");
3836     strtitlept+=fptbins[i];
3837     strtitlept.Append("<= pt <");
3838     strtitlept+=fptbins[i+1];
3839     strtitlept.Append(" [GeV/c]");
3840     
3841     hd0D0ptLSCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3842     hd0D0ptLSCotherSB->SetXTitle("Impact parameter [#mum] ");
3843     hd0D0ptLSCotherSB->SetYTitle("Entries");
3844     flistLsCutsOther->Add(hd0D0ptLSCotherSB);
3845
3846     strnamept.ReplaceAll("hd0D0","hMCd0D0");
3847     hMCd0D0ptLSCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3848     hMCd0D0ptLSCotherSB->SetXTitle("MC Impact parameter [#mum] ");
3849     hMCd0D0ptLSCotherSB->SetYTitle("Entries");
3850     flistLsCutsOther->Add(hMCd0D0ptLSCotherSB);
3851
3852     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
3853     hd0D0VtxTrueptLSCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
3854     hd0D0VtxTrueptLSCotherSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
3855     hd0D0VtxTrueptLSCotherSB->SetYTitle("Entries");
3856     flistLsCutsOther->Add(hd0D0VtxTrueptLSCotherSB);
3857   }
3858
3859   //Printf("END OF LSCUTS HISTOS CREATION \n");
3860
3861
3862   //################################################################################################
3863   //                                                                                               #
3864   //                         HISTOS FOR TIGHT CUTS                                                 #
3865   //                                                                                               #
3866   //################################################################################################
3867
3868   //############ TIGHT CUTS SIGNAL HISTOGRAMS ###############
3869   //
3870   // ####### global properties histo ############
3871
3872   TH2F *hCPtaVSd0d0TGHCsign=new TH2F("hCPtaVSd0d0TGHCsign","hCPtaVSd0d0_TightCuts_Signal",1000,-100000.,100000.,100,-1.,1.);
3873   TH1F *hSecVtxZTGHCsign=new TH1F("hSecVtxZTGHCsign","hSecVtxZ_TightCuts_Signal",1000,-8.,8.);
3874   TH1F *hSecVtxXTGHCsign=new TH1F("hSecVtxXTGHCsign","hSecVtxX_TightCuts_Signal",1000,-3000.,3000.);
3875   TH1F *hSecVtxYTGHCsign=new TH1F("hSecVtxYTGHCsign","hSecVtxY_TightCuts_Signal",1000,-3000.,3000.);
3876   TH2F *hSecVtxXYTGHCsign=new TH2F("hSecVtxXYTGHCsign","hSecVtxXY_TightCuts_Signal",1000,-3000.,3000.,1000,-3000.,3000.);
3877   TH1F *hSecVtxPhiTGHCsign=new TH1F("hSecVtxPhiTGHCsign","hSecVtxPhi_TightCuts_Signal",180,-180.1,180.1);
3878   TH1F *hd0singlTrackTGHCsign=new TH1F("hd0singlTrackTGHCsign","hd0singlTrackTightCuts_Signal",1000,-5000.,5000.);
3879   TH1F *hCPtaTGHCsign=new TH1F("hCPtaTGHCsign","hCPta_TightCuts_Signal",100,-1.,1.);
3880   TH1F *hd0xd0TGHCsign=new TH1F("hd0xd0TGHCsign","hd0xd0_TightCuts_Signal",1000,-100000.,100000.);
3881   TH1F *hMassTrueTGHCsign=new TH1F("hMassTrueTGHCsign","D^{0} MC inv. Mass Tight Cuts Signal(All momenta)",600,1.600,2.200);
3882   TH1F *hMassTGHCsign=new TH1F("hMassTGHCsign","D^{0} inv. Mass Tight Cuts Signal (All momenta)",600,1.600,2.200);
3883   hMassTGHCsign->Sumw2();
3884   TH1F *hMassTrueTGHCsignPM=new TH1F("hMassTrueTGHCsignPM","D^{0} MC inv. Mass Tight Cuts Signal, Mass Peak. (All momenta)",600,1.600,2.200);
3885   TH1F *hMassTGHCsignPM=new TH1F("hMassTGHCsignPM","D^{0} inv. Mass Tight Cuts Signal (All momenta), MassPeak",600,1.600,2.200);
3886   hMassTGHCsignPM->Sumw2();
3887   TH1F *hMassTrueTGHCsignSB=new TH1F("hMassTrueTGHCsignSB","D^{0} MC inv. Mass in Side Bands Tight Cuts Signal(All momenta)",600,1.600,2.200);
3888   TH1F *hMassTGHCsignSB=new TH1F("hMassTGHCsignSB","D^{0} inv. Mass in Side Bands Tight Cuts Signal (All momenta)",600,1.600,2.200);
3889   hMassTGHCsignSB->Sumw2();
3890
3891   flistTghCutsSignal->Add(hCPtaVSd0d0TGHCsign);
3892   flistTghCutsSignal->Add(hSecVtxZTGHCsign);
3893   flistTghCutsSignal->Add(hSecVtxYTGHCsign);
3894   flistTghCutsSignal->Add(hSecVtxXTGHCsign);
3895   flistTghCutsSignal->Add(hSecVtxXYTGHCsign);
3896   flistTghCutsSignal->Add(hSecVtxPhiTGHCsign);
3897   flistTghCutsSignal->Add(hd0singlTrackTGHCsign);
3898   flistTghCutsSignal->Add(hCPtaTGHCsign);
3899   flistTghCutsSignal->Add(hd0xd0TGHCsign);
3900   flistTghCutsSignal->Add(hMassTrueTGHCsign);
3901   flistTghCutsSignal->Add(hMassTGHCsign);
3902   flistTghCutsSignal->Add(hMassTrueTGHCsignPM);
3903   flistTghCutsSignal->Add(hMassTGHCsignPM);
3904   flistTghCutsSignal->Add(hMassTrueTGHCsignSB);
3905   flistTghCutsSignal->Add(hMassTGHCsignSB);
3906
3907
3908
3909
3910
3911
3912  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
3913   TH1F *hdcaTGHCsign=new TH1F("hdcaTGHCsign","hdca_TightCuts_Signal",100,0.,1000.);
3914   hdcaTGHCsign->SetXTitle("dca   [#mum]");
3915   hdcaTGHCsign->SetYTitle("Entries");
3916   TH1F *hcosthetastarTGHCsign=new TH1F("hcosthetastarTGHCsign","hCosThetaStar_TightCuts_Signal",50,-1.,1.);
3917   hcosthetastarTGHCsign->SetXTitle("cos #theta^{*}");
3918   hcosthetastarTGHCsign->SetYTitle("Entries");
3919   TH1F *hptD0TGHCsign=new TH1F("hptD0TGHCsign","D^{0} transverse momentum distribution",34,ptbinsD0arr);
3920   hptD0TGHCsign->SetXTitle("p_{t}  [GeV/c]");
3921   hptD0TGHCsign->SetYTitle("Entries");
3922   TH1F *hptD0VsMaxPtTGHCsign=new TH1F("hptD0VsMaxPtTGHCsign","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
3923   TH2F *hptD0PTallsqrtTGHCsign=new TH2F("hptD0PTallsqrtTGHCsign","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
3924   TH2F *hptD0PTallTGHCsign=new TH2F("hptD0PTallTGHCsign","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
3925   TH2F *hptD0vsptBTGHCsign=new TH2F("hptD0vsptBTGHCsign","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3926   TH2F *hpD0vspBTGHCsign=new TH2F("hpD0vspBTGHCsign","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3927   TH2F *hptD0vsptcquarkTGHCsign=new TH2F("hptD0vsptcquarkTGHCsign","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3928   TH2F *hpD0vspcquarkTGHCsign=new TH2F("hpD0vspcquarkTGHCsign","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
3929   flistTghCutsSignal->Add(hdcaTGHCsign);
3930   flistTghCutsSignal->Add(hcosthetastarTGHCsign);
3931   flistTghCutsSignal->Add(hptD0TGHCsign);
3932   flistTghCutsSignal->Add(hptD0VsMaxPtTGHCsign);
3933   flistTghCutsSignal->Add(hptD0PTallsqrtTGHCsign);
3934   flistTghCutsSignal->Add(hptD0PTallTGHCsign);
3935   flistTghCutsSignal->Add(hptD0vsptBTGHCsign);
3936   flistTghCutsSignal->Add(hpD0vspBTGHCsign);
3937   flistTghCutsSignal->Add(hptD0vsptcquarkTGHCsign);
3938   flistTghCutsSignal->Add(hpD0vspcquarkTGHCsign);
3939  
3940   TH1F *hd0zD0ptTGHCsign;
3941   TH1F *hInvMassD0TGHCsign,*hInvMassD0barTGHCsign;
3942   TH2F *hInvMassPtTGHCsign=new TH2F("hInvMassPtTGHCsign","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
3943   TH3F *hInvMassPtSelSignOnlyTGHCsign=new TH3F("hInvMassPtSelSignOnlyTGHCsign","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3944   flistTghCutsSignal->Add(hInvMassPtSelSignOnlyTGHCsign);
3945   TH3F *hInvMassPtSelReflOnlyTGHCsign=new TH3F("hInvMassPtSelReflOnlyTGHCsign","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
3946   flistTghCutsSignal->Add(hInvMassPtSelReflOnlyTGHCsign);
3947
3948
3949   THnSparseF *hSparseTGHCsign=new THnSparseF("hSparseTGHCsign","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
3950   hSparseTGHCsign->SetBinEdges(0,massbins);
3951   hSparseTGHCsign->SetBinEdges(1,massbins);
3952   hSparseTGHCsign->SetBinEdges(2,ptbinsForNsparse);
3953   hSparseTGHCsign->SetBinEdges(3,impparbins);
3954   hSparseTGHCsign->SetBinEdges(4,massHypoBins); 
3955   flistTghCutsSignal->Add(hSparseTGHCsign);
3956
3957
3958   THnSparseF *hSparseCxyLxyTGHCsign=new THnSparseF("hSparseCxyLxyTGHCsign","Candidate Mass;massD0;Pt;CosXY;Lxy",4,nbinsSparsCxyLxy,binLowLimitSparseCxyLxy,binUpLimitSparseCxyLxy);
3959   hSparseCxyLxyTGHCsign->SetBinEdges(1,ptbinlimitsCxyLxy);
3960   hSparseCxyLxyTGHCsign->GetAxis(0)->SetName("mass");
3961   hSparseCxyLxyTGHCsign->GetAxis(0)->SetTitle("Invariant Mass (K#pi) [GeV/c^{2}]");
3962   hSparseCxyLxyTGHCsign->GetAxis(1)->SetName("pt");
3963   hSparseCxyLxyTGHCsign->GetAxis(1)->SetTitle("p_{t} [GeV/c]");
3964   hSparseCxyLxyTGHCsign->GetAxis(2)->SetName("CosPointXY");
3965   hSparseCxyLxyTGHCsign->GetAxis(2)->SetTitle("Cos#theta_{point}^{XY}");
3966   hSparseCxyLxyTGHCsign->GetAxis(3)->SetName("NormDecLengthXY");
3967   hSparseCxyLxyTGHCsign->GetAxis(3)->SetTitle("Normalized XY decay length");
3968
3969
3970   flistTghCutsSignal->Add(hSparseCxyLxyTGHCsign);
3971   
3972   
3973   TH1F *hetaTGHCsign;
3974   TH1F *hCosPDPBTGHCsign;
3975   TH1F *hCosPcPDTGHCsign;
3976   flistTghCutsSignal->Add(hInvMassPtTGHCsign);
3977 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
3978   TH2F *hd0D0VSd0xd0TGHCsignpt;
3979   TH2F *hangletracksVSd0xd0TGHCsignpt;
3980   TH2F *hangletracksVSd0D0TGHCsignpt;
3981   TH1F *hd0xd0TGHCsignpt;
3982   TH1F *hPhiHistPMTGHCsignpt,*hPhiHistSBTGHCsignpt;
3983
3984   TH2F *hTOFpidTGHCsign=new TH2F("hTOFpidTGHCsign","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
3985   flistTghCutsSignal->Add(hTOFpidTGHCsign);
3986
3987   for(Int_t i=0;i<fnbins;i++){
3988     // Printf("INSIDE FIRST LOOP FOR  TIGHT CUTS HISTO CREATION %d\n", fnbins);
3989     namehist="hPhiHistPMTGHCsign_pt";
3990     namehist+=i;
3991     titlehist="Azimuthal correlation TGH Cuts Sign PM ptbin=";
3992     titlehist+=i;
3993     hPhiHistPMTGHCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
3994     hPhiHistPMTGHCsignpt->Sumw2();
3995     flistTghCutsSignal->Add(hPhiHistPMTGHCsignpt);
3996
3997     namehist="hPhiHistSBTGHCsign_pt";
3998     namehist+=i;
3999     titlehist="Azimuthal correlation TGH Cuts Sign SB ptbin=";
4000     titlehist+=i;
4001     hPhiHistSBTGHCsignpt=new TH1F(namehist.Data(),titlehist.Data(),100,-3.15,3.15);
4002     hPhiHistSBTGHCsignpt->Sumw2();
4003     flistTghCutsSignal->Add(hPhiHistSBTGHCsignpt);
4004
4005     namehist="hd0zD0ptTGHCsign_pt";
4006     namehist+=i;
4007     titlehist="d0(z) Tight Cuts Signal ptbin=";
4008     titlehist+=i;
4009     hd0zD0ptTGHCsign=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
4010     hd0zD0ptTGHCsign->SetXTitle("d_{0}(z)    [#mum]");
4011     hd0zD0ptTGHCsign->SetYTitle("Entries");
4012     flistTghCutsSignal->Add(hd0zD0ptTGHCsign);
4013
4014     namehist="hInvMassD0TGHCsign_pt";
4015     namehist+=i;
4016     titlehist="Invariant Mass Tight Cuts Signal ptbin=";
4017     titlehist+=i;
4018     hInvMassD0TGHCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4019     hInvMassD0TGHCsign->SetXTitle("Invariant Mass    [GeV]");
4020     hInvMassD0TGHCsign->SetYTitle("Entries");
4021     flistTghCutsSignal->Add(hInvMassD0TGHCsign);
4022
4023     namehist="hInvMassD0barTGHCsign_pt";
4024     namehist+=i;
4025     titlehist="Invariant Mass D0bar Tight Cuts Signal ptbin=";
4026     titlehist+=i;
4027     hInvMassD0barTGHCsign=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4028     hInvMassD0barTGHCsign->SetXTitle("Invariant Mass    [GeV]");
4029     hInvMassD0barTGHCsign->SetYTitle("Entries");
4030     flistTghCutsSignal->Add(hInvMassD0barTGHCsign);
4031
4032
4033     namehist="hetaTGHCsign_pt";
4034     namehist+=i;
4035     titlehist="eta Tight Cuts Signal ptbin=";
4036     titlehist+=i;
4037     hetaTGHCsign=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
4038     hetaTGHCsign->SetXTitle("Pseudorapidity");
4039     hetaTGHCsign->SetYTitle("Entries");
4040     flistTghCutsSignal->Add(hetaTGHCsign);
4041
4042     namehist="hCosPDPBTGHCsign_pt";
4043     namehist+=i;
4044     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
4045     titlehist+=i;
4046     hCosPDPBTGHCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4047     hCosPDPBTGHCsign->SetXTitle("Cosine between D0 momentum and B momentum");
4048     hCosPDPBTGHCsign->SetYTitle("Entries");
4049     flistTghCutsSignal->Add(hCosPDPBTGHCsign);
4050
4051     namehist="hCosPcPDTGHCsign_pt";
4052     namehist+=i;
4053     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
4054     titlehist+=i;
4055     hCosPcPDTGHCsign=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4056     hCosPcPDTGHCsign->SetXTitle("Cosine between c quark momentum and D0 momentum");
4057     hCosPcPDTGHCsign->SetYTitle("Entries");
4058     flistTghCutsSignal->Add(hCosPcPDTGHCsign);
4059    
4060  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4061     namehist="hd0xd0TGHCsign_pt";
4062     namehist+=i;
4063     titlehist="d0xd0 Tight Cuts Signal ptbin=";
4064     titlehist+=i;
4065     hd0xd0TGHCsignpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
4066     hd0xd0TGHCsignpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
4067     hd0xd0TGHCsignpt->SetYTitle("Entries");
4068     flistTghCutsSignal->Add(hd0xd0TGHCsignpt);
4069
4070
4071     namehist="hd0D0VSd0xd0TGHCsign_pt";
4072     namehist+=i;
4073     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Signal ptbin=";
4074     titlehist+=i;
4075     hd0D0VSd0xd0TGHCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
4076     hd0D0VSd0xd0TGHCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4077     hd0D0VSd0xd0TGHCsignpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
4078     flistTghCutsSignal->Add(hd0D0VSd0xd0TGHCsignpt);
4079     
4080     
4081     namehist="hangletracksVSd0xd0TGHCsign_pt";
4082     namehist+=i;
4083     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Signal ptbin=";
4084     titlehist+=i;
4085     hangletracksVSd0xd0TGHCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
4086     hangletracksVSd0xd0TGHCsignpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4087     hangletracksVSd0xd0TGHCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
4088     flistTghCutsSignal->Add(hangletracksVSd0xd0TGHCsignpt);
4089     
4090
4091     namehist="hangletracksVSd0D0TGHCsign_pt";
4092     namehist+=i;
4093     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Tight Cuts Signal ptbin=";
4094     titlehist+=i;
4095     hangletracksVSd0D0TGHCsignpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
4096     hangletracksVSd0D0TGHCsignpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
4097     hangletracksVSd0D0TGHCsignpt->SetYTitle(" angle between K and #p tracks  [rad]");
4098     flistTghCutsSignal->Add(hangletracksVSd0D0TGHCsignpt);
4099
4100   }
4101   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
4102   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4103
4104
4105
4106
4107
4108
4109
4110
4111   // ####### d0 D0 histos ############
4112   TH1F *hd0D0TGHCsignPM = new TH1F("hd0D0TGHCsignPM","D^{0} impact par. plot , Tight Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
4113   hd0D0TGHCsignPM->SetXTitle("Impact parameter [#mum]");
4114   hd0D0TGHCsignPM->SetYTitle("Entries");
4115
4116   TH1F *hd0D0VtxTrueTGHCsignPM = new TH1F("hd0D0VtxTrueTGHCsignPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
4117   hd0D0VtxTrueTGHCsignPM->SetXTitle("Impact parameter [#mum]");
4118   hd0D0VtxTrueTGHCsignPM->SetYTitle("Entries");
4119
4120   TH1F *hMCd0D0TGHCsignPM = new TH1F("hMCd0D0TGHCsignPM","D^{0} impact par. plot, Tight Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
4121   hMCd0D0TGHCsignPM->SetXTitle("MC Impact parameter [#mum]");
4122   hMCd0D0TGHCsignPM->SetYTitle("Entries");
4123
4124   TH1F *hd0D0TGHCsignSB = new TH1F("hd0D0TGHCsignSB","D^{0} impact par. plot , Tight Cuts ,Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
4125   hd0D0TGHCsignSB->SetXTitle("Impact parameter [#mum]");
4126   hd0D0TGHCsignSB->SetYTitle("Entries");
4127
4128   TH1F *hd0D0VtxTrueTGHCsignSB = new TH1F("hd0D0VtxTrueTGHCsignSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Signal,Mass Peak (All momenta)",1000,-1000.,1000.);
4129   hd0D0VtxTrueTGHCsignSB->SetXTitle("Impact parameter [#mum]");
4130   hd0D0VtxTrueTGHCsignSB->SetYTitle("Entries");
4131
4132   TH1F *hMCd0D0TGHCsignSB = new TH1F("hMCd0D0TGHCsignSB","D^{0} impact par. plot, Tight Cuts, Signal,Mass Peak  (All momenta)",1000,-1000.,1000.);
4133   hMCd0D0TGHCsignSB->SetXTitle("MC Impact parameter [#mum]");
4134   hMCd0D0TGHCsignSB->SetYTitle("Entries");
4135
4136   flistTghCutsSignal->Add(hd0D0TGHCsignPM);
4137   flistTghCutsSignal->Add(hd0D0VtxTrueTGHCsignPM);
4138   flistTghCutsSignal->Add(hMCd0D0TGHCsignPM);
4139   flistTghCutsSignal->Add(hd0D0TGHCsignSB);
4140   flistTghCutsSignal->Add(hd0D0VtxTrueTGHCsignSB);
4141   flistTghCutsSignal->Add(hMCd0D0TGHCsignSB);
4142   
4143   TH1F *hd0D0ptTGHCsignPM;
4144   TH1F *hMCd0D0ptTGHCsignPM;
4145   TH1F *hd0D0VtxTrueptTGHCsignPM;
4146   TH1F *hd0D0ptTGHCsignSB;
4147   TH1F *hMCd0D0ptTGHCsignSB;
4148   TH1F *hd0D0VtxTrueptTGHCsignSB;
4149   namehist="hd0D0ptTGHCsign_";
4150   titlehist="D^{0} impact par. plot, Tight Cuts, Signal, ";
4151   for(Int_t i=0;i<fnbins;i++){
4152     strnamept=namehist;
4153     strnamept.Append("PkMss_pt");
4154     strnamept+=i;
4155
4156     strtitlept=titlehist;
4157     strtitlept.Append(" Mass Peak, ");
4158     strtitlept+=fptbins[i];
4159     strtitlept.Append("<= pt <");
4160     strtitlept+=fptbins[i+1];
4161     strtitlept.Append(" [GeV/c]");
4162     
4163     hd0D0ptTGHCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4164     hd0D0ptTGHCsignPM->SetXTitle("Impact parameter [#mum] ");
4165     hd0D0ptTGHCsignPM->SetYTitle("Entries");
4166     flistTghCutsSignal->Add(hd0D0ptTGHCsignPM);
4167
4168     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4169     hMCd0D0ptTGHCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4170     hMCd0D0ptTGHCsignPM->SetXTitle("MC Impact parameter [#mum] ");
4171     hMCd0D0ptTGHCsignPM->SetYTitle("Entries");
4172     flistTghCutsSignal->Add(hMCd0D0ptTGHCsignPM);
4173  
4174
4175     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4176     hd0D0VtxTrueptTGHCsignPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4177     hd0D0VtxTrueptTGHCsignPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4178     hd0D0VtxTrueptTGHCsignPM->SetYTitle("Entries");
4179     flistTghCutsSignal->Add(hd0D0VtxTrueptTGHCsignPM);
4180     
4181     strnamept=namehist;
4182     strnamept.Append("SBMss_pt");
4183     strnamept+=i;
4184
4185     strtitlept=titlehist;
4186     strtitlept.Append(" Side Bands, ");
4187     strtitlept+=fptbins[i];
4188     strtitlept.Append("<= pt <");
4189     strtitlept+=fptbins[i+1];
4190     strtitlept.Append(" [GeV/c]");
4191     
4192     hd0D0ptTGHCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4193     hd0D0ptTGHCsignSB->SetXTitle("Impact parameter [#mum] ");
4194     hd0D0ptTGHCsignSB->SetYTitle("Entries");
4195     flistTghCutsSignal->Add(hd0D0ptTGHCsignSB);
4196
4197     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4198     hMCd0D0ptTGHCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4199     hMCd0D0ptTGHCsignSB->SetXTitle("MC Impact parameter [#mum] ");
4200     hMCd0D0ptTGHCsignSB->SetYTitle("Entries");
4201     flistTghCutsSignal->Add(hMCd0D0ptTGHCsignSB);
4202
4203     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4204     hd0D0VtxTrueptTGHCsignSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4205     hd0D0VtxTrueptTGHCsignSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4206     hd0D0VtxTrueptTGHCsignSB->SetYTitle("Entries");
4207     flistTghCutsSignal->Add(hd0D0VtxTrueptTGHCsignSB);
4208   }
4209
4210
4211   //############ TIGHT CUTS BACKGROUND HISTOGRAMS ###########
4212   //
4213   //   ######## global properties histos #######
4214   TH2F *hCPtaVSd0d0TGHCback=new TH2F("hCPtaVSd0d0TGHCback","hCPtaVSd0d0_TightCuts_Background",1000,-100000.,100000.,100,-1.,1.);
4215   TH1F *hSecVtxZTGHCback=new TH1F("hSecVtxZTGHCback","hSecVtxZ_TightCuts_Background",1000,-8.,8.);
4216   TH1F *hSecVtxXTGHCback=new TH1F("hSecVtxXTGHCback","hSecVtxX_TightCuts_Background",1000,-3000.,3000.);
4217   TH1F *hSecVtxYTGHCback=new TH1F("hSecVtxYTGHCback","hSecVtxY_TightCuts_Background",1000,-3000.,3000.);
4218   TH2F *hSecVtxXYTGHCback=new TH2F("hSecVtxXYTGHCback","hSecVtxXY_TightCuts_Background",1000,-3000.,3000.,1000,-3000.,3000.);
4219   TH1F *hSecVtxPhiTGHCback=new TH1F("hSecVtxPhiTGHCback","hSecVtxPhi_TightCuts_Background",180,-180.1,180.1);
4220   TH1F *hd0singlTrackTGHCback=new TH1F("hd0singlTrackTGHCback","hd0singlTrackTightCuts_Back",1000,-5000.,5000.);
4221   TH1F *hCPtaTGHCback=new TH1F("hCPtaTGHCback","hCPta_TightCuts_Background",100,-1.,1.);
4222   TH1F *hd0xd0TGHCback=new TH1F("hd0xd0TGHCback","hd0xd0_TightCuts_Background",1000,-100000.,100000.);
4223   TH1F *hMassTrueTGHCback=new TH1F("hMassTrueTGHCback","D^{0} MC inv. Mass Tight Cuts Background(All momenta)",600,1.600,2.200);
4224   TH1F *hMassTGHCback=new TH1F("hMassTGHCback","D^{0} inv. Mass Tight Cuts Background (All momenta)",600,1.600,2.200);
4225   hMassTGHCback->Sumw2();
4226   TH1F *hMassTrueTGHCbackPM=new TH1F("hMassTrueTGHCbackPM","D^{0} MC inv. Mass Tight Cuts Background, Mass Peak. (All momenta)",600,1.600,2.200);
4227   TH1F *hMassTGHCbackPM=new TH1F("hMassTGHCbackPM","D^{0} inv. Mass Tight Cuts Background (All momenta), MassPeak",600,1.600,2.200);
4228   hMassTGHCbackPM->Sumw2();
4229   TH1F *hMassTrueTGHCbackSB=new TH1F("hMassTrueTGHCbackSB","D^{0} MC inv. Mass in Side Bands Tight Cuts Backgrround(All momenta)",600,1.600,2.200);
4230   TH1F *hMassTGHCbackSB=new TH1F("hMassTGHCbackSB","D^{0} inv. Mass in Side Bands Tight Cuts Background (All momenta)",600,1.600,2.200);
4231   hMassTGHCbackSB->Sumw2();
4232
4233   flistTghCutsBack->Add(hCPtaVSd0d0TGHCback);
4234   flistTghCutsBack->Add(hSecVtxZTGHCback);
4235   flistTghCutsBack->Add(hSecVtxYTGHCback);
4236   flistTghCutsBack->Add(hSecVtxXTGHCback);
4237   flistTghCutsBack->Add(hSecVtxXYTGHCback);
4238   flistTghCutsBack->Add(hSecVtxPhiTGHCback);
4239   flistTghCutsBack->Add(hd0singlTrackTGHCback);
4240   flistTghCutsBack->Add(hCPtaTGHCback);
4241   flistTghCutsBack->Add(hd0xd0TGHCback);
4242   flistTghCutsBack->Add(hMassTrueTGHCback);
4243   flistTghCutsBack->Add(hMassTGHCback);
4244   flistTghCutsBack->Add(hMassTrueTGHCbackPM);
4245   flistTghCutsBack->Add(hMassTGHCbackPM);
4246   flistTghCutsBack->Add(hMassTrueTGHCbackSB);
4247   flistTghCutsBack->Add(hMassTGHCbackSB);
4248
4249
4250
4251
4252
4253
4254
4255  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
4256   TH1F *hdcaTGHCback=new TH1F("hdcaTGHCback","hdca_TightCuts_Backgr",100,0.,1000.);
4257   hdcaTGHCback->SetXTitle("dca   [#mum]");
4258   hdcaTGHCback->SetYTitle("Entries");
4259   TH1F *hcosthetastarTGHCback=new TH1F("hcosthetastarTGHCback","hCosThetaStar_TightCuts_Backgr",50,-1.,1.);
4260   hcosthetastarTGHCback->SetXTitle("cos #theta^{*}");
4261   hcosthetastarTGHCback->SetYTitle("Entries");
4262   TH1F *hptD0TGHCback=new TH1F("hptD0TGHCback","D^{0} transverse momentum distribution",34,ptbinsD0arr);
4263   hptD0TGHCback->SetXTitle("p_{t}  [GeV/c]");
4264   hptD0TGHCback->SetYTitle("Entries");
4265   TH1F *hptD0VsMaxPtTGHCback=new TH1F("hptD0VsMaxPtTGHCback","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
4266   TH2F *hptD0PTallsqrtTGHCback=new TH2F("hptD0PTallsqrtTGHCback","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
4267   TH2F *hptD0PTallTGHCback=new TH2F("hptD0PTallTGHCback","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
4268   TH2F *hptD0vsptBTGHCback=new TH2F("hptD0vsptBTGHCback","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4269   TH2F *hpD0vspBTGHCback=new TH2F("hpD0vspBTGHCback","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4270   TH2F *hptD0vsptcquarkTGHCback=new TH2F("hptD0vsptcquarkTGHCback","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4271   TH2F *hpD0vspcquarkTGHCback=new TH2F("hpD0vspcquarkTGHCback","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4272   flistTghCutsBack->Add(hdcaTGHCback);
4273   flistTghCutsBack->Add(hcosthetastarTGHCback);
4274   flistTghCutsBack->Add(hptD0TGHCback);
4275   flistTghCutsBack->Add(hptD0VsMaxPtTGHCback);
4276   flistTghCutsBack->Add(hptD0PTallsqrtTGHCback);
4277   flistTghCutsBack->Add(hptD0PTallTGHCback);
4278   flistTghCutsBack->Add(hptD0vsptBTGHCback);
4279   flistTghCutsBack->Add(hpD0vspBTGHCback);
4280   flistTghCutsBack->Add(hptD0vsptcquarkTGHCback);
4281   flistTghCutsBack->Add(hpD0vspcquarkTGHCback);
4282  
4283   TH1F *hd0zD0ptTGHCback;
4284   TH1F *hInvMassD0TGHCback,*hInvMassD0barTGHCback;
4285   TH2F *hInvMassPtTGHCback=new TH2F("hInvMassPtTGHCback","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
4286   THnSparseF *hSparseTGHCback=new THnSparseF("hSparseTGHCback","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
4287   hSparseTGHCback->SetBinEdges(0,massbins);
4288   hSparseTGHCback->SetBinEdges(1,massbins);
4289   hSparseTGHCback->SetBinEdges(2,ptbinsForNsparse);
4290   hSparseTGHCback->SetBinEdges(3,impparbins);
4291   hSparseTGHCback->SetBinEdges(4,massHypoBins); 
4292   flistTghCutsBack->Add(hSparseTGHCback);
4293   TH1F *hetaTGHCback;
4294   TH1F *hCosPDPBTGHCback;
4295   TH1F *hCosPcPDTGHCback;
4296   flistTghCutsBack->Add(hInvMassPtTGHCback);
4297 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4298   TH2F *hd0D0VSd0xd0TGHCbackpt;
4299   TH2F *hangletracksVSd0xd0TGHCbackpt;
4300   TH2F *hangletracksVSd0D0TGHCbackpt;
4301   TH1F *hd0xd0TGHCbackpt;
4302
4303   TH2F *hTOFpidTGHCback=new TH2F("hTOFpidTGHCback","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
4304   flistTghCutsBack->Add(hTOFpidTGHCback);
4305
4306
4307   for(Int_t i=0;i<fnbins;i++){
4308     namehist="hd0zD0ptTGHCback_pt";
4309     namehist+=i;
4310     titlehist="d0(z) Tight Cuts Backgrm ptbin=";
4311     titlehist+=i;
4312     hd0zD0ptTGHCback=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
4313     hd0zD0ptTGHCback->SetXTitle("d_{0}(z)    [#mum]");
4314     hd0zD0ptTGHCback->SetYTitle("Entries");
4315     flistTghCutsBack->Add(hd0zD0ptTGHCback);
4316
4317     namehist="hInvMassD0TGHCback_pt";
4318     namehist+=i;
4319     titlehist="Invariant Mass Tight Cuts Backgr ptbin=";
4320     titlehist+=i;
4321     hInvMassD0TGHCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4322     hInvMassD0TGHCback->SetXTitle("Invariant Mass    [GeV]");
4323     hInvMassD0TGHCback->SetYTitle("Entries");
4324     flistTghCutsBack->Add(hInvMassD0TGHCback);
4325
4326     namehist="hInvMassD0barTGHCback_pt";
4327     namehist+=i;
4328     titlehist="Invariant Mass D0bar Tight Cuts Back ptbin=";
4329     titlehist+=i;
4330     hInvMassD0barTGHCback=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4331     hInvMassD0barTGHCback->SetXTitle("Invariant Mass    [GeV]");
4332     hInvMassD0barTGHCback->SetYTitle("Entries");
4333     flistTghCutsBack->Add(hInvMassD0barTGHCback);
4334
4335     namehist="hetaTGHCback_pt";
4336     namehist+=i;
4337     titlehist="eta Tight Cuts Backgr ptbin=";
4338     titlehist+=i;
4339     hetaTGHCback=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
4340     hetaTGHCback->SetXTitle("Pseudorapidity");
4341     hetaTGHCback->SetYTitle("Entries");
4342     flistTghCutsBack->Add(hetaTGHCback);
4343
4344     namehist="hCosPDPBTGHCback_pt";
4345     namehist+=i;
4346     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
4347     titlehist+=i;
4348     hCosPDPBTGHCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4349     hCosPDPBTGHCback->SetXTitle("Cosine between D0 momentum and B momentum");
4350     hCosPDPBTGHCback->SetYTitle("Entries");
4351     flistTghCutsBack->Add(hCosPDPBTGHCback);
4352
4353     namehist="hCosPcPDTGHCback_pt";
4354     namehist+=i;
4355     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
4356     titlehist+=i;
4357     hCosPcPDTGHCback=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4358     hCosPcPDTGHCback->SetXTitle("Cosine between c quark momentum and D0 momentum");
4359     hCosPcPDTGHCback->SetYTitle("Entries");
4360     flistTghCutsBack->Add(hCosPcPDTGHCback);
4361
4362  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4363     namehist="hd0xd0TGHCback_pt";
4364     namehist+=i;
4365     titlehist="d0xd0 Tight Cuts Back ptbin=";
4366     titlehist+=i;
4367     hd0xd0TGHCbackpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
4368     hd0xd0TGHCbackpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
4369     hd0xd0TGHCbackpt->SetYTitle("Entries");
4370     flistTghCutsBack->Add(hd0xd0TGHCbackpt);
4371
4372
4373     namehist="hd0D0VSd0xd0TGHCback_pt";
4374     namehist+=i;
4375     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Back ptbin=";
4376     titlehist+=i;
4377     hd0D0VSd0xd0TGHCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
4378     hd0D0VSd0xd0TGHCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4379     hd0D0VSd0xd0TGHCbackpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
4380     flistTghCutsBack->Add(hd0D0VSd0xd0TGHCbackpt);
4381     
4382     
4383     namehist="hangletracksVSd0xd0TGHCback_pt";
4384     namehist+=i;
4385     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Back ptbin=";
4386     titlehist+=i;
4387     hangletracksVSd0xd0TGHCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
4388     hangletracksVSd0xd0TGHCbackpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4389     hangletracksVSd0xd0TGHCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
4390     flistTghCutsBack->Add(hangletracksVSd0xd0TGHCbackpt);
4391     
4392
4393     namehist="hangletracksVSd0D0TGHCback_pt";
4394     namehist+=i;
4395     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Tight Cuts Back ptbin=";
4396     titlehist+=i;
4397     hangletracksVSd0D0TGHCbackpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
4398     hangletracksVSd0D0TGHCbackpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
4399     hangletracksVSd0D0TGHCbackpt->SetYTitle(" angle between K and #p tracks  [rad]");
4400     flistTghCutsBack->Add(hangletracksVSd0D0TGHCbackpt);
4401
4402     
4403   }
4404   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
4405   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4406
4407
4408
4409
4410   // ####### d0 D0 histos ############
4411   
4412  TH1F *hd0D0TGHCbackPM = new TH1F("hd0D0TGHCbackPM","D^{0} impact par. plot , Tight Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
4413   hd0D0TGHCbackPM->SetXTitle("Impact parameter [#mum]");
4414   hd0D0TGHCbackPM->SetYTitle("Entries");
4415
4416   TH1F *hd0D0VtxTrueTGHCbackPM = new TH1F("hd0D0VtxTrueTGHCbackPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
4417   hd0D0VtxTrueTGHCbackPM->SetXTitle("Impact parameter [#mum]");
4418   hd0D0VtxTrueTGHCbackPM->SetYTitle("Entries");
4419
4420   TH1F *hMCd0D0TGHCbackPM = new TH1F("hMCd0D0TGHCbackPM","D^{0} impact par. plot, Tight Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
4421   hMCd0D0TGHCbackPM->SetXTitle("MC Impact parameter [#mum]");
4422   hMCd0D0TGHCbackPM->SetYTitle("Entries");
4423
4424   TH1F *hd0D0TGHCbackSB = new TH1F("hd0D0TGHCbackSB","D^{0} impact par. plot , Tight Cuts ,Background,Mass Peak (All momenta)",1000,-1000.,1000.);
4425   hd0D0TGHCbackSB->SetXTitle("Impact parameter [#mum]");
4426   hd0D0TGHCbackSB->SetYTitle("Entries");
4427
4428   TH1F *hd0D0VtxTrueTGHCbackSB = new TH1F("hd0D0VtxTrueTGHCbackSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Background,Mass Peak (All momenta)",1000,-1000.,1000.);
4429   hd0D0VtxTrueTGHCbackSB->SetXTitle("Impact parameter [#mum]");
4430   hd0D0VtxTrueTGHCbackSB->SetYTitle("Entries");
4431
4432   TH1F *hMCd0D0TGHCbackSB = new TH1F("hMCd0D0TGHCbackSB","D^{0} impact par. plot, Tight Cuts, Background,Mass Peak  (All momenta)",1000,-1000.,1000.);
4433   hMCd0D0TGHCbackSB->SetXTitle("MC Impact parameter [#mum]");
4434   hMCd0D0TGHCbackSB->SetYTitle("Entries");
4435
4436   flistTghCutsBack->Add(hd0D0TGHCbackPM);
4437   flistTghCutsBack->Add(hd0D0VtxTrueTGHCbackPM);
4438   flistTghCutsBack->Add(hMCd0D0TGHCbackPM);
4439   flistTghCutsBack->Add(hd0D0TGHCbackSB);
4440   flistTghCutsBack->Add(hd0D0VtxTrueTGHCbackSB);
4441   flistTghCutsBack->Add(hMCd0D0TGHCbackSB);
4442   
4443   TH1F *hd0D0ptTGHCbackPM;
4444   TH1F *hMCd0D0ptTGHCbackPM;
4445   TH1F *hd0D0VtxTrueptTGHCbackPM;
4446   TH1F *hd0D0ptTGHCbackSB;
4447   TH1F *hMCd0D0ptTGHCbackSB;
4448   TH1F *hd0D0VtxTrueptTGHCbackSB;
4449   namehist="hd0D0ptTGHCback_";
4450   titlehist="D^{0} impact par. plot, Tight Cuts, Background, ";
4451   for(Int_t i=0;i<fnbins;i++){
4452     strnamept=namehist;
4453     strnamept.Append("PkMss_pt");
4454     strnamept+=i;
4455
4456     strtitlept=titlehist;
4457     strtitlept.Append(" Mass Peak, ");
4458     strtitlept+=fptbins[i];
4459     strtitlept.Append("<= pt <");
4460     strtitlept+=fptbins[i+1];
4461     strtitlept.Append(" [GeV/c]");
4462     
4463     hd0D0ptTGHCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4464     hd0D0ptTGHCbackPM->SetXTitle("Impact parameter [#mum] ");
4465     hd0D0ptTGHCbackPM->SetYTitle("Entries");
4466     flistTghCutsBack->Add(hd0D0ptTGHCbackPM);
4467
4468     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4469     hMCd0D0ptTGHCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4470     hMCd0D0ptTGHCbackPM->SetXTitle("MC Impact parameter [#mum] ");
4471     hMCd0D0ptTGHCbackPM->SetYTitle("Entries");
4472     flistTghCutsBack->Add(hMCd0D0ptTGHCbackPM);
4473  
4474
4475     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4476     hd0D0VtxTrueptTGHCbackPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4477     hd0D0VtxTrueptTGHCbackPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4478     hd0D0VtxTrueptTGHCbackPM->SetYTitle("Entries");
4479     flistTghCutsBack->Add(hd0D0VtxTrueptTGHCbackPM);
4480     
4481     strnamept=namehist;
4482     strnamept.Append("SBMss_pt");
4483     strnamept+=i;
4484
4485     strtitlept=titlehist;
4486     strtitlept.Append(" Side Bands, ");
4487     strtitlept+=fptbins[i];
4488     strtitlept.Append("<= pt <");
4489     strtitlept+=fptbins[i+1];
4490     strtitlept.Append(" [GeV/c]");
4491     
4492     hd0D0ptTGHCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4493     hd0D0ptTGHCbackSB->SetXTitle("Impact parameter [#mum] ");
4494     hd0D0ptTGHCbackSB->SetYTitle("Entries");
4495     flistTghCutsBack->Add(hd0D0ptTGHCbackSB);
4496
4497     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4498     hMCd0D0ptTGHCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4499     hMCd0D0ptTGHCbackSB->SetXTitle("MC Impact parameter [#mum] ");
4500     hMCd0D0ptTGHCbackSB->SetYTitle("Entries");
4501     flistTghCutsBack->Add(hMCd0D0ptTGHCbackSB);
4502
4503     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4504     hd0D0VtxTrueptTGHCbackSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4505     hd0D0VtxTrueptTGHCbackSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4506     hd0D0VtxTrueptTGHCbackSB->SetYTitle("Entries");
4507     flistTghCutsBack->Add(hd0D0VtxTrueptTGHCbackSB);
4508   }
4509
4510
4511
4512  //############ TIGHT CUTS FROMB HISTOGRAMS ###########
4513   //
4514   //#######  global properties histos
4515
4516   TH2F *hCPtaVSd0d0TGHCfromB=new TH2F("hCPtaVSd0d0TGHCfromB","hCPtaVSd0d0_TightCuts_FromB",1000,-100000.,100000.,100,-1.,1.);
4517   TH1F *hSecVtxZTGHCfromB=new TH1F("hSecVtxZTGHCfromB","hSecVtxZ_TightCuts_FromB",1000,-8.,8.);
4518   TH1F *hSecVtxXTGHCfromB=new TH1F("hSecVtxXTGHCfromB","hSecVtxX_TightCuts_FromB",1000,-3000.,3000.);
4519   TH1F *hSecVtxYTGHCfromB=new TH1F("hSecVtxYTGHCfromB","hSecVtxY_TightCuts_FromB",1000,-3000.,3000.);
4520   TH2F *hSecVtxXYTGHCfromB=new TH2F("hSecVtxXYTGHCfromB","hSecVtxXY_TightCuts_FromB",1000,-3000.,3000.,1000,-3000.,3000.);
4521   TH1F *hSecVtxPhiTGHCfromB=new TH1F("hSecVtxPhiTGHCfromB","hSecVtxPhi_TightCuts_FromB",180,-180.1,180.1);
4522   TH1F *hd0singlTrackTGHCfromB=new TH1F("hd0singlTrackTGHCfromB","hd0singlTrackTightCuts_FromB",1000,-5000.,5000.);
4523   TH1F *hCPtaTGHCfromB=new TH1F("hCPtaTGHCfromB","hCPta_TightCuts_FromB",100,-1.,1.);
4524   TH1F *hd0xd0TGHCfromB=new TH1F("hd0xd0TGHCfromB","hd0xd0_TightCuts_FromB",1000,-100000.,100000.);
4525   TH1F *hMassTrueTGHCfromB=new TH1F("hMassTrueTGHCfromB","D^{0} MC inv. Mass Tight Cuts FromB(All momenta)",600,1.600,2.200);
4526   TH1F *hMassTGHCfromB=new TH1F("hMassTGHCfromB","D^{0} inv. Mass Tight Cuts FromB (All momenta)",600,1.600,2.200);
4527   hMassTGHCfromB->Sumw2();
4528   TH1F *hMassTrueTGHCfromBPM=new TH1F("hMassTrueTGHCfromBPM","D^{0} MC inv. Mass Tight Cuts FromB, Mass Peak. (All momenta)",600,1.600,2.200);
4529   TH1F *hMassTGHCfromBPM=new TH1F("hMassTGHCfromBPM","D^{0} inv. Mass Tight Cuts FromB (All momenta), MassPeak",600,1.600,2.200);
4530   hMassTGHCfromBPM->Sumw2();
4531   TH1F *hMassTrueTGHCfromBSB=new TH1F("hMassTrueTGHCfromBSB","D^{0} MC inv. Mass in Side Bands Tight Cuts FromB(All momenta)",600,1.600,2.200);
4532   TH1F *hMassTGHCfromBSB=new TH1F("hMassTGHCfromBSB","D^{0} inv. Mass in Side Bands Tight Cuts FromB (All momenta)",600,1.600,2.200);
4533   hMassTGHCfromBSB->Sumw2();
4534
4535   flistTghCutsFromB->Add(hCPtaVSd0d0TGHCfromB);
4536   flistTghCutsFromB->Add(hSecVtxZTGHCfromB);
4537   flistTghCutsFromB->Add(hSecVtxYTGHCfromB);
4538   flistTghCutsFromB->Add(hSecVtxXTGHCfromB);
4539   flistTghCutsFromB->Add(hSecVtxXYTGHCfromB);
4540   flistTghCutsFromB->Add(hSecVtxPhiTGHCfromB);
4541   flistTghCutsFromB->Add(hd0singlTrackTGHCfromB);
4542   flistTghCutsFromB->Add(hCPtaTGHCfromB);
4543   flistTghCutsFromB->Add(hd0xd0TGHCfromB);
4544   flistTghCutsFromB->Add(hMassTrueTGHCfromB);
4545   flistTghCutsFromB->Add(hMassTGHCfromB);
4546   flistTghCutsFromB->Add(hMassTrueTGHCfromBPM);
4547   flistTghCutsFromB->Add(hMassTGHCfromBPM);
4548   flistTghCutsFromB->Add(hMassTrueTGHCfromBSB);
4549   flistTghCutsFromB->Add(hMassTGHCfromBSB);
4550
4551
4552
4553  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
4554   TH1F *hdcaTGHCfromB=new TH1F("hdcaTGHCfromB","hdca_TightCuts_FromB",100,0.,1000.);
4555   hdcaTGHCfromB->SetXTitle("dca   [#mum]");
4556   hdcaTGHCfromB->SetYTitle("Entries");
4557   TH1F *hcosthetastarTGHCfromB=new TH1F("hcosthetastarTGHCfromB","hCosThetaStar_TightCuts_FromB",50,-1.,1.);
4558   hcosthetastarTGHCfromB->SetXTitle("cos #theta^{*}");
4559   hcosthetastarTGHCfromB->SetYTitle("Entries");
4560   TH1F *hptD0TGHCfromB=new TH1F("hptD0TGHCfromB","D^{0} transverse momentum distribution",34,ptbinsD0arr);
4561   hptD0TGHCfromB->SetXTitle("p_{t}  [GeV/c]");
4562   hptD0TGHCfromB->SetYTitle("Entries");
4563   TH1F *hptD0VsMaxPtTGHCfromB=new TH1F("hptD0VsMaxPtTGHCfromB","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
4564   TH2F *hptD0PTallsqrtTGHCfromB=new TH2F("hptD0PTallsqrtTGHCfromB","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
4565   TH2F *hptD0PTallTGHCfromB=new TH2F("hptD0PTallTGHCfromB","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
4566   TH2F *hptD0vsptBTGHCfromB=new TH2F("hptD0vsptBTGHCfromB","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4567   TH2F *hpD0vspBTGHCfromB=new TH2F("hpD0vspBTGHCfromB","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4568   TH2F *hptD0vsptcquarkTGHCfromB=new TH2F("hptD0vsptcquarkTGHCfromB","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4569   TH2F *hpD0vspcquarkTGHCfromB=new TH2F("hpD0vspcquarkTGHCfromB","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4570   flistTghCutsFromB->Add(hdcaTGHCfromB);
4571   flistTghCutsFromB->Add(hcosthetastarTGHCfromB);
4572   flistTghCutsFromB->Add(hptD0TGHCfromB);
4573   flistTghCutsFromB->Add(hptD0VsMaxPtTGHCfromB);
4574   flistTghCutsFromB->Add(hptD0PTallsqrtTGHCfromB);
4575   flistTghCutsFromB->Add(hptD0PTallTGHCfromB);
4576   flistTghCutsFromB->Add(hptD0vsptBTGHCfromB);
4577   flistTghCutsFromB->Add(hpD0vspBTGHCfromB);
4578   flistTghCutsFromB->Add(hptD0vsptcquarkTGHCfromB);
4579   flistTghCutsFromB->Add(hpD0vspcquarkTGHCfromB);
4580  
4581   TH1F *hd0zD0ptTGHCfromB;
4582   TH1F *hInvMassD0TGHCfromB,*hInvMassD0barTGHCfromB;
4583   TH2F *hInvMassPtTGHCfromB=new TH2F("hInvMassPtTGHCfromB","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
4584   TH3F *hInvMassPtSelSignOnlyTGHCfromB=new TH3F("hInvMassPtSelSignOnlyTGHCfromB","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
4585   flistTghCutsFromB->Add(hInvMassPtSelSignOnlyTGHCfromB);
4586   TH3F *hInvMassPtSelReflOnlyTGHCfromB=new TH3F("hInvMassPtSelReflOnlyTGHCfromB","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
4587   flistTghCutsFromB->Add(hInvMassPtSelReflOnlyTGHCfromB);
4588
4589
4590   THnSparseF *hSparseTGHCfromB=new THnSparseF("hSparseTGHCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
4591   hSparseTGHCfromB->SetBinEdges(0,massbins);
4592   hSparseTGHCfromB->SetBinEdges(1,massbins);
4593   hSparseTGHCfromB->SetBinEdges(2,ptbinsForNsparse);
4594   hSparseTGHCfromB->SetBinEdges(3,impparbins);
4595   hSparseTGHCfromB->SetBinEdges(4,massHypoBins); 
4596   flistTghCutsFromB->Add(hSparseTGHCfromB);
4597
4598   
4599   THnSparseF *hSparseRecoTGHCfromB=new THnSparseF("hSparseRecoTGHCfromB","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
4600   hSparseRecoTGHCfromB->SetBinEdges(0,massbins);
4601   hSparseRecoTGHCfromB->SetBinEdges(1,massbins);
4602   hSparseRecoTGHCfromB->SetBinEdges(2,ptbinsForNsparse);
4603   hSparseRecoTGHCfromB->SetBinEdges(3,impparbins);
4604   hSparseRecoTGHCfromB->SetBinEdges(4,massHypoBins); 
4605   flistTghCutsFromB->Add(hSparseRecoTGHCfromB);
4606
4607   TH1F *hetaTGHCfromB;
4608   TH1F *hCosPDPBTGHCfromB;
4609   TH1F *hCosPcPDTGHCfromB;
4610   flistTghCutsFromB->Add(hInvMassPtTGHCfromB);
4611 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4612   TH2F *hd0D0VSd0xd0TGHCfromBpt;
4613   TH2F *hangletracksVSd0xd0TGHCfromBpt;
4614   TH2F *hangletracksVSd0D0TGHCfromBpt;
4615   TH1F *hd0xd0TGHCfromBpt;
4616
4617   TH2F *hTOFpidTGHCfromB=new TH2F("hTOFpidTGHCfromB","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
4618   flistTghCutsFromB->Add(hTOFpidTGHCfromB);
4619
4620
4621   for(Int_t i=0;i<fnbins;i++){
4622     namehist="hd0zD0ptTGHCfromB_pt";
4623     namehist+=i;
4624     titlehist="d0(z) Tight Cuts FromBm ptbin=";
4625     titlehist+=i;
4626     hd0zD0ptTGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
4627     hd0zD0ptTGHCfromB->SetXTitle("d_{0}(z)    [#mum]");
4628     hd0zD0ptTGHCfromB->SetYTitle("Entries");
4629     flistTghCutsFromB->Add(hd0zD0ptTGHCfromB);
4630
4631     namehist="hInvMassD0TGHCfromB_pt";
4632     namehist+=i;
4633     titlehist="Invariant Mass Tight Cuts FromB ptbin=";
4634     titlehist+=i;
4635     hInvMassD0TGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4636     hInvMassD0TGHCfromB->SetXTitle("Invariant Mass    [GeV]");
4637     hInvMassD0TGHCfromB->SetYTitle("Entries");
4638     flistTghCutsFromB->Add(hInvMassD0TGHCfromB);
4639
4640     namehist="hInvMassD0barTGHCfromB_pt";
4641     namehist+=i;
4642     titlehist="Invariant Mass D0bar Tight Cuts FromB ptbin=";
4643     titlehist+=i;
4644     hInvMassD0barTGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4645     hInvMassD0barTGHCfromB->SetXTitle("Invariant Mass    [GeV]");
4646     hInvMassD0barTGHCfromB->SetYTitle("Entries");
4647     flistTghCutsFromB->Add(hInvMassD0barTGHCfromB);
4648
4649     namehist="hetaTGHCfromB_pt";
4650     namehist+=i;
4651     titlehist="eta Tight Cuts FromB ptbin=";
4652     titlehist+=i;
4653     hetaTGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
4654     hetaTGHCfromB->SetXTitle("Pseudorapidity");
4655     hetaTGHCfromB->SetYTitle("Entries");
4656     flistTghCutsFromB->Add(hetaTGHCfromB);
4657
4658     namehist="hCosPDPBTGHCfromB_pt";
4659     namehist+=i;
4660     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
4661     titlehist+=i;
4662     hCosPDPBTGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4663     hCosPDPBTGHCfromB->SetXTitle("Cosine between D0 momentum and B momentum");
4664     hCosPDPBTGHCfromB->SetYTitle("Entries");
4665     flistTghCutsFromB->Add(hCosPDPBTGHCfromB);
4666
4667     namehist="hCosPcPDTGHCfromB_pt";
4668     namehist+=i;
4669     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
4670     titlehist+=i;
4671     hCosPcPDTGHCfromB=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4672     hCosPcPDTGHCfromB->SetXTitle("Cosine between c quark momentum and D0 momentum");
4673     hCosPcPDTGHCfromB->SetYTitle("Entries");
4674     flistTghCutsFromB->Add(hCosPcPDTGHCfromB);
4675
4676 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4677     namehist="hd0xd0TGHCfromB_pt";
4678     namehist+=i;
4679     titlehist="d0xd0 Tight Cuts FromB ptbin=";
4680     titlehist+=i;
4681     hd0xd0TGHCfromBpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
4682     hd0xd0TGHCfromBpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
4683     hd0xd0TGHCfromBpt->SetYTitle("Entries");
4684     flistTghCutsFromB->Add(hd0xd0TGHCfromBpt);
4685
4686
4687     namehist="hd0D0VSd0xd0TGHCfromB_pt";
4688     namehist+=i;
4689     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts FromB ptbin=";
4690     titlehist+=i;
4691     hd0D0VSd0xd0TGHCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
4692     hd0D0VSd0xd0TGHCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4693     hd0D0VSd0xd0TGHCfromBpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
4694     flistTghCutsFromB->Add(hd0D0VSd0xd0TGHCfromBpt);
4695     
4696     
4697     namehist="hangletracksVSd0xd0TGHCfromB_pt";
4698     namehist+=i;
4699     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts FromB ptbin=";
4700     titlehist+=i;
4701     hangletracksVSd0xd0TGHCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
4702     hangletracksVSd0xd0TGHCfromBpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4703     hangletracksVSd0xd0TGHCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
4704     flistTghCutsFromB->Add(hangletracksVSd0xd0TGHCfromBpt);
4705     
4706
4707     namehist="hangletracksVSd0D0TGHCfromB_pt";
4708     namehist+=i;
4709     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Tight Cuts FromB ptbin=";
4710     titlehist+=i;
4711     hangletracksVSd0D0TGHCfromBpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
4712     hangletracksVSd0D0TGHCfromBpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
4713     hangletracksVSd0D0TGHCfromBpt->SetYTitle(" angle between K and #p tracks  [rad]");
4714     flistTghCutsFromB->Add(hangletracksVSd0D0TGHCfromBpt);
4715     
4716   }
4717   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
4718   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4719
4720
4721
4722
4723
4724   // ######### d0 D0 histos ##############
4725   TH1F *hd0D0TGHCfromBPM = new TH1F("hd0D0TGHCfromBPM","D^{0} impact par. plot , Tight Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
4726   hd0D0TGHCfromBPM->SetXTitle("Impact parameter [#mum]");
4727   hd0D0TGHCfromBPM->SetYTitle("Entries");
4728
4729   TH1F *hd0D0VtxTrueTGHCfromBPM = new TH1F("hd0D0VtxTrueTGHCfromBPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
4730   hd0D0VtxTrueTGHCfromBPM->SetXTitle("Impact parameter [#mum]");
4731   hd0D0VtxTrueTGHCfromBPM->SetYTitle("Entries");
4732
4733   TH1F *hMCd0D0TGHCfromBPM = new TH1F("hMCd0D0TGHCfromBPM","D^{0} impact par. plot, Tight Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
4734   hMCd0D0TGHCfromBPM->SetXTitle("MC Impact parameter [#mum]");
4735   hMCd0D0TGHCfromBPM->SetYTitle("Entries");
4736
4737   TH1F *hd0D0TGHCfromBSB = new TH1F("hd0D0TGHCfromBSB","D^{0} impact par. plot , Tight Cuts ,FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
4738   hd0D0TGHCfromBSB->SetXTitle("Impact parameter [#mum]");
4739   hd0D0TGHCfromBSB->SetYTitle("Entries");
4740
4741   TH1F *hd0D0VtxTrueTGHCfromBSB = new TH1F("hd0D0VtxTrueTGHCfromBSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromB,Mass Peak (All momenta)",1000,-1000.,1000.);
4742   hd0D0VtxTrueTGHCfromBSB->SetXTitle("Impact parameter [#mum]");
4743   hd0D0VtxTrueTGHCfromBSB->SetYTitle("Entries");
4744
4745   TH1F *hMCd0D0TGHCfromBSB = new TH1F("hMCd0D0TGHCfromBSB","D^{0} impact par. plot, Tight Cuts, FromB,Mass Peak  (All momenta)",1000,-1000.,1000.);
4746   hMCd0D0TGHCfromBSB->SetXTitle("MC Impact parameter [#mum]");
4747   hMCd0D0TGHCfromBSB->SetYTitle("Entries");
4748
4749   flistTghCutsFromB->Add(hd0D0TGHCfromBPM);
4750   flistTghCutsFromB->Add(hd0D0VtxTrueTGHCfromBPM);
4751   flistTghCutsFromB->Add(hMCd0D0TGHCfromBPM);
4752   flistTghCutsFromB->Add(hd0D0TGHCfromBSB);
4753   flistTghCutsFromB->Add(hd0D0VtxTrueTGHCfromBSB);
4754   flistTghCutsFromB->Add(hMCd0D0TGHCfromBSB);
4755   
4756   TH1F *hd0D0ptTGHCfromBPM;
4757   TH1F *hMCd0D0ptTGHCfromBPM;
4758   TH1F *hd0D0VtxTrueptTGHCfromBPM;
4759   TH1F *hd0D0ptTGHCfromBSB;
4760   TH1F *hMCd0D0ptTGHCfromBSB;
4761   TH1F *hd0D0VtxTrueptTGHCfromBSB;
4762   namehist="hd0D0ptTGHCfromB_";
4763   titlehist="D^{0} impact par. plot, Tight Cuts, FromB, ";
4764   for(Int_t i=0;i<fnbins;i++){
4765     strnamept=namehist;
4766     strnamept.Append("PkMss_pt");
4767     strnamept+=i;
4768
4769     strtitlept=titlehist;
4770     strtitlept.Append(" Mass Peak, ");
4771     strtitlept+=fptbins[i];
4772     strtitlept.Append("<= pt <");
4773     strtitlept+=fptbins[i+1];
4774     strtitlept.Append(" [GeV/c]");
4775     
4776     hd0D0ptTGHCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4777     hd0D0ptTGHCfromBPM->SetXTitle("Impact parameter [#mum] ");
4778     hd0D0ptTGHCfromBPM->SetYTitle("Entries");
4779     flistTghCutsFromB->Add(hd0D0ptTGHCfromBPM);
4780
4781     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4782     hMCd0D0ptTGHCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4783     hMCd0D0ptTGHCfromBPM->SetXTitle("MC Impact parameter [#mum] ");
4784     hMCd0D0ptTGHCfromBPM->SetYTitle("Entries");
4785     flistTghCutsFromB->Add(hMCd0D0ptTGHCfromBPM);
4786  
4787
4788     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4789     hd0D0VtxTrueptTGHCfromBPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4790     hd0D0VtxTrueptTGHCfromBPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4791     hd0D0VtxTrueptTGHCfromBPM->SetYTitle("Entries");
4792     flistTghCutsFromB->Add(hd0D0VtxTrueptTGHCfromBPM);
4793     
4794     strnamept=namehist;
4795     strnamept.Append("SBMss_pt");
4796     strnamept+=i;
4797
4798     strtitlept=titlehist;
4799     strtitlept.Append(" Side Bands, ");
4800     strtitlept+=fptbins[i];
4801     strtitlept.Append("<= pt <");
4802     strtitlept+=fptbins[i+1];
4803     strtitlept.Append(" [GeV/c]");
4804     
4805     hd0D0ptTGHCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4806     hd0D0ptTGHCfromBSB->SetXTitle("Impact parameter [#mum] ");
4807     hd0D0ptTGHCfromBSB->SetYTitle("Entries");
4808     flistTghCutsFromB->Add(hd0D0ptTGHCfromBSB);
4809
4810     strnamept.ReplaceAll("hd0D0","hMCd0D0");
4811     hMCd0D0ptTGHCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4812     hMCd0D0ptTGHCfromBSB->SetXTitle("MC Impact parameter [#mum] ");
4813     hMCd0D0ptTGHCfromBSB->SetYTitle("Entries");
4814     flistTghCutsFromB->Add(hMCd0D0ptTGHCfromBSB);
4815
4816     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
4817     hd0D0VtxTrueptTGHCfromBSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
4818     hd0D0VtxTrueptTGHCfromBSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
4819     hd0D0VtxTrueptTGHCfromBSB->SetYTitle("Entries");
4820     flistTghCutsFromB->Add(hd0D0VtxTrueptTGHCfromBSB);
4821   }
4822
4823
4824
4825  //############ TIGHT CUTS FROM DSTAR HISTOGRAMS ###########
4826  //
4827   //############## global properties histos
4828   TH2F *hCPtaVSd0d0TGHCfromDstar=new TH2F("hCPtaVSd0d0TGHCfromDstar","hCPtaVSd0d0_TightCuts_FromDStar",1000,-100000.,100000.,100,-1.,1.);
4829   TH1F *hSecVtxZTGHCfromDstar=new TH1F("hSecVtxZTGHCfromDstar","hSecVtxZ_TightCuts_FromDStar",1000,-8.,8.);
4830   TH1F *hSecVtxXTGHCfromDstar=new TH1F("hSecVtxXTGHCfromDstar","hSecVtxX_TightCuts_FromDStar",1000,-3000.,3000.);
4831   TH1F *hSecVtxYTGHCfromDstar=new TH1F("hSecVtxYTGHCfromDstar","hSecVtxY_TightCuts_FromDStar",1000,-3000.,3000.);
4832   TH2F *hSecVtxXYTGHCfromDstar=new TH2F("hSecVtxXYTGHCfromDstar","hSecVtxXY_TightCuts_FromDStar",1000,-3000.,3000.,1000,-3000.,3000.);
4833   TH1F *hSecVtxPhiTGHCfromDstar=new TH1F("hSecVtxPhiTGHCfromDstar","hSecVtxPhi_TightCuts_FromDStar",180,-180.1,180.1);
4834   TH1F *hd0singlTrackTGHCfromDstar=new TH1F("hd0singlTrackTGHCfromDstar","hd0singlTrackTightCuts_FromDstar",1000,-5000.,5000.);
4835   TH1F *hCPtaTGHCfromDstar=new TH1F("hCPtaTGHCfromDstar","hCPta_TightCuts_FromDStar",100,-1.,1.);
4836   TH1F *hd0xd0TGHCfromDstar=new TH1F("hd0xd0TGHCfromDstar","hd0xd0_TightCuts_FromDStar",1000,-100000.,100000.);
4837   TH1F *hMassTrueTGHCfromDstar=new TH1F("hMassTrueTGHCfromDstar","D^{0} MC inv. Mass Tight Cuts FromDStar(All momenta)",600,1.600,2.200);
4838   TH1F *hMassTGHCfromDstar=new TH1F("hMassTGHCfromDstar","D^{0} inv. Mass Tight Cuts FromDStar (All momenta)",600,1.600,2.200);
4839   hMassTGHCfromDstar->Sumw2();
4840   TH1F *hMassTrueTGHCfromDstarPM=new TH1F("hMassTrueTGHCfromDstarPM","D^{0} MC inv. Mass Tight Cuts FromDStar, Mass Peak. (All momenta)",600,1.600,2.200);
4841   TH1F *hMassTGHCfromDstarPM=new TH1F("hMassTGHCfromDstarPM","D^{0} inv. Mass Tight Cuts FromDStar (All momenta), MassPeak",600,1.600,2.200);
4842   hMassTGHCfromDstarPM->Sumw2();
4843   TH1F *hMassTrueTGHCfromDstarSB=new TH1F("hMassTrueTGHCfromDstarSB","D^{0} MC inv. Mass in Side Bands Tight Cuts FromDStar(All momenta)",600,1.600,2.200);
4844   TH1F *hMassTGHCfromDstarSB=new TH1F("hMassTGHCfromDstarSB","D^{0} inv. Mass in Side Bands Tight Cuts FromDStar (All momenta)",600,1.600,2.200);
4845   hMassTGHCfromDstarSB->Sumw2();
4846
4847   flistTghCutsFromDstar->Add(hCPtaVSd0d0TGHCfromDstar);
4848   flistTghCutsFromDstar->Add(hSecVtxZTGHCfromDstar);
4849   flistTghCutsFromDstar->Add(hSecVtxYTGHCfromDstar);
4850   flistTghCutsFromDstar->Add(hSecVtxXTGHCfromDstar);
4851   flistTghCutsFromDstar->Add(hSecVtxXYTGHCfromDstar);
4852   flistTghCutsFromDstar->Add(hSecVtxPhiTGHCfromDstar);
4853   flistTghCutsFromDstar->Add(hd0singlTrackTGHCfromDstar);
4854   flistTghCutsFromDstar->Add(hCPtaTGHCfromDstar);
4855   flistTghCutsFromDstar->Add(hd0xd0TGHCfromDstar);
4856   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstar);
4857   flistTghCutsFromDstar->Add(hMassTGHCfromDstar);
4858   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstarPM);
4859   flistTghCutsFromDstar->Add(hMassTGHCfromDstarPM);
4860   flistTghCutsFromDstar->Add(hMassTrueTGHCfromDstarSB);
4861   flistTghCutsFromDstar->Add(hMassTGHCfromDstarSB);
4862
4863
4864
4865
4866
4867  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
4868   TH1F *hdcaTGHCfromDstar=new TH1F("hdcaTGHCfromDstar","hdca_TightCuts_FromDstar",100,0.,1000.);
4869   hdcaTGHCfromDstar->SetXTitle("dca   [#mum]");
4870   hdcaTGHCfromDstar->SetYTitle("Entries");
4871   TH1F *hcosthetastarTGHCfromDstar=new TH1F("hcosthetastarTGHCfromDstar","hCosThetaStar_TightCuts_FromDstar",50,-1.,1.);
4872   hcosthetastarTGHCfromDstar->SetXTitle("cos #theta^{*}");
4873   hcosthetastarTGHCfromDstar->SetYTitle("Entries");
4874   TH1F *hptD0TGHCfromDstar=new TH1F("hptD0TGHCfromDstar","D^{0} transverse momentum distribution",34,ptbinsD0arr);
4875   hptD0TGHCfromDstar->SetXTitle("p_{t}  [GeV/c]");
4876   hptD0TGHCfromDstar->SetYTitle("Entries");
4877   TH1F *hptD0VsMaxPtTGHCfromDstar=new TH1F("hptD0VsMaxPtTGHCfromDstar","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
4878   TH2F *hptD0PTallsqrtTGHCfromDstar=new TH2F("hptD0PTallsqrtTGHCfromDstar","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
4879   TH2F *hptD0PTallTGHCfromDstar=new TH2F("hptD0PTallTGHCfromDstar","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
4880   TH2F *hptD0vsptBTGHCfromDstar=new TH2F("hptD0vsptBTGHCfromDstar","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4881   TH2F *hpD0vspBTGHCfromDstar=new TH2F("hpD0vspBTGHCfromDstar","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4882   TH2F *hptD0vsptcquarkTGHCfromDstar=new TH2F("hptD0vsptcquarkTGHCfromDstar","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4883   TH2F *hpD0vspcquarkTGHCfromDstar=new TH2F("hpD0vspcquarkTGHCfromDstar","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
4884   flistTghCutsFromDstar->Add(hdcaTGHCfromDstar);
4885   flistTghCutsFromDstar->Add(hcosthetastarTGHCfromDstar);
4886   flistTghCutsFromDstar->Add(hptD0TGHCfromDstar);
4887   flistTghCutsFromDstar->Add(hptD0VsMaxPtTGHCfromDstar);
4888   flistTghCutsFromDstar->Add(hptD0PTallsqrtTGHCfromDstar);
4889   flistTghCutsFromDstar->Add(hptD0PTallTGHCfromDstar);
4890   flistTghCutsFromDstar->Add(hptD0vsptBTGHCfromDstar);
4891   flistTghCutsFromDstar->Add(hpD0vspBTGHCfromDstar);
4892   flistTghCutsFromDstar->Add(hptD0vsptcquarkTGHCfromDstar);
4893   flistTghCutsFromDstar->Add(hpD0vspcquarkTGHCfromDstar);
4894  
4895   TH1F *hd0zD0ptTGHCfromDstar;
4896   TH1F *hInvMassD0TGHCfromDstar,*hInvMassD0barTGHCfromDstar;
4897   TH1F *hetaTGHCfromDstar;
4898   TH2F *hInvMassPtTGHCfromDstar=new TH2F("hInvMassPtTGHCfromDstar","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
4899
4900   TH3F *hInvMassPtSelSignOnlyTGHCfromDstar=new TH3F("hInvMassPtSelSignOnlyTGHCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for signal only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
4901   flistTghCutsFromDstar->Add(hInvMassPtSelSignOnlyTGHCfromDstar);
4902   TH3F *hInvMassPtSelReflOnlyTGHCfromDstar=new TH3F("hInvMassPtSelReflOnlyTGHCfromDstar","Candidate p_{t} Vs invariant mass vs sel case for reflections only",600,1.600,2.200,72,0.,36.,3,0.5,3.5);
4903   flistTghCutsFromDstar->Add(hInvMassPtSelReflOnlyTGHCfromDstar);
4904
4905   THnSparseF *hSparseTGHCfromDstar=new THnSparseF("hSparseTGHCfromDstar","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
4906   hSparseTGHCfromDstar->SetBinEdges(0,massbins);
4907   hSparseTGHCfromDstar->SetBinEdges(1,massbins);
4908   hSparseTGHCfromDstar->SetBinEdges(2,ptbinsForNsparse);
4909   hSparseTGHCfromDstar->SetBinEdges(3,impparbins);
4910   hSparseTGHCfromDstar->SetBinEdges(4,massHypoBins); 
4911   flistTghCutsFromDstar->Add(hSparseTGHCfromDstar);
4912   TH1F *hCosPDPBTGHCfromDstar;
4913   TH1F *hCosPcPDTGHCfromDstar;
4914   flistTghCutsFromDstar->Add(hInvMassPtTGHCfromDstar);
4915 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4916   TH2F *hd0D0VSd0xd0TGHCfromDstarpt;
4917   TH2F *hangletracksVSd0xd0TGHCfromDstarpt;
4918   TH2F *hangletracksVSd0D0TGHCfromDstarpt;
4919   TH1F *hd0xd0TGHCfromDstarpt;
4920
4921   TH2F *hTOFpidTGHCfromDstar=new TH2F("hTOFpidTGHCfromDstar","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
4922   flistTghCutsFromDstar->Add(hTOFpidTGHCfromDstar);
4923
4924   for(Int_t i=0;i<fnbins;i++){
4925     namehist="hd0zD0ptTGHCfromDstar_pt";
4926     namehist+=i;
4927     titlehist="d0(z) Tight Cuts FromDstarm ptbin=";
4928     titlehist+=i;
4929     hd0zD0ptTGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
4930     hd0zD0ptTGHCfromDstar->SetXTitle("d_{0}(z)    [#mum]");
4931     hd0zD0ptTGHCfromDstar->SetYTitle("Entries");
4932     flistTghCutsFromDstar->Add(hd0zD0ptTGHCfromDstar);
4933
4934     namehist="hInvMassD0TGHCfromDstar_pt";
4935     namehist+=i;
4936     titlehist="Invariant Mass Tight Cuts FromDstar ptbin=";
4937     titlehist+=i;
4938     hInvMassD0TGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4939     hInvMassD0TGHCfromDstar->SetXTitle("Invariant Mass    [GeV]");
4940     hInvMassD0TGHCfromDstar->SetYTitle("Entries");
4941     flistTghCutsFromDstar->Add(hInvMassD0TGHCfromDstar);
4942
4943     namehist="hInvMassD0barTGHCfromDstar_pt";
4944     namehist+=i;
4945     titlehist="Invariant Mass D0bar Tight Cuts FromDstar ptbin=";
4946     titlehist+=i;
4947     hInvMassD0barTGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
4948     hInvMassD0barTGHCfromDstar->SetXTitle("Invariant Mass    [GeV]");
4949     hInvMassD0barTGHCfromDstar->SetYTitle("Entries");
4950     flistTghCutsFromDstar->Add(hInvMassD0barTGHCfromDstar);
4951
4952     namehist="hetaTGHCfromDstar_pt";
4953     namehist+=i;
4954     titlehist="eta Tight Cuts FromDstar ptbin=";
4955     titlehist+=i;
4956     hetaTGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
4957     hetaTGHCfromDstar->SetXTitle("Pseudorapidity");
4958     hetaTGHCfromDstar->SetYTitle("Entries");
4959     flistTghCutsFromDstar->Add(hetaTGHCfromDstar);
4960
4961     namehist="hCosPDPBTGHCfromDstar_pt";
4962     namehist+=i;
4963     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
4964     titlehist+=i;
4965     hCosPDPBTGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4966     hCosPDPBTGHCfromDstar->SetXTitle("Cosine between D0 momentum and B momentum");
4967     hCosPDPBTGHCfromDstar->SetYTitle("Entries");
4968     flistTghCutsFromDstar->Add(hCosPDPBTGHCfromDstar);
4969
4970     namehist="hCosPcPDTGHCfromDstar_pt";
4971     namehist+=i;
4972     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
4973     titlehist+=i;
4974     hCosPcPDTGHCfromDstar=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
4975     hCosPcPDTGHCfromDstar->SetXTitle("Cosine between c quark momentum and D0 momentum");
4976     hCosPcPDTGHCfromDstar->SetYTitle("Entries");
4977     flistTghCutsFromDstar->Add(hCosPcPDTGHCfromDstar);
4978
4979  // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
4980     namehist="hd0xd0TGHCfromDstar_pt";
4981     namehist+=i;
4982     titlehist="d0xd0 Tight Cuts FromDstar ptbin=";
4983     titlehist+=i;
4984     hd0xd0TGHCfromDstarpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
4985     hd0xd0TGHCfromDstarpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
4986     hd0xd0TGHCfromDstarpt->SetYTitle("Entries");
4987     flistTghCutsFromDstar->Add(hd0xd0TGHCfromDstarpt);
4988
4989
4990     namehist="hd0D0VSd0xd0TGHCfromDstar_pt";
4991     namehist+=i;
4992     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts FromDstar ptbin=";
4993     titlehist+=i;
4994     hd0D0VSd0xd0TGHCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
4995     hd0D0VSd0xd0TGHCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
4996     hd0D0VSd0xd0TGHCfromDstarpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
4997     flistTghCutsFromDstar->Add(hd0D0VSd0xd0TGHCfromDstarpt);
4998     
4999     
5000     namehist="hangletracksVSd0xd0TGHCfromDstar_pt";
5001     namehist+=i;
5002     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts FromDstar ptbin=";
5003     titlehist+=i;
5004     hangletracksVSd0xd0TGHCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
5005     hangletracksVSd0xd0TGHCfromDstarpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
5006     hangletracksVSd0xd0TGHCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
5007     flistTghCutsFromDstar->Add(hangletracksVSd0xd0TGHCfromDstarpt);
5008     
5009
5010     namehist="hangletracksVSd0D0TGHCfromDstar_pt";
5011     namehist+=i;
5012     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Tight Cuts FromDstar ptbin=";
5013     titlehist+=i;
5014     hangletracksVSd0D0TGHCfromDstarpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
5015     hangletracksVSd0D0TGHCfromDstarpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
5016     hangletracksVSd0D0TGHCfromDstarpt->SetYTitle(" angle between K and #p tracks  [rad]");
5017     flistTghCutsFromDstar->Add(hangletracksVSd0D0TGHCfromDstarpt);
5018
5019     
5020   }
5021   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
5022   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5023
5024
5025   //########## d0 D0 histos #############  
5026   TH1F *hd0D0TGHCfromDstPM = new TH1F("hd0D0TGHCfromDstarPM","D^{0} impact par. plot , Tight Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
5027   hd0D0TGHCfromDstPM->SetXTitle("Impact parameter [#mum]");
5028   hd0D0TGHCfromDstPM->SetYTitle("Entries");
5029
5030   TH1F *hd0D0VtxTrueTGHCfromDstPM = new TH1F("hd0D0VtxTrueTGHCfromDstarPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
5031   hd0D0VtxTrueTGHCfromDstPM->SetXTitle("Impact parameter [#mum]");
5032   hd0D0VtxTrueTGHCfromDstPM->SetYTitle("Entries");
5033
5034   TH1F *hMCd0D0TGHCfromDstPM = new TH1F("hMCd0D0TGHCfromDstarPM","D^{0} impact par. plot, Tight Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
5035   hMCd0D0TGHCfromDstPM->SetXTitle("MC Impact parameter [#mum]");
5036   hMCd0D0TGHCfromDstPM->SetYTitle("Entries");
5037
5038   TH1F *hd0D0TGHCfromDstSB = new TH1F("hd0D0TGHCfromDstarSB","D^{0} impact par. plot , Tight Cuts ,FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
5039   hd0D0TGHCfromDstSB->SetXTitle("Impact parameter [#mum]");
5040   hd0D0TGHCfromDstSB->SetYTitle("Entries");
5041
5042   TH1F *hd0D0VtxTrueTGHCfromDstSB = new TH1F("hd0D0VtxTrueTGHCfromDstarSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, FromDStar,Mass Peak (All momenta)",1000,-1000.,1000.);
5043   hd0D0VtxTrueTGHCfromDstSB->SetXTitle("Impact parameter [#mum]");
5044   hd0D0VtxTrueTGHCfromDstSB->SetYTitle("Entries");
5045
5046   TH1F *hMCd0D0TGHCfromDstSB = new TH1F("hMCd0D0TGHCfromDstarSB","D^{0} impact par. plot, Tight Cuts, FromDStar,Mass Peak  (All momenta)",1000,-1000.,1000.);
5047   hMCd0D0TGHCfromDstSB->SetXTitle("MC Impact parameter [#mum]");
5048   hMCd0D0TGHCfromDstSB->SetYTitle("Entries");
5049
5050   flistTghCutsFromDstar->Add(hd0D0TGHCfromDstPM);
5051   flistTghCutsFromDstar->Add(hd0D0VtxTrueTGHCfromDstPM);
5052   flistTghCutsFromDstar->Add(hMCd0D0TGHCfromDstPM);
5053   flistTghCutsFromDstar->Add(hd0D0TGHCfromDstSB);
5054   flistTghCutsFromDstar->Add(hd0D0VtxTrueTGHCfromDstSB);
5055   flistTghCutsFromDstar->Add(hMCd0D0TGHCfromDstSB);
5056   
5057   TH1F *hd0D0ptTGHCfromDstPM;
5058   TH1F *hMCd0D0ptTGHCfromDstPM;
5059   TH1F *hd0D0VtxTrueptTGHCfromDstPM;
5060   TH1F *hd0D0ptTGHCfromDstSB;
5061   TH1F *hMCd0D0ptTGHCfromDstSB;
5062   TH1F *hd0D0VtxTrueptTGHCfromDstSB;
5063   namehist="hd0D0ptTGHCfromDstar_";
5064   titlehist="D^{0} impact par. plot, Tight Cuts, FromDStar, ";
5065   for(Int_t i=0;i<fnbins;i++){
5066     strnamept=namehist;
5067     strnamept.Append("PkMss_pt");
5068     strnamept+=i;
5069
5070     strtitlept=titlehist;
5071     strtitlept.Append(" Mass Peak, ");
5072     strtitlept+=fptbins[i];
5073     strtitlept.Append("<= pt <");
5074     strtitlept+=fptbins[i+1];
5075     strtitlept.Append(" [GeV/c]");
5076     
5077     hd0D0ptTGHCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5078     hd0D0ptTGHCfromDstPM->SetXTitle("Impact parameter [#mum] ");
5079     hd0D0ptTGHCfromDstPM->SetYTitle("Entries");
5080     flistTghCutsFromDstar->Add(hd0D0ptTGHCfromDstPM);
5081
5082     strnamept.ReplaceAll("hd0D0","hMCd0D0");
5083     hMCd0D0ptTGHCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5084     hMCd0D0ptTGHCfromDstPM->SetXTitle("MC Impact parameter [#mum] ");
5085     hMCd0D0ptTGHCfromDstPM->SetYTitle("Entries");
5086     flistTghCutsFromDstar->Add(hMCd0D0ptTGHCfromDstPM);
5087  
5088
5089     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
5090     hd0D0VtxTrueptTGHCfromDstPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5091     hd0D0VtxTrueptTGHCfromDstPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
5092     hd0D0VtxTrueptTGHCfromDstPM->SetYTitle("Entries");
5093     flistTghCutsFromDstar->Add(hd0D0VtxTrueptTGHCfromDstPM);
5094     
5095     strnamept=namehist;
5096     strnamept.Append("SBMss_pt");
5097     strnamept+=i;
5098
5099     strtitlept=titlehist;
5100     strtitlept.Append(" Side Bands, ");
5101     strtitlept+=fptbins[i];
5102     strtitlept.Append("<= pt <");
5103     strtitlept+=fptbins[i+1];
5104     strtitlept.Append(" [GeV/c]");
5105     
5106     hd0D0ptTGHCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5107     hd0D0ptTGHCfromDstSB->SetXTitle("Impact parameter [#mum] ");
5108     hd0D0ptTGHCfromDstSB->SetYTitle("Entries");
5109     flistTghCutsFromDstar->Add(hd0D0ptTGHCfromDstSB);
5110
5111     strnamept.ReplaceAll("hd0D0","hMCd0D0");
5112     hMCd0D0ptTGHCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5113     hMCd0D0ptTGHCfromDstSB->SetXTitle("MC Impact parameter [#mum] ");
5114     hMCd0D0ptTGHCfromDstSB->SetYTitle("Entries");
5115     flistTghCutsFromDstar->Add(hMCd0D0ptTGHCfromDstSB);
5116
5117     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
5118     hd0D0VtxTrueptTGHCfromDstSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5119     hd0D0VtxTrueptTGHCfromDstSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
5120     hd0D0VtxTrueptTGHCfromDstSB->SetYTitle("Entries");
5121     flistTghCutsFromDstar->Add(hd0D0VtxTrueptTGHCfromDstSB);
5122   }
5123
5124
5125   //############ TIGHT CUTS OTHER HISTOGRAMS ###########
5126   //
5127   //########### global properties histos ###########
5128
5129   TH2F *hCPtaVSd0d0TGHCother=new TH2F("hCPtaVSd0d0TGHCother","hCPtaVSd0d0_TightCuts_other",1000,-100000.,100000.,100,-1.,1.);
5130   TH1F *hSecVtxZTGHCother=new TH1F("hSecVtxZTGHCother","hSecVtxZ_TightCuts_other",1000,-8.,8.);
5131   TH1F *hSecVtxXTGHCother=new TH1F("hSecVtxXTGHCother","hSecVtxX_TightCuts_other",1000,-3000.,3000.);
5132   TH1F *hSecVtxYTGHCother=new TH1F("hSecVtxYTGHCother","hSecVtxY_TightCuts_other",1000,-3000.,3000.);
5133   TH2F *hSecVtxXYTGHCother=new TH2F("hSecVtxXYTGHCother","hSecVtxXY_TightCuts_other",1000,-3000.,3000.,1000,-3000.,3000.);
5134   TH1F *hSecVtxPhiTGHCother=new TH1F("hSecVtxPhiTGHCother","hSecVtxPhi_TightCuts_other",180,-180.1,180.1);
5135   TH1F *hd0singlTrackTGHCother=new TH1F("hd0singlTrackTGHCother","hd0singlTrackTightCuts_Other",1000,-5000.,5000.);
5136   TH1F *hCPtaTGHCother=new TH1F("hCPtaTGHCother","hCPta_TightCuts_other",100,-1.,1.);
5137   TH1F *hd0xd0TGHCother=new TH1F("hd0xd0TGHCother","hd0xd0_TightCuts_other",1000,-100000.,100000.);
5138   TH1F *hMassTrueTGHCother=new TH1F("hMassTrueTGHCother","D^{0} MC inv. Mass Tight Cuts other(All momenta)",600,1.600,2.200);
5139   TH1F *hMassTGHCother=new TH1F("hMassTGHCother","D^{0} inv. Mass Tight Cuts other (All momenta)",600,1.600,2.200);
5140   hMassTGHCother->Sumw2();
5141   TH1F *hMassTrueTGHCotherPM=new TH1F("hMassTrueTGHCotherPM","D^{0} MC inv. Mass Tight Cuts other, Mass Peak. (All momenta)",600,1.600,2.200);
5142   TH1F *hMassTGHCotherPM=new TH1F("hMassTGHCotherPM","D^{0} inv. Mass Tight Cuts other (All momenta), MassPeak",600,1.600,2.200);
5143   hMassTGHCotherPM->Sumw2();
5144   TH1F *hMassTrueTGHCotherSB=new TH1F("hMassTrueTGHCotherSB","D^{0} MC inv. Mass in Side Bands Tight Cuts other(All momenta)",600,1.600,2.200);
5145   TH1F *hMassTGHCotherSB=new TH1F("hMassTGHCotherSB","D^{0} inv. Mass in Side Bands Tight Cuts other (All momenta)",600,1.600,2.200);
5146   hMassTGHCotherSB->Sumw2();
5147
5148   flistTghCutsOther->Add(hCPtaVSd0d0TGHCother);
5149   flistTghCutsOther->Add(hSecVtxZTGHCother);
5150   flistTghCutsOther->Add(hSecVtxYTGHCother);
5151   flistTghCutsOther->Add(hSecVtxXTGHCother);
5152   flistTghCutsOther->Add(hSecVtxXYTGHCother);
5153   flistTghCutsOther->Add(hSecVtxPhiTGHCother);
5154   flistTghCutsOther->Add(hd0singlTrackTGHCother);
5155   flistTghCutsOther->Add(hCPtaTGHCother);
5156   flistTghCutsOther->Add(hd0xd0TGHCother);
5157   flistTghCutsOther->Add(hMassTrueTGHCother);
5158   flistTghCutsOther->Add(hMassTGHCother);
5159   flistTghCutsOther->Add(hMassTrueTGHCotherPM);
5160   flistTghCutsOther->Add(hMassTGHCotherPM);
5161   flistTghCutsOther->Add(hMassTrueTGHCotherSB);
5162   flistTghCutsOther->Add(hMassTGHCotherSB);
5163
5164
5165
5166
5167  //%%% NEW HISTOS %%%%%%%%%%%%%%%%
5168   TH1F *hdcaTGHCother=new TH1F("hdcaTGHCother","hdca_TightCuts_Other",100,0.,1000.);
5169   hdcaTGHCother->SetXTitle("dca   [#mum]");
5170   hdcaTGHCother->SetYTitle("Entries");
5171   TH1F *hcosthetastarTGHCother=new TH1F("hcosthetastarTGHCother","hCosThetaStar_TightCuts_Other",50,-1.,1.);
5172   hcosthetastarTGHCother->SetXTitle("cos #theta^{*}");
5173   hcosthetastarTGHCother->SetYTitle("Entries");
5174   TH1F *hptD0TGHCother=new TH1F("hptD0TGHCother","D^{0} transverse momentum distribution",34,ptbinsD0arr);
5175   hptD0TGHCother->SetXTitle("p_{t}  [GeV/c]");
5176   hptD0TGHCother->SetYTitle("Entries");
5177   TH1F *hptD0VsMaxPtTGHCother=new TH1F("hptD0VsMaxPtTGHCother","Difference between D^{0} pt and highest (or second) pt",400,-50.,50.);
5178   TH2F *hptD0PTallsqrtTGHCother=new TH2F("hptD0PTallsqrtTGHCother","D^{0} pt Vs Sqrt(Sum pt square)",34,ptbinsD0arr,200,dumbinning);
5179   TH2F *hptD0PTallTGHCother=new TH2F("hptD0PTallTGHCother","D^{0} pt Vs Sum pt ",34,ptbinsD0arr,200,dumbinning);
5180   TH2F *hptD0vsptBTGHCother=new TH2F("hptD0vsptBTGHCother","D^{0} pt Vs B pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
5181   TH2F *hpD0vspBTGHCother=new TH2F("hpD0vspBTGHCother","D^{0} tot momentum Vs B tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
5182   TH2F *hptD0vsptcquarkTGHCother=new TH2F("hptD0vsptcquarkTGHCother","D^{0} pt Vs cquark pt distribution",34,ptbinsD0arr,34,ptbinsD0arr);
5183   TH2F *hpD0vspcquarkTGHCother=new TH2F("hpD0vspcquarkTGHCother","D^{0} tot momentum Vs cquark tot momentum distribution",34,ptbinsD0arr,34,ptbinsD0arr);
5184   flistTghCutsOther->Add(hdcaTGHCother);
5185   flistTghCutsOther->Add(hcosthetastarTGHCother);
5186   flistTghCutsOther->Add(hptD0TGHCother);
5187   flistTghCutsOther->Add(hptD0VsMaxPtTGHCother);
5188   flistTghCutsOther->Add(hptD0PTallsqrtTGHCother);
5189   flistTghCutsOther->Add(hptD0PTallTGHCother);
5190   flistTghCutsOther->Add(hptD0vsptBTGHCother);
5191   flistTghCutsOther->Add(hpD0vspBTGHCother);
5192   flistTghCutsOther->Add(hptD0vsptcquarkTGHCother);
5193   flistTghCutsOther->Add(hpD0vspcquarkTGHCother);
5194
5195   TH1F *hd0zD0ptTGHCother;
5196   TH1F *hInvMassD0TGHCother,*hInvMassD0barTGHCother;
5197   TH2F *hInvMassPtTGHCother=new TH2F("hInvMassPtTGHCother","Candidate p_{t} Vs invariant mass",330,1.700,2.030,200,0.,20.);
5198   THnSparseF *hSparseTGHCother=new THnSparseF("hSparseTGHCother","Candidate Masses, pt, Imp Par;massD0;massD0bar;pt;impactpar;selcase",5,nbinsSparse);
5199   hSparseTGHCother->SetBinEdges(0,massbins);
5200   hSparseTGHCother->SetBinEdges(1,massbins);
5201   hSparseTGHCother->SetBinEdges(2,ptbinsForNsparse);
5202   hSparseTGHCother->SetBinEdges(3,impparbins);
5203   hSparseTGHCother->SetBinEdges(4,massHypoBins); 
5204   flistTghCutsOther->Add(hSparseTGHCother);
5205   TH1F *hetaTGHCother;
5206   TH1F *hCosPDPBTGHCother;
5207   TH1F *hCosPcPDTGHCother;
5208   flistTghCutsOther->Add(hInvMassPtTGHCother);
5209 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
5210   TH2F *hd0D0VSd0xd0TGHCotherpt;
5211   TH2F *hangletracksVSd0xd0TGHCotherpt;
5212   TH2F *hangletracksVSd0D0TGHCotherpt;
5213   TH1F *hd0xd0TGHCotherpt;
5214
5215   TH2F *hTOFpidTGHCother=new TH2F("hTOFpidTGHCother","TOF time VS momentum",10,0.,4.,50,-50000.,50000.);
5216   flistTghCutsOther->Add(hTOFpidTGHCother);
5217
5218   for(Int_t i=0;i<fnbins;i++){
5219     namehist="hd0zD0ptTGHCother_pt";
5220     namehist+=i;
5221     titlehist="d0(z) Tight Cuts Otherm ptbin=";
5222     titlehist+=i;
5223     hd0zD0ptTGHCother=new TH1F(namehist.Data(),titlehist.Data(),1000,-3000,3000.);
5224     hd0zD0ptTGHCother->SetXTitle("d_{0}(z)    [#mum]");
5225     hd0zD0ptTGHCother->SetYTitle("Entries");
5226     flistTghCutsOther->Add(hd0zD0ptTGHCother);
5227
5228     namehist="hInvMassD0TGHCother_pt";
5229     namehist+=i;
5230     titlehist="Invariant Mass Tight Cuts Other ptbin=";
5231     titlehist+=i;
5232     hInvMassD0TGHCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
5233     hInvMassD0TGHCother->SetXTitle("Invariant Mass    [GeV]");
5234     hInvMassD0TGHCother->SetYTitle("Entries");
5235     flistTghCutsOther->Add(hInvMassD0TGHCother);
5236
5237     namehist="hInvMassD0barTGHCother_pt";
5238     namehist+=i;
5239     titlehist="Invariant Mass D0bar Tight Cuts Other ptbin=";
5240     titlehist+=i;
5241     hInvMassD0barTGHCother=new TH1F(namehist.Data(),titlehist.Data(),600,1.600,2.200);
5242     hInvMassD0barTGHCother->SetXTitle("Invariant Mass    [GeV]");
5243     hInvMassD0barTGHCother->SetYTitle("Entries");
5244     flistTghCutsOther->Add(hInvMassD0barTGHCother);
5245
5246     namehist="hetaTGHCother_pt";
5247     namehist+=i;
5248     titlehist="eta Tight Cuts Other ptbin=";
5249     titlehist+=i;
5250     hetaTGHCother=new TH1F(namehist.Data(),titlehist.Data(),100,-3.,3.);
5251     hetaTGHCother->SetXTitle("Pseudorapidity");
5252     hetaTGHCother->SetYTitle("Entries");
5253     flistTghCutsOther->Add(hetaTGHCother);
5254
5255     namehist="hCosPDPBTGHCother_pt";
5256     namehist+=i;
5257     titlehist="Cosine between D0 momentum and B momentum, ptbin=";
5258     titlehist+=i;
5259     hCosPDPBTGHCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
5260     hCosPDPBTGHCother->SetXTitle("Cosine between D0 momentum and B momentum");
5261     hCosPDPBTGHCother->SetYTitle("Entries");
5262     flistTghCutsOther->Add(hCosPDPBTGHCother);
5263
5264     namehist="hCosPcPDTGHCother_pt";
5265     namehist+=i;
5266     titlehist="Cosine between cquark momentum and D0 momentum, ptbin=";
5267     titlehist+=i;
5268     hCosPcPDTGHCother=new TH1F(namehist.Data(),titlehist.Data(),50,-1.,1.);
5269     hCosPcPDTGHCother->SetXTitle("Cosine between c quark momentum and D0 momentum");
5270     hCosPcPDTGHCother->SetYTitle("Entries");
5271     flistTghCutsOther->Add(hCosPcPDTGHCother);
5272
5273 // %%%%%%%%%%% HERE THE ADDITIONAL HISTS %%%%%%%%%%%%%%%%%
5274     namehist="hd0xd0TGHCother_pt";
5275     namehist+=i;
5276     titlehist="d0xd0 Tight Cuts Other ptbin=";
5277     titlehist+=i;
5278     hd0xd0TGHCotherpt=new TH1F(namehist.Data(),titlehist.Data(),1000,-50000.,10000.);
5279     hd0xd0TGHCotherpt->SetXTitle("d_{0}^{K}xd_{0}^{#pi}   [#mum^2]");
5280     hd0xd0TGHCotherpt->SetYTitle("Entries");
5281     flistTghCutsOther->Add(hd0xd0TGHCotherpt);
5282
5283
5284     namehist="hd0D0VSd0xd0TGHCother_pt";
5285     namehist+=i;
5286     titlehist="d_{0}^{D^{0}} Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Other ptbin=";
5287     titlehist+=i;
5288     hd0D0VSd0xd0TGHCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,100,-300,300);
5289     hd0D0VSd0xd0TGHCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
5290     hd0D0VSd0xd0TGHCotherpt->SetYTitle(" d_{0}^{D^{0}}    [#mum]");
5291     flistTghCutsOther->Add(hd0D0VSd0xd0TGHCotherpt);
5292     
5293     
5294     namehist="hangletracksVSd0xd0TGHCother_pt";
5295     namehist+=i;
5296     titlehist="Angle between K and #pi tracks Vs d_{0}^{K}xd_{0}^{#pi} Tight Cuts Other ptbin=";
5297     titlehist+=i;
5298     hangletracksVSd0xd0TGHCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-50000.,30000.,40,-0.1,3.24);
5299     hangletracksVSd0xd0TGHCotherpt->SetXTitle(" d_{0}^{K}xd_{0}^{#pi} [#mum]");
5300     hangletracksVSd0xd0TGHCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
5301     flistTghCutsOther->Add(hangletracksVSd0xd0TGHCotherpt);
5302     
5303
5304     namehist="hangletracksVSd0D0TGHCother_pt";
5305     namehist+=i;
5306     titlehist="Angle between K and #pi tracks Vs d_{0}^{D^{0}} Tight Cuts Other ptbin=";
5307     titlehist+=i;
5308     hangletracksVSd0D0TGHCotherpt=new TH2F(namehist.Data(),titlehist.Data(),200,-400.,400.,40,-0.12,3.24);
5309     hangletracksVSd0D0TGHCotherpt->SetXTitle(" d_{0}^{D^{0}} [#mum]");
5310     hangletracksVSd0D0TGHCotherpt->SetYTitle(" angle between K and #p tracks  [rad]");
5311     flistTghCutsOther->Add(hangletracksVSd0D0TGHCotherpt);
5312     
5313   }
5314   // %%%%%%%% END OF NEW HISTOS %%%%%%%%%%%%%
5315   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5316
5317
5318
5319
5320
5321   //############# d0 D0 histos ###############à
5322   TH1F *hd0D0TGHCotherPM = new TH1F("hd0D0TGHCotherPM","D^{0} impact par. plot , Tight Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
5323   hd0D0TGHCotherPM->SetXTitle("Impact parameter [#mum]");
5324   hd0D0TGHCotherPM->SetYTitle("Entries");
5325
5326   TH1F *hd0D0VtxTrueTGHCotherPM = new TH1F("hd0D0VtxTrueTGHCotherPM","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
5327   hd0D0VtxTrueTGHCotherPM->SetXTitle("Impact parameter [#mum]");
5328   hd0D0VtxTrueTGHCotherPM->SetYTitle("Entries");
5329
5330   TH1F *hMCd0D0TGHCotherPM = new TH1F("hMCd0D0TGHCotherPM","D^{0} impact par. plot, Tight Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
5331   hMCd0D0TGHCotherPM->SetXTitle("MC Impact parameter [#mum]");
5332   hMCd0D0TGHCotherPM->SetYTitle("Entries");
5333
5334   TH1F *hd0D0TGHCotherSB = new TH1F("hd0D0TGHCotherSB","D^{0} impact par. plot , Tight Cuts ,Other,Mass Peak (All momenta)",1000,-1000.,1000.);
5335   hd0D0TGHCotherSB->SetXTitle("Impact parameter [#mum]");
5336   hd0D0TGHCotherSB->SetYTitle("Entries");
5337
5338   TH1F *hd0D0VtxTrueTGHCotherSB = new TH1F("hd0D0VtxTrueTGHCotherSB","D^{0} impact par. w.r.t. True Vtx, Tight Cuts, Other,Mass Peak (All momenta)",1000,-1000.,1000.);
5339   hd0D0VtxTrueTGHCotherSB->SetXTitle("Impact parameter [#mum]");
5340   hd0D0VtxTrueTGHCotherSB->SetYTitle("Entries");
5341
5342   TH1F *hMCd0D0TGHCotherSB = new TH1F("hMCd0D0TGHCotherSB","D^{0} impact par. plot, Tight Cuts, Other,Mass Peak  (All momenta)",1000,-1000.,1000.);
5343   hMCd0D0TGHCotherSB->SetXTitle("MC Impact parameter [#mum]");
5344   hMCd0D0TGHCotherSB->SetYTitle("Entries");
5345
5346   flistTghCutsOther->Add(hd0D0TGHCotherPM);
5347   flistTghCutsOther->Add(hd0D0VtxTrueTGHCotherPM);
5348   flistTghCutsOther->Add(hMCd0D0TGHCotherPM);
5349   flistTghCutsOther->Add(hd0D0TGHCotherSB);
5350   flistTghCutsOther->Add(hd0D0VtxTrueTGHCotherSB);
5351   flistTghCutsOther->Add(hMCd0D0TGHCotherSB);
5352   
5353   TH1F *hd0D0ptTGHCotherPM;
5354   TH1F *hMCd0D0ptTGHCotherPM;
5355   TH1F *hd0D0VtxTrueptTGHCotherPM;
5356   TH1F *hd0D0ptTGHCotherSB;
5357   TH1F *hMCd0D0ptTGHCotherSB;
5358   TH1F *hd0D0VtxTrueptTGHCotherSB;
5359   namehist="hd0D0ptTGHCother_";
5360   titlehist="D^{0} impact par. plot, Tight Cuts, Other, ";
5361   for(Int_t i=0;i<fnbins;i++){
5362     strnamept=namehist;
5363     strnamept.Append("PkMss_pt");
5364     strnamept+=i;
5365
5366     strtitlept=titlehist;
5367     strtitlept.Append(" Mass Peak, ");
5368     strtitlept+=fptbins[i];
5369     strtitlept.Append("<= pt <");
5370     strtitlept+=fptbins[i+1];
5371     strtitlept.Append(" [GeV/c]");
5372     
5373     hd0D0ptTGHCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5374     hd0D0ptTGHCotherPM->SetXTitle("Impact parameter [#mum] ");
5375     hd0D0ptTGHCotherPM->SetYTitle("Entries");
5376     flistTghCutsOther->Add(hd0D0ptTGHCotherPM);
5377
5378     strnamept.ReplaceAll("hd0D0","hMCd0D0");
5379     hMCd0D0ptTGHCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5380     hMCd0D0ptTGHCotherPM->SetXTitle("MC Impact parameter [#mum] ");
5381     hMCd0D0ptTGHCotherPM->SetYTitle("Entries");
5382     flistTghCutsOther->Add(hMCd0D0ptTGHCotherPM);
5383  
5384
5385     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
5386     hd0D0VtxTrueptTGHCotherPM = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5387     hd0D0VtxTrueptTGHCotherPM->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
5388     hd0D0VtxTrueptTGHCotherPM->SetYTitle("Entries");
5389     flistTghCutsOther->Add(hd0D0VtxTrueptTGHCotherPM);
5390     
5391     strnamept=namehist;
5392     strnamept.Append("SBMss_pt");
5393     strnamept+=i;
5394
5395     strtitlept=titlehist;
5396     strtitlept.Append(" Side Bands, ");
5397     strtitlept+=fptbins[i];
5398     strtitlept.Append("<= pt <");
5399     strtitlept+=fptbins[i+1];
5400     strtitlept.Append(" [GeV/c]");
5401     
5402     hd0D0ptTGHCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5403     hd0D0ptTGHCotherSB->SetXTitle("Impact parameter [#mum] ");
5404     hd0D0ptTGHCotherSB->SetYTitle("Entries");
5405     flistTghCutsOther->Add(hd0D0ptTGHCotherSB);
5406
5407     strnamept.ReplaceAll("hd0D0","hMCd0D0");
5408     hMCd0D0ptTGHCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5409     hMCd0D0ptTGHCotherSB->SetXTitle("MC Impact parameter [#mum] ");
5410     hMCd0D0ptTGHCotherSB->SetYTitle("Entries");
5411     flistTghCutsOther->Add(hMCd0D0ptTGHCotherSB);
5412
5413     strnamept.ReplaceAll("hMCd0D0","hd0D0VtxTrue");
5414     hd0D0VtxTrueptTGHCotherSB = new TH1F(strnamept.Data(),strtitlept.Data(),1000,-1000.,1000.);
5415     hd0D0VtxTrueptTGHCotherSB->SetXTitle("Impact parameter w.r.t. True Vtx [#mum] ");
5416     hd0D0VtxTrueptTGHCotherSB->SetYTitle("Entries");
5417     flistTghCutsOther->Add(hd0D0VtxTrueptTGHCotherSB);
5418   }
5419   Printf("AFTER DATA HISTOS CREATION \n");
5420
5421   delete ptbinlimitsCxyLxy;
5422
5423
5424   PostData(1,fNentries);
5425   PostData(2,fSignalType);
5426   PostData(3,fSignalTypeLsCuts);
5427   PostData(4,fSignalTypeTghCuts);
5428   PostData(5,fCounter);
5429   PostData(6,flistMCproperties);
5430   PostData(7,flistNoCutsSignal);
5431   PostData(8,flistNoCutsBack);
5432   PostData(9,flistNoCutsFromB);
5433   PostData(10,flistNoCutsFromDstar);
5434   PostData(11,flistNoCutsOther);
5435   PostData(12,flistLsCutsSignal);
5436   PostData(13,flistLsCutsBack);
5437   PostData(14,flistLsCutsFromB);
5438   PostData(15,flistLsCutsFromDstar);
5439   PostData(16,flistLsCutsOther);
5440   PostData(17,flistTghCutsSignal);
5441   PostData(18,flistTghCutsBack);
5442   PostData(19,flistTghCutsFromB);
5443   PostData(20,flistTghCutsFromDstar);
5444   PostData(21,flistTghCutsOther);
5445
5446   return;
5447
5448 }
5449
5450
5451
5452
5453
5454 //________________________________________________________________________
5455 void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
5456 {
5457   // Execute analysis for current event:
5458   // heavy flavor candidates association to MC truth
5459   
5460   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
5461   if (!aod) {
5462     Printf("ERROR: aod not available");
5463     return;
5464   }
5465   TClonesArray *arrayD0toKpi=NULL;
5466   if(!aod && AODEvent() && IsStandardAOD()) {
5467     // In case there is an AOD handler writing a standard AOD, use the AOD 
5468     // event in memory rather than the input (ESD) event.    
5469     aod = dynamic_cast<AliAODEvent*> (AODEvent());
5470     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
5471     // have to taken from the AOD event hold by the AliAODExtension
5472     AliAODHandler* aodHandler = (AliAODHandler*) 
5473       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
5474
5475     if(aodHandler->GetExtensions()) {
5476       AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
5477       AliAODEvent* aodFromExt = ext->GetAOD();
5478       if(fLikeSign){
5479         // load 2Prong Like Sign                                                   
5480         arrayD0toKpi =(TClonesArray*)aodFromExt->GetList()->FindObject("LikeSign2Prong");
5481         if(!arrayD0toKpi) {
5482           Printf("AliAnalysisTaskSECharmFraction::UserExec: LikeSign branch not found!\n");
5483           return;
5484         }
5485       }
5486       else {
5487         // load D0->Kpi candidates                                                   
5488         arrayD0toKpi = (TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
5489         if(!arrayD0toKpi) {
5490           Printf("AliAnalysisTaskSECharmFraction::UserExec: D0toKpi branch not found!\n");
5491           return;
5492         }
5493       }  
5494     }
5495   } else {
5496     if(fLikeSign){
5497       // load 2Prong Like Sign                                                   
5498       arrayD0toKpi =(TClonesArray*)aod->GetList()->FindObject("LikeSign2Prong");
5499       if(!arrayD0toKpi) {
5500         Printf("AliAnalysisTaskSECharmFraction::UserExec: LikeSign branch not found!\n");
5501         return;
5502       }
5503     }
5504     else {
5505       // load D0->Kpi candidates                                                   
5506       arrayD0toKpi = (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
5507       if(!arrayD0toKpi) {
5508         Printf("AliAnalysisTaskSECharmFraction::UserExec: D0toKpi branch not found!\n");
5509         return;
5510       }
5511     }     
5512   }
5513
5514
5515   if(!arrayD0toKpi) {
5516     printf("AliAnalysisTaskSECharmFraction::UserExec: input branch not found!\n");
5517     return;
5518   }
5519
5520   //histogram filled with 1 for every AOD
5521   fNentries->Fill(0);
5522   fCounter->StoreEvent(aod,fCutsLoose,fReadMC); 
5523   
5524   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
5525   //  TString trigclass=aod->GetFiredTriggerClasses();
5526   // if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
5527  
5528   Int_t nSelectedloose=0, nSelectedtight=0; 
5529
5530   Bool_t isEventSelTGHT=kTRUE,isEventSelLOOSE=kTRUE;
5531   if(!fskipEventSelection){
5532     if(!fCutsTight->IsEventSelected(aod)){
5533       isEventSelTGHT=kFALSE;
5534       if(fCutsTight->GetWhyRejection()==1){ 
5535         // rejected for pileup
5536         fNentries->Fill(2);    
5537       }
5538       if(fCutsTight->GetWhyRejection()==6){
5539         // |prim Vtx Zspd| > acceptable
5540         fNentries->Fill(4);      
5541       }
5542     }  
5543     else {
5544       fNentries->Fill(1);    
5545     }
5546     if(!fCutsLoose->IsEventSelected(aod)){
5547       isEventSelLOOSE=kFALSE;
5548       if(fCutsLoose->GetWhyRejection()==1){
5549         // rejected for pileup    
5550         fNentries->Fill(9);
5551         
5552       }
5553       if(fCutsLoose->GetWhyRejection()==6){
5554         // |prim Vtx Z| > acceptable
5555         fNentries->Fill(11);      
5556       }
5557     }
5558     else {
5559       fNentries->Fill(8);    
5560     }
5561     
5562     if(!(isEventSelTGHT||isEventSelLOOSE)){
5563       PostData(1,fNentries);
5564       return;
5565     }
5566   }
5567   else{
5568     fCutsTight->SetupPID(aod);
5569     // SHOULD ADD RECOMPUTATION OF PRIMARY VERTEX DONE AT THE BEGINNING OF IS EVENT SELECTED??
5570     // LIKELY NOT NEEDE
5571   }
5572
5573   // fix for temporary bug in ESDfilter
5574   // the AODs with null vertex pointer didn't pass the PhysSel
5575   if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001){
5576     if(isEventSelTGHT)fNentries->Fill(19);
5577     if(isEventSelLOOSE)fNentries->Fill(20);
5578     PostData(1,fNentries);
5579     return;
5580   }
5581   // AOD primary vertex
5582   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
5583   TString primTitle = vtx1->GetTitle();
5584   if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) { 
5585     
5586     if(isEventSelTGHT)fNentries->Fill(3);
5587     if(isEventSelLOOSE)fNentries->Fill(10);
5588   }
5589   else {
5590     PostData(1,fNentries);
5591     return;    
5592   }
5593   if(fskipEventSelection){
5594     //check z of the primary vertex for the cases in which the z vtx > maximum
5595     if(TMath::Abs(vtx1->GetZ())>fZvtxUpgr){
5596         fNentries->Fill(4);      
5597         fNentries->Fill(11);      
5598         PostData(1,fNentries);
5599         return;
5600     }
5601     else {
5602       fNentries->Fill(1);    
5603       fNentries->Fill(8);    
5604     }
5605   }
5606   // FILL n-tracks counter
5607   if(isEventSelTGHT)fNentries->Fill(5,aod->GetNumberOfTracks());
5608   if(isEventSelLOOSE)fNentries->Fill(12,aod->GetNumberOfTracks());
5609   
5610
5611   Bool_t aziListIsFilled=kFALSE;
5612   Double_t azilist[30000];
5613   Int_t trkIDlist[30000],nprim=0;
5614   
5615  
5616   for(Int_t ephi=0;ephi<30000;ephi++){
5617     azilist[ephi]=-999.;
5618     trkIDlist[ephi]=-999;
5619   }
5620   //aziListIsFilled=kFALSE;
5621     
5622
5623
5624
5625   
5626   TClonesArray *arrayMC=0x0;
5627   AliAODMCHeader *aodmcHeader=0x0;
5628   Double_t vtxTrue[3];
5629  
5630   
5631   if(fReadMC){
5632     // load MC particles
5633     arrayMC = 
5634       (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
5635     if(!arrayMC) {
5636       Printf("AliAnalysisTaskSECharmFraction::UserExec: MC particles branch not found!\n");
5637       return;
5638     }
5639     // load MC header
5640     aodmcHeader = 
5641       (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
5642     if(!aodmcHeader) {
5643       Printf("AliAnalysisTaskSECharmFraction::UserExec: MC header branch not found!\n");
5644       return;
5645     }
5646     // MC primary vertex
5647     aodmcHeader->GetVertex(vtxTrue);
5648     // FILL HISTOS FOR D0 mesons, c quarks and D0 from B properties
5649     FillHistoMCproperties(arrayMC);
5650   }
5651  
5652
5653
5654   //Printf("There are %d tracks in this event", aod->GetNumberOfTracks());
5655   //  Int_t nTotHF=0,nTotDstar=0,nTot3Prong=0;
5656   Int_t nTotD0toKpi=0;
5657   Int_t okd0tight,okd0bartight,okd0loose,okd0barloose,okd0tightnopid,okd0bartightnopid;
5658   Bool_t defaultNC=kTRUE;
5659   Bool_t isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,isSideBand;
5660   Bool_t isinacceptance;
5661   Int_t signallevel=-1;
5662   Int_t ptbin,nVtx; 
5663   //  const  Int_t nptbins=10;
5664   Double_t invMassD0,invMassD0bar,ptD0,massmumtrue;
5665   
5666  
5667   AliAODRecoDecayHF *aodDMC=0x0;// to be used to create a fake true sec vertex
5668   // make trkIDtoEntry register (temporary)  
5669   
5670   if(fFastAnalysis<1){
5671     Int_t trkIDtoEntry[100000];
5672     fptAll=0.;
5673     fptAllSq=0.;
5674     fptMax[0]=0.;
5675     fptMax[1]=0.;
5676     fptMax[2]=0.;
5677     for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
5678       AliAODTrack *track = dynamic_cast<AliAODTrack*>(aod->GetTrack(it));
5679       if(!track) AliFatal("Not a standard AOD");
5680       fptAll+=track->Pt();
5681       fptAllSq+=track->Pt()*track->Pt();
5682       if(track->Pt()>fptMax[0]){
5683         fptMax[2]=fptMax[1];
5684         fptMax[1]=fptMax[0];
5685         fptMax[0]=track->Pt();
5686       }
5687       else if(track->Pt()>fptMax[1]){
5688         fptMax[2]=fptMax[1];
5689         fptMax[1]=track->Pt();
5690       }
5691       else if(track->Pt()>fptMax[2])fptMax[2]=track->Pt();
5692       if(track->GetID()<0) {
5693         if(isEventSelTGHT)fNentries->Fill(19);
5694         if(isEventSelLOOSE)fNentries->Fill(20);
5695         //printf("Track ID <0, id= %d\n",track->GetID());
5696         PostData(1,fNentries);
5697         return;
5698       }
5699       trkIDtoEntry[track->GetID()]=it;
5700     }
5701   }
5702
5703   // loop over D0->Kpi candidates
5704   Int_t nD0toKpi = arrayD0toKpi->GetEntriesFast();
5705   nTotD0toKpi += nD0toKpi;
5706   // fille D0 candidate counter 
5707   if(isEventSelTGHT)fNentries->Fill(6,nD0toKpi);
5708   if(isEventSelLOOSE)fNentries->Fill(13,nD0toKpi);
5709   
5710   //    cout<<"Number of D0->Kpi: "<<nD0toKpi<<endl;
5711   
5712   for (Int_t iD0toKpi = 0; iD0toKpi < nD0toKpi; iD0toKpi++) {
5713     if(aodDMC!=0x0)delete aodDMC;
5714       
5715     defaultNC=kTRUE;
5716     isPeakD0=kFALSE;
5717     isPeakD0bar=kFALSE;
5718     isSideBandD0=kFALSE;
5719     isSideBandD0bar=kFALSE;
5720     isSideBand=kFALSE;
5721     isinacceptance=kTRUE;
5722     okd0tight=0;
5723     okd0bartight=0;
5724     okd0tightnopid=0;
5725     okd0bartightnopid=0;
5726     okd0loose=0;
5727     okd0barloose=0;
5728   
5729     signallevel=-1;
5730     
5731    
5732
5733     AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->UncheckedAt(iD0toKpi);
5734     if(fcheckD0Bit&&(!d->HasSelectionBit(AliRDHFCutsD0toKpi::kD0toKpiCuts)))continue;
5735     
5736     //  Bool_t unsetvtx=kFALSE;
5737     //     if(!d->GetOwnPrimaryVtx()) {
5738     //       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
5739     //       unsetvtx=kTRUE;
5740     //     }
5741     
5742     
5743     //recalculate vertex w/o daughters
5744     AliAODVertex *origownvtx=0x0;
5745     if(fCleanCandOwnVtx){      
5746       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
5747       if(!fCutsTight->RecalcOwnPrimaryVtx(d,aod))  defaultNC=kFALSE;   
5748       
5749     }
5750
5751     
5752     // ############ MISALIGN HERE: TEMPORARY SOLUTION ##########
5753     //    d->Misalign("resC");
5754
5755     
5756     //############# SIGNALLEVEL DESCRIPTION #####################
5757     // TO BE CONSIDERED WITH GREAT CARE, only =0 and =1 (and MC selection when possible) are reliable
5758     //                                    For the other signallevel numbers the order in which cut are applied is relevant 
5759     // signallevel =0,1: is selected as signal,is signal (MC)
5760     //               from 2 to 20: MC information
5761     //              from 21 to 29: "detector" selection (acceptance, pt, refits) 
5762     //                                                  21: acceptance, eta (N.B. before 24 May was signallevel=9)     
5763     //                                                  22: isinfiducialacceptance
5764     //                                                  23: single track p
5765     //                                                  25: ITS cluster selection
5766     //                                                  26: TPC refit
5767     //                                                  27: ITS refit
5768     //                                                  28: no (TOF||TPC) pid information (no kTOFpid,kTOFout,kTIME,kTPCpid,...)
5769     //
5770     //              from 30 to 39: PID selection
5771     //                                                  31: no Kaon compatible tracks found between daughters
5772     //                                                  32: no Kaon identified tracks found (strong sel. at low momenta)
5773     //                                                  33: both mass hypotheses are rejected 
5774     //              from 40 to 45: standard cut selection
5775     //              from 45 to 49: special cut signal kinematic selection
5776     //                                                  46: pstar cut
5777     //              from 50 to 60: special cut selection
5778     //                                                  51: Nvtx contributors
5779     //                                                  52: angle between tracks
5780     //                                                  53: vtx not reconstructed when excludind daughters 
5781     //                                                  54: track not propagated to dca when the vtx is recalculated
5782     //                                                  55: single track normalized impact par.
5783     //                                                  56: normalized d0xd0 
5784     //                                                  57: d0xd0 cut with vtx on the fly
5785     //                                                  58,59: cut normalized decay lenght and decay lenght
5786     //####### DATA SELECTION ####################################
5787     //
5788     // ######## CHECK FOR ACCEPTANCE ##########
5789     ptD0=d->Pt();
5790     ptbin=fCutsTight->PtBin(ptD0);
5791     //    Double_t relangle=d->ProngsRelAngle(0,1);
5792     // UPV: HERE TO CHANGE WITH:
5793      //  isinacceptance = (TMath::Abs(d->EtaProng(0))<fAcceptanceCuts[0]&&TMath::Abs(d->EtaProng(1))<fAcceptanceCuts[0]); //eta acceptance 
5794
5795     // INVESTIGATE SIGNAL TYPE : ACCESS TO MC INFORMATION
5796     Int_t isD0D0barMC=0;
5797     if(fReadMC){
5798       if(fselectForUpgrade){
5799         TString nameGen;        
5800         Int_t generator=0;// adding per track: -1 hijing; 0-pythiaHF; 2-the rest  --> -2= pure hijing -> back ok (but check identity); 0= phytia,pythia-> ok for checking signal; reject the rest: -1 (Hij,pyt), 1 (hij, rest), 2 (pythia,rest) ,4 (rest,rest) 
5801         for(Int_t jp=0;jp<2;jp++){
5802           AliAODTrack *daughA=(AliAODTrack*)d->GetDaughter(0);
5803           fVertUtil->GetTrackPrimaryGenerator(daughA,aodmcHeader,arrayMC,nameGen);
5804           if(nameGen.Contains("ijing")){
5805             generator+=-1;
5806           }
5807           else if(!nameGen.Contains("pythia")){
5808             generator+=2;
5809           }
5810         }
5811         if(generator==-2){
5812           Int_t pdgdaughters[2]={211,321};
5813           Int_t labMum=d->MatchToMC(421,arrayMC,2,pdgdaughters);
5814           if(labMum<0)signallevel=-1;
5815           else signallevel=-2;
5816         }
5817         else if (generator==0){
5818           aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue,isD0D0barMC);
5819         }
5820         else{
5821           signallevel=-3;
5822         }
5823         if(fVertUtil->IsCandidateInjected(d,aodmcHeader,arrayMC)){
5824           //      Printf("The candidate is injected and generator is : %d",generator);
5825         }
5826         else {
5827           //      Printf("The candidate is not injected and generator is : %d",generator);
5828         }
5829       }      
5830       else {
5831         aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue,isD0D0barMC);
5832       }
5833     }
5834     else signallevel=0;
5835     //   ACCOUNT FOR ETA & ITS CLUSTER SELECTION
5836     if(fFastAnalysis<1){  // ALREADY DONE BY AliRDHFCutsD0ToKPi selection
5837       isinacceptance=fCutsTight->AreDaughtersSelected(d); 
5838       if(!isinacceptance)signallevel=21;
5839     }
5840     if(!fCutsTight->IsInFiducialAcceptance(ptD0,d->Y(421))){
5841       isinacceptance=kFALSE;
5842       signallevel=22; 
5843     }
5844     else{
5845       nSelectedloose++;
5846     }
5847    
5848     //###################################################################################
5849     //
5850     // ################ SPECIAL ADDITIONAL CUTS FOR SIGNAL SEARCH #######################
5851     //  UPV: ITS CLUSTER SELECTION ALREADY DONE , COUNT THEM THE SAME
5852     //  
5853     Int_t nlayers=0,nSPD=0,nSSD=0;
5854     Bool_t spd1=kFALSE;
5855     if(fFastAnalysis<1){
5856       for(Int_t idg=0;idg<d->GetNDaughters();idg++){
5857         
5858         AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(idg);
5859         if(TESTBIT(dgTrack->GetITSClusterMap(),5)){
5860           nlayers++;
5861           nSSD++;
5862         }
5863       if(TESTBIT(dgTrack->GetITSClusterMap(),4)){
5864         nlayers++;
5865         nSSD++;
5866       }
5867       if(TESTBIT(dgTrack->GetITSClusterMap(),3))nlayers++;
5868       if(TESTBIT(dgTrack->GetITSClusterMap(),2))nlayers++;
5869       if(TESTBIT(dgTrack->GetITSClusterMap(),1)){
5870         nlayers++;
5871         nSPD++;
5872       }
5873       if(TESTBIT(dgTrack->GetITSClusterMap(),0)){
5874         nlayers++;
5875         nSPD++;
5876         spd1=kTRUE;
5877       }
5878       }
5879     }
5880     /*
5881       // ######## NOW SELECTION ##########
5882       if(dgTrack->Pt()<0.5){
5883         // ########## k-Both selection ##############
5884         if(nlayers<5)signallevel=25;
5885         if(nSPD<2)signallevel=25;
5886       }
5887       else if(dgTrack->Pt()<1.){
5888         // ########## 4 its clust (1 SSD,1 SPD) && k-Any selection ##############
5889         if(nlayers<4)signallevel=25;
5890         if(nSSD<1)signallevel=25;
5891         if(nSPD<1)signallevel=25;
5892       }
5893       else{ 
5894         // ########## 3 its clust (1 SPD, 1 SSD) && k-Any selection ##########
5895         if(nlayers<3)signallevel=25;
5896         if(nSSD<1)signallevel=25;
5897         if(nSPD<1)signallevel=25;           
5898       }
5899     }
5900   */
5901
5902
5903    
5904
5905     //###########   END OF SPECIAL CUTS        ######################
5906     //
5907     //###############################################################
5908
5909     // NOW APPLY CUTS
5910     // Check tighter cuts w/o PID:
5911     // 
5912     //    Int_t ncont=vtx1->GetNContributors();   
5913     if(fFastAnalysis<1)if(vtx1->GetNContributors()<1)signallevel=51;
5914   
5915     if(defaultNC&&fFastAnalysis<1&&fNtrMaxforVtx<2)defaultNC=SpecialSelD0(d,nVtx);// No More in USE!
5916     if(isEventSelTGHT&&defaultNC){
5917       Bool_t iscutusingpid=fCutsTight->GetIsUsePID();
5918       fCutsTight->SetUsePID(kFALSE);
5919       Int_t isSelectedTightNoPid=fCutsTight->IsSelected(d,AliRDHFCuts::kAll,aod);
5920       switch(isSelectedTightNoPid){
5921       case 0:
5922         okd0tightnopid=kFALSE;
5923         okd0bartightnopid=kFALSE;
5924         break;
5925       case 1:
5926         okd0tightnopid=kTRUE;
5927         okd0bartightnopid=kFALSE;
5928         break;
5929       case 2:
5930         okd0tightnopid=kFALSE;
5931         okd0bartightnopid=kTRUE;
5932         break;
5933       case 3:
5934         okd0tightnopid=kTRUE;
5935         okd0bartightnopid=kTRUE;
5936         break;
5937       default:
5938         okd0tightnopid=kTRUE;
5939         okd0bartightnopid=kTRUE;
5940         break;
5941       }
5942       
5943     
5944       //    signallevel=fCutsTight->GetSelectionStep();
5945       fSignalType->Fill(signallevel);
5946       
5947     
5948       
5949       
5950       // ######### SPECIAL SELECTION PID ##############
5951       fCutsTight->SetUsePID(iscutusingpid);
5952       if(okd0tightnopid||okd0bartightnopid){
5953         Int_t isSelectedPid=fCutsTight->IsSelected(d,AliRDHFCuts::kPID,aod);
5954         Int_t isSelectedTight=fCutsTight->CombineSelectionLevels(3,isSelectedTightNoPid,isSelectedPid);
5955         switch(isSelectedTight){
5956         case 0:
5957           okd0tight=kFALSE;
5958           okd0bartight=kFALSE;
5959           break;
5960         case 1:
5961           okd0tight=kTRUE;
5962           okd0bartight=kFALSE;
5963           break;
5964         case 2:
5965           okd0tight=kFALSE;
5966           okd0bartight=kTRUE;
5967           break;
5968         case 3:
5969           okd0tight=kTRUE;
5970           okd0bartight=kTRUE;
5971           break;
5972         default:
5973           okd0tight=kTRUE;
5974           okd0bartight=kTRUE;
5975           break;
5976         }
5977       }
5978     }
5979     else{
5980       fSignalType->Fill(signallevel);
5981     }
5982
5983     
5984   
5985     
5986     if(isEventSelLOOSE&&defaultNC){
5987       // CHECK LOOSER CUTS 
5988       //ptbin=SetStandardCuts(ptD0,flargeInvMassCut);
5989       
5990       //    d->SelectD0(fCutsLoose->GetD0toKpiCuts(),okd0loose,okd0barloose);
5991       Int_t isSelectedLoose=fCutsLoose->IsSelected(d,AliRDHFCuts::kAll,aod);
5992       switch(isSelectedLoose){
5993       case 0:
5994         okd0loose=kFALSE;
5995         okd0barloose=kFALSE;
5996         break;
5997       case 1:
5998         okd0loose=kTRUE;
5999         okd0barloose=kFALSE;
6000         break;
6001       case 2:
6002         okd0loose=kFALSE;
6003         okd0barloose=kTRUE;
6004       break;
6005       case 3:
6006         okd0loose=kTRUE;
6007         okd0barloose=kTRUE;
6008         break;
6009       default:
6010         okd0loose=kTRUE;
6011         okd0barloose=kTRUE;
6012         break;
6013       }
6014      
6015     }
6016     
6017   
6018     //NO CUTS Case: force okD0 and okD0bar = kTRUE
6019     //     special cuts are applied also in the "NO Cuts" case
6020     //
6021     //
6022     // SPECIAL modification:
6023     // IMPORTANT!!!!!!  ONLY FOR TEMPORARY CONVENIENCE
6024     // IF fusePID is kTRUE, NO CUTS BECOMES NO PID case with tight cuts (fill signal histos when 30<=signallevel<40 )!!!!!!!!!!  
6025     if((!fusePID)&&isEventSelTGHT){
6026       okd0tightnopid=defaultNC;
6027       okd0bartightnopid=defaultNC;
6028     }        
6029
6030     if(okd0loose||okd0barloose||okd0tight||okd0bartight||okd0tightnopid||okd0bartightnopid){
6031       //######## INVARIANT MASS SELECTION ###############
6032       CheckInvMassD0(d,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar);
6033       if((isSideBandD0||isSideBandD0bar)){
6034         if(!(isPeakD0||isPeakD0bar))isSideBand=kTRUE; //(isSideBand no more used in the following, can remove it)
6035         else {// AVOID TO CONSIDER IN THE SIDEBAND  THOSE  CANDIDATES FOR WHICH 1 MASS HYPOTHESIS IS IN THE PEAK REGION
6036           isSideBand=kFALSE; 
6037           isSideBandD0=kFALSE;
6038           isSideBandD0bar=kFALSE;          
6039         }
6040       }
6041       if(fFastAnalysis<2){
6042         if(!aziListIsFilled){
6043           FillAziList(aod,azilist,trkIDlist,nprim);
6044           aziListIsFilled=kTRUE;
6045         }
6046         
6047         if(signallevel==1||signallevel==0){
6048           if(nprim!=0){
6049             FillAziHistos(d,flistNoCutsSignal,ptbin,azilist,trkIDlist,nprim,okd0tightnopid,okd0bartightnopid,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar); 
6050             FillAziHistos(d,flistTghCutsSignal,ptbin,azilist,trkIDlist,nprim,okd0tight,okd0bartight,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar); 
6051             FillAziHistos(d,flistLsCutsSignal,ptbin,azilist,trkIDlist,nprim,okd0loose,okd0barloose,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar);    
6052           }
6053         }
6054         
6055       }
6056     }
6057     if(((isPeakD0&&okd0tight)||(isPeakD0bar&&okd0bartight))&&isinacceptance)fSignalTypeTghCuts->Fill(signallevel);
6058     if(((isPeakD0&&okd0loose)||(isPeakD0bar&&okd0barloose))&&isinacceptance)fSignalTypeLsCuts->Fill(signallevel);
6059   
6060    
6061     
6062   
6063     //###################    FILL HISTOS      ########################
6064     //################################################################
6065     //
6066     //######## improvement: SPEED HERE CAN BE IMPROVED: CALCULATE ONCE AND FOR ALL 
6067     //            CANDIDATE VARIABLES   
6068
6069    
6070     if(signallevel==1||signallevel==0)FillHistos(d,flistNoCutsSignal,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);    // else if(fusePID&&signallevel>=30&&signallevel<40)FillHistos(d,flistNoCutsSignal,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue);// OLD LINE, COULD BE REMOVED 
6071     else if(signallevel==2)FillHistos(d,flistNoCutsFromDstar,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6072     else if(signallevel==3||signallevel==4)FillHistos(d,flistNoCutsFromB,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6073     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10||signallevel==11)FillHistos(d,flistNoCutsBack,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6074     else if(signallevel==5||signallevel==6)FillHistos(d,flistNoCutsOther,ptbin,okd0tightnopid,okd0bartightnopid,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6075     
6076
6077     
6078     //LOOSE CUTS Case
6079     if(okd0loose||okd0barloose)fNentries->Fill(14);
6080
6081     if(signallevel==1||signallevel==0)FillHistos(d,flistLsCutsSignal,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6082     else if(signallevel==2)FillHistos(d,flistLsCutsFromDstar,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6083     else if(signallevel==3||signallevel==4)FillHistos(d,flistLsCutsFromB,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6084     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10||signallevel==11)FillHistos(d,flistLsCutsBack,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6085     else if(signallevel==5||signallevel==6)FillHistos(d,flistLsCutsOther,ptbin,okd0loose,okd0barloose,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6086
6087     //TIGHT CUTS Case
6088     if(okd0tight||okd0bartight){
6089       fNentries->Fill(7);
6090       nSelectedtight++; 
6091     }
6092     
6093     if(signallevel==1||signallevel==0)FillHistos(d,flistTghCutsSignal,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6094     else if(signallevel==2)FillHistos(d,flistTghCutsFromDstar,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6095     else if(signallevel==3||signallevel==4)FillHistos(d,flistTghCutsFromB,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6096     else if(signallevel==-1||signallevel==7||signallevel==8||signallevel==10||signallevel==11)FillHistos(d,flistTghCutsBack,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6097     else if(signallevel==5||signallevel==6)FillHistos(d,flistTghCutsOther,ptbin,okd0tight,okd0bartight,invMassD0,invMassD0bar,isPeakD0,isPeakD0bar,isSideBandD0,isSideBandD0bar,massmumtrue,aodDMC,vtxTrue,isD0D0barMC);
6098     
6099
6100     // ######## PRINTING INFO FOR D0-like candidate
6101
6102     if(nSPD==2&&ptD0>2.){
6103       if((okd0tight&&TMath::Abs(invMassD0-1.864)<0.01)||(okd0bartight&&TMath::Abs(invMassD0bar-1.864)<0.01)){
6104         //printf("INFO FOR DRAWING: \n pt: %f \n Rapidity: %f \n Period Number: %d \n Run Number: %d \n BunchCrossNumb: %d \n OrbitNumber: %d \n",ptD0,d->Y(421),aod->GetPeriodNumber(),aod->GetRunNumber(),aod->GetBunchCrossNumber(),aod->GetOrbitNumber());
6105         //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
6106       }
6107     }
6108     if(aodDMC!=0x0){
6109       delete aodDMC;
6110       aodDMC=0x0;
6111     }
6112     
6113     if(fCleanCandOwnVtx)fCutsTight->CleanOwnPrimaryVtx(d,aod,origownvtx);
6114     
6115
6116     //   if(unsetvtx) d->UnsetOwnPrimaryVtx();
6117     
6118   }
6119
6120
6121   fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);  
6122   fCounter->StoreCandidates(aod,nSelectedtight,kFALSE); 
6123   
6124   
6125   // ####################### POST OUTPUT TLIST DATA #########################
6126   // ####### histo for #AOD entries already posted
6127   PostData(1,fNentries);
6128   PostData(2,fSignalType);
6129   PostData(3,fSignalTypeLsCuts);
6130   PostData(4,fSignalTypeTghCuts);
6131   PostData(5,fCounter);
6132   PostData(6,flistMCproperties);
6133   PostData(7,flistNoCutsSignal);
6134   PostData(8,flistNoCutsBack);
6135   PostData(9,flistNoCutsFromB);
6136   PostData(10,flistNoCutsFromDstar);
6137   PostData(11,flistNoCutsOther);
6138   PostData(12,flistLsCutsSignal);
6139   PostData(13,flistLsCutsBack);
6140   PostData(14,flistLsCutsFromB);
6141   PostData(15,flistLsCutsFromDstar);
6142   PostData(16,flistLsCutsOther);
6143   PostData(17,flistTghCutsSignal);
6144   PostData(18,flistTghCutsBack);
6145   PostData(19,flistTghCutsFromB);
6146   PostData(20,flistTghCutsFromDstar);
6147   PostData(21,flistTghCutsOther);
6148
6149   return;
6150 }
6151
6152
6153
6154 //_________________________________________
6155 Int_t  AliAnalysisTaskSECharmFraction::SetStandardCuts(){
6156   //
6157   // creating cuts for D0 -> Kpi
6158   //
6159
6160   if(fCutsTight){
6161     delete fCutsTight;fCutsTight=NULL;
6162   }
6163   if(fCutsLoose){
6164     delete fCutsLoose;fCutsLoose=NULL;
6165   }
6166
6167   
6168   fCutsTight=new AliRDHFCutsD0toKpi("D0toKpiCutsStandard");
6169   fCutsTight->SetTitle("Standard Cuts for D0 analysis");
6170   fCutsTight->SetStandardCutsPP2010();
6171   fCutsLoose=new AliRDHFCutsD0toKpi("D0toKpiCutsLoose");
6172   fCutsLoose->SetTitle("Loose Cuts for D0 analysis");
6173   fCutsLoose->SetStandardCutsPP2010();
6174
6175   fCutsTight->SetUseSpecialCuts(kTRUE);
6176   fCutsLoose->SetUseSpecialCuts(kTRUE);
6177   fCutsTight->SetRemoveDaughtersFromPrim(kTRUE);
6178   fCutsLoose->SetRemoveDaughtersFromPrim(kTRUE);
6179         
6180   fCutsTight->SetLowPt(kFALSE,0.);  
6181   fCutsTight->SetMaximumPforPID(999.);
6182  
6183   fCutsLoose->SetLowPt(kTRUE,3.);  
6184   fCutsLoose->SetMaximumPforPID(999.);
6185   // PILE UP REJECTION
6186   fCutsTight->SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
6187   fCutsLoose->SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
6188
6189
6190   fnbins=fCutsTight->GetNPtBins();
6191   if(fptbins)delete fptbins;
6192   fptbins=fCutsTight->GetPtBinLimits();
6193   
6194
6195   return fnbins;
6196  
6197 }
6198
6199
6200 //__________________________________________________________
6201 void AliAnalysisTaskSECharmFraction::CheckInvMassD0(AliAODRecoDecayHF2Prong *d,Double_t &invMassD0,Double_t &invMassD0bar,Bool_t &isPeakD0,Bool_t &isPeakD0bar,Bool_t &isSideBandD0,Bool_t &isSideBandD0bar){
6202   //Check wheter the candidate inv. mass is compatible with signal or sideband inv. mass selection
6203       
6204   d->InvMassD0(invMassD0,invMassD0bar);
6205   //CHECK if ISPEAK 
6206   if(TMath::Abs(invMassD0-fmD0PDG)<fsignalInvMassCut)isPeakD0=kTRUE;
6207   if(TMath::Abs(invMassD0bar-fmD0PDG)<fsignalInvMassCut)isPeakD0bar=kTRUE;
6208   //CHECK if ISSIDEBAND: no constraint is present between signal region definition and side band definition
6209   // ######## TO BE CHANGED the distinction between sidebandD0 and sidebandD0bar is meaningless 
6210   //               and it is present only for side band region study (see which inv mass has the D0(D0bar) 
6211   //               in case the D0bar(D0) is in the sideband) #######
6212   if(TMath::Abs(invMassD0-fmD0PDG)>fsidebandInvMassCut&&TMath::Abs(invMassD0-fmD0PDG)<fsidebandInvMassCut+fsidebandInvMassWindow){
6213     isSideBandD0=kTRUE;
6214   }
6215   if(TMath::Abs(invMassD0bar-fmD0PDG)>fsidebandInvMassCut&&TMath::Abs(invMassD0bar-fmD0PDG)<fsidebandInvMassCut+fsidebandInvMassWindow){
6216     isSideBandD0bar=kTRUE;
6217   }
6218   
6219 }
6220         
6221
6222 //__________________________________________________________________
6223 AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::GetD0toKPiSignalType(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx,Int_t &isD0D0bar){
6224   //THIS METHOD CHECK THE TYPE OF SIGNAL/BACKGROUND THE CANDIDATE IS. 
6225   //  IF (!AND ONLY IF) THE TWO DAUGHTERS COME FROM A COMMONE MOTHER A FAKE TRUE SECONDARY VERTEX IS CONSTRUCTED (aodDMC)  
6226   //
6227   // THE FOLLOWING SCHEME IS ADOPTED: signaltype is set to
6228   //  1:signal (D0 prompt); 2: signal D0 from Dstar; 3: D0 fromB 4: D0 from Dstar fromB
6229   // then background categories: -1: one or both daughters is a fake track
6230   //                             5: both daughters come from a D meson != D0
6231   //                             6: both daughters come from a D0->4prongs  
6232   //                             7: both daughetrs are primaries
6233   //                             8: generic background (can include one of the previous if desired)
6234   //                             9: daughters out of acceptance
6235   //                            10: pathologic cases (not clear)
6236   //                            11: end of the method without output
6237   //                            12: different result than MatchToMC method
6238   
6239   AliAODMCParticle *mum1=0x0;
6240   AliAODMCParticle *b1=0x0,*b2=0x0;
6241   AliAODMCParticle *grandmoth1=0x0;
6242   massMumTrue=-1;
6243   AliAODRecoDecayHF *aodDMC=0x0;
6244   Int_t pdgdaughters[2]={211,321};
6245   Int_t labMum=d->MatchToMC(421,arrayMC,2,pdgdaughters);
6246   if(labMum==-1){
6247     signaltype=-1;
6248     return aodDMC;    
6249   }
6250   
6251
6252   if(labMum<0){
6253     signaltype=-1;
6254     return aodDMC;    
6255   }
6256   
6257   mum1=(AliAODMCParticle*)arrayMC->At(labMum);  
6258   if(mum1->GetPdgCode()==421)isD0D0bar=1;
6259   else if(mum1->GetPdgCode()==-421)isD0D0bar=2;
6260   // get daughter AOD tracks
6261   AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
6262   AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
6263  
6264   if(trk0==0x0||trk1==0x0){
6265     AliDebug(2,"null daughter tracks \n");
6266   
6267     signaltype=-1;
6268     return aodDMC;
6269     
6270   }
6271   if(trk0->GetLabel()<0||trk1->GetLabel()<0){
6272     AliDebug(2,"Fake tracks? \n");
6273     signaltype=-1;
6274     return aodDMC;
6275   }
6276   
6277   b1=(AliAODMCParticle*)arrayMC->At(trk0->GetLabel());
6278   b2=(AliAODMCParticle*)arrayMC->At(trk1->GetLabel());
6279
6280   massMumTrue=mum1->GetCalcMass();
6281   aodDMC=ConstructFakeTrueSecVtx(b1,b2,mum1,primaryVtx);
6282  
6283   if(aodDMC==0x0){
6284     signaltype=10;
6285     return aodDMC;
6286   }
6287
6288   Bool_t isfromDstar=kFALSE;
6289  
6290   if(mum1->GetMother()>=0){
6291      grandmoth1=(AliAODMCParticle*)arrayMC->At(mum1->GetMother());
6292     if(TMath::Abs(grandmoth1->GetPdgCode())==413||TMath::Abs(grandmoth1->GetPdgCode())==423)isfromDstar=kTRUE;// D0 COMING FROM A D*
6293   }
6294   
6295   Int_t origin=CheckOrigin(arrayMC,mum1);
6296   if(origin==4){
6297       if(isfromDstar)signaltype=2;
6298       else signaltype=1;
6299       return aodDMC;
6300   }
6301   else if(origin==5){
6302     if(isfromDstar)signaltype=4;
6303     else signaltype=3;
6304     return aodDMC;
6305   }
6306   else if(origin==-1){
6307     signaltype=11;
6308     return aodDMC;
6309   }
6310   else if(origin==-2){
6311     signaltype=-1;
6312     return aodDMC;
6313   }
6314   
6315   signaltype=11;// JUST FOR SAFETY: SHOULD NEVER REACH THIS POINT
6316   return aodDMC;
6317
6318 }
6319
6320 //_________________________________________________________________________________________________
6321 Int_t AliAnalysisTaskSECharmFraction::CheckOrigin(const TClonesArray* arrayMC, const AliAODMCParticle *mcPartCandidate) const {         
6322   //
6323   // checking whether the mother of the particles come from a charm or a bottom quark
6324   //
6325         
6326   Int_t pdgGranma = 0;
6327   Int_t mother = 0;
6328   mother = mcPartCandidate->GetMother();
6329
6330   Int_t abspdgGranma =0;
6331   Bool_t isFromB=kFALSE;
6332   Bool_t isQuarkFound=kFALSE;
6333   while (mother >0 ){
6334     
6335     AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
6336     if (mcGranma){
6337       pdgGranma = mcGranma->GetPdgCode();
6338       abspdgGranma = TMath::Abs(pdgGranma);
6339       if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
6340         isFromB=kTRUE;
6341       }
6342       if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
6343       mother = mcGranma->GetMother();
6344     }else{
6345       AliError("Failed casting the mother particle!");
6346       return -2;
6347     }
6348   }
6349   
6350   if(!isQuarkFound)return -1;
6351   if(isFromB) return 5;  
6352   else return 4;
6353 }
6354
6355 //__________________________________________________
6356 AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::GetD0toKPiSignalTypeObsolete(const AliAODRecoDecayHF2Prong *d,TClonesArray *arrayMC,Int_t &signaltype,Double_t &massMumTrue,Double_t *primaryVtx){// OBSOLETE METHOD!!!!!
6357   //THIS METHOD CHECK THE TYPE OF SIGNAL/BACKGROUND THE CANDIDATE IS. 
6358   //  IF (!AND ONLY IF) THE TWO DAUGHTERS COME FROM A COMMONE MOTHER A FAKE TRUE SECONDARY VERTEX IS CONSTRUCTED (aodDMC)  
6359   //
6360   // THE FOLLOWING SCHEME IS ADOPTED: signaltype is set to
6361   //  1:signal (D0 prompt); 2: signal D0 from Dstar; 3: D0 fromB 4: D0 from Dstar fromB
6362   // then background categories: -1: one or both daughters is a fake track
6363   //                             5: both daughters come from a D meson != D0
6364   //                             6: both daughters come from a D0->4prongs  
6365   //                             7: both daughetrs are primaries
6366   //                             8: generic background (can include one of the previous if desired)
6367   //                             9: daughters out of acceptance
6368   //                            10: pathologic cases (not clear)
6369   //                            11: end of the method without output
6370   //                            12: different result than MatchToMC method
6371   
6372   AliAODMCParticle *mum1=0x0;
6373   AliAODMCParticle *b1=0x0,*b2=0x0;
6374   AliAODMCParticle *grandmoth1=0x0;
6375   massMumTrue=-1;
6376   
6377   Int_t pdgmum,dglabels[2],matchtoMC;
6378   Int_t pdgdaughters[2]={211,321};
6379   // get daughter AOD tracks
6380   AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
6381   AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
6382   AliAODRecoDecayHF *aodDMC=0x0;
6383   if(trk0==0x0||trk1==0x0){
6384     AliDebug(2,"Delete tracks I AM \n");
6385   
6386     signaltype=-1;
6387     return aodDMC;
6388    
6389   }
6390   dglabels[0]=trk0->GetLabel();
6391   dglabels[1]=trk1->GetLabel();
6392   if(dglabels[0]<0||dglabels[1]<0){
6393     AliDebug(2,"HERE I AM \n");
6394
6395     //fake tracks
6396     
6397     signaltype=-1;
6398     return aodDMC;
6399
6400   }
6401   //      printf("Before entering the MC checks \n");
6402   
6403   b1=(AliAODMCParticle*)arrayMC->At(trk0->GetLabel());
6404   b2=(AliAODMCParticle*)arrayMC->At(trk1->GetLabel());
6405   if(!b1||!b2){
6406     //Tracks with no mother  ??? FAKE DECAY VERTEX
6407     signaltype=10;
6408     return aodDMC;
6409   }
6410   if(b1->GetMother()<0||b2->GetMother()<0){
6411     //Tracks with no mother  ??? FAKE DECAY VERTEX
6412     signaltype=10;
6413     return aodDMC;
6414   }
6415   
6416   mum1=(AliAODMCParticle*)arrayMC->At(b1->GetMother());
6417   //  mum2=(AliAODMCParticle*)arrayMC->At(b2->GetMother());//FOR FURTHER USE
6418   
6419   if(b1->GetMother()!=b2->GetMother()){
6420     //Check the label of the mother is the same
6421     // NOT SAME MOTHER
6422    
6423
6424     signaltype=8;
6425     return aodDMC;
6426   }
6427   massMumTrue=mum1->GetCalcMass();
6428   
6429   matchtoMC=d->MatchToMC(421,arrayMC,2,pdgdaughters);
6430   aodDMC=ConstructFakeTrueSecVtx(b1,b2,mum1,primaryVtx);
6431  
6432   if(aodDMC==0x0){
6433     signaltype=10;
6434     return aodDMC;
6435   }
6436
6437   // if((mum1->GetPdgCode()!=mum2->GetPdgCode()))continue; //Check the mother is the same particle
6438   // printf("Particle codes: tr1: %d, tr2: %d, mum1: %d, mum 2: %d \n",b1->GetPdgCode(),b2->GetPdgCode(),mum1->GetPdgCode(),mum2->GetPdgCode());
6439   if(!((TMath::Abs(b1->GetPdgCode())==321&&TMath::Abs(b1->GetPdgCode())!=211)||(TMath::Abs(b1->GetPdgCode())==211&&TMath::Abs(b1->GetPdgCode()!=321)))){
6440     // Not a Kaon and a Pion
6441    
6442     signaltype=8;
6443     return aodDMC;
6444   }
6445   
6446   pdgmum=mum1->GetPdgCode();
6447   if(TMath::Abs(pdgmum)!=421){
6448     if(TMath::Abs(pdgmum)==411||TMath::Abs(pdgmum)==431||TMath::Abs(pdgmum)==443){
6449       // IT IS A SECONDARY VERTEX FROM CHARM BUT NOT A D0
6450       
6451       signaltype=5;
6452       return aodDMC;
6453     }
6454     else {
6455        signaltype=8;
6456        return aodDMC;
6457     }
6458   }
6459
6460   if(mum1->GetDaughter(1)-mum1->GetDaughter(0)+1!=2){
6461     // from D0 but NOT A 2 PRONG DECAY
6462     signaltype=6;
6463     return aodDMC;
6464    
6465   }
6466   
6467   if(mum1->GetMother()<0){
6468     // A particle coming from nothing
6469     signaltype=10;
6470     return aodDMC;
6471     
6472   }
6473   Bool_t isfromDstar=kFALSE;
6474   //  matchtoMC=d->MatchToMC(421,arrayMC,2,pdgdaughters);
6475   grandmoth1=(AliAODMCParticle*)arrayMC->At(mum1->GetMother());
6476   if(TMath::Abs(grandmoth1->GetPdgCode())==413||TMath::Abs(grandmoth1->GetPdgCode())==423)isfromDstar=kTRUE;// D0 COMING FROM A D0*
6477   
6478   /*
6479   //CHECK FOR CABIBBO SUPPRESSED DECAY
6480   Int_t isCabibSup=0,pdgKaon;
6481  
6482   pdgKaon=b1->GetPdgCode();
6483   if(TMath::Abs(pdgKaon)!=321)pdgKaon=b2->GetPdgCode();
6484   if(pdgmum>0&&pdgKaon>0)isCabibSup=1;
6485   if(pdgmum<0&&pdgKaon<0)isCabibSup=1;
6486   if(isCabibSup){
6487     signaltype=0;
6488     return aodDMC;
6489   }
6490   */
6491   //      if(fcheckMCD0){//THIS CHECK IS NEEDED TO AVOID POSSIBLE FAILURE IN THE SECOND WHILE, FOR DEBUGGING
6492   while(TMath::Abs(grandmoth1->GetPdgCode())!=4&&TMath::Abs(grandmoth1->GetPdgCode())!=5){
6493     if(grandmoth1->GetMother()<0){
6494       //### THE FOLLOWING IN CASE OF DEBUGGING ##########à
6495       /*printf("mother=-1, pdgcode: %d \n",grandmoth1->GetPdgCode());
6496         Int_t son=grandmoth1->GetDaughter(0);
6497         sonpart=(AliAODMCParticle*)arrayMC->At(son);
6498         while(TMath::Abs(sonpart->GetPdgCode())!=421){
6499         printf("mother=-1, pdgcode: %d \n",sonpart->GetPdgCode());
6500         son++;
6501         sonpart=(AliAODMCParticle*)arrayMC->At(son);
6502         }*/
6503    
6504       signaltype=10;
6505       return aodDMC;
6506     }
6507     grandmoth1=(AliAODMCParticle*)arrayMC->At(grandmoth1->GetMother());
6508   }
6509   
6510   if(TMath::Abs(grandmoth1->GetPdgCode())==4){
6511     if(matchtoMC!=-1){
6512       
6513       if(isfromDstar)signaltype=2;
6514       else signaltype=1;
6515       return aodDMC;
6516     }
6517     else {
6518       signaltype=12;
6519       return aodDMC;
6520       
6521     }
6522   }
6523   else if(TMath::Abs(grandmoth1->GetPdgCode())==5){
6524     if(matchtoMC!=-1){
6525       if(isfromDstar)signaltype=4;
6526       else signaltype=3;
6527       return aodDMC;
6528       
6529     }
6530     else {
6531      
6532       signaltype=12;
6533       return aodDMC;
6534     }
6535   }
6536   signaltype=11;// JUST FOR SAFETY: SHOULD NEVER REACH THIS POINT
6537   return aodDMC;
6538   //  return 11;
6539 }
6540
6541 //___________________________________
6542 AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::ConstructFakeTrueSecVtx(const AliAODMCParticle *b1, const AliAODMCParticle *b2, const AliAODMCParticle *mum,Double_t *primaryVtxTrue){
6543   // CONSTRUCT A FAKE TRUE SECONDARY VERTEX (aodDMC)  
6544   //!!!NOTE THAT ONLY ONE MOTHER IS CONSIDERED: THE METHOD REQUIRES THE DAUGHTERS COME FROM THE SAME MOTHER !!
6545   if(b1==0x0||b2==0x0)return 0x0;
6546   if(mum==0x0)return 0x0;
6547   Double_t pD[3],xD[3],pXtrTrue[2],pYtrTrue[2],pZtrTrue[2],xtr1[3],xtr2[3];
6548   Int_t charge[2]={0,0};
6549   if(b1->Charge()==-1)charge[0]=1;
6550   else {
6551     if(b2->Charge()==-1){
6552       //printf("Same charges for prongs \n");
6553       if(!fLikeSign)return 0x0;
6554     }
6555     charge[1]=1;
6556   }
6557   
6558   pXtrTrue[charge[0]]=b1->Px();
6559   pYtrTrue[charge[0]]=b1->Py();
6560   pZtrTrue[charge[0]]=b1->Pz();
6561   if(!b1->XvYvZv(xtr1)){
6562     return 0x0;
6563   }
6564   
6565   pXtrTrue[charge[1]]=b2->Px();
6566   pYtrTrue[charge[1]]=b2->Py();
6567   pZtrTrue[charge[1]]=b2->Pz();
6568   
6569   if(!mum->PxPyPz(pD)){
6570     //printf("!D from B:Get momentum failed \n");
6571     return 0x0;
6572   }
6573   if(!mum->XvYvZv(xD)){
6574     //printf("!D from B:Get position failed \n");
6575     return 0x0;
6576   }
6577   /* ############ THIS HAPPENS FROM TIME TO TIME: NUMERIC PROBLEM KNOWN #################
6578      if(pXtrTrue[0]+pXtrTrue[1]!=pD[0]){
6579      }*/
6580   
6581   
6582   if(!b2->XvYvZv(xtr2)){
6583     return 0x0;
6584   }
6585   Double_t d0dummy[2]={0.,0.};//TEMPORARY : dummy d0 for AliAODRecoDeay constructor
6586   AliAODRecoDecayHF* aodDMC=new AliAODRecoDecayHF(primaryVtxTrue,xD,2,0,pXtrTrue,pYtrTrue,pZtrTrue,d0dummy);
6587   
6588   /*   ######## THE FOLLOWINF FOR DEBUGGING ############
6589        Printf("testing the Fake vertex: SecVtxX: %f, Px: %f, Py: %f, Pz:%f \n ",aodDMC->GetSecVtxX(),aodDMC->Px(),aodDMC->Py(),aodDMC->Pz());
6590        Printf("pD: x=%f, y=%f,z=%f\n",pD[0],pD[1],pD[2]);
6591        Printf("Daughters :px1:%f, px2:%f \n",pXtrTrue[0],pXtrTrue[1]);
6592        Printf("Daughters :py1:%f, py2:%f \n",pYtrTrue[0],pYtrTrue[1]);
6593        Printf("Daughters :pz1:%f, pz2:%f \n",pZtrTrue[0],pZtrTrue[1]);
6594        Printf("Mother pdg: %d",mum->GetPdgCode());
6595        Printf("Impact Par Prod: %f\n",aodDMC->ImpParXY());
6596   */
6597
6598   return aodDMC;
6599 }
6600
6601 //________________________________________________________
6602 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 isSideBandD0,Bool_t isSideBandD0bar,Double_t massmumtrue,AliAODRecoDecayHF *aodDMC,Double_t *vtxTrue,Int_t isD0D0barMC){//FILL THE HISTOGRAMS: TAKE THE HISTOS FROM THE list NAME
6603
6604   
6605   if((!okD0)&&(!okD0bar))return kTRUE;
6606   if(ptbin==-1)return kTRUE;
6607   //  flistNoCutsSignal->Add(hptD0NCsign);
6608   // flistNoCutsSignal->Add(hptD0VsMaxPtNCsign);
6609   // flistNoCutsSignal->Add(hptD0PTallsqrtNCsign);
6610   //  flistNoCutsSignal->Add(hptD0PTallNCsign);
6611   
6612   // %%%%%% TO BE DONE 
6613   //    flistNoCutsSignal->Add(hptD0vsptBNCsign);
6614   // flistNoCutsSignal->Add(hpD0vspBNCsign);
6615   //flistNoCutsSignal->Add(hptD0vsptcquarkNCsign);
6616   //flistNoCutsSignal->Add(hpD0vspcquarkNCsign);
6617   // %%%%%%%%%%%%%%%%%%%%%%%%%%%%
6618   // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6619   
6620   // DONE
6621   //hd0zD0ptLSCsign_pt
6622   //hInvMassD0LSCsign_pt
6623   //hetaLSCsign_pt
6624   //
6625   // %%% TO BE DONE %% 
6626   //hCosPDPBLSCsign_pt
6627   //hCosPcPDLSCsign_pt
6628   
6629   Double_t pt=d->Pt();
6630   Double_t impparxy=d->ImpParXY()*10000.;
6631
6632
6633
6634   // ######### Get Standard label for hist in tlist ###############
6635   TString namehist=list->GetName(),str;
6636   namehist.ReplaceAll("list","");
6637
6638   //  ######### Global properties histos #################
6639   // ####### take care: only for candidates which pass the cuts !! not for side band ########
6640   if(fFastAnalysis<2){ 
6641     if((isPeakD0&&okD0)||(isPeakD0bar&&okD0bar)){
6642       str="hCPtaVSd0d0";
6643       str.Append(namehist.Data());
6644       ((TH1F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0(),d->CosPointingAngle());
6645       
6646       str="hSecVtxZ";
6647       str.Append(namehist.Data());
6648       ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxZ());
6649       
6650       str="hSecVtxX";
6651       str.Append(namehist.Data());
6652       ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxX()*10000.);
6653       
6654       str="hSecVtxY";
6655       str.Append(namehist.Data());
6656       ((TH1F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxY()*10000.);
6657       
6658       str="hSecVtxXY";
6659       str.Append(namehist.Data());
6660       ((TH2F*)list->FindObject(str.Data()))->Fill(d->GetSecVtxX()*10000.,d->GetSecVtxY()*10000.);
6661       
6662       str="hSecVtxPhi";
6663       str.Append(namehist.Data());
6664       ((TH1F*)list->FindObject(str.Data()))->Fill(TMath::ATan2(d->GetSecVtxY()*10000.,d->GetSecVtxX()*10000.)*TMath::RadToDeg());
6665       
6666       
6667       str="hd0singlTrack";
6668       str.Append(namehist.Data());
6669       ((TH1F*)list->FindObject(str.Data()))->Fill(d->Getd0Prong(0)*10000.);
6670       ((TH1F*)list->FindObject(str.Data()))->Fill(d->Getd0Prong(1)*10000.);
6671       
6672       str="hCPta";
6673       str.Append(namehist.Data());
6674       ((TH1F*)list->FindObject(str.Data()))->Fill(d->CosPointingAngle());
6675       
6676       str="hd0xd0";
6677       str.Append(namehist.Data());
6678       ((TH1F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0());
6679       
6680       //%%%%%%%% NEW HISTO %%%%%%%%%%
6681       str="hdca";
6682       str.Append(namehist.Data());
6683       ((TH1F*)list->FindObject(str.Data()))->Fill(1e4*d->GetDCA());
6684       
6685       str="hcosthetastar";
6686       str.Append(namehist.Data());
6687       if(okD0)((TH1F*)list->FindObject(str.Data()))->Fill(d->CosThetaStarD0());
6688       if(okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(d->CosThetaStarD0bar());
6689       
6690       str="hptD0";
6691       str.Append(namehist.Data());
6692       ((TH1F*)list->FindObject(str.Data()))->Fill(pt);
6693       
6694       str="hptD0VsMaxPt";
6695       str.Append(namehist.Data());
6696       Int_t pr=0;
6697       if(d->PtProng(1)>d->PtProng(0))pr=1;
6698       if(d->PtProng(pr)<fptMax[0]) ((TH1F*)list->FindObject(str.Data()))->Fill(pt-fptMax[0]);
6699       else if(d->PtProng(TMath::Abs(pr-1))<fptMax[1])((TH1F*)list->FindObject(str.Data()))->Fill(pt-fptMax[1]);
6700       else ((TH1F*)list->FindObject(str.Data()))->Fill(pt-fptMax[2]);
6701       
6702       
6703       str="hptD0PTallsqrt";
6704       str.Append(namehist.Data());
6705       Double_t sumsqrpt=fptAllSq-d->PtProng(1)*d->PtProng(1)-d->PtProng(0)*d->PtProng(0);
6706       if(sumsqrpt>0.)((TH1F*)list->FindObject(str.Data()))->Fill(pt,TMath::Sqrt(sumsqrpt));
6707       
6708       str="hptD0PTall";
6709       str.Append(namehist.Data());
6710       ((TH1F*)list->FindObject(str.Data()))->Fill(pt,fptAll-d->PtProng(1)-d->PtProng(0));
6711       
6712       
6713       str="hd0zD0pt";
6714       str.Append(namehist.Data());
6715       str.Append("_pt");
6716       str+=ptbin;
6717       if(d->GetPrimaryVtx()!=0x0)((TH1F*)list->FindObject(str.Data()))->Fill(1e4*(d->Zv()-d->GetPrimaryVtx()->GetZ()));
6718       
6719       str="heta";
6720       str.Append(namehist.Data());
6721       str.Append("_pt");
6722       str+=ptbin;
6723       ((TH1F*)list->FindObject(str.Data()))->Fill(d->Eta());
6724       
6725       // OTHER NEW ADDITIONAL HISTOS
6726       
6727       str="hd0xd0";
6728       str.Append(namehist.Data());
6729       str.Append("_pt");
6730       str+=ptbin;
6731       //printf("Hist name: %s \n",str.Data());
6732       ((TH1F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0());
6733       
6734       
6735       str="hd0D0VSd0xd0";
6736       str.Append(namehist.Data());
6737       str.Append("_pt");
6738       str+=ptbin;
6739       //printf("Hist name: %s \n",str.Data());
6740       ((TH2F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0(),impparxy);
6741       
6742       
6743       str="hangletracksVSd0xd0";
6744       str.Append(namehist.Data());
6745       str.Append("_pt");
6746       str+=ptbin;
6747       //printf("Hist name: %s \n",str.Data());
6748       ((TH2F*)list->FindObject(str.Data()))->Fill(1e8*d->Prodd0d0(),d->ProngsRelAngle(0,1));
6749       
6750       str="hangletracksVSd0D0";
6751       str.Append(namehist.Data());
6752       str.Append("_pt");
6753       str+=ptbin;
6754       //  printf("Hist name: %s \n",str.Data());
6755       ((TH2F*)list->FindObject(str.Data()))->Fill(impparxy,d->ProngsRelAngle(0,1));
6756     // ####################################################
6757     }
6758   }  
6759   
6760   //  ######### Invariant mass histos #################
6761   if(fFastAnalysis<1){ 
6762     str="hMass";
6763     str.Append(namehist.Data());
6764     ((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6765     ((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6766     
6767     
6768     if(isPeakD0||isPeakD0bar){
6769       str="hMass";
6770       str.Append(namehist.Data());
6771       str.Append("PM");
6772       if(isPeakD0&&okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6773       if(isPeakD0bar&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6774     }
6775   }
6776
6777   // The Following is a NEW HISTO  
6778   str="hInvMassD0";
6779   str.Append(namehist.Data());
6780   str.Append("_pt");
6781   str+=ptbin;
6782   if(okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6783   if((!fsplitMassD0D0bar)&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6784   str="hInvMassD0bar";
6785   str.Append(namehist.Data());
6786   str.Append("_pt");
6787   str+=ptbin;
6788   if(fsplitMassD0D0bar&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6789   
6790
6791   if(fReadMC&&(namehist.Contains("fromDstar")||namehist.Contains("sign")||namehist.Contains("fromB"))){
6792     str="hInvMassPtSelSignOnly";
6793     str.Append(namehist.Data());
6794     Int_t sel=0;
6795     if(okD0)sel+=1;
6796     if(okD0bar)sel+=2;
6797     Double_t w=1;
6798     if(fWeightPt){
6799       w=fWeightPt->Eval(pt);
6800     }
6801
6802     if(okD0&&isD0D0barMC==1)((TH3F*)list->FindObject(str.Data()))->Fill(invMassD0,pt,sel,w);
6803     if(okD0bar&&isD0D0barMC==2)((TH3F*)list->FindObject(str.Data()))->Fill(invMassD0bar,pt,sel,w);
6804
6805     str="hInvMassPtSelReflOnly";
6806     str.Append(namehist.Data());
6807
6808     if(okD0&&isD0D0barMC==2)((TH3F*)list->FindObject(str.Data()))->Fill(invMassD0,pt,sel,w);
6809     if(okD0bar&&isD0D0barMC==1)((TH3F*)list->FindObject(str.Data()))->Fill(invMassD0bar,pt,sel,w);
6810   }
6811   
6812
6813   // FILLING OF THE SPARSE HISTO
6814   if(fFastAnalysis<=2){ // ONLY IF NOT VERY FAST ANALYSIS
6815     str="hSparse";
6816     str.Append(namehist.Data());
6817
6818     Double_t point[5]={invMassD0,invMassD0bar,pt,impparxy,0.};
6819     if(okD0&&okD0bar)point[4]=3.5;
6820     else if(okD0)point[4]=1.5;
6821     else if(okD0bar)point[4]=2.5;
6822     if(fReadMC&&aodDMC!=0x0&&namehist.Contains("fromB")){     
6823       point[3]=aodDMC->ImpParXY()*10000.;
6824     }
6825     ((THnSparseF*)list->FindObject(str.Data()))->Fill(point);
6826     if(fReadMC&&aodDMC!=0x0&&namehist.Contains("fromB")){     
6827       point[3]=impparxy;
6828       str="hSparseReco";
6829       str.Append(namehist.Data());
6830       ((THnSparseF*)list->FindObject(str.Data()))->Fill(point);
6831     }
6832
6833     
6834     str="hInvMassPt";
6835     str.Append(namehist.Data());
6836     if(okD0)((TH2F*)list->FindObject(str.Data()))->Fill(invMassD0,pt);
6837     if(okD0bar)((TH2F*)list->FindObject(str.Data()))->Fill(invMassD0bar,pt);
6838
6839   }
6840
6841
6842
6843
6844   if(fFastAnalysis<=3&&namehist.Contains("sign")){
6845     str="hSparseCxyLxy";
6846     str.Append(namehist.Data()); 
6847     Double_t nLxy=d->NormalizedDecayLengthXY();
6848     Double_t cosPxy=TMath::Abs(d->CosPointingAngleXY());
6849     Double_t point[4]={invMassD0,pt,cosPxy,nLxy};
6850     if(okD0){
6851       //      printf("Listname: %s, Here the histo : %p \n",namehist.Data(),((THnSparseF*)list->FindObject(str.Data())));
6852       ((THnSparseF*)list->FindObject(str.Data()))->Fill(point);
6853     }
6854     point[0]=invMassD0bar;
6855     if(okD0bar){
6856       ((THnSparseF*)list->FindObject(str.Data()))->Fill(point);
6857     }
6858   }
6859
6860
6861
6862   /* if(isPeakD0||isPeakD0bar){
6863     str="hMass";
6864     str.Append(namehist.Data());
6865     str.Append("PM");
6866     if(isPeakD0&&okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6867     if(isPeakD0bar&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6868     // The Following is a NEW HISTO
6869     str="hInvMassD0";
6870     str.Append(namehist.Data());
6871     str.Append("_pt");
6872     str+=ptbin;
6873     if(isPeakD0&&okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6874     if(isPeakD0bar&&okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6875     }*/
6876   if(fFastAnalysis<2){ 
6877     if(isSideBandD0||isSideBandD0bar){
6878       str="hMass";
6879       str.Append(namehist.Data());
6880       str.Append("SB");
6881       if(okD0)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0);
6882       if(okD0bar)((TH1F*)list->FindObject(str.Data()))->Fill(invMassD0bar);
6883     }
6884   }
6885   
6886   if(fReadMC){
6887     if(massmumtrue>0.){
6888       str="hMassTrue";
6889       str.Append(namehist.Data());
6890       ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
6891       
6892       if(isPeakD0||isPeakD0bar){
6893         str="hMassTrue";
6894         str.Append(namehist.Data());
6895         str.Append("PM");
6896         ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
6897       }
6898       if(isSideBandD0||isSideBandD0bar){
6899         str="hMassTrue";
6900         str.Append(namehist.Data());
6901         str.Append("SB");
6902         ((TH1F*)list->FindObject(str.Data()))->Fill(massmumtrue);
6903       }
6904     }
6905   }
6906
6907   // ################ D0 Impact Parameter Histos #####################
6908   if(isPeakD0||isPeakD0bar){    
6909    
6910     str="hd0D0";
6911     str.Append(namehist.Data());
6912     str.Append("PM");
6913     if(!fReadMC){
6914       // WE COUNT TWICE A CANDIDATE UNDER THE INV MASS PEAK BOTH AS a D0 and a D0bar (if selected) for DATA ONLY
6915       // THIS BECAUSE WE SUBTRACT a "BACKGROUND" AMOUNT ESTIMATED USING THE INV MASS FIT INFORMATION
6916       // WHICH SHOULD ACCOUNT FOR REFLECTIONS
6917       if(isPeakD0&&okD0){
6918         ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6919       }
6920       if(isPeakD0bar&&okD0bar){
6921         ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6922       }
6923     }
6924     else {
6925       if((isPeakD0&&okD0)||(isPeakD0bar&&okD0bar))((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6926     }
6927     
6928     str="hd0D0pt";
6929     str.Append(namehist.Data());
6930     str.Append("_PkMss_pt");
6931     str+=ptbin;     
6932     if(!fReadMC){
6933       // WE COUNT TWICE A CANDIDATE UNDER THE INV MASS PEAK BOTH AS a D0 and a D0bar (if selected) for DATA ONLY
6934       // THIS BECAUSE WE SUBTRACT a "BACKGROUND" AMOUNT ESTIMATED USING THE INV MASS FIT INFORMATION
6935       // WHICH SHOULD ACCOUNT FOR REFLECTIONS
6936       if(isPeakD0&&okD0){
6937         ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6938       }
6939       if(isPeakD0bar&&okD0bar){
6940         ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6941       }
6942     }
6943     else {
6944       if((isPeakD0&&okD0)||(isPeakD0bar&&okD0bar))((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6945     }
6946     
6947     
6948     if(fReadMC&&vtxTrue){
6949       // ONLY AN HISTO FOR QA: WE DO NOT CONSIDER THE IMPACT PARAMETER FOR EACH MASS HYPOTHESIS
6950       str="hd0D0VtxTrue";
6951       str.Append(namehist.Data());
6952       str.Append("PM");
6953       ((TH1F*)list->FindObject(str.Data()))->Fill(d->AliAODRecoDecay::ImpParXY(vtxTrue)*10000.);
6954       
6955       str="hd0D0VtxTruept";
6956       str.Append(namehist.Data());
6957       str.Append("_PkMss_pt");
6958       str+=ptbin;
6959       ((TH1F*)list->FindObject(str.Data()))->Fill(d->AliAODRecoDecay::ImpParXY(vtxTrue)*10000.);
6960     }
6961     
6962     if(fReadMC&&aodDMC!=0x0){
6963       // WE NEED JUST THE SHAPE: AVOID TAKING THE IMPACT PAR FOR EACH MASS HYPO PASSING THE CUTS
6964       // aodDMC->Print("");
6965       //aodDMC->ImpParXY();
6966       // aodDMC->Print("");
6967       str="hMCd0D0";
6968       str.Append(namehist.Data());
6969       str.Append("PM");
6970       ((TH1F*)list->FindObject(str.Data()))->Fill(aodDMC->ImpParXY()*10000.);
6971       
6972       str="hMCd0D0pt";
6973       str.Append(namehist.Data());
6974       str.Append("_PkMss_pt");
6975       str+=ptbin;
6976       ((TH1F*)list->FindObject(str.Data()))->Fill(aodDMC->ImpParXY()*10000.);
6977     }       
6978   } 
6979   else if(isSideBandD0||isSideBandD0bar){
6980     // WE ASSUME THE IMPACT PARAMETER DISTRIBUION FOR BACKGROUND(SIDEBANDS) CANDIDATES
6981     // IS NOT CORRELATED TO THE INVARIANT MASSES. THEREFORE WE JUST TAKE ONE TIME
6982     // THE IMPACT PARAMETER AND NOT ONE FOR EACH MASS HYPOTHESIS PASSING THE CUTS
6983
6984     str="hd0D0";
6985     str.Append(namehist.Data());
6986     str.Append("SB");
6987     ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6988     
6989     str="hd0D0pt";
6990     str.Append(namehist.Data());
6991     str.Append("_SBMss_pt");
6992     str+=ptbin;
6993     ((TH1F*)list->FindObject(str.Data()))->Fill(impparxy);
6994     
6995     
6996     if(fReadMC&&vtxTrue){
6997       str="hd0D0VtxTrue";
6998       str.Append(namehist.Data());
6999       str.Append("SB");
7000       ((TH1F*)list->FindObject(str.Data()))->Fill(d->AliAODRecoDecay::ImpParXY(vtxTrue)*10000.);
7001       
7002       str="hd0D0VtxTruept";
7003       str.Append(namehist.Data());
7004       str.Append("_SBMss_pt");
7005       str+=ptbin;
7006       ((TH1F*)list->FindObject(str.Data()))->Fill(d->AliAODRecoDecay::ImpParXY(vtxTrue)*10000.);
7007       
7008     }
7009     
7010     if(fReadMC&&aodDMC!=0x0){
7011       str="hMCd0D0";
7012       str.Append(namehist.Data());
7013       str.Append("SB");
7014       ((TH1F*)list->FindObject(str.Data()))->Fill(aodDMC->ImpParXY()*10000.);
7015       
7016       str="hMCd0D0pt";
7017       str.Append(namehist.Data());
7018       str.Append("_SBMss_pt");
7019       str+=ptbin;
7020       ((TH1F*)list->FindObject(str.Data()))->Fill(aodDMC->ImpParXY()*10000.);
7021     }
7022     
7023   }
7024      
7025    return kTRUE;
7026 }
7027
7028
7029  void  AliAnalysisTaskSECharmFraction::FillHistoMCproperties(TClonesArray *arrayMC){ 
7030     //#############################################################
7031     //            HERE LOOK AT global properties of D0 mesons, c quarks and B
7032     // 
7033     //#############################################################
7034    Double_t pxyzMum[3],pxyzDaught[3],cosOpenAngle=-1.1,ptmum,ptdaught;
7035    Int_t ncdaught=0,cquarksMC=0,nD0all=0,nD0FromB=0,nBdaught=0,nD0bquark=0,nD0bMeson=0,nD0bBaryon=0;
7036    for (Int_t iPart=0; iPart<arrayMC->GetEntriesFast(); iPart++) { 
7037      AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(arrayMC->At(iPart));
7038      if (!mcPart) {
7039        AliWarning("Particle not found in tree, skipping"); 
7040        continue;
7041      } 
7042      if (TMath::Abs(mcPart->GetPdgCode()) == 4){
7043        cquarksMC++;  
7044        mcPart->PxPyPz(pxyzMum);
7045        ptmum=mcPart->Pt();
7046        
7047        ((TH1F*)flistMCproperties->FindObject("hMCcquarkAllPt"))->Fill(ptmum);
7048        ((TH1F*)flistMCproperties->FindObject("hMCcquarkAllEta"))->Fill(mcPart->Eta());
7049        ((TH1F*)flistMCproperties->FindObject("hMCcquarkAllEnergy"))->Fill(mcPart->E());
7050        //NOW LOOK FOR A D0 among cquark daughters
7051        ncdaught=mcPart->GetDaughter(1)-mcPart->GetDaughter(0)+1;
7052        ((TH1F*)flistMCproperties->FindObject("hMCcquarkNdaught"))->Fill(ncdaught);
7053        if(ncdaught>1){
7054          for(Int_t iDaught=mcPart->GetDaughter(0);iDaught<mcPart->GetDaughter(1);iDaught++){
7055            AliAODMCParticle* mcPartD0 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(iDaught));
7056            if(mcPartD0==0x0)continue;
7057            if(TMath::Abs(mcPartD0->GetPdgCode()) == 421){
7058              // a D0 coming from a c quark
7059              mcPartD0->PxPyPz(pxyzDaught);
7060              ptdaught=mcPartD0->Pt();
7061              ((TH1F*)flistMCproperties->FindObject("hMCD0fromcPt"))->Fill(ptdaught);
7062              ((TH1F*)flistMCproperties->FindObject("hMCD0fromcEta"))->Fill(mcPartD0->Eta());
7063              ((TH1F*)flistMCproperties->FindObject("hMCD0fromcEnergy"))->Fill(mcPartD0->E());
7064              // ##############################################################################################
7065              //                            Compare D0 momentum and c quarks: 
7066              //              NB: here ALL D0 are considered, also those not decaying in KPi !!!
7067              // ##############################################################################################
7068              ((TH2F*)flistMCproperties->FindObject("hMCD0VscquarkPt"))->Fill(mcPart->Pt(),mcPartD0->Pt());
7069              ((TH2F*)flistMCproperties->FindObject("hMCD0VscquarkEnergy"))->Fill(mcPart->E(),mcPartD0->E());
7070              ((TH1F*)flistMCproperties->FindObject("hMCD0deltacquarkEnergy"))->Fill(mcPartD0->E()/mcPart->E());
7071              ((TH1F*)flistMCproperties->FindObject("hMCD0EnergyVsAvcquarkDaughtEn"))->Fill((mcPartD0->E()-(mcPart->E()/ncdaught))/mcPart->E());
7072              //calculate open angle
7073              if((pxyzMum[0]!=0.||pxyzMum[1]!=0.||pxyzMum[2]!=0.)&&(pxyzDaught[0]!=0.||pxyzDaught[1]!=0.||pxyzDaught[2]!=0.))cosOpenAngle=(pxyzDaught[0]*pxyzMum[0]+pxyzDaught[1]*pxyzMum[1]+pxyzDaught[2]*pxyzMum[2])/(TMath::Sqrt(pxyzDaught[0]*pxyzDaught[0]+pxyzDaught[1]*pxyzDaught[1]+pxyzDaught[2]*pxyzDaught[2])*TMath::Sqrt(pxyzDaught[0]*pxyzDaught[0]+pxyzDaught[1]*pxyzDaught[1]+pxyzDaught[2]*pxyzDaught[2]));
7074              ((TH1F*)flistMCproperties->FindObject("hMCD0cquarkAngle"))->Fill(cosOpenAngle);
7075              ((TH2F*)flistMCproperties->FindObject("hMCD0cquarkAngleEnergy"))->Fill(mcPart->E(),cosOpenAngle);
7076            }
7077          }
7078        }
7079      }
7080      
7081      // NOW LOOK FOR D0 not coming from cquarks
7082       if (TMath::Abs(mcPart->GetPdgCode()) == 421){
7083         nD0all++;  
7084         if(mcPart->GetMother()<0)continue;
7085         AliAODMCParticle* mcD0Parent = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mcPart->GetMother()));
7086         if(mcD0Parent==0x0)continue;
7087         Bool_t notfound=kFALSE,bMeson=kFALSE,bBaryon=kFALSE;
7088         //CheckOrigin
7089         while(TMath::Abs(mcD0Parent->GetPdgCode())!=4&&TMath::Abs(mcD0Parent->GetPdgCode())!=5){
7090           if(500<TMath::Abs(mcD0Parent->GetPdgCode())%10000&&TMath::Abs(mcD0Parent->GetPdgCode())<600){
7091             bMeson=kTRUE;
7092             break;
7093           }
7094           else if (5000<TMath::Abs(mcD0Parent->GetPdgCode())&&TMath::Abs(mcD0Parent->GetPdgCode())<6000){
7095             bBaryon=kTRUE;
7096             break;
7097           }
7098           if(mcD0Parent->GetMother()==0x0){
7099             notfound=kTRUE;
7100             break;
7101           };
7102           if(mcD0Parent->GetMother()<0){
7103             notfound=kTRUE;
7104             break;
7105           }
7106           mcD0Parent=dynamic_cast<AliAODMCParticle*>(arrayMC->At(mcD0Parent->GetMother()));
7107           if(mcD0Parent==0x0) break;
7108         }
7109
7110         if(mcD0Parent==0x0)continue;
7111         if(notfound)continue;
7112         if(TMath::Abs(mcD0Parent->GetPdgCode())==4)continue;//D0 from c quarks already counted
7113         ((TH1F*)flistMCproperties->FindObject("hMCfromBpdgB"))->Fill(TMath::Abs(mcD0Parent->GetPdgCode()));
7114         if(bBaryon)nD0bBaryon++;
7115         else if(bMeson)nD0bMeson++;
7116         else nD0bquark++;
7117         nD0FromB++;
7118         mcD0Parent->PxPyPz(pxyzMum);
7119         ptmum=mcD0Parent->Pt();
7120         ((TH1F*)flistMCproperties->FindObject("hMCBhadrPt"))->Fill(ptmum);
7121         ((TH1F*)flistMCproperties->FindObject("hMCBhadrEta"))->Fill(mcD0Parent->Eta());
7122         ((TH1F*)flistMCproperties->FindObject("hMCBhadrEnergy"))->Fill(mcD0Parent->E());
7123         
7124         nBdaught=mcD0Parent->GetDaughter(1)-mcD0Parent->GetDaughter(0)+1;
7125         ((TH1F*)flistMCproperties->FindObject("hMCBhadrNdaught"))->Fill(nBdaught);
7126
7127         
7128         // Now take properties of this D0 coming from a B
7129         mcPart->PxPyPz(pxyzDaught);
7130         ptdaught=mcPart->Pt();
7131         ((TH1F*)flistMCproperties->FindObject("hMCD0fromBPt"))->Fill(ptdaught);
7132         ((TH1F*)flistMCproperties->FindObject("hMCD0fromBEta"))->Fill(mcPart->Eta());
7133         ((TH1F*)flistMCproperties->FindObject("hMCD0fromBEnergy"))->Fill(mcPart->E());
7134         // ##############################################################################################
7135         //                            Compare D0 momentum and b hadron: 
7136         //              NB: here ALL D0 are considered, also those not decaying in KPi !!!
7137         // ##############################################################################################
7138         ((TH2F*)flistMCproperties->FindObject("hMCD0VsBhadrPt"))->Fill(mcD0Parent->Pt(),mcPart->Pt());
7139         ((TH2F*)flistMCproperties->FindObject("hMCD0VsBhadrEnergy"))->Fill(mcD0Parent->E(),mcPart->E());
7140         ((TH1F*)flistMCproperties->FindObject("hMCD0deltaBhadrEnergy"))->Fill(mcPart->E()/mcD0Parent->E());
7141         ((TH1F*)flistMCproperties->FindObject("hMCD0EnergyVsAvBDaughtEn"))->Fill((mcPart->E()-(mcD0Parent->E()/nBdaught))/mcD0Parent->E());
7142         //calculate open angle
7143         if((pxyzMum[0]!=0.||pxyzMum[1]!=0.||pxyzMum[2]!=0.)&&(pxyzDaught[0]!=0.||pxyzDaught[1]!=0.||pxyzDaught[2]!=0.))cosOpenAngle=(pxyzDaught[0]*pxyzMum[0]+pxyzDaught[1]*pxyzMum[1]+pxyzDaught[2]*pxyzMum[2])/(TMath::Sqrt(pxyzDaught[0]*pxyzDaught[0]+pxyzDaught[1]*pxyzDaught[1]+pxyzDaught[2]*pxyzDaught[2])*TMath::Sqrt(pxyzDaught[0]*pxyzDaught[0]+pxyzDaught[1]*pxyzDaught[1]+pxyzDaught[2]*pxyzDaught[2]));
7144         ((TH1F*)flistMCproperties->FindObject("hMCD0BhadrAngle"))->Fill(cosOpenAngle);
7145         ((TH2F*)flistMCproperties->FindObject("hMCD0BhadrAngleEnergy"))->Fill(mcPart->E(),cosOpenAngle);
7146       }
7147    }
7148    ((TH1F*)flistMCproperties->FindObject("hMCPartFound"))->Fill(1,cquarksMC);
7149    ((TH1F*)flistMCproperties->FindObject("hMCPartFound"))->Fill(2,nD0all);
7150    ((TH1F*)flistMCproperties->FindObject("hMCPartFound"))->Fill(3,nD0FromB);
7151    ((TH1F*)flistMCproperties->FindObject("hMCPartFound"))->Fill(4,nD0bMeson);
7152    ((TH1F*)flistMCproperties->FindObject("hMCPartFound"))->Fill(5,nD0bBaryon);
7153    
7154  }
7155
7156
7157 void AliAnalysisTaskSECharmFraction::SetPtBins(Int_t nbins,const Float_t *ptbins){
7158   if((fptbins)!=0x0)delete fptbins;
7159   fnbins=nbins;fptbins=new Float_t[fnbins];
7160   memcpy(fptbins,ptbins,fnbins*sizeof(Float_t));
7161   return;
7162 }
7163
7164 void AliAnalysisTaskSECharmFraction::SetStandardMassSelection(){
7165   //SET THE DEFAULT VALUES FOR INVARIANT MASS SELECTION
7166
7167   /*HERE DEFAULT
7168     SetSignalInvMassCut();
7169     SetLargeInvMassCut();
7170     SetSideBandInvMassCut();
7171     SetSideBandInvMassWindow();
7172   */
7173
7174   // HERE FOR SEARCH FOR SIGNAL
7175   SetSignalInvMassCut();
7176   SetLargeInvMassCut();
7177   SetSideBandInvMassCut();
7178   SetSideBandInvMassWindow();
7179   return;
7180 }
7181
7182 Bool_t AliAnalysisTaskSECharmFraction::SpecialSelD0(AliAODRecoDecayHF2Prong *d,Int_t &nusedforVtx){
7183   
7184   AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
7185   AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
7186   nusedforVtx=0;
7187   if(trk0->GetUsedForPrimVtxFit())nusedforVtx++;
7188   if(trk1->GetUsedForPrimVtxFit())nusedforVtx++;
7189   if(nusedforVtx>fNtrMaxforVtx)return kFALSE;
7190   
7191   if(TMath::Abs(d->Getd0Prong(1)) < -99999.  || 
7192      TMath::Abs(d->Getd0Prong(0)) < -99999.) return kFALSE;
7193   
7194   return kTRUE;
7195 }
7196
7197
7198
7199 AliAODVertex* AliAnalysisTaskSECharmFraction::GetPrimaryVtxSkipped(AliAODEvent *aodev,AliAODRecoDecayHF2Prong *d){
7200   //Calculate the primary vertex w/o the daughter tracks of the candidate
7201   
7202   AliESDVertex *vertexESD=0x0;
7203   AliAODVertex *vertexAOD=0x0;
7204   AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
7205   
7206   Int_t skipped[2];
7207   Int_t nTrksToSkip=2;
7208   AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(0);
7209   skipped[0]=dgTrack->GetID();
7210   dgTrack = (AliAODTrack*)d->GetDaughter(1);
7211   skipped[1]=dgTrack->GetID();
7212
7213  
7214   //
7215   vertexer->SetSkipTracks(nTrksToSkip,skipped);
7216   vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev); 
7217   vertexer->SetMinClusters(4);  
7218   if(!vertexESD) return vertexAOD;
7219   if(vertexESD->GetNContributors()<=0) { 
7220     AliDebug(2,"vertexing failed"); 
7221     delete vertexESD; vertexESD=NULL;
7222     return vertexAOD;
7223   }
7224   
7225   delete vertexer; vertexer=NULL;
7226   
7227   
7228   // convert to AliAODVertex
7229   Double_t pos[3],cov[6],chi2perNDF;
7230   vertexESD->GetXYZ(pos); // position
7231   vertexESD->GetCovMatrix(cov); //covariance matrix
7232   chi2perNDF = vertexESD->GetChi2toNDF();
7233   delete vertexESD; vertexESD=NULL;
7234   
7235   vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
7236   return vertexAOD;
7237   
7238 }
7239
7240
7241
7242  Bool_t AliAnalysisTaskSECharmFraction::FillAziList(AliAODEvent *aod,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t &nprim)const{
7243    Int_t ntracks=aod->GetNumberOfTracks();
7244    Double_t ptmin=1.;
7245    if(ntracks>30000){
7246      nprim=1;
7247      return kFALSE;       
7248    }
7249    nprim=0;
7250    for(Int_t it=0;it<ntracks;it++) {
7251      AliAODTrack *track = dynamic_cast<AliAODTrack*>(aod->GetTrack(it));
7252      if(!track) AliFatal("Not a standard AOD");
7253      
7254      if(track->IsPrimaryCandidate()){
7255        if(track->Pt()>ptmin){
7256          
7257          azilist[nprim]=track->Phi();
7258          trkIDlist[nprim]=track->GetID();
7259          nprim++;
7260        }
7261      }
7262    }
7263    return kTRUE;
7264  }
7265  
7266  
7267  void AliAnalysisTaskSECharmFraction::FillAziHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t nprim,Int_t okD0,Int_t okD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar)const{
7268    
7269    if((!okD0)&&(!okD0bar))return;
7270    if(ptbin==-1)return;
7271    TString namehist=list->GetName(),str;
7272    namehist.ReplaceAll("list","");
7273    //   Double_t ptD=d->Pt();
7274  
7275    str="hPhiHist";
7276    if(isPeakD0||isPeakD0bar)str.Append("PM");
7277    else if(isSideBandD0||isSideBandD0bar)str.Append("SB");
7278    else return;
7279    str.Append(namehist.Data());
7280    str.Append("_pt");
7281    str+=ptbin;
7282    
7283    AliAODTrack *dtr;
7284    dtr=(AliAODTrack*)d->GetDaughter(0);
7285    Int_t id1=dtr->GetID();
7286    dtr=(AliAODTrack*)d->GetDaughter(1);
7287    Int_t id2=dtr->GetID();
7288    
7289    Double_t phi=d->Phi();       
7290    Double_t weight=1./nprim;
7291    Double_t azi;
7292    for(Int_t j=0;j<nprim;j++){
7293      if(trkIDlist[j]!=id1&&trkIDlist[j]!=id2){
7294        azi=azilist[j]-phi;
7295        if(azi>TMath::Pi())azi-=2.*TMath::Pi();
7296        else if(azi<-TMath::Pi())azi+=2.*TMath::Pi();
7297        
7298        ((TH1F*)list->FindObject(str.Data()))->Fill(azi,weight);
7299      }
7300    }
7301    
7302    
7303  }
7304
7305
7306 //_______________________________________________
7307 void AliAnalysisTaskSECharmFraction::SetPtWeightsFromDataPbPb276overLHC12a17a(){
7308   // Method cp paste from AliCFTaskVertexingHF
7309   // ad-hoc weight function from ratio of 
7310   // D0 pt spectra in PbPb 2011 0-10% centrality and
7311  // pt spectra from MC production LHC12a17a (PYTHIA Perugia0 with pthard bins)
7312   if(fWeightPt) delete fWeightPt;
7313   fWeightPt=new TF1("funcWeight","[0]+[1]/TMath::Power(x,[2])",0.05,50.);
7314   fWeightPt->SetParameter(0,1.43116e-02);
7315   fWeightPt->SetParameter(1,4.37758e+02);
7316   fWeightPt->SetParameter(2,3.08583);
7317
7318 }
7319
7320
7321
7322 //_______________________________
7323 void AliAnalysisTaskSECharmFraction::Terminate(const Option_t*){
7324   //TERMINATE METHOD: NOTHING TO DO
7325
7326
7327
7328 }