Fixing TOF calib tree task to use the same output handler as in CPass
authorzampolli <chiara.zampolli@cern.ch>
Tue, 21 Oct 2014 14:58:18 +0000 (16:58 +0200)
committerzampolli <chiara.zampolli@cern.ch>
Tue, 21 Oct 2014 14:58:18 +0000 (16:58 +0200)
TOF/AddTOFAnalysisTaskCalibTree.C
TOF/AliTOFAnalysisTaskCalibTree.cxx
TOF/AliTOFAnalysisTaskCalibTree.h

index 7416193..d3abac4 100644 (file)
@@ -29,13 +29,23 @@ AliTOFAnalysisTaskCalibTree *AddTOFAnalysisTaskCalibTree()
   }
   
   // setup output event handler
-  AliAODHandler *outputh = (AliAODHandler *)mgr->GetOutputEventHandler();
-  outputh->SetCreateNonStandardAOD();
-  outputh->SetOutputFileName("TOFcalibTree.root");
+
+  // old way: expecting to use AOD tree
+  // AliAODHandler *outputh = (AliAODHandler *)mgr->GetOutputEventHandler();
+  // outputh->SetCreateNonStandardAOD();
+  // outputh->SetOutputFileName("TOFcalibTree.root");
+
+  // new way:
+  AliAnalysisDataContainer *coutput   = mgr->CreateContainer(Form("aodTree"), TTree::Class(), AliAnalysisManager::kOutputContainer, "TOFcalibTree.root"); // tree
+  if (!coutput) {
+    Error("AddTOFAnalysisTaskCalibTree", "cannot create output container");
+    return NULL;
+  }
 
   //  create task and connect input/output 
   AliTOFAnalysisTaskCalibTree *task = new AliTOFAnalysisTaskCalibTree();
   mgr->ConnectInput(task, 0, inputc);
+  mgr->ConnectOutput(task, 1, coutput);
 
   // setup task 
   task->SetEventSelectionFlag(kFALSE);
index e8c7224..9f44d89 100644 (file)
@@ -48,13 +48,16 @@ AliAnalysisTaskSE(name),
   fTimeResolution(80.),
   fTOFcalib(new AliTOFcalib()),             
   fTOFT0maker(new AliTOFT0maker(fESDpid, fTOFcalib)),         
-  fTOFT0v1(new AliTOFT0v1(fESDpid))             
+  fTOFT0v1(new AliTOFT0v1(fESDpid)),
+  fOutputTree(0x0)             
 
 {
   /* 
    * default constructor 
    */
 
+  DefineOutput(1, TTree::Class());  
+
 }
 
 //_______________________________________________________
@@ -70,6 +73,10 @@ AliTOFAnalysisTaskCalibTree::~AliTOFAnalysisTaskCalibTree()
   delete fTOFcalib;
   delete fTOFT0maker;
   delete fTOFT0v1;
+  if (fOutputTree) {
+    delete fOutputTree;
+    fOutputTree = 0x0;
+  }
 
 }
 
@@ -82,18 +89,22 @@ AliTOFAnalysisTaskCalibTree::UserCreateOutputObjects()
    * user create output objects
    */
 
+  fOutputTree = new TTree("aodTree", "Tree with TOF calib output"); 
+
   /* setup output tree */
-  OutputTree()->Branch("run", &fRunNumber, "run/I");
-  OutputTree()->Branch("timestamp", &ftimestamp, "timestamp/i");
-  OutputTree()->Branch("timezero", &ftimezero, "timezero/F");
-  OutputTree()->Branch("vertex", &fVertexZ, "vertex/F");
-  OutputTree()->Branch("nhits", &fnhits, "nhits/I");
-  OutputTree()->Branch("momentum", &fmomentum, "momentum[nhits]/F");
-  OutputTree()->Branch("length", &flength, "length[nhits]/F");
-  OutputTree()->Branch("index", &findex, "index[nhits]/I");
-  OutputTree()->Branch("time", &ftime, "time[nhits]/F");
-  OutputTree()->Branch("tot", &ftot, "tot[nhits]/F");
-  OutputTree()->Branch("texp", &ftexp, "texp[nhits]/F");
+  fOutputTree->Branch("run", &fRunNumber, "run/I");
+  fOutputTree->Branch("timestamp", &ftimestamp, "timestamp/i");
+  fOutputTree->Branch("timezero", &ftimezero, "timezero/F");
+  fOutputTree->Branch("vertex", &fVertexZ, "vertex/F");
+  fOutputTree->Branch("nhits", &fnhits, "nhits/I");
+  fOutputTree->Branch("momentum", &fmomentum, "momentum[nhits]/F");
+  fOutputTree->Branch("length", &flength, "length[nhits]/F");
+  fOutputTree->Branch("index", &findex, "index[nhits]/I");
+  fOutputTree->Branch("time", &ftime, "time[nhits]/F");
+  fOutputTree->Branch("tot", &ftot, "tot[nhits]/F");
+  fOutputTree->Branch("texp", &ftexp, "texp[nhits]/F");
+
+  PostData(1, fOutputTree);
 
 }
 
@@ -171,7 +182,9 @@ void AliTOFAnalysisTaskCalibTree::UserExec(Option_t *option) {
 
   // check number of hits and set fill output tree
   if (fnhits > 0)
-    ((AliAODHandler*)(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()))->SetFillAOD(kTRUE);
+    fOutputTree->Fill();
+
+  PostData(1, fOutputTree);
 
 }
 
@@ -179,7 +192,7 @@ void AliTOFAnalysisTaskCalibTree::UserExec(Option_t *option) {
 
 Bool_t AliTOFAnalysisTaskCalibTree::InitRun() {
 
-  //
+  //¯
   // init run
   //
   
@@ -249,8 +262,10 @@ Bool_t AliTOFAnalysisTaskCalibTree::InitEvent() {
   fElapsedTime = fESDEvent->GetTimeStamp() - fStartTime;
 
   // event selection
-  fIsCollisionCandidate = fEventCuts->IsCollisionCandidate(fESDEvent);
-  if (fEventSelectionFlag && !fIsCollisionCandidate) return kFALSE;
+  if (fEventSelectionFlag){
+    fIsCollisionCandidate = fEventCuts->IsCollisionCandidate(fESDEvent);
+    if (!fIsCollisionCandidate) return kFALSE;
+  }
 
   // vertex selection
   fVertex = fESDEvent->GetPrimaryVertexTracks();
index 0dd93c1..c0e5c2e 100644 (file)
@@ -124,7 +124,9 @@ public AliAnalysisTaskSE
   Float_t ftot[MAXHITS];
   Float_t ftexp[MAXHITS];
 
-  ClassDef(AliTOFAnalysisTaskCalibTree, 1);
+  TTree* fOutputTree;                 // output tree
+
+  ClassDef(AliTOFAnalysisTaskCalibTree, 2);
 };
 
 #endif /* ALIANALYSISTASKTOFCOMPACTCALIB_H */