68 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
113 const std::map<unsigned int,TreeStruct>& treeInfo,
114 const char *treeName)
const;
185 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
191 <<
"Trying to cache SiPixelLorentzAngle payload for a run (" <<
runNumber 192 <<
") in an IOV (" <<
firstRun <<
") that was already cached.\n" 193 <<
"The following record in your input database tag has an IOV " 194 <<
"boundary that does not match your IOV definition:\n" 195 <<
" - SiPixelLorentzAngleRcd '" << lorentzAngleRcd.key().name()
197 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
213 outDerivInds.clear();
228 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
229 const double yDerivative = bFieldLocal.x() * dZ * 0.5;
230 if (xDerivative || yDerivative) {
231 const Values derivs{xDerivative, yDerivative};
236 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::derivatives2" 237 <<
"Hit without GeomDet, skip!";
240 return outDerivInds.size();
294 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" <<
"Created with name " 295 << this->
name() <<
"',\n" << this->
numParameters() <<
" parameters to be determined," 302 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 312 std::ostringstream
out;
313 out <<
"Parameter results\n";
314 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
317 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" << out.str();
319 std::map<unsigned int, TreeStruct> treeInfo;
323 std::vector<const SiPixelLorentzAngle*>
inputs{};
329 (treeName +
"input_" + std::to_string(firstRunOfIOV)).c_str());
331 if (
inputs.back()->getLorentzAngles().empty()) {
332 edm::LogError(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 333 <<
"Input Lorentz angle map is empty, skip writing output!";
338 const unsigned int nonZeroParamsOrErrors =
341 std::bind2nd(std::not_equal_to<double>(), 0.));
347 for (
const auto& iterIdValue:
inputs[iIOV]->getLorentzAngles()) {
349 const auto detId = iterIdValue.first;
353 auto value = iterIdValue.second +
static_cast<float>(param);
359 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
360 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
368 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 369 <<
"No PoolDBOutputService available, but saveToDB true!";
380 const auto& resolvedRun = run > 0 ? run :
currentIOV_;
385 const std::string treeName{this->
name()+
"_input_"+std::to_string(resolvedRun)};
396 if (!la.getLorentzAngles().empty() &&
399 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 400 <<
"Different input values from tree " << treeName
401 <<
" in file " << iFile <<
".";
411 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 412 <<
"No input, create an empty one!";
414 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 431 const std::map<unsigned int,TreeStruct> &treeInfo,
432 const char *treeName)
const 434 if (!lorentzAngle)
return;
438 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::writeTree" 443 TTree *
tree =
new TTree(treeName, treeName);
447 tree->Branch(
"detId", &
id,
"detId/i");
448 tree->Branch(
"value", &value,
"value/F");
454 id = iterIdValue->first;
455 value = iterIdValue->second;
457 auto treeStructIter = treeInfo.find(
id);
458 if (treeStructIter != treeInfo.end()) {
459 treeStruct = treeStructIter->second;
478 TFile*
file =
nullptr;
479 FILE* testFile = fopen(fileName,
"r");
482 file = TFile::Open(fileName,
"READ");
485 TTree *
tree =
nullptr;
486 if (file) file->GetObject(treeName, tree);
492 tree->SetBranchAddress(
"detId", &
id);
493 tree->SetBranchAddress(
"value", &value);
495 const Long64_t nEntries = tree->GetEntries();
496 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
497 tree->GetEntry(iEntry);
498 result.putLorentzAngle(
id, value);
501 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::createFromTree" 502 <<
"Could not get TTree '" << treeName <<
"' from file '" 503 << fileName << (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.
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 get(HolderT &iHolder) const
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.
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
std::pair< double, double > Values
~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