48 #include <boost/assign/list_of.hpp>
77 virtual unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
122 const std::map<unsigned int,TreeStruct> &treeInfo,
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_(0),
156 moduleGroupSelector_(0),
157 moduleGroupSelCfg_(cfg.getParameter<edm::
ParameterSet>(
"BackplaneModuleGroups"))
169 <<
"SiStripBackplaneCalibration:\n" <<
"Unknown mode '"
201 outDerivInds.clear();
205 const int16_t
mode = latency->singleReadOutMode();
224 const double mobility = lorentzAngleHandle->getLorentzAngle(hit.
det()->
geographicalId());
233 const double xDerivative = 0.5 * dZ * (mobility * bFieldLocal.y() + tanPsi);
243 const Values derivs(xDerivative, 0.);
247 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives1"
248 <<
"Hit without GeomDet, skip!";
252 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::derivatives2"
253 <<
"Readout mode is " << mode <<
", but looking for "
257 return outDerivInds.size();
308 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration" <<
"Created with name "
310 <<
"',\n" << this->
numParameters() <<
" parameters to be determined."
317 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration"
328 std::ostringstream
out;
330 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
333 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob" << out.str();
335 std::map<unsigned int, TreeStruct> treeInfo;
339 const std::string treeName(this->
name() +
'_' + readoutModeName_ +
'_');
340 this->
writeTree(input, treeInfo, (treeName +
"input").c_str());
343 edm::LogError(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::endOfJob"
344 <<
"Input back plane correction map is empty ('"
345 << readoutModeName_ <<
"' mode), skip writing output!";
349 const unsigned int nonZeroParamsOrErrors =
352 std::bind2nd(std::not_equal_to<double>(), 0.));
361 const unsigned int detId = iterIdValue->first;
395 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
396 this->
writeTree(output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
406 edm::LogError(
"BadConfig") <<
"@SUB=SiStripBackplaneCalibration::endOfJob"
407 <<
"No PoolDBOutputService available, but saveToDB true!";
429 if (backPlaneCorrHandle->getBackPlaneCorrections()
434 <<
"SiStripBackplaneCalibration::checkBackPlaneCorrectionInput:\n"
435 <<
"Content of SiStripBackPlaneCorrection changed at run " << eventInfo.
eventId_.
run()
436 <<
", but algorithm expects constant input!\n";
465 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
466 <<
"Different input values from tree " << treeName
467 <<
" in file " << *iFile <<
".";
476 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
479 edm::LogError(
"NoInput") <<
"@SUB=SiStripBackplaneCalibration::getBackPlaneCorrectionInput"
497 const std::map<unsigned int, TreeStruct> &treeInfo,
498 const char *treeName)
const
500 if (!backPlaneCorrection)
return;
504 edm::LogError(
"BadConfig") <<
"@SUB=SiStripBackplaneCalibration::writeTree"
509 TTree *
tree =
new TTree(treeName, treeName);
513 tree->Branch(
"detId", &
id,
"detId/i");
514 tree->Branch(
"value", &value,
"value/F");
520 id = iterIdValue->first;
521 value = iterIdValue->second;
523 auto treeStructIter = treeInfo.find(
id);
524 if (treeStructIter != treeInfo.end()) {
525 treeStruct = treeStructIter->second;
545 FILE* testFile = fopen(fileName,
"r");
548 file = TFile::Open(fileName,
"READ");
552 if (file) file->GetObject(treeName, tree);
558 tree->SetBranchAddress(
"detId", &
id);
559 tree->SetBranchAddress(
"value", &value);
562 const Long64_t nEntries = tree->GetEntries();
563 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
564 tree->GetEntry(iEntry);
568 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripBackplaneCalibration::createFromTree"
569 <<
"Could not get TTree '" << treeName <<
"' from file '"
570 << fileName << (file ?
"'." :
"' (file does not exist).");
TkModuleGroupSelector * moduleGroupSelector_
bool putBackPlaneCorrection(const uint32_t &, float)
const std::string outFileName_
virtual ~SiStripBackplaneCalibration()
Destructor.
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).
const std::string & name() const
name of this calibration
const Bounds & bounds() const
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
SiStripBackPlaneCorrection * siStripBackPlaneCorrInput_
void writeTree(const SiStripBackPlaneCorrection *backPlaneCorr, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
const edm::ParameterSet moduleGroupSelCfg_
const Plane & surface() const
The nominal surface of the GeomDet.
static std::string const input
bool checkBackPlaneCorrectionInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
const SiStripBackPlaneCorrection * getBackPlaneCorrectionInput()
virtual unsigned int numParameters() const
How many parameters does this calibration define?
virtual float thickness() const =0
structure to store algorithm results in a TTree
const std::map< unsigned int, float > & getBackPlaneCorrections() const
virtual bool setParameterError(unsigned int index, double error)
SiStripBackPlaneCorrection * createFromTree(const char *fileName, const char *treeName) const
unsigned long long Time_t
const std::vector< std::string > mergeFileNames_
const GeomDet * det() const
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
const std::string recordNameDBwrite_
DetId geographicalId() const
The label of this GeomDet.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
const std::string readoutModeName_
const edm::EventID & eventId_
virtual bool setParameter(unsigned int index, double value)
virtual unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const
virtual void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras)
SiStripBackplaneCalibration(const edm::ParameterSet &cfg)
Constructor.
virtual double getParameter(unsigned int index) const
std::pair< double, double > Values
static const char * LeafList()
AlgebraicVector5 mixedFormatVector() const
virtual double getParameterError(unsigned int index) const
bool check(const edm::EventSetup &iSetup)
std::vector< double > parameters_
unsigned int getNumberOfParameters() const
unsigned int numIovs() const
Total number of IOVs.
#define DEFINE_EDM_PLUGIN(factory, type, name)
Constructor of the full muon geometry.
const PositionType & position() const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
define event information passed to algorithms