File indexing completed on 2023-03-17 10:40:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
0016 #include "Alignment/CommonAlignment/interface/StructureType.h"
0017 #include "Alignment/CommonAlignment/interface/SurveyDet.h"
0018 #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h"
0019 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
0020 #include "FWCore/Framework/interface/ESHandle.h"
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0024 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0025 #include "TRandom3.h"
0026
0027 #include <map>
0028
0029 class SurveyInputDummy : public SurveyInputBase {
0030 public:
0031 SurveyInputDummy(const edm::ParameterSet&);
0032
0033
0034 virtual void analyze(const edm::Event&, const edm::EventSetup&);
0035
0036 private:
0037
0038 void addSurveyInfo(Alignable*);
0039
0040 const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0041 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkGeomToken_;
0042 const bool theRandomizeValue;
0043
0044 std::map<align::StructureType, double> theErrors;
0045 };
0046
0047 SurveyInputDummy::SurveyInputDummy(const edm::ParameterSet& cfg)
0048 : tTopoToken_(esConsumes()),
0049 tkGeomToken_(esConsumes()),
0050 theRandomizeValue(cfg.getParameter<bool>("randomizeValue")) {
0051 typedef std::vector<edm::ParameterSet> ParameterSets;
0052
0053 const ParameterSets& errors = cfg.getParameter<ParameterSets>("errors");
0054
0055 unsigned int nError = errors.size();
0056
0057
0058
0059 AlignableObjectId alignableObjectId{AlignableObjectId::Geometry::General};
0060
0061 for (unsigned int i = 0; i < nError; ++i) {
0062 const edm::ParameterSet& error = errors[i];
0063
0064 theErrors[alignableObjectId.stringToId(error.getParameter<std::string>("level"))] =
0065 error.getParameter<double>("value");
0066 }
0067 }
0068
0069 void SurveyInputDummy::analyze(const edm::Event&, const edm::EventSetup& setup) {
0070 if (theFirstEvent) {
0071
0072 const TrackerTopology* const tTopo = &setup.getData(tTopoToken_);
0073 const TrackerGeometry* tracker = &setup.getData(tkGeomToken_);
0074
0075 Alignable* ali = new AlignableTracker(tracker, tTopo);
0076
0077 addSurveyInfo(ali);
0078 addComponent(ali);
0079
0080 theFirstEvent = false;
0081 }
0082 }
0083
0084 void SurveyInputDummy::addSurveyInfo(Alignable* ali) {
0085 static TRandom3 rand;
0086
0087 const align::Alignables& comp = ali->components();
0088
0089 unsigned int nComp = comp.size();
0090
0091 for (unsigned int i = 0; i < nComp; ++i)
0092 addSurveyInfo(comp[i]);
0093
0094 align::ErrorMatrix cov;
0095
0096 std::map<align::StructureType, double>::const_iterator e = theErrors.find(ali->alignableObjectId());
0097
0098 if (theErrors.end() != e) {
0099 double error = e->second;
0100
0101 if (theRandomizeValue) {
0102 double x = rand.Gaus(0., error);
0103 double y = rand.Gaus(0., error);
0104 double z = rand.Gaus(0., error);
0105 double a = rand.Gaus(0., error);
0106 double b = rand.Gaus(0., error);
0107 double g = rand.Gaus(0., error);
0108
0109 align::EulerAngles angles(3);
0110
0111 angles(1) = a;
0112 angles(2) = b;
0113 angles(3) = g;
0114
0115 ali->move(ali->surface().toGlobal(align::LocalVector(x, y, z)));
0116 ali->rotateInLocalFrame(align::toMatrix(angles));
0117 }
0118
0119 cov = ROOT::Math::SMatrixIdentity();
0120 cov *= error * error;
0121 }
0122
0123 ali->setSurvey(new SurveyDet(ali->surface(), cov));
0124 }
0125
0126 #include "FWCore/Framework/interface/MakerMacros.h"
0127 DEFINE_FWK_MODULE(SurveyInputDummy);