Fix coverity defect 24647
[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 'E.Fermi' - Roma
32 //  (b) INFN and University of Salerno
33 //
34 //  Contatcs: decaro@sa.infn.it
35 //            paola.pagano@sa.infn.it
36 //-------------------------------------------------------------------------
37
38 #include <TSystem.h>
39 #include <TParticle.h>
40 #include <TParticlePDG.h>
41 #include <TH1F.h>
42 #include <TH2F.h>
43 #include <TH3F.h>
44 #include <THnSparse.h>
45 #include <TTree.h>
46 #include "TROOT.h"
47 #include <TDatabasePDG.h>
48 #include <AliAnalysisDataSlot.h>
49 #include <AliAnalysisDataContainer.h>
50 #include "AliStack.h"
51 #include "AliMCEvent.h"
52 #include "AliAnalysisManager.h"
53 #include "AliAODMCHeader.h"
54 #include "AliAODHandler.h"
55 #include "AliLog.h"
56 #include "AliExternalTrackParam.h"
57 #include "AliAODVertex.h"
58 #include "AliAODRecoDecay.h"
59 #include "AliAODRecoDecayHF.h"
60 #include "AliAODRecoCascadeHF.h"
61 #include "AliAnalysisVertexingHF.h"
62 #include "AliESDtrack.h"
63 #include "AliAODTrack.h"
64 #include "AliAODv0.h"
65 #include "AliAODMCParticle.h"
66 #include "AliAnalysisTaskSE.h"
67 #include "AliAnalysisTaskSELc2V0bachelor.h"
68 #include "AliNormalizationCounter.h"
69 #include "AliAODPidHF.h"
70 #include "AliInputEventHandler.h"
71 #include "AliESDtrackCuts.h"
72 #include "AliNeutralTrackParam.h"
73
74 using std::cout;
75 using std::endl;
76
77 ClassImp(AliAnalysisTaskSELc2V0bachelor)
78
79 //__________________________________________________________________________
80 AliAnalysisTaskSELc2V0bachelor::AliAnalysisTaskSELc2V0bachelor() : AliAnalysisTaskSE(),
81   fUseMCInfo(kFALSE),
82   fOutput(0),
83   fOutputAll(0),
84   fOutputPIDBach(0),
85   fCEvents(0),
86   fIsK0SAnalysis(kFALSE),
87   fCounter(0),
88   fAnalCuts(0),
89   fUseOnTheFlyV0(kFALSE),
90   fIsEventSelected(kFALSE),
91   fWriteVariableTree(kFALSE),
92   fVariablesTree(0),
93   fCandidateVariables(),
94   fVtx1(0),
95   fBzkG(0),
96   fAdditionalChecks(kFALSE),
97   fTrackRotation(kFALSE),
98   fOutputPIDBachTR(0),
99   fMinAngleForRot(5*TMath::Pi()/6),
100   fMaxAngleForRot(7*TMath::Pi()/6),
101   fMinMass(0),
102   fMaxMass(0),
103   fNRotations(9),
104   fPtMinToFillTheTree(0.),
105   fPtMaxToFillTheTree(999.)
106 {
107   //
108   // Default ctor
109   //
110
111   Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
112   fMinMass=mLcPDG-0.250;
113   fMaxMass=mLcPDG+0.250;
114
115 }
116 //___________________________________________________________________________
117 AliAnalysisTaskSELc2V0bachelor::AliAnalysisTaskSELc2V0bachelor(const Char_t* name,
118                                                                AliRDHFCutsLctoV0* analCuts, Bool_t useOnTheFly,
119                                                                Bool_t writeVariableTree, Bool_t additionalChecks, Bool_t trackRotation) :
120   AliAnalysisTaskSE(name),
121   fUseMCInfo(kFALSE),
122   fOutput(0),
123   fOutputAll(0),
124   fOutputPIDBach(0),
125   fCEvents(0),
126   fIsK0SAnalysis(kFALSE),
127   fCounter(0),
128   fAnalCuts(analCuts),
129   fUseOnTheFlyV0(useOnTheFly),
130   fIsEventSelected(kFALSE),
131   fWriteVariableTree(writeVariableTree),
132   fVariablesTree(0),
133   fCandidateVariables(),
134   fVtx1(0),
135   fBzkG(0),
136   fAdditionalChecks(additionalChecks),
137   fTrackRotation(trackRotation),
138   fOutputPIDBachTR(0),
139   fMinAngleForRot(5*TMath::Pi()/6),
140   fMaxAngleForRot(7*TMath::Pi()/6),
141   fMinMass(0),
142   fMaxMass(0),
143   fNRotations(9),
144   fPtMinToFillTheTree(0.),
145   fPtMaxToFillTheTree(999.)
146 {
147   //
148   // Constructor. Initialization of Inputs and Outputs
149   //
150   Info("AliAnalysisTaskSELc2V0bachelor","Calling Constructor");
151
152   if (fWriteVariableTree && fTrackRotation) {
153     AliInfo(Form("You cannot initialize fWriteVariableTree=%d and fTrackRotation=%d => fTrackRotation=0",fWriteVariableTree,fTrackRotation));
154     fTrackRotation=kFALSE;
155   }
156
157   Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
158   fMinMass=mLcPDG-0.250;
159   fMaxMass=mLcPDG+0.250;
160
161   DefineOutput(1,TList::Class());  //conters
162   DefineOutput(2,AliNormalizationCounter::Class());
163   DefineOutput(3,AliRDHFCutsLctoV0::Class());
164   if (!writeVariableTree) {
165     DefineOutput(4,TList::Class());  //All Entries output
166     DefineOutput(5,TList::Class());  //3sigma PID output
167     if (trackRotation) {
168       DefineOutput(6,TList::Class());  //All Entries output
169     }
170   } else {
171     // Output slot #4 keeps a tree of the candidate variables after track selection
172     DefineOutput(4,TTree::Class());  //My private output
173   }
174
175 }
176
177 //___________________________________________________________________________
178 AliAnalysisTaskSELc2V0bachelor::~AliAnalysisTaskSELc2V0bachelor() {
179   //
180   // destructor
181   //
182   Info("~AliAnalysisTaskSELc2V0bachelor","Calling Destructor");
183   
184   if (fOutput) {
185     delete fOutput;
186     fOutput = 0;
187   }
188
189   if (fOutputAll) {
190     delete fOutputAll;
191     fOutputAll = 0;
192   }
193
194   if (fOutputPIDBach) {
195     delete fOutputPIDBach;
196     fOutputPIDBach = 0;
197   }
198
199   if (fCounter) {
200     delete fCounter;
201     fCounter = 0;
202   }
203
204   if (fAnalCuts) {
205     delete fAnalCuts;
206     fAnalCuts = 0;
207   }
208
209   if (fVariablesTree) {
210     delete fVariablesTree;
211     fVariablesTree = 0;
212   }
213
214   if (fOutputPIDBachTR) {
215     delete fOutputPIDBachTR;
216     fOutputPIDBachTR = 0;
217   }
218
219 }
220 //_________________________________________________
221 void AliAnalysisTaskSELc2V0bachelor::Init() {
222   //
223   // Initialization
224   //
225
226   fIsEventSelected=kFALSE;
227
228   if (fDebug > 1) AliInfo("Init");
229
230   PostData(3,fAnalCuts);
231
232   return;
233 }
234
235 //_________________________________________________
236 void AliAnalysisTaskSELc2V0bachelor::UserExec(Option_t *)
237 {
238   // user exec
239   if (!fInputEvent) {
240     AliError("NO EVENT FOUND!");
241     return;
242   }
243
244   AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
245   TClonesArray *arrayLctopKos=0;
246
247   if (!aodEvent && AODEvent() && IsStandardAOD()) {
248     // In case there is an AOD handler writing a standard AOD, use the AOD 
249     // event in memory rather than the input (ESD) event.    
250     aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
251     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
252     // have to taken from the AOD event hold by the AliAODExtension
253     AliAODHandler* aodHandler = (AliAODHandler*) 
254       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
255
256     if (aodHandler->GetExtensions()) {
257       AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
258       AliAODEvent *aodFromExt = ext->GetAOD();
259       arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
260     }
261   } else {
262     arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
263   }
264
265   fCEvents->Fill(1);
266
267   if (fUseMCInfo)
268     fAnalCuts->SetTriggerClass("");
269
270   // AOD primary vertex
271   fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
272   if (!fVtx1) return;
273
274   fIsEventSelected = fAnalCuts->IsEventSelected(aodEvent); // better to initialize before CheckEventSelection call
275
276   CheckEventSelection(aodEvent);
277
278
279   // fix for temporary bug in ESDfilter 
280   fBzkG = (Double_t)aodEvent->GetMagneticField(); 
281   if (TMath::Abs(fBzkG)<0.001) return;
282   fCEvents->Fill(2);
283
284   if (!arrayLctopKos) {
285     AliInfo("Could not find array of HF cascades, skipping the event");
286     return;
287   } else {
288     if (arrayLctopKos->GetEntriesFast()) {
289       AliInfo(Form("Found %d cascades",arrayLctopKos->GetEntriesFast()));
290     }
291   }
292   fCEvents->Fill(3);
293
294   // mc analysis 
295   TClonesArray *mcArray = 0;
296   AliAODMCHeader *mcHeader=0;
297
298   if (fUseMCInfo) {
299     // MC array need for maching
300     mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
301     if (!mcArray) {
302       AliError("Could not find Monte-Carlo in AOD");
303       return;
304     }
305     fCEvents->Fill(4); // in case of MC events
306
307     // load MC header
308     mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
309     if (!mcHeader) {
310       AliError("AliAnalysisTaskSELc2V0bachelor::UserExec: MC header branch not found!\n");
311       return;
312     }
313     fCEvents->Fill(5); // in case of MC events
314
315     Double_t zMCVertex = mcHeader->GetVtxZ();
316     if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
317       AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
318       return;
319     } else {
320       fCEvents->Fill(17); // in case of MC events
321     }
322   }
323
324   fCounter->StoreEvent(aodEvent,fAnalCuts,fUseMCInfo); // it is very important that it stays BEFORE any other event selection
325
326   if (fVtx1->GetNContributors()>0) // this check is done in IsEventSelected
327     fCEvents->Fill(6);
328
329   if ( !fIsEventSelected ) return; // don't take into account not selected events 
330   fCEvents->Fill(7);
331
332   Int_t nSelectedAnal = 0;
333   if (fIsK0SAnalysis) {
334     MakeAnalysisForLc2prK0S(arrayLctopKos,mcArray, nSelectedAnal, fAnalCuts);
335
336     if (nSelectedAnal)
337       CheckEventSelectionWithCandidates(aodEvent);
338
339   }
340
341   fCounter->StoreCandidates(aodEvent,nSelectedAnal,kTRUE);
342   fCounter->StoreCandidates(aodEvent,nSelectedAnal,kFALSE);
343
344   PostData(1,fOutput);
345   PostData(2,fCounter);
346   if (!fWriteVariableTree) {
347     PostData(4,fOutputAll);
348     PostData(5,fOutputPIDBach);
349     if (fTrackRotation)
350       PostData(6,fOutputPIDBachTR);
351   } else {
352     PostData(4,fVariablesTree);
353   }
354
355   fIsEventSelected=kFALSE;
356
357   return;
358 }
359
360 //________________________________________ terminate ___________________________
361 void AliAnalysisTaskSELc2V0bachelor::Terminate(Option_t*)
362 {    
363   // The Terminate() function is the last function to be called during
364   // a query. It always runs on the client, it can be used to present
365   // the results graphically or save the results to file.
366   
367   //AliInfo("Terminate","");
368   AliAnalysisTaskSE::Terminate();
369   
370   fOutput = dynamic_cast<TList*> (GetOutputData(1));
371   if (!fOutput) {     
372     AliError("fOutput not available");
373     return;
374   }
375   
376   //fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
377   if (!fWriteVariableTree) {
378     fOutputAll = dynamic_cast<TList*> (GetOutputData(4));
379     if (!fOutputAll) {
380       AliError("fOutputAll not available");
381       return;
382     }
383
384     fOutputPIDBach = dynamic_cast<TList*> (GetOutputData(5));
385     if (!fOutputPIDBach) {
386       AliError("fOutputPIDBach not available");
387       return;
388     }
389
390     if (fTrackRotation) {
391       fOutputPIDBachTR = dynamic_cast<TList*> (GetOutputData(6));
392       if (!fOutputPIDBachTR) {
393         AliError("fOutputPIDBachTR not available");
394         return;
395       }
396     }
397
398   } else {
399     fVariablesTree = dynamic_cast<TTree*> (GetOutputData(4));
400     if (!fVariablesTree) {
401       AliError("fVariablesTree not available");
402       return;
403     }
404   }
405
406   return;
407 }
408 //___________________________________________________________________________
409 void AliAnalysisTaskSELc2V0bachelor::UserCreateOutputObjects() { 
410   // output
411   AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
412
413   fOutput = new TList();
414   fOutput->SetOwner();
415   fOutput->SetName("chist0");
416   DefineGeneralHistograms(); // define general histograms
417   PostData(1,fOutput);
418
419   fCounter = new AliNormalizationCounter("NormalizationCounter");
420   fCounter->Init();
421   PostData(2,fCounter);
422
423   if (!fWriteVariableTree) {
424
425     fOutputAll = new TList();
426     fOutputAll->SetOwner();
427     fOutputAll->SetName("listAll");
428
429     fOutputPIDBach = new TList();
430     fOutputPIDBach->SetOwner();
431     fOutputPIDBach->SetName("listPIDBach");
432
433     if (fTrackRotation) {
434       fOutputPIDBachTR = new TList();
435       fOutputPIDBachTR->SetOwner();
436       fOutputPIDBachTR->SetName("listPIDBachTR");
437     }
438
439     DefineAnalysisHistograms(); // define analysis histograms
440   
441     PostData(4,fOutputAll);
442     PostData(5,fOutputPIDBach);
443
444     if (fTrackRotation)
445       PostData(6,fOutputPIDBachTR);
446
447   }
448   else {
449     DefineTreeVariables();
450     PostData(4,fVariablesTree);
451   }
452
453   return;
454 }
455
456 //-------------------------------------------------------------------------------
457 void AliAnalysisTaskSELc2V0bachelor::MakeAnalysisForLc2prK0S(TClonesArray *arrayLctopKos,
458                                                              TClonesArray *mcArray,
459                                                              Int_t &nSelectedAnal,
460                                                              AliRDHFCutsLctoV0 *cutsAnal)
461 {
462
463   // make the analysis
464
465   Int_t pdgCand = 4122;
466   Int_t pdgDgLctoV0bachelor[2]={2212,310}; // always 1st bachelor, 2nd V0
467   Int_t pdgDgV0toDaughters[2]={211,211};
468
469   // loop over cascades to search for candidates Lc->p+K0S
470   Int_t nCascades= arrayLctopKos->GetEntriesFast();
471   if (nCascades==0) {
472     AliInfo("Could not find cascades, skipping the event");
473     return;
474   }
475
476   for (Int_t iLctopK0S = 0; iLctopK0S<nCascades; iLctopK0S++) {
477
478     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(0);
479
480     // Lc candidates and K0S from Lc
481     AliAODRecoCascadeHF* lcK0Spr = dynamic_cast<AliAODRecoCascadeHF*>(arrayLctopKos->At(iLctopK0S));
482     if (!lcK0Spr) {
483       AliDebug(2,Form("Cascade %d doens't exist, skipping",iLctopK0S));
484       continue;
485     }
486
487     Bool_t unsetvtx=kFALSE;
488     if (!lcK0Spr->GetOwnPrimaryVtx()) {
489       lcK0Spr->SetOwnPrimaryVtx(fVtx1);
490       unsetvtx=kTRUE;
491     }
492
493     if (!lcK0Spr->GetSecondaryVtx()) {
494       AliInfo("No secondary vertex"); // it will be done in AliRDHFCutsLctoV0::IsSelected
495       continue;
496     }
497
498     if (lcK0Spr->GetNDaughters()!=2) {
499       AliDebug(2,Form("Cascade %d has not 2 daughters (nDaughters=%d)",iLctopK0S,lcK0Spr->GetNDaughters())); // it will be done in AliRDHFCutsLctoV0::IsSelected
500       continue;
501     }
502
503     AliAODv0 * v0part = dynamic_cast<AliAODv0*>(lcK0Spr->Getv0());
504     AliAODTrack * bachPart = dynamic_cast<AliAODTrack*>(lcK0Spr->GetBachelor());
505     if (!v0part || !bachPart) {
506       AliDebug(2,Form("Cascade %d has no V0 or no bachelor object",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
507       continue;
508     }
509
510     if (!v0part->GetSecondaryVtx()) {
511       AliDebug(2,Form("No secondary vertex for V0 by cascade %d",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
512       continue;
513     }
514
515     if (v0part->GetNDaughters()!=2) {
516       AliDebug(2,Form("current V0 has not 2 daughters (onTheFly=%d, nDaughters=%d)",v0part->GetOnFlyStatus(),v0part->GetNDaughters())); // it will be done in AliRDHFCutsLctoV0::IsSelected
517       continue;
518     }
519
520     AliAODTrack * v0Pos = dynamic_cast<AliAODTrack*>(lcK0Spr->Getv0PositiveTrack());
521     AliAODTrack * v0Neg = dynamic_cast<AliAODTrack*>(lcK0Spr->Getv0NegativeTrack());
522     if (!v0Neg || !v0Pos) {
523       AliDebug(2,Form("V0 by cascade %d has no V0positive of V0negative object",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
524       continue;
525     }
526
527     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(1);
528
529     if (v0Pos->Charge() == v0Neg->Charge()) continue;
530
531     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(2);
532
533     Int_t isLc = 0;
534
535     if (fUseMCInfo) {
536
537       Int_t pdgCode=-2;
538
539       // find associated MC particle for Lc -> p+K0 and K0S->pi+pi
540       Int_t mcLabel = lcK0Spr->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE);
541       if (mcLabel!=-1) {
542         AliDebug(2,Form(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cascade number %d (total cascade number = %d)", iLctopK0S,nCascades));
543
544         AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
545         if (partLc) {
546           pdgCode = partLc->GetPdgCode();
547           if (pdgCode<0) AliDebug(2,Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", mcLabel, pdgCode));
548           pdgCode = TMath::Abs(pdgCode);
549           isLc = 1;
550         }
551       } else {
552         AliDebug(2,Form("No MC candidate (cascade number %d -total cascade number = %d -)", iLctopK0S,nCascades));
553         pdgCode=-1;
554       }
555     }
556
557     FillLc2pK0Sspectrum(lcK0Spr, isLc,
558                         nSelectedAnal, cutsAnal,
559                         mcArray);
560
561     if (unsetvtx) lcK0Spr->UnsetOwnPrimaryVtx();
562
563   }
564
565   AliDebug(2, Form("Found %d Reco particles that are Lc!!", nSelectedAnal));
566
567   return;
568 }
569
570 //________________________________________________________________________
571 void AliAnalysisTaskSELc2V0bachelor::FillLc2pK0Sspectrum(AliAODRecoCascadeHF *part,
572                                                          Int_t isLc,
573                                                          Int_t &nSelectedAnal,
574                                                          AliRDHFCutsLctoV0 *cutsAnal,
575                                                          TClonesArray *mcArray)
576 {
577   //
578   // Fill histos for Lc -> K0S+proton
579   //
580
581   TString fillthis="";
582
583   AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
584   Double_t momBach  = bachelor->P();
585
586   AliAODv0 * v0part = (AliAODv0*)part->Getv0();
587   Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
588
589   Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
590   cutsAnal->SetUsePID(kFALSE);
591   Bool_t isInCascadeWindow = (((cutsAnal->IsSelectedSingleCut(part,AliRDHFCuts::kCandidate,0))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // cut on Lc->p+K0S invMass
592   cutsAnal->SetUsePID(areCutsUsingPID);
593
594   if ( onFlyV0 && !fUseOnTheFlyV0 ) return;
595
596   if (fAdditionalChecks) CheckCandidatesAtDifferentLevels(part,cutsAnal);
597
598   // track rotation
599   if (fTrackRotation) {
600     if (onFlyV0) {
601       TrackRotation(cutsAnal,part,"");
602     }
603     else {
604       TrackRotation(cutsAnal,part,"Offline");
605     }
606     if (fUseMCInfo) {
607       if (isLc==1) {
608         if (onFlyV0) {
609           TrackRotation(cutsAnal,part,"Sgn");
610         }     
611         else {  
612           TrackRotation(cutsAnal,part,"OfflineSgn");
613         }
614       }// sgn
615       else { // bkg
616         if (onFlyV0) {
617           TrackRotation(cutsAnal,part,"Bkg");
618         }
619         else {
620           TrackRotation(cutsAnal,part,"OfflineBkg");
621         }
622       }
623     } // if fUseMCInfo
624   } // if fTrackRotation
625  
626
627
628
629   if ( !(cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122))) ) return;
630
631   if ( !( ( (cutsAnal->IsSelected(part,AliRDHFCuts::kTracks))&(AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr) ) ) return;
632
633   if ( ( ( (cutsAnal->IsSelected(part,AliRDHFCuts::kAll))&(AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr) ) ) nSelectedAnal++;
634
635   // Fill candidate variable Tree (track selection, V0 invMass selection)
636   if ( fWriteVariableTree ) {
637     Double_t invmassK0S = v0part->MassK0Short();
638     Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
639     if ( !onFlyV0 && isInCascadeWindow &&
640          part->CosV0PointingAngle()>0.99 && TMath::Abs(invmassK0S-mk0sPDG)<=0.05 &&
641          part->Pt()>=fPtMinToFillTheTree && part->Pt()<fPtMaxToFillTheTree)
642       FillTheTree(part,cutsAnal,mcArray,isLc);
643     return;
644   }
645
646   cutsAnal->SetUsePID(kFALSE);
647   Bool_t isCandidateSelectedCuts = (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // kinematic/topological cuts
648   cutsAnal->SetUsePID(areCutsUsingPID);
649   Bool_t isBachelorID = (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // ID x bachelor
650
651   //if (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
652   if (((cutsAnal->IsSelected(part,AliRDHFCuts::kAll))&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
653     if (fUseMCInfo && isLc && !fWriteVariableTree) {
654       Int_t pdgCand1 = 4122;
655       Int_t pdgDgLctoV0bachelor1[2]={2212,310};
656       Int_t pdgDgV0toDaughters1[2]={211,211};
657       Int_t mcLabel1=part->MatchToMC(pdgCand1,pdgDgLctoV0bachelor1[1],pdgDgLctoV0bachelor1,pdgDgV0toDaughters1,mcArray,kTRUE);
658       AliDebug(2,Form(" Found true MC candidate: Lc->pK0S(%d) - onTheFly=%1d",mcLabel1,onFlyV0));
659     }
660   }
661
662   Double_t nSigmaTPCpr=-999.;
663   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
664   Double_t nSigmaTOFpr=-999.;
665   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
666
667   Double_t nSigmaTPCpi=-999.;
668   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
669   Double_t nSigmaTOFpi=-999.;
670   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
671
672   Double_t nSigmaTPCka=-999.;
673   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
674   Double_t nSigmaTOFka=-999.;
675   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
676
677   if (onFlyV0) {  
678
679     fillthis="histArmPodK0S";
680     FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
681
682     fillthis="histArmPodLc";
683     FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
684
685     //if (isCandidateSelectedCuts) {
686     FillAnalysisHistograms(part,cutsAnal,"");
687     //}
688   }
689   else {
690
691     fillthis="histArmPodK0SOffline";
692     FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
693
694     fillthis="histArmPodLcOffline";
695     FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
696
697     FillAnalysisHistograms(part,cutsAnal,"Offline");
698     if (isCandidateSelectedCuts) {
699       fillthis="histoprotonBachSigmaVspTOF";
700       ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
701       fillthis="histoprotonBachSigmaVspTPC";
702       ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
703       //FillAnalysisHistograms(part,cutsAnal,"Offline");
704     }
705   }
706   if (fUseMCInfo) {
707     if (isLc==1) {
708       if (onFlyV0) {
709
710         fillthis="histArmPodK0SSgn";
711         FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
712
713         fillthis="histArmPodLcSgn";
714         FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
715
716         //if (isCandidateSelectedCuts) {
717         FillAnalysisHistograms(part,cutsAnal,"Sgn");
718         //}
719       }     
720       else {
721
722         fillthis="histArmPodK0SOfflineSgn";
723         FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
724
725         fillthis="histArmPodLcOfflineSgn";
726         FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
727
728         FillAnalysisHistograms(part,cutsAnal,"OfflineSgn");
729         if (isCandidateSelectedCuts) {
730           fillthis="histoprotonBachSigmaVspTOFsgn";
731           ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
732           fillthis="histoprotonBachSigmaVspTPCsgn";
733           ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
734           //FillAnalysisHistograms(part,cutsAnal,"OfflineSgn");
735         }
736       }
737     }// sgn
738     else { // bkg
739       if (onFlyV0) {
740
741         fillthis="histArmPodK0SBkg";
742         FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
743
744         fillthis="histArmPodLcBkg";
745         FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
746
747         //if (isCandidateSelectedCuts) {
748         FillAnalysisHistograms(part,cutsAnal,"Bkg");
749         //}
750       }
751       else {
752
753         fillthis="histArmPodK0SOfflineBkg";
754         FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
755
756         fillthis="histArmPodLcOfflineBkg";
757         FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
758
759         FillAnalysisHistograms(part,cutsAnal,"OfflineBkg");
760         if (isCandidateSelectedCuts) {
761           fillthis="histoprotonBachSigmaVspTOFbkg";
762           ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
763           fillthis="histoprotonBachSigmaVspTPCbkg";
764           ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
765           //FillAnalysisHistograms(part,cutsAnal,"OfflineBkg");
766         }
767       }
768     }
769   } // if fUseMCInfo
770
771   return;
772 }
773
774 //----------------------------------------------------
775 void AliAnalysisTaskSELc2V0bachelor::DefineK0SHistos()
776
777
778   Double_t mLcPDG  = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
779   Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
780   Double_t mMinLambdaPDG  = TDatabasePDG::Instance()->GetParticle(2212)->Mass()+
781     TDatabasePDG::Instance()->GetParticle(211)->Mass();
782
783   TString nameHisto=" ", nameHistoSgn=" ", nameHistoBkg=" ";
784   TString titleHisto=" ", titleHistoSgn=" ", titleHistoBkg=" ";
785
786   // pt(Lc)
787   Double_t *binLimpTLc=new Double_t[11+1]; // 11 pT(Lc) bins
788   binLimpTLc[ 0]= 0.;
789   binLimpTLc[ 1]= 1.;
790   binLimpTLc[ 2]= 2.;
791   binLimpTLc[ 3]= 3.;
792   binLimpTLc[ 4]= 4.;
793   binLimpTLc[ 5]= 5.;
794   binLimpTLc[ 6]= 6.;
795   binLimpTLc[ 7]= 8.;
796   binLimpTLc[ 8]=12.;
797   binLimpTLc[ 9]=17.;
798   binLimpTLc[10]=25.;
799   binLimpTLc[11]=35.;
800
801   // pt(prong)
802   Double_t *binLimpTprong=new Double_t[41+1]; // 41 pT(prong) bins
803   binLimpTprong[ 0]= 0.0;
804   binLimpTprong[ 1]= 0.1;
805   binLimpTprong[ 2]= 0.2;
806   binLimpTprong[ 3]= 0.3;
807   binLimpTprong[ 4]= 0.4;
808   binLimpTprong[ 5]= 0.5;
809   binLimpTprong[ 6]= 0.6;
810   binLimpTprong[ 7]= 0.7;
811   binLimpTprong[ 8]= 0.8;
812   binLimpTprong[ 9]= 0.9;
813   binLimpTprong[10]= 1.0;
814   binLimpTprong[11]= 1.2;
815   binLimpTprong[12]= 1.4;
816   binLimpTprong[13]= 1.6;
817   binLimpTprong[14]= 1.8;
818   binLimpTprong[15]= 2.0;
819   binLimpTprong[16]= 2.2;
820   binLimpTprong[17]= 2.4;
821   binLimpTprong[18]= 2.6;
822   binLimpTprong[19]= 2.8;
823   binLimpTprong[20]= 3.0;
824   binLimpTprong[21]= 3.5;
825   binLimpTprong[22]= 4.0;
826   binLimpTprong[23]= 4.5;
827   binLimpTprong[24]= 5.0;
828   binLimpTprong[25]= 5.5;
829   binLimpTprong[26]= 6.0;
830   binLimpTprong[27]= 6.5;
831   binLimpTprong[28]= 7.0;
832   binLimpTprong[29]= 7.5;
833   binLimpTprong[30]= 8.0;
834   binLimpTprong[31]= 9.0;
835   binLimpTprong[32]=10.0;
836   binLimpTprong[33]=11.0;
837   binLimpTprong[34]=12.0;
838   binLimpTprong[35]=13.0;
839   binLimpTprong[36]=14.0;
840   binLimpTprong[37]=15.0;
841   binLimpTprong[38]=20.0;
842   binLimpTprong[39]=25.0;
843   binLimpTprong[40]=30.0;
844   binLimpTprong[41]=35.0;
845
846   if (fUseOnTheFlyV0) {
847
848     // V0 invariant masses (on-the-fly)
849     nameHisto="histK0SMass";
850     titleHisto="K^{0}_{S} invariant mass VS p_{T}; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
851     TH2F* spectrumK0SMass = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
852
853     // Lc invariant masses (x K0S on-the-fly)
854     nameHisto="histLcMassByK0S";
855     titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T}; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
856     TH2F* spectrumLcMassByK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
857
858     nameHisto="histpK0Svsp";
859     titleHisto="p(K^{0}_{S}) vs p(p); p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
860     TH2F* momentumDistributionK0Svsp = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,41,binLimpTprong);
861
862     nameHisto="histArmPodK0S";
863     titleHisto="K^{0}_{S} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
864     TH2F* armenterosPodK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
865  
866     nameHisto="histArmPodLc";
867     titleHisto="#Lambda_{c} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
868     TH2F* armenterosPodLc = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
869  
870     TH2F* allspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone(); 
871     TH2F* allspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone(); 
872     TH2F* allmomentumDistributionK0Svsp = (TH2F*)momentumDistributionK0Svsp->Clone();
873     TH2F* allArmenterosPodK0S = (TH2F*)armenterosPodK0S->Clone();
874     TH2F* allArmenterosPodLc = (TH2F*)armenterosPodLc->Clone();
875
876     TH2F* pidBachspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone(); 
877     TH2F* pidBachspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone(); 
878     TH2F* pidBachmomentumDistributionK0Svsp = (TH2F*)momentumDistributionK0Svsp->Clone();
879     TH2F* pidBachArmenterosPodK0S = (TH2F*)armenterosPodK0S->Clone();
880     TH2F* pidBachArmenterosPodLc = (TH2F*)armenterosPodLc->Clone();
881
882     fOutputAll->Add(allspectrumK0SMass);
883     fOutputAll->Add(allspectrumLcMassByK0S);
884     fOutputAll->Add(allmomentumDistributionK0Svsp); 
885     fOutputAll->Add(allArmenterosPodK0S);
886     fOutputAll->Add(allArmenterosPodLc);
887
888     fOutputPIDBach->Add(pidBachspectrumK0SMass);
889     fOutputPIDBach->Add(pidBachspectrumLcMassByK0S);
890     fOutputPIDBach->Add(pidBachmomentumDistributionK0Svsp); 
891     fOutputPIDBach->Add(pidBachArmenterosPodK0S);
892     fOutputPIDBach->Add(pidBachArmenterosPodLc);
893  
894     nameHisto="histArmPodK0S0";
895     titleHisto="K^{0}_{S} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
896     TH2F* armenterosPodK0S0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
897     nameHisto="histArmPodLc0";
898     titleHisto="#Lambda_{c} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
899     TH2F* armenterosPodLc0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
900     fOutputAll->Add(armenterosPodK0S0);
901     fOutputAll->Add(armenterosPodLc0);
902  
903
904     if (fTrackRotation) {
905       TH2F* pidBachTRspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone(); 
906       fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0S);
907     }
908
909
910
911     nameHisto="histptK0S";
912     titleHisto="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
913     TH2F* ptK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
914
915     nameHisto="histptP";
916     titleHisto="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
917     TH2F* ptP = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
918
919     nameHisto="histptPip";
920     titleHisto="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
921     TH2F* ptPiP = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
922
923     nameHisto="histptPim";
924     titleHisto="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
925     TH2F* ptPiM = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
926
927     nameHisto="histLambdaMass";
928     titleHisto="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
929     TH2F* massLambda = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
930
931     nameHisto="histLambdaBarMass";
932     titleHisto="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
933     TH2F* massLambdaBar = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
934
935     nameHisto="histGammaMass";
936     titleHisto="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
937     TH2F* massGamma = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,100,0.,1.);
938
939     nameHisto="histD0K0S";
940     titleHisto="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
941     TH2F* d0K0S = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
942
943     nameHisto="histD0P";
944     titleHisto="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
945     TH2F* d0P = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
946
947     nameHisto="histCosPAK0S";
948     titleHisto="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
949     TH2F *cosPAK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,0.99,1.);
950
951     TH2F* allptK0S = (TH2F*)ptK0S->Clone();
952     TH2F* allptP = (TH2F*)ptP->Clone();
953     TH2F* allptPiP = (TH2F*)ptPiP->Clone();
954     TH2F* allptPiM = (TH2F*)ptPiM->Clone();
955     TH2F* allmassLambda = (TH2F*)massLambda->Clone();
956     TH2F* allmassLambdaBar = (TH2F*)massLambdaBar->Clone();
957     TH2F* allmassGamma = (TH2F*)massGamma->Clone();
958     TH2F* alld0K0S = (TH2F*)d0K0S->Clone();
959     TH2F* alld0P = (TH2F*)d0P->Clone();
960     TH2F* allcosPAK0S = (TH2F*)cosPAK0S->Clone();
961
962     TH2F* pidptK0S = (TH2F*)ptK0S->Clone();
963     TH2F* pidptP = (TH2F*)ptP->Clone();
964     TH2F* pidptPiP = (TH2F*)ptPiP->Clone();
965     TH2F* pidptPiM = (TH2F*)ptPiM->Clone();
966     TH2F* pidmassLambda = (TH2F*)massLambda->Clone();
967     TH2F* pidmassLambdaBar = (TH2F*)massLambdaBar->Clone();
968     TH2F* pidmassGamma = (TH2F*)massGamma->Clone();
969     TH2F* pidd0K0S = (TH2F*)d0K0S->Clone();
970     TH2F* pidd0P = (TH2F*)d0P->Clone();
971     TH2F* pidcosPAK0S = (TH2F*)cosPAK0S->Clone();
972
973     fOutputAll->Add(allptK0S);
974     fOutputAll->Add(allptP);
975     fOutputAll->Add(allptPiP);
976     fOutputAll->Add(allptPiM);
977     fOutputAll->Add(allmassLambda);
978     fOutputAll->Add(allmassLambdaBar);
979     fOutputAll->Add(allmassGamma);
980     fOutputAll->Add(alld0K0S);
981     fOutputAll->Add(alld0P);
982     fOutputAll->Add(allcosPAK0S);
983
984     fOutputPIDBach->Add(pidptK0S);
985     fOutputPIDBach->Add(pidptP);
986     fOutputPIDBach->Add(pidptPiP);
987     fOutputPIDBach->Add(pidptPiM);
988     fOutputPIDBach->Add(pidmassLambda);
989     fOutputPIDBach->Add(pidmassLambdaBar);
990     fOutputPIDBach->Add(pidmassGamma);
991     fOutputPIDBach->Add(pidd0K0S);
992     fOutputPIDBach->Add(pidd0P);
993     fOutputPIDBach->Add(pidcosPAK0S);
994
995     if (fTrackRotation) {
996
997       TH2F* pidTRptK0S = (TH2F*)ptK0S->Clone();
998       TH2F* pidTRptP = (TH2F*)ptP->Clone();
999       TH2F* pidTRptPiP = (TH2F*)ptPiP->Clone();
1000       TH2F* pidTRptPiM = (TH2F*)ptPiM->Clone();
1001       TH2F* pidTRmassLambda = (TH2F*)massLambda->Clone();
1002       TH2F* pidTRmassLambdaBar = (TH2F*)massLambdaBar->Clone();
1003       TH2F* pidTRmassGamma = (TH2F*)massGamma->Clone();
1004       TH2F* pidTRcosPAK0S = (TH2F*)cosPAK0S->Clone();
1005       fOutputPIDBachTR->Add(pidTRptK0S);
1006       fOutputPIDBachTR->Add(pidTRptP);
1007       fOutputPIDBachTR->Add(pidTRptPiP);
1008       fOutputPIDBachTR->Add(pidTRptPiM);
1009       fOutputPIDBachTR->Add(pidTRmassLambda);
1010       fOutputPIDBachTR->Add(pidTRmassLambdaBar);
1011       fOutputPIDBachTR->Add(pidTRmassGamma);
1012       fOutputPIDBachTR->Add(pidTRcosPAK0S);
1013
1014     }
1015
1016   }
1017
1018   // V0 invariant masses (offline)
1019   nameHisto="histK0SMassOffline";
1020   titleHisto="K^{0}_{S} invariant mass VS p_{T}; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1021   TH2F* spectrumK0SMassOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
1022
1023   // Lc invariant masses (x K0S offline)
1024   nameHisto="histLcMassByK0SOffline";
1025   titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T}; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1026   TH2F* spectrumLcMassOfflineByK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1027
1028   nameHisto="histpK0SvspOffline";
1029   titleHisto="p(K^{0}_{S}) vs p(p); p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1030   TH2F* momentumDistributionK0SvspOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,41,binLimpTprong);
1031
1032   nameHisto="histArmPodK0SOffline";
1033   titleHisto="K^{0}_{S} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1034   TH2F* armenterosPodK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1035
1036   nameHisto="histArmPodLcOffline";
1037   titleHisto="#Lambda_{c} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1038   TH2F* armenterosPodLcOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1039
1040   TH2F* allspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone(); 
1041   TH2F* allspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone(); 
1042   TH2F* allmomentumDistributionK0SvspOffline = (TH2F*)momentumDistributionK0SvspOffline->Clone();
1043   TH2F* allArmenterosPodK0SOffline = (TH2F*)armenterosPodK0SOffline->Clone();
1044   TH2F* allArmenterosPodLcOffline = (TH2F*)armenterosPodLcOffline->Clone();
1045
1046   TH2F* pidBachspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone(); 
1047   TH2F* pidBachspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone(); 
1048   TH2F* pidBachmomentumDistributionK0SvspOffline = (TH2F*)momentumDistributionK0SvspOffline->Clone();
1049   TH2F* pidBachArmenterosPodK0SOffline = (TH2F*)armenterosPodK0SOffline->Clone();
1050   TH2F* pidBachArmenterosPodLcOffline = (TH2F*)armenterosPodLcOffline->Clone();
1051
1052   fOutputAll->Add(allspectrumK0SMassOffline);
1053   fOutputAll->Add(allspectrumLcMassOfflineByK0S);
1054   fOutputAll->Add(allmomentumDistributionK0SvspOffline); 
1055   fOutputAll->Add(allArmenterosPodK0SOffline);
1056   fOutputAll->Add(allArmenterosPodLcOffline);
1057
1058   fOutputPIDBach->Add(pidBachspectrumK0SMassOffline);
1059   fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0S);
1060   fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOffline); 
1061   fOutputPIDBach->Add(pidBachArmenterosPodK0SOffline);
1062   fOutputPIDBach->Add(pidBachArmenterosPodLcOffline);
1063
1064   nameHisto="histArmPodK0SOffline0";
1065   titleHisto="K^{0}_{S} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1066   TH2F* armenterosPodK0SOffline0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1067   nameHisto="histArmPodLcOffline0";
1068   titleHisto="#Lambda_{c} Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1069   TH2F* armenterosPodLcOffline0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1070   fOutputAll->Add(armenterosPodK0SOffline0);
1071   fOutputAll->Add(armenterosPodLcOffline0);
1072
1073   if (fTrackRotation) {
1074     TH2F* pidBachTRspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone(); 
1075     fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0S);
1076   }
1077
1078
1079
1080
1081   nameHisto="histptK0SOffline";
1082   titleHisto="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1083   TH2F* ptK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1084
1085   nameHisto="histptPOffline";
1086   titleHisto="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1087   TH2F* ptPOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1088
1089   nameHisto="histptPipOffline";
1090   titleHisto="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1091   TH2F* ptPiPOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1092
1093   nameHisto="histptPimOffline";
1094   titleHisto="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1095   TH2F* ptPiMOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1096
1097   nameHisto="histLambdaMassOffline";
1098   titleHisto="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1099   TH2F* massLambdaOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1100
1101   nameHisto="histLambdaBarMassOffline";
1102   titleHisto="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1103   TH2F* massLambdaBarOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1104
1105   nameHisto="histGammaMassOffline";
1106   titleHisto="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1107   TH2F* massGammaOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,100,0.,1.);
1108
1109   nameHisto="histD0K0SOffline";
1110   titleHisto="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1111   TH2F* d0K0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1112
1113   nameHisto="histD0POffline";
1114   titleHisto="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1115   TH2F* d0POffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1116
1117   nameHisto="histCosPAK0SOffline";
1118   titleHisto="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1119   TH2F *cosPAK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,0.99,1.);
1120
1121   TH2F* allptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1122   TH2F* allptPOffline = (TH2F*)ptPOffline->Clone();
1123   TH2F* allptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1124   TH2F* allptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1125   TH2F* allmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1126   TH2F* allmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1127   TH2F* allmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1128   TH2F* alld0K0SOffline = (TH2F*)d0K0SOffline->Clone();
1129   TH2F* alld0POffline = (TH2F*)d0POffline->Clone();
1130   TH2F* allcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1131
1132   TH2F* pidptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1133   TH2F* pidptPOffline = (TH2F*)ptPOffline->Clone();
1134   TH2F* pidptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1135   TH2F* pidptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1136   TH2F* pidmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1137   TH2F* pidmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1138   TH2F* pidmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1139   TH2F* pidd0K0SOffline = (TH2F*)d0K0SOffline->Clone();
1140   TH2F* pidd0POffline = (TH2F*)d0POffline->Clone();
1141   TH2F* pidcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1142
1143   fOutputAll->Add(allptK0SOffline);
1144   fOutputAll->Add(allptPOffline);
1145   fOutputAll->Add(allptPiPOffline);
1146   fOutputAll->Add(allptPiMOffline);
1147   fOutputAll->Add(allmassLambdaOffline);
1148   fOutputAll->Add(allmassLambdaBarOffline);
1149   fOutputAll->Add(allmassGammaOffline);
1150   fOutputAll->Add(alld0K0SOffline);
1151   fOutputAll->Add(alld0POffline);
1152   fOutputAll->Add(allcosPAK0SOffline);
1153
1154   fOutputPIDBach->Add(pidptK0SOffline);
1155   fOutputPIDBach->Add(pidptPOffline);
1156   fOutputPIDBach->Add(pidptPiPOffline);
1157   fOutputPIDBach->Add(pidptPiMOffline);
1158   fOutputPIDBach->Add(pidmassLambdaOffline);
1159   fOutputPIDBach->Add(pidmassLambdaBarOffline);
1160   fOutputPIDBach->Add(pidmassGammaOffline);
1161   fOutputPIDBach->Add(pidd0K0SOffline);
1162   fOutputPIDBach->Add(pidd0POffline);
1163   fOutputPIDBach->Add(pidcosPAK0SOffline);
1164
1165   if (fTrackRotation) {
1166
1167     TH2F* pidTRptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1168     TH2F* pidTRptPOffline = (TH2F*)ptPOffline->Clone();
1169     TH2F* pidTRptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1170     TH2F* pidTRptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1171     TH2F* pidTRmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1172     TH2F* pidTRmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1173     TH2F* pidTRmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1174     TH2F* pidTRcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1175     fOutputPIDBachTR->Add(pidTRptK0SOffline);
1176     fOutputPIDBachTR->Add(pidTRptPOffline);
1177     fOutputPIDBachTR->Add(pidTRptPiPOffline);
1178     fOutputPIDBachTR->Add(pidTRptPiMOffline);
1179     fOutputPIDBachTR->Add(pidTRmassLambdaOffline);
1180     fOutputPIDBachTR->Add(pidTRmassLambdaBarOffline);
1181     fOutputPIDBachTR->Add(pidTRmassGammaOffline);
1182     fOutputPIDBachTR->Add(pidTRcosPAK0SOffline);
1183
1184   }
1185
1186
1187
1188
1189
1190   if (fUseMCInfo) {
1191
1192     if (fUseOnTheFlyV0) {
1193
1194       nameHistoSgn="histK0SMassSgn";
1195       nameHistoBkg="histK0SMassBkg";
1196       titleHistoSgn="K^{0}_{S} - sgn: invariant mass VS p_{T} - MC; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1197       titleHistoBkg="K^{0}_{S} - bkg: invariant mass VS p_{T} - MC; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1198       TH2F* spectrumK0SMassSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
1199       TH2F* spectrumK0SMassBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
1200
1201       nameHistoSgn="histLcMassByK0SSgn";
1202       nameHistoBkg="histLcMassByK0SBkg";
1203       titleHistoSgn="#Lambda_{c} - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1204       titleHistoBkg="#Lambda_{c} - bkg: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1205       TH2F* spectrumLcMassByK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1206       TH2F* spectrumLcMassByK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1207
1208       nameHistoSgn="histpK0SvspSgn";
1209       nameHistoBkg="histpK0SvspBkg";
1210       titleHistoSgn="#Lambda_{c} - sgn: K^{0}_{S} vs p Total Momentum Distribution - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1211       titleHistoBkg="#Lambda_{c} - bkg: K^{0}_{S} vs p Total Momentum Distribution - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1212       TH2F* momentumDistributionK0SvspSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,41,binLimpTprong);
1213       TH2F* momentumDistributionK0SvspBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,41,binLimpTprong);
1214
1215       // armenteros-podolanski plots K0S
1216       nameHistoSgn="histArmPodK0SSgn";
1217       nameHistoBkg="histArmPodK0SBkg";
1218       titleHistoSgn="K^{0}_{S} Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1219       titleHistoBkg="K^{0}_{S} Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1220       TH2F* armenterosPodK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1221       TH2F* armenterosPodK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1222
1223       nameHistoSgn="histArmPodLcSgn";
1224       nameHistoBkg="histArmPodLcBkg";
1225       titleHistoSgn="#Lambda_{c} Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1226       titleHistoBkg="#Lambda_{c} Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1227       TH2F* armenterosPodLcSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1228       TH2F* armenterosPodLcBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1229
1230       TH2F* allspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone();
1231       TH2F* allspectrumK0SMassBkg = (TH2F*)spectrumK0SMassBkg->Clone();
1232       TH2F* allspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1233       TH2F* allspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1234       TH2F* allmomentumDistributionK0SvspSgn = (TH2F*)momentumDistributionK0SvspSgn->Clone();
1235       TH2F* allmomentumDistributionK0SvspBkg = (TH2F*)momentumDistributionK0SvspBkg->Clone();
1236       TH2F* allArmenterosPodK0SSgn = (TH2F*)armenterosPodK0SSgn->Clone();
1237       TH2F* allArmenterosPodK0SBkg = (TH2F*)armenterosPodK0SBkg->Clone();
1238       TH2F* allArmenterosPodLcSgn = (TH2F*)armenterosPodLcSgn->Clone();
1239       TH2F* allArmenterosPodLcBkg = (TH2F*)armenterosPodLcBkg->Clone();
1240
1241       TH2F* pidBachspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone();
1242       TH2F* pidBachspectrumK0SMassBkg = (TH2F*)spectrumK0SMassBkg->Clone();
1243       TH2F* pidBachspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1244       TH2F* pidBachspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1245       TH2F* pidBachmomentumDistributionK0SvspSgn = (TH2F*)momentumDistributionK0SvspSgn->Clone();
1246       TH2F* pidBachmomentumDistributionK0SvspBkg = (TH2F*)momentumDistributionK0SvspBkg->Clone();
1247       TH2F* pidBachArmenterosPodK0SSgn = (TH2F*)armenterosPodK0SSgn->Clone();
1248       TH2F* pidBachArmenterosPodK0SBkg = (TH2F*)armenterosPodK0SBkg->Clone();
1249       TH2F* pidBachArmenterosPodLcSgn = (TH2F*)armenterosPodLcSgn->Clone();
1250       TH2F* pidBachArmenterosPodLcBkg = (TH2F*)armenterosPodLcBkg->Clone();
1251
1252       fOutputAll->Add(allspectrumK0SMassSgn);
1253       fOutputAll->Add(allspectrumK0SMassBkg);
1254       fOutputAll->Add(allspectrumLcMassByK0SSgn);
1255       fOutputAll->Add(allspectrumLcMassByK0SBkg);
1256       fOutputAll->Add(allmomentumDistributionK0SvspSgn);
1257       fOutputAll->Add(allmomentumDistributionK0SvspBkg);
1258       fOutputAll->Add(allArmenterosPodK0SSgn);
1259       fOutputAll->Add(allArmenterosPodK0SBkg);
1260       fOutputAll->Add(allArmenterosPodLcSgn);
1261       fOutputAll->Add(allArmenterosPodLcBkg);
1262
1263       fOutputPIDBach->Add(pidBachspectrumK0SMassSgn);
1264       fOutputPIDBach->Add(pidBachspectrumK0SMassBkg);
1265       fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgn);
1266       fOutputPIDBach->Add(pidBachspectrumLcMassByK0SBkg);
1267       fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspSgn);
1268       fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspBkg);
1269       fOutputPIDBach->Add(pidBachArmenterosPodK0SSgn);
1270       fOutputPIDBach->Add(pidBachArmenterosPodK0SBkg);
1271       fOutputPIDBach->Add(pidBachArmenterosPodLcSgn);
1272       fOutputPIDBach->Add(pidBachArmenterosPodLcBkg);
1273
1274       nameHistoSgn="histArmPodK0SSgn0";
1275       nameHistoBkg="histArmPodK0SBkg0";
1276       titleHistoSgn="K^{0}_{S} Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1277       titleHistoBkg="K^{0}_{S} Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1278       TH2F* armenterosPodK0SSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1279       TH2F* armenterosPodK0SBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1280       fOutputAll->Add(armenterosPodK0SSgn0);
1281       fOutputAll->Add(armenterosPodK0SBkg0);
1282       nameHistoSgn="histArmPodLcSgn0";
1283       nameHistoBkg="histArmPodLcBkg0";
1284       titleHistoSgn="#Lambda_{c} Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1285       titleHistoBkg="#Lambda_{c} Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1286       TH2F* armenterosPodLcSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1287       TH2F* armenterosPodLcBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1288       fOutputAll->Add(armenterosPodLcSgn0);
1289       fOutputAll->Add(armenterosPodLcBkg0);
1290
1291       if (fTrackRotation) {
1292         TH2F* pidBachTRspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1293         TH2F* pidBachTRspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1294         fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0SSgn);
1295         fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0SBkg);
1296       }
1297
1298
1299
1300     nameHistoSgn="histptK0SSgn";
1301     nameHistoBkg="histptK0SBkg";
1302     titleHistoSgn="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1303     titleHistoBkg="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1304     TH2F* ptK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1305     TH2F* ptK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1306
1307     nameHistoSgn="histptPSgn";
1308     nameHistoBkg="histptPBkg";
1309     titleHistoSgn="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1310     titleHistoBkg="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1311     TH2F* ptPSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1312     TH2F* ptPBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1313
1314     nameHistoSgn="histptPipSgn";
1315     nameHistoBkg="histptPipBkg";
1316     titleHistoSgn="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1317     titleHistoBkg="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1318     TH2F* ptPiPSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1319     TH2F* ptPiPBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1320
1321     nameHistoSgn="histptPimSgn";
1322     nameHistoBkg="histptPimBkg";
1323     titleHistoSgn="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1324     titleHistoBkg="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1325     TH2F* ptPiMSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1326     TH2F* ptPiMBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1327
1328     nameHistoSgn="histLambdaMassSgn";
1329     nameHistoBkg="histLambdaMassBkg";
1330     titleHistoSgn="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1331     titleHistoBkg="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1332     TH2F* massLambdaSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1333     TH2F* massLambdaBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1334
1335     nameHistoSgn="histLambdaBarMassSgn";
1336     nameHistoBkg="histLambdaBarMassBkg";
1337     titleHistoSgn="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1338     titleHistoBkg="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1339     TH2F* massLambdaBarSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1340     TH2F* massLambdaBarBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1341
1342     nameHistoSgn="histGammaMassSgn";
1343     nameHistoBkg="histGammaMassBkg";
1344     titleHistoSgn="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1345     titleHistoBkg="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1346     TH2F* massGammaSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,100,0.,1.);
1347     TH2F* massGammaBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,100,0.,1.);
1348
1349     nameHistoSgn="histD0K0SSgn";
1350     nameHistoBkg="histD0K0SBkg";
1351     titleHistoSgn="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1352     titleHistoBkg="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1353     TH2F* d0K0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1354     TH2F* d0K0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1355
1356     nameHistoSgn="histD0PSgn";
1357     nameHistoBkg="histD0PBkg";
1358     titleHistoSgn="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1359     titleHistoBkg="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1360     TH2F* d0PSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1361     TH2F* d0PBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1362
1363     nameHistoSgn="histCosPAK0SSgn";
1364     nameHistoBkg="histCosPAK0SBkg";
1365     titleHistoSgn="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1366     titleHistoBkg="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1367     TH2F *cosPAK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,0.99,1.);
1368     TH2F *cosPAK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,0.99,1.);
1369
1370     TH2F* allptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1371     TH2F* allptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1372     TH2F* allptPSgn = (TH2F*)ptPSgn->Clone();
1373     TH2F* allptPBkg = (TH2F*)ptPBkg->Clone();
1374     TH2F* allptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1375     TH2F* allptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1376     TH2F* allptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1377     TH2F* allptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1378     TH2F* allmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1379     TH2F* allmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1380     TH2F* allmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1381     TH2F* allmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1382     TH2F* allmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1383     TH2F* allmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1384     TH2F* alld0K0SSgn = (TH2F*)d0K0SSgn->Clone();
1385     TH2F* alld0K0SBkg = (TH2F*)d0K0SBkg->Clone();
1386     TH2F* alld0PSgn = (TH2F*)d0PSgn->Clone();
1387     TH2F* alld0PBkg = (TH2F*)d0PBkg->Clone();
1388     TH2F* allcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1389     TH2F* allcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1390
1391     TH2F* pidptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1392     TH2F* pidptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1393     TH2F* pidptPSgn = (TH2F*)ptPSgn->Clone();
1394     TH2F* pidptPBkg = (TH2F*)ptPBkg->Clone();
1395     TH2F* pidptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1396     TH2F* pidptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1397     TH2F* pidptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1398     TH2F* pidptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1399     TH2F* pidmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1400     TH2F* pidmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1401     TH2F* pidmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1402     TH2F* pidmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1403     TH2F* pidmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1404     TH2F* pidmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1405     TH2F* pidd0K0SSgn = (TH2F*)d0K0SSgn->Clone();
1406     TH2F* pidd0K0SBkg = (TH2F*)d0K0SBkg->Clone();
1407     TH2F* pidd0PSgn = (TH2F*)d0PSgn->Clone();
1408     TH2F* pidd0PBkg = (TH2F*)d0PBkg->Clone();
1409     TH2F* pidcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1410     TH2F* pidcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1411
1412     fOutputAll->Add(allptK0SSgn);
1413     fOutputAll->Add(allptK0SBkg);
1414     fOutputAll->Add(allptPSgn);
1415     fOutputAll->Add(allptPBkg);
1416     fOutputAll->Add(allptPiPSgn);
1417     fOutputAll->Add(allptPiPBkg);
1418     fOutputAll->Add(allptPiMSgn);
1419     fOutputAll->Add(allptPiMBkg);
1420     fOutputAll->Add(allmassLambdaSgn);
1421     fOutputAll->Add(allmassLambdaBkg);
1422     fOutputAll->Add(allmassLambdaBarSgn);
1423     fOutputAll->Add(allmassLambdaBarBkg);
1424     fOutputAll->Add(allmassGammaSgn);
1425     fOutputAll->Add(allmassGammaBkg);
1426     fOutputAll->Add(alld0K0SSgn);
1427     fOutputAll->Add(alld0K0SBkg);
1428     fOutputAll->Add(alld0PSgn);
1429     fOutputAll->Add(alld0PBkg);
1430     fOutputAll->Add(allcosPAK0SSgn);
1431     fOutputAll->Add(allcosPAK0SBkg);
1432
1433     fOutputPIDBach->Add(pidptK0SSgn);
1434     fOutputPIDBach->Add(pidptK0SBkg);
1435     fOutputPIDBach->Add(pidptPSgn);
1436     fOutputPIDBach->Add(pidptPBkg);
1437     fOutputPIDBach->Add(pidptPiPSgn);
1438     fOutputPIDBach->Add(pidptPiPBkg);
1439     fOutputPIDBach->Add(pidptPiMSgn);
1440     fOutputPIDBach->Add(pidptPiMBkg);
1441     fOutputPIDBach->Add(pidmassLambdaSgn);
1442     fOutputPIDBach->Add(pidmassLambdaBkg);
1443     fOutputPIDBach->Add(pidmassLambdaBarSgn);
1444     fOutputPIDBach->Add(pidmassLambdaBarBkg);
1445     fOutputPIDBach->Add(pidmassGammaSgn);
1446     fOutputPIDBach->Add(pidmassGammaBkg);
1447     fOutputPIDBach->Add(pidd0K0SSgn);
1448     fOutputPIDBach->Add(pidd0K0SBkg);
1449     fOutputPIDBach->Add(pidd0PSgn);
1450     fOutputPIDBach->Add(pidd0PBkg);
1451     fOutputPIDBach->Add(pidcosPAK0SSgn);
1452     fOutputPIDBach->Add(pidcosPAK0SBkg);
1453
1454     if (fTrackRotation) {
1455
1456       TH2F* pidTRptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1457       TH2F* pidTRptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1458       TH2F* pidTRptPSgn = (TH2F*)ptPSgn->Clone();
1459       TH2F* pidTRptPBkg = (TH2F*)ptPBkg->Clone();
1460       TH2F* pidTRptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1461       TH2F* pidTRptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1462       TH2F* pidTRptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1463       TH2F* pidTRptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1464       TH2F* pidTRmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1465       TH2F* pidTRmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1466       TH2F* pidTRmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1467       TH2F* pidTRmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1468       TH2F* pidTRmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1469       TH2F* pidTRmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1470       TH2F* pidTRcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1471       TH2F* pidTRcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1472       fOutputPIDBachTR->Add(pidTRptK0SSgn);
1473       fOutputPIDBachTR->Add(pidTRptK0SBkg);
1474       fOutputPIDBachTR->Add(pidTRptPSgn);
1475       fOutputPIDBachTR->Add(pidTRptPBkg);
1476       fOutputPIDBachTR->Add(pidTRptPiPSgn);
1477       fOutputPIDBachTR->Add(pidTRptPiPBkg);
1478       fOutputPIDBachTR->Add(pidTRptPiMSgn);
1479       fOutputPIDBachTR->Add(pidTRptPiMBkg);
1480       fOutputPIDBachTR->Add(pidTRmassLambdaSgn);
1481       fOutputPIDBachTR->Add(pidTRmassLambdaBkg);
1482       fOutputPIDBachTR->Add(pidTRmassLambdaBarSgn);
1483       fOutputPIDBachTR->Add(pidTRmassLambdaBarBkg);
1484       fOutputPIDBachTR->Add(pidTRmassGammaSgn);
1485       fOutputPIDBachTR->Add(pidTRmassGammaBkg);
1486       fOutputPIDBachTR->Add(pidTRcosPAK0SSgn);
1487       fOutputPIDBachTR->Add(pidTRcosPAK0SBkg);
1488
1489     }
1490
1491
1492     } // useOnTheFly
1493
1494
1495     nameHistoSgn="histK0SMassOfflineSgn";
1496     nameHistoBkg="histK0SMassOfflineBkg";
1497     titleHistoSgn="K^{0}_{S} - sgn: invariant mass VS p_{T} - MC; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1498     titleHistoBkg="K^{0}_{S} - bkg: invariant mass VS p_{T} - MC; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1499     TH2F* spectrumK0SMassOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
1500     TH2F* spectrumK0SMassOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mK0SPDG-0.050,mK0SPDG+0.050,41,binLimpTprong);
1501
1502     nameHistoSgn="histLcMassByK0SOfflineSgn";
1503     nameHistoBkg="histLcMassByK0SOfflineBkg";
1504     titleHistoSgn="#Lambda_{c} - sgn: invariant mass (by K^{0}_{S})  vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1505     titleHistoBkg="#Lambda_{c} - bkg: invariant mass (by K^{0}_{S})  vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1506     TH2F* spectrumLcMassOfflineByK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1507     TH2F* spectrumLcMassOfflineByK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1508
1509     nameHistoSgn="histpK0SvspOfflineSgn";
1510     nameHistoBkg="histpK0SvspOfflineBkg";
1511     titleHistoSgn="#Lambda_{c} - sgn: K^{0}_{S} vs p Total Momentum Distribution - Offline - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1512     titleHistoBkg="#Lambda_{c} - bkg: K^{0}_{S} vs p Total Momentum Distribution - Offline - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1513     TH2F* momentumDistributionK0SvspOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,41,binLimpTprong);
1514     TH2F* momentumDistributionK0SvspOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,41,binLimpTprong);
1515
1516     // armenteros-podolanski plots K0S (offline)
1517     nameHistoSgn="histArmPodK0SOfflineSgn";
1518     nameHistoBkg="histArmPodK0SOfflineBkg";
1519     titleHistoSgn="K^{0}_{S} Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1520     titleHistoBkg="K^{0}_{S} Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1521     TH2F* armenterosPodK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1522     TH2F* armenterosPodK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1523
1524     nameHistoSgn="histArmPodLcOfflineSgn";
1525     nameHistoBkg="histArmPodLcOfflineBkg";
1526     titleHistoSgn="#Lambda_{c} Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1527     titleHistoBkg="#Lambda_{c} Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1528     TH2F* armenterosPodLcOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1529     TH2F* armenterosPodLcOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1530
1531
1532     TH2F* allspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone(); 
1533     TH2F* allspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();  
1534     TH2F* allspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone(); 
1535     TH2F* allspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();  
1536     TH2F* allmomentumDistributionK0SvspOfflineSgn = (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone();
1537     TH2F* allmomentumDistributionK0SvspOfflineBkg = (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone();
1538     TH2F* allArmenterosPodK0SOfflineSgn = (TH2F*)armenterosPodK0SOfflineSgn->Clone();
1539     TH2F* allArmenterosPodK0SOfflineBkg = (TH2F*)armenterosPodK0SOfflineBkg->Clone();
1540     TH2F* allArmenterosPodLcOfflineSgn = (TH2F*)armenterosPodLcOfflineSgn->Clone();
1541     TH2F* allArmenterosPodLcOfflineBkg = (TH2F*)armenterosPodLcOfflineBkg->Clone();
1542
1543     TH2F* pidBachspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone();
1544     TH2F* pidBachspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();
1545     TH2F* pidBachspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone();
1546     TH2F* pidBachspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();
1547     TH2F* pidBachmomentumDistributionK0SvspOfflineSgn = (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone();
1548     TH2F* pidBachmomentumDistributionK0SvspOfflineBkg = (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone();
1549     TH2F* pidBachArmenterosPodK0SOfflineSgn = (TH2F*)armenterosPodK0SOfflineSgn->Clone();
1550     TH2F* pidBachArmenterosPodK0SOfflineBkg = (TH2F*)armenterosPodK0SOfflineBkg->Clone();
1551     TH2F* pidBachArmenterosPodLcOfflineSgn = (TH2F*)armenterosPodLcOfflineSgn->Clone();
1552     TH2F* pidBachArmenterosPodLcOfflineBkg = (TH2F*)armenterosPodLcOfflineBkg->Clone();
1553
1554     fOutputAll->Add(allspectrumK0SMassOfflineSgn);
1555     fOutputAll->Add(allspectrumK0SMassOfflineBkg);
1556     fOutputAll->Add(allspectrumLcMassOfflineByK0SSgn);
1557     fOutputAll->Add(allspectrumLcMassOfflineByK0SBkg);
1558     fOutputAll->Add(allmomentumDistributionK0SvspOfflineSgn);
1559     fOutputAll->Add(allmomentumDistributionK0SvspOfflineBkg);
1560     fOutputAll->Add(allArmenterosPodK0SOfflineSgn);
1561     fOutputAll->Add(allArmenterosPodK0SOfflineBkg);
1562     fOutputAll->Add(allArmenterosPodLcOfflineSgn);
1563     fOutputAll->Add(allArmenterosPodLcOfflineBkg);
1564
1565     fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineSgn);
1566     fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineBkg);
1567     fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SSgn);
1568     fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SBkg);
1569     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineSgn);
1570     fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineBkg);
1571     fOutputPIDBach->Add(pidBachArmenterosPodK0SOfflineSgn);
1572     fOutputPIDBach->Add(pidBachArmenterosPodK0SOfflineBkg);
1573     fOutputPIDBach->Add(pidBachArmenterosPodLcOfflineSgn);
1574     fOutputPIDBach->Add(pidBachArmenterosPodLcOfflineBkg);
1575
1576     nameHistoSgn="histArmPodK0SOfflineSgn0";
1577     nameHistoBkg="histArmPodK0SOfflineBkg0";
1578     titleHistoSgn="K^{0}_{S} Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1579     titleHistoBkg="K^{0}_{S} Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1580     TH2F* armenterosPodK0SOfflineSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1581     TH2F* armenterosPodK0SOfflineBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1582     nameHistoSgn="histArmPodLcOfflineSgn0";
1583     nameHistoBkg="histArmPodLcOfflineBkg0";
1584     titleHistoSgn="#Lambda_{c} Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1585     titleHistoBkg="#Lambda_{c} Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1586     TH2F* armenterosPodLcOfflineSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1587     TH2F* armenterosPodLcOfflineBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1588     fOutputAll->Add(armenterosPodK0SOfflineSgn0);
1589     fOutputAll->Add(armenterosPodK0SOfflineBkg0);
1590     fOutputAll->Add(armenterosPodLcOfflineSgn0);
1591     fOutputAll->Add(armenterosPodLcOfflineBkg0);
1592
1593     if (fTrackRotation) {
1594       TH2F* pidBachTRspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone(); 
1595       TH2F* pidBachTRspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();  
1596       fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0SSgn);
1597       fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0SBkg);
1598     }
1599
1600
1601
1602
1603     nameHistoSgn="histptK0SOfflineSgn";
1604     nameHistoBkg="histptK0SOfflineBkg";
1605     titleHistoSgn="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1606     titleHistoBkg="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1607     TH2F* ptK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1608     TH2F* ptK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1609
1610     nameHistoSgn="histptPOfflineSgn";
1611     nameHistoBkg="histptPOfflineBkg";
1612     titleHistoSgn="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1613     titleHistoBkg="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1614     TH2F* ptPOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1615     TH2F* ptPOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1616
1617     nameHistoSgn="histptPipOfflineSgn";
1618     nameHistoBkg="histptPipOfflineBkg";
1619     titleHistoSgn="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1620     titleHistoBkg="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1621     TH2F* ptPiPOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1622     TH2F* ptPiPOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1623
1624     nameHistoSgn="histptPimOfflineSgn";
1625     nameHistoBkg="histptPimOfflineBkg";
1626     titleHistoSgn="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1627     titleHistoBkg="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1628     TH2F* ptPiMOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1629     TH2F* ptPiMOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1630
1631     nameHistoSgn="histLambdaMassOfflineSgn";
1632     nameHistoBkg="histLambdaMassOfflineBkg";
1633     titleHistoSgn="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1634     titleHistoBkg="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1635     TH2F* massLambdaOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1636     TH2F* massLambdaOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1637
1638     nameHistoSgn="histLambdaBarMassOfflineSgn";
1639     nameHistoBkg="histLambdaBarMassOfflineBkg";
1640     titleHistoSgn="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1641     titleHistoBkg="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1642     TH2F* massLambdaBarOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1643     TH2F* massLambdaBarOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1644
1645     nameHistoSgn="histGammaMassOfflineSgn";
1646     nameHistoBkg="histGammaMassOfflineBkg";
1647     titleHistoSgn="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1648     titleHistoBkg="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1649     TH2F* massGammaOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,100,0.,1.);
1650     TH2F* massGammaOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,100,0.,1.);
1651
1652     nameHistoSgn="histD0K0SOfflineSgn";
1653     nameHistoBkg="histD0K0SOfflineBkg";
1654     titleHistoSgn="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1655     titleHistoBkg="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1656     TH2F* d0K0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1657     TH2F* d0K0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1658
1659     nameHistoSgn="histD0POfflineSgn";
1660     nameHistoBkg="histD0POfflineBkg";
1661     titleHistoSgn="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1662     titleHistoBkg="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1663     TH2F* d0POfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1664     TH2F* d0POfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1665
1666     nameHistoSgn="histCosPAK0SOfflineSgn";
1667     nameHistoBkg="histCosPAK0SOfflineBkg";
1668     titleHistoSgn="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1669     titleHistoBkg="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1670     TH2F *cosPAK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,0.99,1.);
1671     TH2F *cosPAK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,0.99,1.);
1672
1673     TH2F* allptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
1674     TH2F* allptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
1675     TH2F* allptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
1676     TH2F* allptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
1677     TH2F* allptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
1678     TH2F* allptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
1679     TH2F* allptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
1680     TH2F* allptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
1681     TH2F* allmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
1682     TH2F* allmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
1683     TH2F* allmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
1684     TH2F* allmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
1685     TH2F* allmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
1686     TH2F* allmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
1687     TH2F* alld0K0SOfflineSgn = (TH2F*)d0K0SOfflineSgn->Clone();
1688     TH2F* alld0K0SOfflineBkg = (TH2F*)d0K0SOfflineBkg->Clone();
1689     TH2F* alld0POfflineSgn = (TH2F*)d0POfflineSgn->Clone();
1690     TH2F* alld0POfflineBkg = (TH2F*)d0POfflineBkg->Clone();
1691     TH2F* allcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
1692     TH2F* allcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
1693
1694     TH2F* pidptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
1695     TH2F* pidptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
1696     TH2F* pidptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
1697     TH2F* pidptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
1698     TH2F* pidptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
1699     TH2F* pidptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
1700     TH2F* pidptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
1701     TH2F* pidptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
1702     TH2F* pidmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
1703     TH2F* pidmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
1704     TH2F* pidmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
1705     TH2F* pidmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
1706     TH2F* pidmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
1707     TH2F* pidmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
1708     TH2F* pidd0K0SOfflineSgn = (TH2F*)d0K0SOfflineSgn->Clone();
1709     TH2F* pidd0K0SOfflineBkg = (TH2F*)d0K0SOfflineBkg->Clone();
1710     TH2F* pidd0POfflineSgn = (TH2F*)d0POfflineSgn->Clone();
1711     TH2F* pidd0POfflineBkg = (TH2F*)d0POfflineBkg->Clone();
1712     TH2F* pidcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
1713     TH2F* pidcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
1714
1715     fOutputAll->Add(allptK0SOfflineSgn);
1716     fOutputAll->Add(allptK0SOfflineBkg);
1717     fOutputAll->Add(allptPOfflineSgn);
1718     fOutputAll->Add(allptPOfflineBkg);
1719     fOutputAll->Add(allptPiPOfflineSgn);
1720     fOutputAll->Add(allptPiPOfflineBkg);
1721     fOutputAll->Add(allptPiMOfflineSgn);
1722     fOutputAll->Add(allptPiMOfflineBkg);
1723     fOutputAll->Add(allmassLambdaOfflineSgn);
1724     fOutputAll->Add(allmassLambdaOfflineBkg);
1725     fOutputAll->Add(allmassLambdaBarOfflineSgn);
1726     fOutputAll->Add(allmassLambdaBarOfflineBkg);
1727     fOutputAll->Add(allmassGammaOfflineSgn);
1728     fOutputAll->Add(allmassGammaOfflineBkg);
1729     fOutputAll->Add(alld0K0SOfflineSgn);
1730     fOutputAll->Add(alld0K0SOfflineBkg);
1731     fOutputAll->Add(alld0POfflineSgn);
1732     fOutputAll->Add(alld0POfflineBkg);
1733     fOutputAll->Add(allcosPAK0SOfflineSgn);
1734     fOutputAll->Add(allcosPAK0SOfflineBkg);
1735
1736     fOutputPIDBach->Add(pidptK0SOfflineSgn);
1737     fOutputPIDBach->Add(pidptK0SOfflineBkg);
1738     fOutputPIDBach->Add(pidptPOfflineSgn);
1739     fOutputPIDBach->Add(pidptPOfflineBkg);
1740     fOutputPIDBach->Add(pidptPiPOfflineSgn);
1741     fOutputPIDBach->Add(pidptPiPOfflineBkg);
1742     fOutputPIDBach->Add(pidptPiMOfflineSgn);
1743     fOutputPIDBach->Add(pidptPiMOfflineBkg);
1744     fOutputPIDBach->Add(pidmassLambdaOfflineSgn);
1745     fOutputPIDBach->Add(pidmassLambdaOfflineBkg);
1746     fOutputPIDBach->Add(pidmassLambdaBarOfflineSgn);
1747     fOutputPIDBach->Add(pidmassLambdaBarOfflineBkg);
1748     fOutputPIDBach->Add(pidmassGammaOfflineSgn);
1749     fOutputPIDBach->Add(pidmassGammaOfflineBkg);
1750     fOutputPIDBach->Add(pidd0K0SOfflineSgn);
1751     fOutputPIDBach->Add(pidd0K0SOfflineBkg);
1752     fOutputPIDBach->Add(pidd0POfflineSgn);
1753     fOutputPIDBach->Add(pidd0POfflineBkg);
1754     fOutputPIDBach->Add(pidcosPAK0SOfflineSgn);
1755     fOutputPIDBach->Add(pidcosPAK0SOfflineBkg);
1756
1757     if (fTrackRotation) {
1758
1759       TH2F* pidTRptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
1760       TH2F* pidTRptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
1761       TH2F* pidTRptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
1762       TH2F* pidTRptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
1763       TH2F* pidTRptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
1764       TH2F* pidTRptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
1765       TH2F* pidTRptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
1766       TH2F* pidTRptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
1767       TH2F* pidTRmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
1768       TH2F* pidTRmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
1769       TH2F* pidTRmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
1770       TH2F* pidTRmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
1771       TH2F* pidTRmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
1772       TH2F* pidTRmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
1773       TH2F* pidTRcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
1774       TH2F* pidTRcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
1775       fOutputPIDBachTR->Add(pidTRptK0SOfflineSgn);
1776       fOutputPIDBachTR->Add(pidTRptK0SOfflineBkg);
1777       fOutputPIDBachTR->Add(pidTRptPOfflineSgn);
1778       fOutputPIDBachTR->Add(pidTRptPOfflineBkg);
1779       fOutputPIDBachTR->Add(pidTRptPiPOfflineSgn);
1780       fOutputPIDBachTR->Add(pidTRptPiPOfflineBkg);
1781       fOutputPIDBachTR->Add(pidTRptPiMOfflineSgn);
1782       fOutputPIDBachTR->Add(pidTRptPiMOfflineBkg);
1783       fOutputPIDBachTR->Add(pidTRmassLambdaOfflineSgn);
1784       fOutputPIDBachTR->Add(pidTRmassLambdaOfflineBkg);
1785       fOutputPIDBachTR->Add(pidTRmassLambdaBarOfflineSgn);
1786       fOutputPIDBachTR->Add(pidTRmassLambdaBarOfflineBkg);
1787       fOutputPIDBachTR->Add(pidTRmassGammaOfflineSgn);
1788       fOutputPIDBachTR->Add(pidTRmassGammaOfflineBkg);
1789       fOutputPIDBachTR->Add(pidTRcosPAK0SOfflineSgn);
1790       fOutputPIDBachTR->Add(pidTRcosPAK0SOfflineBkg);
1791
1792     }
1793
1794   } // useMCinfo
1795
1796
1797   if (fTrackRotation) {
1798
1799     TH3F *phiVSthetaVSpt = new TH3F("phiVSthetaVSpt","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1800     TH3F *phiVSthetaVSptRot = new TH3F("phiVSthetaVSptRot","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1801     TH3F *phiVSthetaVSptOffline = new TH3F("phiVSthetaVSptOffline","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1802     TH3F *phiVSthetaVSptRotOffline = new TH3F("phiVSthetaVSptRotOffline","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1803     fOutputPIDBachTR->Add(phiVSthetaVSpt);
1804     fOutputPIDBachTR->Add(phiVSthetaVSptRot);
1805     fOutputPIDBachTR->Add(phiVSthetaVSptOffline);
1806     fOutputPIDBachTR->Add(phiVSthetaVSptRotOffline);
1807
1808     TH1F *hNormRotated=new TH1F("hNormRotated","",fNRotations+1,-0.5,fNRotations+0.5);
1809     TH1F *hNormRotatedOffline=new TH1F("hNormRotatedOffline","",fNRotations+1,-0.5,fNRotations+0.5);
1810     /*
1811     hNormRotated->Sumw2();
1812     hNormRotatedOffline->Sumw2();
1813  
1814     hNormRotated->SetMinimum(0);
1815     hNormRotatedOffline->SetMinimum(0);
1816     */
1817
1818     fOutputPIDBachTR->Add(hNormRotated);
1819     fOutputPIDBachTR->Add(hNormRotatedOffline);
1820
1821     if (fUseMCInfo) {
1822
1823       TH3F *phiVSthetaVSptSgn = new TH3F("phiVSthetaVSptSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1824       TH3F *phiVSthetaVSptRotSgn = new TH3F("phiVSthetaVSptRotSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1825       TH3F *phiVSthetaVSptOfflineSgn = new TH3F("phiVSthetaVSptOfflineSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1826       TH3F *phiVSthetaVSptRotOfflineSgn = new TH3F("phiVSthetaVSptRotOfflineSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1827       fOutputPIDBachTR->Add(phiVSthetaVSptSgn);
1828       fOutputPIDBachTR->Add(phiVSthetaVSptRotSgn);
1829       fOutputPIDBachTR->Add(phiVSthetaVSptOfflineSgn);
1830       fOutputPIDBachTR->Add(phiVSthetaVSptRotOfflineSgn);
1831
1832       TH3F *phiVSthetaVSptBkg = new TH3F("phiVSthetaVSptBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1833       TH3F *phiVSthetaVSptRotBkg = new TH3F("phiVSthetaVSptRotBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1834       TH3F *phiVSthetaVSptOfflineBkg = new TH3F("phiVSthetaVSptOfflineBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1835       TH3F *phiVSthetaVSptRotOfflineBkg = new TH3F("phiVSthetaVSptRotOfflineBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
1836       fOutputPIDBachTR->Add(phiVSthetaVSptBkg);
1837       fOutputPIDBachTR->Add(phiVSthetaVSptRotBkg);
1838       fOutputPIDBachTR->Add(phiVSthetaVSptOfflineBkg);
1839       fOutputPIDBachTR->Add(phiVSthetaVSptRotOfflineBkg);
1840
1841       TH1F *hNormRotatedSgn=new TH1F("hNormRotatedSgn","",fNRotations+1,-0.5,fNRotations+0.5);
1842       TH1F *hNormRotatedOfflineSgn=new TH1F("hNormRotatedOfflineSgn","",fNRotations+1,-0.5,fNRotations+0.5);
1843       TH1F *hNormRotatedBkg=new TH1F("hNormRotatedBkg","",fNRotations+1,-0.5,fNRotations+0.5);
1844       TH1F *hNormRotatedOfflineBkg=new TH1F("hNormRotatedOfflineBkg","",fNRotations+1,-0.5,fNRotations+0.5);
1845       /*
1846       hNormRotatedSgn->Sumw2();
1847       hNormRotatedOfflineSgn->Sumw2();
1848       hNormRotatedBkg->Sumw2();
1849       hNormRotatedOfflineBkg->Sumw2();
1850
1851       hNormRotatedSgn->SetMinimum(0);
1852       hNormRotatedOfflineSgn->SetMinimum(0);
1853       hNormRotatedBkg->SetMinimum(0);
1854       hNormRotatedOfflineBkg->SetMinimum(0);
1855       */
1856
1857       fOutputPIDBachTR->Add(hNormRotatedSgn);
1858       fOutputPIDBachTR->Add(hNormRotatedOfflineSgn);
1859       fOutputPIDBachTR->Add(hNormRotatedBkg);
1860       fOutputPIDBachTR->Add(hNormRotatedOfflineBkg);
1861
1862     }
1863
1864     Int_t nMassBins=(Int_t)(fMaxMass*1000.-fMinMass*1000.);
1865     Double_t maxm=fMinMass+nMassBins*0.001;
1866     TH3F *hMassVsPtVsY=new TH3F("hMassVsPtVsY","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1867     TH3F *hMassVsPtVsYOffline=new TH3F("hMassVsPtVsYOffline","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1868     /*
1869     hMassVsPtVsY->Sumw2();
1870     hMassVsPtVsYOffline->Sumw2();
1871
1872     hMassVsPtVsY->SetMinimum(0);
1873     hMassVsPtVsYOffline->SetMinimum(0);
1874     */
1875
1876     fOutputPIDBachTR->Add(hMassVsPtVsY);
1877     fOutputPIDBachTR->Add(hMassVsPtVsYOffline);
1878
1879     if (fUseMCInfo) {
1880
1881       TH3F *hMassVsPtVsYSgn=new TH3F("hMassVsPtVsYSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1882       TH3F *hMassVsPtVsYOfflineSgn=new TH3F("hMassVsPtVsYOfflineSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1883       TH3F *hMassVsPtVsYBkg=new TH3F("hMassVsPtVsYBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1884       TH3F *hMassVsPtVsYOfflineBkg=new TH3F("hMassVsPtVsYOfflineBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1885
1886       /*
1887       hMassVsPtVsYSgn->Sumw2();
1888       hMassVsPtVsYOfflineSgn->Sumw2();
1889       hMassVsPtVsYBkg->Sumw2();
1890       hMassVsPtVsYOfflineBkg->Sumw2();
1891
1892       hMassVsPtVsYSgn->SetMinimum(0);
1893       hMassVsPtVsYOfflineSgn->SetMinimum(0);
1894       hMassVsPtVsYBkg->SetMinimum(0);
1895       hMassVsPtVsYOfflineBkg->SetMinimum(0);
1896       */
1897
1898       fOutputPIDBachTR->Add(hMassVsPtVsYSgn);
1899       fOutputPIDBachTR->Add(hMassVsPtVsYOfflineSgn);
1900       fOutputPIDBachTR->Add(hMassVsPtVsYBkg);
1901       fOutputPIDBachTR->Add(hMassVsPtVsYOfflineBkg);
1902
1903     }
1904
1905     TH3F *hMassVsPtVsYRot=new TH3F("hMassVsPtVsYRot","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1906     TH3F *hMassVsPtVsYRotOffline=new TH3F("hMassVsPtVsYRotOffline","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1907     /*
1908     hMassVsPtVsYRot->Sumw2();
1909     hMassVsPtVsYRotOffline->Sumw2();
1910
1911     hMassVsPtVsYRot->SetMinimum(0);
1912     hMassVsPtVsYRotOffline->SetMinimum(0);
1913     */
1914
1915     fOutputPIDBachTR->Add(hMassVsPtVsYRot);
1916     fOutputPIDBachTR->Add(hMassVsPtVsYRotOffline);
1917
1918     if (fUseMCInfo) {
1919
1920       TH3F *hMassVsPtVsYRotSgn=new TH3F("hMassVsPtVsYRotSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1921       TH3F *hMassVsPtVsYRotOfflineSgn=new TH3F("hMassVsPtVsYRotOfflineSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1922       TH3F *hMassVsPtVsYRotBkg=new TH3F("hMassVsPtVsYRotBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1923       TH3F *hMassVsPtVsYRotOfflineBkg=new TH3F("hMassVsPtVsYRotOfflineBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
1924       /*
1925       hMassVsPtVsYRotSgn->Sumw2();
1926       hMassVsPtVsYRotOfflineSgn->Sumw2();
1927       hMassVsPtVsYRotBkg->Sumw2();
1928       hMassVsPtVsYRotOfflineBkg->Sumw2();
1929
1930       hMassVsPtVsYRotSgn->SetMinimum(0);
1931       hMassVsPtVsYRotOfflineSgn->SetMinimum(0);
1932       hMassVsPtVsYRotBkg->SetMinimum(0);
1933       hMassVsPtVsYRotOfflineBkg->SetMinimum(0);
1934       */
1935
1936       fOutputPIDBachTR->Add(hMassVsPtVsYRotSgn);
1937       fOutputPIDBachTR->Add(hMassVsPtVsYRotOfflineSgn);
1938       fOutputPIDBachTR->Add(hMassVsPtVsYRotBkg);
1939       fOutputPIDBachTR->Add(hMassVsPtVsYRotOfflineBkg);
1940
1941     }
1942
1943     TH1F *hDeltaMass=new TH1F("hDeltaMass","",100,-0.4,0.4);
1944     TH1F *hDeltaMassOffline=new TH1F("hDeltaMassOffline","",100,-0.4,0.4);
1945     /*
1946     hDeltaMass->Sumw2();
1947     hDeltaMassOffline->Sumw2();
1948
1949     hDeltaMass->SetMinimum(0);
1950     hDeltaMassOffline->SetMinimum(0);
1951     */
1952
1953     fOutputPIDBachTR->Add(hDeltaMass);
1954     fOutputPIDBachTR->Add(hDeltaMassOffline);
1955
1956     if (fUseMCInfo) {
1957
1958       TH1F *hDeltaMassSgn=new TH1F("hDeltaMassSgn","",100,-0.4,0.4);
1959       TH1F *hDeltaMassOfflineSgn=new TH1F("hDeltaMassOfflineSgn","",100,-0.4,0.4);
1960       TH1F *hDeltaMassBkg=new TH1F("hDeltaMassBkg","",100,-0.4,0.4);
1961       TH1F *hDeltaMassOfflineBkg=new TH1F("hDeltaMassOfflineBkg","",100,-0.4,0.4);
1962       /*
1963       hDeltaMassSgn->Sumw2();
1964       hDeltaMassOfflineSgn->Sumw2();
1965       hDeltaMassBkg->Sumw2();
1966       hDeltaMassOfflineBkg->Sumw2();
1967
1968       hDeltaMassSgn->SetMinimum(0);
1969       hDeltaMassOfflineSgn->SetMinimum(0);
1970       hDeltaMassBkg->SetMinimum(0);
1971       hDeltaMassOfflineBkg->SetMinimum(0);
1972       */
1973
1974       fOutputPIDBachTR->Add(hDeltaMassSgn);
1975       fOutputPIDBachTR->Add(hDeltaMassOfflineSgn);
1976       fOutputPIDBachTR->Add(hDeltaMassBkg);
1977       fOutputPIDBachTR->Add(hDeltaMassOfflineBkg);
1978
1979     }
1980
1981     /*
1982     Int_t binSparseDMassRot[5]={nMassBins,100,24,40,20};
1983     Double_t edgeLowSparseDMassRot[5]={fMinMass,-0.4,0.,-4.,0};
1984     Double_t edgeHighSparseDMassRot[5]={maxm,0.4,12.,4.,3.14};
1985     THnSparse *hDeltaMassFullAnalysis=new THnSparseF("hDeltaMassFullAnalysis","hDeltaMassFullAnalysis;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1986     THnSparse *hDeltaMassFullAnalysisOffline=new THnSparseF("fDeltaMassFullAnalysisOffline","hDeltaMassFullAnalysisOffline;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1987
1988     fOutputPIDBachTR->Add(hDeltaMassFullAnalysis);
1989     fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOffline);
1990
1991     if (fUseMCInfo) {
1992
1993     THnSparse *hDeltaMassFullAnalysisSgn=new THnSparseF("hDeltaMassFullAnalysisSgn","hDeltaMassFullAnalysisSgn;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1994     THnSparse *hDeltaMassFullAnalysisOfflineSgn=new THnSparseF("fDeltaMassFullAnalysisOfflineSgn","hDeltaMassFullAnalysisOfflineSgn;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1995
1996     THnSparse *hDeltaMassFullAnalysisBkg=new THnSparseF("hDeltaMassFullAnalysisBkg","hDeltaMassFullAnalysisBkg;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1997     THnSparse *hDeltaMassFullAnalysisOfflineBkg=new THnSparseF("fDeltaMassFullAnalysisOfflineBkg","hDeltaMassFullAnalysisOfflineBkg;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
1998
1999     fOutputPIDBachTR->Add(hDeltaMassFullAnalysisSgn);
2000     fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOfflineSgn);
2001     fOutputPIDBachTR->Add(hDeltaMassFullAnalysisBkg);
2002     fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOfflineBkg);
2003
2004     }
2005     */
2006
2007   }
2008
2009   /*
2010   fOutputAll->Print();
2011   fOutputPIDBach->Print();
2012   if (fTrackRotation) fOutputPIDBachTR->Print();
2013   */
2014   return;
2015 }
2016
2017 //---------------------------
2018 void AliAnalysisTaskSELc2V0bachelor::CheckEventSelection(AliAODEvent *aodEvent) {
2019   //
2020   // To fill control histograms
2021   //
2022
2023   TClonesArray *arrayLctopKos=0;
2024   if (!aodEvent){
2025     if(AODEvent() && IsStandardAOD()) {
2026       // In case there is an AOD handler writing a standard AOD, use the AOD 
2027       // event in memory rather than the input (ESD) event.    
2028       aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
2029       // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
2030       // have to taken from the AOD event hold by the AliAODExtension
2031       AliAODHandler* aodHandler = (AliAODHandler*) 
2032         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
2033
2034       if (aodHandler->GetExtensions()) {
2035         AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
2036         AliAODEvent *aodFromExt = ext->GetAOD();
2037         arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
2038       }
2039     }
2040   } else {
2041     arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
2042   }
2043
2044   Float_t zVertex = fVtx1->GetZ();
2045   TString titleVtx=fVtx1->GetTitle();
2046
2047   if (TMath::Abs(fBzkG)>=0.001) {
2048
2049     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ2")))->Fill(zVertex);
2050
2051     if (arrayLctopKos) {
2052
2053       if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ3")))->Fill(zVertex);
2054
2055       // mc analysis 
2056       TClonesArray *mcArray = 0;
2057       AliAODMCHeader *mcHeader=0;
2058
2059       if (fUseMCInfo) {
2060         // MC array need for maching
2061         mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2062
2063         if (mcArray) {
2064           // load MC header
2065           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ4")))->Fill(zVertex);
2066           mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
2067
2068           if (mcHeader && fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ5")))->Fill(zVertex);
2069
2070           // check on MC Lc Daughter
2071           if (fAdditionalChecks) {
2072             for (Int_t iii=0; iii<mcArray->GetEntries(); iii++)
2073               SearchLcDaughter(mcArray,iii);
2074           }
2075
2076         }
2077
2078       }
2079
2080       if (fVtx1->GetNContributors()>0) {
2081         if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ6")))->Fill(zVertex);
2082
2083         TString firedTriggerClasses = aodEvent->GetFiredTriggerClasses(); // trigger class
2084         ULong64_t fTriggerMask=AliVEvent::kAnyINT;
2085         Bool_t check1 = kFALSE;
2086         if ( !fUseMCInfo && // don't do for MC...
2087              (aodEvent->GetRunNumber()<136851 || aodEvent->GetRunNumber()>139517) ) { // ...and for PbPb 2010 data
2088           if ( !(firedTriggerClasses.Contains("CINT1")) ) {
2089             AliInfo(Form(" ======================== firedTriggerClasses.Data() = %s",firedTriggerClasses.Data()));
2090             fCEvents->Fill(8);
2091             if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ8")))->Fill(zVertex);
2092             check1 = kTRUE;
2093           }
2094         }
2095
2096         Bool_t isSelectedAAA = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
2097         if (!isSelectedAAA) {
2098           fCEvents->Fill(9);
2099           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ9")))->Fill(zVertex);
2100         }
2101
2102         if (!isSelectedAAA || check1) {
2103           fCEvents->Fill(16);
2104           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ16")))->Fill(zVertex);
2105         }
2106
2107         fTriggerMask=AliVEvent::kAny;
2108         Bool_t isSelectedBBB = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
2109         if (!isSelectedBBB) {
2110           fCEvents->Fill(10);
2111           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ10")))->Fill(zVertex);
2112         }
2113
2114         if (titleVtx.Contains("Z")) {
2115           fCEvents->Fill(11);
2116           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ11")))->Fill(zVertex);
2117         }
2118         else if (titleVtx.Contains("3D")) {
2119           fCEvents->Fill(12);
2120           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ12")))->Fill(zVertex);
2121         } else {
2122           fCEvents->Fill(13);
2123           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ13")))->Fill(zVertex);
2124         }
2125
2126         if (TMath::Abs(zVertex)<=fAnalCuts->GetMaxVtxZ()) {
2127           fCEvents->Fill(14);
2128           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ14")))->Fill(zVertex);
2129         }
2130
2131         if ( fIsEventSelected ) {
2132           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ7")))->Fill(zVertex);
2133         } else {
2134           fCEvents->Fill(15);
2135           if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ15")))->Fill(zVertex);
2136         }
2137
2138       } // nContributors>=1
2139     } // analysisArray exists
2140   } // magnetic field exists
2141
2142   return;
2143 }
2144
2145 //-----------------
2146 void AliAnalysisTaskSELc2V0bachelor::CheckEventSelectionWithCandidates(AliAODEvent *aodEvent) {
2147   //
2148   // To fill control histograms
2149   //
2150
2151   Float_t zVertex = fVtx1->GetZ();
2152   TString titleVtx=fVtx1->GetTitle();
2153   TString firedTriggerClasses = aodEvent->GetFiredTriggerClasses(); // trigger class
2154   ULong64_t fTriggerMask=AliVEvent::kAnyINT;
2155
2156   ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(6);
2157   if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ6a")))->Fill(zVertex);
2158
2159   Bool_t check1a = kFALSE;
2160   if ( !fUseMCInfo && // don't do for MC...
2161        (aodEvent->GetRunNumber()<136851 || aodEvent->GetRunNumber()>139517) ) { // ...and for PbPb 2010 data
2162     if ( !(firedTriggerClasses.Contains("CINT1")) ) {
2163       AliInfo(Form(" ======================== firedTriggerClasses.Data() = %s",firedTriggerClasses.Data()));
2164       ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(8);
2165       if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ8a")))->Fill(zVertex);
2166       check1a = kTRUE;
2167     }
2168   }
2169
2170   Bool_t isSelectedAAAa = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
2171   if (!isSelectedAAAa) {
2172     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(9);
2173     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ9a")))->Fill(zVertex);
2174   }
2175
2176   if (!isSelectedAAAa || check1a) {
2177     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(16);
2178     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ16a")))->Fill(zVertex);
2179   }
2180
2181   fTriggerMask=AliVEvent::kAny;
2182   Bool_t isSelectedBBBa = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
2183   if (!isSelectedBBBa) {
2184     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(10);
2185     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ10a")))->Fill(zVertex);
2186   }
2187
2188   if (titleVtx.Contains("Z")) {
2189     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(11);
2190     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ11a")))->Fill(zVertex);
2191   }
2192   else if (titleVtx.Contains("3D")) {
2193     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(12);
2194     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ12a")))->Fill(zVertex);
2195   } else {
2196     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(13);
2197     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ13a")))->Fill(zVertex);
2198   }
2199
2200   if (TMath::Abs(zVertex)<=fAnalCuts->GetMaxVtxZ()) {
2201     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(14);
2202     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ14a")))->Fill(zVertex);
2203   }
2204
2205   if ( fIsEventSelected ) {
2206     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(7);
2207     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ7a")))->Fill(zVertex);
2208   } else {
2209     ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(15);
2210     if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ15a")))->Fill(zVertex);
2211   }
2212
2213   return;
2214 }
2215
2216 //-----------------------------
2217 Int_t AliAnalysisTaskSELc2V0bachelor::MatchToMC(AliAODRecoCascadeHF *lc2bacV0,
2218                                                 Int_t *pdgDgLc2bacV0, Int_t *pdgDgV0,
2219                                                 TClonesArray *mcArray) {
2220   //
2221   // This is now implemented in AliAODRecoCascadeHF
2222   //
2223
2224   // bachelor
2225   AliAODTrack *bachelor = (AliAODTrack*)lc2bacV0->GetBachelor();
2226   if (!bachelor) return -1;
2227   Int_t labBachelor = TMath::Abs(bachelor->GetLabel());
2228   if (labBachelor<0) return -1;
2229   AliAODMCParticle *partBachelor = (AliAODMCParticle*)mcArray->At(labBachelor);
2230   if (!partBachelor) return -1;
2231   if (TMath::Abs(partBachelor->GetPdgCode())!=pdgDgLc2bacV0[0]) return -1;
2232
2233   Int_t labBacMother = partBachelor->GetMother();
2234   if (labBacMother<0) return -1;
2235   AliAODMCParticle *partBacMother = (AliAODMCParticle*)mcArray->At(labBacMother);
2236   if (!partBacMother) return -1;
2237   if (TMath::Abs(partBacMother->GetPdgCode())!=4122) return -1;
2238
2239   // V0
2240   AliAODTrack *posV0Daugh = (AliAODTrack*)lc2bacV0->Getv0PositiveTrack();
2241   AliAODTrack *negV0Daugh = (AliAODTrack*)lc2bacV0->Getv0NegativeTrack();
2242   if (!posV0Daugh || !negV0Daugh) return -1;
2243
2244   Int_t labV0pos = TMath::Abs(posV0Daugh->GetLabel());
2245   Int_t labV0neg = TMath::Abs(negV0Daugh->GetLabel());
2246   if (labV0pos<0 || labV0neg<0) return -1;
2247
2248   AliAODMCParticle *partV0pos = (AliAODMCParticle*)mcArray->At(labV0neg);
2249   AliAODMCParticle *partV0neg = (AliAODMCParticle*)mcArray->At(labV0pos);
2250   if (!partV0pos || !partV0neg) return -1;
2251
2252   if ( ! ( (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[0] &&
2253             TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[1]) ||
2254            (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[1] &&
2255             TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[0]) ) ) return -1;
2256   Int_t labV0posMother = partV0pos->GetMother();
2257   Int_t labV0negMother = partV0neg->GetMother();
2258
2259   if (labV0posMother<0 || labV0negMother<0) return -1;
2260   if (labV0posMother!=labV0negMother) return -1;
2261
2262   AliAODMCParticle *motherV0 = (AliAODMCParticle*)mcArray->At(labV0posMother);
2263   if (!motherV0) return-1;
2264
2265   if (TMath::Abs(motherV0->GetPdgCode())!=pdgDgLc2bacV0[1]) return -1;
2266   Int_t labV0mother = motherV0->GetMother();
2267   if (labV0mother<0) return -1;
2268   AliAODMCParticle *gMotherV0 = (AliAODMCParticle*)mcArray->At(labV0mother);
2269   if (!gMotherV0) return-1;
2270
2271   if ( !(pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) &&
2272        !(pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) ) return -1;
2273
2274   if ( (pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) ) {
2275     Int_t labV0GMother = gMotherV0->GetMother();
2276     if (labV0GMother<0) return -1;
2277     AliAODMCParticle *ggMotherV0 = (AliAODMCParticle*)mcArray->At(labV0GMother);
2278     if (!ggMotherV0) return-1;
2279
2280     if (TMath::Abs(ggMotherV0->GetPdgCode())!=4122) return -1;
2281     gMotherV0 = (AliAODMCParticle*)ggMotherV0;
2282     labV0mother=labV0GMother;
2283   }
2284   else if (pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) {
2285     if (TMath::Abs(gMotherV0->GetPdgCode())!=4122) return -1;
2286   }
2287
2288   if (labBacMother!=labV0mother) {
2289     return -1;
2290   }
2291
2292   return labBacMother;
2293
2294 }
2295
2296 //________________________________________________________________
2297 Int_t AliAnalysisTaskSELc2V0bachelor::SearchLcDaughter(TClonesArray *arrayMC, Int_t iii) {
2298   //
2299   // This is to check Lc dinasty
2300   //
2301
2302   Int_t indexToBeReturned=-999;
2303
2304   Int_t pdgLc=4122;
2305   Int_t pdgLambda=3122;
2306   Int_t pdgV0=310;
2307   Int_t pdgK0=311;
2308   Int_t pdgBachelor=2212;
2309   Int_t pdgBachelorPi=211;
2310
2311   TString fillthis="";
2312   fillthis="histMcStatLc";
2313
2314   AliAODMCParticle *searchLc = dynamic_cast<AliAODMCParticle*>(arrayMC->At(iii));
2315   if(!searchLc) return -999;
2316   if (TMath::Abs(searchLc->GetPdgCode()) != pdgLc) return -999;
2317
2318   ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(0);
2319   indexToBeReturned = 0;
2320
2321   ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*1);
2322   indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*1;
2323
2324   Int_t nDaughLc = searchLc->GetNDaughters();
2325   if (nDaughLc!=2) {
2326     ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*10);
2327     indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*10;
2328     return indexToBeReturned;
2329   }
2330
2331   Int_t index1=searchLc->GetDaughter(0);
2332   Int_t index2=searchLc->GetDaughter(1);
2333   if (index1<=0 || index2<=0) {
2334     return -999;
2335   }
2336
2337   AliAODMCParticle *daugh1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
2338   AliAODMCParticle *daugh2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
2339   if (!daugh1 || !daugh2) return -999;
2340
2341   Int_t daughPdg1 = TMath::Abs(daugh1->GetPdgCode());
2342   Int_t daughPdg2 = TMath::Abs(daugh2->GetPdgCode());
2343   if ( !( (daughPdg1==pdgBachelor && daughPdg2==pdgK0) ||
2344           (daughPdg2==pdgBachelor && daughPdg1==pdgK0) ||
2345           (daughPdg1==pdgLambda && daughPdg2==pdgBachelorPi) ||
2346           (daughPdg2==pdgLambda && daughPdg1==pdgBachelorPi) ) ) {
2347     ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*10);
2348     indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*10;
2349     return indexToBeReturned;
2350   }
2351
2352   if (daughPdg1==pdgK0 || daughPdg1==pdgLambda) {
2353     index1=searchLc->GetDaughter(1);
2354     index2=searchLc->GetDaughter(0);
2355   }
2356   daugh1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
2357   daugh2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
2358   if (!daugh1 || !daugh2) return -999;
2359
2360   daughPdg1=TMath::Abs(daugh1->GetPdgCode());
2361   daughPdg2=TMath::Abs(daugh2->GetPdgCode());
2362
2363   if ( daughPdg1==pdgBachelor && daughPdg2==pdgK0 ) { // Lc+ -> p K0bar
2364
2365     ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*2);
2366     indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*2;
2367
2368     Int_t nDaughK0 = daugh2->GetNDaughters();
2369     if (nDaughK0!=1) return -999;
2370
2371     Int_t indexK0daugh=daugh2->GetDaughter(0);
2372     if (indexK0daugh<=0) return -999;
2373
2374     AliAODMCParticle *daughK0 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(indexK0daugh));
2375     if (!daughK0) return -999;
2376
2377     Int_t daughK0Pdg=TMath::Abs(daughK0->GetPdgCode());
2378     if (daughK0Pdg!=pdgV0) {
2379       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*4); // K0L
2380       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*4;
2381       return indexToBeReturned;
2382     }
2383     ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*3); // K0S
2384     indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*3;
2385
2386     Int_t nDaughK0S = daughK0->GetNDaughters();
2387     if (nDaughK0S!=2) {
2388       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*5); // other decays for K0S
2389       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*5;
2390       return indexToBeReturned;
2391     }
2392
2393     index1=daughK0->GetDaughter(0);
2394     index2=daughK0->GetDaughter(1);
2395     if(index1<=0 || index2<=0) {
2396       return -999;
2397     }
2398
2399     AliAODMCParticle *daughK0S1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
2400     AliAODMCParticle *daughK0S2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
2401     if (!daughK0S1 || !daughK0S2) return -999;
2402
2403     Int_t daughK0S1pdg=TMath::Abs(daughK0S1->GetPdgCode());
2404     Int_t daughK0S2pdg=TMath::Abs(daughK0S2->GetPdgCode());
2405
2406     if ( daughK0S1pdg==211 && daughK0S2pdg==211 ) {
2407       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*6); // K0S -> pi+ pi-
2408       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*6;
2409     } else {
2410       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*5); // other decays for K0S
2411       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*5;
2412     }
2413
2414   } //if (daughPdg1==pdgBachelor && daughPdg2==pdgK0)
2415   else if ( daughPdg1==pdgBachelorPi && daughPdg2==pdgLambda ) { // Lc+ -> pi+ Lambda
2416
2417     ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*7);
2418     indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*7;
2419
2420     Int_t nDaughL = daugh2->GetNDaughters();
2421     if (nDaughL!=2) {
2422       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*8);
2423       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*8;
2424       return indexToBeReturned;
2425     }
2426
2427     index1=daugh2->GetDaughter(0);
2428     index2=daugh2->GetDaughter(1);
2429     if(index1<=0 || index2<=0) {
2430       return -999;
2431     }
2432
2433     AliAODMCParticle *daughL1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
2434     AliAODMCParticle *daughL2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
2435     if (!daughL1 || !daughL2) return -999;
2436
2437     Int_t daughL1pdg=TMath::Abs(daughL1->GetPdgCode());
2438     Int_t daughL2pdg=TMath::Abs(daughL2->GetPdgCode());
2439     if ( (daughL1pdg==211 && daughL2pdg==2212) ||
2440          (daughL2pdg==211 && daughL1pdg==2212) ) {
2441       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*9);
2442       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*9;
2443     } else {
2444       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*8);
2445       indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*8;
2446     }
2447
2448   } //else if (daughPdg1==pdgBachelorPi && daughPdg2==pdgLambda)
2449
2450   return indexToBeReturned;
2451 }
2452
2453 //________________________________________________________________
2454 void AliAnalysisTaskSELc2V0bachelor::FillArmPodDistribution(AliAODRecoDecay *vZero,
2455                                                             TString histoTitle,
2456                                                             Bool_t isCandidateSelectedCuts,
2457                                                             Bool_t isBachelorID) {
2458   //
2459   // This is to fill Armenteros Podolanski plots
2460   //
2461
2462   Double_t alpha = vZero->Alpha();//AlphaV0();
2463   Double_t qT    = vZero->QtProng();//PtArmV0();
2464
2465   ((TH2F*)(fOutputAll->FindObject(histoTitle+"0")))->Fill(alpha,qT);
2466   if (isCandidateSelectedCuts) {
2467     ((TH2F*)(fOutputAll->FindObject(histoTitle)))->Fill(alpha,qT);
2468     if (isBachelorID)
2469       ((TH2F*)(fOutputPIDBach->FindObject(histoTitle)))->Fill(alpha,qT);
2470   }
2471
2472 }
2473
2474 //-------------------------------------------------------------------------------
2475 void AliAnalysisTaskSELc2V0bachelor::CheckCandidatesAtDifferentLevels(AliAODRecoCascadeHF *part, AliRDHFCutsLctoV0* cutsAnal) {
2476   //
2477   // This is to check candidates at different levels
2478   //
2479
2480   Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
2481
2482   AliAODv0 * v0part = (AliAODv0*)part->Getv0();
2483   Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
2484
2485   AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
2486
2487   if ( !onFlyV0 )
2488     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(3); // it counts number of candidates coming from offline V0s
2489
2490   if ( cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122)) )
2491     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(4);
2492   if ( (((cutsAnal->IsSelected(part,AliRDHFCuts::kTracks))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) )
2493     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(5);
2494   cutsAnal->SetUsePID(kFALSE);
2495   if ( (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) )
2496     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(6);
2497   cutsAnal->SetUsePID(areCutsUsingPID);
2498   if ( (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) )
2499     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(7);
2500   if ( (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) )
2501     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(8);
2502   if ( (((cutsAnal->IsSelected(part,AliRDHFCuts::kAll))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) )
2503     ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(9);
2504
2505   if ( cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122)) ) {
2506
2507     if ( ( (cutsAnal->IsSelected(part,AliRDHFCuts::kTracks))&(AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr) ) {
2508
2509       Int_t aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kTracks);
2510       if ( (aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr ) {
2511         if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()==-1)  ||
2512              ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()==+1) )
2513           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates1")))->Fill( -aaa );
2514         else
2515           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates1")))->Fill( aaa );
2516       }
2517
2518       cutsAnal->SetUsePID(kFALSE);
2519       aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate);
2520       if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
2521         if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()==-1) ||
2522              ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()==+1) )
2523           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates2")))->Fill( -aaa );
2524         else
2525           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates2")))->Fill( aaa );
2526       }
2527       cutsAnal->SetUsePID(areCutsUsingPID);
2528
2529       aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kPID);
2530       if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
2531         if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()==-1) ||
2532              ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()==+1) )
2533           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates3")))->Fill( -aaa );
2534         else
2535           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates3")))->Fill( aaa );
2536       }
2537
2538       aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kAll);
2539       if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
2540         if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()==-1) ||
2541              ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()==+1) )
2542           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates4")))->Fill( -aaa );
2543         else
2544           ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates4")))->Fill( aaa );
2545       }
2546
2547     }
2548   }
2549
2550   return;
2551 }
2552
2553 //-------------------------------------------------------------------------------
2554 void AliAnalysisTaskSELc2V0bachelor::FillTheTree(AliAODRecoCascadeHF *part, AliRDHFCutsLctoV0 *cutsAnal, TClonesArray *mcArray, Int_t isLc) {
2555   //
2556   // This is to fill tree
2557   //
2558
2559   Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
2560   Double_t mLPDG   = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
2561
2562   Double_t invmassLc = part->InvMassLctoK0sP();
2563   Double_t invmassLc2Lpi = part->InvMassLctoLambdaPi();
2564
2565   AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
2566
2567   AliAODv0 * v0part = (AliAODv0*)part->Getv0();
2568   Double_t dcaV0ptp = v0part->GetDCA();
2569   Double_t invmassK0S = v0part->MassK0Short();
2570   Double_t invmassLambda = v0part->MassLambda();
2571   Double_t invmassLambdaBar = v0part->MassAntiLambda();
2572
2573   Int_t isLc2LBarpi=0, isLc2Lpi=0;
2574   Int_t mcLabel = -1;
2575   Int_t isDp2K0Spi=0, isDs2K0SK=0;
2576   Int_t mcLabel2 = -1;
2577   Int_t mcLabel3 = -1;
2578   Int_t isKstar12K0Spi=0, isKstar22K0Spi=0;
2579   Int_t mcLabel4 = -1;
2580   Int_t mcLabel5 = -1;
2581   Double_t ptCandByMC = 0.;//fmcPartCandidate->Pt();
2582   Double_t yCandByMC  = 0.;//fmcPartCandidate->Y();
2583   if (fUseMCInfo) {
2584     if (isLc) {
2585       Int_t pdgCand0 = 4122;
2586       Int_t pdgDgLctoV0bachelor0[2]={2212,310};
2587       Int_t pdgDgV0toDaughters0[2]={211,211};
2588       Int_t mcLabelLc2pK0S = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
2589       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabelLc2pK0S);
2590       if (lambdaCpartMC) {
2591         ptCandByMC = lambdaCpartMC->Pt();
2592         yCandByMC  = lambdaCpartMC->Y();
2593       }
2594     }
2595
2596     Int_t pdgCand = 4122;
2597     Int_t pdgDgLctoV0bachelor[2]={211,3122};
2598     Int_t pdgDgV0toDaughters[2]={2212,211};
2599     mcLabel = part->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE);
2600     if (mcLabel!=-1) {
2601       if (bachelor->Charge()==-1) isLc2LBarpi=1;
2602       if (bachelor->Charge()==+1) isLc2Lpi=1;
2603       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel);
2604       if (lambdaCpartMC) {
2605         ptCandByMC = lambdaCpartMC->Pt();
2606         yCandByMC  = lambdaCpartMC->Y();
2607       }
2608     }
2609
2610     Int_t pdgCand2 = 411; // D+ -> pi+ K0S
2611     Int_t pdgCand3 = 431; // Ds+ -> K+ K0S
2612     Int_t pdgDgCand2[2]={211,310};
2613     Int_t pdgDgCand3[2]={321,310};
2614     pdgDgV0toDaughters[0]=211;
2615     pdgDgV0toDaughters[1]=211;
2616     mcLabel2 = part->MatchToMC(pdgCand2,pdgDgCand2[1],pdgDgCand2,pdgDgV0toDaughters,mcArray,kTRUE);
2617     mcLabel3 = part->MatchToMC(pdgCand3,pdgDgCand3[1],pdgDgCand3,pdgDgV0toDaughters,mcArray,kTRUE);
2618     if (mcLabel2!=-1) {
2619       isDp2K0Spi=1;
2620       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel2);
2621       if (lambdaCpartMC) {
2622         ptCandByMC = lambdaCpartMC->Pt();
2623         yCandByMC  = lambdaCpartMC->Y();
2624       }
2625     }
2626     if (mcLabel3!=-1) {
2627       isDs2K0SK=1;
2628       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel3);
2629       if (lambdaCpartMC) {
2630         ptCandByMC = lambdaCpartMC->Pt();
2631         yCandByMC  = lambdaCpartMC->Y();
2632       }
2633     }
2634
2635     Int_t pdgCand4 = 313; // K*(892)+ -> pi+ K0S
2636     Int_t pdgCand5 = 325; // K*(1430)+ -> pi+ K0S
2637     Int_t pdgDgCand4[2]={211,310};
2638     Int_t pdgDgCand5[2]={211,310};
2639     pdgDgV0toDaughters[0]=211;
2640     pdgDgV0toDaughters[1]=211;
2641     mcLabel4 = part->MatchToMC(pdgCand4,pdgDgCand4[1],pdgDgCand4,pdgDgV0toDaughters,mcArray,kTRUE);
2642     mcLabel5 = part->MatchToMC(pdgCand5,pdgDgCand5[1],pdgDgCand5,pdgDgV0toDaughters,mcArray,kTRUE);
2643     if (mcLabel4!=-1) {
2644       isKstar12K0Spi=1;
2645       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel4);
2646       if (lambdaCpartMC) {
2647         ptCandByMC = lambdaCpartMC->Pt();
2648         yCandByMC  = lambdaCpartMC->Y();
2649       }
2650     }
2651     if (mcLabel5!=-1) {
2652       isKstar22K0Spi=1;
2653       AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel5);
2654       if (lambdaCpartMC) {
2655         ptCandByMC = lambdaCpartMC->Pt();
2656         yCandByMC  = lambdaCpartMC->Y();
2657       }
2658     }
2659   }
2660
2661   Int_t isLcByMC = isLc+isLc2LBarpi*2+isLc2Lpi*4+isDp2K0Spi*8+isDs2K0SK*16+isKstar12K0Spi*32+isKstar22K0Spi*64;
2662
2663   Bool_t isMCparticleInFiducialAcceptance = kTRUE;
2664   if (isLc || isLc2LBarpi || isLc2Lpi || isDp2K0Spi || isDs2K0SK || isKstar12K0Spi || isKstar22K0Spi) {
2665     isMCparticleInFiducialAcceptance = cutsAnal->IsInFiducialAcceptance(ptCandByMC,yCandByMC);
2666   }
2667
2668   Int_t isK0S = 0;
2669   Int_t isLambda = 0;
2670   Int_t isLambdaBar = 0;
2671   Int_t isGamma = 0;
2672   if (fUseMCInfo) {
2673     Int_t pdgDg2prong[2] = {211, 211};
2674     Int_t labelK0S = v0part->MatchToMC(310,mcArray,2,pdgDg2prong);
2675     if (labelK0S>=0) isK0S = 1;
2676
2677     pdgDg2prong[0] = 211;
2678     pdgDg2prong[1] = 2212;
2679     Int_t lambdaLabel = v0part->MatchToMC(3122,mcArray,2,pdgDg2prong);
2680     if (lambdaLabel>=0) {
2681       AliAODMCParticle *lambdaTrack = (AliAODMCParticle*)mcArray->At(lambdaLabel);
2682       if (lambdaTrack->GetPdgCode()==3122) isLambda = 1;
2683       else if (lambdaTrack->GetPdgCode()==-3122) isLambdaBar = 1;
2684     }
2685
2686     pdgDg2prong[0] = 11;
2687     pdgDg2prong[1] = 11;
2688     Int_t gammaLabel = v0part->MatchToMC(22,mcArray,2,pdgDg2prong);
2689     if (gammaLabel>=0) {
2690       AliAODMCParticle *gammaTrack = (AliAODMCParticle*)mcArray->At(gammaLabel);
2691       if (gammaTrack->GetPdgCode()==22) isGamma = 1;
2692     }
2693   }
2694
2695   Int_t isV0ByMC = isK0S+isLambdaBar*2+isLambda*4+isGamma*8;
2696
2697   Int_t isBachelorSelected = (bachelor->TestFilterMask(BIT(4)))*1 + (!(bachelor->TestFilterMask(BIT(4))))*2;
2698   isBachelorSelected += (bachelor->GetLabel()<0)*4 + (bachelor->GetLabel()>=0)*8;
2699   if ( ( !(bachelor->HasPointOnITSLayer(0)) && !(bachelor->HasPointOnITSLayer(1)) ) )
2700     isBachelorSelected += 16;
2701   else {
2702     if ( bachelor->HasPointOnITSLayer(0) && !(bachelor->HasPointOnITSLayer(1)) )
2703       isBachelorSelected += 32;
2704     else if ( !(bachelor->HasPointOnITSLayer(0)) && bachelor->HasPointOnITSLayer(1) )
2705       isBachelorSelected += 64;
2706     else
2707       isBachelorSelected += 128;
2708   }
2709
2710   AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
2711   AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
2712
2713   Int_t areV0daughtersSelected = (v0pos->TestFilterMask(BIT(4)))*1 + (!(v0pos->TestFilterMask(BIT(4))))*2;
2714   areV0daughtersSelected += (v0pos->GetLabel()<0)*4 + (v0pos->GetLabel()>=0)*8;
2715   areV0daughtersSelected += (v0neg->TestFilterMask(BIT(4)))*16 + (!(v0neg->TestFilterMask(BIT(4))))*32;
2716   areV0daughtersSelected += (v0neg->GetLabel()<0)*64 + (v0neg->GetLabel()>=0)*128;
2717
2718   Double_t nSigmaITSpr=-999.;
2719   cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,4,nSigmaITSpr);
2720   Double_t nSigmaTPCpr=-999.;
2721   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
2722   Double_t nSigmaTOFpr=-999.;
2723   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
2724
2725   Double_t nSigmaITSpi=-999.;
2726   cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,2,nSigmaITSpi);
2727   Double_t nSigmaTPCpi=-999.;
2728   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
2729   Double_t nSigmaTOFpi=-999.;
2730   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
2731
2732   Double_t nSigmaITSka=-999.;
2733   cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,3,nSigmaITSka);
2734   Double_t nSigmaTPCka=-999.;
2735   cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
2736   Double_t nSigmaTOFka=-999.;
2737   cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
2738
2739
2740   Int_t flagToCheckCandidate = 1*(TMath::Abs(invmassK0S-mk0sPDG)<=0.050);
2741   flagToCheckCandidate+=2*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()==-1));
2742   flagToCheckCandidate+=4*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()==+1));
2743   flagToCheckCandidate+=8*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()==+1));
2744   flagToCheckCandidate+=16*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()==-1));
2745
2746   /*
2747   Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
2748   cutsAnal->SetUsePID(kFALSE);
2749   Int_t aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate);
2750   if ( (aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr ) {
2751     if ( aaa==AliRDHFCutsLctoV0::kLcToK0Spr ) {
2752       flagToCheckCandidate = aaa; // Lc->K0S+p OK
2753     } else {
2754       if ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi ) {
2755         if (bachelor->Charge()==+1)
2756           flagToCheckCandidate = aaa; // Lc->Lambda+pi+
2757         else if (bachelor->Charge()==-1)
2758           flagToCheckCandidate =-aaa; // Lambda+pi- AS Lc->K0S+p candidate
2759       }
2760       if ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi ) {
2761         if (bachelor->Charge()==-1)
2762           flagToCheckCandidate = aaa; // Lc->LambdaBar+pi-
2763         else if (bachelor->Charge()==+1)
2764           flagToCheckCandidate =-aaa; // LambdaBar+pi+ AS Lc->K0S+p candidate
2765       }
2766     }
2767   } else {
2768     //if ( aaa==AliRDHFCutsLctoV0::kLcToK0Spr ) {
2769     //flagToCheckCandidate = -10-(AliRDHFCutsLctoV0::kLcToK0Spr); // NEVER
2770     //} else {
2771       if ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi ) {
2772         if (bachelor->Charge()==+1)
2773           flagToCheckCandidate = aaa; // Lc->Lambda+pi+ OK
2774         else if (bachelor->Charge()==-1)
2775           flagToCheckCandidate =-aaa; // Lambda+pi- AS Lc->Lambda+pi+ candidate
2776       }
2777       if ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi ) {
2778         if (bachelor->Charge()==-1)
2779           flagToCheckCandidate = aaa; // Lc->LambdaBar+pi- OK
2780         else if (bachelor->Charge()==+1)
2781           flagToCheckCandidate =-aaa; // LambdaBar+pi+ AS Lc->LambdaBar+pi- candidate
2782       }
2783       //}
2784   }
2785   cutsAnal->SetUsePID(areCutsUsingPID);
2786   */
2787
2788   fCandidateVariables[ 0] = fUseMCInfo+isLcByMC; // 0: real data; 1: bkg; 2: Lc->K0S+p; 3: Lc->LambdaBar+pbar; 5: Lc->Lambda+p; 9: D+->K0S+pi; 17: Ds+->K0S+K; 33: K*+->K0S+pi; 65: K*+->K0S+K
2789   fCandidateVariables[ 1] = fUseMCInfo+isV0ByMC; // 0: real data; 1: bkg; 2: K0S->pi+pi; 3: LambdaBar->pbar+pi+; 5: Lambda->p+pi-
2790   fCandidateVariables[ 2] = isBachelorSelected;
2791   fCandidateVariables[ 3] = areV0daughtersSelected;
2792   fCandidateVariables[ 4] = flagToCheckCandidate;
2793   fCandidateVariables[ 5] = invmassLc;
2794   fCandidateVariables[ 6] = invmassLc2Lpi;
2795   fCandidateVariables[ 7] = part->InvMass2Prongs(0,1,211,310); // D+ -> pi+ K0S
2796   fCandidateVariables[ 8] = part->InvMass2Prongs(0,1,321,310); // D+S -> K+ K0S
2797   fCandidateVariables[ 9] = invmassK0S;
2798   fCandidateVariables[10] = invmassLambda;
2799   fCandidateVariables[11] = invmassLambdaBar;
2800   fCandidateVariables[12] = v0part->InvMass2Prongs(0,1,11,11);
2801   fCandidateVariables[13] = part->GetDCA();
2802   fCandidateVariables[14] = dcaV0ptp;
2803   fCandidateVariables[15] = part->Getd0Prong(0);
2804   fCandidateVariables[16] = part->Getd0Prong(1);
2805   fCandidateVariables[17] = v0part->Getd0Prong(0);
2806   fCandidateVariables[18] = v0part->Getd0Prong(1);
2807   fCandidateVariables[19] = part->CosPointingAngle();
2808   fCandidateVariables[20] = part->CosV0PointingAngle();
2809   fCandidateVariables[21] = v0part->RadiusSecVtx();
2810   fCandidateVariables[22] = nSigmaITSpr;
2811   fCandidateVariables[23] = nSigmaITSpi;
2812   fCandidateVariables[24] = nSigmaITSka;
2813   fCandidateVariables[25] = nSigmaTPCpr;
2814   fCandidateVariables[26] = nSigmaTPCpi;
2815   fCandidateVariables[27] = nSigmaTPCka;
2816   fCandidateVariables[28] = nSigmaTOFpr;
2817   fCandidateVariables[29] = nSigmaTOFpi;
2818   fCandidateVariables[30] = nSigmaTOFka;
2819   fCandidateVariables[31] = part->Y(4122);
2820   fCandidateVariables[32] = bachelor->Eta();
2821   fCandidateVariables[33] = v0pos->Eta();
2822   fCandidateVariables[34] = v0neg->Eta();
2823   fCandidateVariables[35] = part->P();
2824   fCandidateVariables[36] = part->Pt();
2825   fCandidateVariables[37] = v0part->P();
2826   fCandidateVariables[38] = v0part->Pt();
2827   fCandidateVariables[39] = bachelor->P();
2828   fCandidateVariables[40] = bachelor->Pt();
2829   fCandidateVariables[41] = v0pos->P();
2830   fCandidateVariables[42] = v0pos->Pt();
2831   fCandidateVariables[43] = v0neg->P();
2832   fCandidateVariables[44] = v0neg->Pt();
2833   fCandidateVariables[45] = part->DecayLength();
2834   fCandidateVariables[46] = part->DecayLengthV0();
2835   fCandidateVariables[47] = part->CosPointingAngleXY();
2836   fCandidateVariables[48] = part->CosV0PointingAngleXY();
2837   fCandidateVariables[49] = part->DecayLengthXY();
2838   fCandidateVariables[50] = part->DecayLengthXYV0();
2839   fCandidateVariables[51] = part->NormalizedDecayLength();
2840   fCandidateVariables[52] = part->NormalizedV0DecayLength();
2841   fCandidateVariables[53] = part->NormalizedDecayLengthXY();
2842   fCandidateVariables[54] = part->NormalizedV0DecayLengthXY();
2843   Double_t xVtxLc=0, yVtxLc=0, zVtxLc=0;
2844   Double_t xLcMC=0,yLcMC=0,zLcMC=0;
2845   Double_t pxVtxBachelor=0, pyVtxBachelor=0, pzVtxBachelor=0;
2846   Double_t dcaForLc = PropagateToDCA(v0part,bachelor,fBzkG, xVtxLc, yVtxLc, zVtxLc, pxVtxBachelor, pyVtxBachelor, pzVtxBachelor);
2847   if (isLc) {
2848     Int_t pdgCand0 = 4122;
2849     Int_t pdgDgLctoV0bachelor0[2]={2212,310};
2850     Int_t pdgDgV0toDaughters0[2]={211,211};
2851     Int_t mcLabel0 = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
2852     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel0));
2853     if(partLc){
2854       AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2855       if(partLcDaug0){
2856         xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2857       }
2858     }
2859   } else if (isLc2LBarpi || isLc2Lpi) {
2860     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
2861     AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2862     xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2863   } else if (isDp2K0Spi) {
2864     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel2));
2865     AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2866     xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2867   } else if (isDs2K0SK) {
2868     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel3));
2869     AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2870     xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2871   } else if (isKstar12K0Spi) {
2872     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel4));
2873     AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2874     xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2875   } else if (isKstar22K0Spi) {
2876     AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel5));
2877     AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
2878     xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
2879   }
2880   fCandidateVariables[55]=dcaForLc;
2881   fCandidateVariables[56]=part->GetSecVtxX();
2882   fCandidateVariables[57]=part->GetSecVtxY();
2883   fCandidateVariables[58]=part->GetSecVtxZ();
2884   fCandidateVariables[59]=xVtxLc;
2885   fCandidateVariables[60]=yVtxLc;
2886   fCandidateVariables[61]=zVtxLc;
2887   fCandidateVariables[62]=xLcMC;
2888   fCandidateVariables[63]=yLcMC;
2889   fCandidateVariables[64]=zLcMC;
2890   fCandidateVariables[65]=bachelor->Px();
2891   fCandidateVariables[66]=bachelor->Py();
2892   fCandidateVariables[67]=pxVtxBachelor;
2893   fCandidateVariables[68]=pyVtxBachelor;
2894   fCandidateVariables[69]=v0part->Px();
2895   fCandidateVariables[70]=v0part->Py();
2896   fCandidateVariables[71]=fVtx1->GetX();
2897   fCandidateVariables[72]=fVtx1->GetY();
2898   fCandidateVariables[73]=fVtx1->GetZ();
2899   fCandidateVariables[74]=part->CosThetaStar(0,4122,2212,310);
2900   fCandidateVariables[75]=part->CosThetaStar(1,4122,2212,310);
2901   fCandidateVariables[76]=v0part->Eta();
2902   fCandidateVariables[77]=v0part->Y(310);
2903   fCandidateVariables[78]=pzVtxBachelor;
2904   fCandidateVariables[79]=v0part->Pz();
2905   fCandidateVariables[80]=bachelor->Charge();
2906   fCandidateVariables[81]=isMCparticleInFiducialAcceptance;
2907   if (fUseMCInfo) {
2908     fCandidateVariables[82]=0;
2909     if (bachelor->GetLabel()!=-1) {
2910       AliAODMCParticle *partBachelor = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(bachelor->GetLabel())));
2911       if(partBachelor) fCandidateVariables[82]=partBachelor->GetPdgCode();
2912     }
2913   } else {
2914     fCandidateVariables[82]=-1;
2915   }
2916   fCandidateVariables[83] = part->InvMass2Prongs(0,1,211,310); // Kstar( 892)+ -> pi+K0S
2917   fCandidateVariables[84] = part->InvMass2Prongs(0,1,321,310); // Kstar(1430)+ -> pi+K0S
2918
2919   fCandidateVariables[85]=0;
2920   fCandidateVariables[86]=0;
2921   fCandidateVariables[87]=0;
2922   fCandidateVariables[88]=0;
2923   if (fUseMCInfo) {
2924     if (v0pos->GetLabel()!=-1 &&
2925         v0neg->GetLabel()!=-1) {
2926       const Int_t ndg=2;
2927       Int_t dgLabels[ndg]={TMath::Abs(v0pos->GetLabel()),
2928                            TMath::Abs(v0neg->GetLabel())};
2929       Int_t ndgCk=0;
2930       Int_t *pdgDg=0;
2931       Int_t absLabelMother=-1;
2932       Int_t nDauCand=-1;
2933       fCandidateVariables[88]=SearchForCommonMother(mcArray,
2934                                                     dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
2935     }
2936     if (bachelor->GetLabel()!=-1 &&
2937         v0pos->GetLabel()!=-1 &&
2938         v0neg->GetLabel()!=-1) {
2939       const Int_t ndg=3;
2940       Int_t dgLabels[ndg]={TMath::Abs(bachelor->GetLabel()),
2941                            TMath::Abs(v0pos->GetLabel()),
2942                            TMath::Abs(v0neg->GetLabel())};
2943       Int_t ndgCk=0;
2944       Int_t *pdgDg=0;
2945       Int_t absLabelMother=-1;
2946       Int_t nDauCand=-1;
2947       fCandidateVariables[85]=SearchForCommonMother(mcArray,
2948                                                     dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
2949       AliAODMCParticle *part1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0pos->GetLabel())));
2950       AliAODMCParticle *part2 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0neg->GetLabel())));
2951       if(part1) fCandidateVariables[86]=part1->GetPdgCode();
2952       if(part2) fCandidateVariables[87]=part2->GetPdgCode();
2953     }
2954   }
2955
2956   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
2957   AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
2958   AliPIDResponse *pidResponse=inputHandler->GetPIDResponse();
2959   fCandidateVariables[89]=pidResponse->GetTOFResponse().GetStartTimeMask(bachelor->P());
2960
2961   //fCandidateVariables[65] = bachelor->Px();
2962   //fCandidateVariables[66] = bachelor->Py();
2963   //fCandidateVariables[67] = bachelor->Pz();
2964   //fCandidateVariables[68] = v0pos->Px();
2965   //fCandidateVariables[69] = v0pos->Py();
2966   //fCandidateVariables[70] = v0pos->Pz();
2967   //fCandidateVariables[71] = v0neg->Px();
2968   //fCandidateVariables[72] = v0neg->Py();
2969   //fCandidateVariables[73] = v0neg->Pz();
2970   //fCandidateVariables[74] = part->PxProng(0);
2971   //fCandidateVariables[75] = part->PyProng(0);
2972   //fCandidateVariables[76] = part->PzProng(0);
2973   //fCandidateVariables[77] = part->PxProng(1);
2974   //fCandidateVariables[78] = part->PyProng(1);
2975   //fCandidateVariables[79] = part->PzProng(1);
2976   //fCandidateVariables[80] = v0part->PxProng(0);
2977   //fCandidateVariables[81] = v0part->PyProng(0);
2978   //fCandidateVariables[82] = v0part->PzProng(0);
2979   //fCandidateVariables[83] = v0part->PxProng(1);
2980   //fCandidateVariables[84] = v0part->PyProng(1);
2981   //fCandidateVariables[85] = v0part->PzProng(1);
2982   //fCandidateVariables[86] = part->QtProng(0);
2983   //fCandidateVariables[87] = part->Alpha();
2984
2985   fVariablesTree->Fill();
2986
2987   return;
2988 }
2989
2990 //-------------------------------------------------------------------------------
2991 void AliAnalysisTaskSELc2V0bachelor::DefineTreeVariables() {
2992   //
2993   // This is to define tree variables
2994   //
2995
2996   const char* nameoutput = GetOutputSlot(4)->GetContainer()->GetName();
2997   fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
2998   Int_t nVar = 90;
2999   fCandidateVariables = new Float_t [nVar];
3000   TString * fCandidateVariableNames = new TString[nVar];
3001   fCandidateVariableNames[ 0]="isLcByMC";
3002   fCandidateVariableNames[ 1]="isV0ByMC";
3003   fCandidateVariableNames[ 2]="flagToCheckBachelor";
3004   fCandidateVariableNames[ 3]="flagToCheckV0daughters";
3005   fCandidateVariableNames[ 4]="flagToCheckCandidate";
3006   fCandidateVariableNames[ 5]="massLc2K0Sp";
3007   fCandidateVariableNames[ 6]="massLc2Lambdapi";
3008   fCandidateVariableNames[ 7]="massD2K0Spi"; // D+ -> pi+ K0S
3009   fCandidateVariableNames[ 8]="massDS2K0SK"; // D+S -> K+ K0S
3010   fCandidateVariableNames[ 9]="massK0S";
3011   fCandidateVariableNames[10]="massLambda";
3012   fCandidateVariableNames[11]="massLambdaBar";
3013   fCandidateVariableNames[12]="massGamma";
3014   fCandidateVariableNames[13]="dcaLcptp"; // DCA Lc prong-to-prong
3015   fCandidateVariableNames[14]="dcaV0ptp";
3016   fCandidateVariableNames[15]="tImpParBach";
3017   fCandidateVariableNames[16]="tImpParV0";
3018   fCandidateVariableNames[17]="dcaV0postoPV";
3019   fCandidateVariableNames[18]="dcaV0negtoPV";
3020   fCandidateVariableNames[19]="cosPALc";
3021   fCandidateVariableNames[20]="cosPAK0S";
3022   fCandidateVariableNames[21]="rhoV0";
3023   fCandidateVariableNames[22]="nSigmaITSpr";
3024   fCandidateVariableNames[23]="nSigmaITSpi";
3025   fCandidateVariableNames[24]="nSigmaITSka";
3026   fCandidateVariableNames[25]="nSigmaTPCpr";
3027   fCandidateVariableNames[26]="nSigmaTPCpi";
3028   fCandidateVariableNames[27]="nSigmaTPCka";
3029   fCandidateVariableNames[28]="nSigmaTOFpr";
3030   fCandidateVariableNames[29]="nSigmaTOFpi";
3031   fCandidateVariableNames[30]="nSigmaTOFka";
3032   fCandidateVariableNames[31]="yLc";
3033   fCandidateVariableNames[32]="etaBach"; // etaBachelor
3034   fCandidateVariableNames[33]="etaV0pos"; // etaV0pos
3035   fCandidateVariableNames[34]="etaV0neg"; // etaV0neg
3036   fCandidateVariableNames[35]="LcP"; // @ DCA
3037   fCandidateVariableNames[36]="LcPt"; // @ DCA
3038   fCandidateVariableNames[37]="v0P"; // @ V0 DCA
3039   fCandidateVariableNames[38]="v0Pt"; // @ V0 DCA
3040   fCandidateVariableNames[39]="bachelorP"; // @ prim vtx
3041   fCandidateVariableNames[40]="bachelorPt"; // @ prim vtx
3042   fCandidateVariableNames[41]="V0positiveP"; // @ prim vtx
3043   fCandidateVariableNames[42]="V0positivePt"; // @ prim vtx
3044   fCandidateVariableNames[43]="V0negativeP"; // @ prim vtx
3045   fCandidateVariableNames[44]="V0negativePt"; // @ prim vtx
3046   fCandidateVariableNames[45]="decayLengthLc";
3047   fCandidateVariableNames[46]="decayLengthV0";
3048   fCandidateVariableNames[47]="cosPALcXY"; // cosPA XY x Lc
3049   fCandidateVariableNames[48]="cosPAV0XY"; // cosPA XY x V0
3050   fCandidateVariableNames[49]="decayLengthLcXY"; // decay length XY x Lc
3051   fCandidateVariableNames[50]="decayLengthV0XY"; // decay length XY x V0
3052   fCandidateVariableNames[51]="normalizedDecayLengthLc"; // normalized decay length x Lc
3053   fCandidateVariableNames[52]="normalizedDecayLengthV0"; // normalized decay length x V0
3054   fCandidateVariableNames[53]="normalizedDecayLengthXYLc"; // normalized decay length XY x Lc
3055   fCandidateVariableNames[54]="normalizedDecayLengthXYV0"; // normalized decay length XY x V0
3056   fCandidateVariableNames[55]="newLcDCA";
3057   fCandidateVariableNames[56]="xVtxLcBad";
3058   fCandidateVariableNames[57]="yVtxLcBad";
3059   fCandidateVariableNames[58]="zVtxLcBad";
3060   fCandidateVariableNames[59]="xVtxLcGood";
3061   fCandidateVariableNames[60]="yVtxLcGood";
3062   fCandidateVariableNames[61]="zVtxLcGood";
3063   fCandidateVariableNames[62]="xVtxLcMC";
3064   fCandidateVariableNames[63]="yVtxLcMC";
3065   fCandidateVariableNames[64]="zVtxLcMC";
3066   fCandidateVariableNames[65]="pxVtxBachelorBad";
3067   fCandidateVariableNames[66]="pyVtxBachelorBad";
3068   fCandidateVariableNames[67]="pxVtxBachelorGood";
3069   fCandidateVariableNames[68]="pyVtxBachelorGood";
3070   fCandidateVariableNames[69]="pxVtxV0";
3071   fCandidateVariableNames[70]="pyVtxV0";
3072   fCandidateVariableNames[71]="xPvtx";
3073   fCandidateVariableNames[72]="yPvtx";
3074   fCandidateVariableNames[73]="zPvtx";
3075   fCandidateVariableNames[74]="cosThetaStarBachelor";
3076   fCandidateVariableNames[75]="cosThetaStarV0";
3077   fCandidateVariableNames[76]="etaV0";
3078   fCandidateVariableNames[77]="yV0";
3079   fCandidateVariableNames[78]="pzVtxBachelorGood";
3080   fCandidateVariableNames[79]="pzVtxV0";
3081   fCandidateVariableNames[80]="bachelorCharge";
3082   fCandidateVariableNames[81]="isMCparticleInFiducialAcceptance";
3083   fCandidateVariableNames[82]="pdgBachelor"; // pdg MC bachelor
3084   fCandidateVariableNames[83]="massKstar12K0Spi"; // Kstar( 892)+ -> pi+ K0S
3085   fCandidateVariableNames[84]="massKstar22K0Spi"; // Kstar(1430)+ -> pi+ K0S
3086   fCandidateVariableNames[85]="pdgCandidate"; // pdg MC candidate recovered via new method
3087   fCandidateVariableNames[86]="pdgV0pos"; // pdg MC V0 positive
3088   fCandidateVariableNames[87]="pdgV0neg"; // pdg MC V0 negative
3089   fCandidateVariableNames[88]="pdgV0Candidate"; // pdg MC V0candidate recovered via new method
3090   fCandidateVariableNames[89]="startTimeMask"; // start time mask
3091
3092   //fCandidateVariableNames[65]="bachelorPx";
3093   //fCandidateVariableNames[66]="bachelorPy";
3094   //fCandidateVariableNames[67]="bachelorPz";
3095   //fCandidateVariableNames[68]="V0positivePx";
3096   //fCandidateVariableNames[69]="V0positivePy";
3097   //fCandidateVariableNames[70]="V0positivePz";
3098   //fCandidateVariableNames[71]="V0negativePx";
3099   //fCandidateVariableNames[72]="V0negativePy";
3100   //fCandidateVariableNames[73]="V0negativePz";
3101   //fCandidateVariableNames[74]="bachelorPxDCA";
3102   //fCandidateVariableNames[75]="bachelorPyDCA";
3103   //fCandidateVariableNames[76]="bachelorPzDCA";
3104   //fCandidateVariableNames[77]="v0PxDCA";
3105   //fCandidateVariableNames[78]="v0PyDCA";
3106   //fCandidateVariableNames[79]="v0PzDCA";
3107   //fCandidateVariableNames[80]="V0positivePxDCA";
3108   //fCandidateVariableNames[81]="V0positivePyDCA";
3109   //fCandidateVariableNames[82]="V0positivePzDCA";
3110   //fCandidateVariableNames[83]="V0negativePxDCA";
3111   //fCandidateVariableNames[84]="V0negativePyDCA";
3112   //fCandidateVariableNames[85]="V0negativePzDCA";
3113   //fCandidateVariableNames[86]="qtLc";
3114   //fCandidateVariableNames[87]="alphaLc";
3115
3116   for (Int_t ivar=0; ivar<nVar; ivar++) {
3117     fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
3118   }
3119
3120   return;
3121 }
3122
3123 //__________________________________________________________________________
3124 void  AliAnalysisTaskSELc2V0bachelor::DefineGeneralHistograms() {
3125   //
3126   // This is to define general histograms
3127   //
3128
3129   fCEvents = new TH1F("fCEvents","conter",18,0,18);
3130   fCEvents->SetStats(kTRUE);
3131   fCEvents->GetXaxis()->SetBinLabel(1,"X1");
3132   fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
3133   fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
3134   fCEvents->GetXaxis()->SetBinLabel(4,"CascadesHF exists");
3135   fCEvents->GetXaxis()->SetBinLabel(5,"MCarray exists");
3136   fCEvents->GetXaxis()->SetBinLabel(6,"MCheader exists");
3137   fCEvents->GetXaxis()->SetBinLabel(7,"GetNContributors()>0");
3138   fCEvents->GetXaxis()->SetBinLabel(8,"IsEventSelected");
3139   fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
3140   fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
3141   fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
3142   fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
3143   fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
3144   fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
3145   fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
3146   fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
3147   fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
3148   fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
3149   //fCEvents->GetXaxis()->SetTitle("");
3150   fCEvents->GetYaxis()->SetTitle("counts");
3151
3152   fOutput->Add(fCEvents);
3153   TString fillthis="";
3154
3155   if (fUseMCInfo && fAdditionalChecks) {
3156     fillthis="histMcStatLc";
3157     TH1F* mcStatisticLc = new TH1F(fillthis.Data(),"#Lambda_{c} generated and their decays",21,-10.5,10.5);
3158     fOutput->Add(mcStatisticLc);
3159   }
3160
3161   //fillthis="histopionV0SigmaVspTOF";
3162   //TH2F *hpionV0SigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
3163   fillthis="histoprotonBachSigmaVspTOF";
3164   TH2F *hprotonBachSigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
3165
3166   //fOutput->Add(hpionV0SigmaVspTOF);
3167   fOutput->Add(hprotonBachSigmaVspTOF);
3168
3169   //fillthis="histopionV0SigmaVspTPC";
3170   //TH2F *hpionV0SigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);