File indexing completed on 2024-04-06 11:57:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "Alignment/CommonAlignment/interface/Alignable.h"
0011 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
0012 #include "Alignment/SurveyAnalysis/interface/SurveyAlignmentPoints.h"
0013 #include "Alignment/SurveyAnalysis/interface/SurveyAlignmentSensor.h"
0014 #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "Alignment/CommonAlignment/interface/StructureType.h"
0017 #include "Alignment/CommonAlignment/interface/Utilities.h"
0018 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0019
0020 class SurveyTest : public edm::one::EDAnalyzer<> {
0021 public:
0022 SurveyTest(const edm::ParameterSet&);
0023
0024 virtual void beginJob();
0025
0026 virtual void analyze(const edm::Event&, const edm::EventSetup&) {}
0027
0028 private:
0029 void getTerminals(align::Alignables& terminals, Alignable* ali);
0030
0031 bool theBiasFlag;
0032
0033 unsigned int theIterations;
0034
0035 std::string theAlgorithm;
0036 std::string theOutputFile;
0037
0038 std::vector<align::StructureType> theHierarchy;
0039 };
0040
0041 SurveyTest::SurveyTest(const edm::ParameterSet& cfg)
0042 : theBiasFlag(cfg.getUntrackedParameter<bool>("bias", false)),
0043 theIterations(cfg.getParameter<unsigned int>("iterator")),
0044 theAlgorithm(cfg.getParameter<std::string>("algorith")),
0045 theOutputFile(cfg.getParameter<std::string>("fileName")) {
0046 typedef std::vector<std::string> Strings;
0047
0048 const Strings& hierarchy = cfg.getParameter<Strings>("hierarch");
0049
0050
0051
0052 AlignableObjectId alignableObjectId{AlignableObjectId::Geometry::General};
0053
0054 for (unsigned int l = 0; l < hierarchy.size(); ++l) {
0055 theHierarchy.push_back(alignableObjectId.stringToId(hierarchy[l]));
0056 }
0057 }
0058
0059 void SurveyTest::beginJob() {
0060 Alignable* det = SurveyInputBase::detector();
0061
0062 align::Alignables sensors;
0063
0064 getTerminals(sensors, det);
0065
0066 std::map<std::string, SurveyAlignment*> algos;
0067
0068 algos["points"] = new SurveyAlignmentPoints(sensors, theHierarchy);
0069 algos["sensor"] = new SurveyAlignmentSensor(sensors, theHierarchy);
0070
0071 algos[theAlgorithm]->iterate(theIterations, theOutputFile, theBiasFlag);
0072
0073 for (std::map<std::string, SurveyAlignment*>::iterator i = algos.begin(); i != algos.end(); ++i)
0074 delete i->second;
0075 }
0076
0077 void SurveyTest::getTerminals(align::Alignables& terminals, Alignable* ali) {
0078 const auto& comp = ali->components();
0079
0080 unsigned int nComp = comp.size();
0081
0082 if (nComp > 0)
0083 for (unsigned int i = 0; i < nComp; ++i) {
0084 getTerminals(terminals, comp[i]);
0085 }
0086 else
0087 terminals.push_back(ali);
0088 }
0089
0090 #include "FWCore/Framework/interface/MakerMacros.h"
0091 DEFINE_FWK_MODULE(SurveyTest);