66 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
111 const std::map<unsigned int, TreeStruct> &treeInfo,
112 const char *treeName)
const;
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")),
164 throw cms::Exception(
"BadConfig") <<
"SiStripLorentzAngleCalibration:\n" 166 <<
"', should be 'peak' or 'deconvolution' .\n";
197 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
203 <<
") in an IOV (" <<
firstRun <<
") that was already cached.\n" 204 <<
"The following record in your input database tag has an IOV " 205 <<
"boundary that does not match your IOV definition:\n" 206 <<
" - SiStripLorentzAngleRcd '" << lorentzAngleRcd.key().name() <<
"' (since " 207 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
221 outDerivInds.clear();
245 const double xDerivative = bFieldLocal.y() *
dZ * -0.5;
246 const double yDerivative = bFieldLocal.x() *
dZ * 0.5;
247 if (xDerivative || yDerivative) {
248 const Values derivs{xDerivative, yDerivative};
253 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives1" 254 <<
"Hit without GeomDet, skip!";
258 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives2" 259 <<
"Readout mode is " <<
mode <<
", but looking for " <<
readoutMode_ <<
" (" 263 return outDerivInds.size();
307 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" 316 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" 324 std::ostringstream
out;
326 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
329 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" <<
out.str();
331 std::map<unsigned int, TreeStruct> treeInfo;
334 const std::string treeName{this->
name() +
'_' + readoutModeName_ +
'_'};
335 std::vector<const SiStripLorentzAngle *>
inputs{};
344 if (
inputs.back()->getLorentzAngles().empty()) {
345 edm::LogError(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" 347 <<
"' mode), skip writing output!";
352 const unsigned int nonZeroParamsOrErrors =
360 for (
const auto &iterIdValue :
inputs[iIOV]->getLorentzAngles()) {
362 const auto detId = iterIdValue.first;
373 auto value = iterIdValue.second +
static_cast<float>(param);
379 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
380 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
388 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" 389 <<
"No PoolDBOutputService available, but saveToDB true!";
406 const double bpCor = backPlaneHandle->getBackPlaneCorrection(
id);
431 if (!la.getLorentzAngles().empty() &&
434 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 435 <<
"Different input values from tree " << treeName <<
" in file " << iFile <<
".";
444 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 447 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 463 const std::map<unsigned int, TreeStruct> &treeInfo,
464 const char *treeName)
const {
470 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::writeTree" 475 TTree *
tree =
new TTree(treeName, treeName);
479 tree->Branch(
"detId", &
id,
"detId/i");
480 tree->Branch(
"value", &
value,
"value/F");
487 id = iterIdValue->first;
488 value = iterIdValue->second;
490 auto treeStructIter = treeInfo.find(
id);
491 if (treeStructIter != treeInfo.end()) {
492 treeStruct = treeStructIter->second;
508 TFile *
file =
nullptr;
509 FILE *testFile = fopen(
fileName,
"r");
515 TTree *
tree =
nullptr;
523 tree->SetBranchAddress(
"detId", &
id);
526 const Long64_t nEntries =
tree->GetEntries();
527 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
528 tree->GetEntry(iEntry);
532 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::createFromTree" 533 <<
"Could not get TTree '" << treeName <<
"' from file '" <<
fileName 534 << (
file ?
"'." :
"' (file does not exist).");
const TimeTypeSpecs timeTypeSpecs[]
const std::string recordNameDBwrite_
void writeTree(const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
static constexpr auto TID
const edm::ParameterSet moduleGroupSelCfg_
const std::vector< std::string > mergeFileNames_
std::vector< double > parameters_
double getParameterError(unsigned int index) const override
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > lorentzAngleToken_
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
Log< level::Error, false > LogError
bool setParameter(unsigned int index, double value) override
const GeomDet * det() const
static std::string to_string(const XMLCh *ch)
define event information passed to algorithms
edm::ESWatcher< SiStripLorentzAngleRcd > watchLorentzAngleRcd_
const std::string outFileName_
double getParameter(unsigned int index) const override
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_
virtual float thickness() const =0
structure to store algorithm results in a TTree
unsigned long long Time_t
~SiStripLorentzAngleCalibration() override=default
Destructor.
double effectiveThickness(const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
in non-peak mode the effective thickness is reduced...
const std::string readoutModeName_
std::vector< double > paramUncertainties_
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
const edm::ESGetToken< SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionRcd > backPlaneCorrToken_
align::RunNumber currentIOV_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
DetId geographicalId() const
The label of this GeomDet.
static constexpr auto TOB
SiStripLorentzAngle createFromTree(const char *fileName, const char *treeName) const
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
std::pair< double, double > Values
Log< level::Info, false > LogInfo
Detector identifier class for the strip tracker.
const Plane & surface() const
The nominal surface of the GeomDet.
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
static const char * LeafList()
void beginRun(const edm::Run &, const edm::EventSetup &) override
Call at beginning of run:
bool check(const edm::EventSetup &iSetup)
static constexpr auto TIB
SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
Constructor.
const SiStripLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
unsigned int numParameters() const override
How many parameters does this calibration define?
bool setParameterError(unsigned int index, double error) override
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
SiStripLorentzAngle * siStripLorentzAngleInput_
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning
const std::map< unsigned int, float > & getLorentzAngles() const
Constructor of the full muon geometry.
const std::string & name() const
name of this calibration
static constexpr auto TEC
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
cond::RealTimeType< cond::runnumber >::type RunNumber
const Bounds & bounds() const