CMS 3D CMS Logo

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

Public Member Functions

void beginOfJob (AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
 
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
 
 SiStripBackplaneCalibration (const edm::ParameterSet &cfg)
 Constructor. More...
 
 ~SiStripBackplaneCalibration () override
 Destructor. More...
 
- Public Member Functions inherited from IntegratedCalibrationBase
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
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

bool checkBackPlaneCorrectionInput (const edm::EventSetup &setup, const EventInfo &eventInfo)
 
SiStripBackPlaneCorrectioncreateFromTree (const char *fileName, const char *treeName) const
 
const SiStripBackPlaneCorrectiongetBackPlaneCorrectionInput ()
 
double getParameterForDetId (unsigned int detId, edm::RunNumber_t run) const
 
void writeTree (const SiStripBackPlaneCorrection *backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
 

Private Attributes

const std::vector< std::string > mergeFileNames_
 
const edm::ParameterSet moduleGroupSelCfg_
 
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_
 
SiStripBackPlaneCorrectionsiStripBackPlaneCorrInput_
 
edm::ESWatcher< SiStripBackPlaneCorrectionRcdwatchBackPlaneCorrRcd_
 

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

Author
: Gero Flucke date : November 2012
Revision
1.1.2.13
Date
2013/05/31 08:37:12

(last update by

Author
flucke

)

Calibration of back plane corrections for the strip tracker, integrated in the alignment algorithms. Note that not all algorithms support this...

Usally use one instance for deco mode data since peak mode should give the

Definition at line 54 of file SiStripBackplaneCalibration.cc.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 144 of file SiStripBackplaneCalibration.cc.

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

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

Destructor.

Definition at line 169 of file SiStripBackplaneCalibration.cc.

References moduleGroupSelector_, and siStripBackPlaneCorrInput_.

169  {
170  delete moduleGroupSelector_;
171  // std::cout << "Destroy SiStripBackplaneCalibration named " << this->name() << std::endl;
173 }
TkModuleGroupSelector * moduleGroupSelector_
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_

Member Function Documentation

void SiStripBackplaneCalibration::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 278 of file SiStripBackplaneCalibration.cc.

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

280  {
281  //specify the sub-detectors for which the back plane correction is determined: all strips
282  const std::vector<int> sdets = {SiStripDetId::TIB, SiStripDetId::TID, SiStripDetId::TOB, SiStripDetId::TEC};
283 
285 
288 
289  edm::LogInfo("Alignment") << "@SUB=SiStripBackplaneCalibration"
290  << "Created with name " << this->name() << " for readout mode '" << readoutModeName_
291  << "',\n"
292  << this->numParameters() << " parameters to be determined."
293  << "\nsaveToDB = " << saveToDB_ << "\n outFileName = " << outFileName_
294  << "\n N(merge files) = " << mergeFileNames_.size()
295  << "\n number of IOVs = " << moduleGroupSelector_->numIovs();
296 
297  if (!mergeFileNames_.empty()) {
298  edm::LogInfo("Alignment") << "@SUB=SiStripBackplaneCalibration"
299  << "First file to merge: " << mergeFileNames_[0];
300  }
301 }
TkModuleGroupSelector * moduleGroupSelector_
static constexpr auto TID
Definition: SiStripDetId.h:38
const std::string & name() const
name of this calibration
const edm::ParameterSet moduleGroupSelCfg_
unsigned int numParameters() const override
How many parameters does this calibration define?
const std::vector< std::string > mergeFileNames_
static constexpr auto TOB
Definition: SiStripDetId.h:39
static constexpr auto TIB
Definition: SiStripDetId.h:37
unsigned int getNumberOfParameters() const
unsigned int numIovs() const
Total number of IOVs.
static constexpr auto TEC
Definition: SiStripDetId.h:40
bool SiStripBackplaneCalibration::checkBackPlaneCorrectionInput ( const edm::EventSetup setup,
const EventInfo eventInfo 
)
private

If called the first time, fill 'siStripBackPlaneCorrInput_', later check that Backplane has not changed.

Definition at line 394 of file SiStripBackplaneCalibration.cc.

References edm::ESWatcher< T >::check(), AlignmentAlgorithmBase::EventInfo::eventId(), Exception, edm::EventSetup::get(), SiStripBackPlaneCorrection::getBackPlaneCorrections(), readoutModeName_, edm::EventID::run(), siStripBackPlaneCorrInput_, and watchBackPlaneCorrRcd_.

Referenced by derivatives().

395  {
396  edm::ESHandle<SiStripBackPlaneCorrection> backPlaneCorrHandle;
398  setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneCorrHandle);
399  siStripBackPlaneCorrInput_ = new SiStripBackPlaneCorrection(*backPlaneCorrHandle);
400  // FIXME: Should we call 'watchBackPlaneCorrRcd_.check(setup)' as well?
401  // Otherwise could be that next check has to check via following 'else', though
402  // no new IOV has started... (to be checked)
403  } else {
404  if (watchBackPlaneCorrRcd_.check(setup)) { // new IOV of input - but how to check peak vs deco?
405  setup.get<SiStripBackPlaneCorrectionRcd>().get(readoutModeName_, backPlaneCorrHandle);
406  if (backPlaneCorrHandle->getBackPlaneCorrections() // but only bad if non-identical values
407  != siStripBackPlaneCorrInput_->getBackPlaneCorrections()) { // (comparing maps)
408  // Maps are containers sorted by key, but comparison problems may arise from
409  // 'floating point comparison' problems (FIXME?)
410  throw cms::Exception("BadInput") << "SiStripBackplaneCalibration::checkBackPlaneCorrectionInput:\n"
411  << "Content of SiStripBackPlaneCorrection changed at run "
412  << eventInfo.eventId().run() << ", but algorithm expects constant input!\n";
413  return false; // not reached...
414  }
415  }
416  }
417 
418  return true;
419 }
RunNumber_t run() const
Definition: EventID.h:38
const std::map< unsigned int, float > & getBackPlaneCorrections() const
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
const edm::EventID eventId() const
edm::ESWatcher< SiStripBackPlaneCorrectionRcd > watchBackPlaneCorrRcd_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
T get() const
Definition: EventSetup.h:73
SiStripBackPlaneCorrection * SiStripBackplaneCalibration::createFromTree ( const char *  fileName,
const char *  treeName 
) const
private

Definition at line 510 of file SiStripBackplaneCalibration.cc.

References DEFINE_EDM_PLUGIN, FrontierConditions_GlobalTag_cff::file, SiStripBackPlaneCorrection::putBackPlaneCorrection(), and mps_fire::result.

Referenced by getBackPlaneCorrectionInput().

511  {
512  // Check for file existence on your own to work around
513  // https://hypernews.cern.ch/HyperNews/CMS/get/swDevelopment/2715.html:
514  TFile *file = nullptr;
515  FILE *testFile = fopen(fileName, "r");
516  if (testFile) {
517  fclose(testFile);
518  file = TFile::Open(fileName, "READ");
519  } // else not existing, see error below
520 
521  TTree *tree = nullptr;
522  if (file)
523  file->GetObject(treeName, tree);
524 
526  if (tree) {
527  unsigned int id = 0;
528  float value = 0.;
529  tree->SetBranchAddress("detId", &id);
530  tree->SetBranchAddress("value", &value);
531 
532  result = new SiStripBackPlaneCorrection;
533  const Long64_t nEntries = tree->GetEntries();
534  for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
535  tree->GetEntry(iEntry);
536  result->putBackPlaneCorrection(id, value);
537  }
538  } else { // Warning only since could be parallel job on no events.
539  edm::LogWarning("Alignment") << "@SUB=SiStripBackplaneCalibration::createFromTree"
540  << "Could not get TTree '" << treeName << "' from file '" << fileName
541  << (file ? "'." : "' (file does not exist).");
542  }
543 
544  delete file; // tree will vanish with file
545  return result;
546 }
bool putBackPlaneCorrection(const uint32_t &, float)
Definition: value.py:1
Definition: tree.py:1
unsigned int SiStripBackplaneCalibration::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 179 of file SiStripBackplaneCalibration.cc.

References Calorimetry_cff::bField, Surface::bounds(), checkBackPlaneCorrectionInput(), TrackingRecHit::det(), AlignmentAlgorithmBase::EventInfo::eventId(), GeomDet::geographicalId(), edm::EventSetup::get(), SiStripLorentzAngle::getLorentzAngle(), TkModuleGroupSelector::getParameterIndexFromDetId(), MagneticField::inTesla(), kDeconvolutionMode, kPeakMode, config_102169_raw_cff::latency, TrajectoryStateOnSurface::localParameters(), HLT_2018_cff::magneticField, LocalTrajectoryParameters::mixedFormatVector(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, moduleGroupSelector_, GloballyPositioned< T >::position(), readoutMode_, readoutModeName_, edm::EventID::run(), SiStripLatency::singleReadOutMode(), GeomDet::surface(), Bounds::thickness(), and GloballyPositioned< T >::toLocal().

183  {
184  // ugly const-cast:
185  // But it is either only first initialisation or throwing an exception...
186  const_cast<SiStripBackplaneCalibration *>(this)->checkBackPlaneCorrectionInput(setup, eventInfo);
187 
188  outDerivInds.clear();
189 
191  setup.get<SiStripLatencyRcd>().get(latency);
192  const int16_t mode = latency->singleReadOutMode();
193 
194  if (mode == readoutMode_) {
195  if (hit.det()) { // otherwise 'constraint hit' or whatever
196 
197  const int index =
199  if (index >= 0) { // otherwise not treated
201  setup.get<IdealMagneticFieldRecord>().get(magneticField);
202  const GlobalVector bField(magneticField->inTesla(hit.det()->surface().position()));
203  const LocalVector bFieldLocal(hit.det()->surface().toLocal(bField));
204  //std::cout << "SiStripBackplaneCalibration derivatives " << readoutModeName_ << std::endl;
205  const double dZ = hit.det()->surface().bounds().thickness(); // it's a float only...
206  const double tanPsi = tsos.localParameters().mixedFormatVector()[1]; //float...
207 
208  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
209  setup.get<SiStripLorentzAngleRcd>().get(readoutModeName_, lorentzAngleHandle);
210  // Yes, mobility (= LA/By) stored in object called LA...
211  const double mobility = lorentzAngleHandle->getLorentzAngle(hit.det()->geographicalId());
212  // shift due to dead back plane has two parts:
213  // 1) Lorentz Angle correction formula gets reduced thickness dz*(1-bp)
214  // 2) 'Direct' effect is shift of effective module position in local z by bp*dz/2
215  // (see GF's presentation in alignment meeting 25.10.2012,
216  // https://indico.cern.ch/conferenceDisplay.py?confId=174266#2012-10-25)
217  // const double xDerivative = 0.5 * dZ * (mobility * bFieldLocal.y() - tanPsi);
218  //FIXME: +tanPsi? At least that fits the sign of the dr/dw residual
219  // in KarimakiDerivatives...
220  const double xDerivative = 0.5 * dZ * (mobility * bFieldLocal.y() + tanPsi);
221  // std::cout << "derivative is " << xDerivative << " for index " << index
222  // << std::endl;
223  // if (index >= 10) {
224  // std::cout << "mobility * y-field " << mobility * bFieldLocal.y()
225  // << ", \n tanPsi " << tanPsi /*<< ", dZ " << dZ */ << std::endl;
226  // std::cout << "|tanPsi| - |mobility * y-field| "
227  // << fabs(tanPsi) - fabs(mobility * bFieldLocal.y())
228  // << std::endl;
229  // }
230  const Values derivs(xDerivative, 0.); // yDerivative = 0.
231  outDerivInds.push_back(ValuesIndexPair(derivs, index));
232  }
233  } else {
234  edm::LogWarning("Alignment") << "@SUB=SiStripBackplaneCalibration::derivatives1"
235  << "Hit without GeomDet, skip!";
236  }
237  } else if (mode != kDeconvolutionMode && mode != kPeakMode) {
238  // warn only if unknown/mixed mode
239  edm::LogWarning("Alignment") << "@SUB=SiStripBackplaneCalibration::derivatives2"
240  << "Readout mode is " << mode << ", but looking for " << readoutMode_ << " ("
241  << readoutModeName_ << ").";
242  }
243 
244  return outDerivInds.size();
245 }
RunNumber_t run() const
Definition: EventID.h:38
TkModuleGroupSelector * moduleGroupSelector_
const LocalTrajectoryParameters & localParameters() const
int16_t singleReadOutMode() const
const Bounds & bounds() const
Definition: Surface.h:89
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool checkBackPlaneCorrectionInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
float getLorentzAngle(const uint32_t &) const
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
AlgebraicVector5 mixedFormatVector() const
T get() const
Definition: EventSetup.h:73
const PositionType & position() const
void SiStripBackplaneCalibration::endOfJob ( )
overridevirtual

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

Implements IntegratedCalibrationBase.

Definition at line 304 of file SiStripBackplaneCalibration.cc.

References HltBtagPostValidation_cff::c, TkModuleGroupSelector::firstRunOfIOV(), getBackPlaneCorrectionInput(), SiStripBackPlaneCorrection::getBackPlaneCorrections(), getParameterError(), getParameterForDetId(), TkModuleGroupSelector::getParameterIndexFromDetId(), input, edm::Service< T >::isAvailable(), moduleGroupSelector_, IntegratedCalibrationBase::name(), TkModuleGroupSelector::numIovs(), MillePedeFileConverter_cfg::out, convertSQLitetoXML_cfg::output, parameters_, paramUncertainties_, SiStripBackPlaneCorrection::putBackPlaneCorrection(), readoutModeName_, recordNameDBwrite_, saveToDB_, AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::writeOne(), and writeTree().

304  {
305  // loginfo output
306  std::ostringstream out;
307  out << "Parameter results for readout mode '" << readoutModeName_ << "'\n";
308  for (unsigned int iPar = 0; iPar < parameters_.size(); ++iPar) {
309  out << iPar << ": " << parameters_[iPar] << " +- " << paramUncertainties_[iPar] << "\n";
310  }
311  edm::LogInfo("Alignment") << "@SUB=SiStripBackplaneCalibration::endOfJob" << out.str();
312 
313  std::map<unsigned int, TreeStruct> treeInfo; // map of TreeStruct for each detId
314 
315  // now write 'input' tree
316  const SiStripBackPlaneCorrection *input = this->getBackPlaneCorrectionInput(); // never NULL
317  const std::string treeName(this->name() + '_' + readoutModeName_ + '_');
318  this->writeTree(input, treeInfo, (treeName + "input").c_str()); // empty treeInfo for input...
319 
320  if (input->getBackPlaneCorrections().empty()) {
321  edm::LogError("Alignment") << "@SUB=SiStripBackplaneCalibration::endOfJob"
322  << "Input back plane correction map is empty ('" << readoutModeName_
323  << "' mode), skip writing output!";
324  return;
325  }
326 
327  const unsigned int nonZeroParamsOrErrors = // Any determined value?
328  count_if(parameters_.begin(), parameters_.end(), [](auto c) { return c != 0.; }) +
329  count_if(paramUncertainties_.begin(), paramUncertainties_.end(), [](auto c) { return c != 0.; });
330 
331  for (unsigned int iIOV = 0; iIOV < moduleGroupSelector_->numIovs(); ++iIOV) {
332  cond::Time_t firstRunOfIOV = moduleGroupSelector_->firstRunOfIOV(iIOV);
334  // Loop on map of values from input and add (possible) parameter results
335  for (auto iterIdValue = input->getBackPlaneCorrections().begin();
336  iterIdValue != input->getBackPlaneCorrections().end();
337  ++iterIdValue) {
338  // type of (*iterIdValue) is pair<unsigned int, float>
339  const unsigned int detId = iterIdValue->first; // key of map is DetId
340  // Some code one could use to miscalibrate wrt input:
341  // double param = 0.;
342  // const DetId id(detId);
343  // switch (id.subdetId()) {
344  // case 3:
345  // // delta = 0.025;
346  // {
347  // TIBDetId tibId(detId);
348  // param = tibId.layer() * 0.01;
349  // }
350  // break;
351  // case 5:
352  // //delta = 0.050;
353  // {
354  // TOBDetId tobId(detId);
355  // param = tobId.layer() * 0.015;
356  // }
357  // break;
358  // case 4: // TID
359  // param = 0.03; break;
360  // case 6: // TEC
361  // param = 0.05; break;
362  // break;
363  // default:
364  // std::cout << "unknown subdet " << id.subdetId() << std::endl;
365  // }
366  const double param = this->getParameterForDetId(detId, firstRunOfIOV);
367  // put result in output, i.e. sum of input and determined parameter:
368  output->putBackPlaneCorrection(detId, iterIdValue->second + param);
369  const int paramIndex = moduleGroupSelector_->getParameterIndexFromDetId(detId, firstRunOfIOV);
370  treeInfo[detId] = TreeStruct(param, this->getParameterError(paramIndex), paramIndex);
371  }
372 
373  if (saveToDB_ || nonZeroParamsOrErrors != 0) { // Skip writing mille jobs...
374  this->writeTree(output, treeInfo, (treeName + Form("result_%lld", firstRunOfIOV)).c_str());
375  }
376 
377  if (saveToDB_) { // If requested, write out to DB
379  if (dbService.isAvailable()) {
380  dbService->writeOne(output, firstRunOfIOV, recordNameDBwrite_);
381  // no 'delete output;': writeOne(..) took over ownership
382  } else {
383  delete output;
384  edm::LogError("BadConfig") << "@SUB=SiStripBackplaneCalibration::endOfJob"
385  << "No PoolDBOutputService available, but saveToDB true!";
386  }
387  } else {
388  delete output;
389  }
390  } // end loop on IOVs
391 }
TkModuleGroupSelector * moduleGroupSelector_
bool putBackPlaneCorrection(const uint32_t &, float)
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
const std::map< unsigned int, float > & getBackPlaneCorrections() const
const std::string & name() const
name of this calibration
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
void writeTree(const SiStripBackPlaneCorrection *backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
static std::string const input
Definition: EdmProvDump.cc:48
const SiStripBackPlaneCorrection * getBackPlaneCorrectionInput()
structure to store algorithm results in a TTree
Definition: TreeStruct.h:6
unsigned long long Time_t
Definition: Time.h:14
bool isAvailable() const
Definition: Service.h:40
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
double getParameterError(unsigned int index) const override
unsigned int numIovs() const
Total number of IOVs.
const SiStripBackPlaneCorrection * SiStripBackplaneCalibration::getBackPlaneCorrectionInput ( )
private

Input BackPlaneCorrection 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 422 of file SiStripBackplaneCalibration.cc.

References createFromTree(), SiStripBackPlaneCorrection::getBackPlaneCorrections(), mergeFileNames_, IntegratedCalibrationBase::name(), readoutModeName_, siStripBackPlaneCorrInput_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by endOfJob().

422  {
423  // For parallel processing in Millepede II, create SiStripBackPlaneCorrection
424  // from info stored in files of parallel jobs and check that they are identical.
425  // If this job has run on events, still check that back plane corrections are
426  // identical to the ones from mergeFileNames_.
427  const std::string treeName(((this->name() + '_') += readoutModeName_) += "_input");
428  for (auto iFile = mergeFileNames_.begin(); iFile != mergeFileNames_.end(); ++iFile) {
429  SiStripBackPlaneCorrection *bpCorr = this->createFromTree(iFile->c_str(), treeName.c_str());
430  // siStripBackPlaneCorrInput_ could be non-null from previous file of this loop
431  // or from checkBackPlaneCorrectionInput(..) when running on data in this job as well
433  delete siStripBackPlaneCorrInput_; // NULL or empty
435  } else {
436  // about comparison of maps see comments in checkBackPlaneCorrectionInput
437  if (bpCorr && !bpCorr->getBackPlaneCorrections().empty() && // single job might not have got events
439  // Throw exception instead of error?
440  edm::LogError("NoInput") << "@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
441  << "Different input values from tree " << treeName << " in file " << *iFile << ".";
442  }
443  delete bpCorr;
444  }
445  }
446 
447  if (!siStripBackPlaneCorrInput_) { // no files nor ran on events
449  edm::LogError("NoInput") << "@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
450  << "No input, create an empty one ('" << readoutModeName_ << "' mode)!";
451  } else if (siStripBackPlaneCorrInput_->getBackPlaneCorrections().empty()) {
452  edm::LogError("NoInput") << "@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
453  << "Empty result ('" << readoutModeName_ << "' mode)!";
454  }
455 
457 }
const std::map< unsigned int, float > & getBackPlaneCorrections() const
const std::string & name() const
name of this calibration
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
SiStripBackPlaneCorrection * createFromTree(const char *fileName, const char *treeName) const
const std::vector< std::string > mergeFileNames_
double SiStripBackplaneCalibration::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 268 of file SiStripBackplaneCalibration.cc.

References parameters_.

Referenced by Mixins._Parameterizable::hasParameter().

268  {
269  return (index >= parameters_.size() ? 0. : parameters_[index]);
270 }
double SiStripBackplaneCalibration::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 273 of file SiStripBackplaneCalibration.cc.

References paramUncertainties_.

Referenced by endOfJob().

273  {
274  return (index >= paramUncertainties_.size() ? 0. : paramUncertainties_[index]);
275 }
double SiStripBackplaneCalibration::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 460 of file SiStripBackplaneCalibration.cc.

References TkModuleGroupSelector::getParameterIndexFromDetId(), moduleGroupSelector_, and parameters_.

Referenced by endOfJob().

460  {
462 
463  return (index < 0 ? 0. : parameters_[index]);
464 }
TkModuleGroupSelector * moduleGroupSelector_
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
unsigned int SiStripBackplaneCalibration::numParameters ( ) const
overridevirtual

How many parameters does this calibration define?

Implements IntegratedCalibrationBase.

Definition at line 176 of file SiStripBackplaneCalibration.cc.

References parameters_.

Referenced by beginOfJob().

176 { return parameters_.size(); }
bool SiStripBackplaneCalibration::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 248 of file SiStripBackplaneCalibration.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().

248  {
249  if (index >= parameters_.size()) {
250  return false;
251  } else {
253  return true;
254  }
255 }
bool SiStripBackplaneCalibration::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 258 of file SiStripBackplaneCalibration.cc.

References relativeConstraints::error, and paramUncertainties_.

258  {
259  if (index >= paramUncertainties_.size()) {
260  return false;
261  } else {
263  return true;
264  }
265 }
void SiStripBackplaneCalibration::writeTree ( const SiStripBackPlaneCorrection backPlaneCorr,
const std::map< unsigned int, TreeStruct > &  treeInfo,
const char *  treeName 
) const
private

Definition at line 467 of file SiStripBackplaneCalibration.cc.

References FrontierConditions_GlobalTag_cff::file, TkModuleGroupSelector::firstRunOfIOV(), SiStripBackPlaneCorrection::getBackPlaneCorrections(), TkModuleGroupSelector::getParameterIndexFromDetId(), TreeStruct::LeafList(), moduleGroupSelector_, and outFileName_.

Referenced by endOfJob().

469  {
470  if (!backPlaneCorrection)
471  return;
472 
473  TFile *file = TFile::Open(outFileName_.c_str(), "UPDATE");
474  if (!file) {
475  edm::LogError("BadConfig") << "@SUB=SiStripBackplaneCalibration::writeTree"
476  << "Could not open file '" << outFileName_ << "'.";
477  return;
478  }
479 
480  TTree *tree = new TTree(treeName, treeName);
481  unsigned int id = 0;
482  float value = 0.;
483  TreeStruct treeStruct;
484  tree->Branch("detId", &id, "detId/i");
485  tree->Branch("value", &value, "value/F");
486  tree->Branch("treeStruct", &treeStruct, TreeStruct::LeafList());
487 
488  for (auto iterIdValue = backPlaneCorrection->getBackPlaneCorrections().begin();
489  iterIdValue != backPlaneCorrection->getBackPlaneCorrections().end();
490  ++iterIdValue) {
491  // type of (*iterIdValue) is pair<unsigned int, float>
492  id = iterIdValue->first; // key of map is DetId
493  value = iterIdValue->second;
494  // type of (*treeStructIter) is pair<unsigned int, TreeStruct>
495  auto treeStructIter = treeInfo.find(id); // find info for this id
496  if (treeStructIter != treeInfo.end()) {
497  treeStruct = treeStructIter->second; // info from input map
498  } else { // if none found, fill at least parameter index (using 1st IOV...)
499  const cond::Time_t run1of1stIov = moduleGroupSelector_->firstRunOfIOV(0);
500  const int ind = moduleGroupSelector_->getParameterIndexFromDetId(id, run1of1stIov);
501  treeStruct = TreeStruct(ind);
502  }
503  tree->Fill();
504  }
505  tree->Write();
506  delete file; // tree vanishes with the file...
507 }
TkModuleGroupSelector * moduleGroupSelector_
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
int getParameterIndexFromDetId(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:14
Definition: value.py:1
static const char * LeafList()
Definition: TreeStruct.h:16
Definition: tree.py:1

Member Data Documentation

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

Definition at line 127 of file SiStripBackplaneCalibration.cc.

Referenced by beginOfJob(), and getBackPlaneCorrectionInput().

const edm::ParameterSet SiStripBackplaneCalibration::moduleGroupSelCfg_
private

Definition at line 137 of file SiStripBackplaneCalibration.cc.

Referenced by beginOfJob().

TkModuleGroupSelector* SiStripBackplaneCalibration::moduleGroupSelector_
private
const std::string SiStripBackplaneCalibration::outFileName_
private

Definition at line 126 of file SiStripBackplaneCalibration.cc.

Referenced by beginOfJob(), and writeTree().

std::vector<double> SiStripBackplaneCalibration::parameters_
private
std::vector<double> SiStripBackplaneCalibration::paramUncertainties_
private
int16_t SiStripBackplaneCalibration::readoutMode_
private

Definition at line 123 of file SiStripBackplaneCalibration.cc.

Referenced by derivatives(), and SiStripBackplaneCalibration().

const std::string SiStripBackplaneCalibration::readoutModeName_
private
const std::string SiStripBackplaneCalibration::recordNameDBwrite_
private

Definition at line 125 of file SiStripBackplaneCalibration.cc.

Referenced by endOfJob().

const bool SiStripBackplaneCalibration::saveToDB_
private

Definition at line 124 of file SiStripBackplaneCalibration.cc.

Referenced by beginOfJob(), and endOfJob().

SiStripBackPlaneCorrection* SiStripBackplaneCalibration::siStripBackPlaneCorrInput_
private
edm::ESWatcher<SiStripBackPlaneCorrectionRcd> SiStripBackplaneCalibration::watchBackPlaneCorrRcd_
private

Definition at line 129 of file SiStripBackplaneCalibration.cc.

Referenced by checkBackPlaneCorrectionInput().