From: hristov Date: Mon, 26 Sep 2011 14:51:07 +0000 (+0000) Subject: Possibility to run analysis train inside AliReconstruction (Andrei) X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=42457748efad3c4917667bab55ee40d1c7d3ba89 Possibility to run analysis train inside AliReconstruction (Andrei) --- diff --git a/ALIROOT/CMakebinaliroot.pkg b/ALIROOT/CMakebinaliroot.pkg index 3218b71c9d6..cf7a6bfb839 100644 --- a/ALIROOT/CMakebinaliroot.pkg +++ b/ALIROOT/CMakebinaliroot.pkg @@ -31,7 +31,7 @@ set ( CSRCS fpu.c) set ( ELIBSDIR ) -set ( ELIBS MUONevaluation MUONmapping MUONshuttle MUONgraphics MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw MUONtrigger MUONcore TPCbase TPCsim TPCrec TPCfast ITSbase ITSsim ITSrec PMDbase PMDsim PMDrec TRDbase TRDsim TRDrec FMDbase FMDsim FMDrec TOFbase TOFrec TOFsim PHOSUtils PHOSbase PHOSsim PHOSrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDrec HMPIDsim ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec EMCALUtils EMCALbase EMCALsim EMCALrec EMCALraw BCM STRUCT T0base T0sim T0rec FASTSIM microcern HLTbase TRIGGERbase STEER STAT CDB AOD STEERBase ESD RAWDatasim RAWDatarec RAWDatabase) +set ( ELIBS MUONevaluation MUONmapping MUONshuttle MUONgraphics MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw MUONtrigger MUONcore TPCbase TPCsim TPCrec TPCfast ITSbase ITSsim ITSrec PMDbase PMDsim PMDrec TRDbase TRDsim TRDrec FMDbase FMDsim FMDrec TOFbase TOFrec TOFsim PHOSUtils PHOSbase PHOSsim PHOSrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDrec HMPIDsim ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec EMCALUtils EMCALbase EMCALsim EMCALrec EMCALraw BCM STRUCT T0base T0sim T0rec FASTSIM microcern HLTbase TRIGGERbase STEER STAT CDB AOD STEERBase ESD ANALYSIS RAWDatasim RAWDatarec RAWDatabase) if(PYTHIA6) list(APPEND ELIBS EVGEN) diff --git a/HLT/CMakebindHLTdumpraw.pkg b/HLT/CMakebindHLTdumpraw.pkg index 5b9a8e0e3d7..b08c221abe2 100644 --- a/HLT/CMakebindHLTdumpraw.pkg +++ b/HLT/CMakebindHLTdumpraw.pkg @@ -32,7 +32,7 @@ set ( EINCLUDE HLT/BASE HLT/MUON MUON RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS AliHLTMUON HLTbase MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS AliHLTMUON HLTbase MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) include ("CMakehlt.conf") diff --git a/HLT/CMakebindHLTrootify.pkg b/HLT/CMakebindHLTrootify.pkg index 96b37067464..2d080a42aa6 100644 --- a/HLT/CMakebindHLTrootify.pkg +++ b/HLT/CMakebindHLTrootify.pkg @@ -32,7 +32,7 @@ set ( EINCLUDE HLT/BASE HLT/MUON MUON) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS AliHLTMUON HLTbase MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS AliHLTMUON HLTbase MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) include ("CMakehlt.conf") diff --git a/MONITOR/CMakebinalionlinemonitor.pkg b/MONITOR/CMakebinalionlinemonitor.pkg index 4c98f0a8950..f4627117342 100644 --- a/MONITOR/CMakebinalionlinemonitor.pkg +++ b/MONITOR/CMakebinalionlinemonitor.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) set ( DATE_ROOT $ENV{DATE_ROOT}) diff --git a/MONITOR/CMakebinalitestproc.pkg b/MONITOR/CMakebinalitestproc.pkg index 38c60db59f5..14ddcd6f65a 100644 --- a/MONITOR/CMakebinalitestproc.pkg +++ b/MONITOR/CMakebinalitestproc.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) set (DATE_ROOT $ENV{DATE_ROOT}) diff --git a/MONITOR/CMakebinderoot.pkg b/MONITOR/CMakebinderoot.pkg index c311ef4750f..c82ed2c362e 100644 --- a/MONITOR/CMakebinderoot.pkg +++ b/MONITOR/CMakebinderoot.pkg @@ -35,4 +35,4 @@ set ( SRCS ${SRCS} root2date.cxx) set ( ELIBSDIR ) -set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ) +set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) diff --git a/MONITOR/CMakebinmonitorCheck.pkg b/MONITOR/CMakebinmonitorCheck.pkg index 4f5c4442ac4..0f382a79635 100644 --- a/MONITOR/CMakebinmonitorCheck.pkg +++ b/MONITOR/CMakebinmonitorCheck.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) set(DATE_ROOT $ENV{DATE_ROOT}) set(ODIR $ENV{ODIR}) diff --git a/MONITOR/CMakebinmonitorGDC.pkg b/MONITOR/CMakebinmonitorGDC.pkg index e494d50d5b6..a993556234d 100644 --- a/MONITOR/CMakebinmonitorGDC.pkg +++ b/MONITOR/CMakebinmonitorGDC.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MONITOR TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) set (DATE_ROOT $ENV{DATE_ROOT}) set(ODIR $ENV{ODIR}) diff --git a/MUON/CMakebinmchview.pkg b/MUON/CMakebinmchview.pkg index 0731222ece3..4743efbd49b 100644 --- a/MUON/CMakebinmchview.pkg +++ b/MUON/CMakebinmchview.pkg @@ -29,5 +29,5 @@ set ( SRCS mchview.cxx) set ( EINCLUDE ${EINCLUDE} MUON/mapping) -set ( ELIBS MUONmapping RAWDatabase MUONshuttle MUONgraphics MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MUONmapping RAWDatabase MUONshuttle MUONgraphics MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) diff --git a/RAW/CMakebinalimdc.pkg b/RAW/CMakebinalimdc.pkg index 487190540dc..2e4788aa1b8 100644 --- a/RAW/CMakebinalimdc.pkg +++ b/RAW/CMakebinalimdc.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MDC TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MDC TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) if( ALICE_TARGET MATCHES "macosx") diff --git a/RAW/CMakebindateStream.pkg b/RAW/CMakebindateStream.pkg index 111b52562be..e394c31f479 100644 --- a/RAW/CMakebindateStream.pkg +++ b/RAW/CMakebindateStream.pkg @@ -31,7 +31,7 @@ set ( EINCLUDE ${EINCLUDE} TPC ITS RAW) set ( PACKBLIBS ${ROOTCLIBS} ${SYSLIBS}) -set ( ELIBS MDC TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase) +set ( ELIBS MDC TPCbase TPCsim TPCrec HLTbase ITSbase ITSsim ITSrec MUONmapping MUONevaluation MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw RAWDatasim MUONtrigger MUONcore STEER CDB AOD RAWDatarec ESD RAWDatabase STEERBase ANALYSIS) if(ALICE_TARGET MATCHES "macosx") diff --git a/STEER/CMakelibSTEER.pkg b/STEER/CMakelibSTEER.pkg index a5a78ba0218..c59c440fd28 100644 --- a/STEER/CMakelibSTEER.pkg +++ b/STEER/CMakelibSTEER.pkg @@ -40,6 +40,7 @@ set ( SRCS STEER/AliMC.cxx STEER/AliSimulation.cxx STEER/AliReconstruction.cxx + STEER/AliRecoInputHandler.cxx STEER/AliVertexGenFile.cxx STEER/AliReconstructor.cxx STEER/AliGeomManager.cxx diff --git a/STEER/STEER/AliRecoInputHandler.cxx b/STEER/STEER/AliRecoInputHandler.cxx new file mode 100644 index 00000000000..096855583be --- /dev/null +++ b/STEER/STEER/AliRecoInputHandler.cxx @@ -0,0 +1,53 @@ +/************************************************************************** + * Copyright(c) 1998-2007, 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. * + **************************************************************************/ + +//------------------------------------------------------------------------- +// Event handler for reconstruction +// Author: Andrei Gheata, CERN +//------------------------------------------------------------------------- + +#include "AliRecoInputHandler.h" +#include "AliVCuts.h" + +ClassImp(AliRecoInputHandler) + +//______________________________________________________________________________ +AliRecoInputHandler::AliRecoInputHandler(const char* name, const char* title) + : AliESDInputHandler(name,title) +{ +// Named constructor +} + +//______________________________________________________________________________ +Bool_t AliRecoInputHandler::Init(TTree* tree, Option_t* opt) +{ +// Initialisation necessary for each new tree. In reco case this is once. + fAnalysisType = opt; + fTree = tree; + if (!fTree) return kFALSE; + fNEvents = fTree->GetEntries(); + return kTRUE; +} +//______________________________________________________________________________ +Bool_t AliRecoInputHandler::BeginEvent(Long64_t) +{ +// Called at the beginning of every event + static Bool_t called = kFALSE; + if (!called && fEventCuts && IsUserCallSelectionMask()) + AliInfo(Form("The ESD input handler expects that the first task calls AliESDInputHandler::CheckSelectionMask() %s", fEventCuts->ClassName())); + fNewEvent = kTRUE; + called = kTRUE; + return kTRUE; +} diff --git a/STEER/STEER/AliRecoInputHandler.h b/STEER/STEER/AliRecoInputHandler.h new file mode 100644 index 00000000000..59012c81487 --- /dev/null +++ b/STEER/STEER/AliRecoInputHandler.h @@ -0,0 +1,72 @@ +#ifndef ALIRECOINPUTHANDLER_H +#define ALIRECOINPUTHANDLER_H +/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//------------------------------------------------------------------------- +// Reconstruction-specific input handler +// Author: Andrei Gheata, CERN +//------------------------------------------------------------------------- + +#ifndef ALIESDINPUTHANDLER_H +#include "AliESDInputHandler.h" +#endif + +class AliReconstruction; + +class AliRecoInputHandler : public AliESDInputHandler { + + public: + AliRecoInputHandler() {} + AliRecoInputHandler(const char* name, const char* title); + virtual ~AliRecoInputHandler() {} + virtual Bool_t Notify() { return AliESDInputHandler::Notify(); }; + virtual Bool_t Notify(const char *) {return kTRUE;} + virtual Bool_t Init(Option_t* opt) {return AliESDInputHandler::Init(opt);} + virtual Bool_t Init(TTree* tree, Option_t* opt="LOCAL"); + virtual Bool_t BeginEvent(Long64_t entry); + virtual Bool_t FinishEvent() {return kTRUE;} +// void CheckSelectionMask(); +// AliESDEvent *GetEvent() const {return fEvent;} +// Option_t *GetAnalysisType() const {return fAnalysisType;} +// Option_t *GetDataType() const; + // Tag cut summary analysis +// Int_t GetNEventAcceptedInFile(); +// Int_t GetNEventRejectedInFile(); +// Bool_t GetCutSummaryForChain(Int_t *aTotal, Int_t *aAccepted, Int_t *aRejected); +// Int_t GetNFilesEmpty(); + // HLT analysis +// AliESDEvent *GetHLTEvent() const {return fHLTEvent;} +// TTree *GetHLTTree() const {return fHLTTree;} +// void SetReadHLT() {fUseHLT = kTRUE;} + // Friends&Co +// AliESDfriend *GetESDfriend() const {return fFriend;} +// void SetReadFriends(Bool_t flag) {fReadFriends = flag;} +// void SetFriendFileName(const char *fname) {fFriendFileName = fname;} + // Tag analysis +// void SetReadTags() {fUseTags = kTRUE;} +// AliRunTag *GetRunTag() const {return fRunTag;} +// const AliEventTag *GetEventTag() const {return fEventTag;} + // Get the statistics object (currently TH2). Option can be BIN0. +// virtual TObject *GetStatistics(Option_t *option="") const; + + //PID response +// virtual AliPIDResponse* GetPIDResponse() {return (AliPIDResponse*)fESDpid;} +// virtual void CreatePIDResponse(Bool_t isMC=kFALSE); +// AliESDpid *GetESDpid() const {return fESDpid;} +// void SetESDpid(AliESDpid* pid) {fESDpid = pid;} + + private: + AliRecoInputHandler(const AliESDInputHandler& handler); + AliRecoInputHandler& operator=(const AliESDInputHandler& handler); + // Private setters used by AliReconstruction + friend class AliReconstruction; + void SetEvent(AliESDEvent *event) {fEvent = event;} + void SetESDfriend(AliESDfriend *esdfriend) {fFriend = esdfriend;} + void SetHLTEvent(AliESDEvent *hltevent) {fHLTEvent = hltevent;} + void SetHLTTree(TTree *hlttree) {fHLTTree = hlttree;} + + ClassDef(AliRecoInputHandler, 1); +}; + +#endif diff --git a/STEER/STEER/AliReconstruction.cxx b/STEER/STEER/AliReconstruction.cxx index 66b2bd7add1..9b3533fddc5 100644 --- a/STEER/STEER/AliReconstruction.cxx +++ b/STEER/STEER/AliReconstruction.cxx @@ -133,6 +133,8 @@ #include #include "AliAlignObj.h" +#include "AliAnalysisManager.h" +#include "AliAnalysisDataContainer.h" #include "AliCDBEntry.h" #include "AliCDBManager.h" #include "AliCDBStorage.h" @@ -176,6 +178,7 @@ #include "AliRawReaderDate.h" #include "AliRawReaderFile.h" #include "AliRawReaderRoot.h" +#include "AliRecoInputHandler.h" #include "AliReconstruction.h" #include "AliReconstructor.h" #include "AliRun.h" @@ -299,7 +302,10 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) : fSspecie(0), fNhighPt(0), fShighPt(0), - fUpgradeModule("") + fUpgradeModule(""), + fAnalysisMacro(), + fAnalysis(0), + fRecoHandler(0) { // create reconstruction object with default parameters gGeoManager = NULL; @@ -414,7 +420,10 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) : fSspecie(0), fNhighPt(0), fShighPt(0), - fUpgradeModule("") + fUpgradeModule(""), + fAnalysisMacro(rec.fAnalysisMacro), + fAnalysis(0), + fRecoHandler(0) { // copy constructor @@ -578,6 +587,9 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) fNhighPt = 0; fShighPt = 0; fUpgradeModule=""; + fAnalysisMacro = rec.fAnalysisMacro; + fAnalysis = 0; + fRecoHandler = 0; return *this; } @@ -1538,6 +1550,10 @@ void AliReconstruction::Begin(TTree *) AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); magFieldMap->SetName("MagneticFieldMap"); gProof->AddInputData(magFieldMap,kTRUE); + if (fAnalysis) { + fAnalysis->SetName("Analysis"); + gProof->AddInputData(fAnalysis,kTRUE); + } } } @@ -1579,6 +1595,11 @@ void AliReconstruction::SlaveBegin(TTree*) TGeoGlobalMagField::Instance()->SetField(newMap); TGeoGlobalMagField::Instance()->Lock(); } + if (!fAnalysis) { + // Attempt to get the analysis manager from the input list + fAnalysis = (AliAnalysisManager*)fInput->FindObject("Analysis"); + if (fAnalysis) AliInfo("==== Analysis manager retrieved from input list ===="); + } if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE")) fProofOutputFileName = outputFileName->GetTitle(); if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION")) @@ -1602,7 +1623,22 @@ void AliReconstruction::SlaveBegin(TTree*) } AliSysInfo::AddStamp("ReadInputInSlaveBegin"); } - + // Check if analysis was requested in the reconstruction event loop + if (!fAnalysis) { + // Attempt to connect in-memory singleton + fAnalysis = AliAnalysisManager::GetAnalysisManager(); + if (fAnalysis) AliInfo(Form("==== Analysis manager <%s> found in memory ====", fAnalysis->GetName())); + // Check if an analysis macro was specified + if (!fAnalysis && !fAnalysisMacro.IsNull()) { + // Run specified analysis macro + gROOT->ProcessLine(Form(".x %s",fAnalysisMacro.Data())); + fAnalysis = AliAnalysisManager::GetAnalysisManager(); + if (!fAnalysis) AliError(Form("No analysis manager produced by analysis macro %s", fAnalysisMacro.Data())); + else AliInfo(Form("==== Analysis manager <%s> produced by analysis macro <%s> ====", + fAnalysis->GetName(), fAnalysisMacro.Data())); + } + } + // get the run loader if (!InitRunLoader()) { Abort("InitRunLoader", TSelector::kAbortProcess); @@ -1704,7 +1740,28 @@ void AliReconstruction::SlaveBegin(TTree*) if (strcmp(gProgName,"alieve") == 0) fRunAliEVE = InitAliEVE(); - + // If we have an analysis manager, connect the AliRecoInputHandler here + if (fAnalysis) { + if (!dynamic_cast(fAnalysis->GetInputEventHandler())) { + AliError("Analysis manager used in reconstruction should use AliRecoInputHandler - \ + \n ->Replacing with AliRecoInputHandler instance."); + delete fAnalysis->GetInputEventHandler(); + } + // Set the event and other data pointers + fRecoHandler = new AliRecoInputHandler(); + fRecoHandler->Init(ftree, "LOCAL"); + fRecoHandler->SetEvent(fesd); + fRecoHandler->SetESDfriend(fesdf); + fRecoHandler->SetHLTEvent(fhltesd); + fRecoHandler->SetHLTTree(fhlttree); + fAnalysis->SetInputEventHandler(fRecoHandler); + // Enter external loop mode + fAnalysis->SetExternalLoop(kTRUE); + // Initialize analysis + fAnalysis->StartAnalysis("local", (TTree*)0); + // Connect ESD tree with the input container + fAnalysis->GetCommonInputContainer()->SetData(ftree); + } return; } @@ -1720,7 +1777,7 @@ Bool_t AliReconstruction::Process(Long64_t entry) currTree->SetBranchAddress("rawevent",&event); currTree->GetEntry(entry); fRawReader = new AliRawReaderRoot(event); - fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents()); + fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents()); delete fRawReader; fRawReader = NULL; delete event; @@ -2215,6 +2272,12 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent) if (fRunQA || fRunGlobalQA) AliQAManager::QAManager()->Increment() ; + // Perform analysis of this event if requested + if (fAnalysis) { + fRecoHandler->BeginEvent(iEvent); + fAnalysis->ExecAnalysis(); + fRecoHandler->FinishEvent(); + } return kTRUE; } @@ -2225,6 +2288,12 @@ void AliReconstruction::SlaveTerminate() // Called after the exit // from the event loop AliCodeTimerAuto("",0); + // If analysis was done during reconstruction, we need to call SlaveTerminate for it + if (fAnalysis) { + fAnalysis->PackOutput(fOutput); + fAnalysis->SetSkipTerminate(kTRUE); + fAnalysis->Terminate(); + } if (fIsNewRunLoader) { // galice.root didn't exist fRunLoader->WriteHeader("OVERWRITE"); @@ -3361,7 +3430,8 @@ void AliReconstruction::CleanUp() if (AliQAManager::QAManager()) AliQAManager::QAManager()->ShowQA() ; - // AliQAManager::Destroy() ; + // AliQAManager::Destroy() ; + delete fAnalysis; } diff --git a/STEER/STEER/AliReconstruction.h b/STEER/STEER/AliReconstruction.h index f33547eb8c0..92a910d6b09 100644 --- a/STEER/STEER/AliReconstruction.h +++ b/STEER/STEER/AliReconstruction.h @@ -46,6 +46,8 @@ class AliGRPObject; class THashTable; class AliTriggerRunScalers; class AliCTPTimeParams; +class AliAnalysisManager; +class AliRecoInputHandler; #include "AliQAv1.h" #include "AliEventInfo.h" @@ -167,6 +169,15 @@ public: void SetUpgradeModule(const char* detectors) {fUpgradeModule = detectors; MatchUpgradeDetector() ; } void MatchUpgradeDetector(); + // Connection to analysis manager. + // If a macro is set it should contain a function returning an analysis + // manager object. The macro is ignored in case the analysis manager is + // set via SetAnalysisManager + void SetAnalysisMacro(const char *macropath) {fAnalysisMacro = macropath;} + const char *GetAnalysisMacro() const {return fAnalysisMacro.Data();} + void SetAnalysisManager(AliAnalysisManager *mgr) {fAnalysis = mgr;} + AliAnalysisManager *GetAnalysisManager() const {return fAnalysis;} + protected: virtual Bool_t ProcessEvent(void* event); void InitRun(const char* input); @@ -342,8 +353,11 @@ private: // Upgrade detector reconstruction TString fUpgradeModule; Bool_t fUpgradeMask[kNDetectors]; - - ClassDef(AliReconstruction, 39) // class for running the reconstruction + // Connect an analysis manager in the event loop + TString fAnalysisMacro; // Full path to a macro creating an analysis manager train + AliAnalysisManager *fAnalysis; //! Analysis manager + AliRecoInputHandler *fRecoHandler; //! Input handler adapted for reconstruction + ClassDef(AliReconstruction, 40) // class for running the reconstruction }; #endif diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index 89f2748ca7c..85ad5cca6a4 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -51,6 +51,7 @@ #pragma link C++ class AliMC+; #pragma link C++ class AliSimulation+; #pragma link C++ class AliReconstruction+; +#pragma link C++ class AliRecoInputHandler+; #pragma link C++ class AliVertexGenFile+; #pragma link C++ class AliVertexer+; #pragma link C++ class AliV0vertexer+; diff --git a/macros/loadlibsrec.C b/macros/loadlibsrec.C index 3b288db0811..c945bd58b1f 100644 --- a/macros/loadlibsrec.C +++ b/macros/loadlibsrec.C @@ -27,6 +27,8 @@ Int_t loadlibsrec () if ( gSystem->Load("libRAWDatabase") < 0 ) return ret; ret--; if ( gSystem->Load("libRAWDatarec") < 0 ) return ret; ret--; if ( gSystem->Load("libAOD") < 0 ) return ret; ret--; + if ( gSystem->Load("libANALYSIS") < 0 ) return ret; ret--; + if ( gSystem->Load("libSTEER") < 0 ) return ret; ret--; if ( gSystem->Load("libRAWDatasim") < 0 ) return ret; ret--;