|
|
Go to the documentation of this file.
75 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
118 const std::map<unsigned int, TreeStruct> &treeInfo,
119 const char *treeName)
const;
146 readoutModeName_(
cfg.getParameter<
std::
string>(
"readoutMode")),
147 saveToDB_(
cfg.getParameter<
bool>(
"saveToDB")),
148 recordNameDBwrite_(
cfg.getParameter<
std::
string>(
"recordNameDBwrite")),
149 outFileName_(
cfg.getParameter<
std::
string>(
"treeFile")),
151 siStripBackPlaneCorrInput_(nullptr),
152 moduleGroupSelector_(nullptr),
162 throw cms::Exception(
"BadConfig") <<
"SiStripBackplaneCalibration:\n"
164 <<
"', should be 'peak' or 'deconvolution' .\n";
186 const_cast<SiStripBackplaneCalibration *>(
this)->checkBackPlaneCorrectionInput(
setup,
eventInfo);
188 outDerivInds.clear();
205 const double dZ =
hit.det()->surface().bounds().thickness();
211 const double mobility = lorentzAngleHandle->
getLorentzAngle(
hit.det()->geographicalId());
220 const double xDerivative = 0.5 * dZ * (mobility * bFieldLocal.y() + tanPsi);
230 const Values derivs(xDerivative, 0.);
234 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives1"
235 <<
"Hit without GeomDet, skip!";
239 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives2"
240 <<
"Readout mode is " <<
mode <<
", but looking for " <<
readoutMode_ <<
" ("
244 return outDerivInds.size();
289 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration"
298 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration"
306 std::ostringstream
out;
308 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
311 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob" <<
out.str();
313 std::map<unsigned int, TreeStruct> treeInfo;
317 const std::string treeName(this->
name() +
'_' + readoutModeName_ +
'_');
318 this->
writeTree(input, treeInfo, (treeName +
"input").c_str());
320 if (
input->getBackPlaneCorrections().empty()) {
321 edm::LogError(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob"
323 <<
"' mode), skip writing output!";
327 const unsigned int nonZeroParamsOrErrors =
335 for (
auto iterIdValue =
input->getBackPlaneCorrections().begin();
336 iterIdValue !=
input->getBackPlaneCorrections().end();
339 const unsigned int detId = iterIdValue->first;
368 output->putBackPlaneCorrection(detId, iterIdValue->second + param);
373 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
374 this->
writeTree(output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
384 edm::LogError(
"BadConfig") <<
"@SUB=SiStripBackplaneCalibration::endOfJob"
385 <<
"No PoolDBOutputService available, but saveToDB true!";
410 throw cms::Exception(
"BadInput") <<
"SiStripBackplaneCalibration::checkBackPlaneCorrectionInput:\n"
411 <<
"Content of SiStripBackPlaneCorrection changed at run "
412 <<
eventInfo.eventId().run() <<
", but algorithm expects constant input!\n";
440 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
441 <<
"Different input values from tree " << treeName <<
" in file " << *iFile <<
".";
449 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
452 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
468 const std::map<unsigned int, TreeStruct> &treeInfo,
469 const char *treeName)
const {
470 if (!backPlaneCorrection)
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).");
bool check(const edm::EventSetup &iSetup)
const edm::ParameterSet moduleGroupSelCfg_
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
static const std::string input
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
const std::string & name() const
name of this calibration
void writeTree(const SiStripBackPlaneCorrection *backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
const SiStripBackPlaneCorrection * getBackPlaneCorrectionInput()
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
double getParameter(unsigned int index) const override
const std::string readoutModeName_
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
TkModuleGroupSelector * moduleGroupSelector_
structure to store algorithm results in a TTree
Log< level::Info, false > LogInfo
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
Log< level::Warning, false > LogWarning
unsigned int numIovs() const
Total number of IOVs.
const std::map< unsigned int, float > & getBackPlaneCorrections() const
bool checkBackPlaneCorrectionInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
std::pair< double, double > Values
~SiStripBackplaneCalibration() override
Destructor.
std::vector< double > parameters_
double getParameterError(unsigned int index) const override
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
static constexpr auto TEC
const std::string recordNameDBwrite_
const LocalTrajectoryParameters & localParameters() const
const std::string outFileName_
unsigned long long Time_t
Constructor of the full muon geometry.
static constexpr auto TOB
AlgebraicVector5 mixedFormatVector() const
static const char * LeafList()
Log< level::Error, false > LogError
SiStripBackplaneCalibration(const edm::ParameterSet &cfg)
Constructor.
static constexpr auto TID
float getLorentzAngle(const uint32_t &) const
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
std::vector< double > paramUncertainties_
edm::ESWatcher< SiStripBackPlaneCorrectionRcd > watchBackPlaneCorrRcd_
static constexpr auto TIB
unsigned int numParameters() const override
How many parameters does this calibration define?
const std::vector< std::string > mergeFileNames_
bool setParameterError(unsigned int index, double error) override
bool setParameter(unsigned int index, double value) override
unsigned int getNumberOfParameters() const
define event information passed to algorithms
SiStripBackPlaneCorrection * createFromTree(const char *fileName, const char *treeName) const