src
PhysicsTools
NanoAOD
plugins
EventStringOutputBranches.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/NanoAOD/plugins/EventStringOutputBranches.h
"
2
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
3
#include "
FWCore/ParameterSet/interface/Registry.h
"
4
5
#include <iostream>
6
7
void
EventStringOutputBranches::updateEventStringNames
(TTree &
tree
,
const
std::string
&evstring) {
8
bool
found
=
false
;
9
for
(
auto
&
existing
:
m_evStringBranches
) {
10
existing
.buffer =
false
;
11
if
(evstring ==
existing
.name) {
12
existing
.buffer =
true
;
13
found
=
true
;
14
}
15
}
16
if
(!
found
&& (!evstring.empty())) {
17
NamedBranchPtr
nb(evstring,
"EventString bit"
);
18
bool
backFillValue =
false
;
19
nb.
branch
=
tree
.Branch(nb.
name
.c_str(), &backFillValue, (nb.
name
+
"/O"
).c_str());
20
nb.
branch
->SetTitle(nb.
title
.c_str());
21
for
(
size_t
i
= 0;
i
<
m_fills
;
i
++)
22
nb.
branch
->Fill();
// Back fill
23
nb.
buffer
=
true
;
24
m_evStringBranches
.push_back(nb);
25
for
(
auto
&
existing
:
m_evStringBranches
)
26
existing
.branch->SetAddress(&(
existing
.buffer));
// m_evStringBranches might have been resized
27
}
28
}
29
30
void
EventStringOutputBranches::fill
(
const
edm::EventForOutput
&
iEvent
, TTree &
tree
) {
31
if
((!
m_update_only_at_new_lumi
) ||
m_lastLumi
!=
iEvent
.id().luminosityBlock()) {
32
edm::Handle<std::string>
handle
;
33
iEvent
.getByToken(
m_token
,
handle
);
34
const
std::string
&evstring = *
handle
;
35
m_lastLumi
=
iEvent
.id().luminosityBlock();
36
updateEventStringNames
(
tree
, evstring);
37
}
38
m_fills
++;
39
}
mps_fire.i
i
Definition:
mps_fire.py:429
Registry.h
EventStringOutputBranches::NamedBranchPtr::buffer
bool buffer
Definition:
EventStringOutputBranches.h:30
EventStringOutputBranches::fill
void fill(const edm::EventForOutput &iEvent, TTree &tree)
Definition:
EventStringOutputBranches.cc:30
EventStringOutputBranches::NamedBranchPtr
Definition:
EventStringOutputBranches.h:27
EventStringOutputBranches::m_fills
unsigned long m_fills
Definition:
EventStringOutputBranches.h:36
edm::Handle
Definition:
AssociativeIterator.h:50
EventStringOutputBranches::m_evStringBranches
std::vector< NamedBranchPtr > m_evStringBranches
Definition:
EventStringOutputBranches.h:34
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
EventStringOutputBranches::m_lastLumi
long m_lastLumi
Definition:
EventStringOutputBranches.h:35
ParameterSet.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
EventStringOutputBranches::updateEventStringNames
void updateEventStringNames(TTree &, const std::string &)
Definition:
EventStringOutputBranches.cc:7
dqmPostProcessing_online.existing
existing
Definition:
dqmPostProcessing_online.py:126
EventStringOutputBranches::NamedBranchPtr::title
std::string title
Definition:
EventStringOutputBranches.h:28
patZpeak.handle
handle
Definition:
patZpeak.py:25
EventStringOutputBranches::m_update_only_at_new_lumi
bool m_update_only_at_new_lumi
Definition:
EventStringOutputBranches.h:37
EventStringOutputBranches::m_token
edm::EDGetToken m_token
Definition:
EventStringOutputBranches.h:26
edm::EventForOutput
Definition:
EventForOutput.h:50
EventStringOutputBranches::NamedBranchPtr::name
std::string name
Definition:
EventStringOutputBranches.h:28
EventStringOutputBranches.h
tree
Definition:
tree.py:1
EventStringOutputBranches::NamedBranchPtr::branch
TBranch * branch
Definition:
EventStringOutputBranches.h:29
newFWLiteAna.found
found
Definition:
newFWLiteAna.py:118
Generated for CMSSW Reference Manual by
1.8.14