New AliAnalysisTaskSE for selection of HF candidates (Andrea)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Apr 2008 18:20:10 +0000 (18:20 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Apr 2008 18:20:10 +0000 (18:20 +0000)
PWG3/AliAnalysisTaskSESelectHF.cxx [new file with mode: 0644]
PWG3/AliAnalysisTaskSESelectHF.h [new file with mode: 0644]
PWG3/AliAnalysisTaskSESelectHFTest.C [new file with mode: 0644]

diff --git a/PWG3/AliAnalysisTaskSESelectHF.cxx b/PWG3/AliAnalysisTaskSESelectHF.cxx
new file mode 100644 (file)
index 0000000..c98ffba
--- /dev/null
@@ -0,0 +1,221 @@
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/////////////////////////////////////////////////////////////
+//
+// AliAnalysisTaskSE for the selection of heavy flavor
+// decay candidates and creation a stand-alone AOD.
+//
+// Author: A.Dainese, andrea.dainese@lnl.infn.it
+/////////////////////////////////////////////////////////////
+
+#include <TClonesArray.h>
+
+#include "AliAODEvent.h"
+#include "AliAODVertex.h"
+#include "AliAODTrack.h"
+#include "AliAODRecoDecayHF2Prong.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisTaskSESelectHF.h"
+
+ClassImp(AliAnalysisTaskSESelectHF)
+
+
+//________________________________________________________________________
+AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF():
+AliAnalysisTaskSE(),
+fVerticesHFTClArr(0),
+fD0toKpiTClArr(0)
+{
+  // Default constructor
+  SetD0toKpiCuts();
+}
+
+//________________________________________________________________________
+AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF(const char *name):
+AliAnalysisTaskSE(name),
+fVerticesHFTClArr(0),
+fD0toKpiTClArr(0)
+{
+  // Default constructor
+  SetD0toKpiCuts();
+}
+
+//________________________________________________________________________
+AliAnalysisTaskSESelectHF::~AliAnalysisTaskSESelectHF()
+{
+  // Destructor
+}  
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::Init()
+{
+  // Initialization
+
+  if(fDebug > 1) printf("AnalysisTaskSESelectHF::Init() \n");
+
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::UserCreateOutputObjects()
+{
+  // Create the output container
+  //
+  if(fDebug > 1) printf("AnalysisTaskSESelectHF::UserCreateOutputObjects() \n");
+
+  fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
+  fVerticesHFTClArr->SetName("VerticesHF");
+  AddAODBranch("TClonesArray", fVerticesHFTClArr);
+
+  fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
+  fD0toKpiTClArr->SetName("D0toKpi");
+  AddAODBranch("TClonesArray", fD0toKpiTClArr);
+
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::UserExec(Option_t */*option*/)
+{
+  // Execute analysis for current event:
+  // heavy flavor candidates selection and histograms
+  
+  AliAODEvent *aodIn = dynamic_cast<AliAODEvent*> (InputEvent());
+
+  // load D0->Kpi candidates                                                   
+  TClonesArray *inputArrayD0toKpi =
+    (TClonesArray*)aodIn->GetList()->FindObject("D0toKpi");
+
+  //print event info
+  aodIn->GetHeader()->Print();
+  
+  // primary vertex
+  AliAODVertex *vtx1 = (AliAODVertex*)aodIn->GetPrimaryVertex();
+  vtx1->Print();
+    
+  // make trkIDtoEntry register (temporary)
+  Int_t trkIDtoEntry[100000];
+  for(Int_t it=0;it<aodIn->GetNumberOfTracks();it++) {
+    AliAODTrack *track = aodIn->GetTrack(it);
+    trkIDtoEntry[track->GetID()]=it;
+  }
+
+  Int_t iOutVerticesHF=0,iOutD0toKpi=0;
+  fVerticesHFTClArr->Delete();
+  iOutVerticesHF = fVerticesHFTClArr->GetEntriesFast();
+  TClonesArray &verticesHFRef = *fVerticesHFTClArr;
+  fD0toKpiTClArr->Delete();
+  iOutD0toKpi = fD0toKpiTClArr->GetEntriesFast();
+  TClonesArray &aodD0toKpiRef = *fD0toKpiTClArr;
+
+
+  // loop over D0->Kpi candidates
+  Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
+  printf("Number of D0->Kpi: %d\n",nInD0toKpi);
+  
+  for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
+    AliAODRecoDecayHF2Prong *dIn = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
+    Bool_t unsetvtx=kFALSE;
+    if(!dIn->GetOwnPrimaryVtx()) {
+      dIn->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
+      unsetvtx=kTRUE;
+    }
+    Int_t okD0=0,okD0bar=0; 
+    if(dIn->SelectD0(fD0toKpiCuts,okD0,okD0bar)) {
+      // get daughter AOD tracks
+      AliAODTrack *trk0=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(0)]);
+      AliAODTrack *trk1=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(1)]);
+      // this will be replaced by 
+      //AliAODTrack *trk0 = (AliAODTrack*)(dIn->GetSecondaryVtx()->GetDaughter(0));
+      printf("pt of positive track: %f\n",trk0->Pt());
+      printf("pt of negative track: %f\n",trk1->Pt());
+
+
+      // clone candidate for output AOD
+      AliAODVertex *v = new(verticesHFRef[iOutVerticesHF++]) 
+       AliAODVertex(*(dIn->GetSecondaryVtx()));
+      Double_t px[2]={dIn->PxProng(0),dIn->PxProng(1)};
+      Double_t py[2]={dIn->PyProng(0),dIn->PyProng(1)};
+      Double_t pz[2]={dIn->PzProng(0),dIn->PzProng(1)};
+      Double_t d0[2]={dIn->Getd0Prong(0),dIn->Getd0Prong(1)};
+      Double_t d0err[2]={dIn->Getd0errProng(0),dIn->Getd0errProng(1)};
+      AliAODRecoDecayHF2Prong *dOut=new(aodD0toKpiRef[iOutD0toKpi++]) 
+       AliAODRecoDecayHF2Prong(v,px,py,pz,d0,d0err,dIn->GetDCA());
+      dOut->SetOwnPrimaryVtx(dIn->GetOwnPrimaryVtx());
+    }
+    if(unsetvtx) dIn->UnsetOwnPrimaryVtx();
+  } // end loop on D0->Kpi
+
+
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  //
+  if(fDebug > 1) printf("AnalysisTaskSESelectHF: Terminate() \n");
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(Double_t cut0,Double_t cut1,
+                                  Double_t cut2,Double_t cut3,Double_t cut4,
+                                  Double_t cut5,Double_t cut6,
+                                  Double_t cut7,Double_t cut8) 
+{
+  // Set the cuts for D0 selection
+  // cuts[0] = inv. mass half width [GeV]   
+  // cuts[1] = dca [cm]
+  // cuts[2] = cosThetaStar 
+  // cuts[3] = pTK [GeV/c]
+  // cuts[4] = pTPi [GeV/c]
+  // cuts[5] = d0K [cm]   upper limit!
+  // cuts[6] = d0Pi [cm]  upper limit!
+  // cuts[7] = d0d0 [cm^2]
+  // cuts[8] = cosThetaPoint
+
+  fD0toKpiCuts[0] = cut0;
+  fD0toKpiCuts[1] = cut1;
+  fD0toKpiCuts[2] = cut2;
+  fD0toKpiCuts[3] = cut3;
+  fD0toKpiCuts[4] = cut4;
+  fD0toKpiCuts[5] = cut5;
+  fD0toKpiCuts[6] = cut6;
+  fD0toKpiCuts[7] = cut7;
+  fD0toKpiCuts[8] = cut8;
+
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(const Double_t cuts[9]) 
+{
+  // Set the cuts for D0 selection
+  // cuts[0] = inv. mass half width [GeV]   
+  // cuts[1] = dca [cm]
+  // cuts[2] = cosThetaStar 
+  // cuts[3] = pTK [GeV/c]
+  // cuts[4] = pTPi [GeV/c]
+  // cuts[5] = d0K [cm]   upper limit!
+  // cuts[6] = d0Pi [cm]  upper limit!
+  // cuts[7] = d0d0 [cm^2]
+  // cuts[8] = cosThetaPoint
+
+  for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];
+
+  return;
+}
diff --git a/PWG3/AliAnalysisTaskSESelectHF.h b/PWG3/AliAnalysisTaskSESelectHF.h
new file mode 100644 (file)
index 0000000..69fb3bd
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALIANALYSISTASKSESELECTHF_H
+#define ALIANALYSISTASKSESELECTHF_H
+
+/* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//*************************************************************************
+// Class AliAnalysisTaskSESelectHF
+// AliAnalysisTaskSE for the selection of heavy-flavour decay candidates
+// and creation of a stand-alone AOD
+// Author: A.Dainese, andrea.dainese@lnl.infn.it
+//*************************************************************************
+
+
+#include <TClonesArray.h>
+
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisVertexingHF.h"
+
+
+class AliAnalysisTaskSESelectHF : public AliAnalysisTaskSE
+{
+ public:
+
+  AliAnalysisTaskSESelectHF();
+  AliAnalysisTaskSESelectHF(const char *name);
+  virtual ~AliAnalysisTaskSESelectHF();
+
+  AliAnalysisTaskSESelectHF(const AliAnalysisTaskSESelectHF &source);
+  AliAnalysisTaskSESelectHF& operator=(const AliAnalysisTaskSESelectHF& source); 
+
+  // Implementation of interface methods
+  virtual void UserCreateOutputObjects();
+  virtual void Init();
+  virtual void LocalInit() {Init();}
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+
+  void SetD0toKpiCuts(Double_t cut0=1000.,Double_t cut1=100000.,
+                     Double_t cut2=1.1,Double_t cut3=0.,Double_t cut4=0.,
+                     Double_t cut5=100000.,Double_t cut6=100000.,
+                     Double_t cut7=100000000.,Double_t cut8=-1.1); 
+  // cuts[0] = inv. mass half width [GeV]   
+  // cuts[1] = dca [cm]
+  // cuts[2] = cosThetaStar 
+  // cuts[3] = pTK [GeV/c]
+  // cuts[4] = pTPi [GeV/c]
+  // cuts[5] = d0K [cm]   upper limit!
+  // cuts[6] = d0Pi [cm]  upper limit!
+  // cuts[7] = d0d0 [cm^2]
+  // cuts[8] = cosThetaPoint
+  void SetD0toKpiCuts(const Double_t cuts[9]); 
+  
+ private:
+
+  TClonesArray *fVerticesHFTClArr;     // Array of heavy-flavour vertices
+  TClonesArray *fD0toKpiTClArr;        // Array of D0->Kpi
+  Double_t fD0toKpiCuts[9];            // cuts for D0->Kpi selection
+  
+  ClassDef(AliAnalysisTaskSESelectHF,1); // AliAnalysisTaskSE for the reconstruction of heavy-flavour decay candidates
+};
+
+#endif
+
diff --git a/PWG3/AliAnalysisTaskSESelectHFTest.C b/PWG3/AliAnalysisTaskSESelectHFTest.C
new file mode 100644 (file)
index 0000000..3ab1b9e
--- /dev/null
@@ -0,0 +1,112 @@
+void AliAnalysisTaskSESelectHFTest()\r
+{\r
+  //\r
+  // Test macro for the AliAnalysisTaskSE for heavy-flavour selection\r
+  // and creation of a stand-alone AOD\r
+  // A.Dainese, andrea.dainese@lnl.infn.it\r
+  //\r
+\r
+  gSystem->Load("libTree.so");\r
+  gSystem->Load("libGeom.so");\r
+  gSystem->Load("libPhysics.so");\r
+  gSystem->Load("libVMC.so");\r
+  gSystem->Load("libSTEERBase.so");\r
+  gSystem->Load("libESD.so");\r
+  gSystem->Load("libAOD.so"); \r
+  gSystem->Load("libANALYSIS.so");\r
+  gSystem->Load("libANALYSISalice.so");\r
+  gSystem->Load("libPWG3base.so");\r
+\r
+\r
+  // Local files \r
+  TChain *chain = new TChain("aodTree");\r
+  chain->Add("./AliAOD.root");\r
+\r
+  // or:\r
+  /*\r
+  //Fetch files with AliEn :\r
+  const char *collectionfile = "CollectionTags.xml";\r
+  TGrid::Connect("alien://") ;\r
+  //Create an AliRunTagCuts and an AliEventTagCuts Object and impose some selection criteria\r
+  AliRunTagCuts      *runCuts   = new AliRunTagCuts();\r
+  AliEventTagCuts    *eventCuts = new AliEventTagCuts();\r
+  AliLHCTagCuts      *lhcCuts   = new AliLHCTagCuts();\r
+  AliDetectorTagCuts *detCuts   = new AliDetectorTagCuts();\r
+  eventCuts->SetMultiplicityRange(0,20000);\r
+  //Create an AliTagAnalysis Object and chain the tags\r
+  AliTagAnalysis   *tagAna = new AliTagAnalysis();\r
+  tagAna->SetType("AOD");\r
+  TAlienCollection *coll   = TAlienCollection::Open(collectionfile);\r
+  TGridResult      *tagResult = coll->GetGridResult("",0,0);\r
+  tagResult->Print();\r
+  tagAna->ChainGridTags(tagResult);\r
+  //Create a new aod chain and assign the chain that is returned by querying the tags\r
+  TChain* chain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts);\r
+  */\r
+\r
+\r
+  // Create the analysis manager\r
+  AliAnalysisManager *mgr  = new AliAnalysisManager("My Manager","My Manager");\r
+  mgr->SetDebugLevel(10);\r
+  \r
+\r
+  // Input\r
+  AliAODInputHandler *inputHandler = new AliAODInputHandler();\r
+  inputHandler->AddFriend("AliAOD.VertexingHF.root");\r
+  mgr->SetInputEventHandler(inputHandler);\r
+\r
+  // Output \r
+  AliAODHandler *aodHandler   = new AliAODHandler();\r
+  aodHandler->SetOutputFileName("AliAOD.VertexingHF.sa.root");\r
+  aodHandler->SetCreateNonStandardAOD();\r
+  mgr->SetOutputEventHandler(aodHandler);\r
+\r
+  \r
+  // Aanalysis task    \r
+  AliAnalysisTaskSESelectHF *hfTask = new AliAnalysisTaskSESelectHF("SelectHFAnalysis");\r
+  hfTask->SetDebugLevel(2);\r
+  Double_t cutsD0[9]=\r
+    // cutsD0[0] = inv. mass half width [GeV]\r
+    // cutsD0[1] = dca [cm]\r
+    // cutsD0[2] = cosThetaStar\r
+    // cutsD0[3] = pTK [GeV/c]\r
+    // cutsD0[4] = pTPi [GeV/c]\r
+    // cutsD0[5] = d0K [cm]   upper limit!\r
+    // cutsD0[6] = d0Pi [cm]  upper limit!\r
+    // cutsD0[7] = d0d0 [cm^2]\r
+    // cutsD0[8] = cosThetaPoint\r
+                     {1,\r
+                     100000.,\r
+                     1.1,\r
+                     0.,\r
+                     0.,\r
+                     100000.,\r
+                     100000.,\r
+                     100000000.,\r
+                     0.9}; \r
+  hfTask->SetD0toKpiCuts(cutsD0);\r
+  \r
+  mgr->AddTask(hfTask);\r
+  \r
+  //\r
+  // Create containers for input/output\r
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), \r
+                                                          AliAnalysisManager::kInputContainer);\r
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),\r
+                                                           AliAnalysisManager::kOutputContainer, \r
+                                                           "default");\r
+  mgr->ConnectInput(hfTask,0,cinput1);\r
+  mgr->ConnectOutput(hfTask,0,coutput1);\r
+\r
+  //\r
+  // Run the analysis\r
+  //    \r
+  printf("CHAIN HAS %d ENTRIES\n",(Int_t)chain->GetEntries());\r
+  if(mgr->InitAnalysis()) {\r
+    mgr->PrintStatus();\r
+    mgr->StartAnalysis("local",chain);\r
+    //mgr->StartAnalysis("grid",chain);\r
+  }\r
+\r
+  return;\r
+}\r