CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripLorentzAngleCalibration Class Reference
Inheritance diagram for SiStripLorentzAngleCalibration:
IntegratedCalibrationBase

Public Member Functions

void beginOfJob (AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 Call at beginning of run: More...
 
unsigned int derivatives (std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
 
void endOfJob () override
 
double getParameter (unsigned int index) const override
 
double getParameterError (unsigned int index) const override
 
unsigned int numParameters () const override
 How many parameters does this calibration define? More...
 
bool setParameter (unsigned int index, double value) override
 
bool setParameterError (unsigned int index, double error) override
 
 SiStripLorentzAngleCalibration (const edm::ParameterSet &cfg)
 Constructor. More...
 
 ~SiStripLorentzAngleCalibration () override=default
 Destructor. More...
 
- Public Member Functions inherited from IntegratedCalibrationBase
virtual std::vector< Valuesderivatives (const TrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const
 
virtual unsigned int derivatives (std::vector< ValuesIndexPair > &outDerivInds, const TrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const =0
 
virtual void endOfLoop ()
 
 IntegratedCalibrationBase (const edm::ParameterSet &cfg)
 Values and their parameter index. More...
 
const std::string & name () const
 name of this calibration More...
 
virtual void startNewLoop ()
 
virtual ~IntegratedCalibrationBase ()
 Destructor. More...
 

Private Member Functions

SiStripLorentzAngle createFromTree (const char *fileName, const char *treeName) const
 
double effectiveThickness (const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
 in non-peak mode the effective thickness is reduced... More...
 
const SiStripLorentzAnglegetLorentzAnglesInput (const align::RunNumber &=0)
 
double getParameterForDetId (unsigned int detId, edm::RunNumber_t run) const
 
void writeTree (const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
 

Private Attributes

std::map< align::RunNumber, SiStripLorentzAnglecachedLorentzAngleInputs_
 
align::RunNumber currentIOV_ {0}
 
const std::vector< std::string > mergeFileNames_
 
const edm::ParameterSet moduleGroupSelCfg_
 
std::unique_ptr< TkModuleGroupSelectormoduleGroupSelector_
 
const std::string outFileName_
 
std::vector< double > parameters_
 
std::vector< double > paramUncertainties_
 
int16_t readoutMode_
 
const std::string readoutModeName_
 
const std::string recordNameDBwrite_
 
const bool saveToDB_
 
SiStripLorentzAnglesiStripLorentzAngleInput_ {nullptr}
 
edm::ESWatcher< SiStripLorentzAngleRcdwatchLorentzAngleRcd_
 

Additional Inherited Members

- Public Types inherited from IntegratedCalibrationBase
typedef AlignmentAlgorithmBase::EventInfo EventInfo
 
typedef std::pair< double, double > Values
 
typedef std::pair< Values, unsigned int > ValuesIndexPair
 x- and y-values More...
 

Detailed Description

Calibration of Lorentz angle for the strip tracker, integrated in the alignment algorithms. Note that not all algorithms support this...

Use one instance for peak and/or one instance for deco mode data.

Author
: Gero Flucke date : August 2012
Revision
1.6.2.14
Date
2013/05/31 08:37:12

(last update by

Author
flucke

)

Definition at line 53 of file SiStripLorentzAngleCalibration.cc.

Constructor & Destructor Documentation

◆ SiStripLorentzAngleCalibration()

SiStripLorentzAngleCalibration::SiStripLorentzAngleCalibration ( const edm::ParameterSet cfg)
explicit

Constructor.

Definition at line 139 of file SiStripLorentzAngleCalibration.cc.

141  readoutModeName_(cfg.getParameter<std::string>("readoutMode")),
142  saveToDB_(cfg.getParameter<bool>("saveToDB")),
143  recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
144  outFileName_(cfg.getParameter<std::string>("treeFile")),
145  mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
146  moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")) {
147  // SiStripLatency::singleReadOutMode() returns
148  // 1: all in peak, 0: all in deco, -1: mixed state
149  // (in principle one could treat even mixed state APV by APV...)
150  if (readoutModeName_ == "peak") {
152  } else if (readoutModeName_ == "deconvolution") {
154  } else {
155  throw cms::Exception("BadConfig") << "SiStripLorentzAngleCalibration:\n"
156  << "Unknown mode '" << readoutModeName_
157  << "', should be 'peak' or 'deconvolution' .\n";
158  }
159 }

References Exception, kDeconvolutionMode, kPeakMode, readoutMode_, and readoutModeName_.

◆ ~SiStripLorentzAngleCalibration()

SiStripLorentzAngleCalibration::~SiStripLorentzAngleCalibration ( )
overridedefault

Destructor.

Member Function Documentation

◆ beginOfJob()

void SiStripLorentzAngleCalibration::beginOfJob ( AlignableTracker tracker,
AlignableMuon muon,
AlignableExtras extras 
)
overridevirtual

Call at beginning of job: default implementation is dummy, to be overwritten in derived class if useful.

Reimplemented from IntegratedCalibrationBase.

Definition at line 291 of file SiStripLorentzAngleCalibration.cc.

293  {
294  //specify the sub-detectors for which the LA is determined
295  const std::vector<int> sdets = {SiStripDetId::TIB, SiStripDetId::TOB, SiStripDetId::TID, SiStripDetId::TEC};
296  moduleGroupSelector_ = std::make_unique<TkModuleGroupSelector>(aliTracker, moduleGroupSelCfg_, sdets);
297 
298  parameters_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
299  paramUncertainties_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
300 
301  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration"
302  << "Created with name " << this->name() << " for readout mode '" << readoutModeName_
303  << "',\n"
304  << this->numParameters() << " parameters to be determined."
305  << "\nsaveToDB = " << saveToDB_ << "\n outFileName = " << outFileName_
306  << "\n N(merge files) = " << mergeFileNames_.size()
307  << "\n number of IOVs = " << moduleGroupSelector_->numIovs();
308 
309  if (!mergeFileNames_.empty()) {
310  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration"
311  << "First file to merge: " << mergeFileNames_[0];
312  }
313 }

References mergeFileNames_, moduleGroupSelCfg_, moduleGroupSelector_, IntegratedCalibrationBase::name(), numParameters(), outFileName_, parameters_, paramUncertainties_, readoutModeName_, saveToDB_, SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, and SiStripDetId::TOB.

◆ beginRun()

void SiStripLorentzAngleCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Call at beginning of run:

Reimplemented from IntegratedCalibrationBase.

Definition at line 165 of file SiStripLorentzAngleCalibration.cc.

165  {
166  // no action needed if the LA record didn't change
167  if (!(watchLorentzAngleRcd_.check(setup)))
168  return;
169 
170  const auto runNumber = run.run();
172 
173  // avoid infinite loop due to wrap-around of unsigned variable 'i' including
174  // arrow from i to zero and a nice smiley ;)
175  for (unsigned int i = moduleGroupSelector_->numIovs(); i-- > 0;) {
176  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(i);
177  if (runNumber >= firstRunOfIOV) {
178  firstRun = firstRunOfIOV;
179  break;
180  }
181  }
182 
183  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
184  const auto &lorentzAngleRcd = setup.get<SiStripLorentzAngleRcd>();
185  lorentzAngleRcd.get(readoutModeName_, lorentzAngleHandle);
187  cachedLorentzAngleInputs_.emplace(firstRun, SiStripLorentzAngle(*lorentzAngleHandle));
188  } else {
189  if (lorentzAngleRcd.validityInterval().first().eventID().run() > firstRun &&
190  lorentzAngleHandle->getLorentzAngles() // only bad if non-identical values
191  != cachedLorentzAngleInputs_[firstRun].getLorentzAngles()) { // (comparing maps)
192  // Maps are containers sorted by key, but comparison problems may arise from
193  // 'floating point comparison' problems (FIXME?)
194  throw cms::Exception("BadInput") << "Trying to cache SiStripLorentzAngle payload for a run (" << runNumber
195  << ") in an IOV (" << firstRun << ") that was already cached.\n"
196  << "The following record in your input database tag has an IOV "
197  << "boundary that does not match your IOV definition:\n"
198  << " - SiStripLorentzAngleRcd '" << lorentzAngleRcd.key().name() << "' (since "
199  << lorentzAngleRcd.validityInterval().first().eventID().run() << ")\n";
200  }
201  }
202 
205 }

References cond::TimeTypeSpecs::beginValue, cachedLorentzAngleInputs_, edm::ESWatcher< T >::check(), currentIOV_, Exception, dataset::firstRun, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), SiStripLorentzAngle::getLorentzAngles(), mps_fire::i, moduleGroupSelector_, readoutModeName_, writedatasetfile::run, cond::runnumber, convertSQLiteXML::runNumber, singleTopDQM_cfi::setup, siStripLorentzAngleInput_, cond::timeTypeSpecs, and watchLorentzAngleRcd_.

◆ createFromTree()

SiStripLorentzAngle SiStripLorentzAngleCalibration::createFromTree ( const char *  fileName,
const char *  treeName 
) const
private

Definition at line 500 of file SiStripLorentzAngleCalibration.cc.

500  {
501  // Check for file existence on your own to work around
502  // https://hypernews.cern.ch/HyperNews/CMS/get/swDevelopment/2715.html:
503  TFile *file = nullptr;
504  FILE *testFile = fopen(fileName, "r");
505  if (testFile) {
506  fclose(testFile);
507  file = TFile::Open(fileName, "READ");
508  } // else not existing, see error below
509 
510  TTree *tree = nullptr;
511  if (file)
512  file->GetObject(treeName, tree);
513 
515  if (tree) {
516  unsigned int id = 0;
517  float value = 0.;
518  tree->SetBranchAddress("detId", &id);
519  tree->SetBranchAddress("value", &value);
520 
521  const Long64_t nEntries = tree->GetEntries();
522  for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
523  tree->GetEntry(iEntry);
524  result.putLorentzAngle(id, value);
525  }
526  } else { // Warning only since could be parallel job on no events.
527  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::createFromTree"
528  << "Could not get TTree '" << treeName << "' from file '" << fileName
529  << (file ? "'." : "' (file does not exist).");
530  }
531 
532  delete file; // tree will vanish with file
533  return result;
534 }

References FrontierConditions_GlobalTag_cff::file, MillePedeFileConverter_cfg::fileName, and mps_fire::result.

Referenced by getLorentzAnglesInput().

◆ derivatives()

unsigned int SiStripLorentzAngleCalibration::derivatives ( std::vector< ValuesIndexPair > &  outDerivInds,
const TransientTrackingRecHit hit,
const TrajectoryStateOnSurface tsos,
const edm::EventSetup setup,
const EventInfo eventInfo 
) const
override

Return non-zero derivatives for x- and y-measurements with their indices by reference. Return value is their number.

Definition at line 208 of file SiStripLorentzAngleCalibration.cc.

212  {
213  outDerivInds.clear();
214 
217  const int16_t mode = latency->singleReadOutMode();
218  if (mode == readoutMode_) {
219  if (hit.det()) { // otherwise 'constraint hit' or whatever
220 
221  const int index =
222  moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
223  if (index >= 0) { // otherwise not treated
226  const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
227  const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
228  const double dZ = this->effectiveThickness(hit.det(), mode, setup);
229  // shift due to LA: dx = tan(LA) * dz/2 = mobility * B_y * dz/2,
230  // '-' since we have derivative of the residual r = hit - trk and mu is part of trk model
231  // (see GF's presentation in alignment meeting 25.10.2012,
232  // https://indico.cern.ch/conferenceDisplay.py?confId=174266#2012-10-25)
233  // Hmm! StripCPE::fillParams() defines, together with
234  // StripCPE::driftDirection(...):
235  // drift.x = -mobility * by * thickness (full drift from backside)
236  // So '-' already comes from that, not from mobility being part of
237  // track model...
238  // GM: sign convention is the same as for pixel LA, i.e. adopt it here, too
239  const double xDerivative = bFieldLocal.y() * dZ * -0.5; // parameter is mobility!
240  const double yDerivative = bFieldLocal.x() * dZ * 0.5; // parameter is mobility!
241  if (xDerivative || yDerivative) { // If field is zero, this is zero: do not return it
242  const Values derivs{xDerivative, yDerivative};
243  outDerivInds.push_back(ValuesIndexPair(derivs, index));
244  }
245  }
246  } else {
247  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::derivatives1"
248  << "Hit without GeomDet, skip!";
249  }
250  } else if (mode != kDeconvolutionMode && mode != kPeakMode) {
251  // warn only if unknown/mixed mode
252  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::derivatives2"
253  << "Readout mode is " << mode << ", but looking for " << readoutMode_ << " ("
254  << readoutModeName_ << ").";
255  }
256 
257  return outDerivInds.size();
258 }

References Calorimetry_cff::bField, TrackingRecHit::det(), effectiveThickness(), ZMuMuAnalysisNtupler_cff::eventInfo, get, kDeconvolutionMode, kPeakMode, config_102169_raw_cff::latency, HLT_FULL_cff::magneticField, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, moduleGroupSelector_, readoutMode_, readoutModeName_, and singleTopDQM_cfi::setup.

◆ effectiveThickness()

double SiStripLorentzAngleCalibration::effectiveThickness ( const GeomDet det,
int16_t  mode,
const edm::EventSetup setup 
) const
private

in non-peak mode the effective thickness is reduced...

Definition at line 390 of file SiStripLorentzAngleCalibration.cc.

392  {
393  if (!det)
394  return 0.;
395  double dZ = det->surface().bounds().thickness(); // it is a float only...
396  const SiStripDetId id(det->geographicalId());
398  // FIXME: which one? DepRcd->get(handle) or Rcd->get(readoutModeName_, handle)??
399  // setup.get<SiStripBackPlaneCorrectionDepRcd>().get(backPlaneHandle); // get correct mode
400  setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneHandle);
401  const double bpCor = backPlaneHandle->getBackPlaneCorrection(id); // it's a float...
402  // std::cout << "bpCor " << bpCor << " in subdet " << id.subdetId() << std::endl;
403  dZ *= (1. - bpCor);
404 
405  return dZ;
406 }

References Surface::bounds(), GeomDet::geographicalId(), get, triggerObjects_cff::id, readoutModeName_, singleTopDQM_cfi::setup, GeomDet::surface(), and Bounds::thickness().

Referenced by derivatives().

◆ endOfJob()

void SiStripLorentzAngleCalibration::endOfJob ( )
overridevirtual

Called at end of a the job of the AlignmentProducer. Write out determined parameters.

Implements IntegratedCalibrationBase.

Definition at line 316 of file SiStripLorentzAngleCalibration.cc.

316  {
317  // loginfo output
318  std::ostringstream out;
319  out << "Parameter results for readout mode '" << readoutModeName_ << "'\n";
320  for (unsigned int iPar = 0; iPar < parameters_.size(); ++iPar) {
321  out << iPar << ": " << parameters_[iPar] << " +- " << paramUncertainties_[iPar] << "\n";
322  }
323  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration::endOfJob" << out.str();
324 
325  std::map<unsigned int, TreeStruct> treeInfo; // map of TreeStruct for each detId
326 
327  // now write 'input' tree
328  const std::string treeName{this->name() + '_' + readoutModeName_ + '_'};
329  std::vector<const SiStripLorentzAngle *> inputs{};
330  inputs.reserve(moduleGroupSelector_->numIovs());
331  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
332  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(iIOV);
333  inputs.push_back(this->getLorentzAnglesInput(firstRunOfIOV)); // never NULL
334  this->writeTree(inputs.back(),
335  treeInfo,
336  (treeName + "input_" + std::to_string(firstRunOfIOV)).c_str()); // empty treeInfo for input...
337 
338  if (inputs.back()->getLorentzAngles().empty()) {
339  edm::LogError("Alignment") << "@SUB=SiStripLorentzAngleCalibration::endOfJob"
340  << "Input Lorentz angle map is empty ('" << readoutModeName_
341  << "' mode), skip writing output!";
342  return;
343  }
344  }
345 
346  const unsigned int nonZeroParamsOrErrors = // Any determined value?
347  count_if(parameters_.begin(), parameters_.end(), [](auto c) { return c != 0.; }) +
348  count_if(paramUncertainties_.begin(), paramUncertainties_.end(), [](auto c) { return c != 0.; });
349 
350  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
351  auto firstRunOfIOV = static_cast<cond::Time_t>(moduleGroupSelector_->firstRunOfIOV(iIOV));
353  // Loop on map of values from input and add (possible) parameter results
354  for (const auto &iterIdValue : inputs[iIOV]->getLorentzAngles()) {
355  // type of 'iterIdValue' is pair<unsigned int, float>
356  const auto detId = iterIdValue.first; // key of map is DetId
357  // Some code one could use to miscalibrate wrt input:
358  // double param = 0.;
359  // const DetId id(detId);
360  // if (id.subdetId() == 3) { // TIB
361  // param = (readoutMode_ == kPeakMode ? -0.003 : -0.002);
362  // } else if (id.subdetId() == 5) { // TOB
363  // param = (readoutMode_ == kPeakMode ? 0.005 : 0.004);
364  // }
365  const double param = this->getParameterForDetId(detId, firstRunOfIOV);
366  // put result in output, i.e. sum of input and determined parameter:
367  auto value = iterIdValue.second + static_cast<float>(param);
368  output.putLorentzAngle(detId, value);
369  const int paramIndex = moduleGroupSelector_->getParameterIndexFromDetId(detId, firstRunOfIOV);
370  treeInfo[detId] = TreeStruct(param, this->getParameterError(paramIndex), paramIndex);
371  }
372 
373  if (saveToDB_ || nonZeroParamsOrErrors != 0) { // Skip writing mille jobs...
374  this->writeTree(&output, treeInfo, (treeName + Form("result_%lld", firstRunOfIOV)).c_str());
375  }
376 
377  if (saveToDB_) { // If requested, write out to DB
379  if (dbService.isAvailable()) {
380  dbService->writeOne(&output, firstRunOfIOV, recordNameDBwrite_);
381  } else {
382  edm::LogError("BadConfig") << "@SUB=SiStripLorentzAngleCalibration::endOfJob"
383  << "No PoolDBOutputService available, but saveToDB true!";
384  }
385  }
386  } // end loop on IOVs
387 }

References HltBtagPostValidation_cff::c, getLorentzAnglesInput(), getParameterError(), getParameterForDetId(), PixelMapPlotter::inputs, edm::Service< T >::isAvailable(), moduleGroupSelector_, IntegratedCalibrationBase::name(), MillePedeFileConverter_cfg::out, convertSQLitetoXML_cfg::output, parameters_, paramUncertainties_, readoutModeName_, recordNameDBwrite_, saveToDB_, AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::writeOne(), and writeTree().

◆ getLorentzAnglesInput()

const SiStripLorentzAngle * SiStripLorentzAngleCalibration::getLorentzAnglesInput ( const align::RunNumber run = 0)
private

Input LorentzAngle values:

  • either from EventSetup of first call to derivatives(..)
  • or created from files of passed by configuration (i.e. from parallel processing)

Definition at line 409 of file SiStripLorentzAngleCalibration.cc.

409  {
410  const auto &resolvedRun = run > 0 ? run : currentIOV_;
411  // For parallel processing in Millepede II, create SiStripLorentzAngle
412  // from info stored in files of parallel jobs and check that they are identical.
413  // If this job has run on events, still check that LA is identical to the ones
414  // from mergeFileNames_.
415  const std::string treeName{this->name() + "_" + readoutModeName_ + "_input_" + std::to_string(resolvedRun)};
416  for (const auto &iFile : mergeFileNames_) {
417  auto la = this->createFromTree(iFile.c_str(), treeName.c_str());
418  // siStripLorentzAngleInput_ could be non-null from previous file of this loop
419  // or from checkLorentzAngleInput(..) when running on data in this job as well
421  cachedLorentzAngleInputs_[resolvedRun] = la;
423  currentIOV_ = resolvedRun;
424  } else {
425  // FIXME: about comparison of maps see comments in checkLorentzAngleInput
426  if (!la.getLorentzAngles().empty() && // single job might not have got events
427  la.getLorentzAngles() != siStripLorentzAngleInput_->getLorentzAngles()) {
428  // Throw exception instead of error?
429  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
430  << "Different input values from tree " << treeName << " in file " << iFile << ".";
431  }
432  }
433  }
434 
435  if (!siStripLorentzAngleInput_) { // no files nor ran on events
436  // [] operator default-constructs an empty SiStripLorentzAngle object in place:
438  currentIOV_ = resolvedRun;
439  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
440  << "No input, create an empty one ('" << readoutModeName_ << "' mode)!";
441  } else if (siStripLorentzAngleInput_->getLorentzAngles().empty()) {
442  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
443  << "Empty result ('" << readoutModeName_ << "' mode)!";
444  }
445 
447 }

References cachedLorentzAngleInputs_, createFromTree(), currentIOV_, SiStripLorentzAngle::getLorentzAngles(), mergeFileNames_, IntegratedCalibrationBase::name(), readoutModeName_, writedatasetfile::run, siStripLorentzAngleInput_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endOfJob().

◆ getParameter()

double SiStripLorentzAngleCalibration::getParameter ( unsigned int  index) const
overridevirtual

Return current value of parameter identified by index. Returns 0. if index out-of-bounds.

Implements IntegratedCalibrationBase.

Definition at line 281 of file SiStripLorentzAngleCalibration.cc.

281  {
282  return (index >= parameters_.size() ? 0. : parameters_[index]);
283 }

References parameters_.

Referenced by Mixins._Parameterizable::hasParameter().

◆ getParameterError()

double SiStripLorentzAngleCalibration::getParameterError ( unsigned int  index) const
overridevirtual

Return current value of parameter identified by index. Returns 0. if index out-of-bounds or if errors undetermined.

Implements IntegratedCalibrationBase.

Definition at line 286 of file SiStripLorentzAngleCalibration.cc.

286  {
287  return (index >= paramUncertainties_.size() ? 0. : paramUncertainties_[index]);
288 }

References paramUncertainties_.

Referenced by endOfJob().

◆ getParameterForDetId()

double SiStripLorentzAngleCalibration::getParameterForDetId ( unsigned int  detId,
edm::RunNumber_t  run 
) const
private

Determined parameter value for this detId (detId not treated => 0.) and the given run.

Definition at line 450 of file SiStripLorentzAngleCalibration.cc.

450  {
451  const int index = moduleGroupSelector_->getParameterIndexFromDetId(detId, run);
452 
453  return (index < 0 ? 0. : parameters_[index]);
454 }

References moduleGroupSelector_, parameters_, and writedatasetfile::run.

Referenced by endOfJob().

◆ numParameters()

unsigned int SiStripLorentzAngleCalibration::numParameters ( ) const
overridevirtual

How many parameters does this calibration define?

Implements IntegratedCalibrationBase.

Definition at line 162 of file SiStripLorentzAngleCalibration.cc.

162 { return parameters_.size(); }

References parameters_.

Referenced by beginOfJob().

◆ setParameter()

bool SiStripLorentzAngleCalibration::setParameter ( unsigned int  index,
double  value 
)
overridevirtual

◆ setParameterError()

bool SiStripLorentzAngleCalibration::setParameterError ( unsigned int  index,
double  error 
)
overridevirtual

Setting the determined parameter uncertainty identified by index, returns false if out-of-bounds, true otherwise.

Implements IntegratedCalibrationBase.

Definition at line 271 of file SiStripLorentzAngleCalibration.cc.

271  {
272  if (index >= paramUncertainties_.size()) {
273  return false;
274  } else {
276  return true;
277  }
278 }

References relativeConstraints::error, and paramUncertainties_.

◆ writeTree()

void SiStripLorentzAngleCalibration::writeTree ( const SiStripLorentzAngle lorentzAngle,
const std::map< unsigned int, TreeStruct > &  treeInfo,
const char *  treeName 
) const
private

Definition at line 457 of file SiStripLorentzAngleCalibration.cc.

459  {
460  if (!lorentzAngle)
461  return;
462 
463  TFile *file = TFile::Open(outFileName_.c_str(), "UPDATE");
464  if (!file) {
465  edm::LogError("BadConfig") << "@SUB=SiStripLorentzAngleCalibration::writeTree"
466  << "Could not open file '" << outFileName_ << "'.";
467  return;
468  }
469 
470  TTree *tree = new TTree(treeName, treeName);
471  unsigned int id = 0;
472  float value = 0.;
473  TreeStruct treeStruct;
474  tree->Branch("detId", &id, "detId/i");
475  tree->Branch("value", &value, "value/F");
476  tree->Branch("treeStruct", &treeStruct, TreeStruct::LeafList());
477 
478  for (auto iterIdValue = lorentzAngle->getLorentzAngles().begin();
479  iterIdValue != lorentzAngle->getLorentzAngles().end();
480  ++iterIdValue) {
481  // type of (*iterIdValue) is pair<unsigned int, float>
482  id = iterIdValue->first; // key of map is DetId
483  value = iterIdValue->second;
484  // type of (*treeStructIter) is pair<unsigned int, TreeStruct>
485  auto treeStructIter = treeInfo.find(id); // find info for this id
486  if (treeStructIter != treeInfo.end()) {
487  treeStruct = treeStructIter->second; // info from input map
488  } else { // if none found, fill at least parameter index (using 1st IOV...)
489  const cond::Time_t run1of1stIov = moduleGroupSelector_->firstRunOfIOV(0);
490  const int ind = moduleGroupSelector_->getParameterIndexFromDetId(id, run1of1stIov);
491  treeStruct = TreeStruct(ind);
492  }
493  tree->Fill();
494  }
495  tree->Write();
496  delete file; // tree vanishes with the file...
497 }

References FrontierConditions_GlobalTag_cff::file, SiStripLorentzAngle::getLorentzAngles(), TreeStruct::LeafList(), moduleGroupSelector_, and outFileName_.

Referenced by endOfJob().

Member Data Documentation

◆ cachedLorentzAngleInputs_

std::map<align::RunNumber, SiStripLorentzAngle> SiStripLorentzAngleCalibration::cachedLorentzAngleInputs_
private

Definition at line 124 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ currentIOV_

align::RunNumber SiStripLorentzAngleCalibration::currentIOV_ {0}
private

Definition at line 126 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ mergeFileNames_

const std::vector<std::string> SiStripLorentzAngleCalibration::mergeFileNames_
private

Definition at line 120 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and getLorentzAnglesInput().

◆ moduleGroupSelCfg_

const edm::ParameterSet SiStripLorentzAngleCalibration::moduleGroupSelCfg_
private

Definition at line 132 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob().

◆ moduleGroupSelector_

std::unique_ptr<TkModuleGroupSelector> SiStripLorentzAngleCalibration::moduleGroupSelector_
private

◆ outFileName_

const std::string SiStripLorentzAngleCalibration::outFileName_
private

Definition at line 119 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and writeTree().

◆ parameters_

std::vector<double> SiStripLorentzAngleCalibration::parameters_
private

◆ paramUncertainties_

std::vector<double> SiStripLorentzAngleCalibration::paramUncertainties_
private

◆ readoutMode_

int16_t SiStripLorentzAngleCalibration::readoutMode_
private

◆ readoutModeName_

const std::string SiStripLorentzAngleCalibration::readoutModeName_
private

◆ recordNameDBwrite_

const std::string SiStripLorentzAngleCalibration::recordNameDBwrite_
private

Definition at line 118 of file SiStripLorentzAngleCalibration.cc.

Referenced by endOfJob().

◆ saveToDB_

const bool SiStripLorentzAngleCalibration::saveToDB_
private

Definition at line 117 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and endOfJob().

◆ siStripLorentzAngleInput_

SiStripLorentzAngle* SiStripLorentzAngleCalibration::siStripLorentzAngleInput_ {nullptr}
private

Definition at line 125 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ watchLorentzAngleRcd_

edm::ESWatcher<SiStripLorentzAngleRcd> SiStripLorentzAngleCalibration::watchLorentzAngleRcd_
private

Definition at line 122 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun().

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
SiStripLorentzAngleCalibration::cachedLorentzAngleInputs_
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
Definition: SiStripLorentzAngleCalibration.cc:124
dataset.firstRun
firstRun
Definition: dataset.py:940
SiStripLorentzAngleCalibration::recordNameDBwrite_
const std::string recordNameDBwrite_
Definition: SiStripLorentzAngleCalibration.cc:118
mps_fire.i
i
Definition: mps_fire.py:428
cond::TimeTypeSpecs::beginValue
Time_t beginValue
Definition: Time.h:41
IntegratedCalibrationBase::name
const std::string & name() const
name of this calibration
Definition: IntegratedCalibrationBase.h:126
config_102169_raw_cff.latency
latency
Definition: config_102169_raw_cff.py:29
kDeconvolutionMode
Definition: SiStripReadoutModeEnums.h:6
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
SiStripLorentzAngleCalibration::mergeFileNames_
const std::vector< std::string > mergeFileNames_
Definition: SiStripLorentzAngleCalibration.cc:120
SiStripLorentzAngleCalibration::numParameters
unsigned int numParameters() const override
How many parameters does this calibration define?
Definition: SiStripLorentzAngleCalibration.cc:162
tree
Definition: tree.py:1
SiStripLorentzAngleCalibration::currentIOV_
align::RunNumber currentIOV_
Definition: SiStripLorentzAngleCalibration.cc:126
IntegratedCalibrationBase::ValuesIndexPair
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
Definition: IntegratedCalibrationBase.h:44
TrackingRecHit::det
const GeomDet * det() const
Definition: TrackingRecHit.h:122
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
TreeStruct
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
relativeConstraints.error
error
Definition: relativeConstraints.py:53
SiStripBackPlaneCorrectionRcd
Definition: SiStripCondDataRecords.h:30
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
SiStripLorentzAngleCalibration::createFromTree
SiStripLorentzAngle createFromTree(const char *fileName, const char *treeName) const
Definition: SiStripLorentzAngleCalibration.cc:500
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
SiStripLorentzAngleCalibration::readoutModeName_
const std::string readoutModeName_
Definition: SiStripLorentzAngleCalibration.cc:115
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
SiStripLorentzAngle
Definition: SiStripLorentzAngle.h:26
cond::timeTypeSpecs
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
IntegratedCalibrationBase::Values
std::pair< double, double > Values
Definition: IntegratedCalibrationBase.h:43
SiStripLorentzAngleCalibration::watchLorentzAngleRcd_
edm::ESWatcher< SiStripLorentzAngleRcd > watchLorentzAngleRcd_
Definition: SiStripLorentzAngleCalibration.cc:122
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
SiStripLorentzAngleCalibration::paramUncertainties_
std::vector< double > paramUncertainties_
Definition: SiStripLorentzAngleCalibration.cc:129
edm::ESHandle< SiStripLorentzAngle >
SiStripLorentzAngleCalibration::moduleGroupSelector_
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
Definition: SiStripLorentzAngleCalibration.cc:131
SiStripLorentzAngleCalibration::effectiveThickness
double effectiveThickness(const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
in non-peak mode the effective thickness is reduced...
Definition: SiStripLorentzAngleCalibration.cc:390
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:103
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripLorentzAngleCalibration::getParameterError
double getParameterError(unsigned int index) const override
Definition: SiStripLorentzAngleCalibration.cc:286
ZMuMuAnalysisNtupler_cff.eventInfo
eventInfo
Definition: ZMuMuAnalysisNtupler_cff.py:15
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Bounds::thickness
virtual float thickness() const =0
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripLorentzAngleCalibration::outFileName_
const std::string outFileName_
Definition: SiStripLorentzAngleCalibration.cc:119
SiStripLorentzAngleCalibration::parameters_
std::vector< double > parameters_
Definition: SiStripLorentzAngleCalibration.cc:128
cond::runnumber
Definition: Time.h:19
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
edm::Service< cond::service::PoolDBOutputService >
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
SiStripLorentzAngleRcd
Definition: SiStripCondDataRecords.h:25
value
Definition: value.py:1
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
TreeStruct::LeafList
static const char * LeafList()
Definition: TreeStruct.h:16
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
SiStripLorentzAngleCalibration::saveToDB_
const bool saveToDB_
Definition: SiStripLorentzAngleCalibration.cc:117
looper.cfg
cfg
Definition: looper.py:297
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
SiStripLorentzAngle::getLorentzAngles
const std::map< unsigned int, float > & getLorentzAngles() const
Definition: SiStripLorentzAngle.h:32
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripLorentzAngleCalibration::siStripLorentzAngleInput_
SiStripLorentzAngle * siStripLorentzAngleInput_
Definition: SiStripLorentzAngleCalibration.cc:125
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:292
IntegratedCalibrationBase::IntegratedCalibrationBase
IntegratedCalibrationBase(const edm::ParameterSet &cfg)
Values and their parameter index.
Definition: IntegratedCalibrationBase.cc:20
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
relativeConstraints.value
value
Definition: relativeConstraints.py:53
SiStripLorentzAngleCalibration::writeTree
void writeTree(const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
Definition: SiStripLorentzAngleCalibration.cc:457
Exception
Definition: hltDiff.cc:246
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
SiStripLorentzAngleCalibration::getLorentzAnglesInput
const SiStripLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
Definition: SiStripLorentzAngleCalibration.cc:409
SiStripLatencyRcd
Definition: SiStripCondDataRecords.h:36
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SiStripLorentzAngleCalibration::readoutMode_
int16_t readoutMode_
Definition: SiStripLorentzAngleCalibration.cc:116
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
mps_fire.result
result
Definition: mps_fire.py:311
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
kPeakMode
Definition: SiStripReadoutModeEnums.h:6
SiStripLorentzAngleCalibration::getParameterForDetId
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
Definition: SiStripLorentzAngleCalibration.cc:450
SiStripLorentzAngleCalibration::moduleGroupSelCfg_
const edm::ParameterSet moduleGroupSelCfg_
Definition: SiStripLorentzAngleCalibration.cc:132
hit
Definition: SiStripHitEffFromCalibTree.cc:88