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.
7 
12 
13 // new record
15 
16 
17 #include <string>
18 #include <memory>
19 
20 //#define NEW_CPEERROR // must be constistent with base.cc, generic cc/h and genericProducer.cc
21 
22 using namespace edm;
23 
25 {
26  std::string myname = p.getParameter<std::string>("ComponentName");
27  // Use LA-width from DB. If both (upper and this) are false LA-width is calcuated from LA-offset
28  useLAWidthFromDB_ = p.existsAs<bool>("useLAWidthFromDB")?
29  p.getParameter<bool>("useLAWidthFromDB"):false;
30  // Use Alignment LA-offset
31  useLAAlignmentOffsets_ = p.existsAs<bool>("useLAAlignmentOffsets")?
32  p.getParameter<bool>("useLAAlignmentOffsets"):false;
33  magname_ = p.existsAs<edm::ESInputTag>("MagneticFieldRecord")?
34  p.getParameter<edm::ESInputTag>("MagneticFieldRecord"):edm::ESInputTag("");
35 
36  pset_ = p;
37  setWhatProduced(this,myname);
38 
39  //std::cout<<" ESProducer "<<myname<<" "<<useLAWidthFromDB_<<" "<<useLAAlignmentOffsets_<<std::endl; //dk
40 
41 }
42 
44 
45 boost::shared_ptr<PixelClusterParameterEstimator>
47 
49  iRecord.getRecord<IdealMagneticFieldRecord>().get( magname_, magfield );
50 
52  iRecord.getRecord<TrackerDigiGeometryRecord>().get( pDD );
53 
54  // Lorant angle for offsets
55  ESHandle<SiPixelLorentzAngle> lorentzAngle;
56  if(useLAAlignmentOffsets_) // LA offsets from alignment
57  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("fromAlignment",lorentzAngle );
58  else // standard LA, from calibration, label=""
59  iRecord.getRecord<SiPixelLorentzAngleRcd>().get(lorentzAngle );
60 
61  // add the new la width object
62  ESHandle<SiPixelLorentzAngle> lorentzAngleWidth;
63  const SiPixelLorentzAngle * lorentzAngleWidthProduct = 0;
64  if(useLAWidthFromDB_) { // use the width LA
65  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("forWidth",lorentzAngleWidth );
66  lorentzAngleWidthProduct = lorentzAngleWidth.product();
67  } else { lorentzAngleWidthProduct = NULL;} // do not use it
68  //std::cout<<" la width "<<lorentzAngleWidthProduct<<std::endl; //dk
69 
70  const SiPixelGenErrorDBObject * genErrorDBObjectProduct = 0;
71 
72 #ifdef NEW_CPEERROR
73  // Errors take only from new GenError
74  ESHandle<SiPixelGenErrorDBObject> genErrorDBObject;
75  iRecord.getRecord<SiPixelGenErrorDBObjectRcd>().get(genErrorDBObject); //needs new TKPixelCPERecord.h
76  genErrorDBObjectProduct = genErrorDBObject.product();
77 
78  cpe_ = boost::shared_ptr<PixelClusterParameterEstimator>(new PixelCPEGeneric(
79  pset_,magfield.product(),*pDD.product(),lorentzAngle.product(),genErrorDBObjectProduct,
80  lorentzAngleWidthProduct) );
81 
82 #else
83  // Errors can be used from tempaltes or from GenError, for testing only
84  const bool useNewSimplerErrors = false;
85  if(useNewSimplerErrors) { // new genError object
86  ESHandle<SiPixelGenErrorDBObject> genErrorDBObject;
87  iRecord.getRecord<SiPixelGenErrorDBObjectRcd>().get(genErrorDBObject); //needs new TKPixelCPERecord.h
88  genErrorDBObjectProduct = genErrorDBObject.product();
89  }
90 
91  // errors come from templates
92  ESHandle<SiPixelTemplateDBObject> templateDBobject;
93  iRecord.getRecord<SiPixelTemplateDBObjectESProducerRcd>().get(templateDBobject);
94 
95  cpe_ = boost::shared_ptr<PixelClusterParameterEstimator>(new PixelCPEGeneric(
96  pset_,magfield.product(),*pDD.product(),lorentzAngle.product(),genErrorDBObjectProduct,
97  templateDBobject.product(),lorentzAngleWidthProduct) );
98 #endif
99 
100  return cpe_;
101 }
102 
103 
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:184
tuple magfield
Definition: HLT_ES_cff.py:2311
#define NULL
Definition: scimark2.h:8
T const * product() const
Definition: ESHandle.h:62
boost::shared_ptr< PixelClusterParameterEstimator > produce(const TkPixelCPERecord &)
PixelCPEGenericESProducer(const edm::ParameterSet &p)