44 #include <boost/assign/list_of.hpp> 76 unsigned int derivatives(std::vector<ValuesIndexPair> &outDerivInds,
123 const std::map<unsigned int,TreeStruct>& treeInfo,
const char *treeName)
const;
185 outDerivInds.clear();
199 const double xDerivative = bFieldLocal.y() * dZ * -0.5;
202 const Values derivs(xDerivative, 0.);
207 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::derivatives2" 208 <<
"Hit without GeomDet, skip!";
211 return outDerivInds.size();
264 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" <<
"Created with name " 265 << this->
name() <<
"',\n" << this->
numParameters() <<
" parameters to be determined," 272 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration" 282 std::ostringstream
out;
283 out <<
"Parameter results\n";
284 for (
unsigned int iPar = 0; iPar <
parameters_.size(); ++iPar) {
287 edm::LogInfo(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" << out.str();
289 std::map<unsigned int, TreeStruct> treeInfo;
294 this->
writeTree(input, treeInfo, (treeName +
"input").c_str());
297 edm::LogError(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 298 <<
"Input Lorentz angle map is empty, skip writing output!";
302 const unsigned int nonZeroParamsOrErrors =
305 std::bind2nd(std::not_equal_to<double>(), 0.));
315 const unsigned int detId = iterIdValue->first;
319 float value = iterIdValue->second + param;
325 if (
saveToDB_ || nonZeroParamsOrErrors != 0) {
326 this->
writeTree(output, treeInfo, (treeName + Form(
"result_%lld", firstRunOfIOV)).c_str());
336 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::endOfJob" 337 <<
"No PoolDBOutputService available, but saveToDB true!";
362 <<
"SiPixelLorentzAngleCalibration::checkLorentzAngleInput:\n" 363 <<
"Content of SiPixelLorentzAngle changed at run " << eventInfo.
eventId().
run()
364 <<
", but algorithm expects constant input!\n";
393 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 394 <<
"Different input values from tree " << treeName
395 <<
" in file " << *iFile <<
".";
404 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 405 <<
"No input, create an empty one!";
407 edm::LogError(
"NoInput") <<
"@SUB=SiPixelLorentzAngleCalibration::getLorentzAnglesInput" 424 const std::map<unsigned int,TreeStruct> &treeInfo,
425 const char *treeName)
const 427 if (!lorentzAngle)
return;
431 edm::LogError(
"BadConfig") <<
"@SUB=SiPixelLorentzAngleCalibration::writeTree" 436 TTree *
tree =
new TTree(treeName, treeName);
440 tree->Branch(
"detId", &
id,
"detId/i");
441 tree->Branch(
"value", &value,
"value/F");
447 id = iterIdValue->first;
448 value = iterIdValue->second;
450 auto treeStructIter = treeInfo.find(
id);
451 if (treeStructIter != treeInfo.end()) {
452 treeStruct = treeStructIter->second;
471 TFile*
file =
nullptr;
472 FILE* testFile = fopen(fileName,
"r");
475 file = TFile::Open(fileName,
"READ");
478 TTree *
tree =
nullptr;
479 if (file) file->GetObject(treeName, tree);
485 tree->SetBranchAddress(
"detId", &
id);
486 tree->SetBranchAddress(
"value", &value);
489 const Long64_t nEntries = tree->GetEntries();
490 for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) {
491 tree->GetEntry(iEntry);
495 edm::LogWarning(
"Alignment") <<
"@SUB=SiPixelLorentzAngleCalibration::createFromTree" 496 <<
"Could not get TTree '" << treeName <<
"' from file '" 497 << fileName << (file ?
"'." :
"' (file does not exist).");
const std::map< unsigned int, float > & getLorentzAngles() const
bool setParameterError(unsigned int index, double error) override
unsigned int numParameters() const override
How many parameters does this calibration define?
SiPixelLorentzAngle * siPixelLorentzAngleInput_
const std::string recordNameDBwrite_
std::vector< double > parameters_
edm::RunNumber_t firstRunOfIOV(unsigned int iovNum) const
First run of iov (0 if iovNum not treated).
TkModuleGroupSelector * moduleGroupSelector_
bool setParameter(unsigned int index, double value) override
const std::string outFileName_
~SiPixelLorentzAngleCalibration() override
Destructor.
const std::string & name() const
name of this calibration
def setup(process, global_tag, zero_tesla=False)
const Bounds & bounds() const
bool checkLorentzAngleInput(const edm::EventSetup &setup, const EventInfo &eventInfo)
int getParameterIndexFromDetId(unsigned int detId, edm::RunNumber_t run) const
const edm::EventID eventId() const
const Plane & surface() const
The nominal surface of the GeomDet.
unsigned int derivatives(std::vector< ValuesIndexPair > &outDerivInds, const TransientTrackingRecHit &hit, const TrajectoryStateOnSurface &tsos, const edm::EventSetup &setup, const EventInfo &eventInfo) const override
define event information passed to algorithms
static std::string const input
void writeTree(const SiPixelLorentzAngle *lorentzAngle, const std::map< unsigned int, TreeStruct > &treeInfo, const char *treeName) const
structure to store algorithm results in a TTree
edm::ESWatcher< SiPixelLorentzAngleRcd > watchLorentzAngleRcd_
unsigned long long Time_t
SiPixelLorentzAngleCalibration(const edm::ParameterSet &cfg)
Constructor.
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
std::pair< Values, unsigned int > ValuesIndexPair
x- and y-values
void beginOfJob(AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras) override
DetId geographicalId() const
The label of this GeomDet.
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
bool putLorentzAngle(const uint32_t &, float &)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const SiPixelLorentzAngle * getLorentzAnglesInput()
double getParameterError(unsigned int index) const override
double getParameterForDetId(unsigned int detId, edm::RunNumber_t run) const
const edm::ParameterSet moduleGroupSelCfg_
virtual float thickness() const =0
std::pair< double, double > Values
SiPixelLorentzAngle * createFromTree(const char *fileName, const char *treeName) const
static const char * LeafList()
bool check(const edm::EventSetup &iSetup)
std::vector< double > paramUncertainties_
unsigned int getNumberOfParameters() const
unsigned int numIovs() const
Total number of IOVs.
const std::vector< std::string > mergeFileNames_
#define DEFINE_EDM_PLUGIN(factory, type, name)
eventInfo
add run, event number and lumi section
double getParameter(unsigned int index) const override
Constructor of the full muon geometry.
const PositionType & position() const