CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
TkLasBeamFitter Class Reference

#include <Alignment/LaserAlignment/plugins/TkLasBeamFitter.cc>

Inheritance diagram for TkLasBeamFitter:
edm::one::EDProducer< edm::EndRunProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void endRunProduce (edm::Run &run, const edm::EventSetup &setup) override
 
void produce (edm::Event &event, const edm::EventSetup &setup) override
 
 TkLasBeamFitter (const edm::ParameterSet &config)
 
 ~TkLasBeamFitter () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void buildTrajectory (TkFittedLasBeam &beam, unsigned int &hit, vector< const GeomDetUnit * > &gd, std::vector< GlobalPoint > &globPtrack, vector< TrajectoryStateOnSurface > &tsosLas, GlobalPoint &globPref)
 
bool fitBeam (TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, double &offset, double &slope, vector< GlobalPoint > &globPtrack, double &bsAngleParam, double &chi2)
 
void fitter (TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, std::vector< double > &hitPhi, std::vector< double > &hitPhiError, std::vector< double > &hitZprimeError, double &zMin, double &zMax, double &bsAngleParam, double &offset, double &offsetError, double &slope, double &slopeError, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam)
 
void getLasBeams (TkFittedLasBeam &beam, vector< TrajectoryStateOnSurface > &tsosLas)
 
void getLasHits (TkFittedLasBeam &beam, const SiStripLaserRecHit2D &hit, vector< const GeomDetUnit * > &gd, vector< GlobalPoint > &globHit, unsigned int &hitsAtTecPlus)
 
void globalTrackPoint (TkFittedLasBeam &beam, unsigned int &hit, unsigned int &hitsAtTecPlus, double &trackPhi, double &trackPhiRef, std::vector< GlobalPoint > &globHit, std::vector< GlobalPoint > &globPtrack, GlobalPoint &globPref, std::vector< double > &hitPhiError)
 
void trackPhi (TkFittedLasBeam &beam, unsigned int &hit, double &trackPhi, double &trackPhiRef, double &offset, double &slope, double &bsAngleParam, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam, std::vector< GlobalPoint > &globHit)
 

Static Private Member Functions

static double atFunction (double *x, double *par)
 
static double tecMinusFunction (double *x, double *par)
 
static double tecPlusFunction (double *x, double *par)
 

Private Attributes

bool fitBeamSplitters_
 
edm::Service< TFileServicefs
 
TH1F * h_bsAngle
 
TH2F * h_bsAngleVsBeam
 
TH1F * h_chi2
 
TH1F * h_chi2ndof
 
TH1F * h_hitX
 
TH1F * h_hitXAt
 
TH1F * h_hitXTecMinus
 
TH1F * h_hitXTecPlus
 
TH2F * h_hitXvsZAt
 
TH2F * h_hitXvsZTecMinus
 
TH2F * h_hitXvsZTecPlus
 
TH1F * h_pull
 
TH1F * h_res
 
TH1F * h_resAt
 
TH1F * h_resTecMinus
 
TH1F * h_resTecPlus
 
TH2F * h_resVsHitAt
 
TH2F * h_resVsHitTecMinus
 
TH2F * h_resVsHitTecPlus
 
TH2F * h_resVsZAt
 
TH2F * h_resVsZTecMinus
 
TH2F * h_resVsZTecPlus
 
unsigned int nAtParameters_
 
const edm::InputTag src_
 

Static Private Attributes

static vector< double > gBarrelModuleOffset
 
static vector< double > gBarrelModuleRadius
 
static double gBeamR = 0.0
 
static double gBeamSplitterZprime = 0.0
 
static double gBeamZ0 = 0.0
 
static double gBSparam = 0.0
 
static bool gFitBeamSplitters = false
 
static unsigned int gHitsAtTecMinus = 0
 
static vector< double > gHitZprime
 
static bool gIsInnerBarrel = false
 
static float gTIBparam = 0.097614
 
static float gTOBparam = 0.034949
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Original Authors: Gero Flucke/Kolja Kaschube Created: Wed May 6 08:43:02 CEST 2009

Id
TkLasBeamFitter.cc,v 1.12 2012/01/25 17:30:30 innocent Exp

Description: Fitting LAS beams with track model and providing TrajectoryStateOnSurface for hits.

Implementation:

Definition at line 62 of file TkLasBeamFitter.cc.

Constructor & Destructor Documentation

TkLasBeamFitter::TkLasBeamFitter ( const edm::ParameterSet config)
explicit

Definition at line 205 of file TkLasBeamFitter.cc.

206  : src_(iConfig.getParameter<edm::InputTag>("src")),
207  fitBeamSplitters_(iConfig.getParameter<bool>("fitBeamSplitters")),
208  nAtParameters_(iConfig.getParameter<unsigned int>("numberOfFittedAtParameters")),
209  h_bsAngle(nullptr),
210  h_hitX(nullptr),
211  h_hitXTecPlus(nullptr),
212  h_hitXTecMinus(nullptr),
213  h_hitXAt(nullptr),
214  h_chi2(nullptr),
215  h_chi2ndof(nullptr),
216  h_pull(nullptr),
217  h_res(nullptr),
218  h_resTecPlus(nullptr),
219  h_resTecMinus(nullptr),
220  h_resAt(nullptr),
221  h_bsAngleVsBeam(nullptr),
222  h_hitXvsZTecPlus(nullptr),
223  h_hitXvsZTecMinus(nullptr),
224  h_hitXvsZAt(nullptr),
225  h_resVsZTecPlus(nullptr),
226  h_resVsZTecMinus(nullptr),
227  h_resVsZAt(nullptr),
228  h_resVsHitTecPlus(nullptr),
229  h_resVsHitTecMinus(nullptr),
230  h_resVsHitAt(nullptr) {
231  // declare the products to produce
232  this->produces<TkFittedLasBeamCollection, edm::Transition::EndRun>();
233  this->produces<TsosVectorCollection, edm::Transition::EndRun>();
234 
235  //now do what ever other initialization is needed
236 }
unsigned int nAtParameters_
const edm::InputTag src_
TkLasBeamFitter::~TkLasBeamFitter ( )
override

Definition at line 239 of file TkLasBeamFitter.cc.

239  {
240  // do anything here that needs to be done at desctruction time
241  // (e.g. close files, deallocate resources etc.)
242 }

Member Function Documentation

double TkLasBeamFitter::atFunction ( double *  x,
double *  par 
)
staticprivate

Definition at line 686 of file TkLasBeamFitter.cc.

References gBeamR, gBeamSplitterZprime, gBeamZ0, gBSparam, gFitBeamSplitters, gIsInnerBarrel, gTIBparam, gTOBparam, and z.

Referenced by fitter().

686  {
687  double z = x[0]; // 'primed'? -> yes!!!
688  // TECminus
689  if (z < -gBeamSplitterZprime - 2.0 * gBeamZ0) {
690  return par[0] + par[1] * z;
691  }
692  // BarrelMinus
693  else if (-gBeamSplitterZprime - 2.0 * gBeamZ0 < z && z < -gBeamZ0) {
694  // z value includes module offset from main beam axis
695  // TOB
696  if (!gIsInnerBarrel) {
697  return par[0] + par[1] * z + gTOBparam * (par[2] + par[4]);
698  }
699  // TIB
700  else {
701  return par[0] + par[1] * z - gTIBparam * (par[2] - par[4]);
702  }
703  }
704  // BarrelPlus
705  else if (-gBeamZ0 < z && z < gBeamSplitterZprime) {
706  // z value includes module offset from main beam axis
707  // TOB
708  if (!gIsInnerBarrel) {
709  return par[0] + par[1] * z + gTOBparam * (par[3] - par[4]);
710  }
711  // TIB
712  else {
713  return par[0] + par[1] * z - gTIBparam * (par[3] + par[4]);
714  }
715  }
716  // TECplus
717  else {
718  if (gFitBeamSplitters) {
719  // par[2] = 2*tan(BeamSplitterAngle/2.0)
720  return par[0] + par[1] * z - par[5] * (z - gBeamSplitterZprime) / gBeamR; // BS par: 5, 4, or 2
721  } else {
722  return par[0] + par[1] * z - gBSparam * (z - gBeamSplitterZprime) / gBeamR;
723  }
724  }
725 }
static float gTOBparam
static double gBeamR
static bool gFitBeamSplitters
static bool gIsInnerBarrel
static double gBeamSplitterZprime
static double gBSparam
static float gTIBparam
static double gBeamZ0
void TkLasBeamFitter::buildTrajectory ( TkFittedLasBeam beam,
unsigned int &  hit,
vector< const GeomDetUnit * > &  gd,
std::vector< GlobalPoint > &  globPtrack,
vector< TrajectoryStateOnSurface > &  tsosLas,
GlobalPoint globPref 
)
private

Definition at line 908 of file TkLasBeamFitter.cc.

References SurfaceSideDefinition::beforeSurface, gBeamSplitterZprime, gBeamZ0, gHitZprime, TkLasBeam::isTecInternal(), HLT_2018_cff::magneticField, and edm::ESHandle< T >::product().

Referenced by getLasBeams().

913  {
915  GlobalVector trajectoryState;
916 
917  // TECplus
918  if (beam.isTecInternal(1)) {
919  trajectoryState = GlobalVector(globPref - globPtrack[hit]);
920  }
921  // TECminus
922  else if (beam.isTecInternal(-1)) {
923  trajectoryState = GlobalVector(globPtrack[hit] - globPref);
924  }
925  // ATs
926  else {
927  // TECminus
928  if (gHitZprime[hit] < -gBeamSplitterZprime - 2.0 * gBeamZ0) {
929  trajectoryState = GlobalVector(globPtrack[hit] - globPref);
930  }
931  // TECplus
932  else if (gHitZprime[hit] > gBeamSplitterZprime) {
933  trajectoryState = GlobalVector(globPref - globPtrack[hit]);
934  }
935  // Barrel
936  else {
937  trajectoryState = GlobalVector(globPtrack[hit] - globPref);
938  }
939  }
940  // cout << "trajectory: " << trajectoryState << endl;
941  const FreeTrajectoryState ftsLas = FreeTrajectoryState(globPtrack[hit], trajectoryState, 0, magneticField);
942  tsosLas.push_back(TrajectoryStateOnSurface(ftsLas, gd[hit]->surface(), SurfaceSideDefinition::beforeSurface));
943 }
ESHandle< MagneticField > fieldHandle
static vector< double > gHitZprime
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
static double gBeamSplitterZprime
T const * product() const
Definition: ESHandle.h:86
Global3DVector GlobalVector
Definition: GlobalVector.h:10
static double gBeamZ0
void TkLasBeamFitter::endRunProduce ( edm::Run run,
const edm::EventSetup setup 
)
override

Definition at line 256 of file TkLasBeamFitter.cc.

References EcalCondDBWriter_cfi::beam, gather_cfg::cout, fitBeamSplitters_, fs, gBSparam, edm::EventSetup::get(), edm::Run::getByLabel(), getLasBeams(), gFitBeamSplitters, h_bsAngle, h_bsAngleVsBeam, h_chi2, h_chi2ndof, h_hitX, h_hitXAt, h_hitXTecMinus, h_hitXTecPlus, h_hitXvsZAt, h_hitXvsZTecMinus, h_hitXvsZTecPlus, h_pull, h_res, h_resAt, h_resTecMinus, h_resTecPlus, h_resVsHitAt, h_resVsHitTecMinus, h_resVsHitTecPlus, h_resVsZAt, h_resVsZTecMinus, h_resVsZTecPlus, TFileService::make(), eostools::move(), and edm::Run::put().

256  {
257  // }
258  // // FIXME!
259  // // Indeed, that should be in endRun(..) - as soon as AlignmentProducer can call
260  // // the algorithm's endRun correctly!
261  //
262  //
263  // void TkLasBeamFitter::beginRun(edm::Run &run, const edm::EventSetup &setup)
264  // {
265 
266  // book histograms
267  h_hitX = fs->make<TH1F>("hitX", "local x of LAS hits;local x [cm];N", 100, -0.5, 0.5);
268  h_hitXTecPlus = fs->make<TH1F>("hitXTecPlus", "local x of LAS hits in TECplus;local x [cm];N", 100, -0.5, 0.5);
269  h_hitXTecMinus = fs->make<TH1F>("hitXTecMinus", "local x of LAS hits in TECminus;local x [cm];N", 100, -0.5, 0.5);
270  h_hitXAt = fs->make<TH1F>("hitXAt", "local x of LAS hits in ATs;local x [cm];N", 100, -2.5, 2.5);
272  fs->make<TH2F>("hitXvsZTecPlus", "local x vs z in TECplus;z [cm];local x [cm]", 80, 120, 280, 100, -0.5, 0.5);
274  fs->make<TH2F>("hitXvsZTecMinus", "local x vs z in TECMinus;z [cm];local x [cm]", 80, -280, -120, 100, -0.5, 0.5);
275  h_hitXvsZAt = fs->make<TH2F>("hitXvsZAt", "local x vs z in ATs;z [cm];local x [cm]", 200, -200, 200, 100, -0.5, 0.5);
276  h_chi2 = fs->make<TH1F>("chi2", "#chi^{2};#chi^{2};N", 100, 0, 2000);
277  h_chi2ndof = fs->make<TH1F>("chi2ndof", "#chi^{2} per degree of freedom;#chi^{2}/N_{dof};N", 100, 0, 300);
278  h_pull = fs->make<TH1F>("pull", "pulls of #phi residuals;pull;N", 50, -10, 10);
279  h_res = fs->make<TH1F>("res", "#phi residuals;#phi_{track} - #phi_{hit} [rad];N", 60, -0.0015, 0.0015);
280  h_resTecPlus =
281  fs->make<TH1F>("resTecPlus", "#phi residuals in TECplus;#phi_{track} - #phi_{hit} [rad];N", 30, -0.0015, 0.0015);
282  h_resTecMinus = fs->make<TH1F>(
283  "resTecMinus", "#phi residuals in TECminus;#phi_{track} - #phi_{hit} [rad];N", 60, -0.0015, 0.0015);
284  h_resAt = fs->make<TH1F>("resAt", "#phi residuals in ATs;#phi_{track} - #phi_{hit} [rad];N", 30, -0.0015, 0.0015);
285  h_resVsZTecPlus = fs->make<TH2F>("resVsZTecPlus",
286  "phi residuals vs. z in TECplus;z [cm];#phi_{track} - #phi_{hit} [rad]",
287  80,
288  120,
289  280,
290  100,
291  -0.0015,
292  0.0015);
293  h_resVsZTecMinus = fs->make<TH2F>("resVsZTecMinus",
294  "phi residuals vs. z in TECminus;z [cm];#phi_{track} - #phi_{hit} [rad]",
295  80,
296  -280,
297  -120,
298  100,
299  -0.0015,
300  0.0015);
301  h_resVsZAt = fs->make<TH2F>(
302  "resVsZAt", "#phi residuals vs. z in ATs;N;#phi_{track} - #phi_{hit} [rad]", 200, -200, 200, 100, -0.0015, 0.0015);
303  h_resVsHitTecPlus = fs->make<TH2F>("resVsHitTecPlus",
304  "#phi residuals vs. hits in TECplus;hit no.;#phi_{track} - #phi_{hit} [rad]",
305  144,
306  0,
307  144,
308  100,
309  -0.0015,
310  0.0015);
311  h_resVsHitTecMinus = fs->make<TH2F>("resVsHitTecMinus",
312  "#phi residuals vs. hits in TECminus;hit no.;#phi_{track} - #phi_{hit} [rad]",
313  144,
314  0,
315  144,
316  100,
317  -0.0015,
318  0.0015);
319  h_resVsHitAt = fs->make<TH2F>("resVsHitAt",
320  "#phi residuals vs. hits in ATs;hit no.;#phi_{track} - #phi_{hit} [rad]",
321  176,
322  0,
323  176,
324  100,
325  -0.0015,
326  0.0015);
327  h_bsAngle = fs->make<TH1F>("bsAngle", "fitted beam splitter angle;BS angle [rad];N", 40, -0.004, 0.004);
328  h_bsAngleVsBeam = fs->make<TH2F>(
329  "bsAngleVsBeam", "fitted beam splitter angle per beam;Beam no.;BS angle [rad]", 40, 0, 300, 100, -0.004, 0.004);
330 
331  // Create output collections - they are parallel.
332  // (edm::Ref etc. and thus edm::AssociationVector are not supported for edm::Run...)
333  auto fittedBeams = std::make_unique<TkFittedLasBeamCollection>();
334  // One std::vector<TSOS> for each TkFittedLasBeam:
335  auto tsosesVec = std::make_unique<TsosVectorCollection>();
336 
337  // get TkLasBeams, Tracker geometry, magnetic field
338  run.getByLabel("LaserAlignment", "tkLaserBeams", laserBeams);
339  setup.get<TrackerDigiGeometryRecord>().get(geometry);
341 
342  // hack for fixed BSparams (ugly!)
343  // double bsParams[34] = {-0.000266,-0.000956,-0.001205,-0.000018,-0.000759,0.002554,
344  // 0.000465,0.000975,0.001006,0.002027,-0.001263,-0.000763,
345  // -0.001702,0.000906,-0.002120,0.001594,0.000661,-0.000457,
346  // -0.000447,0.000347,-0.002266,-0.000446,0.000659,0.000018,
347  // -0.001630,-0.000324,
348  // // ATs
349  // -999.,-0.001709,-0.002091,-999.,
350  // -0.001640,-999.,-0.002444,-0.002345};
351 
352  double bsParams[40] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
353  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
354 
355  // beam counter
356  unsigned int beamNo(0);
357  // fit BS? If false, values from bsParams are taken
359  if (fitBeamSplitters_)
360  cout << "Fitting BS!" << endl;
361  else
362  cout << "BS fixed, not fitted!" << endl;
363 
364  // loop over LAS beams
365  for (TkLasBeamCollection::const_iterator iBeam = laserBeams->begin(), iEnd = laserBeams->end(); iBeam != iEnd;
366  ++iBeam) {
367  TkFittedLasBeam beam(*iBeam);
368  vector<TrajectoryStateOnSurface> tsosLas;
369 
370  // set BS param for fit
371  gBSparam = bsParams[beamNo];
372 
373  // call main function; all other functions are called inside getLasBeams(..)
374  this->getLasBeams(beam, tsosLas);
375 
376  // fill output products
377  fittedBeams->push_back(beam);
378  tsosesVec->push_back(tsosLas);
379 
380  // if(!this->fitBeam(fittedBeams->back(), tsosesVec->back())){
381  // edm::LogError("BadFit")
382  // << "Problems fitting TkLasBeam, id " << fittedBeams->back().getBeamId() << ".";
383  // fittedBeams->pop_back(); // remove last entry added just before
384  // tsosesVec->pop_back(); // dito
385  // }
386 
387  beamNo++;
388  }
389 
390  // finally, put fitted beams and TSOS vectors into run
391  run.put(std::move(fittedBeams));
392  run.put(std::move(tsosesVec));
393 }
ESHandle< MagneticField > fieldHandle
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:280
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
static bool gFitBeamSplitters
Handle< TkLasBeamCollection > laserBeams
static double gBSparam
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:108
T get() const
Definition: EventSetup.h:73
void getLasBeams(TkFittedLasBeam &beam, vector< TrajectoryStateOnSurface > &tsosLas)
edm::Service< TFileService > fs
def move(src, dest)
Definition: eostools.py:511
bool TkLasBeamFitter::fitBeam ( TkFittedLasBeam beam,
AlgebraicSymMatrix covMatrix,
unsigned int &  hitsAtTecPlus,
unsigned int &  nFitParams,
double &  offset,
double &  slope,
vector< GlobalPoint > &  globPtrack,
double &  bsAngleParam,
double &  chi2 
)
private

Definition at line 946 of file TkLasBeamFitter.cc.

References DEFINE_FWK_MODULE, fitBeamSplitters_, gBarrelModuleOffset, gBeamSplitterZprime, gBeamZ0, gHitsAtTecMinus, gHitZprime, TkLasBeam::isAlignmentTube(), TkLasBeam::isTecInternal(), hltrates_dqm_sourceclient-live_cfg::offset, CalibrationSummaryClient_cfi::params, TkFittedLasBeam::setParameters(), and slope.

Referenced by getLasBeams().

954  {
955  // set beam parameters for beam output
956  unsigned int paramType(0);
957  if (!fitBeamSplitters_)
958  paramType = 1;
959  if (beam.isAlignmentTube() && hitsAtTecPlus == 0)
960  paramType = 0;
961  // const unsigned int nPedeParams = nFitParams + paramType;
962 
963  // test without BS params
964  const unsigned int nPedeParams(nFitParams);
965  // cout << "number of Pede parameters: " << nPedeParams << endl;
966 
967  std::vector<TkFittedLasBeam::Scalar> params(nPedeParams);
968  params[0] = offset;
969  params[1] = slope;
970  // no BS parameter for AT beams without TECplus hits
971  // if(beam.isTecInternal() || hitsAtTecPlus > 0) params[2] = bsAngleParam;
972 
973  AlgebraicMatrix derivatives(gHitZprime.size(), nPedeParams);
974  // fill derivatives matrix with local track derivatives
975  for (unsigned int hit = 0; hit < gHitZprime.size(); ++hit) {
976  // d(delta phi)/d(offset) is identical for every hit
977  derivatives[hit][0] = 1.0;
978 
979  // d(delta phi)/d(slope) and d(delta phi)/d(bsAngleParam) depend on parametrizations
980  // TECplus
981  if (beam.isTecInternal(1)) {
982  derivatives[hit][1] = globPtrack[hit].z();
983  // if(gHitZprime[hit] < gBeamSplitterZprime){
984  // derivatives[hit][2] = 0.0;
985  // }
986  // else{
987  // derivatives[hit][2] = - (globPtrack[hit].z() - gBeamSplitterZprime) / gBeamR;
988  // }
989  }
990  // TECminus
991  else if (beam.isTecInternal(-1)) {
992  derivatives[hit][1] = globPtrack[hit].z();
993  // if(gHitZprime[hit] > gBeamSplitterZprime){
994  // derivatives[hit][2] = 0.0;
995  // }
996  // else{
997  // derivatives[hit][2] = (globPtrack[hit].z() - gBeamSplitterZprime) / gBeamR;
998  // }
999  }
1000  // ATs
1001  else {
1002  // TECminus
1003  if (gHitZprime[hit] < -gBeamSplitterZprime - 2.0 * gBeamZ0) {
1004  derivatives[hit][1] = globPtrack[hit].z();
1005  // if(hitsAtTecPlus > 0){
1006  // derivatives[hit][2] = 0.0;
1007  // }
1008  }
1009  // TECplus
1010  else if (gHitZprime[hit] > gBeamSplitterZprime) {
1011  derivatives[hit][1] = globPtrack[hit].z();
1012  // if(hitsAtTecPlus > 0){
1013  // derivatives[hit][2] = - (globPtrack[hit].z() - gBeamSplitterZprime) / gBeamR;
1014  // }
1015  }
1016  // Barrel
1017  else {
1018  derivatives[hit][1] = globPtrack[hit].z() - gBarrelModuleOffset[hit - gHitsAtTecMinus];
1019  // if(hitsAtTecPlus > 0){
1020  // derivatives[hit][2] = 0.0;
1021  // }
1022  }
1023  }
1024  }
1025 
1026  unsigned int firstFixedParam(covMatrix.num_col()); // FIXME! --> no, is fine!!!
1027  // unsigned int firstFixedParam = nPedeParams - 1;
1028  // if(beam.isAlignmentTube() && hitsAtTecPlus == 0) firstFixedParam = nPedeParams;
1029  // cout << "first fixed parameter: " << firstFixedParam << endl;
1030  // set fit results
1031  beam.setParameters(paramType, params, covMatrix, derivatives, firstFixedParam, chi2);
1032 
1033  return true; // return false in case of problems
1034 }
static vector< double > gHitZprime
static const double slope[3]
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
CLHEP::HepMatrix AlgebraicMatrix
static double gBeamSplitterZprime
static unsigned int gHitsAtTecMinus
static vector< double > gBarrelModuleOffset
bool isAlignmentTube(void) const
true if this is an AT beam (from 10^2 digit of beamId)
Definition: TkLasBeam.h:44
void setParameters(unsigned int parametrisation, const std::vector< Scalar > &params, const AlgebraicSymMatrix &paramCovariance, const AlgebraicMatrix &derivatives, unsigned int firstFixedParam, float chi2)
static double gBeamZ0
void TkLasBeamFitter::fitter ( TkFittedLasBeam beam,
AlgebraicSymMatrix covMatrix,
unsigned int &  hitsAtTecPlus,
unsigned int &  nFitParams,
std::vector< double > &  hitPhi,
std::vector< double > &  hitPhiError,
std::vector< double > &  hitZprimeError,
double &  zMin,
double &  zMax,
double &  bsAngleParam,
double &  offset,
double &  offsetError,
double &  slope,
double &  slopeError,
double &  phiAtMinusParam,
double &  phiAtPlusParam,
double &  atThetaSplitParam 
)
private

Definition at line 728 of file TkLasBeamFitter.cc.

References atFunction(), cuy::col, fitBeamSplitters_, gBSparam, gHitZprime, fitWZ::gMinuit, TkLasBeam::isAlignmentTube(), TkLasBeam::isTecInternal(), tecMinusFunction(), and tecPlusFunction().

Referenced by getLasBeams().

744  {
745  TGraphErrors *lasData =
746  new TGraphErrors(gHitZprime.size(), &(gHitZprime[0]), &(hitPhi[0]), &(hitZprimeError[0]), &(hitPhiError[0]));
747 
748  // do fit (R = entire range)
749  if (beam.isTecInternal(1)) {
750  TF1 tecPlus("tecPlus", tecPlusFunction, zMin, zMax, nFitParams);
751  tecPlus.SetParameter(1, 0); // slope
752  tecPlus.SetParameter(nFitParams - 1, 0); // BS
753  lasData->Fit(&tecPlus, "R"); // "R", "RV" or "RQ"
754  } else if (beam.isTecInternal(-1)) {
755  TF1 tecMinus("tecMinus", tecMinusFunction, zMin, zMax, nFitParams);
756  tecMinus.SetParameter(1, 0); // slope
757  tecMinus.SetParameter(nFitParams - 1, 0); // BS
758  lasData->Fit(&tecMinus, "R");
759  } else {
760  TF1 at("at", atFunction, zMin, zMax, nFitParams);
761  at.SetParameter(1, 0); // slope
762  at.SetParameter(nFitParams - 1, 0); // BS
763  lasData->Fit(&at, "R");
764  }
765 
766  // get values and errors for offset and slope
767  gMinuit->GetParameter(0, offset, offsetError);
768  gMinuit->GetParameter(1, slope, slopeError);
769 
770  // additional AT parameters
771  // define param errors that are not used later
772  double bsAngleParamError(0.), phiAtMinusParamError(0.), phiAtPlusParamError(0.), atThetaSplitParamError(0.);
773 
774  if (beam.isAlignmentTube()) {
775  gMinuit->GetParameter(2, phiAtMinusParam, phiAtMinusParamError);
776  gMinuit->GetParameter(3, phiAtPlusParam, phiAtPlusParamError);
777  gMinuit->GetParameter(4, atThetaSplitParam, atThetaSplitParamError);
778  }
779  // get Beam Splitter parameters
780  if (fitBeamSplitters_) {
781  if (beam.isAlignmentTube() && hitsAtTecPlus == 0) {
782  bsAngleParam = gBSparam;
783  } else {
784  gMinuit->GetParameter(nFitParams - 1, bsAngleParam, bsAngleParamError);
785  }
786  } else {
787  bsAngleParam = gBSparam;
788  }
789 
790  // fill covariance matrix
791  vector<double> vec(covMatrix.num_col() * covMatrix.num_col());
792  gMinuit->mnemat(&vec[0], covMatrix.num_col());
793  for (int col = 0; col < covMatrix.num_col(); col++) {
794  for (int row = 0; row < covMatrix.num_col(); row++) {
795  covMatrix[col][row] = vec[row + covMatrix.num_col() * col];
796  }
797  }
798  // compute correlation between parameters
799  // double corr01 = covMatrix[1][0]/(offsetError*slopeError);
800 
801  delete lasData;
802 }
static vector< double > gHitZprime
static double tecMinusFunction(double *x, double *par)
static double tecPlusFunction(double *x, double *par)
static const double slope[3]
gMinuit
Definition: fitWZ.py:36
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
static double gBSparam
col
Definition: cuy.py:1010
static double atFunction(double *x, double *par)
bool isAlignmentTube(void) const
true if this is an AT beam (from 10^2 digit of beamId)
Definition: TkLasBeam.h:44
void TkLasBeamFitter::getLasBeams ( TkFittedLasBeam beam,
vector< TrajectoryStateOnSurface > &  tsosLas 
)
private

Fit 'beam' using info from its base class TkLasBeam and set its parameters. Also fill 'tsoses' with TSOS for each LAS hit.

Definition at line 398 of file TkLasBeamFitter.cc.

References funct::abs(), TkLasBeam::begin(), buildTrajectory(), hltPixelTracks_cff::chi2, gather_cfg::cout, TkLasBeam::end(), fitBeam(), fitBeamSplitters_, fitter(), gBarrelModuleOffset, gBarrelModuleRadius, gBeamR, gBeamSplitterZprime, gBeamZ0, TkLasBeam::getBeamId(), getLasHits(), gHitsAtTecMinus, gHitZprime, gIsInnerBarrel, globalTrackPoint(), h_bsAngle, h_bsAngleVsBeam, h_chi2, h_chi2ndof, h_hitX, h_hitXAt, h_hitXTecMinus, h_hitXTecPlus, h_hitXvsZAt, h_hitXvsZTecMinus, h_hitXvsZTecPlus, h_pull, h_res, h_resAt, h_resTecMinus, h_resTecPlus, h_resVsHitAt, h_resVsHitTecMinus, h_resVsHitTecPlus, h_resVsZAt, h_resVsZTecMinus, h_resVsZTecPlus, TkLasBeam::isAlignmentTube(), TkLasBeam::isRing6(), TkLasBeam::isTecInternal(), SiStripLaserRecHit2D::localPosition(), nAtParameters_, hltrates_dqm_sourceclient-live_cfg::offset, perp(), phi, slope, trackPhi(), z, photonAnalyzer_cfi::zMax, and photonAnalyzer_cfi::zMin.

Referenced by endRunProduce().

398  {
399  cout << "---------------------------------------" << endl;
400  cout << "beam id: " << beam.getBeamId() // << " isTec: " << (beam.isTecInternal() ? "Y" : "N")
401  << " isTec+: " << (beam.isTecInternal(1) ? "Y" : "N") << " isTec-: " << (beam.isTecInternal(-1) ? "Y" : "N")
402  << " isAt: " << (beam.isAlignmentTube() ? "Y" : "N") << " isR6: " << (beam.isRing6() ? "Y" : "N") << endl;
403 
404  // reset static variables
405  gHitsAtTecMinus = 0;
406  gHitZprime.clear();
407  gBarrelModuleRadius.clear();
408  gBarrelModuleOffset.clear();
409 
410  // set right beam radius
411  gBeamR = beam.isRing6() ? 84.0 : 56.4;
412 
413  vector<const GeomDetUnit *> gd;
414  vector<GlobalPoint> globHit;
415  unsigned int hitsAtTecPlus(0);
416  double sumZ(0.);
417 
418  // loop over hits
419  for (TkLasBeam::const_iterator iHit = beam.begin(); iHit < beam.end(); ++iHit) {
420  // iHit is a SiStripLaserRecHit2D
421 
422  const SiStripLaserRecHit2D hit(*iHit);
423 
424  this->getLasHits(beam, hit, gd, globHit, hitsAtTecPlus);
425  sumZ += globHit.back().z();
426 
427  // fill histos
428  h_hitX->Fill(hit.localPosition().x());
429  // TECplus
430  if (beam.isTecInternal(1)) {
431  h_hitXTecPlus->Fill(hit.localPosition().x());
432  h_hitXvsZTecPlus->Fill(globHit.back().z(), hit.localPosition().x());
433  }
434  // TECminus
435  else if (beam.isTecInternal(-1)) {
436  h_hitXTecMinus->Fill(hit.localPosition().x());
437  h_hitXvsZTecMinus->Fill(globHit.back().z(), hit.localPosition().x());
438  }
439  // ATs
440  else {
441  h_hitXAt->Fill(hit.localPosition().x());
442  h_hitXvsZAt->Fill(globHit.back().z(), hit.localPosition().x());
443  }
444  }
445 
446  gBeamZ0 = sumZ / globHit.size();
447  double zMin(0.), zMax(0.);
448  // TECplus
449  if (beam.isTecInternal(1)) {
450  gBeamSplitterZprime = 205.75 - gBeamZ0;
451  zMin = 120.0 - gBeamZ0;
452  zMax = 280.0 - gBeamZ0;
453  }
454  // TECminus
455  else if (beam.isTecInternal(-1)) {
456  gBeamSplitterZprime = -205.75 - gBeamZ0;
457  zMin = -280.0 - gBeamZ0;
458  zMax = -120.0 - gBeamZ0;
459  }
460  // AT
461  else {
462  gBeamSplitterZprime = 112.3 - gBeamZ0;
463  zMin = -200.0 - gBeamZ0;
464  zMax = 200.0 - gBeamZ0;
465  }
466 
467  // fill vectors for fitted quantities
468  vector<double> hitPhi, hitPhiError, hitZprimeError;
469 
470  for (unsigned int hit = 0; hit < globHit.size(); ++hit) {
471  hitPhi.push_back(static_cast<double>(globHit[hit].phi()));
472  // localPositionError[hit] or assume 0.003, 0.006
473  hitPhiError.push_back(0.003 / globHit[hit].perp());
474  // no errors on z, fill with zeros
475  hitZprimeError.push_back(0.0);
476  // barrel-specific values
477  if (beam.isAlignmentTube() && abs(globHit[hit].z()) < 112.3) {
478  gBarrelModuleRadius.push_back(globHit[hit].perp());
479  gBarrelModuleOffset.push_back(gBarrelModuleRadius.back() - gBeamR);
480  // TIB/TOB flag
481  if (gBarrelModuleOffset.back() < 0.0) {
482  gIsInnerBarrel = true;
483  } else {
484  gIsInnerBarrel = false;
485  }
486  gHitZprime.push_back(globHit[hit].z() - gBeamZ0 - abs(gBarrelModuleOffset.back()));
487  }
488  // non-barrel z'
489  else {
490  gHitZprime.push_back(globHit[hit].z() - gBeamZ0);
491  }
492  }
493 
494  // number of fit parameters, 3 for TECs (always!); 3, 5, or 6 for ATs
495  unsigned int tecParams(3), atParams(0);
496  if (nAtParameters_ == 3)
497  atParams = 3;
498  else if (nAtParameters_ == 5)
499  atParams = 5;
500  else
501  atParams = 6; // <-- default value, recommended
502  unsigned int nFitParams(0);
503  if (!fitBeamSplitters_ || (hitsAtTecPlus == 0 && beam.isAlignmentTube())) {
504  tecParams = tecParams - 1;
505  atParams = atParams - 1;
506  }
507  if (beam.isTecInternal()) {
508  nFitParams = tecParams;
509  } else {
510  nFitParams = atParams;
511  }
512 
513  // fit parameter definitions
514  double offset(0.), offsetError(0.), slope(0.), slopeError(0.), bsAngleParam(0.), phiAtMinusParam(0.),
515  phiAtPlusParam(0.), atThetaSplitParam(0.);
516  AlgebraicSymMatrix covMatrix;
517  if (!fitBeamSplitters_ || (beam.isAlignmentTube() && hitsAtTecPlus == 0)) {
518  covMatrix = AlgebraicSymMatrix(nFitParams, 1);
519  } else {
520  covMatrix = AlgebraicSymMatrix(nFitParams - 1, 1);
521  }
522 
523  this->fitter(beam,
524  covMatrix,
525  hitsAtTecPlus,
526  nFitParams,
527  hitPhi,
528  hitPhiError,
529  hitZprimeError,
530  zMin,
531  zMax,
532  bsAngleParam,
533  offset,
534  offsetError,
535  slope,
536  slopeError,
537  phiAtMinusParam,
538  phiAtPlusParam,
539  atThetaSplitParam);
540 
541  vector<GlobalPoint> globPtrack;
542  GlobalPoint globPref;
543  double chi2(0.);
544 
545  for (unsigned int hit = 0; hit < gHitZprime.size(); ++hit) {
546  // additional phi value (trackPhiRef) for trajectory calculation
547  double trackPhi(0.), trackPhiRef(0.);
548 
549  this->trackPhi(beam,
550  hit,
551  trackPhi,
552  trackPhiRef,
553  offset,
554  slope,
555  bsAngleParam,
556  phiAtMinusParam,
557  phiAtPlusParam,
558  atThetaSplitParam,
559  globHit);
560 
561  cout << "track phi = " << trackPhi << ", hit phi = " << hitPhi[hit] << ", zPrime = " << gHitZprime[hit]
562  << " r = " << globHit[hit].perp() << endl;
563 
564  this->globalTrackPoint(beam, hit, hitsAtTecPlus, trackPhi, trackPhiRef, globHit, globPtrack, globPref, hitPhiError);
565 
566  // calculate residuals = pred - hit (in global phi)
567  const double phiResidual = globPtrack[hit].phi() - globHit[hit].phi();
568  // pull calculation (FIX!!!)
569  const double phiResidualPull = phiResidual / hitPhiError[hit];
570  // sqrt(hitPhiError[hit]*hitPhiError[hit] +
571  // (offsetError*offsetError + globPtrack[hit].z()*globPtrack[hit].z() * slopeError*slopeError));
572 
573  // calculate chi2
574  chi2 += phiResidual * phiResidual / (hitPhiError[hit] * hitPhiError[hit]);
575 
576  // fill histos
577  h_res->Fill(phiResidual);
578  // TECplus
579  if (beam.isTecInternal(1)) {
580  h_pull->Fill(phiResidualPull);
581  h_resTecPlus->Fill(phiResidual);
582  h_resVsZTecPlus->Fill(globPtrack[hit].z(), phiResidual);
583  // Ring 6
584  if (beam.isRing6()) {
585  h_resVsHitTecPlus->Fill(hit + (beam.getBeamId() - 1) / 10 * 9 + 72, phiResidual);
586  }
587  // Ring 4
588  else {
589  h_resVsHitTecPlus->Fill(hit + beam.getBeamId() / 10 * 9, phiResidual);
590  }
591  }
592  // TECminus
593  else if (beam.isTecInternal(-1)) {
594  h_pull->Fill(phiResidualPull);
595  h_resTecMinus->Fill(phiResidual);
596  h_resVsZTecMinus->Fill(globPtrack[hit].z(), phiResidual);
597  // Ring 6
598  if (beam.isRing6()) {
599  h_resVsHitTecMinus->Fill(hit + (beam.getBeamId() - 101) / 10 * 9 + 72, phiResidual);
600  }
601  // Ring 4
602  else {
603  h_resVsHitTecMinus->Fill(hit + (beam.getBeamId() - 100) / 10 * 9, phiResidual);
604  }
605  }
606  // ATs
607  else {
608  h_pull->Fill(phiResidualPull);
609  h_resAt->Fill(phiResidual);
610  h_resVsZAt->Fill(globPtrack[hit].z(), phiResidual);
611  h_resVsHitAt->Fill(hit + (beam.getBeamId() - 200) / 10 * 22, phiResidual);
612  }
613 
614  this->buildTrajectory(beam, hit, gd, globPtrack, tsosLas, globPref);
615  }
616 
617  cout << "chi^2 = " << chi2 << ", chi^2/ndof = " << chi2 / (gHitZprime.size() - nFitParams) << endl;
618  this->fitBeam(beam, covMatrix, hitsAtTecPlus, nFitParams, offset, slope, globPtrack, bsAngleParam, chi2);
619 
620  cout << "bsAngleParam = " << bsAngleParam << endl;
621 
622  // fill histos
623  // include slope, offset, covariance plots here
624  h_chi2->Fill(chi2);
625  h_chi2ndof->Fill(chi2 / (gHitZprime.size() - nFitParams));
626  if (bsAngleParam != 0.0) {
627  h_bsAngle->Fill(2.0 * atan(0.5 * bsAngleParam));
628  h_bsAngleVsBeam->Fill(beam.getBeamId(), 2.0 * atan(0.5 * bsAngleParam));
629  }
630 }
static vector< double > gHitZprime
static double gBeamR
static const double slope[3]
bool isRing6(void) const
true if this beam hits TEC R6 (last digit of beamId)
Definition: TkLasBeam.h:47
static vector< double > gBarrelModuleRadius
bool fitBeam(TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, double &offset, double &slope, vector< GlobalPoint > &globPtrack, double &bsAngleParam, double &chi2)
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
static bool gIsInnerBarrel
unsigned int nAtParameters_
unsigned int getBeamId(void) const
return the full beam identifier
Definition: TkLasBeam.h:23
void globalTrackPoint(TkFittedLasBeam &beam, unsigned int &hit, unsigned int &hitsAtTecPlus, double &trackPhi, double &trackPhiRef, std::vector< GlobalPoint > &globHit, std::vector< GlobalPoint > &globPtrack, GlobalPoint &globPref, std::vector< double > &hitPhiError)
static double gBeamSplitterZprime
std::vector< SiStripLaserRecHit2D >::const_iterator end(void) const
access iterator to the collection of hits
Definition: TkLasBeam.h:32
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< SiStripLaserRecHit2D >::const_iterator begin(void) const
access iterator to the collection of hits
Definition: TkLasBeam.h:29
static unsigned int gHitsAtTecMinus
void fitter(TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, std::vector< double > &hitPhi, std::vector< double > &hitPhiError, std::vector< double > &hitZprimeError, double &zMin, double &zMax, double &bsAngleParam, double &offset, double &offsetError, double &slope, double &slopeError, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam)
void buildTrajectory(TkFittedLasBeam &beam, unsigned int &hit, vector< const GeomDetUnit * > &gd, std::vector< GlobalPoint > &globPtrack, vector< TrajectoryStateOnSurface > &tsosLas, GlobalPoint &globPref)
static vector< double > gBarrelModuleOffset
T perp() const
Magnitude of transverse component.
void trackPhi(TkFittedLasBeam &beam, unsigned int &hit, double &trackPhi, double &trackPhiRef, double &offset, double &slope, double &bsAngleParam, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam, std::vector< GlobalPoint > &globHit)
CLHEP::HepSymMatrix AlgebraicSymMatrix
void getLasHits(TkFittedLasBeam &beam, const SiStripLaserRecHit2D &hit, vector< const GeomDetUnit * > &gd, vector< GlobalPoint > &globHit, unsigned int &hitsAtTecPlus)
std::vector< SiStripLaserRecHit2D >::const_iterator const_iterator
Definition: TkLasBeam.h:14
bool isAlignmentTube(void) const
true if this is an AT beam (from 10^2 digit of beamId)
Definition: TkLasBeam.h:44
static double gBeamZ0
void TkLasBeamFitter::getLasHits ( TkFittedLasBeam beam,
const SiStripLaserRecHit2D hit,
vector< const GeomDetUnit * > &  gd,
vector< GlobalPoint > &  globHit,
unsigned int &  hitsAtTecPlus 
)
private

Definition at line 633 of file TkLasBeamFitter.cc.

References funct::abs(), SiStripLaserRecHit2D::getDetId(), gHitsAtTecMinus, TrackerGeometry::idToDetUnit(), TkLasBeam::isAlignmentTube(), SiStripLaserRecHit2D::localPosition(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by getLasBeams().

637  {
638  // get global position of LAS hits
639  gd.push_back(geometry->idToDetUnit(hit.getDetId()));
640  GlobalPoint globPtemp(gd.back()->toGlobal(hit.localPosition()));
641 
642  // testing: globPtemp should be right
643  globHit.push_back(globPtemp);
644 
645  if (beam.isAlignmentTube()) {
646  if (abs(globPtemp.z()) > 112.3) {
647  if (globPtemp.z() < 112.3)
648  gHitsAtTecMinus++;
649  else
650  hitsAtTecPlus++;
651  }
652  }
653 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int gHitsAtTecMinus
const SiStripDetId & getDetId(void) const
LocalPoint localPosition() const override
bool isAlignmentTube(void) const
true if this is an AT beam (from 10^2 digit of beamId)
Definition: TkLasBeam.h:44
void TkLasBeamFitter::globalTrackPoint ( TkFittedLasBeam beam,
unsigned int &  hit,
unsigned int &  hitsAtTecPlus,
double &  trackPhi,
double &  trackPhiRef,
std::vector< GlobalPoint > &  globHit,
std::vector< GlobalPoint > &  globPtrack,
GlobalPoint globPref,
std::vector< double > &  hitPhiError 
)
private

Definition at line 873 of file TkLasBeamFitter.cc.

References gBeamR, gHitsAtTecMinus, gHitZprime, TkLasBeam::isTecInternal(), perp(), and z.

Referenced by getLasBeams().

881  {
882  // TECs
883  if (beam.isTecInternal(0)) {
884  globPtrack.push_back(GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhi, globHit[hit].z())));
885  globPref = GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhiRef, globHit[hit].z() + 1.0));
886  }
887  // ATs
888  else {
889  // TECminus
890  if (hit < gHitsAtTecMinus) { // gHitZprime[hit] < -gBeamSplitterZprime - 2.0*gBeamZ0
891  globPtrack.push_back(GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhi, globHit[hit].z())));
892  globPref = GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhiRef, globHit[hit].z() + 1.0));
893  }
894  // TECplus
895  else if (hit > gHitZprime.size() - hitsAtTecPlus - 1) { // gHitZprime[hit] > gBeamSplitterZprime
896  globPtrack.push_back(GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhi, globHit[hit].z())));
897  globPref = GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhiRef, globHit[hit].z() + 1.0));
898  }
899  // Barrel
900  else {
901  globPtrack.push_back(GlobalPoint(GlobalPoint::Cylindrical(globHit[hit].perp(), trackPhi, globHit[hit].z())));
902  globPref = GlobalPoint(GlobalPoint::Cylindrical(gBeamR, trackPhiRef, globHit[hit].z()));
903  }
904  }
905 }
static vector< double > gHitZprime
static double gBeamR
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
static unsigned int gHitsAtTecMinus
T perp() const
Magnitude of transverse component.
void trackPhi(TkFittedLasBeam &beam, unsigned int &hit, double &trackPhi, double &trackPhiRef, double &offset, double &slope, double &bsAngleParam, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam, std::vector< GlobalPoint > &globHit)
void TkLasBeamFitter::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 250 of file TkLasBeamFitter.cc.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

250  {
251  // Nothing per event!
252 }
double TkLasBeamFitter::tecMinusFunction ( double *  x,
double *  par 
)
staticprivate

Definition at line 671 of file TkLasBeamFitter.cc.

References gBeamR, gBeamSplitterZprime, gBSparam, gFitBeamSplitters, and z.

Referenced by fitter().

671  {
672  double z = x[0]; // 'primed'? -> yes!!!
673 
674  if (z > gBeamSplitterZprime) {
675  return par[0] + par[1] * z;
676  } else {
677  if (gFitBeamSplitters) {
678  // par[2] = 2*tan(BeamSplitterAngle/2.0)
679  return par[0] + par[1] * z + par[2] * (z - gBeamSplitterZprime) / gBeamR;
680  } else {
681  return par[0] + par[1] * z + gBSparam * (z - gBeamSplitterZprime) / gBeamR;
682  }
683  }
684 }
static double gBeamR
static bool gFitBeamSplitters
static double gBeamSplitterZprime
static double gBSparam
double TkLasBeamFitter::tecPlusFunction ( double *  x,
double *  par 
)
staticprivate

Definition at line 656 of file TkLasBeamFitter.cc.

References gBeamR, gBeamSplitterZprime, gBSparam, gFitBeamSplitters, and z.

Referenced by fitter().

656  {
657  double z = x[0]; // 'primed'? -> yes!!!
658 
659  if (z < gBeamSplitterZprime) {
660  return par[0] + par[1] * z;
661  } else {
662  if (gFitBeamSplitters) {
663  // par[2] = 2*tan(BeamSplitterAngle/2.0)
664  return par[0] + par[1] * z - par[2] * (z - gBeamSplitterZprime) / gBeamR;
665  } else {
666  return par[0] + par[1] * z - gBSparam * (z - gBeamSplitterZprime) / gBeamR;
667  }
668  }
669 }
static double gBeamR
static bool gFitBeamSplitters
static double gBeamSplitterZprime
static double gBSparam
void TkLasBeamFitter::trackPhi ( TkFittedLasBeam beam,
unsigned int &  hit,
double &  trackPhi,
double &  trackPhiRef,
double &  offset,
double &  slope,
double &  bsAngleParam,
double &  phiAtMinusParam,
double &  phiAtPlusParam,
double &  atThetaSplitParam,
std::vector< GlobalPoint > &  globHit 
)
private

Definition at line 805 of file TkLasBeamFitter.cc.

References funct::abs(), gBarrelModuleOffset, gBeamR, gBeamSplitterZprime, gBeamZ0, gHitsAtTecMinus, gHitZprime, gIsInnerBarrel, gTIBparam, gTOBparam, and TkLasBeam::isTecInternal().

Referenced by getLasBeams().

815  {
816  // TECplus
817  if (beam.isTecInternal(1)) {
820  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
821  } else {
822  trackPhi = offset + slope * gHitZprime[hit] - bsAngleParam * (gHitZprime[hit] - gBeamSplitterZprime) / gBeamR;
823  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0) -
824  bsAngleParam * ((gHitZprime[hit] + 1.0) - gBeamSplitterZprime) / gBeamR;
825  }
826  }
827  // TECminus
828  else if (beam.isTecInternal(-1)) {
831  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
832  } else {
833  trackPhi = offset + slope * gHitZprime[hit] + bsAngleParam * (gHitZprime[hit] - gBeamSplitterZprime) / gBeamR;
834  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0) +
835  bsAngleParam * ((gHitZprime[hit] + 1.0) - gBeamSplitterZprime) / gBeamR;
836  }
837  }
838  // ATs
839  else {
840  // TECminus
841  if (gHitZprime[hit] < -gBeamSplitterZprime - 2.0 * gBeamZ0) {
843  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
844  }
845  // BarrelMinus
846  else if (-gBeamSplitterZprime - 2.0 * gBeamZ0 < gHitZprime[hit] && gHitZprime[hit] < -gBeamZ0) {
847  if (!gIsInnerBarrel) {
848  trackPhi = offset + slope * gHitZprime[hit] + gTOBparam * (phiAtMinusParam + atThetaSplitParam);
849  } else {
850  trackPhi = offset + slope * gHitZprime[hit] - gTIBparam * (phiAtMinusParam - atThetaSplitParam);
851  }
853  }
854  // BarrelPlus
856  if (!gIsInnerBarrel) {
857  trackPhi = offset + slope * gHitZprime[hit] + gTOBparam * (phiAtPlusParam - atThetaSplitParam);
858  } else {
859  trackPhi = offset + slope * gHitZprime[hit] - gTIBparam * (phiAtPlusParam + atThetaSplitParam);
860  }
862  }
863  // TECplus
864  else {
865  trackPhi = offset + slope * gHitZprime[hit] - bsAngleParam * (gHitZprime[hit] - gBeamSplitterZprime) / gBeamR;
866  trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0) -
867  bsAngleParam * ((gHitZprime[hit] + 1.0) - gBeamSplitterZprime) / gBeamR;
868  }
869  }
870 }
static vector< double > gHitZprime
static float gTOBparam
static double gBeamR
static const double slope[3]
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
Definition: TkLasBeam.cc:4
static bool gIsInnerBarrel
static double gBeamSplitterZprime
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int gHitsAtTecMinus
static vector< double > gBarrelModuleOffset
void trackPhi(TkFittedLasBeam &beam, unsigned int &hit, double &trackPhi, double &trackPhiRef, double &offset, double &slope, double &bsAngleParam, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam, std::vector< GlobalPoint > &globHit)
static float gTIBparam
static double gBeamZ0

Member Data Documentation

bool TkLasBeamFitter::fitBeamSplitters_
private

Definition at line 149 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), fitBeam(), fitter(), and getLasBeams().

edm::Service<TFileService> TkLasBeamFitter::fs
private

Definition at line 152 of file TkLasBeamFitter.cc.

Referenced by endRunProduce().

vector< double > TkLasBeamFitter::gBarrelModuleOffset
staticprivate

Definition at line 157 of file TkLasBeamFitter.cc.

Referenced by fitBeam(), getLasBeams(), and trackPhi().

vector< double > TkLasBeamFitter::gBarrelModuleRadius
staticprivate

Definition at line 156 of file TkLasBeamFitter.cc.

Referenced by getLasBeams().

double TkLasBeamFitter::gBeamR = 0.0
staticprivate
double TkLasBeamFitter::gBeamSplitterZprime = 0.0
staticprivate
double TkLasBeamFitter::gBeamZ0 = 0.0
staticprivate

Definition at line 161 of file TkLasBeamFitter.cc.

Referenced by atFunction(), buildTrajectory(), fitBeam(), getLasBeams(), and trackPhi().

double TkLasBeamFitter::gBSparam = 0.0
staticprivate
bool TkLasBeamFitter::gFitBeamSplitters = false
staticprivate

Definition at line 165 of file TkLasBeamFitter.cc.

Referenced by atFunction(), endRunProduce(), tecMinusFunction(), and tecPlusFunction().

unsigned int TkLasBeamFitter::gHitsAtTecMinus = 0
staticprivate

Definition at line 163 of file TkLasBeamFitter.cc.

Referenced by fitBeam(), getLasBeams(), getLasHits(), globalTrackPoint(), and trackPhi().

vector< double > TkLasBeamFitter::gHitZprime
staticprivate
bool TkLasBeamFitter::gIsInnerBarrel = false
staticprivate

Definition at line 166 of file TkLasBeamFitter.cc.

Referenced by atFunction(), getLasBeams(), and trackPhi().

float TkLasBeamFitter::gTIBparam = 0.097614
staticprivate

Definition at line 158 of file TkLasBeamFitter.cc.

Referenced by atFunction(), and trackPhi().

float TkLasBeamFitter::gTOBparam = 0.034949
staticprivate

Definition at line 159 of file TkLasBeamFitter.cc.

Referenced by atFunction(), and trackPhi().

TH1F* TkLasBeamFitter::h_bsAngle
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F* TkLasBeamFitter::h_bsAngleVsBeam
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_chi2
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_chi2ndof
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_hitX
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_hitXAt
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_hitXTecMinus
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_hitXTecPlus
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_hitXvsZAt
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_hitXvsZTecMinus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_hitXvsZTecPlus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_pull
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_res
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_resAt
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_resTecMinus
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH1F * TkLasBeamFitter::h_resTecPlus
private

Definition at line 169 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsHitAt
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsHitTecMinus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsHitTecPlus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsZAt
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsZTecMinus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

TH2F * TkLasBeamFitter::h_resVsZTecPlus
private

Definition at line 171 of file TkLasBeamFitter.cc.

Referenced by endRunProduce(), and getLasBeams().

unsigned int TkLasBeamFitter::nAtParameters_
private

Definition at line 150 of file TkLasBeamFitter.cc.

Referenced by getLasBeams().

const edm::InputTag TkLasBeamFitter::src_
private

Definition at line 148 of file TkLasBeamFitter.cc.