46 #include <boost/assign/list_of.hpp>
75 virtual unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
91 virtual double getParameter(
unsigned int index)
const override;
123 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 siStripLorentzAngleInput_(0),
156 moduleGroupSelector_(0),
157 moduleGroupSelCfg_(cfg.getParameter<edm::
ParameterSet>(
"LorentzAngleModuleGroups"))
169 <<
"SiStripLorentzAngleCalibration:\n" <<
"Unknown mode '"
201 outDerivInds.clear();
205 const int16_t
mode = latency->singleReadOutMode();
227 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
229 const Values derivs(xDerivative, 0.);
234 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives1"
235 <<
"Hit without GeomDet, skip!";
239 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::derivatives2"
240 <<
"Readout mode is " << mode <<
", but looking for "
244 return outDerivInds.size();
293 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration" <<
"Created with name "
295 <<
"',\n" << this->
numParameters() <<
" parameters to be determined."
302 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration"
312 std::ostringstream
out;
314 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
317 edm::LogInfo(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob" << out.str();
319 std::map<unsigned int, TreeStruct> treeInfo;
323 const std::string treeName(this->
name() +
'_' + readoutModeName_ +
'_');
324 this->
writeTree(input, treeInfo, (treeName +
"input").c_str());
327 edm::LogError(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob"
328 <<
"Input Lorentz angle map is empty ('"
329 << readoutModeName_ <<
"' mode), skip writing output!";
333 const unsigned int nonZeroParamsOrErrors =
336 std::bind2nd(std::not_equal_to<double>(), 0.));
345 const unsigned int detId = iterIdValue->first;
361 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
362 this->
writeTree(output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
372 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::endOfJob"
373 <<
"No PoolDBOutputService available, but saveToDB true!";
395 if (lorentzAngleHandle->getLorentzAngles()
400 <<
"SiStripLorentzAngleCalibration::checkLorentzAngleInput:\n"
401 <<
"Content of SiStripLorentzAngle changed at run " << eventInfo.
eventId().
run()
402 <<
", but algorithm expects constant input!\n";
423 const double bpCor = backPlaneHandle->getBackPlaneCorrection(
id);
450 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
451 <<
"Different input values from tree " << treeName
452 <<
" in file " << *iFile <<
".";
461 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
464 edm::LogError(
"NoInput") <<
"@SUB=SiStripLorentzAngleCalibration::getLorentzAnglesInput"
482 const std::map<unsigned int, TreeStruct> &treeInfo,
483 const char *treeName)
const
485 if (!lorentzAngle)
return;
489 edm::LogError(
"BadConfig") <<
"@SUB=SiStripLorentzAngleCalibration::writeTree"
494 TTree *
tree =
new TTree(treeName, treeName);
498 tree->Branch(
"detId", &
id,
"detId/i");
499 tree->Branch(
"value", &value,
"value/F");
505 id = iterIdValue->first;
506 value = iterIdValue->second;
508 auto treeStructIter = treeInfo.find(
id);
509 if (treeStructIter != treeInfo.end()) {
510 treeStruct = treeStructIter->second;
529 FILE* testFile = fopen(fileName,
"r");
532 file = TFile::Open(fileName,
"READ");
536 if (file) file->GetObject(treeName, tree);
542 tree->SetBranchAddress(
"detId", &
id);
543 tree->SetBranchAddress(
"value", &value);
546 const Long64_t nEntries = tree->GetEntries();
547 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
548 tree->GetEntry(iEntry);
552 edm::LogWarning(
"Alignment") <<
"@SUB=SiStripLorentzAngleCalibration::createFromTree"
553 <<
"Could not get TTree '" << treeName <<
"' from file '"
554 << fileName << (file ?
"'." :
"' (file does not exist).");
const std::string recordNameDBwrite_
tuple SiStripLorentzAngle
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
const edm::ParameterSet moduleGroupSelCfg_
const std::vector< std::string > mergeFileNames_
SiStripLorentzAngleCalibration(const edm::ParameterSet &cfg)
Constructor.
std::vector< double > parameters_
const std::string & name() const
name of this calibration
const Bounds & bounds() const
virtual double getParameterError(unsigned int index) const override
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
void writeTree(const SiStripLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
virtual bool setParameter(unsigned int index, double value) override
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
define event information passed to algorithms
bool putLorentzAngle(const uint32_t &, float)
edm::ESWatcher< SiStripLorentzAngleRcd > watchLorentzAngleRcd_
static std::string const input
const std::string outFileName_
virtual double getParameter(unsigned int index) const override
virtual float thickness() const =0
virtual void endOfJob() override
structure to store algorithm results in a TTree
const std::map< unsigned int, float > & getLorentzAngles() const
unsigned long long Time_t
const std::string readoutModeName_
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
std::vector< double > paramUncertainties_
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
DetId geographicalId() const
The label of this GeomDet.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
TkModuleGroupSelector * moduleGroupSelector_
virtual ~SiStripLorentzAngleCalibration()
Destructor.
virtual unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
Detector identifier class for the strip tracker.
std::pair< double, double > Values
static const char * LeafList()
double effectiveThickness(const GeomDet *det, int16_t mode, const edm::EventSetup &setup) const
in non-peak mode the effective thickness is reduced...
bool check(const edm::EventSetup &iSetup)
bool checkLorentzAngleInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
unsigned int getNumberOfParameters() const
virtual unsigned int numParameters() const override
How many parameters does this calibration define?
virtual bool setParameterError(unsigned int index, double error) override
unsigned int numIovs() const
Total number of IOVs.
virtual void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
SiStripLorentzAngle * siStripLorentzAngleInput_
Constructor of the full muon geometry.
const SiStripLorentzAngle * getLorentzAnglesInput()
SiStripLorentzAngle * createFromTree(const char *fileName, const char *treeName) const
const PositionType & position() const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")