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

Constructor.

Definition at line 141 of file SiStripLorentzAngleCalibration.cc.

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

143  readoutModeName_(cfg.getParameter<std::string>("readoutMode")),
144  saveToDB_(cfg.getParameter<bool>("saveToDB")),
145  recordNameDBwrite_(cfg.getParameter<std::string>("recordNameDBwrite")),
146  outFileName_(cfg.getParameter<std::string>("treeFile")),
147  mergeFileNames_(cfg.getParameter<std::vector<std::string> >("mergeTreeFiles")),
148  moduleGroupSelCfg_(cfg.getParameter<edm::ParameterSet>("LorentzAngleModuleGroups"))
149 {
150 
151  // SiStripLatency::singleReadOutMode() returns
152  // 1: all in peak, 0: all in deco, -1: mixed state
153  // (in principle one could treat even mixed state APV by APV...)
154  if (readoutModeName_ == "peak") {
156  } else if (readoutModeName_ == "deconvolution") {
158  } else {
159  throw cms::Exception("BadConfig")
160  << "SiStripLorentzAngleCalibration:\n" << "Unknown mode '"
161  << readoutModeName_ << "', should be 'peak' or 'deconvolution' .\n";
162  }
163 
164 }
T getParameter(std::string const &) const
IntegratedCalibrationBase(const edm::ParameterSet &cfg)
Values and their parameter index.
const std::vector< std::string > mergeFileNames_
SiStripLorentzAngleCalibration::~SiStripLorentzAngleCalibration ( )
overridedefault

Destructor.

Member Function Documentation

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 309 of file SiStripLorentzAngleCalibration.cc.

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

312 {
313  //specify the sub-detectors for which the LA is determined
314  const std::vector<int> sdets = {SiStripDetId::TIB, SiStripDetId::TOB,
317  std::make_unique<TkModuleGroupSelector>(aliTracker, moduleGroupSelCfg_, sdets);
318 
319  parameters_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
320  paramUncertainties_.resize(moduleGroupSelector_->getNumberOfParameters(), 0.);
321 
322  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration" << "Created with name "
323  << this->name() << " for readout mode '" << readoutModeName_
324  << "',\n" << this->numParameters() << " parameters to be determined."
325  << "\nsaveToDB = " << saveToDB_
326  << "\n outFileName = " << outFileName_
327  << "\n N(merge files) = " << mergeFileNames_.size()
328  << "\n number of IOVs = " << moduleGroupSelector_->numIovs();
329 
330  if (!mergeFileNames_.empty()) {
331  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration"
332  << "First file to merge: " << mergeFileNames_[0];
333  }
334 }
const std::vector< std::string > mergeFileNames_
const std::string & name() const
name of this calibration
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
unsigned int numParameters() const override
How many parameters does this calibration define?
void SiStripLorentzAngleCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Call at beginning of run:

Reimplemented from IntegratedCalibrationBase.

Definition at line 174 of file SiStripLorentzAngleCalibration.cc.

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

175  {
176 
177  // no action needed if the LA record didn't change
178  if (!(watchLorentzAngleRcd_.check(setup))) return;
179 
180  const auto runNumber = run.run();
182 
183  // avoid infinite loop due to wrap-around of unsigned variable 'i' including
184  // arrow from i to zero and a nice smiley ;)
185  for (unsigned int i = moduleGroupSelector_->numIovs(); i-->0 ;) {
186  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(i);
187  if (runNumber >= firstRunOfIOV) {
188  firstRun = firstRunOfIOV;
189  break;
190  }
191  }
192 
193  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
194  const auto& lorentzAngleRcd = setup.get<SiStripLorentzAngleRcd>();
195  lorentzAngleRcd.get(readoutModeName_, lorentzAngleHandle);
197  cachedLorentzAngleInputs_.emplace(firstRun, SiStripLorentzAngle(*lorentzAngleHandle));
198  } else {
199  if (lorentzAngleRcd.validityInterval().first().eventID().run() > firstRun &&
200  lorentzAngleHandle->getLorentzAngles() // only bad if non-identical values
201  != cachedLorentzAngleInputs_[firstRun].getLorentzAngles()) { // (comparing maps)
202  // Maps are containers sorted by key, but comparison problems may arise from
203  // 'floating point comparison' problems (FIXME?)
204  throw cms::Exception("BadInput")
205  << "Trying to cache SiStripLorentzAngle payload for a run (" << runNumber
206  << ") in an IOV (" << firstRun << ") that was already cached.\n"
207  << "The following record in your input database tag has an IOV "
208  << "boundary that does not match your IOV definition:\n"
209  << " - SiStripLorentzAngleRcd '" << lorentzAngleRcd.key().name()
210  << "' (since "
211  << lorentzAngleRcd.validityInterval().first().eventID().run() << ")\n";
212  }
213  }
214 
217 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
RunNumber_t run() const
Definition: RunBase.h:40
Time_t beginValue
Definition: Time.h:45
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
edm::ESWatcher< SiStripLorentzAngleRcd > watchLorentzAngleRcd_
const std::map< unsigned int, float > & getLorentzAngles() const
void get(HolderT &iHolder) const
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
T get() const
Definition: EventSetup.h:62
firstRun
Definition: dataset.py:938
SiStripLorentzAngle SiStripLorentzAngleCalibration::createFromTree ( const char *  fileName,
const char *  treeName 
) const
private

Definition at line 530 of file SiStripLorentzAngleCalibration.cc.

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

Referenced by getLorentzAnglesInput().

531 {
532  // Check for file existence on your own to work around
533  // https://hypernews.cern.ch/HyperNews/CMS/get/swDevelopment/2715.html:
534  TFile* file = nullptr;
535  FILE* testFile = fopen(fileName,"r");
536  if (testFile) {
537  fclose(testFile);
538  file = TFile::Open(fileName, "READ");
539  } // else not existing, see error below
540 
541  TTree *tree = nullptr;
542  if (file) file->GetObject(treeName, tree);
543 
545  if (tree) {
546  unsigned int id = 0;
547  float value = 0.;
548  tree->SetBranchAddress("detId", &id);
549  tree->SetBranchAddress("value", &value);
550 
551  const Long64_t nEntries = tree->GetEntries();
552  for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
553  tree->GetEntry(iEntry);
554  result.putLorentzAngle(id, value);
555  }
556  } else { // Warning only since could be parallel job on no events.
557  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::createFromTree"
558  << "Could not get TTree '" << treeName << "' from file '"
559  << fileName << (file ? "'." : "' (file does not exist).");
560  }
561 
562  delete file; // tree will vanish with file
563  return result;
564 }
Definition: value.py:1
Definition: tree.py:1
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 221 of file SiStripLorentzAngleCalibration.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, TrackingRecHit::det(), effectiveThickness(), AlignmentAlgorithmBase::EventInfo::eventId(), GeomDet::geographicalId(), edm::EventSetup::get(), MagneticField::inTesla(), kDeconvolutionMode, kPeakMode, hcaltpdigi_cfi::latency, seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, moduleGroupSelector_, GloballyPositioned< T >::position(), readoutMode_, readoutModeName_, edm::EventID::run(), GeneralSetup::setup(), SiStripLatency::singleReadOutMode(), GeomDet::surface(), and GloballyPositioned< T >::toLocal().

226 {
227  outDerivInds.clear();
228 
230  setup.get<SiStripLatencyRcd>().get(latency);
231  const int16_t mode = latency->singleReadOutMode();
232  if (mode == readoutMode_) {
233  if (hit.det()) { // otherwise 'constraint hit' or whatever
234 
235  const int index = moduleGroupSelector_->getParameterIndexFromDetId(hit.det()->geographicalId(),
236  eventInfo.eventId().run());
237  if (index >= 0) { // otherwise not treated
239  setup.get<IdealMagneticFieldRecord>().get(magneticField);
240  const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
241  const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
242  const double dZ = this->effectiveThickness(hit.det(), mode, setup);
243  // shift due to LA: dx = tan(LA) * dz/2 = mobility * B_y * dz/2,
244  // '-' since we have derivative of the residual r = hit - trk and mu is part of trk model
245  // (see GF's presentation in alignment meeting 25.10.2012,
246  // https://indico.cern.ch/conferenceDisplay.py?confId=174266#2012-10-25)
247  // Hmm! StripCPE::fillParams() defines, together with
248  // StripCPE::driftDirection(...):
249  // drift.x = -mobility * by * thickness (full drift from backside)
250  // So '-' already comes from that, not from mobility being part of
251  // track model...
252  // GM: sign convention is the same as for pixel LA, i.e. adopt it here, too
253  const double xDerivative = bFieldLocal.y() * dZ * -0.5; // parameter is mobility!
254  const double yDerivative = bFieldLocal.x() * dZ * 0.5; // parameter is mobility!
255  if (xDerivative || yDerivative) { // If field is zero, this is zero: do not return it
256  const Values derivs{xDerivative, yDerivative};
257  outDerivInds.push_back(ValuesIndexPair(derivs, index));
258  }
259  }
260  } else {
261  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::derivatives1"
262  << "Hit without GeomDet, skip!";
263  }
264  } else if (mode != kDeconvolutionMode && mode != kPeakMode) {
265  // warn only if unknown/mixed mode
266  edm::LogWarning("Alignment") << "@SUB=SiStripLorentzAngleCalibration::derivatives2"
267  << "Readout mode is " << mode << ", but looking for "
268  << readoutMode_ << " (" << readoutModeName_ << ").";
269  }
270 
271  return outDerivInds.size();
272 }
RunNumber_t run() const
Definition: EventID.h:39
int16_t singleReadOutMode() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
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:79
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::pair< double, double > Values
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
double effectiveThickness(const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
in non-peak mode the effective thickness is reduced...
T get() const
Definition: EventSetup.h:62
latency
hardware algo
const PositionType & position() const
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 413 of file SiStripLorentzAngleCalibration.cc.

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

Referenced by derivatives().

416 {
417  if (!det) return 0.;
418  double dZ = det->surface().bounds().thickness(); // it is a float only...
419  const SiStripDetId id(det->geographicalId());
421  // FIXME: which one? DepRcd->get(handle) or Rcd->get(readoutModeName_, handle)??
422  // setup.get<SiStripBackPlaneCorrectionDepRcd>().get(backPlaneHandle); // get correct mode
423  setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneHandle);
424  const double bpCor = backPlaneHandle->getBackPlaneCorrection(id); // it's a float...
425  // std::cout << "bpCor " << bpCor << " in subdet " << id.subdetId() << std::endl;
426  dZ *= (1. - bpCor);
427 
428  return dZ;
429 }
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
virtual float thickness() const =0
T get() const
Definition: EventSetup.h:62
void SiStripLorentzAngleCalibration::endOfJob ( )
overridevirtual

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

Implements IntegratedCalibrationBase.

Definition at line 338 of file SiStripLorentzAngleCalibration.cc.

References EnergyCorrector::c, getLorentzAnglesInput(), getParameterError(), getParameterForDetId(), PatBasicFWLiteJetAnalyzer_Selector_cfg::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().

339 {
340  // loginfo output
341  std::ostringstream out;
342  out << "Parameter results for readout mode '" << readoutModeName_ << "'\n";
343  for (unsigned int iPar = 0; iPar < parameters_.size(); ++iPar) {
344  out << iPar << ": " << parameters_[iPar] << " +- " << paramUncertainties_[iPar] << "\n";
345  }
346  edm::LogInfo("Alignment") << "@SUB=SiStripLorentzAngleCalibration::endOfJob" << out.str();
347 
348  std::map<unsigned int, TreeStruct> treeInfo; // map of TreeStruct for each detId
349 
350  // now write 'input' tree
351  const std::string treeName{this->name() + '_' + readoutModeName_ + '_'};
352  std::vector<const SiStripLorentzAngle*> inputs{};
353  inputs.reserve(moduleGroupSelector_->numIovs());
354  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
355  const auto firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(iIOV);
356  inputs.push_back(this->getLorentzAnglesInput(firstRunOfIOV)); // never NULL
357  this->writeTree(inputs.back(), treeInfo,
358  (treeName + "input_" + std::to_string(firstRunOfIOV)).c_str()); // empty treeInfo for input...
359 
360  if (inputs.back()->getLorentzAngles().empty()) {
361  edm::LogError("Alignment") << "@SUB=SiStripLorentzAngleCalibration::endOfJob"
362  << "Input Lorentz angle map is empty ('"
363  << readoutModeName_ << "' mode), skip writing output!";
364  return;
365  }
366  }
367 
368  const unsigned int nonZeroParamsOrErrors = // Any determined value?
369  count_if (parameters_.begin(), parameters_.end(), [](auto c){return c!=0.;})
370  + count_if(paramUncertainties_.begin(), paramUncertainties_.end(),
371  [](auto c){return c!=0.;});
372 
373  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
374  auto firstRunOfIOV = static_cast<cond::Time_t>(moduleGroupSelector_->firstRunOfIOV(iIOV));
376  // Loop on map of values from input and add (possible) parameter results
377  for (const auto& iterIdValue: inputs[iIOV]->getLorentzAngles()) {
378  // type of 'iterIdValue' is pair<unsigned int, float>
379  const auto detId = iterIdValue.first; // key of map is DetId
380  // Some code one could use to miscalibrate wrt input:
381  // double param = 0.;
382  // const DetId id(detId);
383  // if (id.subdetId() == 3) { // TIB
384  // param = (readoutMode_ == kPeakMode ? -0.003 : -0.002);
385  // } else if (id.subdetId() == 5) { // TOB
386  // param = (readoutMode_ == kPeakMode ? 0.005 : 0.004);
387  // }
388  const double param = this->getParameterForDetId(detId, firstRunOfIOV);
389  // put result in output, i.e. sum of input and determined parameter:
390  auto value = iterIdValue.second + static_cast<float>(param);
391  output.putLorentzAngle(detId, value);
392  const int paramIndex = moduleGroupSelector_->getParameterIndexFromDetId(detId,firstRunOfIOV);
393  treeInfo[detId] = TreeStruct(param, this->getParameterError(paramIndex), paramIndex);
394  }
395 
396  if (saveToDB_ || nonZeroParamsOrErrors != 0) { // Skip writing mille jobs...
397  this->writeTree(&output, treeInfo, (treeName + Form("result_%lld", firstRunOfIOV)).c_str());
398  }
399 
400  if (saveToDB_) { // If requested, write out to DB
402  if (dbService.isAvailable()) {
403  dbService->writeOne(&output, firstRunOfIOV, recordNameDBwrite_);
404  } else {
405  edm::LogError("BadConfig") << "@SUB=SiStripLorentzAngleCalibration::endOfJob"
406  << "No PoolDBOutputService available, but saveToDB true!";
407  }
408  }
409  } // end loop on IOVs
410 }
const std::string & name() const
name of this calibration
void writeTree(const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
unsigned long long Time_t
Definition: Time.h:16
bool isAvailable() const
Definition: Service.h:46
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
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
const SiStripLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
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 433 of file SiStripLorentzAngleCalibration.cc.

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

Referenced by endOfJob().

434 {
435  const auto& resolvedRun = run > 0 ? run : currentIOV_;
436  // For parallel processing in Millepede II, create SiStripLorentzAngle
437  // from info stored in files of parallel jobs and check that they are identical.
438  // If this job has run on events, still check that LA is identical to the ones
439  // from mergeFileNames_.
440  const std::string treeName{this->name()+"_"+readoutModeName_+"_input_"+
441  std::to_string(resolvedRun)};
442  for (const auto& iFile: mergeFileNames_) {
443  auto la = this->createFromTree(iFile.c_str(), treeName.c_str());
444  // siStripLorentzAngleInput_ could be non-null from previous file of this loop
445  // or from checkLorentzAngleInput(..) when running on data in this job as well
447  cachedLorentzAngleInputs_[resolvedRun] = la;
449  currentIOV_ = resolvedRun;
450  } else {
451  // FIXME: about comparison of maps see comments in checkLorentzAngleInput
452  if (!la.getLorentzAngles().empty() && // single job might not have got events
453  la.getLorentzAngles() != siStripLorentzAngleInput_->getLorentzAngles()) {
454  // Throw exception instead of error?
455  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
456  << "Different input values from tree " << treeName
457  << " in file " << iFile << ".";
458 
459  }
460  }
461  }
462 
463  if (!siStripLorentzAngleInput_) { // no files nor ran on events
464  // [] operator default-constructs an empty SiStripLorentzAngle object in place:
466  currentIOV_ = resolvedRun;
467  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
468  << "No input, create an empty one ('" << readoutModeName_ << "' mode)!";
469  } else if (siStripLorentzAngleInput_->getLorentzAngles().empty()) {
470  edm::LogError("NoInput") << "@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
471  << "Empty result ('" << readoutModeName_ << "' mode)!";
472  }
473 
475 }
const std::vector< std::string > mergeFileNames_
const std::string & name() const
name of this calibration
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
const std::map< unsigned int, float > & getLorentzAngles() const
SiStripLorentzAngle createFromTree(const char *fileName, const char *treeName) const
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 297 of file SiStripLorentzAngleCalibration.cc.

References parameters_.

Referenced by Mixins._Parameterizable::hasParameter().

298 {
299  return (index >= parameters_.size() ? 0. : parameters_[index]);
300 }
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 303 of file SiStripLorentzAngleCalibration.cc.

References paramUncertainties_.

Referenced by endOfJob().

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 478 of file SiStripLorentzAngleCalibration.cc.

References moduleGroupSelector_, and parameters_.

Referenced by endOfJob().

480 {
481  const int index = moduleGroupSelector_->getParameterIndexFromDetId(detId, run);
482 
483  return (index < 0 ? 0. : parameters_[index]);
484 }
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
unsigned int SiStripLorentzAngleCalibration::numParameters ( ) const
overridevirtual

How many parameters does this calibration define?

Implements IntegratedCalibrationBase.

Definition at line 167 of file SiStripLorentzAngleCalibration.cc.

References parameters_.

Referenced by beginOfJob().

168 {
169  return parameters_.size();
170 }
bool SiStripLorentzAngleCalibration::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 275 of file SiStripLorentzAngleCalibration.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__(), trackTools.MakeTrackCandidates::__call__(), tauTools.AddTauCollection::__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().

276 {
277  if (index >= parameters_.size()) {
278  return false;
279  } else {
281  return true;
282  }
283 }
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 286 of file SiStripLorentzAngleCalibration.cc.

References relativeConstraints::error, and paramUncertainties_.

287 {
288  if (index >= paramUncertainties_.size()) {
289  return false;
290  } else {
292  return true;
293  }
294 }
void SiStripLorentzAngleCalibration::writeTree ( const SiStripLorentzAngle lorentzAngle,
const std::map< unsigned int, TreeStruct > &  treeInfo,
const char *  treeName 
) const
private

Definition at line 487 of file SiStripLorentzAngleCalibration.cc.

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

Referenced by endOfJob().

490 {
491  if (!lorentzAngle) return;
492 
493  TFile* file = TFile::Open(outFileName_.c_str(), "UPDATE");
494  if (!file) {
495  edm::LogError("BadConfig") << "@SUB=SiStripLorentzAngleCalibration::writeTree"
496  << "Could not open file '" << outFileName_ << "'.";
497  return;
498  }
499 
500  TTree *tree = new TTree(treeName, treeName);
501  unsigned int id = 0;
502  float value = 0.;
503  TreeStruct treeStruct;
504  tree->Branch("detId", &id, "detId/i");
505  tree->Branch("value", &value, "value/F");
506  tree->Branch("treeStruct", &treeStruct, TreeStruct::LeafList());
507 
508  for (auto iterIdValue = lorentzAngle->getLorentzAngles().begin();
509  iterIdValue != lorentzAngle->getLorentzAngles().end(); ++iterIdValue) {
510  // type of (*iterIdValue) is pair<unsigned int, float>
511  id = iterIdValue->first; // key of map is DetId
512  value = iterIdValue->second;
513  // type of (*treeStructIter) is pair<unsigned int, TreeStruct>
514  auto treeStructIter = treeInfo.find(id); // find info for this id
515  if (treeStructIter != treeInfo.end()) {
516  treeStruct = treeStructIter->second; // info from input map
517  } else { // if none found, fill at least parameter index (using 1st IOV...)
518  const cond::Time_t run1of1stIov = moduleGroupSelector_->firstRunOfIOV(0);
519  const int ind = moduleGroupSelector_->getParameterIndexFromDetId(id, run1of1stIov);
520  treeStruct = TreeStruct(ind);
521  }
522  tree->Fill();
523  }
524  tree->Write();
525  delete file; // tree vanishes with the file...
526 }
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
const std::map< unsigned int, float > & getLorentzAngles() const
unsigned long long Time_t
Definition: Time.h:16
Definition: value.py:1
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
static const char * LeafList()
Definition: TreeStruct.h:17
Definition: tree.py:1

Member Data Documentation

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

Definition at line 126 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

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

Definition at line 128 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

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

Definition at line 122 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and getLorentzAnglesInput().

const edm::ParameterSet SiStripLorentzAngleCalibration::moduleGroupSelCfg_
private

Definition at line 134 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob().

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

Definition at line 121 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and writeTree().

std::vector<double> SiStripLorentzAngleCalibration::parameters_
private
std::vector<double> SiStripLorentzAngleCalibration::paramUncertainties_
private
int16_t SiStripLorentzAngleCalibration::readoutMode_
private
const std::string SiStripLorentzAngleCalibration::readoutModeName_
private
const std::string SiStripLorentzAngleCalibration::recordNameDBwrite_
private

Definition at line 120 of file SiStripLorentzAngleCalibration.cc.

Referenced by endOfJob().

const bool SiStripLorentzAngleCalibration::saveToDB_
private

Definition at line 119 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginOfJob(), and endOfJob().

SiStripLorentzAngle* SiStripLorentzAngleCalibration::siStripLorentzAngleInput_ { 0 }
private

Definition at line 127 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun(), and getLorentzAnglesInput().

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

Definition at line 124 of file SiStripLorentzAngleCalibration.cc.

Referenced by beginRun().