Commit 7004ecf0 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
parent 51a0aba1
......@@ -45,5 +45,5 @@ atlas_add_component( CaloTrkMuIdTools
# Install files from the package:
atlas_install_headers( CaloTrkMuIdTools )
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 @@
#define CALOTRKMUIDTOOLS_CALOMUONTAG_H
#include "ICaloTrkMuIdTools/ICaloMuonTag.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ITHistSvc.h"
#include "GaudiKernel/ToolHandle.h"
class TFile;
class TH2F;
......@@ -59,9 +56,10 @@ private:
int getPtBinLow(double pt) const;
int getCutBin(std::string cutName) const;
TH2F* m_hist;
std::string m_fileNames;
ServiceHandle<ITHistSvc> m_histSvc;
std::string m_tagMode;
StatusCode getHist(TFile* file, const char* histName, TH2F*& hist);
std::vector < std::string > m_vecCutNames;
std::vector < int > m_vecPtBins;
......
......@@ -41,7 +41,7 @@ apply_pattern component_library
library CaloTrkMuIdTools *.cxx components/*.cxx
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
#macro cppdebugflags '$(cppdebugflags_s)'
......
......@@ -26,12 +26,7 @@ def defineCaloLhrPdf(rootFileName, streamName=""):
else:
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'"]
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
###############################################################################
......@@ -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.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 += 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 ###
from CaloTrkMuIdTools.CaloTrkMuIdToolsConf import TrackEnergyInCaloTool as ConfiguredTrackEnergyInCaloTool
......
......@@ -3,29 +3,23 @@
*/
#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 "TFile.h"
#include "TH2F.h"
#include "PathResolver/PathResolver.h"
///////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////
CaloMuonTag::CaloMuonTag(const std::string& type, const std::string& name, const IInterface* pInterface) :
AthAlgTool(type, name, pInterface),
m_hist(0),
m_histSvc("THistSvc/THistSvc", name),
m_numCuts(0),
m_numPtBins(0),
m_numTagged(0),
m_numRejected(0)
{
declareInterface<ICaloMuonTag>(this);
declareProperty("RootFileNames", m_fileNames = "/CaloTagTight/");
declareProperty("TagMode", m_tagMode = "Tight");
}
///////////////////////////////////////////////////////////////////////////////
......@@ -44,17 +38,9 @@ StatusCode CaloMuonTag::initialize()
} */
// Retrieve histogram
const std::string& fileName = m_fileNames;
TList histList;
if (m_histSvc->getTHists(fileName, histList).isFailure()) {
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;
}
std::string rootFilePath = PathResolver::find_file("CaloTag.CutConfig.root","DATAPATH");
TFile* rootFile = TFile::Open(rootFilePath.c_str(), "READ");
ATH_CHECK(getHist(rootFile, m_tagMode.c_str(), m_hist));
// Read cut names from histogram
m_numCuts = m_hist->GetYaxis()->GetNbins();
if (m_numCuts == 0) {
......@@ -77,6 +63,24 @@ StatusCode CaloMuonTag::initialize()
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
///////////////////////////////////////////////////////////////////////////////
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment