CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TtEvtBuilder.h
Go to the documentation of this file.
1 #ifndef TtEvtBuilder_h
2 #define TtEvtBuilder_h
3 
4 #include <vector>
5 
11 
28 template <typename C>
29 class TtEvtBuilder : public edm::EDProducer {
30 
31  public:
32 
34  explicit TtEvtBuilder(const edm::ParameterSet&);
37 
38  private:
39 
42  virtual void produce(edm::Event&, const edm::EventSetup&);
44  virtual void fillSpecific(C&, const edm::Event&);
45 
46  private:
47 
51  std::vector<edm::InputTag> hyps_;
58 
86 };
87 
88 template <typename C>
90  verbosity_ (cfg.getParameter<int> ("verbosity" )),
91  hyps_ (cfg.getParameter<std::vector<edm::InputTag> >("hypotheses" )),
92  genEvt_ (cfg.getParameter<edm::InputTag> ("genEvent" )),
93  decayChnTop1_(cfg.getParameter<int> ("decayChannel1")),
94  decayChnTop2_(cfg.getParameter<int> ("decayChannel2"))
95 {
96  // parameter subsets for kKinFit
97  if( cfg.exists("kinFit") ) {
98  kinFit_ = cfg.getParameter<edm::ParameterSet>("kinFit");
101  }
102  // parameter subsets for kHitFit
103  if( cfg.exists("hitFit") ) {
104  hitFit_ = cfg.getParameter<edm::ParameterSet>("hitFit");
109  }
110  // parameter subsets for kKinSolution
111  if( cfg.exists("kinSolution") ) {
112  kinSolution_ = cfg.getParameter<edm::ParameterSet>("kinSolution");
115  }
116  // parameter subsets for kGenMatch
117  if( cfg.exists("genMatch") ) {
118  genMatch_ = cfg.getParameter<edm::ParameterSet>("genMatch");
121  }
122  // parameter subsets for kMvaDisc
123  if( cfg.exists("mvaDisc") ) {
124  mvaDisc_ = cfg.getParameter<edm::ParameterSet>("mvaDisc");
127  }
128  // produces a TtEventEvent for:
129  // * TtSemiLeptonicEvent
130  // * TtFullLeptonicEvent
131  // * TtFullHadronicEvent
132  // from hypotheses and associated extra information
133  produces<C>();
134 }
135 
136 template <typename C>
137 void
139 {
140  C ttEvent;
141 
142  // set leptonic decay channels
143  ttEvent.setLepDecays( WDecay::LeptonType(decayChnTop1_), WDecay::LeptonType(decayChnTop2_) );
144 
145  // set genEvent (if available)
147  if( evt.getByLabel(genEvt_, genEvt) )
148  ttEvent.setGenEvent(genEvt);
149 
150  // add event hypotheses for all given
151  // hypothesis classes to the TtEvent
152  typedef std::vector<edm::InputTag>::const_iterator EventHypo;
153  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
155  evt.getByLabel(h->label(), "Key", key);
156 
158  evt.getByLabel(*h, hypMatchVec);
159 
160  typedef std::vector<TtEvent::HypoCombPair>::const_iterator HypMatch;
161  for(HypMatch hm=hypMatchVec->begin(); hm != hypMatchVec->end(); ++hm){
162  ttEvent.addEventHypo((TtEvent::HypoClassKey&)*key, *hm);
163  }
164  }
165 
166  // set kKinFit extras
167  if( ttEvent.isHypoAvailable(TtEvent::kKinFit) ) {
169  evt.getByLabel(fitChi2_, fitChi2);
170  ttEvent.setFitChi2( *fitChi2 );
171 
173  evt.getByLabel(fitProb_, fitProb);
174  ttEvent.setFitProb( *fitProb );
175  }
176 
177  // set kHitFit extras
178  if( ttEvent.isHypoAvailable(TtEvent::kHitFit) ) {
179  edm::Handle<std::vector<double> > hitFitChi2;
180  evt.getByLabel(hitFitChi2_, hitFitChi2);
181  ttEvent.setHitFitChi2( *hitFitChi2 );
182 
183  edm::Handle<std::vector<double> > hitFitProb;
184  evt.getByLabel(hitFitProb_, hitFitProb);
185  ttEvent.setHitFitProb( *hitFitProb );
186 
188  evt.getByLabel(hitFitMT_, hitFitMT);
189  ttEvent.setHitFitMT( *hitFitMT );
190 
191  edm::Handle<std::vector<double> > hitFitSigMT;
192  evt.getByLabel(hitFitSigMT_, hitFitSigMT);
193  ttEvent.setHitFitSigMT( *hitFitSigMT );
194  }
195 
196  // set kGenMatch extras
197  if( ttEvent.isHypoAvailable(TtEvent::kGenMatch) ) {
199  evt.getByLabel(sumPt_, sumPt);
200  ttEvent.setGenMatchSumPt( *sumPt );
201 
203  evt.getByLabel(sumDR_, sumDR);
204  ttEvent.setGenMatchSumDR( *sumDR );
205  }
206 
207  // set kMvaDisc extras
208  if( ttEvent.isHypoAvailable(TtEvent::kMVADisc) ) {
210  evt.getByLabel(meth_, meth);
211  ttEvent.setMvaMethod( *meth );
212 
214  evt.getByLabel(disc_, disc);
215  ttEvent.setMvaDiscriminators( *disc );
216  }
217 
218  // fill data members that are decay-channel specific
219  fillSpecific(ttEvent, evt);
220 
221  // print summary via MessageLogger if verbosity_>0
222  ttEvent.print(verbosity_);
223 
224  // write object into the edm::Event
225  std::auto_ptr<C> pOut(new C);
226  *pOut=ttEvent;
227  evt.put(pOut);
228 }
229 
230 template <>
232 {
233 }
234 
235 template <>
237 {
238 
239  // set kKinSolution extras
240  if( ttEvent.isHypoAvailable(TtEvent::kKinSolution) ) {
242  evt.getByLabel(solWeight_, solWeight);
243  ttEvent.setSolWeight( *solWeight );
244 
245  edm::Handle<bool> wrongCharge;
246  evt.getByLabel(wrongCharge_, wrongCharge);
247  ttEvent.setWrongCharge( *wrongCharge );
248  }
249 
250 }
251 
252 template <>
254 {
255 
256  typedef std::vector<edm::InputTag>::const_iterator EventHypo;
257  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
259  evt.getByLabel(h->label(), "Key", key);
260 
261  // set number of real neutrino solutions for all hypotheses
262  edm::Handle<int> numberOfRealNeutrinoSolutions;
263  evt.getByLabel(h->label(), "NumberOfRealNeutrinoSolutions", numberOfRealNeutrinoSolutions);
264  ttEvent.setNumberOfRealNeutrinoSolutions((TtEvent::HypoClassKey&)*key, *numberOfRealNeutrinoSolutions);
265 
266  // set number of considered jets for all hypotheses
267  edm::Handle<int> numberOfConsideredJets;
268  evt.getByLabel(h->label(), "NumberOfConsideredJets", numberOfConsideredJets);
269  ttEvent.setNumberOfConsideredJets((TtEvent::HypoClassKey&)*key, *numberOfConsideredJets);
270  }
271 
272 }
273 
274 #endif
void setWrongCharge(const bool &val)
set right or wrong charge combination of kKinSolution hypothesis
T getParameter(std::string const &) const
HypoClassKey
supported classes of event hypotheses
Definition: TtEvent.h:31
bool isHypoAvailable(const std::string &key, const unsigned &cmb=0) const
Definition: TtEvent.h:60
std::vector< edm::InputTag > hyps_
vector of hypothesis class names
Definition: TtEvtBuilder.h:51
edm::InputTag fitProb_
Definition: TtEvtBuilder.h:63
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: TtEvtBuilder.h:138
edm::InputTag sumDR_
Definition: TtEvtBuilder.h:80
TtEvtBuilder(const edm::ParameterSet &)
default constructor
Definition: TtEvtBuilder.h:89
edm::InputTag genEvt_
TtGenEvent.
Definition: TtEvtBuilder.h:53
edm::InputTag hitFitProb_
Definition: TtEvtBuilder.h:68
bool exists(std::string const &parameterName) const
checks if a parameter exists
void setNumberOfRealNeutrinoSolutions(const HypoClassKey &key, const int &nr)
set number of real neutrino solutions for a given hypo class
Class derived from the TtEvent for the semileptonic decay channel.
static double fitChi2(const CachingVertex< 5 > &vtx)
edm::ParameterSet genMatch_
Definition: TtEvtBuilder.h:78
edm::InputTag solWeight_
Definition: TtEvtBuilder.h:74
~TtEvtBuilder()
default destructor
Definition: TtEvtBuilder.h:36
Template class to fill the TtEvent structure.
Definition: TtEvtBuilder.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void fillSpecific(C &, const edm::Event &)
fill data members that are decay-channel specific
edm::InputTag sumPt_
Definition: TtEvtBuilder.h:79
int verbosity_
vebosity level
Definition: TtEvtBuilder.h:49
edm::ParameterSet mvaDisc_
Definition: TtEvtBuilder.h:83
Class derived from the TtEvent for the full leptonic decay channel.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void setSolWeight(const std::vector< double > &val)
set weight of kKinSolution hypothesis
edm::ParameterSet kinFit_
Definition: TtEvtBuilder.h:61
edm::InputTag wrongCharge_
Definition: TtEvtBuilder.h:75
edm::ParameterSet kinSolution_
Definition: TtEvtBuilder.h:73
Class derived from the TtEvent for the full hadronic decay channel.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::InputTag hitFitChi2_
Definition: TtEvtBuilder.h:67
edm::InputTag disc_
Definition: TtEvtBuilder.h:85
edm::InputTag hitFitMT_
Definition: TtEvtBuilder.h:69
edm::ParameterSet hitFit_
Definition: TtEvtBuilder.h:66
void setNumberOfConsideredJets(const HypoClassKey &key, const unsigned int nJets)
set number of jets considered when building a given hypothesis
Definition: TtEvent.h:123
edm::InputTag fitChi2_
Definition: TtEvtBuilder.h:62
list key
Definition: combine.py:13
edm::InputTag meth_
Definition: TtEvtBuilder.h:84
edm::InputTag hitFitSigMT_
Definition: TtEvtBuilder.h:70
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")