CMS 3D CMS Logo

Constrained_Z.cc
Go to the documentation of this file.
1 //
2 //
3 // File: Constrained_Z.cc
4 // Purpose: Do kinematic fitting for a (Z->ll)+jets event.
5 // Created: Apr, 2004, sss
6 //
7 // CMSSW File : src/Constrained_Z.cc
8 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
9 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
10 //
11 
40 #include <ostream>
41 #include <cassert>
42 #include <cstdio>
43 
44 namespace hitfit {
45 
46  //*************************************************************************
47  // Argument handling.
48  //
49 
51  //
52  // Purpose: Constructor.
53  //
54  // Inputs:
55  // defs - The Defaults instance from which to initialize.
56  //
57  : _zmass(defs.get_float("zmass")), _fourvec_constrainer_args(defs) {}
58 
60  //
61  // Purpose: Return the zmass parameter.
62  // See the header for documentation.
63  //
64  {
65  return _zmass;
66  }
67 
69  //
70  // Purpose: Return the contained subobject parameters.
71  //
72  {
74  }
75 
76  //*************************************************************************
77 
79  //
80  // Purpose: Constructor.
81  //
82  // Inputs:
83  // args - The parameter settings for this instance.
84  //
85  : _args(args), _constrainer(args.fourvec_constrainer_args()) {
86  char buf[256];
87  sprintf(buf, "(%d) = %f", lepton_label, _args.zmass());
89  }
90 
91  namespace {
92 
107  FE_Obj make_fe_obj(const Lepjets_Event_Lep& obj, double mass, int type)
108  //
109  // Purpose: Helper to create an object to put into the Fourvec_Event.
110  //
111  // Inputs:
112  // obj - The input object.
113  // mass - The mass to which it should be constrained.
114  // type - The type to assign it.
115  //
116  // Returns:
117  // The constructed FE_Obj.
118  //
119  {
120  return FE_Obj(obj.p(), mass, type, obj.p_sigma(), obj.eta_sigma(), obj.phi_sigma(), obj.res().p_res().inverse());
121  }
122 
138  void do_import(const Lepjets_Event& ev, Fourvec_Event& fe)
139  //
140  // Purpose: Convert from a Lepjets_Event to a Fourvec_Event.
141  //
142  // Inputs:
143  // ev - The input event.
144  //
145  // Outputs:
146  // fe - The initialized Fourvec_Event.
147  //
148  {
149  assert(ev.nleps() >= 2);
150  fe.add(make_fe_obj(ev.lep(0), 0, lepton_label));
151  fe.add(make_fe_obj(ev.lep(1), 0, lepton_label));
152 
153  for (std::vector<Lepjets_Event_Jet>::size_type j = 0; j < ev.njets(); j++)
154  fe.add(make_fe_obj(ev.jet(j), 0, isr_label));
155 
156  Fourvec kt = ev.kt();
157  fe.set_kt_error(ev.kt_res().sigma(kt.x()), ev.kt_res().sigma(kt.y()), 0);
158  fe.set_x_p(ev.met());
159  }
160 
177  void do_export(const Fourvec_Event& fe, Lepjets_Event& ev)
178  //
179  // Purpose: Convert from a Fourvec_Event to a Lepjets_Event.
180  //
181  // Inputs:
182  // fe - The input event.
183  // ev - The original Lepjets_Event.
184  //
185  // Outputs:
186  // ev - The updated Lepjets_Event.
187  //
188  {
189  ev.lep(0).p() = fe.obj(0).p;
190  ev.lep(1).p() = fe.obj(1).p;
191 
192  for (std::vector<Lepjets_Event_Jet>::size_type j = 0, k = 1; j < ev.njets(); j++)
193  ev.jet(j).p() = fe.obj(k++).p;
194 
195  Fourvec nu;
196  ev.met() = nu;
197  }
198 
199  } // unnamed namespace
200 
202  //
203  // Purpose: Do a constrained fit for EV.
204  // Returns the pull quantities in PULL.
205  // Returns the chisq; this will be < 0 if the fit failed
206  // to converge.
207  //
208  // Inputs:
209  // ev - The event we're fitting.
210  //
211  // Outputs:
212  // ev - The fitted event.
213  // pull - Pull quantities for well-measured variables.
214  //
215  // Returns:
216  // The fit chisq, or < 0 if the fit didn't converge.
217  //
218  {
219  Fourvec_Event fe;
220  do_import(ev, fe);
221  Column_Vector pully;
222  double m, sigm;
223  double chisq = _constrainer.constrain(fe, m, sigm, pull, pully);
224  do_export(fe, ev);
225 
226  return chisq;
227  }
228 
236  std::ostream& operator<<(std::ostream& s, const Constrained_Z& cz)
237  //
238  // Purpose: Print the object to S.
239  //
240  // Inputs:
241  // s - The stream to which to write.
242  // cz - The object to write.
243  //
244  // Returns:
245  // The stream S.
246  //
247  {
248  return s << cz._constrainer;
249  }
250 
251 } // namespace hitfit
writedatasetfile.args
args
Definition: writedatasetfile.py:18
hitfit::Constrained_Z_Args::zmass
double zmass() const
Definition: Constrained_Z.cc:59
hitfit::Column_Vector
CLHEP::HepVector Column_Vector
Definition: matutil.h:63
hitfit
Definition: Base_Constrainer.h:43
hitfit::Constrained_Z_Args::Constrained_Z_Args
Constrained_Z_Args(const Defaults &defs)
Constructor, initialize from a Defaults object.
Definition: Constrained_Z.cc:50
hitfit::Fourvec
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:55
Fourvec_Event.h
Represent an event for kinematic fitting as a collection of four-momenta.
hitfit::Constrained_Z
Do a constrained kinematic fitting for a event.
Definition: Constrained_Z.h:102
cms::cuda::assert
assert(be >=bs)
hitfit::Constrained_Z::_args
const Constrained_Z_Args & _args
Definition: Constrained_Z.h:147
Defaults.h
Define an abstract interface for getting parameter settings.
watchdog.const
const
Definition: watchdog.py:83
hitfit::Fourvec_Event
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
Definition: Fourvec_Event.h:193
Constrained_Z.h
Do a constrained kinematic fit of a event.
hitfit::FE_Obj
Represent a single object in a Fourvec_Event, this is just a dumb data container. Each object in a Fo...
Definition: Fourvec_Event.h:90
Lepjets_Event.h
Represent a simple event consisting of lepton(s) and jet(s).
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
hitfit::Lepjets_Event
Represent a simple event consisting of lepton(s) and jet(s). An instance of this class holds a list o...
Definition: Lepjets_Event.h:62
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
dqmdumpme.k
k
Definition: dqmdumpme.py:60
hitfit::operator<<
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream.
Definition: Constraint_Intermed.cc:268
hitfit::Constrained_Z_Args::_fourvec_constrainer_args
Fourvec_Constrainer_Args _fourvec_constrainer_args
Definition: Constrained_Z.h:92
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
hitfit::Constrained_Z::_constrainer
Fourvec_Constrainer _constrainer
Definition: Constrained_Z.h:153
hitfit::Constrained_Z::Constrained_Z
Constrained_Z(const Constrained_Z_Args &args)
Constructor, create an instance of the Constrained_Z object from the argument object.
Definition: Constrained_Z.cc:78
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
hitfit::Fourvec_Constrainer::constrain
double constrain(Fourvec_Event &ev, double &m, double &sigm, Column_Vector &pullx, Column_Vector &pully)
Do a constrained fit for event ev. Returns the requested mass and its uncertainty in m and sigm,...
Definition: Fourvec_Constrainer.cc:1612
hitfit::Constrained_Z::constrain
double constrain(Lepjets_Event &ev, Column_Vector &pull)
Do a constrained fit of event. Returns the pull quantities in pull. Returns the ,...
Definition: Constrained_Z.cc:201
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
hitfit::Constrained_Z_Args::_zmass
double _zmass
Definition: Constrained_Z.h:86
hitfit::Constrained_Z_Args
Hold on to parameters for the Constrained_Z class.
Definition: Constrained_Z.h:49
hitfit::Constrained_Z_Args::fourvec_constrainer_args
const Fourvec_Constrainer_Args & fourvec_constrainer_args() const
Definition: Constrained_Z.cc:68
hitfit::Fourvec_Constrainer::add_constraint
void add_constraint(std::string s)
Specify an additional constraint s for the problem. The format for s is described in the class descri...
Definition: Fourvec_Constrainer.cc:183
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
hitfit::Defaults
Define an interface for getting parameter settings.
Definition: Defaults.h:57
hitfit::Fourvec_Constrainer_Args
Hold on to parameters for the Fourvec_Constrainer class.
Definition: Fourvec_Constrainer.h:93
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hitfit::isr_label
Definition: Lepjets_Event_Jet.h:55
hitfit::lepton_label
Definition: Lepjets_Event_Lep.h:52
hitfit::Lepjets_Event_Lep
Represent a lepton in an instance of Lepjets_Event class. This class hold the following information:
Definition: Lepjets_Event_Lep.h:64