67 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
114 const std::map<unsigned int,TreeStruct> &treeInfo,
const char *treeName)
const;
160 <<
"SiStripLorentzAngleCalibration:\n" <<
"Unknown mode '" 199 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
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()
211 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
227 outDerivInds.clear();
253 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
254 const double yDerivative = bFieldLocal.x() * dZ * 0.5;
255 if (xDerivative || yDerivative) {
256 const Values derivs{xDerivative, yDerivative};
261 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives1" 262 <<
"Hit without GeomDet, skip!";
266 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives2" 267 <<
"Readout mode is " << mode <<
", but looking for " 271 return outDerivInds.size();
322 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" <<
"Created with name " 324 <<
"',\n" << this->
numParameters() <<
" parameters to be determined." 331 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" 341 std::ostringstream
out;
343 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
346 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" << out.str();
348 std::map<unsigned int, TreeStruct> treeInfo;
351 const std::string treeName{this->
name() +
'_' + readoutModeName_ +
'_'};
352 std::vector<const SiStripLorentzAngle*>
inputs{};
358 (treeName +
"input_" + std::to_string(firstRunOfIOV)).c_str());
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!";
368 const unsigned int nonZeroParamsOrErrors =
371 [](
auto c){
return c!=0.;});
377 for (
const auto& iterIdValue:
inputs[iIOV]->getLorentzAngles()) {
379 const auto detId = iterIdValue.first;
390 auto value = iterIdValue.second +
static_cast<float>(param);
396 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
397 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
405 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" 406 <<
"No PoolDBOutputService available, but saveToDB true!";
424 const double bpCor = backPlaneHandle->getBackPlaneCorrection(
id);
435 const auto& resolvedRun = run > 0 ? run :
currentIOV_;
441 std::to_string(resolvedRun)};
452 if (!la.getLorentzAngles().empty() &&
455 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 456 <<
"Different input values from tree " << treeName
457 <<
" in file " << iFile <<
".";
467 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 470 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput" 488 const std::map<unsigned int, TreeStruct> &treeInfo,
489 const char *treeName)
const 491 if (!lorentzAngle)
return;
495 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::writeTree" 500 TTree *
tree =
new TTree(treeName, treeName);
504 tree->Branch(
"detId", &
id,
"detId/i");
505 tree->Branch(
"value", &value,
"value/F");
511 id = iterIdValue->first;
512 value = iterIdValue->second;
514 auto treeStructIter = treeInfo.find(
id);
515 if (treeStructIter != treeInfo.end()) {
516 treeStruct = treeStructIter->second;
534 TFile*
file =
nullptr;
535 FILE* testFile = fopen(fileName,
"r");
538 file = TFile::Open(fileName,
"READ");
541 TTree *
tree =
nullptr;
542 if (file) file->GetObject(treeName, tree);
548 tree->SetBranchAddress(
"detId", &
id);
549 tree->SetBranchAddress(
"value", &value);
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);
557 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::createFromTree" 558 <<
"Could not get TTree '" << treeName <<
"' from file '" 559 << fileName << (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
~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
void get(HolderT &iHolder) const
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.
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::pair< double, double > Values
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