Cleaning up files, added documentation. Added ntuple for v0s.
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliAnalysisTaskGammaConversion.cxx
index f6edf1f..5df0c83 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
  *                                                                        *\r
  * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *\r
- * Version 1.0                                                            *\r
+ * Version 1.1                                                            *\r
  *                                                                        *\r
  * Permission to use, copy, modify and distribute this software and its   *\r
  * documentation strictly for non-commercial purposes is hereby granted   *\r
@@ -64,7 +64,11 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
   fGammaWidth(-1),\r
   fPi0Width(-1),\r
   fEtaWidth(-1),\r
-  fCalculateBackground(kFALSE)\r
+  fCalculateBackground(kFALSE),\r
+  fWriteNtuple(kFALSE),\r
+  fGammaNtuple(NULL),\r
+  fNeutralMesonNtuple(NULL),\r
+  fTotalNumberOfAddedNtupleEntries(0)\r
 {\r
   // Default constructor\r
   // Common I/O in slot 0\r
@@ -94,7 +98,11 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
   fGammaWidth(-1),\r
   fPi0Width(-1),\r
   fEtaWidth(-1),\r
-  fCalculateBackground(kFALSE)\r
+  fCalculateBackground(kFALSE),\r
+  fWriteNtuple(kFALSE),\r
+  fGammaNtuple(NULL),\r
+  fNeutralMesonNtuple(NULL),\r
+  fTotalNumberOfAddedNtupleEntries(0)\r
 {\r
   // Common I/O in slot 0\r
   DefineInput (0, TChain::Class());\r
@@ -380,9 +388,62 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
   }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)\r
 } // end ProcessMCData\r
 \r
+void AliAnalysisTaskGammaConversion::FillNtuple(){\r
+\r
+  if(fGammaNtuple == NULL){\r
+    return;\r
+  }\r
+  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();\r
+  for(Int_t i=0;i<numberOfV0s;i++){\r
+    Float_t values[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
+    AliESDv0 * cV0 = fV0Reader->GetV0(i);\r
+    Double_t negPID=0;\r
+    Double_t posPID=0;\r
+    fV0Reader->GetPIDProbability(negPID,posPID);\r
+    values[0]=cV0->GetOnFlyStatus();\r
+    values[1]=fV0Reader->CheckForPrimaryVertex();\r
+    values[2]=negPID;\r
+    values[3]=posPID;\r
+    values[4]=fV0Reader->GetX();\r
+    values[5]=fV0Reader->GetY();\r
+    values[6]=fV0Reader->GetZ();\r
+    values[7]=fV0Reader->GetXYRadius();\r
+    values[8]=fV0Reader->GetMotherCandidateNDF();\r
+    values[9]=fV0Reader->GetMotherCandidateChi2();\r
+    values[10]=fV0Reader->GetMotherCandidateEnergy();\r
+    values[11]=fV0Reader->GetMotherCandidateEta();\r
+    values[12]=fV0Reader->GetMotherCandidatePt();\r
+    values[13]=fV0Reader->GetMotherCandidateMass();\r
+    values[14]=fV0Reader->GetMotherCandidateWidth();\r
+    //    values[15]=fV0Reader->GetMotherMCParticle()->Pt();   MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array\r
+    values[16]=fV0Reader->GetOpeningAngle();\r
+    values[17]=fV0Reader->GetNegativeTrackEnergy();\r
+    values[18]=fV0Reader->GetNegativeTrackPt();\r
+    values[19]=fV0Reader->GetNegativeTrackEta();\r
+    values[20]=fV0Reader->GetNegativeTrackPhi();\r
+    values[21]=fV0Reader->GetPositiveTrackEnergy();\r
+    values[22]=fV0Reader->GetPositiveTrackPt();\r
+    values[23]=fV0Reader->GetPositiveTrackEta();\r
+    values[24]=fV0Reader->GetPositiveTrackPhi();\r
+    values[25]=fV0Reader->HasSameMCMother();\r
+    if(values[25] != 0){\r
+      values[26]=fV0Reader->GetMotherMCParticlePDGCode();\r
+      values[15]=fV0Reader->GetMotherMCParticle()->Pt();\r
+    }\r
+    fTotalNumberOfAddedNtupleEntries++;\r
+    fGammaNtuple->Fill(values);\r
+  }\r
+  fV0Reader->ResetV0IndexNumber();\r
+  \r
+}\r
+\r
 void AliAnalysisTaskGammaConversion::ProcessV0s(){\r
   // see header file for documentation\r
 \r
+  if(fWriteNtuple == kTRUE){\r
+    FillNtuple();\r
+  }\r
+\r
   Int_t nSurvivingV0s=0;\r
   while(fV0Reader->NextV0()){\r
     nSurvivingV0s++;\r
@@ -606,7 +667,24 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
   if(fOutputContainer == NULL){\r
     fOutputContainer = new TList();\r
   }\r
+  \r
+  //Adding the histograms to the output container\r
   fHistograms->GetOutputContainer(fOutputContainer);\r
+\r
+  \r
+  if(fWriteNtuple){\r
+    if(fGammaNtuple == NULL){\r
+      fGammaNtuple = new TNtuple("V0ntuple","V0ntuple","OnTheFly:HasVertex:NegPIDProb:PosPIDProb:X:Y:Z:R:MotherCandidateNDF:MotherCandidateChi2:MotherCandidateEnergy:MotherCandidateEta:MotherCandidatePt:MotherCandidateMass:MotherCandidateWidth:MCMotherCandidatePT:EPOpeningAngle:ElectronEnergy:ElectronPt:ElectronEta:ElectronPhi:PositronEnergy:PositronPt:PositronEta:PositronPhi:HasSameMCMother:MotherMCParticlePIDCode",50000);\r
+    }\r
+    if(fNeutralMesonNtuple == NULL){\r
+      fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");\r
+    }\r
+    TList * ntupleTList = new TList();\r
+    ntupleTList->SetName("Ntuple");\r
+    ntupleTList->Add((TNtuple*)fGammaNtuple);\r
+    fOutputContainer->Add(ntupleTList);\r
+  }\r
+\r
   fOutputContainer->SetName(GetName());\r
 }\r
 \r