8 #include <TObjString.h>
20 iEvent.getByToken(srcToken_, view);
21 passingProbes_.clear();
22 for (
size_t i = 0,
n = view->size();
i <
n; ++
i)
23 passingProbes_.push_back(view->refAt(
i));
29 value_ = (
std::find(passingProbes_.begin(), passingProbes_.end(), probe) != passingProbes_.end());
31 value_ =
bool(cut_(*probe));
41 addBranches_(tree_, iConfig, iC,
"");
44 if (iConfig.
existsAs<
double>(
"eventWeight")) {
48 weightMode_ = External;
53 if (weightMode_ !=
None) {
54 tree_->Branch(
"weight", &weight_,
"weight/F");
55 tree_->Branch(
"totWeight", &totWeight_,
"totWeight/F");
61 tree_->Branch(
"PUweight", &PUweight_,
"PUweight/F");
68 addRunLumiInfo_ = iConfig.
existsAs<
bool>(
"addRunLumiInfo") ? iConfig.
getParameter<
bool>(
"addRunLumiInfo") :
false;
69 if (addRunLumiInfo_) {
70 tree_->Branch(
"run", &run_,
"run/i");
71 tree_->Branch(
"lumi", &lumi_,
"lumi/i");
72 tree_->Branch(
"event", &
event_,
"event/l");
73 tree_->Branch(
"truePU", &truePU_,
"truePU/I");
75 addEventVariablesInfo_ =
76 iConfig.
existsAs<
bool>(
"addEventVariablesInfo") ? iConfig.
getParameter<
bool>(
"addEventVariablesInfo") :
false;
77 if (addEventVariablesInfo_) {
95 addCaloMet_ = iConfig.
existsAs<
bool>(
"addCaloMet") ? iConfig.
getParameter<
bool>(
"addCaloMet") :
true;
96 tree_->Branch(
"event_nPV", &mNPV_,
"mNPV/I");
100 tree_->Branch(
"event_met_calomet", &mMET_,
"mMET/F");
101 tree_->Branch(
"event_met_calosumet", &mSumET_,
"mSumET/F");
102 tree_->Branch(
"event_met_calometsignificance", &mMETSign_,
"mMETSign/F");
103 tree_->Branch(
"event_met_tcmet", &mtcMET_,
"mtcMET/F");
104 tree_->Branch(
"event_met_tcsumet", &mtcSumET_,
"mtcSumET/F");
105 tree_->Branch(
"event_met_tcmetsignificance", &mtcMETSign_,
"mtcMETSign/F");
107 tree_->Branch(
"event_met_pfmet", &mpfMET_,
"mpfMET/F");
108 tree_->Branch(
"event_met_pfphi", &mpfPhi_,
"mpfPhi/F");
109 tree_->Branch(
"event_met_pfsumet", &mpfSumET_,
"mpfSumET/F");
111 tree_->Branch(
"event_met_pfmetsignificance", &mpfMETSign_,
"mpfMETSign/F");
112 tree_->Branch(
"event_PrimaryVertex_x", &mPVx_,
"mPVx/F");
113 tree_->Branch(
"event_PrimaryVertex_y", &mPVy_,
"mPVy/F");
114 tree_->Branch(
"event_PrimaryVertex_z", &mPVz_,
"mPVz/F");
115 tree_->Branch(
"event_BeamSpot_x", &mBSx_,
"mBSx/F");
116 tree_->Branch(
"event_BeamSpot_y", &mBSy_,
"mBSy/F");
117 tree_->Branch(
"event_BeamSpot_z", &mBSz_,
"mBSz/F");
123 tree_->Branch(
"event_rho", &rho_,
"rho/F");
131 : addRunLumiInfo_(
false), addEventVariablesInfo_(
false), tree_(nullptr) {
145 for (std::vector<std::string>::const_iterator it = stringVars.begin(), ed = stringVars.end(); it != ed; ++it) {
150 for (std::vector<std::string>::const_iterator it = inputTagVars.begin(), ed = inputTagVars.end(); it != ed; ++it) {
157 std::vector<std::string> stringFlags =
flags.getParameterNamesForType<
std::string>();
158 for (std::vector<std::string>::const_iterator it = stringFlags.begin(), ed = stringFlags.end(); it != ed; ++it) {
162 std::vector<std::string> inputTagFlags =
flags.getParameterNamesForType<
edm::InputTag>();
163 for (std::vector<std::string>::const_iterator it = inputTagFlags.begin(), ed = inputTagFlags.end(); it != ed; ++it) {
169 for (std::vector<tnp::ProbeVariable>::iterator it = vars_.begin(), ed = vars_.end(); it != ed; ++it) {
170 tree->Branch(it->name().c_str(), it->address(), (it->name() +
"/F").c_str());
173 for (std::vector<tnp::ProbeFlag>::iterator it = flags_.begin(), ed = flags_.end(); it != ed; ++it) {
174 tree->Branch(it->name().c_str(), it->address(), (it->name() +
"/I").c_str());
182 lumi_ =
iEvent.id().luminosityBlock();
186 if (!
iEvent.isRealData() and !pileupInfoToken_.isUninitialized()) {
188 iEvent.getByToken(pileupInfoToken_, PupInfo);
189 truePU_ = PupInfo->begin()->getTrueNumInteractions();
193 for (std::vector<tnp::ProbeVariable>::const_iterator it = vars_.begin(), ed = vars_.end(); it != ed; ++it) {
196 for (std::vector<tnp::ProbeFlag>::const_iterator it = flags_.begin(), ed = flags_.end(); it != ed; ++it) {
199 if (weightMode_ == External) {
205 weight_ =
weight->weight();
206 totWeight_ *= weight_;
211 if (storePUweight_ and !PUweightSrcToken_.isUninitialized()) {
213 bool isPresent =
iEvent.getByToken(PUweightSrcToken_, weightPU);
215 PUweight_ =
float(*weightPU);
216 totWeight_ *= PUweight_;
219 if (addEventVariablesInfo_) {
223 iEvent.getByToken(recVtxsToken_, recVtxs);
229 for (
unsigned int ind = 0; ind < recVtxs->size(); ind++) {
230 if (!((*recVtxs)[ind].isFake()) && ((*recVtxs)[ind].ndof() > 4) && (fabs((*recVtxs)[ind].z()) <= 24.0) &&
231 ((*recVtxs)[ind].position().Rho() <= 2.0)) {
234 mPVx_ = (*recVtxs)[ind].x();
235 mPVy_ = (*recVtxs)[ind].y();
236 mPVz_ = (*recVtxs)[ind].z();
257 mMET_ = (*met)[0].et();
258 mSumET_ = (*met)[0].sumEt();
259 mMETSign_ = (*met)[0].significance();
264 iEvent.getByToken(tcmetToken_, tcmet);
265 if (tcmet->empty()) {
270 mtcMET_ = (*tcmet)[0].et();
271 mtcSumET_ = (*tcmet)[0].sumEt();
272 mtcMETSign_ = (*tcmet)[0].significance();
278 iEvent.getByToken(pfmetToken_, pfmet);
280 if (pfmet->empty()) {
285 mpfMET_ = (*pfmet)[0].et();
286 mpfPhi_ = (*pfmet)[0].phi();
287 mpfSumET_ = (*pfmet)[0].sumEt();
288 mpfMETSign_ = (*pfmet)[0].significance();
292 iEvent.getByToken(pfmetTokenMiniAOD_, pfmet2);
296 mpfSumET_ =
met.sumEt();
297 mpfMETSign_ =
met.significance();
302 iEvent.getByToken(rhoToken_, rhos);
309 for (
auto const &
var : vars_)
311 for (
auto const &
flag : flags_)
318 TList *
list = tree_->GetUserInfo();
319 list->Add(
new TObjString(
pset.dump().c_str()));