67 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
110 const std::map<unsigned int, TreeStruct> &treeInfo,
111 const char *treeName)
const;
174 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
180 <<
") in an IOV (" <<
firstRun <<
") that was already cached.\n" 181 <<
"The following record in your input database tag has an IOV " 182 <<
"boundary that does not match your IOV definition:\n" 183 <<
" - SiPixelLorentzAngleRcd '" << lorentzAngleRcd.key().name() <<
"' (since " 184 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
198 outDerivInds.clear();
213 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
214 const double yDerivative = bFieldLocal.x() * dZ * 0.5;
215 if (xDerivative || yDerivative) {
216 const Values derivs{xDerivative, yDerivative};
221 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::derivatives2" 222 <<
"Hit without GeomDet, skip!";
225 return outDerivInds.size();
270 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 271 <<
"Created with name " << this->
name() <<
"',\n" 278 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 286 std::ostringstream
out;
287 out <<
"Parameter results\n";
288 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
291 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" << out.str();
293 std::map<unsigned int, TreeStruct> treeInfo;
297 std::vector<const SiPixelLorentzAngle *>
inputs{};
304 (treeName +
"input_" + std::to_string(firstRunOfIOV)).c_str());
306 if (
inputs.back()->getLorentzAngles().empty()) {
307 edm::LogError(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 308 <<
"Input Lorentz angle map is empty, skip writing output!";
313 const unsigned int nonZeroParamsOrErrors =
321 for (
const auto &iterIdValue :
inputs[iIOV]->getLorentzAngles()) {
323 const auto detId = iterIdValue.first;
327 auto value = iterIdValue.second +
static_cast<float>(param);
333 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
334 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
342 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 343 <<
"No PoolDBOutputService available, but saveToDB true!";
351 const auto &resolvedRun = run > 0 ? run :
currentIOV_;
356 const std::string treeName{this->
name() +
"_input_" + std::to_string(resolvedRun)};
367 if (!la.getLorentzAngles().empty() &&
370 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 371 <<
"Different input values from tree " << treeName <<
" in file " << iFile <<
".";
380 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 381 <<
"No input, create an empty one!";
383 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 398 const std::map<unsigned int, TreeStruct> &treeInfo,
399 const char *treeName)
const {
405 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::writeTree" 410 TTree *
tree =
new TTree(treeName, treeName);
414 tree->Branch(
"detId", &
id,
"detId/i");
415 tree->Branch(
"value", &value,
"value/F");
422 id = iterIdValue->first;
423 value = iterIdValue->second;
425 auto treeStructIter = treeInfo.find(
id);
426 if (treeStructIter != treeInfo.end()) {
427 treeStruct = treeStructIter->second;
443 TFile *
file =
nullptr;
444 FILE *testFile = fopen(fileName,
"r");
447 file = TFile::Open(fileName,
"READ");
450 TTree *
tree =
nullptr;
452 file->GetObject(treeName, tree);
458 tree->SetBranchAddress(
"detId", &
id);
459 tree->SetBranchAddress(
"value", &value);
461 const Long64_t nEntries = tree->GetEntries();
462 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
463 tree->GetEntry(iEntry);
464 result.putLorentzAngle(
id, value);
467 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::createFromTree" 468 <<
"Could not get TTree '" << treeName <<
"' from file '" << fileName
469 << (file ?
"'." :
"' (file does not exist).");
const TimeTypeSpecs timeTypeSpecs[]
const std::map< unsigned int, float > & getLorentzAngles() const
bool setParameterError(unsigned int index, double error) override
unsigned int numParameters() const override
How many parameters does this calibration define?
SiPixelLorentzAngle * siPixelLorentzAngleInput_
const std::string recordNameDBwrite_
std::vector< double > parameters_
bool setParameter(unsigned int index, double value) override
const std::string outFileName_
const std::string & name() const
name of this calibration
def setup(process, global_tag, zero_tesla=False)
void beginRun(const edm::Run &, const edm::EventSetup &) override
Call at beginning of run:
const Bounds & bounds() const
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
SiPixelLorentzAngle createFromTree(const char *fileName, const char *treeName) const
define event information passed to algorithms
void writeTree(const SiPixelLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
structure to store algorithm results in a TTree
edm::ESWatcher< SiPixelLorentzAngleRcd > watchLorentzAngleRcd_
std::map< align::RunNumber, SiPixelLorentzAngle > cachedLorentzAngleInputs_
unsigned long long Time_t
SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg)
Constructor.
const std::string lorentzAngleLabel_
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
Call at beginning of job:
const SiPixelLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
DetId geographicalId() const
The label of this GeomDet.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
align::RunNumber currentIOV_
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
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
const edm::ParameterSet moduleGroupSelCfg_
virtual float thickness() const =0
~SiPixelLorentzAngleCalibration() override=default
Destructor.
static const char * LeafList()
bool check(const edm::EventSetup &iSetup)
std::vector< double > paramUncertainties_
const std::vector< std::string > mergeFileNames_
#define DEFINE_EDM_PLUGIN(factory, type, name)
eventInfo
add run, event number and lumi section
double getParameter(unsigned int index) const override
Constructor of the full muon geometry.
const PositionType & position() const
cond::RealTimeType< cond::runnumber >::type RunNumber