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)
 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 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_ { 0 }
 
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 ( const edm::ParameterSet cfg)
explicit

Constructor.

Definition at line 137 of file SiPixelLorentzAngleCalibration.cc.

139  saveToDB_(cfg.getParameter<bool>("saveToDB")),
140  recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
141  outFileName_(cfg.getParameter<std::string>("treeFile")),
142  mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
143  lorentzAngleLabel_(cfg.getParameter<std::string>("lorentzAngleLabel")),
144  moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups")) {}
T getParameter(std::string const &) const
IntegratedCalibrationBase(const edm::ParameterSet &cfg)
Values and their parameter index.
const std::vector< std::string > mergeFileNames_
SiPixelLorentzAngleCalibration::~SiPixelLorentzAngleCalibration ( )
overridedefault

Destructor.

Member Function Documentation

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

Call at beginning of job:

Reimplemented from IntegratedCalibrationBase.

Definition at line 259 of file SiPixelLorentzAngleCalibration.cc.

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

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

Call at beginning of run:

Reimplemented from IntegratedCalibrationBase.

Definition at line 150 of file SiPixelLorentzAngleCalibration.cc.

References cond::TimeTypeSpecs::beginValue, cachedLorentzAngleInputs_, edm::ESWatcher< T >::check(), currentIOV_, Exception, dataset::firstRun, edm::EventSetup::get(), edm::eventsetup::EventSetupRecordImplementation< T >::get(), SiPixelLorentzAngle::getLorentzAngles(), mps_fire::i, lorentzAngleLabel_, moduleGroupSelector_, edm::RunBase::run(), cond::runnumber, convertSQLiteXML::runNumber, siPixelLorentzAngleInput_, cond::timeTypeSpecs, and watchLorentzAngleRcd_.

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

Definition at line 440 of file SiPixelLorentzAngleCalibration.cc.

References DEFINE_EDM_PLUGIN, FrontierConditions_GlobalTag_cff::file, and mps_fire::result.

Referenced by getLorentzAnglesInput().

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

References Calorimetry_cff::bField, Surface::bounds(), TrackingRecHit::det(), AlignmentAlgorithmBase::EventInfo::eventId(), GeomDet::geographicalId(), edm::EventSetup::get(), MagneticField::inTesla(), HLT_2018_cff::magneticField, moduleGroupSelector_, GloballyPositioned< T >::position(), edm::EventID::run(), GeomDet::surface(), Bounds::thickness(), and GloballyPositioned< T >::toLocal().

197  {
198  outDerivInds.clear();
199 
200  if (hit.det()) { // otherwise 'constraint hit' or whatever
201 
202  const int index =
203  moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(), eventInfo.eventId().run());
204  if (index >= 0) { // otherwise not treated
206  setup.get<IdealMagneticFieldRecord>().get(magneticField);
207  const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
208  const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
209  const double dZ = hit.det()->surface().bounds().thickness(); // it is a float only...
210  // shift due to LA: dx = tan(LA) * dz/2 = mobility * B_y * dz/2,
211  // shift due to LA: dy = - mobility * B_x * dz/2,
212  // '-' since we have derivative of the residual r = trk -hit
213  const double xDerivative = bFieldLocal.y() * dZ * -0.5; // parameter is mobility!
214  const double yDerivative = bFieldLocal.x() * dZ * 0.5; // parameter is mobility!
215  if (xDerivative || yDerivative) { // If field is zero, this is zero: do not return it
216  const Values derivs{xDerivative, yDerivative};
217  outDerivInds.push_back(ValuesIndexPair(derivs, index));
218  }
219  }
220  } else {
221  edm::LogWarning("Alignment") << "@SUB=SiPixelLorentzAngleCalibration::derivatives2"
222  << "Hit without GeomDet, skip!";
223  }
224 
225  return outDerivInds.size();
226 }
RunNumber_t run() const
Definition: EventID.h:38
const Bounds & bounds() const
Definition: Surface.h:89
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::pair< double, double > Values
virtual float thickness() const =0
T get() const
Definition: EventSetup.h:73
const PositionType & position() const
void SiPixelLorentzAngleCalibration::endOfJob ( )
overridevirtual

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

Implements IntegratedCalibrationBase.

Definition at line 284 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::service::PoolDBOutputService::writeOne(), and writeTree().

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

References cachedLorentzAngleInputs_, createFromTree(), currentIOV_, SiPixelLorentzAngle::getLorentzAngles(), mergeFileNames_, IntegratedCalibrationBase::name(), siPixelLorentzAngleInput_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endOfJob().

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

References parameters_.

Referenced by Mixins._Parameterizable::hasParameter().

249  {
250  return (index >= parameters_.size() ? 0. : parameters_[index]);
251 }
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 254 of file SiPixelLorentzAngleCalibration.cc.

References paramUncertainties_.

Referenced by endOfJob().

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 391 of file SiPixelLorentzAngleCalibration.cc.

References moduleGroupSelector_, and parameters_.

Referenced by endOfJob().

391  {
392  const int index = moduleGroupSelector_->getParameterIndexFromDetId(detId, run);
393  return (index < 0 ? 0. : parameters_[index]);
394 }
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
unsigned int SiPixelLorentzAngleCalibration::numParameters ( ) const
overridevirtual

How many parameters does this calibration define?

Implements IntegratedCalibrationBase.

Definition at line 147 of file SiPixelLorentzAngleCalibration.cc.

References parameters_.

Referenced by beginOfJob().

147 { return parameters_.size(); }
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 229 of file SiPixelLorentzAngleCalibration.cc.

References parameters_, and relativeConstraints::value.

Referenced by editorTools.UserCodeTool::__call__(), HiCoreTools.RestrictInputToAOD::__call__(), coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), runJetUncertainties.RunJetUncertainties::__call__(), metTools.AddMETCollection::__call__(), editorTools.ChangeSource::__call__(), HiCoreTools.RemoveMCMatching::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), tauTools.AddTauCollection::__call__(), trackTools.MakeTrackCandidates::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), HiCoreTools.AddCleaning::__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().

229  {
230  if (index >= parameters_.size()) {
231  return false;
232  } else {
234  return true;
235  }
236 }
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 239 of file SiPixelLorentzAngleCalibration.cc.

References relativeConstraints::error, and paramUncertainties_.

239  {
240  if (index >= paramUncertainties_.size()) {
241  return false;
242  } else {
244  return true;
245  }
246 }
void SiPixelLorentzAngleCalibration::writeTree ( const SiPixelLorentzAngle lorentzAngle,
const std::map< unsigned int, TreeStruct > &  treeInfo,
const char *  treeName 
) const
private

Definition at line 397 of file SiPixelLorentzAngleCalibration.cc.

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

Referenced by endOfJob().

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

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

Definition at line 123 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

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

Definition at line 125 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

const std::string SiPixelLorentzAngleCalibration::lorentzAngleLabel_
private

Definition at line 118 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun().

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

Definition at line 117 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and getLorentzAnglesInput().

const edm::ParameterSet SiPixelLorentzAngleCalibration::moduleGroupSelCfg_
private

Definition at line 130 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob().

std::unique_ptr<TkModuleGroupSelector> SiPixelLorentzAngleCalibration::moduleGroupSelector_
private
const std::string SiPixelLorentzAngleCalibration::outFileName_
private

Definition at line 116 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and writeTree().

std::vector<double> SiPixelLorentzAngleCalibration::parameters_
private
std::vector<double> SiPixelLorentzAngleCalibration::paramUncertainties_
private
const std::string SiPixelLorentzAngleCalibration::recordNameDBwrite_
private

Definition at line 115 of file SiPixelLorentzAngleCalibration.cc.

Referenced by endOfJob().

const bool SiPixelLorentzAngleCalibration::saveToDB_
private

Definition at line 114 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and endOfJob().

SiPixelLorentzAngle* SiPixelLorentzAngleCalibration::siPixelLorentzAngleInput_ { 0 }
private

Definition at line 124 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

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

Definition at line 120 of file SiPixelLorentzAngleCalibration.cc.

Referenced by beginRun().