75 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
79 const EventInfo &eventInfo)
const override;
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")),
154 mergeFileNames_(cfg.getParameter<std::
vector<std::
string> >(
"mergeTreeFiles")),
155 siStripBackPlaneCorrInput_(nullptr),
156 moduleGroupSelector_(nullptr),
157 moduleGroupSelCfg_(cfg.getParameter<edm::
ParameterSet>(
"BackplaneModuleGroups")),
170 throw cms::Exception(
"BadConfig") <<
"SiStripBackplaneCalibration:\n"
172 <<
"', should be 'peak' or 'deconvolution' .\n";
196 outDerivInds.clear();
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());
326 edm::LogError(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob"
327 <<
"Input back plane correction map is empty ('" << readoutModeName_
328 <<
"' mode), skip writing output!";
332 const unsigned int nonZeroParamsOrErrors =
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");
518 file = TFile::Open(fileName,
"READ");
521 TTree *
tree =
nullptr;
523 file->GetObject(treeName, tree);
529 tree->SetBranchAddress(
"detId", &
id);
530 tree->SetBranchAddress(
"value", &value);
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).");
TkModuleGroupSelector * moduleGroupSelector_
bool putBackPlaneCorrection(const uint32_t &, float)
const edm::EventSetup & c
const std::string outFileName_
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_
const LocalTrajectoryParameters & localParameters() const
std::vector< double > paramUncertainties_
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
static constexpr auto TID
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
int16_t singleReadOutMode() const
const std::map< unsigned int, float > & getBackPlaneCorrections() const
const std::string & name() const
name of this calibration
const Bounds & bounds() const
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
~SiStripBackplaneCalibration() override
Destructor.
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
Log< level::Error, false > LogError
const edm::ParameterSet moduleGroupSelCfg_
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
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()
virtual float thickness() const =0
bool getData(T &iHolder) const
structure to store algorithm results in a TTree
SiStripBackPlaneCorrection * createFromTree(const char *fileName, const char *treeName) const
float getLorentzAngle(const uint32_t &) const
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > lorentzAngleToken_
unsigned long long Time_t
const std::vector< std::string > mergeFileNames_
const GeomDet * det() const
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
LocalPoint toLocal(const GlobalPoint &gp) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
edm::ESWatcher< SiStripBackPlaneCorrectionRcd > watchBackPlaneCorrRcd_
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const std::string recordNameDBwrite_
DetId geographicalId() const
The label of this GeomDet.
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
void writeTree(const SiStripBackPlaneCorrection &backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
Log< level::Info, false > LogInfo
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_
AlgebraicVector5 mixedFormatVector() const
bool check(const edm::EventSetup &iSetup)
static constexpr auto TIB
std::vector< double > parameters_
unsigned int getNumberOfParameters() const
unsigned int numIovs() const
Total number of IOVs.
#define DEFINE_EDM_PLUGIN(factory, type, name)
Log< level::Warning, false > LogWarning
double getParameterError(unsigned int index) const override
Constructor of the full muon geometry.
const PositionType & position() const
bool setParameter(unsigned int index, double value) override
static constexpr auto TEC