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<std::string> hyps_;
58 
79 };
80 
81 template <typename C>
83  verbosity_ (cfg.getParameter<int> ("verbosity" )),
84  hyps_ (cfg.getParameter<std::vector<std::string> >("hypotheses" )),
85  genEvt_ (cfg.getParameter<edm::InputTag> ("genEvent" )),
86  decayChnTop1_(cfg.getParameter<int> ("decayChannel1")),
87  decayChnTop2_(cfg.getParameter<int> ("decayChannel2"))
88 {
89  // parameter subsets for kKinFit
90  if( cfg.exists("kinFit") ) {
91  kinFit_ = cfg.getParameter<edm::ParameterSet>("kinFit");
94  }
95  // parameter subsets for kKinSolution
96  if( cfg.exists("kinSolution") ) {
97  kinSolution_ = cfg.getParameter<edm::ParameterSet>("kinSolution");
100  }
101  // parameter subsets for kGenMatch
102  if( cfg.exists("genMatch") ) {
103  genMatch_ = cfg.getParameter<edm::ParameterSet>("genMatch");
106  }
107  // parameter subsets for kMvaDisc
108  if( cfg.exists("mvaDisc") ) {
109  mvaDisc_ = cfg.getParameter<edm::ParameterSet>("mvaDisc");
112  }
113  // produces a TtEventEvent for:
114  // * TtSemiLeptonicEvent
115  // * TtFullLeptonicEvent
116  // * TtFullHadronicEvent
117  // from hypotheses and associated extra information
118  produces<C>();
119 }
120 
121 template <typename C>
122 void
124 {
125  C ttEvent;
126 
127  // set leptonic decay channels
128  ttEvent.setLepDecays( WDecay::LeptonType(decayChnTop1_), WDecay::LeptonType(decayChnTop2_) );
129 
130  // set genEvent (if available)
132  if( evt.getByLabel(genEvt_, genEvt) )
133  ttEvent.setGenEvent(genEvt);
134 
135  // add event hypotheses for all given
136  // hypothesis classes to the TtEvent
137  typedef std::vector<std::string>::const_iterator EventHypo;
138  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
140  evt.getByLabel(*h, "Key", key);
141 
143  evt.getByLabel(*h, hypMatchVec);
144 
145  typedef std::vector<TtEvent::HypoCombPair>::const_iterator HypMatch;
146  for(HypMatch hm=hypMatchVec->begin(); hm != hypMatchVec->end(); ++hm){
147  ttEvent.addEventHypo((TtEvent::HypoClassKey&)*key, *hm);
148  }
149  }
150 
151  // set kKinFit extras
152  if( ttEvent.isHypoAvailable(TtEvent::kKinFit) ) {
154  evt.getByLabel(fitChi2_, fitChi2);
155  ttEvent.setFitChi2( *fitChi2 );
156 
158  evt.getByLabel(fitProb_, fitProb);
159  ttEvent.setFitProb( *fitProb );
160  }
161 
162  // set kGenMatch extras
163  if( ttEvent.isHypoAvailable(TtEvent::kGenMatch) ) {
165  evt.getByLabel(sumPt_, sumPt);
166  ttEvent.setGenMatchSumPt( *sumPt );
167 
169  evt.getByLabel(sumDR_, sumDR);
170  ttEvent.setGenMatchSumDR( *sumDR );
171  }
172 
173  // set kMvaDisc extras
174  if( ttEvent.isHypoAvailable(TtEvent::kMVADisc) ) {
176  evt.getByLabel(meth_, meth);
177  ttEvent.setMvaMethod( *meth );
178 
180  evt.getByLabel(disc_, disc);
181  ttEvent.setMvaDiscriminators( *disc );
182  }
183 
184  // fill data members that are decay-channel specific
185  fillSpecific(ttEvent, evt);
186 
187  // print summary via MessageLogger if verbosity_>0
188  ttEvent.print(verbosity_);
189 
190  // write object into the edm::Event
191  std::auto_ptr<C> pOut(new C);
192  *pOut=ttEvent;
193  evt.put(pOut);
194 }
195 
196 template <>
198 {
199 }
200 
201 template <>
203 {
204 
205  // set kKinSolution extras
206  if( ttEvent.isHypoAvailable(TtEvent::kKinSolution) ) {
208  evt.getByLabel(solWeight_, solWeight);
209  ttEvent.setSolWeight( *solWeight );
210 
211  edm::Handle<bool> wrongCharge;
212  evt.getByLabel(wrongCharge_, wrongCharge);
213  ttEvent.setWrongCharge( *wrongCharge );
214  }
215 
216 }
217 
218 template <>
220 {
221 
222  // set number of real neutrino solutions for all hypotheses
223  typedef std::vector<std::string>::const_iterator EventHypo;
224  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
226  evt.getByLabel(*h, "Key", key);
227 
228  edm::Handle<int> numberOfRealNeutrinoSolutions;
229  evt.getByLabel(*h, "NumberOfRealNeutrinoSolutions", numberOfRealNeutrinoSolutions);
230 
231  ttEvent.setNumberOfRealNeutrinoSolutions((TtEvent::HypoClassKey&)*key, *numberOfRealNeutrinoSolutions);
232  }
233 
234 }
235 
236 #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
edm::InputTag fitProb_
Definition: TtEvtBuilder.h:63
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: TtEvtBuilder.h:123
edm::InputTag sumDR_
Definition: TtEvtBuilder.h:73
TtEvtBuilder(const edm::ParameterSet &)
default constructor
Definition: TtEvtBuilder.h:82
edm::InputTag genEvt_
TtGenEvent.
Definition: TtEvtBuilder.h:53
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:71
edm::InputTag solWeight_
Definition: TtEvtBuilder.h:67
~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:84
virtual void fillSpecific(C &, const edm::Event &)
fill data members that are decay-channel specific
std::vector< std::string > hyps_
vector of hypothesis class names
Definition: TtEvtBuilder.h:51
edm::InputTag sumPt_
Definition: TtEvtBuilder.h:72
int verbosity_
vebosity level
Definition: TtEvtBuilder.h:49
edm::ParameterSet mvaDisc_
Definition: TtEvtBuilder.h:76
Class derived from the TtEvent for the full leptonic decay channel.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
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:68
edm::ParameterSet kinSolution_
Definition: TtEvtBuilder.h:66
Class derived from the TtEvent for the full hadronic decay channel.
edm::InputTag disc_
Definition: TtEvtBuilder.h:78
edm::InputTag fitChi2_
Definition: TtEvtBuilder.h:62
list key
Definition: combine.py:13
edm::InputTag meth_
Definition: TtEvtBuilder.h:77
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4