CMS 3D CMS Logo

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

Public Member Functions

void beginOfJob (AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
 Call at beginning of job: More...
 
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
 
 SiPixelLorentzAngleCalibration (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 Constructor. More...
 
 ~SiPixelLorentzAngleCalibration () 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

SiPixelLorentzAngle createFromTree (const char *fileName, const char *treeName) const
 
const SiPixelLorentzAnglegetLorentzAnglesInput (const align::RunNumber &=0)
 
double getParameterForDetId (unsigned int detId, edm::RunNumber_t run) const
 
void writeTree (const SiPixelLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
 

Private Attributes

std::map< align::RunNumber, SiPixelLorentzAnglecachedLorentzAngleInputs_
 
align::RunNumber currentIOV_ {0}
 
const std::string lorentzAngleLabel_
 
const edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcdlorentzAngleToken_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagFieldToken_
 
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_
 
const std::string recordNameDBwrite_
 
const bool saveToDB_
 
SiPixelLorentzAnglesiPixelLorentzAngleInput_ {nullptr}
 
edm::ESWatcher< SiPixelLorentzAngleRcdwatchLorentzAngleRcd_
 

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 pixel, integrated in the alignment algorithms.

Note that not all algorithms support this...

Author
: Gero Flucke date : September 2012
Revision
1.4.2.21
Date
2013/05/31 08:37:12

(last update by

Author
flucke

)

Definition at line 54 of file SiPixelLorentzAngleCalibration.cc.

Constructor & Destructor Documentation

◆ SiPixelLorentzAngleCalibration()

SiPixelLorentzAngleCalibration::SiPixelLorentzAngleCalibration ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)
explicit

Constructor.

Definition at line 138 of file SiPixelLorentzAngleCalibration.cc.

140  saveToDB_(cfg.getParameter<bool>("saveToDB")),
141  recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
142  outFileName_(cfg.getParameter<std::string>("treeFile")),
143  mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
144  lorentzAngleLabel_(cfg.getParameter<std::string>("lorentzAngleLabel")),
147  moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")) {}
IntegratedCalibrationBase(const edm::ParameterSet &cfg)
Values and their parameter index.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
const edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcd > lorentzAngleToken_
const std::vector< std::string > mergeFileNames_

◆ ~SiPixelLorentzAngleCalibration()

SiPixelLorentzAngleCalibration::~SiPixelLorentzAngleCalibration ( )
overridedefault

Destructor.

Member Function Documentation

◆ beginOfJob()

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

Call at beginning of job:

Reimplemented from IntegratedCalibrationBase.

Definition at line 262 of file SiPixelLorentzAngleCalibration.cc.

References mergeFileNames_, moduleGroupSelCfg_, moduleGroupSelector_, IntegratedCalibrationBase::name(), numParameters(), outFileName_, parameters_, paramUncertainties_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, and saveToDB_.

264  {
265  //specify the sub-detectors for which the LA is determined
266  const std::vector<int> sdets = {PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap};
267 
268  moduleGroupSelector_ = std::make_unique<TkModuleGroupSelector>(aliTracker, moduleGroupSelCfg_, sdets);
269 
270  parameters_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
271  paramUncertainties_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
272 
273  edm::LogInfo("Alignment") << "@SUB=SiPixelLorentzAngleCalibration"
274  << "Created with name " << this->name() << "',\n"
275  << this->numParameters() << " parameters to be determined,"
276  << "\n saveToDB = " << saveToDB_ << "\n outFileName = " << outFileName_
277  << "\n N(merge files) = " << mergeFileNames_.size()
278  << "\n number of IOVs = " << moduleGroupSelector_->numIovs();
279 
280  if (!mergeFileNames_.empty()) {
281  edm::LogInfo("Alignment") << "@SUB=SiPixelLorentzAngleCalibration"
282  << "First file to merge: " << mergeFileNames_[0];
283  }
284 }
unsigned int numParameters() const override
How many parameters does this calibration define?
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
Log< level::Info, false > LogInfo
const std::vector< std::string > mergeFileNames_
const std::string & name() const
name of this calibration

◆ beginRun()

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

Call at beginning of run:

Reimplemented from IntegratedCalibrationBase.

Definition at line 153 of file SiPixelLorentzAngleCalibration.cc.

References cond::TimeTypeSpecs::beginValue, cachedLorentzAngleInputs_, edm::ESWatcher< T >::check(), currentIOV_, Exception, dataset::firstRun, SiPixelLorentzAngle::getLorentzAngles(), mps_fire::i, lorentzAngleToken_, moduleGroupSelector_, writedatasetfile::run, cond::runnumber, convertSQLiteXML::runNumber, singleTopDQM_cfi::setup, siPixelLorentzAngleInput_, cond::timeTypeSpecs, and watchLorentzAngleRcd_.

153  {
154  // no action needed if the LA record didn't change
155  if (!(watchLorentzAngleRcd_.check(setup)))
156  return;
157 
158  const auto runNumber = run.run();
160 
161  // avoid infinite loop due to wrap-around of unsigned variable 'i' including
162  // arrow from i to zero and a nice smiley ;)
163  for (unsigned int i = moduleGroupSelector_->numIovs(); i-- > 0;) {
164  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(i);
165  if (runNumber >= firstRunOfIOV) {
166  firstRun = firstRunOfIOV;
167  break;
168  }
169  }
170 
171  const SiPixelLorentzAngle *lorentzAngleHandle = &setup.getData(lorentzAngleToken_);
172  const auto &lorentzAngleRcd = setup.get<SiPixelLorentzAngleRcd>();
173 
175  cachedLorentzAngleInputs_.emplace(firstRun, SiPixelLorentzAngle(*lorentzAngleHandle));
176  } else {
177  if (lorentzAngleRcd.validityInterval().first().eventID().run() > firstRun &&
178  lorentzAngleHandle->getLorentzAngles() // only bad if non-identical values
179  != cachedLorentzAngleInputs_[firstRun].getLorentzAngles()) { // (comparing maps)
180  // Maps are containers sorted by key, but comparison problems may arise from
181  // 'floating point comparison' problems (FIXME?)
182  throw cms::Exception("BadInput") << "Trying to cache SiPixelLorentzAngle payload for a run (" << runNumber
183  << ") in an IOV (" << firstRun << ") that was already cached.\n"
184  << "The following record in your input database tag has an IOV "
185  << "boundary that does not match your IOV definition:\n"
186  << " - SiPixelLorentzAngleRcd '" << lorentzAngleRcd.key().name() << "' (since "
187  << lorentzAngleRcd.validityInterval().first().eventID().run() << ")\n";
188  }
189  }
190 
193 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
Time_t beginValue
Definition: Time.h:41
const std::map< unsigned int, float > & getLorentzAngles() const
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
edm::ESWatcher< SiPixelLorentzAngleRcd > watchLorentzAngleRcd_
std::map< align::RunNumber, SiPixelLorentzAngle > cachedLorentzAngleInputs_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcd > lorentzAngleToken_
firstRun
Definition: dataset.py:940

◆ createFromTree()

SiPixelLorentzAngle SiPixelLorentzAngleCalibration::createFromTree ( const char *  fileName,
const char *  treeName 
) const
private

Definition at line 443 of file SiPixelLorentzAngleCalibration.cc.

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

Referenced by getLorentzAnglesInput().

443  {
444  // Check for file existence on your own to work around
445  // https://hypernews.cern.ch/HyperNews/CMS/get/swDevelopment/2715.html:
446  TFile *file = nullptr;
447  FILE *testFile = fopen(fileName, "r");
448  if (testFile) {
449  fclose(testFile);
450  file = TFile::Open(fileName, "READ");
451  } // else not existing, see error below
452 
453  TTree *tree = nullptr;
454  if (file)
455  file->GetObject(treeName, tree);
456 
458  if (tree) {
459  unsigned int id = 0;
460  float value = 0.;
461  tree->SetBranchAddress("detId", &id);
462  tree->SetBranchAddress("value", &value);
463 
464  const Long64_t nEntries = tree->GetEntries();
465  for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
466  tree->GetEntry(iEntry);
467  result.putLorentzAngle(id, value);
468  }
469  } else { // Warning only since could be parallel job on no events.
470  edm::LogWarning("Alignment") << "@SUB=SiPixelLorentzAngleCalibration::createFromTree"
471  << "Could not get TTree '" << treeName << "' from file '" << fileName
472  << (file ? "'." : "' (file does not exist).");
473  }
474 
475  delete file; // tree will vanish with file
476  return result;
477 }
Definition: value.py:1
Definition: tree.py:1
Log< level::Warning, false > LogWarning

◆ derivatives()

unsigned int SiPixelLorentzAngleCalibration::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 196 of file SiPixelLorentzAngleCalibration.cc.

References Calorimetry_cff::bField, l1ctLayer1_cff::dZ, dumpTauVariables_cfi::eventInfo, magFieldToken_, HLT_2022v15_cff::magneticField, moduleGroupSelector_, singleTopDQM_cfi::setup, and hit::y.

200  {
201  outDerivInds.clear();
202 
203  if (hit.det()) { // otherwise 'constraint hit' or whatever
204 
205  const int index =
206  moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
207  if (index >= 0) { // otherwise not treated
208 
209  const MagneticField *magneticField = &setup.getData(magFieldToken_);
210  const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
211  const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
212  const double dZ = hit.det()->surface().bounds().thickness(); // it is a float only...
213  // shift due to LA: dx = tan(LA) * dz/2 = mobility * B_y * dz/2,
214  // shift due to LA: dy = - mobility * B_x * dz/2,
215  // '-' since we have derivative of the residual r = trk -hit
216  const double xDerivative = bFieldLocal.y() * dZ * -0.5; // parameter is mobility!
217  const double yDerivative = bFieldLocal.x() * dZ * 0.5; // parameter is mobility!
218  if (xDerivative || yDerivative) { // If field is zero, this is zero: do not return it
219  const Values derivs{xDerivative, yDerivative};
220  outDerivInds.push_back(ValuesIndexPair(derivs, index));
221  }
222  }
223  } else {
224  edm::LogWarning("Alignment") << "@SUB=SiPixelLorentzAngleCalibration::derivatives2"
225  << "Hit without GeomDet, skip!";
226  }
227 
228  return outDerivInds.size();
229 }
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
std::pair< double, double > Values
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning

◆ endOfJob()

void SiPixelLorentzAngleCalibration::endOfJob ( )
overridevirtual

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

Implements IntegratedCalibrationBase.

Definition at line 287 of file SiPixelLorentzAngleCalibration.cc.

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

287  {
288  // loginfo output
289  std::ostringstream out;
290  out << "Parameter results\n";
291  for (unsigned int iPar = 0; iPar < parameters_.size(); ++iPar) {
292  out << iPar << ": " << parameters_[iPar] << " +- " << paramUncertainties_[iPar] << "\n";
293  }
294  edm::LogInfo("Alignment") << "@SUB=SiPixelLorentzAngleCalibration::endOfJob" << out.str();
295 
296  std::map<unsigned int, TreeStruct> treeInfo; // map of TreeStruct for each detId
297 
298  // now write 'input' tree(s)
299  const std::string treeName{this->name() + '_'};
300  std::vector<const SiPixelLorentzAngle *> inputs{};
301  inputs.reserve(moduleGroupSelector_->numIovs());
302  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
303  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(iIOV);
304  inputs.push_back(this->getLorentzAnglesInput(firstRunOfIOV)); // never NULL
305  this->writeTree(inputs.back(),
306  treeInfo,
307  (treeName + "input_" + std::to_string(firstRunOfIOV)).c_str()); // empty treeInfo for input...
308 
309  if (inputs.back()->getLorentzAngles().empty()) {
310  edm::LogError("Alignment") << "@SUB=SiPixelLorentzAngleCalibration::endOfJob"
311  << "Input Lorentz angle map is empty, skip writing output!";
312  return;
313  }
314  }
315 
316  const unsigned int nonZeroParamsOrErrors = // Any determined value?
317  count_if(parameters_.begin(), parameters_.end(), [](auto c) { return c != 0.; }) +
318  count_if(paramUncertainties_.begin(), paramUncertainties_.end(), [](auto c) { return c != 0.; });
319 
320  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
321  auto firstRunOfIOV = static_cast<cond::Time_t>(moduleGroupSelector_->firstRunOfIOV(iIOV));
323  // Loop on map of values from input and add (possible) parameter results
324  for (const auto &iterIdValue : inputs[iIOV]->getLorentzAngles()) {
325  // type of 'iterIdValue' is pair<unsigned int, float>
326  const auto detId = iterIdValue.first; // key of map is DetId
327  const auto param = this->getParameterForDetId(detId, firstRunOfIOV);
328  // put result in output, i.e. sum of input and determined parameter, but the nasty
329  // putLorentzAngle(..) takes float by reference - not even const reference:
330  auto value = iterIdValue.second + static_cast<float>(param);
331  output.putLorentzAngle(detId, value);
332  const int paramIndex = moduleGroupSelector_->getParameterIndexFromDetId(detId, firstRunOfIOV);
333  treeInfo[detId] = TreeStruct(param, this->getParameterError(paramIndex), paramIndex);
334  }
335 
336  if (saveToDB_ || nonZeroParamsOrErrors != 0) { // Skip writing mille jobs...
337  this->writeTree(&output, treeInfo, (treeName + Form("result_%lld", firstRunOfIOV)).c_str());
338  }
339 
340  if (saveToDB_) { // If requested, write out to DB
342  if (dbService.isAvailable()) {
343  dbService->writeOneIOV(output, firstRunOfIOV, recordNameDBwrite_);
344  } else {
345  edm::LogError("BadConfig") << "@SUB=SiPixelLorentzAngleCalibration::endOfJob"
346  << "No PoolDBOutputService available, but saveToDB true!";
347  }
348  }
349  } // end loop on IOVs
350 }
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Log< level::Error, false > LogError
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
unsigned long long Time_t
Definition: Time.h:14
double getParameterError(unsigned int index) const override
const SiPixelLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Definition: value.py:1
Log< level::Info, false > LogInfo
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
bool isAvailable() const
Definition: Service.h:40
const std::string & name() const
name of this calibration
void writeTree(const SiPixelLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const

◆ getLorentzAnglesInput()

const SiPixelLorentzAngle * SiPixelLorentzAngleCalibration::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 353 of file SiPixelLorentzAngleCalibration.cc.

References cachedLorentzAngleInputs_, createFromTree(), currentIOV_, SiPixelLorentzAngle::getLorentzAngles(), mergeFileNames_, IntegratedCalibrationBase::name(), writedatasetfile::run, siPixelLorentzAngleInput_, AlCaHLTBitMon_QueryRunRegistry::string, and cond::impl::to_string().

Referenced by endOfJob().

353  {
354  const auto &resolvedRun = run > 0 ? run : currentIOV_;
355  // For parallel processing in Millepede II, create SiPixelLorentzAngle
356  // from info stored in files of parallel jobs and check that they are identical.
357  // If this job has run on data, still check that LA is identical to the ones
358  // from mergeFileNames_.
359  const std::string treeName{this->name() + "_input_" + std::to_string(resolvedRun)};
360  for (const auto &iFile : mergeFileNames_) {
361  auto la = this->createFromTree(iFile.c_str(), treeName.c_str());
362  // siPixelLorentzAngleInput_ could be non-null from previous file of this loop
363  // or from checkLorentzAngleInput(..) when running on data in this job as well
365  cachedLorentzAngleInputs_[resolvedRun] = la;
367  currentIOV_ = resolvedRun;
368  } else {
369  // FIXME: about comparison of maps see comments in checkLorentzAngleInput
370  if (!la.getLorentzAngles().empty() && // single job might not have got events
371  la.getLorentzAngles() != siPixelLorentzAngleInput_->getLorentzAngles()) {
372  // Throw exception instead of error?
373  edm::LogError("NoInput") << "@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput"
374  << "Different input values from tree " << treeName << " in file " << iFile << ".";
375  }
376  }
377  }
378 
379  if (!siPixelLorentzAngleInput_) { // no files nor ran on events
380  // [] operator default-constructs an empty SiPixelLorentzAngle object in place:
382  currentIOV_ = resolvedRun;
383  edm::LogError("NoInput") << "@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput"
384  << "No input, create an empty one!";
385  } else if (siPixelLorentzAngleInput_->getLorentzAngles().empty()) {
386  edm::LogError("NoInput") << "@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput"
387  << "Empty result!";
388  }
389 
391 }
SiPixelLorentzAngle createFromTree(const char *fileName, const char *treeName) const
std::string to_string(const V &value)
Definition: OMSAccess.h:71
const std::map< unsigned int, float > & getLorentzAngles() const
Log< level::Error, false > LogError
std::map< align::RunNumber, SiPixelLorentzAngle > cachedLorentzAngleInputs_
const std::vector< std::string > mergeFileNames_
const std::string & name() const
name of this calibration

◆ getParameter()

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

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

Implements IntegratedCalibrationBase.

Definition at line 252 of file SiPixelLorentzAngleCalibration.cc.

References parameters_.

Referenced by Mixins._Parameterizable::hasParameter().

252  {
253  return (index >= parameters_.size() ? 0. : parameters_[index]);
254 }

◆ getParameterError()

double SiPixelLorentzAngleCalibration::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 257 of file SiPixelLorentzAngleCalibration.cc.

References paramUncertainties_.

Referenced by endOfJob().

◆ getParameterForDetId()

double SiPixelLorentzAngleCalibration::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 394 of file SiPixelLorentzAngleCalibration.cc.

References moduleGroupSelector_, parameters_, and writedatasetfile::run.

Referenced by endOfJob().

394  {
395  const int index = moduleGroupSelector_->getParameterIndexFromDetId(detId, run);
396  return (index < 0 ? 0. : parameters_[index]);
397 }
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_

◆ numParameters()

unsigned int SiPixelLorentzAngleCalibration::numParameters ( ) const
overridevirtual

How many parameters does this calibration define?

Implements IntegratedCalibrationBase.

Definition at line 150 of file SiPixelLorentzAngleCalibration.cc.

References parameters_.

Referenced by beginOfJob().

150 { return parameters_.size(); }

◆ setParameter()

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

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

Implements IntegratedCalibrationBase.

Definition at line 232 of file SiPixelLorentzAngleCalibration.cc.

References parameters_, and relativeConstraints::value.

Referenced by coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), runJetUncertainties.RunJetUncertainties::__call__(), metTools.AddMETCollection::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), tauTools.AddTauCollection::__call__(), trackTools.MakeTrackCandidates::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.AddJetCollection::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.UpdateJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::jetConfiguration().

232  {
233  if (index >= parameters_.size()) {
234  return false;
235  } else {
237  return true;
238  }
239 }

◆ setParameterError()

bool SiPixelLorentzAngleCalibration::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 242 of file SiPixelLorentzAngleCalibration.cc.

References relativeConstraints::error, and paramUncertainties_.

242  {
243  if (index >= paramUncertainties_.size()) {
244  return false;
245  } else {
247  return true;
248  }
249 }

◆ writeTree()

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

Definition at line 400 of file SiPixelLorentzAngleCalibration.cc.

References geometryDiff::file, SiPixelLorentzAngle::getLorentzAngles(), TreeStruct::LeafList(), moduleGroupSelector_, and outFileName_.

Referenced by endOfJob().

402  {
403  if (!lorentzAngle)
404  return;
405 
406  TFile *file = TFile::Open(outFileName_.c_str(), "UPDATE");
407  if (!file) {
408  edm::LogError("BadConfig") << "@SUB=SiPixelLorentzAngleCalibration::writeTree"
409  << "Could not open file '" << outFileName_ << "'.";
410  return;
411  }
412 
413  TTree *tree = new TTree(treeName, treeName);
414  unsigned int id = 0;
415  float value = 0.;
416  TreeStruct treeStruct;
417  tree->Branch("detId", &id, "detId/i");
418  tree->Branch("value", &value, "value/F");
419  tree->Branch("treeStruct", &treeStruct, TreeStruct::LeafList());
420 
421  for (auto iterIdValue = lorentzAngle->getLorentzAngles().begin();
422  iterIdValue != lorentzAngle->getLorentzAngles().end();
423  ++iterIdValue) {
424  // type of (*iterIdValue) is pair<unsigned int, float>
425  id = iterIdValue->first; // key of map is DetId
426  value = iterIdValue->second;
427  // type of (*treeStructIter) is pair<unsigned int, TreeStruct>
428  auto treeStructIter = treeInfo.find(id); // find info for this id
429  if (treeStructIter != treeInfo.end()) {
430  treeStruct = treeStructIter->second; // info from input map
431  } else { // if none found, fill at least parameter index (using 1st IOV...)
432  const cond::Time_t run1of1stIov = moduleGroupSelector_->firstRunOfIOV(0);
433  const int ind = moduleGroupSelector_->getParameterIndexFromDetId(id, run1of1stIov);
434  treeStruct = TreeStruct(ind);
435  }
436  tree->Fill();
437  }
438  tree->Write();
439  delete file; // tree vanishes with the file... (?)
440 }
const std::map< unsigned int, float > & getLorentzAngles() const
Log< level::Error, false > LogError
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
unsigned long long Time_t
Definition: Time.h:14
Definition: value.py:1
static const char * LeafList()
Definition: TreeStruct.h:16
Definition: tree.py:1

Member Data Documentation

◆ cachedLorentzAngleInputs_

std::map<align::RunNumber, SiPixelLorentzAngle> SiPixelLorentzAngleCalibration::cachedLorentzAngleInputs_
private

Definition at line 124 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ currentIOV_

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

Definition at line 126 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ lorentzAngleLabel_

const std::string SiPixelLorentzAngleCalibration::lorentzAngleLabel_
private

Definition at line 118 of file SiPixelLorentzAngleCalibration.cc.

◆ lorentzAngleToken_

const edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> SiPixelLorentzAngleCalibration::lorentzAngleToken_
private

Definition at line 119 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun().

◆ magFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SiPixelLorentzAngleCalibration::magFieldToken_
private

Definition at line 120 of file SiPixelLorentzAngleCalibration.cc.

Referenced by derivatives().

◆ mergeFileNames_

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

Definition at line 117 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and getLorentzAnglesInput().

◆ moduleGroupSelCfg_

const edm::ParameterSet SiPixelLorentzAngleCalibration::moduleGroupSelCfg_
private

Definition at line 131 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob().

◆ moduleGroupSelector_

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

◆ outFileName_

const std::string SiPixelLorentzAngleCalibration::outFileName_
private

Definition at line 116 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and writeTree().

◆ parameters_

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

◆ paramUncertainties_

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

◆ recordNameDBwrite_

const std::string SiPixelLorentzAngleCalibration::recordNameDBwrite_
private

Definition at line 115 of file SiPixelLorentzAngleCalibration.cc.

Referenced by endOfJob().

◆ saveToDB_

const bool SiPixelLorentzAngleCalibration::saveToDB_
private

Definition at line 114 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and endOfJob().

◆ siPixelLorentzAngleInput_

SiPixelLorentzAngle* SiPixelLorentzAngleCalibration::siPixelLorentzAngleInput_ {nullptr}
private

Definition at line 125 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

◆ watchLorentzAngleRcd_

edm::ESWatcher<SiPixelLorentzAngleRcd> SiPixelLorentzAngleCalibration::watchLorentzAngleRcd_
private

Definition at line 121 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun().