67 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
110 const std::map<unsigned int, TreeStruct> &treeInfo,
111 const char *treeName)
const;
140 saveToDB_(
cfg.getParameter<
bool>(
"saveToDB")),
141 recordNameDBwrite_(
cfg.getParameter<
std::
string>(
"recordNameDBwrite")),
142 outFileName_(
cfg.getParameter<
std::
string>(
"treeFile")),
144 lorentzAngleLabel_(
cfg.getParameter<
std::
string>(
"lorentzAngleLabel")),
147 moduleGroupSelCfg_(
cfg.getParameter<
edm::
ParameterSet>(
"LorentzAngleModuleGroups")) {}
177 if (lorentzAngleRcd.validityInterval().first().eventID().run() >
firstRun &&
183 <<
") in an IOV (" <<
firstRun <<
") that was already cached.\n" 184 <<
"The following record in your input database tag has an IOV " 185 <<
"boundary that does not match your IOV definition:\n" 186 <<
" - SiPixelLorentzAngleRcd '" << lorentzAngleRcd.key().name() <<
"' (since " 187 << lorentzAngleRcd.validityInterval().first().eventID().run() <<
")\n";
201 outDerivInds.clear();
212 const double dZ =
hit.det()->surface().bounds().thickness();
216 const double xDerivative = bFieldLocal.
y() *
dZ * -0.5;
217 const double yDerivative = bFieldLocal.x() *
dZ * 0.5;
218 if (xDerivative || yDerivative) {
219 const Values derivs{xDerivative, yDerivative};
224 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::derivatives2" 225 <<
"Hit without GeomDet, skip!";
228 return outDerivInds.size();
273 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 274 <<
"Created with name " << this->
name() <<
"',\n" 281 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 289 std::ostringstream
out;
290 out <<
"Parameter results\n";
291 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
294 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" <<
out.str();
296 std::map<unsigned int, TreeStruct> treeInfo;
300 std::vector<const SiPixelLorentzAngle *>
inputs{};
309 if (
inputs.back()->getLorentzAngles().empty()) {
310 edm::LogError(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 311 <<
"Input Lorentz angle map is empty, skip writing output!";
316 const unsigned int nonZeroParamsOrErrors =
324 for (
const auto &iterIdValue :
inputs[iIOV]->getLorentzAngles()) {
326 const auto detId = iterIdValue.first;
330 auto value = iterIdValue.second +
static_cast<float>(param);
336 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
337 this->
writeTree(&
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
345 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 346 <<
"No PoolDBOutputService available, but saveToDB true!";
370 if (!la.getLorentzAngles().empty() &&
373 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 374 <<
"Different input values from tree " << treeName <<
" in file " << iFile <<
".";
383 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 384 <<
"No input, create an empty one!";
386 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 401 const std::map<unsigned int, TreeStruct> &treeInfo,
402 const char *treeName)
const {
408 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::writeTree" 413 TTree *
tree =
new TTree(treeName, treeName);
417 tree->Branch(
"detId", &
id,
"detId/i");
418 tree->Branch(
"value", &
value,
"value/F");
425 id = iterIdValue->first;
426 value = iterIdValue->second;
428 auto treeStructIter = treeInfo.find(
id);
429 if (treeStructIter != treeInfo.end()) {
430 treeStruct = treeStructIter->second;
446 TFile *
file =
nullptr;
447 FILE *testFile = fopen(
fileName,
"r");
453 TTree *
tree =
nullptr;
461 tree->SetBranchAddress(
"detId", &
id);
464 const Long64_t nEntries =
tree->GetEntries();
465 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
466 tree->GetEntry(iEntry);
470 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::createFromTree" 471 <<
"Could not get TTree '" << treeName <<
"' from file '" <<
fileName 472 << (
file ?
"'." :
"' (file does not exist).");
const TimeTypeSpecs timeTypeSpecs[]
bool setParameterError(unsigned int index, double error) override
SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
Constructor.
SiPixelLorentzAngle * siPixelLorentzAngleInput_
const std::string recordNameDBwrite_
std::vector< double > parameters_
bool setParameter(unsigned int index, double value) override
const std::string outFileName_
unsigned int numParameters() const override
How many parameters does this calibration define?
SiPixelLorentzAngle createFromTree(const char *fileName, const char *treeName) const
void beginRun(const edm::Run &, const edm::EventSetup &) override
Call at beginning of run:
const std::map< unsigned int, float > & getLorentzAngles() const
double getParameter(unsigned int index) const override
Log< level::Error, false > LogError
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
std::unique_ptr< TkModuleGroupSelector > moduleGroupSelector_
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
static std::string to_string(const XMLCh *ch)
define event information passed to algorithms
structure to store algorithm results in a TTree
edm::ESWatcher< SiPixelLorentzAngleRcd > watchLorentzAngleRcd_
std::map< align::RunNumber, SiPixelLorentzAngle > cachedLorentzAngleInputs_
unsigned long long Time_t
const std::string lorentzAngleLabel_
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
double getParameterError(unsigned int index) const override
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
Call at beginning of job:
const SiPixelLorentzAngle * getLorentzAnglesInput(const align::RunNumber &=0)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
align::RunNumber currentIOV_
std::pair< double, double > Values
Log< level::Info, false > LogInfo
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
const edm::ParameterSet moduleGroupSelCfg_
~SiPixelLorentzAngleCalibration() override=default
Destructor.
static const char * LeafList()
bool check(const edm::EventSetup &iSetup)
const edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcd > lorentzAngleToken_
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
Log< level::Warning, false > LogWarning
Constructor of the full muon geometry.
const std::string & name() const
name of this calibration
void writeTree(const SiPixelLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
cond::RealTimeType< cond::runnumber >::type RunNumber