5 #include "Artus/Core/interface/ConsumerBase.h"
6 #include "Artus/Utility/interface/RootFileHelper.h"
7 #include "Artus/Utility/interface/SafeMap.h"
9 #include "HiggsAnalysis/KITHiggsToTauTau/interface/HttTypes.h"
10 #include "Artus/KappaAnalysis/interface/Consumers/KappaLambdaNtupleConsumer.h"
12 template<
class TTag,
class TProbe>
20 std::vector<std::pair<TTag*, TProbe*> > product_type::*triggerTagProbeObjectPairsMember,
21 std::vector<std::pair<bool, bool> > product_type::*triggerTagProbeObjectMatchedPairsMember
25 m_triggerTagProbeObjectPairsMember(triggerTagProbeObjectPairsMember),
26 m_triggerTagProbeObjectMatchedPairsMember(triggerTagProbeObjectMatchedPairsMember)
30 virtual void Init(setting_type
const& settings, metadata_type& metadata)
override
32 ConsumerBase<HttTypes>::Init(settings, metadata);
34 RootFileHelper::SafeCd(settings.GetRootOutFile(),
35 settings.GetRootFileFolder());
36 m_tree =
new TTree(m_treeName.c_str(), m_treeName.c_str());
38 m_tree->Branch(
"tag", &m_currentTagObject);
39 m_tree->Branch(
"tagMatched", &m_currentTagObjectMatched,
"tagMatched/O");
40 m_tree->Branch(
"probe", &m_currentProbeObject);
41 m_tree->Branch(
"probeMatched", &m_currentProbeObjectMatched,
"probeMatched/O");
42 m_tree->Branch(
"tagProbeSystem", &m_tagProbeSystem);
45 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"tagPt", [
this](event_type
const& event, product_type
const& product)
47 std::vector<float> tagPt;
48 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
49 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
51 tagPt.push_back(tagProbePair->first->p4.Pt());
55 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"probePt", [
this](event_type
const& event, product_type
const& product)
57 std::vector<float> probePt;
58 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
59 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
61 probePt.push_back(tagProbePair->second->p4.Pt());
65 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"probeEta", [
this](event_type
const& event, product_type
const& product)
67 std::vector<float> probeEta;
68 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
69 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
71 probeEta.push_back(tagProbePair->second->p4.Eta());
75 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"tagProbeDeltaR", [
this](event_type
const& event, product_type
const& product)
77 std::vector<float> tagProbeDeltaR;
78 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
79 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
81 tagProbeDeltaR.push_back(ROOT::Math::VectorUtil::DeltaR(tagProbePair->first->p4, tagProbePair->second->p4));
83 return tagProbeDeltaR;
85 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"tagProbeMass", [
this](event_type
const& event, product_type
const& product)
87 std::vector<float> tagProbeMass;
88 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
89 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
91 tagProbeMass.push_back((tagProbePair->first->p4 + tagProbePair->second->p4).M());
95 LambdaNtupleConsumer<HttTypes>::AddVIntQuantity(metadata,
"probeMatched", [
this](event_type
const& event, product_type
const& product)
97 std::vector<int> probeMatched;
98 for (
typename std::vector<std::pair<bool, bool> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectMatchedPairsMember)).begin();
99 tagProbePair != (product.*(this->m_triggerTagProbeObjectMatchedPairsMember)).end(); ++tagProbePair)
101 probeMatched.push_back(tagProbePair->second);
105 LambdaNtupleConsumer<HttTypes>::AddVIntQuantity(metadata,
"tagMatched", [
this](event_type
const& event, product_type
const& product)
107 std::vector<int> tagMatched;
108 for (
typename std::vector<std::pair<bool, bool> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectMatchedPairsMember)).begin();
109 tagProbePair != (product.*(this->m_triggerTagProbeObjectMatchedPairsMember)).end(); ++tagProbePair)
111 tagMatched.push_back(tagProbePair->first);
115 LambdaNtupleConsumer<HttTypes>::AddVIntQuantity(metadata,
"tagCharge", [
this](event_type
const& event, product_type
const& product)
117 std::vector<int> tagCharge;
118 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
119 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
121 tagCharge.push_back(tagProbePair->first->charge());
125 LambdaNtupleConsumer<HttTypes>::AddVIntQuantity(metadata,
"probeCharge", [
this](event_type
const& event, product_type
const& product)
127 std::vector<int> probeCharge;
128 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
129 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
131 probeCharge.push_back(tagProbePair->second->charge());
135 LambdaNtupleConsumer<HttTypes>::AddVIntQuantity(metadata,
"isOS", [
this](event_type
const& event, product_type
const& product)
137 std::vector<int> isOS;
138 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
139 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
141 isOS.push_back(
int((tagProbePair->first->charge()*tagProbePair->second->charge())<0));
145 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"tagIsoOverPt", [
this](event_type
const& event, product_type
const& product)
147 std::vector<float> tagIsoOverPt;
148 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
149 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
151 tagIsoOverPt.push_back(tagProbePair->first->pfIso() / tagProbePair->first->p4.Pt());
155 LambdaNtupleConsumer<HttTypes>::AddVFloatQuantity(metadata,
"tagIso", [
this](event_type
const& event, product_type
const& product)
157 std::vector<float> tagIso;
158 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*(this->m_triggerTagProbeObjectPairsMember)).begin();
159 tagProbePair != (product.*(this->m_triggerTagProbeObjectPairsMember)).end(); ++tagProbePair)
161 tagIso.push_back(tagProbePair->first->pfIso() / tagProbePair->first->p4.Pt());
168 setting_type
const& settings, metadata_type
const& metadata)
override
171 for (
typename std::vector<std::pair<TTag*, TProbe*> >::const_iterator tagProbePair = (product.*m_triggerTagProbeObjectPairsMember).begin();
172 tagProbePair != (product.*m_triggerTagProbeObjectPairsMember).end(); ++tagProbePair)
174 m_currentTagObject = *(tagProbePair->first);
175 m_currentProbeObject = *(tagProbePair->second);
177 m_currentTagObjectMatched = (product.*m_triggerTagProbeObjectMatchedPairsMember).at(index).first;
178 m_currentProbeObjectMatched = (product.*m_triggerTagProbeObjectMatchedPairsMember).at(index).second;
180 m_tagProbeSystem = tagProbePair->first->p4 + tagProbePair->second->p4;
187 virtual void Finish(setting_type
const& settings, metadata_type
const& metadata)
override
189 RootFileHelper::SafeCd(settings.GetRootOutFile(),
190 settings.GetRootFileFolder());
192 m_tree->Write(m_tree->GetName());
197 std::string m_treeName;
198 std::vector<std::pair<TTag*, TProbe*> > product_type::*m_triggerTagProbeObjectPairsMember;
199 std::vector<std::pair<bool, bool> > product_type::*m_triggerTagProbeObjectMatchedPairsMember;
201 TTree* m_tree =
nullptr;
203 TTag m_currentTagObject;
204 bool m_currentTagObjectMatched;
205 TProbe m_currentProbeObject;
206 bool m_currentProbeObjectMatched;
207 RMFLV m_tagProbeSystem;
TriggerTagAndProbeConsumerBase(std::string treeName, std::vector< std::pair< TTag *, TProbe * > > product_type::*triggerTagProbeObjectPairsMember, std::vector< std::pair< bool, bool > > product_type::*triggerTagProbeObjectMatchedPairsMember)
Definition: TriggerTagAndProbeConsumers.h:18
MTTriggerTagAndProbeConsumer()
Definition: TriggerTagAndProbeConsumers.cc:35
Definition: TriggerTagAndProbeConsumers.h:220
virtual std::string GetConsumerId() const override
Definition: TriggerTagAndProbeConsumers.cc:29
MMTriggerTagAndProbeConsumer()
Definition: TriggerTagAndProbeConsumers.cc:5
Definition: TriggerTagAndProbeConsumers.h:236
virtual std::string GetConsumerId() const override
Definition: TriggerTagAndProbeConsumers.cc:44
index
Definition: makePlots_shapeUncertainties.py:54
Definition: TriggerTagAndProbeConsumers.h:13
EETriggerTagAndProbeConsumer()
Definition: TriggerTagAndProbeConsumers.cc:20
virtual void ProcessFilteredEvent(event_type const &event, product_type const &product, setting_type const &settings, metadata_type const &metadata) override
Definition: TriggerTagAndProbeConsumers.h:167
Definition: TriggerTagAndProbeConsumers.h:228
Definition: TriggerTagAndProbeConsumers.h:212
ETTriggerTagAndProbeConsumer()
Definition: TriggerTagAndProbeConsumers.cc:50
virtual std::string GetConsumerId() const override
Definition: TriggerTagAndProbeConsumers.cc:59
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: TriggerTagAndProbeConsumers.h:30
all data types which are used for Htt analyses
Definition: HttTypes.h:27
virtual std::string GetConsumerId() const override
Definition: TriggerTagAndProbeConsumers.cc:14
virtual void Finish(setting_type const &settings, metadata_type const &metadata) override
Definition: TriggerTagAndProbeConsumers.h:187