CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelCPEGenericESProducer.cc
Go to the documentation of this file.
9 
14 
15 // new record
17 
18 
19 #include <string>
20 #include <memory>
21 
22 #define NEW_CPEERROR // must be constistent with base.cc, generic cc/h and genericProducer.cc
23 
24 using namespace edm;
25 
27 {
28  std::string myname = p.getParameter<std::string>("ComponentName");
29  // Use LA-width from DB. If both (upper and this) are false LA-width is calcuated from LA-offset
30  useLAWidthFromDB_ = p.existsAs<bool>("useLAWidthFromDB")?
31  p.getParameter<bool>("useLAWidthFromDB"):false;
32  // Use Alignment LA-offset
33  useLAAlignmentOffsets_ = p.existsAs<bool>("useLAAlignmentOffsets")?
34  p.getParameter<bool>("useLAAlignmentOffsets"):false;
35  magname_ = p.existsAs<edm::ESInputTag>("MagneticFieldRecord")?
36  p.getParameter<edm::ESInputTag>("MagneticFieldRecord"):edm::ESInputTag("");
37  UseErrorsFromTemplates_ = p.getParameter<bool>("UseErrorsFromTemplates");
38 
39 
40  pset_ = p;
41  setWhatProduced(this,myname);
42 
43  //std::cout<<" ESProducer "<<myname<<" "<<useLAWidthFromDB_<<" "<<useLAAlignmentOffsets_<<" "
44  // <<UseErrorsFromTemplates_<<std::endl; //dk
45 
46 }
47 
49 
50 boost::shared_ptr<PixelClusterParameterEstimator>
52 
54  iRecord.getRecord<IdealMagneticFieldRecord>().get( magname_, magfield );
55 
57  iRecord.getRecord<TrackerDigiGeometryRecord>().get( pDD );
58 
60  iRecord.getRecord<TrackerDigiGeometryRecord>().getRecord<TrackerTopologyRcd>().get(hTT);
61 
62  // Lorant angle for offsets
63  ESHandle<SiPixelLorentzAngle> lorentzAngle;
64  if(useLAAlignmentOffsets_) // LA offsets from alignment
65  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("fromAlignment",lorentzAngle );
66  else // standard LA, from calibration, label=""
67  iRecord.getRecord<SiPixelLorentzAngleRcd>().get(lorentzAngle );
68 
69  // add the new la width object
70  ESHandle<SiPixelLorentzAngle> lorentzAngleWidth;
71  const SiPixelLorentzAngle * lorentzAngleWidthProduct = 0;
72  if(useLAWidthFromDB_) { // use the width LA
73  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("forWidth",lorentzAngleWidth );
74  lorentzAngleWidthProduct = lorentzAngleWidth.product();
75  } else { lorentzAngleWidthProduct = NULL;} // do not use it
76  //std::cout<<" la width "<<lorentzAngleWidthProduct<<std::endl; //dk
77 
78  const SiPixelGenErrorDBObject * genErrorDBObjectProduct = 0;
79 
80 #ifdef NEW_CPEERROR
81  // Errors take only from new GenError
82  ESHandle<SiPixelGenErrorDBObject> genErrorDBObject;
83  if(UseErrorsFromTemplates_) { // do only when generrors are needed
84  iRecord.getRecord<SiPixelGenErrorDBObjectRcd>().get(genErrorDBObject);
85  genErrorDBObjectProduct = genErrorDBObject.product();
86  //} else {
87  //std::cout<<" pass an empty GenError pointer"<<std::endl;
88  }
89  cpe_ = boost::shared_ptr<PixelClusterParameterEstimator>
90  (new PixelCPEGeneric(pset_,magfield.product(),*pDD.product(),
91  *hTT.product(),lorentzAngle.product(),
92  genErrorDBObjectProduct,lorentzAngleWidthProduct) );
93 
94 #else // old full templates, not used anymore
95  // Errors can be used from tempaltes or from GenError, for testing only
96  const bool useNewSimplerErrors = false;
97  if(useNewSimplerErrors) { // new genError object
98  ESHandle<SiPixelGenErrorDBObject> genErrorDBObject;
99  iRecord.getRecord<SiPixelGenErrorDBObjectRcd>().get(genErrorDBObject); //needs new TKPixelCPERecord.h
100  genErrorDBObjectProduct = genErrorDBObject.product();
101  }
102 
103  // errors come from templates
104  ESHandle<SiPixelTemplateDBObject> templateDBobject;
105  iRecord.getRecord<SiPixelTemplateDBObjectESProducerRcd>().get(templateDBobject);
106 
107  cpe_ = boost::shared_ptr<PixelClusterParameterEstimator>(new PixelCPEGeneric(
108  pset_,magfield.product(),*pDD.product(),*hTT.product(),lorentzAngle.product(),genErrorDBObjectProduct,
109  templateDBobject.product(),lorentzAngleWidthProduct) );
110 #endif
111 
112  return cpe_;
113 }
114 
115 
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
tuple magfield
Definition: HLT_ES_cff.py:2311
#define NULL
Definition: scimark2.h:8
void get(HolderT &iHolder) const
T const * product() const
Definition: ESHandle.h:86
boost::shared_ptr< PixelClusterParameterEstimator > produce(const TkPixelCPERecord &)
PixelCPEGenericESProducer(const edm::ParameterSet &p)