Commit 9d7f975a authored by Elemer Nagy's avatar Elemer Nagy
Browse files

Filled histograms with off-line PV data

parent a8364b26
......@@ -68,15 +68,27 @@ def TrigBjetMonConfig(inputFlags):
print " ==> bjet_triglist: ", bjet_triglist
expert = []
shifter = []
expertI = []
shifterI = []
eI = 0
sI = 0
for chain in bjet_triglist :
if chain[0:1] == "E" :
expert.append(chain[2:])
eI = eI + 1
expertI.append(str(eI))
if chain[0:1] == "S" :
shifter.append(chain[2:])
sI = sI + 1
shifterI.append(str(sI))
print " ==> expert folder: ", expert
print " ==> shifter folder: ", shifter
trigBjetMonAlg.expert = expert
trigBjetMonAlg.shifter = shifter
print " ==> expertI folder: ", expertI
print " ==> shifterI folder: ", shifterI
trigBjetMonAlg.expertI = expertI
trigBjetMonAlg.shifterI = shifterI
# Add some tools. N.B. Do not use your own trigger decion tool. Use the
# standard one that is included with AthMonitorAlgorithm.
......@@ -111,7 +123,8 @@ def TrigBjetMonConfig(inputFlags):
print " ==> expert[0]: ", expert[0]
for i in range ( len(expert) ) :
EHist = 'E' + str(i+1) + 'd0;E' + str(i+1) + 'd0'
#EHist = 'E' + str(i+1) + 'd0;E' + str(i+1) + 'd0'
EHist = 'E' + str(i+1) + 'd0'
print " ==> EHist: ", EHist
myGroup.defineHistogram(EHist, title='Distribution of d0;d0;Events',
path=expert[i],xbins=10,xmin=-1.0,xmax=1.0)
......@@ -134,7 +147,8 @@ def TrigBjetMonConfig(inputFlags):
print " ==> shifter[0]: ", shifter[0]
for i in range ( len(shifter) ) :
SHist = 'S' + str(i+1) + 'd0;S' + str(i+1) + 'd0'
#SHist = 'S' + str(i+1) + 'd0;S' + str(i+1) + 'd0'
SHist = 'S' + str(i+1) + 'd0'
print " ==> SHist: ", SHist
shifterGroup.defineHistogram(SHist, title='Distribution of d0;d0;Events',
path=shifter[i],xbins=10,xmin=-1.0,xmax=1.0)
......@@ -144,8 +158,16 @@ def TrigBjetMonConfig(inputFlags):
#shifterGroup.defineHistogram('S2d0;S2d0', title='Distribution of d0;d0;Events',
# path=shifter[1],xbins=10,xmin=-1.0,xmax=1.0)
shifterGroup.defineHistogram('S2IP3D_pu;S2IP3D_pu', title='IP3D_pu probability distribution;IP3D_pu;Events',
path=shifter[1],xbins=50,xmin=0.0,xmax=1.0)
shifterGroup.defineHistogram('Off_NVtx', title='Number of Offline Vertices;NVtx;Events',
path='Offline',xbins=100,xmin=0.0,xmax=100.)
shifterGroup.defineHistogram('Off_xVtx', title='Offline xVtx;xVtx;Events',
path='Offline',xbins=200,xmin=-1.5,xmax=+1.5)
shifterGroup.defineHistogram('Off_yVtx', title='Offline yVtx;yVtx;Events',
path='Offline',xbins=200,xmin=-1.5,xmax=+1.5)
shifterGroup.defineHistogram('Off_zVtx', title='Offline zVtx;zVtx;Events',
path='Offline',xbins=200,xmin=-200.0,xmax=+200.0)
#shifterGroup.defineHistogram('run',title='Run Number;run;Events',
# path='SomePath',xbins=1000000,xmin=-0.5,xmax=999999.5)
......@@ -197,6 +219,6 @@ if __name__=='__main__':
cfg.printConfig(withDetails=True) # set True for exhaustive info
Nevents = 10
# cfg.run(Nevents)
#cfg.run(Nevents)
cfg.run() #use cfg.run(20) to only run on first 20 events
......@@ -8,9 +8,15 @@ TrigBjetMonitorAlgorithm::TrigBjetMonitorAlgorithm( const std::string& name, ISv
: AthMonitorAlgorithm(name,pSvcLocator)
,m_doRandom(true)
,m_expert{},m_shifter{}
,m_MuonContainerKey("Muons")
,m_VertexContainerKey("PrimaryVertices")
{
declareProperty ("expert", m_expert);
declareProperty ("shifter", m_shifter);
declareProperty ("expertI", m_expertI);
declareProperty ("shifterI", m_shifterI);
declareProperty("MuonContainerName",m_MuonContainerKey);
declareProperty("VertexContainerName",m_VertexContainerKey);
}
......@@ -18,6 +24,8 @@ TrigBjetMonitorAlgorithm::~TrigBjetMonitorAlgorithm() {}
StatusCode TrigBjetMonitorAlgorithm::initialize() {
ATH_CHECK( m_MuonContainerKey.initialize() );
ATH_CHECK( m_VertexContainerKey.initialize() );
return AthMonitorAlgorithm::initialize();
}
......@@ -66,31 +74,88 @@ StatusCode TrigBjetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) c
ATH_MSG_INFO(" Chain number: " << i << " Shifter Chain Name: " << chainName );
}
/* Verifiy if the trigger chain was fired */
/* Verifiy if the trigger chain was fired and if yes, fill the corresponding histogram*/
auto tool = getGroup("TrigBjetMonitor");
std::string NameF = "E";
int i = 0;
for ( auto& trigName : m_expert ) {
if ( m_trigDecTool->isPassed(trigName) ) {
std::cout << " Trigger chain from expert folder: " << trigName << " has fired !!! " << std::endl;
std::string NameH = NameF + m_expertI.at(i) + "d0";
std::cout << " i: " << i << " NameH: " << NameH << std::endl;
auto d0 = Monitored::Scalar<float>(NameH,0.0);
// here should come the retrival of d0 from the Trigger Track Container
fill(tool,d0);
} else {
std::cout << " Trigger chain from expert folder: " << trigName << " has not fired " << std::endl;
}
i++;
} // for
NameF = "S";
i = 0;
for ( auto& trigName : m_shifter ) {
if ( m_trigDecTool->isPassed(trigName) ) {
std::cout << " Trigger chain from shifter folder: " << trigName << " has fired !!! " << std::endl;
std::string NameH = NameF + m_shifterI.at(i) + "d0";
std::cout << " i: " << i << " NameH: " << NameH << std::endl;
auto d0 = Monitored::Scalar<float>(NameH,0.0);
// here should come the retrival of d0 from the Trigger Track Container
fill(tool,d0);
} else {
std::cout << " Trigger chain from shifter folder: " << trigName << " has not fired " << std::endl;
}
i++;
} // for
/* Read muons */
auto pT_mu = Monitored::Scalar<float>("pT_mu",0.0);
SG::ReadHandle<xAOD::MuonContainer> muons(m_MuonContainerKey, ctx);
if (! muons.isValid() ) {
ATH_MSG_ERROR("evtStore() does not contain muon Collection with name "<< m_MuonContainerKey);
return StatusCode::FAILURE;
}
for (const auto& muonItr : *muons) {
pT_mu = muonItr->pt();
std::cout << " pT_mu: " << pT_mu << std::endl;
}
/* Read off-line PV's and fill histograms */
auto OffNVtx = Monitored::Scalar<int>("Off_NVtx",0);
auto OffxVtx = Monitored::Scalar<float>("Off_xVtx",0.0);
auto OffyVtx = Monitored::Scalar<float>("Off_yVtx",0.0);
auto OffzVtx = Monitored::Scalar<float>("Off_zVtx",0.0);
SG::ReadHandle<xAOD::VertexContainer> offlinepv(m_VertexContainerKey, ctx);
if (! offlinepv.isValid() ) {
ATH_MSG_ERROR("evtStore() does not contain VertexContainer Collection with name "<< m_VertexContainerKey);
return StatusCode::FAILURE;
}
std::cout << " Size of the Off-line PV container: " << offlinepv->size() << std::endl;
OffNVtx = offlinepv->size() ;
fill(tool,OffNVtx);
for (unsigned int j = 0; j<offlinepv->size(); j++){
OffxVtx = (*(offlinepv))[j]->x();
OffyVtx = (*(offlinepv))[j]->y();
OffzVtx = (*(offlinepv))[j]->z();
fill(tool,OffxVtx);
fill(tool,OffyVtx);
fill(tool,OffzVtx);
}
/* Fill some of the histograms with random values */
/*
auto E1d0 = Monitored::Scalar<float>("E1d0",0.0);
auto E2d0 = Monitored::Scalar<float>("E2d0",0.0);
auto S1d0 = Monitored::Scalar<float>("S1d0",0.0);
auto S2d0 = Monitored::Scalar<float>("S2d0",0.0);
auto S2IP3D_pu = Monitored::Scalar<float>("S2IP3D_pu",0.0);
auto random = Monitored::Scalar<float>("random",0.0);
*/
//auto S2IP3D_pu = Monitored::Scalar<float>("S2IP3D_pu",0.0);
//auto random = Monitored::Scalar<float>("random",0.0);
// Set the values of the monitored variables for the event
/*
......@@ -99,16 +164,19 @@ StatusCode TrigBjetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) c
S1d0 = -0.01;
S2d0 = +0.01;
*/
S2IP3D_pu = 0.5;
//S2IP3D_pu = 0.5;
// TRandom r;
/*
TRandom r(ctx.eventID().event_number());
TRandom q(ctx.eventID().event_number());
*/
std::cout << " E1d0 before: " << E1d0 << std::endl;
std::cout << " S2d0 before: " << S2d0 << std::endl;
std::cout << " random before: " << random << std::endl;
std::cout << " m_doRandom " << m_doRandom << std::endl;
//std::cout << " E1d0 before: " << E1d0 << std::endl;
//std::cout << " S2d0 before: " << S2d0 << std::endl;
//std::cout << " random before: " << random << std::endl;
//std::cout << " m_doRandom " << m_doRandom << std::endl;
/*
if (m_doRandom) {
E1d0 = r.Gaus(0.,0.1);
E2d0 = r.Gaus(0.,0.2);
......@@ -119,21 +187,21 @@ StatusCode TrigBjetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) c
std::cout << " S2d0 in: " << S2d0 << std::endl;
std::cout << " random in: " << random << std::endl;
}
std::cout << " E1d0 after: " << E1d0 << std::endl;
std::cout << " S2d0 after: " << S2d0 << std::endl;
std::cout << " S2IP3D_pu after: " << S2IP3D_pu << std::endl;
std::cout << " random after: " << random << std::endl;
*/
//std::cout << " E1d0 after: " << E1d0 << std::endl;
//std::cout << " S2d0 after: " << S2d0 << std::endl;
//std::cout << " S2IP3D_pu after: " << S2IP3D_pu << std::endl;
//std::cout << " random after: " << random << std::endl;
// Fill. First argument is the tool name, all others are the variables to be saved.
/*
fill("TrigBjetMonitor",E1d0,S1d0);
// Alternative fill method. Get the group yourself, and pass it to the fill function.
auto tool = getGroup("TrigBjetMonitor");
fill(tool,E2d0);
fill(tool,S2d0);
fill(tool,S2IP3D_pu);
*/
//fill(tool,S2IP3D_pu);
return StatusCode::SUCCESS;
......
......@@ -10,6 +10,11 @@
#include "TRandom3.h"
#include "StoreGate/ReadHandleKey.h"
#include "xAODMuon/MuonContainer.h"
#include "xAODTracking/VertexContainer.h"
class TrigBjetMonitorAlgorithm : public AthMonitorAlgorithm {
public:
TrigBjetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator );
......@@ -20,6 +25,10 @@ class TrigBjetMonitorAlgorithm : public AthMonitorAlgorithm {
// Gaudi::Property<bool> m_doRandom {this,"RandomHist",false};
Gaudi::Property<bool> m_doRandom {this,"RandomHist",true};
std::vector<std::string> m_expert;
std::vector<std::string> m_expertI;
std::vector<std::string> m_shifter;
std::vector<std::string> m_shifterI;
SG::ReadHandleKey<xAOD::MuonContainer> m_MuonContainerKey;
SG::ReadHandleKey<xAOD::VertexContainer> m_VertexContainerKey;
};
#endif
Markdown is supported
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