ATLAS Offline Software
RPVLLTestRates.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include <iostream>
9 
10 
13 
14 RPVLLTestRates::RPVLLTestRates(const std::string& name, ISvcLocator* pSvcLocator) :
15  AthAlgorithm(name, pSvcLocator),
16  m_EventCounter(0),
17  m_tHistSvc("THistSvc",name),
18  m_myTree(0),
19  m_skimPassHist(0),
20  m_twoDskimHist(0),
21  m_runNum(0),
22  m_lumiBlock(0),
23  m_evtNum(0)
24 {
25 }
26 
30 
32 
35 
37 
39 
40  ATH_CHECK(m_tHistSvc.retrieve());
42  m_myTree= new TTree("myTree","myTree");
43  StatusCode sc = m_tHistSvc->regTree("/AANT/myTree",m_myTree);
44  if (sc.isFailure()) ATH_MSG_ERROR("Failed to book TTree");
45 
46  m_myTree->Branch("RunNumber",&m_runNum,"RunNumber/I");
47  m_myTree->Branch("LumiBlock",&m_lumiBlock,"LumiBlock/I");
48  m_myTree->Branch("EventNumber",&m_evtNum,"EventNumber/I");
49 
50  return StatusCode::SUCCESS;
51 }
52 
54  return StatusCode::SUCCESS;
55 }
56 
58 
59  const EventContext& ctx = Gaudi::Hive::currentContext();
60 
61  if (m_EventCounter==0) {
62 
65  if (SDcoll.isValid()) {
66  std::cout<<"nick - booking skimPasshist"<<std::endl;
67  m_skimPassHist = new TH1F("skim","skim",SDcoll->size(), 0.,(float)SDcoll->size());
68  m_twoDskimHist = new TH2F("skim2D","skim",SDcoll->size(),0.,(float)SDcoll->size(),SDcoll->size(), 0.,(float)SDcoll->size());
69  StatusCode sc = m_tHistSvc->regHist("/AANT/skimPass",m_skimPassHist);
70  if (sc.isFailure()) msg(MSG::ERROR)<<"Failed to book TH1"<<endmsg;
71  sc = m_tHistSvc->regHist("/AANT/skimPass2D",m_twoDskimHist);
72  if (sc.isFailure()) msg(MSG::ERROR)<<"Failed to book TH1"<<endmsg;
73 
74  m_filterPassed.resize(SDcoll->size());
75  for (unsigned int i=0; i< m_filterPassed.size(); ++i) m_filterPassed[i]=0;
76  SkimDecisionCollection::const_iterator itr=SDcoll->begin(), itrEnd = SDcoll->end();
77  int filterCount = 0;
78  for(; itr != itrEnd; ++itr) {
79  filterCount++;
80  std::string name = (*itr)->getName();
81  const char* cname = name.c_str();
82  m_skimPassHist->GetXaxis()->SetBinLabel(filterCount,cname);
83  m_twoDskimHist->GetXaxis()->SetBinLabel(filterCount,cname);
84  m_twoDskimHist->GetYaxis()->SetBinLabel(filterCount,cname);
85 
86  m_myTree->Branch(name.c_str(),&(m_filterPassed[filterCount-1]),(name+"/I").c_str());
87  }
88  }
89  }
90 
92 
93  m_runNum = ctx.eventID().run_number();
94  m_evtNum = ctx.eventID().event_number();
95  m_lumiBlock = ctx.eventID().lumi_block();
96 
97 
100  int isAc=0;
101 
102  if (SDcoll.isValid()) {
103  SkimDecisionCollection::const_iterator itr=SDcoll->begin(), itrEnd = SDcoll->end();
104  int filterCount = 0;
105  for(; itr != itrEnd; ++itr) {
106  isAc = (*itr)->isAccepted();
107  m_skimPassHist->Fill((float)filterCount+0.5,isAc);
108  m_filterPassed[filterCount] = isAc;
109  std::string name = (*itr)->getName();
110  msg(MSG::INFO) << "SkimDecName = " << name <<" isAccepted: "<< isAc << endmsg;
111 
112  if (isAc>0) {
113  int filterCount2=0;
114  SkimDecisionCollection::const_iterator itr2=SDcoll->begin(), itrEnd2 = SDcoll->end();
115  for(; itr2 != itrEnd2; ++itr2) {
116  int isAc2 = (*itr2)->isAccepted();
117  m_twoDskimHist->Fill((float)filterCount+0.5,filterCount2+0.5,isAc2);
118  filterCount2++;
119 
120  }
121  }
122  filterCount++;
123  }
124  }
125  else {
126  ATH_MSG_WARNING("No SkimDecisionCollection was found: key = DESDM_RPVLL_SkimDecisionsContaine");
127  }
128 
129 
130  m_myTree->Fill();
131 
132  return StatusCode::SUCCESS;
133 }
RPVLLTestRates::m_evtNum
int m_evtNum
Definition: RPVLLTestRates.h:52
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventBookkeeperCollection.h
RPVLLTestRates.h
RPVLLTestRates::m_twoDskimHist
TH2F * m_twoDskimHist
Definition: RPVLLTestRates.h:48
SkimDecisionCollection.h
RPVLLTestRates::finalize
virtual StatusCode finalize()
Definition: RPVLLTestRates.cxx:53
RPVLLTestRates::m_filterPassed
std::vector< int > m_filterPassed
Definition: RPVLLTestRates.h:53
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
RPVLLTestRates::initialize
virtual StatusCode initialize()
Initialize.
Definition: RPVLLTestRates.cxx:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RPVLLTestRates::execute
virtual StatusCode execute()
Definition: RPVLLTestRates.cxx:57
lumiFormat.i
int i
Definition: lumiFormat.py:92
RPVLLTestRates::m_lumiBlock
int m_lumiBlock
Definition: RPVLLTestRates.h:51
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RPVLLTestRates::m_skimPassHist
TH1F * m_skimPassHist
Definition: RPVLLTestRates.h:47
RPVLLTestRates::RPVLLTestRates
RPVLLTestRates(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: RPVLLTestRates.cxx:14
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
RPVLLTestRates::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: RPVLLTestRates.h:41
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
RPVLLTestRates::m_myTree
TTree * m_myTree
Definition: RPVLLTestRates.h:46
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
RPVLLTestRates::m_SDcollKey
SG::ReadHandleKey< SkimDecisionCollection > m_SDcollKey
Definition: RPVLLTestRates.h:54
RPVLLTestRates::m_runNum
int m_runNum
Definition: RPVLLTestRates.h:50
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
RPVLLTestRates::~RPVLLTestRates
~RPVLLTestRates()
Destructor - check up memory allocation delete any memory allocation on the heap.
Definition: RPVLLTestRates.cxx:31
RPVLLTestRates::m_EventCounter
int m_EventCounter
Definition: RPVLLTestRates.h:40
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.