75 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
118 const std::map<unsigned int, TreeStruct> &treeInfo,
119 const char *treeName)
const;
150 readoutModeName_(
cfg.getParameter<
std::
string>(
"readoutMode")),
151 saveToDB_(
cfg.getParameter<
bool>(
"saveToDB")),
152 recordNameDBwrite_(
cfg.getParameter<
std::
string>(
"recordNameDBwrite")),
153 outFileName_(
cfg.getParameter<
std::
string>(
"treeFile")),
155 siStripBackPlaneCorrInput_(nullptr),
156 moduleGroupSelector_(nullptr),
170 throw cms::Exception(
"BadConfig") <<
"SiStripBackplaneCalibration:\n" 172 <<
"', should be 'peak' or 'deconvolution' .\n";
196 outDerivInds.clear();
211 const double dZ =
hit.det()->surface().bounds().thickness();
216 const double mobility = lorentzAngleHandle->
getLorentzAngle(
hit.det()->geographicalId());
225 const double xDerivative = 0.5 *
dZ * (mobility * bFieldLocal.y() + tanPsi);
235 const Values derivs(xDerivative, 0.);
239 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives1" 240 <<
"Hit without GeomDet, skip!";
244 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives2" 245 <<
"Readout mode is " <<
mode <<
", but looking for " <<
readoutMode_ <<
" (" 249 return outDerivInds.size();
294 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration" 303 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration" 311 std::ostringstream
out;
313 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
316 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob" <<
out.str();
318 std::map<unsigned int, TreeStruct> treeInfo;
322 const std::string treeName(this->
name() +
'_' + readoutModeName_ +
'_');
323 this->
writeTree(*input, treeInfo, (treeName +
"input").c_str());
325 if (
input->getBackPlaneCorrections().empty()) {
326 edm::LogError(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob" 328 <<
"' mode), skip writing output!";
332 const unsigned int nonZeroParamsOrErrors =
340 for (
auto iterIdValue =
input->getBackPlaneCorrections().begin();
341 iterIdValue !=
input->getBackPlaneCorrections().end();
344 const unsigned int detId = iterIdValue->first;
373 output.putBackPlaneCorrection(
detId, iterIdValue->second + param);
378 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
379 this->
writeTree(
output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
388 edm::LogError(
"BadConfig") <<
"@SUB=SiStripBackplaneCalibration::endOfJob" 389 <<
"No PoolDBOutputService available, but saveToDB true!";
413 throw cms::Exception(
"BadInput") <<
"SiStripBackplaneCalibration::checkBackPlaneCorrectionInput:\n" 414 <<
"Content of SiStripBackPlaneCorrection changed at run " 415 <<
eventInfo.eventId().run() <<
", but algorithm expects constant input!\n";
443 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput" 444 <<
"Different input values from tree " << treeName <<
" in file " << *iFile <<
".";
452 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput" 455 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput" 471 const std::map<unsigned int, TreeStruct> &treeInfo,
472 const char *treeName)
const {
475 edm::LogError(
"BadConfig") <<
"@SUB=SiStripBackplaneCalibration::writeTree" 480 TTree *
tree =
new TTree(treeName, treeName);
484 tree->Branch(
"detId", &
id,
"detId/i");
485 tree->Branch(
"value", &
value,
"value/F");
492 id = iterIdValue->first;
493 value = iterIdValue->second;
495 auto treeStructIter = treeInfo.find(
id);
496 if (treeStructIter != treeInfo.end()) {
497 treeStruct = treeStructIter->second;
511 const char *treeName)
const {
514 TFile *
file =
nullptr;
515 FILE *testFile = fopen(
fileName,
"r");
521 TTree *
tree =
nullptr;
529 tree->SetBranchAddress(
"detId", &
id);
533 const Long64_t nEntries =
tree->GetEntries();
534 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
535 tree->GetEntry(iEntry);
539 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::createFromTree" 540 <<
"Could not get TTree '" << treeName <<
"' from file '" <<
fileName 541 << (
file ?
"'." :
"' (file does not exist).");
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
unsigned int numIovs() const
Total number of IOVs.
TkModuleGroupSelector * moduleGroupSelector_
const std::string outFileName_
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_
std::vector< double > paramUncertainties_
static constexpr auto TID
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
const LocalTrajectoryParameters & localParameters() const
~SiStripBackplaneCalibration() override
Destructor.
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
unsigned int getNumberOfParameters() const
Log< level::Error, false > LogError
const edm::ParameterSet moduleGroupSelCfg_
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
unsigned int numParameters() const override
How many parameters does this calibration define?
define event information passed to algorithms
static std::string const input
bool checkBackPlaneCorrectionInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
const SiStripBackPlaneCorrection * getBackPlaneCorrectionInput()
structure to store algorithm results in a TTree
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > lorentzAngleToken_
unsigned long long Time_t
const std::vector< std::string > mergeFileNames_
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
SiStripBackPlaneCorrection * createFromTree(const char *fileName, const char *treeName) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
edm::ESWatcher< SiStripBackPlaneCorrectionRcd > watchBackPlaneCorrRcd_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const std::string recordNameDBwrite_
bool setParameterError(unsigned int index, double error) override
const std::string readoutModeName_
const edm::ESGetToken< SiStripBackPlaneCorrection, SiStripBackPlaneCorrectionRcd > backPlaneCorrToken_
static constexpr auto TOB
std::pair< double, double > Values
Log< level::Info, false > LogInfo
float getLorentzAngle(const uint32_t &) const
AlgebraicVector5 mixedFormatVector() const
const std::map< unsigned int, float > & getBackPlaneCorrections() const
static const char * LeafList()
double getParameter(unsigned int index) const override
SiStripBackplaneCalibration(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
Constructor.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
void writeTree(const SiStripBackPlaneCorrection &backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
bool check(const edm::EventSetup &iSetup)
static constexpr auto TIB
std::vector< double > parameters_
#define DEFINE_EDM_PLUGIN(factory, type, name)
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning
double getParameterError(unsigned int index) const override
Constructor of the full muon geometry.
bool setParameter(unsigned int index, double value) override
const std::string & name() const
name of this calibration
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
static constexpr auto TEC