Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-06 09:39:44

0001 
0002 // Framework
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 #include "Alignment/CommonAlignment/interface/AlignableModifier.h"
0009 #include "Alignment/TrackerAlignment/interface/TrackerAlignment.h"
0010 #include "Alignment/TrackerAlignment/interface/TrackerScenarioBuilder.h"
0011 #include "Alignment/CommonAlignment/interface/Alignable.h"
0012 
0013 #include "Alignment/SurveyAnalysis/plugins/SurveyDataConverter.h"
0014 
0015 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0016 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0017 
0018 //__________________________________________________________________________________________________
0019 SurveyDataConverter::SurveyDataConverter(const edm::ParameterSet& iConfig)
0020     : topoToken(esConsumes()), ttrackerGeometryToken(esConsumes()), theParameterSet(iConfig) {}
0021 //__________________________________________________________________________________________________
0022 void SurveyDataConverter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0023   //Retrieve tracker topology from geometry
0024   const TrackerTopology* const tTopo = &iSetup.getData(topoToken);
0025   const TrackerGeometry* const tGeom = &iSetup.getData(ttrackerGeometryToken);
0026 
0027   edm::LogInfo("SurveyDataConverter") << "Analyzer called";
0028   applyfineinfo = theParameterSet.getParameter<bool>("applyFineInfo");
0029   applycoarseinfo = theParameterSet.getParameter<bool>("applyCoarseInfo");
0030   adderrors = theParameterSet.getParameter<bool>("applyErrors");
0031 
0032   // Read in the information from the text files
0033   edm::ParameterSet textFiles = theParameterSet.getParameter<edm::ParameterSet>("textFileNames");
0034 
0035   std::string textFileNames[NFILES];
0036   std::string fileType[NFILES];
0037   textFileNames[0] = textFiles.getUntrackedParameter<std::string>("forTIB", "NONE");
0038   fileType[0] = "TIB";
0039   textFileNames[1] = textFiles.getUntrackedParameter<std::string>("forTID", "NONE");
0040   fileType[1] = "TID";
0041 
0042   SurveyDataReader dataReader;
0043   for (int ii = 0; ii < NFILES; ii++) {
0044     if (textFileNames[ii] == "NONE")
0045       throw cms::Exception("BadConfig") << fileType[ii] << " input file not found in configuration";
0046     dataReader.readFile(textFileNames[ii], fileType[ii], tTopo);
0047   }
0048 
0049   // Get info and map
0050   const MapType& mapIdToInfo = dataReader.detIdMap();
0051   std::cout << "DATA HAS BEEN READ INTO THE MAP" << std::endl;
0052   std::cout << "DATA HAS BEEN CONVERTED IN ALIGNABLE COORDINATES" << std::endl;
0053   TrackerAlignment tr_align(tTopo, tGeom);
0054 
0055   if (applycoarseinfo)
0056     this->applyCoarseSurveyInfo(tr_align);
0057   if (applyfineinfo)
0058     this->applyFineSurveyInfo(tr_align, mapIdToInfo);
0059   if (adderrors)
0060     this->applyAPEs(tr_align);
0061   tr_align.saveToDB();
0062 }
0063 
0064 //___________________________________
0065 //
0066 void SurveyDataConverter::applyFineSurveyInfo(TrackerAlignment& tr_align, const MapType& map) {
0067   std::cout << "Apply fine info: " << std::endl;
0068 
0069   for (MapType::const_iterator it = map.begin(); it != map.end(); it++) {
0070     const align::Scalars& align_params = (it)->second;
0071 
0072     align::Scalars translations;
0073     translations.push_back(align_params[0]);
0074     translations.push_back(align_params[1]);
0075     translations.push_back(align_params[2]);
0076 
0077     align::RotationType bRotation(align_params[6],
0078                                   align_params[9],
0079                                   align_params[3],
0080                                   align_params[7],
0081                                   align_params[10],
0082                                   align_params[4],
0083                                   align_params[8],
0084                                   align_params[11],
0085                                   align_params[5]);
0086 
0087     align::RotationType fRotation(align_params[15],
0088                                   align_params[18],
0089                                   align_params[12],
0090                                   align_params[16],
0091                                   align_params[19],
0092                                   align_params[13],
0093                                   align_params[17],
0094                                   align_params[20],
0095                                   align_params[14]);
0096 
0097     // Use "false" for debugging only
0098     tr_align.moveAlignableTIBTIDs((it)->first, translations, bRotation, fRotation, true);
0099   }
0100 }
0101 
0102 //___________________________________
0103 //
0104 void SurveyDataConverter::applyCoarseSurveyInfo(TrackerAlignment& tr_align) {
0105   std::cout << "Apply coarse info: " << std::endl;
0106   MisalignScenario = theParameterSet.getParameter<edm::ParameterSet>("MisalignmentScenario");
0107 
0108   TrackerScenarioBuilder scenarioBuilder(tr_align.getAlignableTracker());
0109   scenarioBuilder.applyScenario(MisalignScenario);
0110 }
0111 
0112 //___________________________________
0113 //
0114 void SurveyDataConverter::applyAPEs(TrackerAlignment& tr_align) {
0115   std::cout << "Apply APEs: " << std::endl;
0116   // Neglect sensor-on-module mounting precision (10 um)
0117   // Irrelevant given other sizes ..
0118   std::vector<double> TIBerrors = theParameterSet.getParameter<std::vector<double> >("TIBerrors");
0119   std::vector<double> TOBerrors = theParameterSet.getParameter<std::vector<double> >("TOBerrors");
0120   std::vector<double> TIDerrors = theParameterSet.getParameter<std::vector<double> >("TIDerrors");
0121   std::vector<double> TECerrors = theParameterSet.getParameter<std::vector<double> >("TECerrors");
0122 
0123   if (TIBerrors.size() < 3 || TOBerrors.size() < 4 || TIDerrors.size() < 4 || TECerrors.size() < 4) {
0124     std::cout << "APE info not valid : please check test/run-converter.cfg" << std::endl;
0125     return;
0126   }
0127 
0128   AlignableModifier theModifier{};
0129   AlignableTracker* theAlignableTracker = tr_align.getAlignableTracker();
0130   align::Alignables::const_iterator iter;
0131 
0132   // TIB
0133   const align::Alignables& theTIBhb = theAlignableTracker->innerHalfBarrels();
0134   for (iter = theTIBhb.begin(); iter != theTIBhb.end(); ++iter) {
0135     theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(0), TIBerrors.at(0), TIBerrors.at(0));
0136   }
0137   const align::Alignables& theTIBlayers = theAlignableTracker->innerBarrelLayers();
0138   for (iter = theTIBlayers.begin(); iter != theTIBlayers.end(); ++iter) {
0139     theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(1), TIBerrors.at(1), TIBerrors.at(1));
0140   }
0141   const align::Alignables& theTIBgd = theAlignableTracker->innerBarrelGeomDets();
0142   for (iter = theTIBgd.begin(); iter != theTIBgd.end(); ++iter) {
0143     theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(2), TIBerrors.at(2), TIBerrors.at(2));
0144   }
0145 
0146   // TOB
0147   const align::Alignables& theTOBhb = theAlignableTracker->outerHalfBarrels();
0148   for (iter = theTOBhb.begin(); iter != theTOBhb.end(); ++iter) {
0149     theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(0), TOBerrors.at(0), TOBerrors.at(1));
0150   }
0151   const align::Alignables& theTOBrods = theAlignableTracker->outerBarrelRods();
0152   for (iter = theTOBrods.begin(); iter != theTOBrods.end(); ++iter) {
0153     theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(2), TOBerrors.at(2), TOBerrors.at(2));
0154   }
0155   const align::Alignables& theTOBgd = theAlignableTracker->outerBarrelGeomDets();
0156   for (iter = theTOBgd.begin(); iter != theTOBgd.end(); ++iter) {
0157     theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(3), TOBerrors.at(3), TOBerrors.at(3));
0158   }
0159 
0160   // TID
0161   const align::Alignables& theTIDs = theAlignableTracker->TIDs();
0162   for (iter = theTIDs.begin(); iter != theTIDs.end(); ++iter) {
0163     theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(0), TIDerrors.at(0), TIDerrors.at(0));
0164   }
0165   const align::Alignables& theTIDdiscs = theAlignableTracker->TIDLayers();
0166   for (iter = theTIDdiscs.begin(); iter != theTIDdiscs.end(); ++iter) {
0167     theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(1), TIDerrors.at(1), TIDerrors.at(1));
0168   }
0169   const align::Alignables& theTIDrings = theAlignableTracker->TIDRings();
0170   for (iter = theTIDrings.begin(); iter != theTIDrings.end(); ++iter) {
0171     theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(2), TIDerrors.at(2), TIDerrors.at(2));
0172   }
0173   const align::Alignables& theTIDgd = theAlignableTracker->TIDGeomDets();
0174   for (iter = theTIDgd.begin(); iter != theTIDgd.end(); ++iter) {
0175     theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(3), TIDerrors.at(3), TIDerrors.at(3));
0176   }
0177 
0178   // TEC
0179   const align::Alignables& theTECs = theAlignableTracker->endCaps();
0180   for (iter = theTECs.begin(); iter != theTECs.end(); ++iter) {
0181     theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(0), TECerrors.at(0), TECerrors.at(0));
0182   }
0183   const align::Alignables& theTECdiscs = theAlignableTracker->endcapLayers();
0184   for (iter = theTECdiscs.begin(); iter != theTECdiscs.end(); ++iter) {
0185     theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(1), TECerrors.at(1), TECerrors.at(1));
0186   }
0187   const align::Alignables& theTECpetals = theAlignableTracker->endcapPetals();
0188   for (iter = theTECpetals.begin(); iter != theTECpetals.end(); ++iter) {
0189     theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(2), TECerrors.at(2), TECerrors.at(2));
0190   }
0191   const align::Alignables& theTECgd = theAlignableTracker->endcapGeomDets();
0192   for (iter = theTECgd.begin(); iter != theTECgd.end(); ++iter) {
0193     theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(3), TECerrors.at(3), TECerrors.at(3));
0194   }
0195 }
0196 
0197 DEFINE_FWK_MODULE(SurveyDataConverter);