Updating SDD task for calibration (Ruben) - see comment #27 in https://savannah.cern...
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Apr 2012 14:28:41 +0000 (14:28 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Apr 2012 14:28:41 +0000 (14:28 +0000)
PWGPP/CalibMacros/CPass0/AddTaskSDDCalib.C
PWGPP/CalibMacros/CPass1/AddTaskSDDCalib.C
PWGPP/ITS/AliAnalysisTaskITSAlignQA.cxx
PWGPP/ITS/AliAnalysisTaskITSAlignQA.h
PWGPP/macros/RecoQAtrain.C

index c9be8a3..836ef57 100644 (file)
@@ -18,13 +18,6 @@ AliAnalysisTaskITSAlignQA *AddTaskSDDCalib(Int_t nrun=0, Bool_t writeITSTP=kFALS
     return NULL;
   }
   
-  if (writeITSTP) {
-    AliAODHandler* aodHandler = new AliAODHandler();
-    aodHandler->SetOutputFileName( "AODtpITS.root" );
-    aodHandler->SetCreateNonStandardAOD();
-    mgr->SetOutputEventHandler(aodHandler);
-  }
-
   // Create and configure the task
   AliAnalysisTaskITSAlignQA *taskali = new AliAnalysisTaskITSAlignQA();
   //  taskali->SelectCollisionCandidates();
@@ -52,5 +45,15 @@ AliAnalysisTaskITSAlignQA *AddTaskSDDCalib(Int_t nrun=0, Bool_t writeITSTP=kFALS
   
   mgr->ConnectInput(taskali, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(taskali, 1, coutput1);
+  //
+  if (writeITSTP) { // if the TPtree to be written, create separate container
+    AliAnalysisDataContainer *coutputTP = mgr->CreateContainer("ITSSumTP",
+                                                              TTree::Class(),
+                                                              AliAnalysisManager::kOutputContainer,
+                                                              "AODtpITS.root" );
+    mgr->ConnectOutput(taskali, 2, coutputTP);
+  }
+  //
+
   return taskali;
 }
index c9be8a3..836ef57 100644 (file)
@@ -18,13 +18,6 @@ AliAnalysisTaskITSAlignQA *AddTaskSDDCalib(Int_t nrun=0, Bool_t writeITSTP=kFALS
     return NULL;
   }
   
-  if (writeITSTP) {
-    AliAODHandler* aodHandler = new AliAODHandler();
-    aodHandler->SetOutputFileName( "AODtpITS.root" );
-    aodHandler->SetCreateNonStandardAOD();
-    mgr->SetOutputEventHandler(aodHandler);
-  }
-
   // Create and configure the task
   AliAnalysisTaskITSAlignQA *taskali = new AliAnalysisTaskITSAlignQA();
   //  taskali->SelectCollisionCandidates();
@@ -52,5 +45,15 @@ AliAnalysisTaskITSAlignQA *AddTaskSDDCalib(Int_t nrun=0, Bool_t writeITSTP=kFALS
   
   mgr->ConnectInput(taskali, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(taskali, 1, coutput1);
+  //
+  if (writeITSTP) { // if the TPtree to be written, create separate container
+    AliAnalysisDataContainer *coutputTP = mgr->CreateContainer("ITSSumTP",
+                                                              TTree::Class(),
+                                                              AliAnalysisManager::kOutputContainer,
+                                                              "AODtpITS.root" );
+    mgr->ConnectOutput(taskali, 2, coutputTP);
+  }
+  //
+
   return taskali;
 }
index 20b5691..d067e86 100644 (file)
@@ -20,7 +20,6 @@
 #include <TProfile.h>
 #include <TChain.h>
 #include <TGeoGlobalMagField.h>
-#include "AliAODHandler.h"
 #include "AliESDInputHandlerRP.h"
 #include "AliITSSumTP.h"
 #include "AliMagF.h"
@@ -81,6 +80,7 @@ AliAnalysisTaskITSAlignQA::AliAnalysisTaskITSAlignQA() : AliAnalysisTaskSE("SDD
   fCutDCAZ(1.e10),
   fFitter(0),
   fITSSumTP(),
+  fTPTree(),
   fRunNb(0),
   fOCDBLocation("local://$ALICE_ROOT/OCDB")
 {
@@ -95,9 +95,12 @@ AliAnalysisTaskITSAlignQA::AliAnalysisTaskITSAlignQA() : AliAnalysisTaskSE("SDD
 //___________________________________________________________________________
 AliAnalysisTaskITSAlignQA::~AliAnalysisTaskITSAlignQA(){
   //
-  if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fOutput;
+  if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
+    delete fOutput;
+    delete fITSSumTP;
+  }
   delete fFitter;
-  delete fITSSumTP;
+  delete fTPTree;
   //
 }
 //___________________________________________________________________________
@@ -130,12 +133,16 @@ void AliAnalysisTaskITSAlignQA::UserCreateOutputObjects() {
   if(fDoSSDResiduals) CreateSSDHistos();
   //
   if (fDoFillTPTree) {
+    TFile* troutf = OpenFile(2);
+    if (!troutf) {
+      AliFatal("Failed to open output file for AliITSSumTP tree");
+      exit(1);
+    }
     fITSSumTP = new AliITSSumTP();
-    AliAODHandler* handler = dynamic_cast<AliAODHandler*>( AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler() );
-    if (!handler) AliFatal("TP tree requested but AOD handler is not available");
-    handler->AddBranch("AliITSSumTP",&fITSSumTP);
-    handler->SetFillAOD(kFALSE); // manual fill
+    fTPTree = new TTree("ITSSumTP","ITS TP Summary");
+    fTPTree->Branch("AliITSSumTP","AliITSSumTP",&fITSSumTP);
     CreateUserInfo();
+    PostData(2,fTPTree);
   }
   //
   PostData(1,fOutput);
@@ -399,8 +406,7 @@ void AliAnalysisTaskITSAlignQA::UserExec(Option_t *)
       }
     }
     fITSSumTP->SetUniqueID(fCurrentRunNumber);
-    AliAODHandler* handler = dynamic_cast<AliAODHandler*>( AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler() );
-    if (ntp) handler->FillTree();
+    if (ntp) fTPTree->Fill();
   }
 
   //
@@ -664,8 +670,8 @@ void AliAnalysisTaskITSAlignQA::Terminate(Option_t */*option*/)
 
   fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("hNEvents"));
   if(fHistNEvents){
-    printf("Number of analyzed events = %d, %d tracks accepted\n",
-          (Int_t)fHistNEvents->GetBinContent(kEvAcc+1),(Int_t)fHistNEvents->GetBinContent(kNTracks+1));
+    AliInfo(Form("Number of analyzed events = %d, %d tracks accepted",
+                (Int_t)fHistNEvents->GetBinContent(kEvAcc+1),(Int_t)fHistNEvents->GetBinContent(kNTracks+1)));
   }else{
     printf("Warning: pointer to fHistNEvents is NULL\n");
   }
@@ -761,9 +767,10 @@ Bool_t AliAnalysisTaskITSAlignQA::AcceptCentrality(const AliESDEvent *esd) const
 void AliAnalysisTaskITSAlignQA::CreateUserInfo()
 {
   // if needed, set user info of the output tree
-  AliAODHandler* handler = dynamic_cast<AliAODHandler*>( AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler() );
-  if (!handler) return;
-  TTree* outTree = handler->GetTree();
+  if (!fTPTree) {
+    AliError("TrackPoints summary tree does not exist"); 
+    return;
+  }
   //
   const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();      
   const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();  
@@ -790,8 +797,8 @@ void AliAnalysisTaskITSAlignQA::CreateUserInfo()
     cdbListCopy->Add(new TObjString(id->ToString().Data()));    
   }     
   // 
-  outTree->GetUserInfo()->Add(cdbMapCopy);      
-  outTree->GetUserInfo()->Add(cdbListCopy);  
+  fTPTree->GetUserInfo()->Add(cdbMapCopy);      
+  fTPTree->GetUserInfo()->Add(cdbListCopy);  
   //
   AliMagF *fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
   Double_t bz = fld ? fld->SolenoidField() : 0;
@@ -801,6 +808,6 @@ void AliAnalysisTaskITSAlignQA::CreateUserInfo()
   bzList->SetOwner(1);  
   bzList->SetName("BzkGauss");  
   bzList->Add(bzObjString);
-  outTree->GetUserInfo()->Add(bzList);
+  fTPTree->GetUserInfo()->Add(bzList);
   //
 }
index 7c2eb22..1cc246e 100644 (file)
@@ -39,6 +39,7 @@ class AliAnalysisTaskITSAlignQA : public AliAnalysisTaskSE {
 
   void SetDoFillTPTree(Bool_t opt){
     fDoFillTPTree=opt;
+    if (fDoFillTPTree) DefineOutput(2,TTree::Class());
   }
   void SetDoSPDResiduals(Bool_t opt){
     fDoSPDResiduals=opt;
@@ -179,7 +180,8 @@ class AliAnalysisTaskITSAlignQA : public AliAnalysisTaskSE {
   Double_t fCutDCAXY;        // apply rough XY DCA cut in case of vtx constraint, in terms of standard deviations
   Double_t fCutDCAZ;         // apply rough Z  DCA cut in case of vtx constraint  in terms of standard deviations
   AliITSTPArrayFit* fFitter;  // Track Point fitter
-  AliITSSumTP* fITSSumTP;     // TracPoints summary objects
+  AliITSSumTP* fITSSumTP;     // !TracPoints summary objects
+  TTree*   fTPTree;           // !output tree for trackpoints
   Int_t fRunNb;               // Run number
   TString fOCDBLocation;      // OCDB location
   ClassDef(AliAnalysisTaskITSAlignQA,6);
index 89e94bd..4873dd9 100644 (file)
@@ -54,13 +54,6 @@ void AddAnalysisTasks(Bool_t writeITSTP, Bool_t useTPCcrv)
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   mgr->SetCommonFileName("RecoQAresults.root");
   //
-  if (writeITSTP) {
-    AliAODHandler* aodHandler = new AliAODHandler();
-    aodHandler->SetOutputFileName( "AODtpITS.root" );
-    aodHandler->SetCreateNonStandardAOD();
-    mgr->SetOutputEventHandler(aodHandler);
-  }
-  //
   // Event Statistics (Jan Fiete)
   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
   AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
@@ -75,6 +68,14 @@ void AddAnalysisTasks(Bool_t writeITSTP, Bool_t useTPCcrv)
   itsAlign->SetDoSDDDriftTime(kFALSE);
   itsAlign->SetMinMaxMult(20.,1070.);
   itsAlign->SetUseTPCMomentum(useTPCcrv);
-  //
   itsAlign->SetDoFillTPTree(writeITSTP);
+  //
+  if (writeITSTP) {
+    AliAnalysisDataContainer *coutputTP = mgr->CreateContainer("ITSSumTP",
+                                                              TTree::Class(),
+                                                              AliAnalysisManager::kOutputContainer,
+                                                              "AODtpITS.root" );
+    mgr->ConnectOutput(itsAlign, 2, coutputTP);
+  }
+  //
 }