CMS 3D CMS Logo

PixelCPEGenericESProducer.cc
Go to the documentation of this file.
9 
14 
15 // new record
17 
18 
19 #include <string>
20 #include <memory>
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  UseErrorsFromTemplates_ = p.getParameter<bool>("UseErrorsFromTemplates");
36 
37 
38  pset_ = p;
39  setWhatProduced(this,myname);
40 
41  //std::cout<<" ESProducer "<<myname<<" "<<useLAWidthFromDB_<<" "<<useLAAlignmentOffsets_<<" "
42  // <<UseErrorsFromTemplates_<<std::endl; //dk
43 
44 }
45 
47 
48 std::unique_ptr<PixelClusterParameterEstimator>
50 
51  ESHandle<MagneticField> magfield;
52  iRecord.getRecord<IdealMagneticFieldRecord>().get( magname_, magfield );
53 
55  iRecord.getRecord<TrackerDigiGeometryRecord>().get( pDD );
56 
58  iRecord.getRecord<TrackerDigiGeometryRecord>().getRecord<TrackerTopologyRcd>().get(hTT);
59 
60  // Lorant angle for offsets
61  ESHandle<SiPixelLorentzAngle> lorentzAngle;
62  if(useLAAlignmentOffsets_) // LA offsets from alignment
63  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("fromAlignment",lorentzAngle );
64  else // standard LA, from calibration, label=""
65  iRecord.getRecord<SiPixelLorentzAngleRcd>().get(lorentzAngle );
66 
67  // add the new la width object
68  ESHandle<SiPixelLorentzAngle> lorentzAngleWidth;
69  const SiPixelLorentzAngle * lorentzAngleWidthProduct = nullptr;
70  if(useLAWidthFromDB_) { // use the width LA
71  iRecord.getRecord<SiPixelLorentzAngleRcd>().get("forWidth",lorentzAngleWidth );
72  lorentzAngleWidthProduct = lorentzAngleWidth.product();
73  } else { lorentzAngleWidthProduct = nullptr;} // do not use it
74  //std::cout<<" la width "<<lorentzAngleWidthProduct<<std::endl; //dk
75 
76  const SiPixelGenErrorDBObject * genErrorDBObjectProduct = nullptr;
77 
78  // Errors take only from new GenError
79  ESHandle<SiPixelGenErrorDBObject> genErrorDBObject;
80  if(UseErrorsFromTemplates_) { // do only when generrors are needed
81  iRecord.getRecord<SiPixelGenErrorDBObjectRcd>().get(genErrorDBObject);
82  genErrorDBObjectProduct = genErrorDBObject.product();
83  //} else {
84  //std::cout<<" pass an empty GenError pointer"<<std::endl;
85  }
86  return std::make_unique<PixelCPEGeneric>(
87  pset_,magfield.product(),*pDD.product(),
88  *hTT.product(),lorentzAngle.product(),
89  genErrorDBObjectProduct,lorentzAngleWidthProduct);
90 }
91 
92 
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
void get(HolderT &iHolder) const
HLT enums.
std::unique_ptr< PixelClusterParameterEstimator > produce(const TkPixelCPERecord &)
T const * product() const
Definition: ESHandle.h:86
PixelCPEGenericESProducer(const edm::ParameterSet &p)