Skip to content
Snippets Groups Projects
Commit 3733734b authored by Edwin Chow's avatar Edwin Chow Committed by Graeme Stewart
Browse files

CaloTag histogram retrieve method update (CaloTrkMuIdTools-00-15-16)

2016-09-15 Yun Sang Chow
	* CaloTag histogram retrieve method update
	* Fix typo in ChangeLog last time
	* CaloTrkMuIdTools-00-15-16

2016-08-31 Yun Sang Chow


Former-commit-id: 7004ecf0
parent cec262b1
Branches
Tags
No related merge requests found
...@@ -45,5 +45,5 @@ atlas_add_component( CaloTrkMuIdTools ...@@ -45,5 +45,5 @@ atlas_add_component( CaloTrkMuIdTools
# Install files from the package: # Install files from the package:
atlas_install_headers( CaloTrkMuIdTools ) atlas_install_headers( CaloTrkMuIdTools )
atlas_install_joboptions( share/*.py ) atlas_install_joboptions( share/*.py )
atlas_install_runtime( share/CaloMuonLikelihood.PDF.A0.root share/CaloMuonLikelihood.PDF.A1.root share/CaloMuonLikelihood.PDF.A2.root share/CaloMuonLikelihood.PDF.B0.root share/CaloMuonLikelihood.PDF.B1.root share/CaloMuonLikelihood.PDF.B2.root share/CaloMuonLikelihood.PDF.C0.root share/CaloMuonLikelihood.PDF.C1.root share/CaloMuonLikelihood.PDF.C2.root share/CaloTag.LooseCut.root share/CaloTag.TightCut.root) atlas_install_runtime( share/CaloMuonLikelihood.PDF.A0.root share/CaloMuonLikelihood.PDF.A1.root share/CaloMuonLikelihood.PDF.A2.root share/CaloMuonLikelihood.PDF.B0.root share/CaloMuonLikelihood.PDF.B1.root share/CaloMuonLikelihood.PDF.B2.root share/CaloMuonLikelihood.PDF.C0.root share/CaloMuonLikelihood.PDF.C1.root share/CaloMuonLikelihood.PDF.C2.root share/CaloTag.CutConfig.root )
...@@ -6,12 +6,9 @@ ...@@ -6,12 +6,9 @@
#define CALOTRKMUIDTOOLS_CALOMUONTAG_H #define CALOTRKMUIDTOOLS_CALOMUONTAG_H
#include "ICaloTrkMuIdTools/ICaloMuonTag.h" #include "ICaloTrkMuIdTools/ICaloMuonTag.h"
#include "AthenaBaseComps/AthAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/MsgStream.h" #include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ITHistSvc.h"
#include "GaudiKernel/ToolHandle.h"
class TFile; class TFile;
class TH2F; class TH2F;
...@@ -59,9 +56,10 @@ private: ...@@ -59,9 +56,10 @@ private:
int getPtBinLow(double pt) const; int getPtBinLow(double pt) const;
int getCutBin(std::string cutName) const; int getCutBin(std::string cutName) const;
TH2F* m_hist; TH2F* m_hist;
std::string m_fileNames; std::string m_tagMode;
ServiceHandle<ITHistSvc> m_histSvc; StatusCode getHist(TFile* file, const char* histName, TH2F*& hist);
std::vector < std::string > m_vecCutNames; std::vector < std::string > m_vecCutNames;
std::vector < int > m_vecPtBins; std::vector < int > m_vecPtBins;
......
...@@ -41,7 +41,7 @@ apply_pattern component_library ...@@ -41,7 +41,7 @@ apply_pattern component_library
library CaloTrkMuIdTools *.cxx components/*.cxx library CaloTrkMuIdTools *.cxx components/*.cxx
apply_pattern declare_joboptions files="*.py" apply_pattern declare_joboptions files="*.py"
apply_pattern declare_runtime files="CaloMuonLikelihood.PDF.A0.root CaloMuonLikelihood.PDF.A1.root CaloMuonLikelihood.PDF.A2.root CaloMuonLikelihood.PDF.B0.root CaloMuonLikelihood.PDF.B1.root CaloMuonLikelihood.PDF.B2.root CaloMuonLikelihood.PDF.C0.root CaloMuonLikelihood.PDF.C1.root CaloMuonLikelihood.PDF.C2.root CaloTag.TightCut.root CaloTag.LooseCut.root" apply_pattern declare_runtime files="CaloMuonLikelihood.PDF.A0.root CaloMuonLikelihood.PDF.A1.root CaloMuonLikelihood.PDF.A2.root CaloMuonLikelihood.PDF.B0.root CaloMuonLikelihood.PDF.B1.root CaloMuonLikelihood.PDF.B2.root CaloMuonLikelihood.PDF.C0.root CaloMuonLikelihood.PDF.C1.root CaloMuonLikelihood.PDF.C2.root CaloTag.CutConfig.root"
#private #private
#macro cppdebugflags '$(cppdebugflags_s)' #macro cppdebugflags '$(cppdebugflags_s)'
......
File added
File deleted
File deleted
...@@ -26,12 +26,7 @@ def defineCaloLhrPdf(rootFileName, streamName=""): ...@@ -26,12 +26,7 @@ def defineCaloLhrPdf(rootFileName, streamName=""):
else: else:
raise ValueError("in CaloTrkMuIdTools_jobOptions.py: defineCaloLhrPdf(...): rootFileName: " + rootFileName + " is not an expected value (should be CaloMuonLikelihood.PDF.xx.root).") raise ValueError("in CaloTrkMuIdTools_jobOptions.py: defineCaloLhrPdf(...): rootFileName: " + rootFileName + " is not an expected value (should be CaloMuonLikelihood.PDF.xx.root).")
return [streamName + " DATAFILE='" + str(rootFile) + "' TYP='ROOT' OPT='READ'"] return [streamName + " DATAFILE='" + str(rootFile) + "' TYP='ROOT' OPT='READ'"]
def defineCaloTagCut(rootFileName, streamName="CaloTag"):
import os
from AthenaCommon.Utils.unixtools import FindFile
rootFile = FindFile(filename=rootFileName, pathlist=os.environ['DATAPATH'].split(os.pathsep), access=os.R_OK)
return [streamName + " DATAFILE='" + str(rootFile) + "' TYP='ROOT' OPT='READ'"]
############################################################################### ###############################################################################
## jobOptions ## jobOptions
############################################################################### ###############################################################################
...@@ -80,8 +75,6 @@ if athenaCommonFlags.isOnline == False: ...@@ -80,8 +75,6 @@ if athenaCommonFlags.isOnline == False:
ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C0.root"); ### PDFs for endcap region low pT ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C0.root"); ### PDFs for endcap region low pT
ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C1.root"); ### PDFs for endcap region medium pT ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C1.root"); ### PDFs for endcap region medium pT
ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C2.root"); ### PDFs for endcap region high pT ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C2.root"); ### PDFs for endcap region high pT
ServiceMgr.THistSvc.Input += defineCaloTagCut("CaloTag.LooseCut.root","CaloTagLoose"); ### Cut definition for CaloTag (Loose)
ServiceMgr.THistSvc.Input += defineCaloTagCut("CaloTag.TightCut.root","CaloTagTight"); ### Cut definition for CaloTag (Tight)
### Configure TrackEnergyInCaloTool ### ### Configure TrackEnergyInCaloTool ###
from CaloTrkMuIdTools.CaloTrkMuIdToolsConf import TrackEnergyInCaloTool as ConfiguredTrackEnergyInCaloTool from CaloTrkMuIdTools.CaloTrkMuIdToolsConf import TrackEnergyInCaloTool as ConfiguredTrackEnergyInCaloTool
......
...@@ -3,29 +3,23 @@ ...@@ -3,29 +3,23 @@
*/ */
#include "CaloTrkMuIdTools/CaloMuonTag.h" #include "CaloTrkMuIdTools/CaloMuonTag.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IToolSvc.h"
#include "GaudiKernel/ListItem.h"
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/Algorithm.h"
#include "StoreGate/StoreGateSvc.h" #include "StoreGate/StoreGateSvc.h"
#include "TFile.h" #include "TFile.h"
#include "TH2F.h" #include "TH2F.h"
#include "PathResolver/PathResolver.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
CaloMuonTag::CaloMuonTag(const std::string& type, const std::string& name, const IInterface* pInterface) : CaloMuonTag::CaloMuonTag(const std::string& type, const std::string& name, const IInterface* pInterface) :
AthAlgTool(type, name, pInterface), AthAlgTool(type, name, pInterface),
m_hist(0), m_hist(0),
m_histSvc("THistSvc/THistSvc", name),
m_numCuts(0), m_numCuts(0),
m_numPtBins(0), m_numPtBins(0),
m_numTagged(0), m_numTagged(0),
m_numRejected(0) m_numRejected(0)
{ {
declareInterface<ICaloMuonTag>(this); declareInterface<ICaloMuonTag>(this);
declareProperty("RootFileNames", m_fileNames = "/CaloTagTight/"); declareProperty("TagMode", m_tagMode = "Tight");
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -44,17 +38,9 @@ StatusCode CaloMuonTag::initialize() ...@@ -44,17 +38,9 @@ StatusCode CaloMuonTag::initialize()
} */ } */
// Retrieve histogram // Retrieve histogram
const std::string& fileName = m_fileNames; std::string rootFilePath = PathResolver::find_file("CaloTag.CutConfig.root","DATAPATH");
TList histList; TFile* rootFile = TFile::Open(rootFilePath.c_str(), "READ");
if (m_histSvc->getTHists(fileName, histList).isFailure()) { ATH_CHECK(getHist(rootFile, m_tagMode.c_str(), m_hist));
ATH_MSG_FATAL("Could not retrieve histogram stream" << fileName);
return StatusCode::FAILURE;
}
m_hist = dynamic_cast<TH2F*>(histList.At(0));
if (!m_hist) {
ATH_MSG_FATAL("Could not retrieve histograms");
return StatusCode::FAILURE;
}
// Read cut names from histogram // Read cut names from histogram
m_numCuts = m_hist->GetYaxis()->GetNbins(); m_numCuts = m_hist->GetYaxis()->GetNbins();
if (m_numCuts == 0) { if (m_numCuts == 0) {
...@@ -77,6 +63,24 @@ StatusCode CaloMuonTag::initialize() ...@@ -77,6 +63,24 @@ StatusCode CaloMuonTag::initialize()
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
///////////////////////////////////////////////////////////////////////////////
// getHist
///////////////////////////////////////////////////////////////////////////////
StatusCode CaloMuonTag::getHist(TFile* file, const char* histName, TH2F*& hist){
if (!file) {
ATH_MSG_ERROR("NULL TFile");
return StatusCode::FAILURE;
}
hist = dynamic_cast<TH2F*>(file->Get(histName));
if (!hist){
ATH_MSG_ERROR("Cannot retrieve histogram: " << histName);
return StatusCode::FAILURE;
}
hist->SetDirectory(0);
ATH_MSG_INFO("Successfully retrieved histogram: " << histName);
return StatusCode::SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// finalize // finalize
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment