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