66 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
111 const std::map<unsigned int, TreeStruct> &treeInfo,
112 const char *treeName)
const;
155 throw cms::Exception(
"BadConfig") <<
"SiStripLorentzAngleCalibration:\n" 157 <<
"', should be 'peak' or 'deconvolution' .\n";
189 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
195 <<
") in an IOV (" <<
firstRun <<
") that was already cached.\n" 196 <<
"The following record in your input database tag has an IOV " 197 <<
"boundary that does not match your IOV definition:\n" 198 <<
" - SiStripLorentzAngleRcd '" << lorentzAngleRcd.key().name() <<
"' (since " 199 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
213 outDerivInds.clear();
239 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
240 const double yDerivative = bFieldLocal.x() * dZ * 0.5;
241 if (xDerivative || yDerivative) {
242 const Values derivs{xDerivative, yDerivative};
247 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives1" 248 <<
"Hit without GeomDet, skip!";
252 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives2" 253 <<
"Readout mode is " << mode <<
", but looking for " <<
readoutMode_ <<
" (" 257 return outDerivInds.size();
301 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" 310 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" 318 std::ostringstream
out;
320 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
323 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" << out.str();
325 std::map<unsigned int, TreeStruct> treeInfo;
328 const std::string treeName{this->
name() +
'_' + readoutModeName_ +
'_'};
329 std::vector<const SiStripLorentzAngle *>
inputs{};
336 (treeName +
"input_" + std::to_string(firstRunOfIOV)).c_str());
338 if (
inputs.back()->getLorentzAngles().empty()) {
339 edm::LogError(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" 340 <<
"Input Lorentz angle map is empty ('" << readoutModeName_
341 <<
"' mode), skip writing output!";
346 const unsigned int nonZeroParamsOrErrors =
354 for (
const auto &iterIdValue :
inputs[iIOV]->getLorentzAngles()) {
356 const auto detId = iterIdValue.first;
367 auto value = iterIdValue.second +
static_cast<float>(param);
373 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
374 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
382 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" 383 <<
"No PoolDBOutputService available, but saveToDB true!";
401 const double bpCor = backPlaneHandle->getBackPlaneCorrection(
id);
410 const auto &resolvedRun = run > 0 ? run :
currentIOV_;
426 if (!la.getLorentzAngles().empty() &&
429 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 430 <<
"Different input values from tree " << treeName <<
" in file " << iFile <<
".";
439 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 442 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 458 const std::map<unsigned int, TreeStruct> &treeInfo,
459 const char *treeName)
const {
465 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::writeTree" 470 TTree *
tree =
new TTree(treeName, treeName);
474 tree->Branch(
"detId", &
id,
"detId/i");
475 tree->Branch(
"value", &value,
"value/F");
482 id = iterIdValue->first;
483 value = iterIdValue->second;
485 auto treeStructIter = treeInfo.find(
id);
486 if (treeStructIter != treeInfo.end()) {
487 treeStruct = treeStructIter->second;
503 TFile *
file =
nullptr;
504 FILE *testFile = fopen(fileName,
"r");
507 file = TFile::Open(fileName,
"READ");
510 TTree *
tree =
nullptr;
512 file->GetObject(treeName, tree);
518 tree->SetBranchAddress(
"detId", &
id);
519 tree->SetBranchAddress(
"value", &value);
521 const Long64_t nEntries = tree->GetEntries();
522 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
523 tree->GetEntry(iEntry);
524 result.putLorentzAngle(
id, value);
527 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::createFromTree" 528 <<
"Could not get TTree '" << treeName <<
"' from file '" << fileName
529 << (file ?
"'." :
"' (file does not exist).");
const TimeTypeSpecs timeTypeSpecs[]
const std::string recordNameDBwrite_
const edm::ParameterSet moduleGroupSelCfg_
int16_t singleReadOutMode() const
const std::vector< std::string > mergeFileNames_
SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg)
Constructor.
std::vector< double > parameters_
const std::string & name() const
name of this calibration
def setup(process, global_tag, zero_tesla=False)
const Bounds & bounds() const
std::map< align::RunNumber, SiStripLorentzAngle > cachedLorentzAngleInputs_
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_
structure to store algorithm results in a TTree
const std::map< unsigned int, float > & getLorentzAngles() const
unsigned long long Time_t
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
~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
align::RunNumber currentIOV_
DetId geographicalId() const
The label of this GeomDet.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
SiStripLorentzAngle createFromTree(const char *fileName, const char *treeName) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::pair< double, double > Values
double getParameterError(unsigned int index) const override
Detector identifier class for the strip tracker.
double getParameter(unsigned int index) const override
virtual float thickness() const =0
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)
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
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
Constructor of the full muon geometry.
const PositionType & position() const
cond::RealTimeType< cond::runnumber >::type RunNumber