00001 // 00002 // $Id: Constraint_Intermed.h,v 1.1 2011/05/26 09:46:53 mseidel Exp $ 00003 // 00004 // File: hitfit/private/Constraint_Intermed.h 00005 // Purpose: Represent one side of a mass constraint equation. 00006 // Created: Jul, 2000, sss, based on run 1 mass analysis code. 00007 // 00008 // Mass constraints come in two varieties, either saying that the sum 00009 // of a set of labels should equal a constant: 00010 // 00011 // (1 + 2) = 80 00012 // 00013 // or that two such sums should equal each other: 00014 // 00015 // (1 + 2) = (3 + 4) 00016 // 00017 // These classes represent one side of such an equation. 00018 // There is an abstract base class Constraint_Intermed, and then concrete 00019 // implementations for the two cases, Constraint_Intermed_Constant 00020 // and Constraint_Intermed_Labels. There is also a free function 00021 // make_constraint_intermed() to parse a string representing one 00022 // side of a constraint and return the appropriate Constraint_Intermed 00023 // instance. 00024 // 00025 // CMSSW File : interface/Constraint_Intermed.h 00026 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0 00027 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch> 00028 // 00029 00030 00073 #ifndef HITFIT_CONSTRAINT_INTERMED_H 00074 #define HITFIT_CONSTRAINT_INTERMED_H 00075 00076 00077 #include <iosfwd> 00078 #include <vector> 00079 #include <string> 00080 #include <memory> 00081 00082 00083 namespace hitfit { 00084 00085 00086 class Fourvec_Event; 00087 00088 00089 //************************************************************************ 00090 00091 00097 class Constraint_Intermed 00098 // 00099 // Purpose: Abstract base class for describing one side of a mass constraint. 00100 // 00101 { 00102 public: 00103 // Constructor, destructor. 00104 00108 Constraint_Intermed () {} 00109 00113 virtual ~Constraint_Intermed () {} 00114 00115 // Return true if this guy references both labels ILABEL and JLABEL. 00129 virtual bool has_labels (int ilabel, int jlabel) const = 0; 00130 00131 // Evaluate this half of the mass constraint, using the data in EV. 00132 // Return m^2/2. 00141 virtual double sum_mass_terms (const Fourvec_Event& ev) const = 0; 00142 00143 // Print out this object. 00149 virtual void print (std::ostream& s) const = 0; 00150 00151 // Copy this object. 00155 virtual std::auto_ptr<Constraint_Intermed> clone () const = 0; 00156 }; 00157 00158 00159 //************************************************************************ 00160 00161 00168 class Constraint_Intermed_Constant 00169 : public Constraint_Intermed 00170 // 00171 // Purpose: Concrete base class for a constant mass constraint half. 00172 // 00173 { 00174 public: 00175 // Constructor, destructor. 00181 Constraint_Intermed_Constant (double constant); 00182 00186 virtual ~Constraint_Intermed_Constant () {}; 00187 00188 // Copy constructor. 00193 Constraint_Intermed_Constant (const Constraint_Intermed_Constant& c); 00194 00195 // Return true if this guy references both labels ILABEL and JLABEL. 00209 virtual bool has_labels (int ilabel, int jlabel) const; 00210 00211 // Evaluate this half of the mass constraint, using the data in EV. 00212 // Return m^2/2. 00221 virtual double sum_mass_terms (const Fourvec_Event& ev) const; 00222 00223 // Print out this object. 00229 virtual void print (std::ostream& s) const; 00230 00231 // Copy this object. 00235 virtual std::auto_ptr<Constraint_Intermed> clone () const; 00236 00237 private: 00238 // Store c^2 / 2. 00242 double _c2; 00243 }; 00244 00245 00246 //************************************************************************ 00247 00248 00258 class Constraint_Intermed_Labels 00259 : public Constraint_Intermed 00260 { 00261 public: 00262 00267 Constraint_Intermed_Labels (const std::vector<int>& labels); 00268 00273 Constraint_Intermed_Labels (const Constraint_Intermed_Labels& c); 00277 virtual ~Constraint_Intermed_Labels () {}; 00278 00279 // Return true if this guy references both labels ILABEL and JLABEL. 00293 virtual bool has_labels (int ilabel, int jlabel) const; 00294 00295 // Evaluate this half of the mass constraint, using the data in EV. 00296 // Return m^2/2. 00305 virtual double sum_mass_terms (const Fourvec_Event& ev) const; 00306 00307 // Print out this object. 00313 virtual void print (std::ostream& s) const; 00314 00315 // Copy this object. 00319 virtual std::auto_ptr<Constraint_Intermed> clone () const; 00320 00321 private: 00322 // Test to see if LABEL is used by this constraint half. 00330 bool has_label (int label) const; 00331 00332 // List of the labels for this constraint half, kept in sorted order. 00337 std::vector<int> _labels; 00338 00339 // Disallow assignment 00343 Constraint_Intermed& operator= (const Constraint_Intermed&); 00344 }; 00345 00346 00347 00348 //************************************************************************ 00349 00350 00351 // Print out a Constraint_Intermed object. 00352 std::ostream& operator<< (std::ostream& s, const Constraint_Intermed& ci); 00353 00354 00355 // Parse the string S and construct the appropriate Constraint_Intermed 00356 // instance. 00382 std::auto_ptr<Constraint_Intermed> make_constraint_intermed (std::string s); 00383 00384 00385 } // namespace hitfit 00386 00387 00388 #endif // not HITFIT_CONSTRAINT_INTERMED_H