]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Use pointers for output TTrees (Mihaela)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Apr 2008 11:25:50 +0000 (11:25 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Apr 2008 11:25:50 +0000 (11:25 +0000)
PWG3/AliAnalysisVertexingHF.cxx
PWG3/AliAnalysisVertexingHF.h
PWG3/AliAnalysisVertexingHFTest.C

index a819332b72693cd66064f2a557411c51afdb682a..c454b92d18f313067f3519a1dee501cdc90da787 100644 (file)
@@ -131,10 +131,9 @@ AliAnalysisVertexingHF::~AliAnalysisVertexingHF() {
   if(fV1) { delete fV1; fV1=0; }
 }
 //----------------------------------------------------------------------------
-void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
+void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree *treeout[])
 {
   // Find heavy-flavour vertex candidates
-
   
   AliAODRecoDecayHF2Prong *io2Prong = new AliAODRecoDecayHF2Prong();
   AliAODRecoDecayHF3Prong *io3Prong = new AliAODRecoDecayHF3Prong();
@@ -144,27 +143,27 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
   Int_t initEntriesD0toKpi=0,initEntriesJPSItoEle=0,initEntries3Prong=0,initEntries4Prong=0;
   if(fD0toKpi) {
     itreeD0toKpi=itree;
-    treeout[itree].SetBranchAddress("D0toKpi",&io2Prong);
+    treeout[itree]->SetBranchAddress("D0toKpi",&io2Prong);
     itree++;
-    initEntriesD0toKpi = treeout[itreeD0toKpi].GetEntries();
+    initEntriesD0toKpi = treeout[itreeD0toKpi]->GetEntries();
   }
   if(fJPSItoEle) {
     itreeJPSItoEle=itree;
-    treeout[itree].SetBranchAddress("JPSItoEle",&io2Prong);
+    treeout[itree]->SetBranchAddress("JPSItoEle",&io2Prong);
     itree++;
-    initEntriesJPSItoEle = treeout[itreeJPSItoEle].GetEntries();
+    initEntriesJPSItoEle = treeout[itreeJPSItoEle]->GetEntries();
   }
   if(f3Prong) {
     itree3Prong=itree;
-    treeout[itree].SetBranchAddress("Charmto3Prong",&io3Prong);
+    treeout[itree]->SetBranchAddress("Charmto3Prong",&io3Prong);
     itree++;
-    initEntries3Prong = treeout[itree3Prong].GetEntries();
+    initEntries3Prong = treeout[itree3Prong]->GetEntries();
   }
   if(f4Prong) {
     itree4Prong=itree;
-    treeout[itree].SetBranchAddress("D0to4Prong",&io4Prong);
+    treeout[itree]->SetBranchAddress("D0to4Prong",&io4Prong);
     itree++;
-    initEntries4Prong = treeout[itree4Prong].GetEntries();
+    initEntries4Prong = treeout[itree4Prong]->GetEntries();
   }
   delete io2Prong; io2Prong = NULL;
   delete io3Prong; io3Prong = NULL;
@@ -241,8 +240,8 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
       }
       if(fD0toKpi || fJPSItoEle) { 
        io2Prong = Make2Prong(twoTrackArray1,esd,vertexp1n1,dcap1n1,okD0,okJPSI);
-       if(okD0)   treeout[itreeD0toKpi].Fill();
-       if(okJPSI) treeout[itreeJPSItoEle].Fill();
+       if(okD0)   treeout[itreeD0toKpi]->Fill();
+       if(okJPSI) treeout[itreeJPSItoEle]->Fill();
         delete io2Prong; io2Prong=NULL; 
       }
 
@@ -271,7 +270,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
          threeTrackArray->AddAt(negtrack1,1);
          threeTrackArray->AddAt(postrack2,2);
          io3Prong = Make3Prong(threeTrackArray,esd,vertexp1n1,vertexp2n1,dcap1n1,dcap2n1,dcap1p2,ok3Prong);
-         if(ok3Prong) treeout[itree3Prong].Fill();
+         if(ok3Prong) treeout[itree3Prong]->Fill();
          if(io3Prong) delete io3Prong; io3Prong=NULL; 
        }
        if(f4Prong) {
@@ -287,7 +286,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
            fourTrackArray->AddAt(postrack2,2);
            fourTrackArray->AddAt(negtrack2,3);
            io4Prong = Make4Prong(fourTrackArray,esd,vertexp1n1,vertexp2n1,dcap1n1,dcap1n2,dcap2n1,ok4Prong);
-           if(ok4Prong) treeout[itree4Prong].Fill();
+           if(ok4Prong) treeout[itree4Prong]->Fill();
            delete io4Prong; io4Prong=NULL; 
             fourTrackArray->Clear();
            negtrack2 = 0;
@@ -316,7 +315,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
          threeTrackArray->AddAt(postrack1,1);
          threeTrackArray->AddAt(negtrack2,2);
          io3Prong = Make3Prong(threeTrackArray,esd,vertexp1n1,vertexp1n2,dcap1n1,dcap1n2,dcan1n2,ok3Prong);
-         if(ok3Prong) treeout[itree3Prong].Fill();
+         if(ok3Prong) treeout[itree3Prong]->Fill();
          if(io3Prong) delete io3Prong; io3Prong=NULL; 
          }
        negtrack2 = 0;
@@ -351,26 +350,26 @@ void AliAnalysisVertexingHF::FindCandidates(AliESDEvent *esd,TTree treeout[])
   if(fD0toKpi) {
     printf(" D0->Kpi: event %d = %d; total = %d;\n",
           (Int_t)esd->GetEventNumberInFile(),
-          (Int_t)treeout[itreeD0toKpi].GetEntries()-initEntriesD0toKpi,
-          (Int_t)treeout[itreeD0toKpi].GetEntries());
+          (Int_t)treeout[itreeD0toKpi]->GetEntries()-initEntriesD0toKpi,
+          (Int_t)treeout[itreeD0toKpi]->GetEntries());
   }
   if(fJPSItoEle) {
     printf(" JPSI->ee: event %d = %d; total = %d;\n",
           (Int_t)esd->GetEventNumberInFile(),
-          (Int_t)treeout[itreeJPSItoEle].GetEntries()-initEntriesJPSItoEle,
-          (Int_t)treeout[itreeJPSItoEle].GetEntries());
+          (Int_t)treeout[itreeJPSItoEle]->GetEntries()-initEntriesJPSItoEle,
+          (Int_t)treeout[itreeJPSItoEle]->GetEntries());
   }
   if(f3Prong) {
     printf(" Charm->3Prong: event %d = %d; total = %d;\n",
           (Int_t)esd->GetEventNumberInFile(),
-          (Int_t)treeout[itree3Prong].GetEntries()-initEntries3Prong,
-          (Int_t)treeout[itree3Prong].GetEntries());
+          (Int_t)treeout[itree3Prong]->GetEntries()-initEntries3Prong,
+          (Int_t)treeout[itree3Prong]->GetEntries());
   }
   if(f4Prong) {
     printf(" Charm->4Prong: event %d = %d; total = %d;\n",
           (Int_t)esd->GetEventNumberInFile(),
-          (Int_t)treeout[itree4Prong].GetEntries()-initEntries4Prong,
-          (Int_t)treeout[itree4Prong].GetEntries());
+          (Int_t)treeout[itree4Prong]->GetEntries()-initEntries4Prong,
+          (Int_t)treeout[itree4Prong]->GetEntries());
   }
 
 
index b65576724c9efa80f6de06b833253cd7368a8a2b..fdd926a499c48f8cdaf0a66536006d4c0cce00dc 100644 (file)
@@ -29,7 +29,7 @@ class AliAnalysisVertexingHF : public TNamed {
   AliAnalysisVertexingHF& operator=(const AliAnalysisVertexingHF& source); 
   virtual ~AliAnalysisVertexingHF();
 
-  void FindCandidates(AliESDEvent *esd,TTree treeout[]);
+  void FindCandidates(AliESDEvent *esd,TTree *treeout[]);
   AliAODRecoDecayHF2Prong* Make2Prong(TObjArray *twoTrackArray1,AliESDEvent *esd,
                                     AliESDVertex *vertexp1n1,Double_t dcap1n1,
                                     Bool_t &okD0,Bool_t &okJPSI) const;
index 5ae11f367a75d72a171458e69ef3089ef9aa55db..49e3b9fc9bb30be05ff507a378cf3b5254808840 100644 (file)
@@ -7,7 +7,7 @@
 //     Andrea Dainese, andrea.dainese@lnl.infn.it
 //--------------------------------------------------------------------------
 
-void AliAnalysisVertexingHFTest(Int_t mode=0)
+void AliAnalysisVertexingHFTest(Int_t mode=1)
 {
   
   gSystem->Load("libANALYSIS.so");
@@ -48,17 +48,24 @@ void AliAnalysisVertexingHFTest(Int_t mode=0)
 
   switch(mode) {
   case 0:
-    vHF->FindCandidatesESDtoAOD();
+    //vHF->FindCandidatesESDtoAOD();
     break;
   case 1:
-    TTree *trees = new TTree[1];
+    TFile *fout = new TFile("AliAnalysisVertexingHF.root","recreate");
+
+    TTree **trees = 0;
+    trees = new TTree*[1];
     AliAODRecoDecayHF2Prong *rd2=0;
-    // AliAODRecoDecayHF3Prong *rd3=0;
+    //AliAODRecoDecayHF3Prong *rd3=0;
     //AliAODRecoDecayHF4Prong *rd4=0;
-    trees[0].Branch("D0toKpi","AliAODRecoDecayHF2Prong",&rd2);
-    //trees[1].Branch("JPSItoEle","AliAODRecoDecayHF2Prong",&rd2);
-    //trees[2].Branch("Charmto3Prong","AliAODRecoDecayHF3Prong",&rd3);
-    //trees[3].Branch("D0to4Prong","AliAODRecoDecayHF4Prong",&rd4);
+    trees[0] = new TTree("D0toKpi","D0toKpi");
+    trees[0]->Branch("D0toKpi","AliAODRecoDecayHF2Prong",&rd2);
+    //trees[1] = new TTree("JPSItoEle","JPSItoEle");
+    //trees[1]->Branch("JPSItoEle","AliAODRecoDecayHF2Prong",&rd2);
+    //trees[2] = new TTree("Charmto3Prong","Charmto3Prong");
+    //trees[2]->Branch("Charmto3Prong","AliAODRecoDecayHF3Prong",&rd3);
+    //trees[3] = new TTree("Charmto4Prong","Charmto4Prong");
+    //trees[3]->Branch("D0to4Prong","AliAODRecoDecayHF4Prong",&rd4);
     
     TFile *inesd = new TFile("AliESDs.root");
     AliESDEvent *esd = new AliESDEvent();
@@ -76,11 +83,11 @@ void AliAnalysisVertexingHFTest(Int_t mode=0)
     delete inesd;
     
     // Write trees with candidates
-    TFile *fout = new TFile("AliAnalysisVertexingHF.root","recreate");
-    trees[0].Write("TreeD0toKpi");
-    //trees[1].Write("TreeJPSItoEle");
-    //trees[2].Write("TreeCharm3Prong");
-    //trees[3].Write("TreeD0to4Prong");
+    fout->cd();
+    trees[0]->Write("TreeD0toKpi");
+    //trees[1]->Write("TreeJPSItoEle");
+    //trees[2]->Write("TreeCharm3Prong");
+    //trees[3]->Write("TreeD0to4Prong");
     fout->Close();
     delete fout;
     break;