bf2f1dd2879be1f5833683235031bb3f97b2a70d
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSELc2V0bachelor.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  * appeuear 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 /* $Id$ */
17
18 //
19 //
20 //               Base class for Lc2V0 Analysis
21 //
22 //
23 //  The Lc spectra study is done 2D histograms:
24 //   cascade_invariantMass VS cascade_pT
25 //
26 //  Cuts have been centralized in AliRDHFCutsLctoV0 class
27 //
28 //-------------------------------------------------------------------------
29 //
30 //                 Authors: A.De Caro(a,b), P. Pagano(b)
31 //  (a) Centro Fermi - Roma and Salerno INFN-University - decaro@sa.infn.it
32 //  (b) Salerno INFN-University - paola.pagano@sa.infn.it
33 //
34 //-------------------------------------------------------------------------
35
36 #include <TSystem.h>
37 #include <TParticle.h>
38 #include <TParticlePDG.h>
39 #include <TH1F.h>
40 #include <TH2F.h>
41 #include "TROOT.h"
42 #include <TDatabasePDG.h>
43 #include <AliAnalysisDataSlot.h>
44 #include <AliAnalysisDataContainer.h>
45 #include "AliStack.h"
46 #include "AliMCEvent.h"
47 #include "AliAnalysisManager.h"
48 #include "AliAODMCHeader.h"
49 #include "AliAODHandler.h"
50 #include "AliLog.h"
51 #include "AliAODVertex.h"
52 #include "AliAODRecoDecay.h"
53 #include "AliAODRecoDecayHF.h"
54 #include "AliAODRecoCascadeHF.h"
55 #include "AliAnalysisVertexingHF.h"
56 #include "AliESDtrack.h"
57 #include "AliAODTrack.h"
58 #include "AliAODv0.h"
59 #include "AliAODMCParticle.h"
60 #include "AliAnalysisTaskSE.h"
61 #include "AliAnalysisTaskSELc2V0bachelor.h"
62 #include "AliNormalizationCounter.h"
63 #include "AliAODPidHF.h"
64 #include "AliPIDResponse.h"
65 #include "AliTOFPIDResponse.h"
66 #include "AliInputEventHandler.h"
67
68 ClassImp(AliAnalysisTaskSELc2V0bachelor)
69
70 //__________________________________________________________________________
71 AliAnalysisTaskSELc2V0bachelor::AliAnalysisTaskSELc2V0bachelor():  
72   AliAnalysisTaskSE(),
73   fUseMCInfo(kFALSE),
74   fOutput(0),
75   fOutputAll(0),
76   fOutputPIDBach(0),
77   fCEvents(0),
78   fPIDResponse(0),
79   fIsK0sAnalysis(kFALSE),
80   fCounter(0),
81   fProdCuts(0),
82   fAnalCuts(0),
83   fListCuts(0)
84 {
85   //
86   // Default ctor
87   //
88 }
89 //___________________________________________________________________________
90 AliAnalysisTaskSELc2V0bachelor::AliAnalysisTaskSELc2V0bachelor(const Char_t* name, AliRDHFCutsLctoV0* prodCuts, AliRDHFCutsLctoV0* analCuts) :
91   AliAnalysisTaskSE(name),
92   fUseMCInfo(kFALSE),
93   fOutput(0),
94   fOutputAll(0),
95   fOutputPIDBach(0),
96   fCEvents(0),
97   fPIDResponse(0),
98   fIsK0sAnalysis(kFALSE),
99   fCounter(0),
100   fProdCuts(prodCuts),
101   fAnalCuts(analCuts),
102   fListCuts(0)
103 {
104   //
105   // Constructor. Initialization of Inputs and Outputs
106   //
107   Info("AliAnalysisTaskSELc2V0bachelor","Calling Constructor");
108
109   DefineOutput(1,TList::Class());  //conters
110   DefineOutput(2,TList::Class());  //All Entries output
111   DefineOutput(3,TList::Class());  //3sigma PID output
112   DefineOutput(4,AliNormalizationCounter::Class());
113   DefineOutput(5,TList::Class());
114
115 }
116
117 //___________________________________________________________________________
118 AliAnalysisTaskSELc2V0bachelor::~AliAnalysisTaskSELc2V0bachelor() {
119   //
120   // destructor
121   //
122   Info("~AliAnalysisTaskSELc2V0bachelor","Calling Destructor");
123   
124   if (fOutput) {
125     delete fOutput;
126     fOutput = 0;
127   }
128
129   if (fOutputAll) {
130     delete fOutputAll;
131     fOutputAll = 0;
132   }
133
134   if (fOutputPIDBach) {
135     delete fOutputPIDBach;
136     fOutputPIDBach = 0;
137   }
138
139   if (fPIDResponse) {
140     delete  fPIDResponse;
141   }
142
143   if (fCounter) {
144     delete fCounter;
145     fCounter = 0;
146   }
147
148   if (fProdCuts) {
149     delete fProdCuts;
150     fProdCuts = 0;
151   }
152
153   if (fAnalCuts) {
154     delete fAnalCuts;
155     fAnalCuts = 0;
156   }
157
158   if (fListCuts) {
159     delete fListCuts;
160     fListCuts = 0;
161   }
162
163 }
164 //_________________________________________________
165 void AliAnalysisTaskSELc2V0bachelor::Init() {
166   //
167   // Initialization
168   //
169
170   if (fDebug > 1) AliInfo("Init");
171
172   fListCuts = new TList();
173   fListCuts->SetOwner();
174   fListCuts->Add(new AliRDHFCutsLctoV0(*fProdCuts));
175   fListCuts->Add(new AliRDHFCutsLctoV0(*fAnalCuts));
176   PostData(5,fListCuts);
177
178   return;
179 }
180
181 //_________________________________________________
182 void AliAnalysisTaskSELc2V0bachelor::UserExec(Option_t *)
183 {
184   // user exec
185   if (!fInputEvent) {
186     AliError("NO EVENT FOUND!");
187     return;
188   }
189
190   AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
191   TClonesArray *arrayLctopKos=0;
192
193   if (!aodEvent && AODEvent() && IsStandardAOD()) {
194     // In case there is an AOD handler writing a standard AOD, use the AOD 
195     // event in memory rather than the input (ESD) event.    
196     aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
197     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
198     // have to taken from the AOD event hold by the AliAODExtension
199     AliAODHandler* aodHandler = (AliAODHandler*) 
200       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
201    
202     if (aodHandler->GetExtensions()) {
203       AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
204       AliAODEvent *aodFromExt = ext->GetAOD();
205       arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
206     }
207   } else {
208     arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
209   }
210
211   fCEvents->Fill(1);
212   fCounter->StoreEvent(aodEvent,fAnalCuts,fUseMCInfo);
213
214   // fix for temporary bug in ESDfilter 
215   // the AODs with null vertex pointer didn't pass the PhysSel
216   if (!aodEvent->GetPrimaryVertex() ||
217       TMath::Abs(aodEvent->GetMagneticField())<0.001) return;
218   fCEvents->Fill(2);
219
220   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD
221   TString trigclass = aodEvent->GetFiredTriggerClasses();
222   if (trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD")||trigclass.Contains("C0SMH-B-NOPF-ALL"))
223     fCEvents->Fill(5); // in case of RealData events
224
225   // AOD primary vertex
226   AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
227   if (!vtx1) return;
228   if (vtx1->GetNContributors()<1) return;
229   fCEvents->Fill(3);
230
231   if (!arrayLctopKos) {
232     AliInfo("Could not find array of HF cascades, skipping the event");
233     return;
234   } else {
235     if (arrayLctopKos->GetEntriesFast()==0) {
236       AliInfo("Could not find cascades, skipping the event");
237       return;
238     } else {
239       AliInfo(Form("Found %d cascades",arrayLctopKos->GetEntriesFast()));
240     }
241   }
242
243   fCEvents->Fill(4);
244
245   if(!fAnalCuts->IsEventSelected(aodEvent)) return;
246
247   // mc analysis 
248   TClonesArray *mcArray = 0;
249   AliAODMCHeader *mcHeader=0;
250
251   if (fUseMCInfo) {
252     // MC array need for maching
253     mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
254     if (!mcArray) {
255       AliError("Could not find Monte-Carlo in AOD");
256       return;
257     }
258     fCEvents->Fill(5); // in case of MC events
259
260     // load MC header
261     mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
262     if (!mcHeader) {
263       AliError("AliAnalysisTaskSELc2V0bachelor::UserExec: MC header branch not found!\n");
264       return;
265     }
266     fCEvents->Fill(6);
267
268     //AliInfo("~~~~~~~~~~Sono dentro fUseMCInfo 2");
269
270     // check on MC Lc Daughter
271     SearchLcDaughter(mcArray);
272
273   }
274
275   //AliInfo("~~~~~~~~~~Sono prima di isEvSelA");
276   Int_t nSelectedProd = 0;
277   Int_t nSelectedAnal = 0;
278   if (fIsK0sAnalysis) MakeAnalysisForLc2prK0S(vtx1,arrayLctopKos,mcArray,
279                                               nSelectedProd, fProdCuts, nSelectedAnal, fAnalCuts);
280
281   fCounter->StoreCandidates(aodEvent,nSelectedProd,kTRUE);
282   fCounter->StoreCandidates(aodEvent,nSelectedAnal,kFALSE);
283
284   PostData(1,fOutput);
285   PostData(2,fOutputAll);
286   PostData(3,fOutputPIDBach);
287   PostData(4,fCounter);
288
289 }
290 //________________________________________ terminate ___________________________
291 void AliAnalysisTaskSELc2V0bachelor::Terminate(Option_t*)
292 {    
293   // The Terminate() function is the last function to be called during
294   // a query. It always runs on the client, it can be used to present
295   // the results graphically or save the results to file.
296   
297   //AliInfo("Terminate","");
298   AliAnalysisTaskSE::Terminate();
299   
300   fOutput = dynamic_cast<TList*> (GetOutputData(1));
301   if (!fOutput) {     
302     AliError("fOutput not available");
303     return;
304   }
305   
306   //fCEvents   = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
307
308   fOutputAll = dynamic_cast<TList*> (GetOutputData(2));
309   if (!fOutputAll) {
310     AliError("fOutputAll not available");
311     return;
312   }
313
314   fOutputPIDBach = dynamic_cast<TList*> (GetOutputData(3));
315   if (!fOutputPIDBach) {
316     AliError("fOutputPIDBach not available");
317     return;
318   }
319
320   return;
321 }
322 //___________________________________________________________________________
323 void AliAnalysisTaskSELc2V0bachelor::UserCreateOutputObjects() { 
324   // output
325   AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
326   
327   //slot #1  
328   //OpenFile(1);
329   fOutput = new TList();
330   fOutput->SetOwner();
331   fOutput->SetName("chist0");
332
333   fOutputAll = new TList();
334   fOutputAll->SetOwner();
335   fOutputAll->SetName("listAll");
336
337   fOutputPIDBach = new TList();
338   fOutputPIDBach->SetOwner();
339   fOutputPIDBach->SetName("listPIDBach");
340
341   // define histograms
342   DefineHistograms();
343   
344   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
345   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
346   fPIDResponse = inputHandler->GetPIDResponse();
347
348   if (fProdCuts->GetIsUsePID()){
349     fProdCuts->GetPidHF()->SetPidResponse(fPIDResponse);
350     fProdCuts->GetPidV0pos()->SetPidResponse(fPIDResponse);
351     fProdCuts->GetPidV0neg()->SetPidResponse(fPIDResponse);
352     fProdCuts->GetPidHF()->SetOldPid(kFALSE);
353     fProdCuts->GetPidV0pos()->SetOldPid(kFALSE);
354     fProdCuts->GetPidV0neg()->SetOldPid(kFALSE);
355   }
356   if (fAnalCuts->GetIsUsePID()){
357     fAnalCuts->GetPidHF()->SetPidResponse(fPIDResponse);
358     fAnalCuts->GetPidV0pos()->SetPidResponse(fPIDResponse);
359     fAnalCuts->GetPidV0neg()->SetPidResponse(fPIDResponse);
360     fAnalCuts->GetPidHF()->SetOldPid(kFALSE);
361     fAnalCuts->GetPidV0pos()->SetOldPid(kFALSE);
362     fAnalCuts->GetPidV0neg()->SetOldPid(kFALSE);
363   }
364
365   PostData(1,fOutput);
366   PostData(2,fOutputAll);
367   PostData(3,fOutputPIDBach);
368
369   fCounter = new AliNormalizationCounter("NormalizationCounter");
370   fCounter->Init();
371   PostData(4,fCounter);
372   
373   return;
374 }
375 //___________________________________ hiostograms _______________________________________
376 void  AliAnalysisTaskSELc2V0bachelor::DefineHistograms() {
377
378   fCEvents = new TH1F("fCEvents","conter",11,0,11);
379   fCEvents->SetStats(kTRUE);
380   fCEvents->GetXaxis()->SetTitle("1");
381   fCEvents->GetYaxis()->SetTitle("counts");
382
383   fOutput->Add(fCEvents);
384   TString fillthis="";
385
386   if (fUseMCInfo) {
387     fillthis="histMcStatLc";
388     TH1F* mcStatisticLc = new TH1F(fillthis.Data(),"#Lambda_{C} generated and their decays",19,-9.5,9.5);
389     fOutput->Add(mcStatisticLc);
390   }
391
392   fillthis="histopionV0SigmaVspTOF";
393   TH2F *hpionV0SigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),100,0.,5.0,100,-10.0,10.0);
394   fillthis="histoprotonBachSigmaVspTOF";
395   TH2F *hprotonBachSigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),100,0.,5.0,100,-10.0,10.0);
396
397   fOutput->Add(hpionV0SigmaVspTOF);
398   fOutput->Add(hprotonBachSigmaVspTOF);
399
400   fillthis="histopionV0SigmaVspTPC";
401   TH2F *hpionV0SigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),100,0.,5.0,100,-10.0,10.0);
402   fillthis="histoprotonBachSigmaVspTPC";
403   TH2F *hprotonBachSigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),100,0.,5.0,100,-10.0,10.0);
404
405   fOutput->Add(hpionV0SigmaVspTPC);
406   fOutput->Add(hprotonBachSigmaVspTPC);
407
408   if (fIsK0sAnalysis) DefineK0SHistos();// hK0S histos declarations
409
410   return;
411 }
412 //________________________________________________________________________
413 void AliAnalysisTaskSELc2V0bachelor::FillLc2pK0Sspectrum(AliAODRecoCascadeHF *part,
414                                                    Int_t isLc,
415                                                    Int_t &nSelectedProd,
416                                                    AliRDHFCutsLctoV0 *cutsProd,
417                                                    Int_t &nSelectedAnal,
418                                                    AliRDHFCutsLctoV0 *cutsAnal)
419 {
420   //
421   // Fill histos for Lc -> K0S+proton
422   //
423   
424   if ( ((cutsProd->IsSelectedPID(part)&(0x1))==1) &&
425        ((cutsProd->IsSelected(part,AliRDHFCuts::kCandidate,2)&(0x1))==1) ) nSelectedProd++;
426
427   TString fillthis="";
428
429   Double_t invmassLc = part->InvMassLctoK0sP();
430   Double_t lambdacpt=part->Pt();
431   Double_t cosOAK0Sp = part->PxProng(0)*part->PxProng(1)+
432     part->PyProng(0)*part->PyProng(1)+
433     part->PzProng(0)*part->PzProng(1);
434   cosOAK0Sp /= (part->PProng(0)*part->PProng(1));
435
436   AliAODv0 * v0part = (AliAODv0*)part->Getv0();
437   Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
438   Double_t momK0s  = TMath::Sqrt(v0part->Ptot2V0());
439   Double_t ptK0s = TMath::Sqrt(v0part->Pt2V0());
440   Double_t dcaV0 = v0part->DcaV0ToPrimVertex();
441   Double_t invmassK0s = v0part->MassK0Short();
442   Bool_t isInV0window = ((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate,2)&(0x1))==1); // cut on V0 invMass
443
444   AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
445   Double_t momBach  = bachelor->P();
446   Bool_t isBachelorID = ((cutsAnal->IsSelectedPID(part)&(0x1))==1); // ID x bachelor
447
448   isBachelorID = isBachelorID && isInV0window; // ID x bachelor and invMass x V0
449
450   if (isBachelorID) nSelectedAnal++;
451
452   if (onFlyV0) {  
453     fillthis="histpK0Svsp";
454     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
455     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
456
457     fillthis="histcosOAK0Spvsp";
458     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
459     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
460
461     fillthis="histoDCAtoPVvsinvmassK0s";
462     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
463     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
464
465     fillthis="histK0SMass";
466     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
467     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
468
469     if (isInV0window) {
470       fillthis="histLcMassByK0S";
471       ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
472       if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
473  
474       fillthis="histArmPodK0s";
475       FillArmPodDistribution(v0part,fillthis,fOutputAll);
476       if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
477     }  
478   }
479   else{  
480     fillthis="histpK0SvspOffline";
481     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
482     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
483
484     fillthis="histcosOAK0SpvspOffline";
485     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
486     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
487   
488     fillthis="histoDCAtoPVvsinvmassK0sOffline";
489     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
490     if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
491
492     fillthis="histK0SMassOffline";
493     ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
494     if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
495
496     if (isInV0window) {
497       fillthis="histLcMassOfflineByK0S";
498       ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
499       if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
500  
501       fillthis="histOfflineArmPodK0s";
502       FillArmPodDistribution(v0part,fillthis,fOutputAll);
503       if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
504     }
505   }
506
507
508   if (fUseMCInfo) {
509     if (isLc==1) {
510       if (onFlyV0) {  
511         fillthis="histpK0SvspSgn";
512         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
513         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
514
515         fillthis="histcosOAK0SpSgnvsp";
516         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
517         if (isBachelorID)     ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
518
519         fillthis="histoDCAtoPVvsinvmassK0sSgn";
520         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
521         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
522
523         fillthis="histK0SMassSgn";
524         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
525         if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
526
527         if (isInV0window) {
528           fillthis="histLcMassByK0SSgn";
529           ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
530           if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
531
532           fillthis="histArmPodK0sSgn";
533           FillArmPodDistribution(v0part,fillthis,fOutputAll);
534           if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
535         }
536     
537       }     
538       else{  
539         fillthis="histpK0SvspOfflineSgn";
540         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
541         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
542   
543         fillthis="histcosOAK0SpSgnvspOffline";
544         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
545         if (isBachelorID)     ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
546
547         fillthis="histoDCAtoPVvsinvmassK0sOfflineSgn";
548         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
549         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
550    
551         fillthis="histK0SMassOfflineSgn";
552         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
553         if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
554
555  
556
557         if (isInV0window) {
558           fillthis="histLcMassOfflineByK0SSgn";
559           ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
560           if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
561           
562           fillthis="histOfflineArmPodK0sSgn";
563           FillArmPodDistribution(v0part,fillthis,fOutputAll);
564           if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
565         }
566
567       }
568
569     }// sgn
570     else { // bkg
571       if (onFlyV0) {  
572         fillthis="histpK0SvspBkg";
573         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
574         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
575
576         fillthis="histcosOAK0SpBkgvsp";
577         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
578         if (isBachelorID)   ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
579
580         fillthis="histoDCAtoPVvsinvmassK0sBkg";
581         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
582         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
583
584         fillthis="histK0SMassBkg";
585         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
586         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
587
588         if (isInV0window) {
589           fillthis="histLcMassByK0SBkg";
590           ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
591           if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
592  
593           fillthis="histArmPodK0sBkg";
594           FillArmPodDistribution(v0part,fillthis,fOutputAll);
595           if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
596         }
597
598       }
599       else {  
600         fillthis="histpK0SvspOfflineBkg";
601         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0s);
602         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0s);
603    
604         fillthis="histcosOAK0SpBkgvspOffline";
605         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
606         if (isBachelorID)   ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(cosOAK0Sp,lambdacpt);
607     
608         fillthis="histoDCAtoPVvsinvmassK0sOfflineBkg";
609         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
610         if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,dcaV0);
611
612         fillthis="histK0SMassOfflineBkg";
613         ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
614         if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassK0s,ptK0s);
615   
616         if (isInV0window) {
617           fillthis="histLcMassOfflineByK0SBkg";
618           ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
619           if (isBachelorID)  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
620  
621           fillthis="histOfflineArmPodK0sBkg";
622           FillArmPodDistribution(v0part,fillthis,fOutputAll);
623           if (isBachelorID) FillArmPodDistribution(v0part,fillthis,fOutputPIDBach);
624         }
625        }
626     }
627   } // if fUseMCInfo
628  
629   return;
630 }
631 //-------------------------------------------------------------------------------
632 Int_t AliAnalysisTaskSELc2V0bachelor::CheckOrigin(TClonesArray* arrayMC, AliAODMCParticle *mcPartCandidate) const {             
633   //
634   // checking whether the mother of the particles come from a charm or a bottom quark
635   //
636         
637   Int_t pdgGranma = 0;
638   Int_t abspdgGranma =0;
639   Bool_t isFromB=kFALSE;
640   Bool_t isQuarkFound=kFALSE;
641   Int_t mother = mcPartCandidate->GetMother();
642   Int_t istep = 0;
643   while (mother>0) {
644     istep++;
645     AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
646     if (mcGranma) {
647       pdgGranma = mcGranma->GetPdgCode();
648       abspdgGranma = TMath::Abs(pdgGranma);
649       if ( (abspdgGranma > 500  && abspdgGranma < 600 ) ||
650            (abspdgGranma > 5000 && abspdgGranma < 6000) ) isFromB=kTRUE;
651       else if (abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
652       mother = mcGranma->GetMother();
653     } else {
654       AliError("Failed casting the mother particle!");
655       break;
656     }
657   }
658   
659   if (isFromB) return 5;
660   else return 4;
661
662 }
663
664 //-------------------------------------------------------------------------------
665 void AliAnalysisTaskSELc2V0bachelor::MakeAnalysisForLc2prK0S(AliAODVertex */*vtx1*/,
666                                                        TClonesArray *arrayLctopKos,
667                                                        TClonesArray *mcArray,
668                                                        Int_t &nSelectedProd,
669                                                        AliRDHFCutsLctoV0 *cutsProd,
670                                                        Int_t &nSelectedAnal,
671                                                        AliRDHFCutsLctoV0 *cutsAnal)
672 {
673
674   // counters for efficiencies
675   Int_t icountReco = 0;
676
677   //Lc prong needed to MatchToMC method
678
679   Int_t pdgDgLctoK0spr[2]={2212,310}; // bachelor+V0
680   Int_t pdgDgK0stopipi[2]={211,211};
681
682   // loop over cascades to search for candidates Lc->p+K0S
683   Int_t nCascades= arrayLctopKos->GetEntriesFast();
684   for (Int_t iLctopK0s = 0; iLctopK0s<nCascades; iLctopK0s++) {
685
686     // Lc candidates and K0s from Lc
687     AliAODRecoCascadeHF* lcK0spr = (AliAODRecoCascadeHF*)arrayLctopKos->At(iLctopK0s);
688     if (!lcK0spr->GetSecondaryVtx()) {
689       AliInfo("No secondary vertex");
690       continue;
691     }
692
693     AliAODTrack * v0Pos = lcK0spr->Getv0PositiveTrack();
694     AliAODTrack * v0Neg = lcK0spr->Getv0NegativeTrack();
695     if (v0Pos->Charge() ==  v0Neg->Charge()) continue;
696   
697     Int_t isLc = 0;
698
699     if (fUseMCInfo) {
700
701       Bool_t isPrimary=kTRUE;
702   
703       Int_t pdgCode=-2;
704
705       // find associated MC particle for Lc -> p+K0 and K0S->pi+pi
706       Int_t mcLabel = MatchToMC(lcK0spr,pdgDgLctoK0spr,pdgDgK0stopipi,mcArray);
707       if (mcLabel>=0) {
708         AliInfo(Form(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cascade numero %d di %d", iLctopK0s,nCascades));
709
710         AliAODMCParticle *partLc = (AliAODMCParticle*)mcArray->At(mcLabel);
711         Int_t checkOrigin = CheckOrigin(mcArray,partLc);
712         if (checkOrigin==5) isPrimary=kFALSE;
713
714         pdgCode = partLc->GetPdgCode();
715         if (pdgCode<0) AliInfo(Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ %d ~~~~~~~~~~ %d", mcLabel, pdgCode));
716         pdgCode = TMath::Abs(pdgCode);
717         isLc = 1;
718       } else {
719         pdgCode=-1;
720       }
721     }
722
723     if( (cutsProd->IsSelected(lcK0spr,AliRDHFCuts::kTracks)&(0x1))==0 ) continue;
724
725     FillLc2pK0Sspectrum(lcK0spr, isLc,
726                         nSelectedProd, cutsProd,
727                         nSelectedAnal, cutsAnal);
728
729   }
730   
731   AliDebug(2, Form("Found %d Reco particles that are Lc!!", icountReco));
732
733 }
734 //-------------------------------------------------------------------------------
735 Int_t AliAnalysisTaskSELc2V0bachelor::MatchToMC(AliAODRecoCascadeHF *lc2bacV0,
736                                           Int_t *pdgDgLc2bacV0, Int_t *pdgDgV0,
737                                           TClonesArray *mcArray)
738 {
739
740   // bachelor
741   AliAODTrack *bachelor = (AliAODTrack*)lc2bacV0->GetBachelor();
742   Int_t labBachelor = bachelor->GetLabel();
743   if (labBachelor<0) return -1;
744   AliAODMCParticle *partBachelor = (AliAODMCParticle*)mcArray->At(labBachelor);
745   if (TMath::Abs(partBachelor->GetPdgCode())!=pdgDgLc2bacV0[0]) return -1;
746
747   Int_t labBacMother = partBachelor->GetMother();
748   if (labBacMother<0) return -1;
749   AliAODMCParticle *partBacMother = (AliAODMCParticle*)mcArray->At(labBacMother);
750   if (TMath::Abs(partBacMother->GetPdgCode())!=4122) return -1;
751
752   // V0
753   AliAODTrack *posV0Daugh = (AliAODTrack*)lc2bacV0->Getv0PositiveTrack();
754   AliAODTrack *negV0Daugh = (AliAODTrack*)lc2bacV0->Getv0NegativeTrack();
755   Int_t labV0pos = posV0Daugh->GetLabel();
756   Int_t labV0neg = negV0Daugh->GetLabel();
757
758   if (labV0pos<0 || labV0neg<0) return -1;
759   AliAODMCParticle *partV0pos = (AliAODMCParticle*)mcArray->At(labV0neg);
760   AliAODMCParticle *partV0neg = (AliAODMCParticle*)mcArray->At(labV0pos);
761
762   if ( ! ( (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[0] &&
763             TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[1]) ||
764            (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[1] &&
765             TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[0]) ) ) return -1;
766   Int_t labV0posMother = partV0pos->GetMother();
767   Int_t labV0negMother = partV0neg->GetMother();
768
769   if (labV0posMother<0 || labV0negMother<0) return -1;
770   if (labV0posMother!=labV0negMother) return -1;
771
772   AliAODMCParticle *motherV0 = (AliAODMCParticle*)mcArray->At(labV0posMother);
773
774   if (TMath::Abs(motherV0->GetPdgCode())!=pdgDgLc2bacV0[1]) return -1;
775   Int_t labV0mother = motherV0->GetMother();
776   if (labV0mother<0) return -1;
777   AliAODMCParticle *gMotherV0 = (AliAODMCParticle*)mcArray->At(labV0mother);
778
779   if ( !(pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) &&
780        !(pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) ) return -1;
781
782   if ( (pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) ) {
783     Int_t labV0GMother = gMotherV0->GetMother();
784     if (labV0GMother<0) return -1;
785     AliAODMCParticle *ggMotherV0 = (AliAODMCParticle*)mcArray->At(labV0GMother);
786
787     if (TMath::Abs(ggMotherV0->GetPdgCode())!=4122) return -1;
788     gMotherV0 = (AliAODMCParticle*)ggMotherV0;
789     labV0mother=labV0GMother;
790   }
791   else if (pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) {
792     if (TMath::Abs(gMotherV0->GetPdgCode())!=4122) return -1;
793   }
794
795   if (labBacMother!=labV0mother) {
796     AliInfo(Form("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++A - %d %d",
797                  labBacMother, labV0mother));
798     return -1;
799   }
800
801   AliInfo(Form(" V0: %d (%d) ->  %d (%d) + %d (%d) --- GM %d (PDG=%d)",
802                motherV0->GetPdgCode(), labV0posMother,
803                partV0pos->GetPdgCode(), labV0pos,
804                partV0neg->GetPdgCode(), labV0neg,
805                labV0mother, gMotherV0->GetPdgCode()));
806
807   AliInfo(Form(" Bachelor: %d (%d) --- M %d (%d)",
808                partBachelor->GetPdgCode(), labBachelor,
809                labBacMother, partBacMother->GetPdgCode()));
810   return labBacMother;//labV0mother;//
811
812 }
813
814 //-----------------------
815 void AliAnalysisTaskSELc2V0bachelor::SearchLcDaughter(TClonesArray *arrayMC)
816 {
817  
818   AliAODMCParticle *searchLc;
819   AliAODMCParticle *daugh;
820   AliAODMCParticle *daugh1;
821   AliAODMCParticle *daugh2;
822   AliAODMCParticle *daughK0;
823   AliAODMCParticle *daughK0s;
824   AliAODMCParticle *daughK0s1;
825   AliAODMCParticle *daughK0s2;
826   AliAODMCParticle *daughL1;
827   AliAODMCParticle *daughL2;
828   Int_t nDaughLc=0;
829
830   Int_t nDaughK0=0;
831   Int_t nDaughK0s=0;
832   Int_t searchLcpdg=0;
833   Int_t daughPdg1=0;
834   Int_t daughPdg2=0;
835   Int_t daughK0Pdg=0;
836   Int_t nDaughL=0;
837   Int_t daughK0s1pdg;
838   Int_t daughK0s2pdg;
839   Int_t daughL1pdg=0;
840   Int_t daughL2pdg=0;
841
842   TString fillthis="";
843   fillthis="histMcStatLc";
844
845   for (Int_t iii=0; iii<arrayMC->GetEntries(); iii++) {
846     searchLc = (AliAODMCParticle*)arrayMC->At(iii);
847     searchLcpdg =  searchLc->GetPdgCode();
848     if (TMath::Abs(searchLcpdg) == 4122) {
849       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(0);
850       nDaughLc= searchLc->GetNDaughters();
851
852       if (searchLcpdg == 4122) { // It is Lc+
853         ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(1);
854         if (nDaughLc!=2) continue;
855         daugh1 = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(0));
856         daughPdg1=daugh1->GetPdgCode();
857         daugh2 = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(1));
858         daughPdg2=daugh2->GetPdgCode();
859         if ( (daughPdg1==2212 && daughPdg2==-311) ||
860              (daughPdg2==2212 && daughPdg1==-311) ) { // Lc+ -> p K0bar
861           ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(2);
862           if (daughPdg1==-311) {
863             daughK0 = (AliAODMCParticle*)arrayMC->At(daugh1->GetDaughter(0));
864             nDaughK0=daugh1->GetNDaughters();
865           }
866           else {
867             daughK0 = (AliAODMCParticle*)arrayMC->At(daugh2->GetDaughter(0));
868             nDaughK0=daugh2->GetNDaughters();    
869           }
870           if (nDaughK0==1) {
871             daughK0Pdg=daughK0->GetPdgCode();
872             if (daughK0Pdg!=310) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(4);
873             else {
874               if (daughK0->GetDaughter(0)<0) continue; // it is very strange
875               daughK0s= (AliAODMCParticle*)arrayMC->At(daughK0->GetDaughter(0));
876               cout << " daughK0s = " << daughK0s << endl;
877               nDaughK0s=daughK0s->GetNDaughters();
878               ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(3);
879               if (nDaughK0s!=2) continue;
880               daughK0s1= (AliAODMCParticle*)arrayMC->At(daughK0s->GetDaughter(0));
881               daughK0s2= (AliAODMCParticle*)arrayMC->At(daughK0s->GetDaughter(1));
882               daughK0s1pdg=daughK0s1->GetPdgCode();
883               daughK0s2pdg=daughK0s2->GetPdgCode();
884
885               if ( ((daughK0s1pdg== 211) && (daughK0s2pdg==-211)) ||
886                    ((daughK0s2pdg==-211) && (daughK0s1pdg== 211)) ) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(5);
887               else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(6);
888             }//else (if (nDaughK0!=1))
889           } // if (nDaughK0==1)
890           else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(4);
891         }//if ((daughPdg1==2212 && daughPdg2==311)||(daughPdg2==2212 && daughPdg1==311))
892
893         else if ( (daughPdg1==3122 && daughPdg2==211) ||
894                   (daughPdg2==3122 && daughPdg1==211) ) { // Lc+ -> pi+ Lambda
895           ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(7);
896           if (daughPdg1==3122) daugh = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(0));
897           else daugh = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(1));
898           nDaughL=daugh->GetNDaughters();
899           if (nDaughL==2) {
900             daughL1= (AliAODMCParticle*)arrayMC->At(daugh->GetDaughter(0));
901             daughL2= (AliAODMCParticle*)arrayMC->At(daugh->GetDaughter(1));
902             daughL1pdg=daughL1->GetPdgCode();
903             daughL2pdg=daughL2->GetPdgCode();
904             if ( ((daughL1pdg==-211) && (daughL2pdg==2212)) ||
905                 ((daughL1pdg==2212) && (daughL2pdg==-211))) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(8);
906             else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(9);
907           }//if (nDaughL==2) 
908           else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(9);
909         }//else if ((daughPdg1==3122 && daughPdg2==211)||(daughPdg2==3122 && daughPdg1==211))
910
911
912
913       }//if (searchLcpdg == 4122)
914
915       if (searchLcpdg == -4122) { // It is Lc+
916         ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-1);
917
918         if (nDaughLc!=2) continue;
919         daugh1 = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(0));
920         daughPdg1=daugh1->GetPdgCode();
921         daugh2 = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(1));
922         daughPdg2=daugh2->GetPdgCode();
923         if ( (daughPdg1==-2212 && daughPdg2==311) ||
924              (daughPdg2==-2212 && daughPdg1==311) ) { // Lc- -> pbar K0
925           ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-2);
926           if (daughPdg1==311) {
927             daughK0 = (AliAODMCParticle*)arrayMC->At(daugh1->GetDaughter(0));
928             nDaughK0=daugh1->GetNDaughters();
929           }
930           else {
931             daughK0 = (AliAODMCParticle*)arrayMC->At(daugh2->GetDaughter(0));
932             nDaughK0 = daugh2->GetNDaughters();  
933           }     
934           if (nDaughK0==1) {
935             daughK0Pdg=daughK0->GetPdgCode();
936             if (daughK0Pdg!=310) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-4);
937             else {
938               if (daughK0->GetDaughter(0)<0) continue; // it is very strange
939
940               daughK0s= (AliAODMCParticle*)arrayMC->At(daughK0->GetDaughter(0));
941               nDaughK0s=daughK0s->GetNDaughters();
942               ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-3);
943               if (nDaughK0s!=2) continue;
944               daughK0s1= (AliAODMCParticle*)arrayMC->At(daughK0s->GetDaughter(0));
945               daughK0s2= (AliAODMCParticle*)arrayMC->At(daughK0s->GetDaughter(1));
946               daughK0s1pdg=daughK0s1->GetPdgCode();
947               daughK0s2pdg=daughK0s2->GetPdgCode();
948               if ( ((daughK0s1pdg== 211) && (daughK0s2pdg==-211)) ||
949                    ((daughK0s2pdg==-211) && (daughK0s1pdg== 211)) ) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-5);
950               else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-6);
951             }//else (if (nDaughK0!=1))
952           } // if (nDaughK0==1)
953           else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-4);
954         }//if ((daughPdg1==-2212 && daughPdg2==-311)||(daughPdg2==-2212 && daughPdg1==-311))
955
956         else if ( (daughPdg1==-3122 && daughPdg2==-211) || (daughPdg2==-3122 && daughPdg1==-211) ) {
957           ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-7);
958           if (daughPdg1==-3122) daugh = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(0));
959           else daugh = (AliAODMCParticle*)arrayMC->At(searchLc->GetDaughter(1));
960           nDaughL=daugh->GetNDaughters();
961           if (nDaughL==2) {
962             daughL1 = (AliAODMCParticle*)arrayMC->At(daugh->GetDaughter(0));
963             daughL2 = (AliAODMCParticle*)arrayMC->At(daugh->GetDaughter(1));
964             daughL1pdg=daughL1->GetPdgCode();
965             daughL2pdg= daughL2->GetPdgCode();
966             if ( ((daughL1pdg==  211) && (daughL2pdg==-2212)) ||
967                 ((daughL1pdg==-2212) && (daughL2pdg==  211)) ) ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-8);
968             else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-9);
969           }//if (nDaughL==2) 
970           else ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(-9);
971         }//else if ((daughPdg1==-3122 && daughPdg2==-211)||(daughPdg2==-3122 && daughPdg1==-211))
972
973
974       }
975     }// if (TMath::Abs(searchLcpdg) == 4122)
976   }// for (Int_t iii=0; iii<arrayMC->GetEntries(); iii++)
977   
978 }
979 //----------------------------------------------------
980
981 void AliAnalysisTaskSELc2V0bachelor::FillArmPodDistribution(AliAODv0 *vZero,
982                                                       TString histoTitle,
983                                                       TList *histoList) {
984
985   Double_t alpha = vZero->AlphaV0();
986   Double_t qT    = vZero->PtArmV0();
987
988   ((TH2F*)(histoList->FindObject(histoTitle)))->Fill(alpha,qT);
989
990 }
991 //----------------------------------------------------
992
993 void AliAnalysisTaskSELc2V0bachelor::DefineK0SHistos()
994
995
996   TString nameMass=" ", nameSgn=" ", nameBkg=" ";
997
998   ///---------------- START  K0S HISTOS DECLARATIONS -------------------///
999
1000   // V0 invariant masses (on-the-fly)
1001   nameMass="histK0SMass";
1002   TH2F* spectrumK0SMass = new TH2F(nameMass.Data(),"K^{0}_{S} invariant mass VS p_{T}; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries",
1003                                    520,0.43,0.56,200,0.,20.);
1004   spectrumK0SMass->Sumw2();
1005   spectrumK0SMass->SetLineColor(6);
1006   spectrumK0SMass->SetMarkerStyle(20);
1007   spectrumK0SMass->SetMarkerSize(0.6);
1008   spectrumK0SMass->SetMarkerColor(6);
1009
1010   // V0 invariant masses (offline)
1011   nameMass="histK0SMassOffline";
1012   TH2F* spectrumK0SMassOffline = new TH2F(nameMass.Data(),"K^{0}_{S} invariant mass VS p_{T}; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries",
1013                                           520,0.43,0.56,200,0.,20.);
1014   spectrumK0SMassOffline->Sumw2();
1015   spectrumK0SMassOffline->SetLineColor(6);
1016   spectrumK0SMassOffline->SetMarkerStyle(20);
1017   spectrumK0SMassOffline->SetMarkerSize(0.6);
1018   spectrumK0SMassOffline->SetMarkerColor(6);
1019
1020
1021   // Lc invariant masses (x K0S on-the-fly)
1022   nameMass="histLcMassByK0S";
1023   TH2F* spectrumLcMassByK0S    = new TH2F(nameMass.Data(),"#Lambda_{C} invariant mass (by K^{0}_{S}) vs p_{T} ; M(#Lambda_{C}) [GeV/c^{2}]; p_{T}",
1024                                           1000,2.,2.5,200,0.,20.);
1025   spectrumLcMassByK0S->Sumw2();
1026   spectrumLcMassByK0S->SetLineColor(6);
1027   spectrumLcMassByK0S->SetMarkerStyle(20);
1028   spectrumLcMassByK0S->SetMarkerSize(0.6);
1029   spectrumLcMassByK0S->SetMarkerColor(6);
1030
1031
1032   
1033   // Lc invariant masses (x K0S offline)
1034   nameMass="histLcMassOfflineByK0S";
1035   TH2F* spectrumLcMassOfflineByK0S    = new TH2F(nameMass.Data(),"#Lambda_{C} invariant mass (by K^{0}_{S})  vs p_{T}; M(#Lambda_{C}) [GeV/c^{2}]; p_{T}",
1036                                                  1000,2.,2.5,200,0.,20.);
1037   spectrumLcMassOfflineByK0S->Sumw2();
1038   spectrumLcMassOfflineByK0S->SetLineColor(6);
1039   spectrumLcMassOfflineByK0S->SetMarkerStyle(20);
1040   spectrumLcMassOfflineByK0S->SetMarkerSize(0.6);
1041   spectrumLcMassOfflineByK0S->SetMarkerColor(6);
1042
1043
1044   nameMass="histcosOAK0Spvsp";
1045   TH2F* cosOpeningAngleK0Spvsp= new TH2F(nameMass.Data(),"#Lambda_{C}  : K^{0}_{S} - p Opening Angle vs p; Cos(Opening Angle)  ; p ",
1046                                          200,-1.,1.,200,0.,20.);
1047  
1048   nameMass="histcosOAK0SpvspOffline";
1049   TH2F* cosOpeningAngleK0SpvspOffline= new TH2F(nameMass.Data(),"#Lambda_{C}  : K^{0}_{S} - p Opening Angle vs p  -  Offline ; Cos(Opening Angle)  ; p ",
1050                                                 200,-1.,1.,200,0.,20.);
1051   nameMass="histpK0Svsp";
1052   TH2F* momentumDistributionK0Svsp= new TH2F(nameMass.Data(),"#Lambda_{C}  : K^{0}_{S} vs p Total Momentum Distribution;  p_{p}; p_{K^{0}_{S}}  ",
1053                                              200,0.,20.,200,0.,20.);
1054   nameMass="histpK0SvspOffline";
1055   TH2F* momentumDistributionK0SvspOffline= new TH2F(nameMass.Data(),"#Lambda_{C}  : K^{0}_{S} vs p Total Momentum Distribution - Offline ;  p_{p}; p_{K^{0}_{S}}  ",
1056                                                     200,0.,20.,200,0.,20.);
1057   nameMass="histArmPodK0s";
1058   TH2F* armenterosPodK0s = new TH2F(nameMass.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",
1059                                     200,-1.,1.,300,0.,0.3);
1060   nameMass="histOfflineArmPodK0s";
1061   TH2F* armenterosPodK0sOff = new TH2F(nameMass.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",200,-1.,1.,300,0.,0.3);
1062
1063   
1064   nameMass="histoDCAtoPVvsinvmassK0s";
1065   TH2F *dcatoPVvspK0s=new TH2F(nameMass.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass ; M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1066   nameMass="histoDCAtoPVvsinvmassK0sOffline";
1067   TH2F *dcatoPVvspK0sOffline=new TH2F(nameMass.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass -offline -; M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1068
1069
1070
1071   TH2F* allspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone(); 
1072   TH2F* allspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone(); 
1073   TH2F* allspectrumLcMassByK0S    = (TH2F*)spectrumLcMassByK0S->Clone(); 
1074   TH2F* allspectrumLcMassOfflineByK0S    = (TH2F*)spectrumLcMassOfflineByK0S->Clone(); 
1075   TH2F* allcosOpeningAngleK0Spvsp= (TH2F*)cosOpeningAngleK0Spvsp->Clone(); 
1076   TH2F* allcosOpeningAngleK0SpvspOffline= (TH2F*)cosOpeningAngleK0SpvspOffline->Clone(); 
1077   TH2F* allmomentumDistributionK0Svsp= (TH2F*)momentumDistributionK0Svsp->Clone(); 
1078   TH2F* allmomentumDistributionK0SvspOffline= (TH2F*)momentumDistributionK0SvspOffline->Clone(); 
1079   TH2F* alldcatoPVvspK0s=(TH2F*)dcatoPVvspK0s->Clone(); 
1080   TH2F* alldcatoPVvspK0sOffline=(TH2F*)dcatoPVvspK0sOffline->Clone(); 
1081
1082   TH2F* pidBachspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone(); 
1083   TH2F* pidBachspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone(); 
1084   TH2F* pidBachspectrumLcMassByK0S    = (TH2F*)spectrumLcMassByK0S->Clone(); 
1085   TH2F* pidBachspectrumLcMassOfflineByK0S    = (TH2F*)spectrumLcMassOfflineByK0S->Clone(); 
1086   TH2F* pidBachcosOpeningAngleK0Spvsp= (TH2F*)cosOpeningAngleK0Spvsp->Clone(); 
1087   TH2F* pidBachcosOpeningAngleK0SpvspOffline= (TH2F*)cosOpeningAngleK0SpvspOffline->Clone(); 
1088   TH2F* pidBachmomentumDistributionK0Svsp= (TH2F*)momentumDistributionK0Svsp->Clone(); 
1089   TH2F* pidBachmomentumDistributionK0SvspOffline= (TH2F*)momentumDistributionK0SvspOffline->Clone(); 
1090   TH2F* pidBachdcatoPVvspK0s=(TH2F*)dcatoPVvspK0s->Clone(); 
1091   TH2F* pidBachdcatoPVvspK0sOffline=(TH2F*)dcatoPVvspK0sOffline->Clone(); 
1092
1093   TH2F* allArmenterosPodK0s = (TH2F*)armenterosPodK0s->Clone();
1094   TH2F* allArmenterosPodK0sOff = (TH2F*)armenterosPodK0sOff->Clone();
1095   TH2F* pidBachArmenterosPodK0s = (TH2F*)armenterosPodK0s->Clone();
1096   TH2F* pidBachArmenterosPodK0sOff = (TH2F*)armenterosPodK0sOff->Clone();
1097
1098
1099   fOutputAll->Add(allspectrumK0SMass);
1100   fOutputAll->Add(allspectrumK0SMassOffline);
1101   fOutputAll->Add(allspectrumLcMassByK0S);
1102   fOutputAll->Add(allspectrumLcMassOfflineByK0S);
1103   fOutputAll->Add(allcosOpeningAngleK0Spvsp); 
1104   fOutputAll->Add(allcosOpeningAngleK0SpvspOffline); 
1105   fOutputAll->Add(allmomentumDistributionK0Svsp); 
1106   fOutputAll->Add(allmomentumDistributionK0SvspOffline); 
1107   fOutputAll->Add(allArmenterosPodK0s);
1108   fOutputAll->Add(allArmenterosPodK0sOff);
1109   fOutputAll->Add(alldcatoPVvspK0s);
1110   fOutputAll->Add(alldcatoPVvspK0sOffline);
1111
1112   fOutputPIDBach->Add(pidBachspectrumK0SMass);
1113   fOutputPIDBach->Add(pidBachspectrumK0SMassOffline);
1114   fOutputPIDBach->Add(pidBachspectrumLcMassByK0S);
1115   fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0S);
1116   fOutputPIDBach->Add(pidBachcosOpeningAngleK0SpvspOffline); 
1117   fOutputPIDBach->Add(pidBachcosOpeningAngleK0Spvsp); 
1118   fOutputPIDBach->Add(pidBachmomentumDistributionK0Svsp); 
1119   fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOffline); 
1120   fOutputPIDBach->Add(pidBachArmenterosPodK0s);
1121   fOutputPIDBach->Add(pidBachArmenterosPodK0sOff);
1122   fOutputPIDBach->Add(pidBachdcatoPVvspK0s);
1123   fOutputPIDBach->Add(pidBachdcatoPVvspK0sOffline);
1124
1125
1126
1127   if (fUseMCInfo) {
1128
1129     nameSgn="histK0SMassSgn";
1130     nameBkg="histK0SMassBkg";
1131     TH2F* spectrumK0SMassSgn = new TH2F(nameSgn.Data(), "K^{0}_{S} Signal invariant mass VS p_{T} - MC; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries", 520,0.43,0.56,200,0.,20.);
1132     TH2F* spectrumK0SMassBkg = new TH2F(nameBkg.Data(), "K^{0}_{S} Background invariant mass VS p_{T} - MC; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries",  520,0.43,0.56,200,0.,20.);
1133     spectrumK0SMassSgn->Sumw2();
1134     spectrumK0SMassBkg->Sumw2();
1135     spectrumK0SMassSgn->SetLineColor(2);
1136     spectrumK0SMassBkg->SetLineColor(4);
1137     spectrumK0SMassSgn->SetMarkerStyle(20);
1138     spectrumK0SMassBkg->SetMarkerStyle(20);
1139     spectrumK0SMassSgn->SetMarkerSize(0.6);
1140     spectrumK0SMassBkg->SetMarkerSize(0.6);
1141     spectrumK0SMassSgn->SetMarkerColor(2);
1142     spectrumK0SMassBkg->SetMarkerColor(4);
1143
1144     TH2F* allspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone(); 
1145     TH2F* allspectrumK0SMassBkg = (TH2F*) spectrumK0SMassBkg->Clone();  
1146     TH2F* pidBachspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone(); 
1147     TH2F* pidBachspectrumK0SMassBkg = (TH2F*) spectrumK0SMassBkg->Clone();  
1148   
1149
1150     fOutputAll->Add(allspectrumK0SMassSgn);
1151     fOutputAll->Add(allspectrumK0SMassBkg);
1152     fOutputPIDBach->Add(pidBachspectrumK0SMassSgn);
1153     fOutputPIDBach->Add(pidBachspectrumK0SMassBkg);
1154
1155
1156     nameSgn="histK0SMassOfflineSgn";
1157     nameBkg="histK0SMassOfflineBkg";
1158     TH2F* spectrumK0SMassOfflineSgn = new TH2F(nameSgn.Data(), "K^{0}_{S} Signal invariant mass VS p_{T} - MC; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries",
1159                                                520,0.43,0.56,200,0.,20.);
1160     TH2F* spectrumK0SMassOfflineBkg = new TH2F(nameBkg.Data(), "K^{0}_{S} Background invariant mass VS p_{T} - MC; M(K^{0}_{S}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries",
1161                                                520,0.43,0.56,200,0.,20.);
1162     spectrumK0SMassOfflineSgn->Sumw2();
1163     spectrumK0SMassOfflineBkg->Sumw2();
1164     spectrumK0SMassOfflineSgn->SetLineColor(2);
1165     spectrumK0SMassOfflineBkg->SetLineColor(4);
1166     spectrumK0SMassOfflineSgn->SetMarkerStyle(20);
1167     spectrumK0SMassOfflineBkg->SetMarkerStyle(20);
1168     spectrumK0SMassOfflineSgn->SetMarkerSize(0.6);
1169     spectrumK0SMassOfflineBkg->SetMarkerSize(0.6);
1170     spectrumK0SMassOfflineSgn->SetMarkerColor(2);
1171     spectrumK0SMassOfflineBkg->SetMarkerColor(4);
1172
1173
1174
1175     TH2F* allspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone(); 
1176     TH2F* allspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();  
1177     TH2F* pidBachspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone(); 
1178     TH2F* pidBachspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();  
1179
1180     fOutputAll->Add(allspectrumK0SMassOfflineSgn);
1181     fOutputAll->Add(allspectrumK0SMassOfflineBkg);
1182     fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineSgn);
1183     fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineBkg);
1184
1185
1186     nameSgn="histLcMassByK0SSgn";
1187     nameBkg="histLcMassByK0SBkg";
1188     TH2F* spectrumLcMassByK0SSgn = new TH2F(nameSgn.Data(), "#Lambda_{C} Signal invariant mass (by K^{0}_{S}) vs p_{T}  - MC; M(#Lambda_{C}) [GeV/c^{2}];  p_{T}",
1189                                             1000,2.,2.5,200,0.,20.);
1190     TH2F* spectrumLcMassByK0SBkg = new TH2F(nameBkg.Data(), "#Lambda_{C} Background invariant mass (by K^{0}_{S}) vs p_{T}  - MC; M(#Lambda_{C}) [GeV/c^{2}]; p_{T}",
1191                                             1000,2.,2.5,200,0.,20.);
1192     spectrumLcMassByK0SSgn->Sumw2();
1193     spectrumLcMassByK0SBkg->Sumw2();
1194     spectrumLcMassByK0SSgn->SetLineColor(2);
1195     spectrumLcMassByK0SBkg->SetLineColor(4);
1196     spectrumLcMassByK0SSgn->SetMarkerStyle(20);
1197     spectrumLcMassByK0SBkg->SetMarkerStyle(20);
1198     spectrumLcMassByK0SSgn->SetMarkerSize(0.6);
1199     spectrumLcMassByK0SBkg->SetMarkerSize(0.6);
1200     spectrumLcMassByK0SSgn->SetMarkerColor(2);
1201     spectrumLcMassByK0SBkg->SetMarkerColor(4);
1202
1203
1204
1205     TH2F* allspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone(); 
1206     TH2F* allspectrumLcMassByK0SBkg = (TH2F*) spectrumLcMassByK0SBkg->Clone();  
1207     TH2F* pidBachspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone(); 
1208     TH2F* pidBachspectrumLcMassByK0SBkg = (TH2F*) spectrumLcMassByK0SBkg->Clone();  
1209     fOutputAll->Add(allspectrumLcMassByK0SSgn);
1210     fOutputAll->Add(allspectrumLcMassByK0SBkg);
1211     fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgn);
1212     fOutputPIDBach->Add(pidBachspectrumLcMassByK0SBkg);
1213
1214
1215     nameSgn="histLcMassOfflineByK0SSgn";
1216     nameBkg="histLcMassOfflineByK0SBkg";
1217     TH2F* spectrumLcMassOfflineByK0SSgn = new TH2F(nameSgn.Data(), "#Lambda_{C} Signal invariant mass (by K^{0}_{S})  vs p_{T} - MC; M(#Lambda_{C}) [GeV/c^{2}]; p_{T}",
1218                                                    1000,2.,2.5,200,0.,20.);
1219     TH2F* spectrumLcMassOfflineByK0SBkg = new TH2F(nameBkg.Data(), "#Lambda_{C} Background invariant mass (by K^{0}_{S})  vs p_{T} - MC; M(#Lambda_{C}) [GeV/c^{2}]; p_{T}",
1220                                                    1000,2.,2.5,200,0.,20.);
1221     spectrumLcMassOfflineByK0SSgn->Sumw2();
1222     spectrumLcMassOfflineByK0SBkg->Sumw2();
1223     spectrumLcMassOfflineByK0SSgn->SetLineColor(2);
1224     spectrumLcMassOfflineByK0SBkg->SetLineColor(4);
1225     spectrumLcMassOfflineByK0SSgn->SetMarkerStyle(20);
1226     spectrumLcMassOfflineByK0SBkg->SetMarkerStyle(20);
1227     spectrumLcMassOfflineByK0SSgn->SetMarkerSize(0.6);
1228     spectrumLcMassOfflineByK0SBkg->SetMarkerSize(0.6);
1229     spectrumLcMassOfflineByK0SSgn->SetMarkerColor(2);
1230     spectrumLcMassOfflineByK0SBkg->SetMarkerColor(4);
1231
1232
1233     TH2F* allspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone(); 
1234     TH2F* allspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();  
1235     TH2F* pidBachspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone(); 
1236     TH2F* pidBachspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();  
1237     fOutputAll->Add(allspectrumLcMassOfflineByK0SSgn);
1238     fOutputAll->Add(allspectrumLcMassOfflineByK0SBkg);
1239     fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SSgn);
1240     fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SBkg);
1241   
1242     nameSgn="histcosOAK0SpSgnvsp";
1243     nameBkg="histcosOAK0SpBkgvsp";
1244     TH2F* cosOpeningAngleK0SpSgnvsp= new TH2F(nameSgn.Data(),"#Lambda_{C}  Signal : K^{0}_{S} - p Opening Angle  vs p - MC ; Cos(Opening Angle);  p ",
1245                                               200,-1.,1.,200,0.,20.);
1246     TH2F* cosOpeningAngleK0SpBkgvsp= new TH2F(nameBkg.Data(),"#Lambda_{C}  Background : K^{0}_{S} - p Opening Angle  vs p - MC;  Cos(Opening Angle);  p ",
1247                                               200,-1.,1.,200,0.,20.);
1248
1249     TH2F* allcosOpeningAngleK0SpSgnvsp= (TH2F*)cosOpeningAngleK0SpSgnvsp->Clone(); 
1250     TH2F* allcosOpeningAngleK0SpBkgvsp= (TH2F*)cosOpeningAngleK0SpBkgvsp->Clone(); 
1251     TH2F* pidBachcosOpeningAngleK0SpSgnvsp= (TH2F*)cosOpeningAngleK0SpSgnvsp->Clone(); 
1252     TH2F* pidBachcosOpeningAngleK0SpBkgvsp= (TH2F*)cosOpeningAngleK0SpBkgvsp->Clone(); 
1253     fOutputAll->Add(allcosOpeningAngleK0SpSgnvsp); 
1254     fOutputAll->Add(allcosOpeningAngleK0SpBkgvsp); 
1255     fOutputPIDBach->Add(pidBachcosOpeningAngleK0SpSgnvsp); 
1256     fOutputPIDBach->Add(pidBachcosOpeningAngleK0SpBkgvsp); 
1257
1258  
1259
1260
1261     nameSgn="histcosOAK0SpSgnvspOffline";
1262     nameBkg="histcosOAK0SpBkgvspOffline";
1263     TH2F* cosOpeningAngleK0SpSgnvspOffline= new TH2F(nameSgn.Data(),"#Lambda_{C}  Signal : K^{0}_{S} - p Opening Angle  vs p  -  Offline  - MC ; Cos(Opening Angle);  p ",
1264                                                      200,-1.,1.,200,0.,20.);
1265     TH2F* cosOpeningAngleK0SpBkgvspOffline= new TH2F(nameBkg.Data(),"#Lambda_{C}  Background : K^{0}_{S} - p Opening Angle  vs p  -  Offline  - MC;  Cos(Opening Angle);  p ",
1266                                                      200,-1.,1.,200,0.,20.);
1267     
1268
1269     TH2F* allcosOpeningAngleK0SpSgnvspOffline= (TH2F*)cosOpeningAngleK0SpSgnvspOffline->Clone(); 
1270     TH2F* allcosOpeningAngleK0SpBkgvspOffline= (TH2F*)cosOpeningAngleK0SpBkgvspOffline->Clone(); 
1271     TH2F* pidBachcosOpeningAngleK0SpSgnvspOffline= (TH2F*)cosOpeningAngleK0SpSgnvspOffline->Clone(); 
1272     TH2F* pidBachcosOpeningAngleK0SpBkgvspOffline= (TH2F*)cosOpeningAngleK0SpBkgvspOffline->Clone(); 
1273     fOutputAll->Add(allcosOpeningAngleK0SpSgnvspOffline); 
1274     fOutputAll->Add(allcosOpeningAngleK0SpBkgvspOffline); 
1275     fOutputPIDBach->Add(pidBachcosOpeningAngleK0SpSgnvspOffline); 
1276     fOutputPIDBach->Add(pidBachcosOpeningAngleK0SpBkgvspOffline); 
1277
1278
1279
1280
1281     nameSgn="histpK0SvspSgn";
1282     nameBkg="histpK0SvspBkg";
1283     TH2F* momentumDistributionK0SvspSgn= new TH2F(nameSgn.Data(),"#Lambda_{C}  Signal : K^{0}_{S} vs p Total Momentum Distribution - MC; p_{p};  p_{K^{0}_{S}}   ",
1284                                                   200,0.,20.,200,0.,20.);
1285     TH2F* momentumDistributionK0SvspBkg= new TH2F(nameBkg.Data(),"#Lambda_{C}  Background : K^{0}_{S} vs p Total Momentum Distribution - MC;  p_{p}; p_{K^{0}_{S}}   ",
1286                                                   200,0.,20.,200,0.,20.);
1287
1288     TH2F* allmomentumDistributionK0SvspSgn= (TH2F*)momentumDistributionK0SvspSgn->Clone(); 
1289     TH2F* allmomentumDistributionK0SvspBkg= (TH2F*)momentumDistributionK0SvspBkg->Clone(); 
1290     TH2F* pidBachmomentumDistributionK0SvspSgn= (TH2F*)momentumDistributionK0SvspSgn->Clone(); 
1291     TH2F* pidBachmomentumDistributionK0SvspBkg= (TH2F*)momentumDistributionK0SvspBkg->Clone(); 
1292     fOutputAll->Add(allmomentumDistributionK0SvspSgn); 
1293     fOutputAll->Add(allmomentumDistributionK0SvspBkg); 
1294     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspSgn); 
1295     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspBkg); 
1296
1297
1298     nameSgn="histpK0SvspOfflineSgn";
1299     nameBkg="histpK0SvspOfflineBkg";
1300     TH2F* momentumDistributionK0SvspOfflineSgn= new TH2F(nameSgn.Data(),"#Lambda_{C}  Signal : K^{0}_{S} vs p Total Momentum Distribution - Offline  - MC; p_{p};  p_{K^{0}_{S}}   ",
1301                                                          200,0.,20.,200,0.,20.);
1302     TH2F* momentumDistributionK0SvspOfflineBkg= new TH2F(nameBkg.Data(),"#Lambda_{C}  Background : K^{0}_{S} vs p Total Momentum Distribution - Offline  - MC;  p_{p}; p_{K^{0}_{S}}   ",
1303                                                          200,0.,20.,200,0.,20.);
1304
1305
1306     TH2F* allmomentumDistributionK0SvspOfflineSgn= (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone(); 
1307     TH2F* allmomentumDistributionK0SvspOfflineBkg= (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone(); 
1308     TH2F* pidBachmomentumDistributionK0SvspOfflineSgn= (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone(); 
1309     TH2F* pidBachmomentumDistributionK0SvspOfflineBkg= (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone(); 
1310     fOutputAll->Add(allmomentumDistributionK0SvspOfflineSgn); 
1311     fOutputAll->Add(allmomentumDistributionK0SvspOfflineBkg); 
1312     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineSgn); 
1313     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineBkg); 
1314
1315
1316
1317
1318
1319     // armenteros-podolanski plots K0S
1320     nameSgn="histArmPodK0sSgn";
1321     nameBkg="histArmPodK0sBkg";
1322     TH2F* armenterosPodK0sSgn = new TH2F(nameSgn.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",
1323                                          200,-1.,1.,300,0.,0.3);
1324     TH2F* armenterosPodK0sBkg = new TH2F(nameBkg.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",
1325                                          200,-1.,1.,300,0.,0.3);
1326     
1327     // armenteros-podolanski plots K0S (offline)
1328     nameSgn="histOfflineArmPodK0sSgn";
1329     nameBkg="histOfflineArmPodK0sBkg";
1330     TH2F* armenterosPodK0sOffSgn = new TH2F(nameSgn.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",200,-1.,1.,300,0.,0.3);
1331     TH2F* armenterosPodK0sOffBkg = new TH2F(nameBkg.Data(),"K^{0}_{S}  Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]",200,-1.,1.,300,0.,0.3);
1332   
1333
1334     TH2F* allArmenterosPodK0sSgn = (TH2F*)armenterosPodK0sSgn->Clone();
1335     TH2F* allArmenterosPodK0sBkg = (TH2F*)armenterosPodK0sBkg->Clone();
1336     TH2F* allArmenterosPodK0sOffSgn = (TH2F*)armenterosPodK0sOffSgn->Clone();
1337     TH2F* allArmenterosPodK0sOffBkg = (TH2F*)armenterosPodK0sOffBkg->Clone();
1338
1339     TH2F* pidBachArmenterosPodK0sSgn = (TH2F*)armenterosPodK0sSgn->Clone();
1340     TH2F* pidBachArmenterosPodK0sBkg = (TH2F*)armenterosPodK0sBkg->Clone();
1341     TH2F* pidBachArmenterosPodK0sOffSgn = (TH2F*)armenterosPodK0sOffSgn->Clone();
1342     TH2F* pidBachArmenterosPodK0sOffBkg = (TH2F*)armenterosPodK0sOffBkg->Clone();
1343
1344     fOutputAll->Add(allArmenterosPodK0sSgn);
1345     fOutputAll->Add(allArmenterosPodK0sBkg);
1346     fOutputAll->Add(allArmenterosPodK0sOffSgn);
1347     fOutputAll->Add(allArmenterosPodK0sOffBkg);
1348
1349     fOutputPIDBach->Add(pidBachArmenterosPodK0sSgn);
1350     fOutputPIDBach->Add(pidBachArmenterosPodK0sBkg);
1351     fOutputPIDBach->Add(pidBachArmenterosPodK0sOffSgn);
1352     fOutputPIDBach->Add(pidBachArmenterosPodK0sOffBkg);
1353
1354
1355
1356     nameSgn="histoDCAtoPVvsinvmassK0sSgn";
1357     nameBkg="histoDCAtoPVvsinvmassK0sBkg";
1358     TH2F *dcatoPVvspK0sSgn=new TH2F(nameSgn.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass (sgn) ; M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1359     TH2F *dcatoPVvspK0sBkg=new TH2F(nameBkg.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass (bkg); M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1360     
1361     nameSgn="histoDCAtoPVvsinvmassK0sOfflineSgn";
1362     nameBkg="histoDCAtoPVvsinvmassK0sOfflineBkg";
1363     TH2F *dcatoPVvspK0sOfflineSgn=new TH2F(nameSgn.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass  -offline - (sgn) ; M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1364     TH2F *dcatoPVvspK0sOfflineBkg=new TH2F(nameBkg.Data(),"K^{0}_{S}: DCA to Primary Vertex vs  K^{0}_{S} invariant mass  -offline - (bkg); M(K^{0}_{S}) [GeV/c^{2}]; DCA to Primary Vertex []; Entries",520,0.43,0.56,100,0.,10.0);
1365     
1366
1367     TH2F* alldcatoPVvspK0sSgn= (TH2F*)dcatoPVvspK0sSgn->Clone();
1368     TH2F* pidBachdcatoPVvspK0sSgn= (TH2F*)dcatoPVvspK0sSgn->Clone();
1369     TH2F* alldcatoPVvspK0sBkg= (TH2F*)dcatoPVvspK0sBkg->Clone();
1370     TH2F* pidBachdcatoPVvspK0sBkg= (TH2F*)dcatoPVvspK0sBkg->Clone();
1371
1372     TH2F* alldcatoPVvspK0sOfflineSgn= (TH2F*)dcatoPVvspK0sOfflineSgn->Clone();
1373     TH2F* pidBachdcatoPVvspK0sOfflineSgn= (TH2F*)dcatoPVvspK0sOfflineSgn->Clone();
1374     TH2F* alldcatoPVvspK0sOfflineBkg= (TH2F*)dcatoPVvspK0sOfflineBkg->Clone();
1375     TH2F* pidBachdcatoPVvspK0sOfflineBkg= (TH2F*)dcatoPVvspK0sOfflineBkg->Clone();
1376
1377
1378
1379     fOutputAll->Add(alldcatoPVvspK0sSgn);
1380     fOutputPIDBach->Add(pidBachdcatoPVvspK0sSgn);
1381     fOutputAll->Add(alldcatoPVvspK0sBkg);
1382     fOutputPIDBach->Add(pidBachdcatoPVvspK0sBkg);
1383
1384     fOutputAll->Add(alldcatoPVvspK0sOfflineSgn);
1385     fOutputPIDBach->Add(pidBachdcatoPVvspK0sOfflineSgn);
1386     fOutputAll->Add(alldcatoPVvspK0sOfflineBkg);
1387     fOutputPIDBach->Add(pidBachdcatoPVvspK0sOfflineBkg);
1388
1389   }
1390
1391
1392   ///---------------- END  K0S HISTOS DECLARATIONS -------------------///
1393 }