CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
TkMSParameterizationBuilder Class Referencefinal
Inheritance diagram for TkMSParameterizationBuilder:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

using ReturnType = std::shared_ptr< TkMSParameterization >
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

ReturnType produce (TkMSParameterizationRecord const &)
 
 TkMSParameterizationBuilder (edm::ParameterSet const &)
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Public Attributes

ReturnType product
 
std::string theNavigationSchoolName
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

Definition at line 59 of file TkMSParameterizationBuilder.cc.

Member Typedef Documentation

Definition at line 69 of file TkMSParameterizationBuilder.cc.

Constructor & Destructor Documentation

TkMSParameterizationBuilder::TkMSParameterizationBuilder ( edm::ParameterSet const &  pset)

Definition at line 76 of file TkMSParameterizationBuilder.cc.

References edm::ESProducer::setWhatProduced().

76  :
77  theNavigationSchoolName(pset.getParameter<std::string>("navigationSchool")){
78  setWhatProduced(this,"");
79 }
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115

Member Function Documentation

static void TkMSParameterizationBuilder::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 62 of file TkMSParameterizationBuilder.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

62  {
64  // desc.add<std::string>("ComponentName","TkMSParameterization");
65  desc.add<std::string>("navigationSchool","SimpleNavigationSchool");
66  descriptions.add("TkMSParameterizationBuilder",desc);
67  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TkMSParameterizationBuilder::ReturnType TkMSParameterizationBuilder::produce ( TkMSParameterizationRecord const &  iRecord)

Definition at line 82 of file TkMSParameterizationBuilder.cc.

References a, funct::abs(), alongMomentum, b, patCaloMETCorrections_cff::C, Chi2MeasurementEstimator_cfi::Chi2MeasurementEstimator, GeometricSearchDet::compatibleDets(), constexpr, funct::cos(), gather_cfg::cout, edmIntegrityCheck::d, debug, DEFINE_FWK_EVENTSETUP_MODULE, MillePedeFileConverter_cfg::e, relativeConstraints::empty, f, TkNavigationSchool::field(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), TrajectoryStateOnSurface::globalPosition(), runTauDisplay::gp, hcalSimParameters_cfi::he, cuy::ib, hcalTTPDigis_cfi::id, createfilelist::int, tkMSParameterization::lmBin(), create_public_lumi_plots::loc, histoParameters_cff::maxLayers, min(), NavigationSchool::nextLayers(), tkMSParameterization::nLmBins(), groupFilesInBlocks::nn, tkMSParameterization::packLID(), phi, PlaneBuilder::plane(), product, edm::ESHandle< T >::product(), EnergyCorrector::pt, alignCSCRings::r, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, TkNavigationSchool::searchTracker(), DetLayer::seqNum(), funct::sin(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, theNavigationSchoolName, ErrorFrameTransformer::transform(), KFUpdator::update(), z, PV3DBase< T, PVType, FrameType >::z(), spu::zerr(), and geometryCSVtoXML::zz.

82  {
83 
84  using namespace tkMSParameterization;
85 
86  product = std::make_shared<TkMSParameterization>();
87 
88  auto & msParam = *product;
89 
90  //
92  iRecord.getRecord<NavigationSchoolRecord>().get(theNavigationSchoolName, navSchoolH);
93  TkNavigationSchool const & navSchool = *(TkNavigationSchool const *)navSchoolH.product();
94  auto const & searchGeom = navSchool.searchTracker();
95  auto const & magfield = navSchool.field();
96 
97  //
98  edm::ESHandle<Propagator> propagatorHandle;
99  iRecord.getRecord<TrackingComponentsRecord>().get("PropagatorWithMaterial", propagatorHandle);
100  auto const & ANprop = *propagatorHandle;
101 
102 
103  // error (very very small)
104  ROOT::Math::SMatrixIdentity id;
106  C *= 1.e-16;
107 
109 
110  Chi2MeasurementEstimator estimator(30.,-3.0,0.5,2.0,0.5,1.e12); // same as defauts....
111  KFUpdator kfu;
112  LocalError he(0.001*0.001,0,0.002*0.002);
113 
114 
115  // loop over lambdas
116  bool debug = false;
117  float tl=0;
118  for (decltype(nLmBins()) ib=0; ib<nLmBins(); ++ib, tl+=lmBin()) {
119 
120  float pt = 1.0f;
121  float tanlmd = tl; // 0.1f;
122  auto sinth2 = 1.f/(1.f+tanlmd*tanlmd);
123  auto sinth = std::sqrt(sinth2);
124  auto overp = sinth/pt;
125  auto pz = pt*tanlmd;
126 
127  // debug= (tl>2.34f && tl<2.55f);
128  if(debug) std::cout << tl << ' ' << pz << ' ' << 1./overp << std::endl;
129 
130 
131  float lastzz=-18.f;
132  bool goFw=false;
133  std::string loc=" Barrel";
134  for (int iz=0;iz<2; ++iz) {
135  if (iz>0) goFw=true;
136  for (float zz=lastzz; zz<18.1f; zz+=0.2f) {
137  float z = zz;
138  GlobalPoint startingPosition(0,0,z);
139 
140  constexpr int maxLayers=6;
141 
142  std::vector<MSData> mserr[maxLayers][maxLayers];
143 
144  // define propagation from/to
145  std::function<void(int, TrajectoryStateOnSurface, DetLayer const *, float, int)>
146  propagate = [&](int from, TrajectoryStateOnSurface tsos, DetLayer const * layer, float z1, int stid) {
147 
148  for (auto il=from+1; il<maxLayers; ++il) {
149 
150  auto compLayers = navSchool.nextLayers(*layer,*tsos.freeState(),alongMomentum);
151  std::stable_sort(compLayers.begin(),compLayers.end(),[](auto a, auto b){return a->seqNum()<b->seqNum();});
152  layer = nullptr;
153  for(auto it : compLayers){
154  if (it->basicComponents().empty()) {
155  //this should never happen. but better protect for it
156  edm::LogError("TkMSParameterizationBuilder") <<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate.";
157  continue;
158  }
159  if (debug) std::cout << il << (it->isBarrel() ? " Barrel" : " Forward") << " layer " << it->seqNum() << " SubDet " << it->subDetector()<< std::endl;
160  auto const & detWithState = it->compatibleDets(tsos,ANprop,estimator);
161  if(!detWithState.size()) {
162  if(debug) std::cout << "no det on this layer" << it->seqNum() << std::endl;
163  continue;
164  }
165  layer = it;
166  auto did = detWithState.front().first->geographicalId();
167  if (debug) std::cout << "arrived at " << int(did) << std::endl;
168  tsos = detWithState.front().second;
169  if(debug) std::cout << tsos.globalPosition() << ' ' << tsos.localError().positionError() << std::endl;
170 
171 
172  // save errs
173  auto globalError = ErrorFrameTransformer::transform(tsos.localError().positionError(), tsos.surface());
174  auto gp = tsos.globalPosition();
175  float r = gp.perp();
176  float errorPhi = std::sqrt(float(globalError.phierr(gp)));
177  float errorR = std::sqrt(float(globalError.rerr(gp)));
178  float errorZ = std::sqrt(float(globalError.czz()));
179  float xerr = overp*errorPhi;
180  float zerr = overp*(layer->isBarrel() ? errorZ : errorR);
181  auto zo = layer->isBarrel() ? gp.z() : r;
182  // std::cout << tanlmd << ' ' << z1 << ' ' << it->seqNum() << ':' << xerr <<'/'<<zerr << std::endl;
183  mserr[from][il-1].emplace_back(MSData{stid,it->seqNum(),z1,zo,xerr,zerr});
184 
185  if (from==0) {
186  // spawn prop from this layer
187  // constrain it to this location (relevant for layer other than very first)
189  SiPixelRecHit hitpx(tsos.localPosition(),he,1.,*detWithState.front().first,pref);
190  auto tsosl = kfu.update(tsos, hitpx);
191  auto z1l = layer->isBarrel() ? tsos.globalPosition().z() : tsos.globalPosition().perp();
192  auto stidl = layer->seqNum();
193  propagate(il,tsosl,layer,z1l, stidl);
194  }
195  break;
196  } // loop on compLayers
197  if (!layer) break;
198  // if (!goFw) lastbz=z1;
199  if(from==0) lastzz=zz;
200 
201  } // layer loop
202 
203  if (debug && mserr[from][from].empty()) {
204  std::cout << "tl " << tanlmd << loc << ' ' <<from<< std::endl;
205  for (auto il=from; il<maxLayers; ++il) { std::cout << il << ' ';
206  for ( auto const & e : mserr[from][il]) std::cout << e<<' '; // << '-' <<e.uerr*sinth <<'/'<<e.verr*sinth <<' ';
207  std::cout << std::endl;
208  }
209  }
210  }; // propagate
211 
212  float phi = 0.0415f;
213  for (int ip=0;ip<5; ++ip) {
214  phi += (3.14159f/6.f)/5.f;
215  GlobalVector startingMomentum(pt*std::sin(phi),pt*std::cos(phi),pz);
216 
217  // make TSOS happy
218  //Define starting plane
219  PlaneBuilder pb;
220  auto rot = rotation(startingMomentum);
221  auto startingPlane = pb.plane( startingPosition, rot);
222 
223  TrajectoryStateOnSurface startingStateP( GlobalTrajectoryParameters(startingPosition,
224  startingMomentum, 1, &magfield),
225  err, *startingPlane);
226  auto tsos0 = startingStateP;
227 
228  DetLayer const * layer0 = searchGeom.pixelBarrelLayers()[0];
229  if (goFw) layer0 = searchGeom.posPixelForwardLayers()[0];
230  int stid0 = layer0->seqNum();
231 
232  {
233  auto it = layer0;
234  if(debug) std::cout << "first layer " << (it->isBarrel() ? " Barrel" : " Forward") << " layer " << it->seqNum() << " SubDet " << it->subDetector()<< std::endl;
235  }
236 
237  auto const & detWithState = layer0->compatibleDets(tsos0,ANprop,estimator);
238  if(!detWithState.size()) {
239  if(debug) std::cout << "no det on first layer" << layer0->seqNum() << std::endl;
240  continue;
241  }
242  tsos0 = detWithState.front().second;
243  if(debug) std::cout << "arrived at " << int(detWithState.front().first->geographicalId()) << ' ' << tsos0.globalPosition() << ' ' << tsos0.localError().positionError() << std::endl;
244 
245  // for barrel
246  float z1l = tsos0.globalPosition().z();
247  if (goFw) {
248  loc = " Forward";
249  z1l = tsos0.globalPosition().perp();
250  }
251 
252  propagate(0,tsos0,layer0,z1l,stid0);
253 
254  } // loop on phi
255 
256  // fill
257  for (auto from=0; from<maxLayers; ++from)
258  for (auto il=from; il<maxLayers; ++il) {
259  if (mserr[from][il].empty()) continue;
260  auto stid=mserr[from][il].front().stid;
261  auto lid=mserr[from][il].front().lid;
262  auto zi = mserr[from][il].front().zi;
263  float xerr =0;
264  float zerr =0;
265  float zo=0;
266  for (auto const & e : mserr[from][il]) {
267  if (e.stid!=stid) continue;
268  lid = std::min(lid,e.lid);
269  }
270  float nn=0;
271  for (auto const & e : mserr[from][il]) {
272  if (e.stid!=stid || lid!=e.lid) continue;
273  xerr+=e.uerr; zerr+=e.verr; zo+=e.zo; ++nn;
274  }
275  xerr/=nn; zerr/=nn; zo/=nn;
276  auto iid = packLID(stid,lid);
277  auto & md = msParam.data[iid].data[ib].data;
278  if (md.empty()
279  || std::abs(xerr-md.back().uerr)>0.2f*xerr
280  || std::abs(zerr-md.back().verr)>0.2f*zerr
281  ) md.emplace_back(Elem{zi,zo,xerr,zerr});
282  } // loop on layers
283 
284  }} // loop on z
285 
286  } // loop on tanLa
287 
288  // sort
289  for (auto & e : msParam.data)
290  for (auto & d : e.second.data) std::stable_sort(d.data.begin(),d.data.end(),[](auto const & a, auto const & b){return a.vo<b.vo;});
291 
292  return product;
293 }
unsigned short packLID(unsigned int id, unsigned int od)
static GlobalError transform(const LocalError &le, const Surface &surf)
void zerr(int)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Definition: PlaneBuilder.h:22
const GeometricSearchTracker & searchTracker() const
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
#define constexpr
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
int seqNum() const
Definition: DetLayer.h:36
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
const MagneticField & field() const
#define debug
Definition: HDRShower.cc:19
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
NavigationDirection.
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
T const * product() const
Definition: ESHandle.h:86
ib
Definition: cuy.py:660
Our base class.
Definition: SiPixelRecHit.h:23

Member Data Documentation

ReturnType TkMSParameterizationBuilder::product

Definition at line 73 of file TkMSParameterizationBuilder.cc.

Referenced by produce().

std::string TkMSParameterizationBuilder::theNavigationSchoolName

Definition at line 72 of file TkMSParameterizationBuilder.cc.

Referenced by produce().