66 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
70 const EventInfo &eventInfo)
const override;
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")),
150 mergeFileNames_(cfg.getParameter<std::
vector<std::
string> >(
"mergeTreeFiles")),
151 moduleGroupSelCfg_(cfg.getParameter<edm::
ParameterSet>(
"LorentzAngleModuleGroups")),
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"
346 <<
"Input Lorentz angle map is empty ('" << readoutModeName_
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);
415 const auto &resolvedRun = run > 0 ? run :
currentIOV_;
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");
512 file = TFile::Open(fileName,
"READ");
515 TTree *
tree =
nullptr;
517 file->GetObject(treeName, tree);
523 tree->SetBranchAddress(
"detId", &
id);
524 tree->SetBranchAddress(
"value", &value);
526 const Long64_t nEntries = tree->GetEntries();
527 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
528 tree->GetEntry(iEntry);
529 result.putLorentzAngle(
id, value);
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_
const edm::EventSetup & c
tuple SiStripLorentzAngle
uint16_t *__restrict__ id
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
static constexpr auto TID
const edm::ParameterSet moduleGroupSelCfg_
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
int16_t singleReadOutMode() const
const std::vector< std::string > mergeFileNames_
const std::map< unsigned int, float > & getLorentzAngles() const
std::vector< double > parameters_
const std::string & name() const
name of this calibration
std::string to_string(const V &value)
const Bounds & bounds() const
double getParameterError(unsigned int index) const override
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > lorentzAngleToken_
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
Log< level::Error, false > LogError
void writeTree(const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
bool setParameter(unsigned int index, double value) override
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
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
bool getData(T &iHolder) const
structure to store algorithm results in a TTree
unsigned long long Time_t
~SiStripLorentzAngleCalibration() override=default
Destructor.
const std::string readoutModeName_
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
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.
SiStripLorentzAngle createFromTree(const char *fileName, const char *treeName) const
static constexpr auto TOB
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.
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
static const char * LeafList()
double effectiveThickness(const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
in non-peak mode the effective thickness is reduced...
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_
Log< level::Warning, false > LogWarning
Constructor of the full muon geometry.
const PositionType & position() const
static constexpr auto TEC
cond::RealTimeType< cond::runnumber >::type RunNumber