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