CMS 3D CMS Logo

SurveyDataConverter.cc
Go to the documentation of this file.
1 
2 // Framework
6 
11 
13 
16 
17 //__________________________________________________________________________________________________
18 SurveyDataConverter::SurveyDataConverter(const edm::ParameterSet& iConfig) : theParameterSet(iConfig) {}
19 
20 //__________________________________________________________________________________________________
22  //Retrieve tracker topology from geometry
24  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
25  const TrackerTopology* const tTopo = tTopoHandle.product();
26 
27  edm::LogInfo("SurveyDataConverter") << "Analyzer called";
28  applyfineinfo = theParameterSet.getParameter<bool>("applyFineInfo");
29  applycoarseinfo = theParameterSet.getParameter<bool>("applyCoarseInfo");
30  adderrors = theParameterSet.getParameter<bool>("applyErrors");
31 
32  // Read in the information from the text files
34 
35  std::string textFileNames[NFILES];
36  std::string fileType[NFILES];
37  textFileNames[0] = textFiles.getUntrackedParameter<std::string>("forTIB", "NONE");
38  fileType[0] = "TIB";
39  textFileNames[1] = textFiles.getUntrackedParameter<std::string>("forTID", "NONE");
40  fileType[1] = "TID";
41 
42  SurveyDataReader dataReader;
43  for (int ii = 0; ii < NFILES; ii++) {
44  if (textFileNames[ii] == "NONE")
45  throw cms::Exception("BadConfig") << fileType[ii] << " input file not found in configuration";
46  dataReader.readFile(textFileNames[ii], fileType[ii], tTopo);
47  }
48 
49  // Get info and map
50  const MapType& mapIdToInfo = dataReader.detIdMap();
51  std::cout << "DATA HAS BEEN READ INTO THE MAP" << std::endl;
52  std::cout << "DATA HAS BEEN CONVERTED IN ALIGNABLE COORDINATES" << std::endl;
53 
54  TrackerAlignment tr_align(iSetup);
55  if (applycoarseinfo)
56  this->applyCoarseSurveyInfo(tr_align);
57  if (applyfineinfo)
58  this->applyFineSurveyInfo(tr_align, mapIdToInfo);
59  if (adderrors)
60  this->applyAPEs(tr_align);
61  tr_align.saveToDB();
62 }
63 
64 //___________________________________
65 //
67  std::cout << "Apply fine info: " << std::endl;
68 
69  for (MapType::const_iterator it = map.begin(); it != map.end(); it++) {
70  const align::Scalars& align_params = (it)->second;
71 
72  align::Scalars translations;
73  translations.push_back(align_params[0]);
74  translations.push_back(align_params[1]);
75  translations.push_back(align_params[2]);
76 
77  align::RotationType bRotation(align_params[6],
78  align_params[9],
79  align_params[3],
80  align_params[7],
81  align_params[10],
82  align_params[4],
83  align_params[8],
84  align_params[11],
85  align_params[5]);
86 
87  align::RotationType fRotation(align_params[15],
88  align_params[18],
89  align_params[12],
90  align_params[16],
91  align_params[19],
92  align_params[13],
93  align_params[17],
94  align_params[20],
95  align_params[14]);
96 
97  // Use "false" for debugging only
98  tr_align.moveAlignableTIBTIDs((it)->first, translations, bRotation, fRotation, true);
99  }
100 }
101 
102 //___________________________________
103 //
105  std::cout << "Apply coarse info: " << std::endl;
107 
108  TrackerScenarioBuilder scenarioBuilder(tr_align.getAlignableTracker());
109  scenarioBuilder.applyScenario(MisalignScenario);
110 }
111 
112 //___________________________________
113 //
115  std::cout << "Apply APEs: " << std::endl;
116  // Neglect sensor-on-module mounting precision (10 um)
117  // Irrelevant given other sizes ..
118  std::vector<double> TIBerrors = theParameterSet.getParameter<std::vector<double> >("TIBerrors");
119  std::vector<double> TOBerrors = theParameterSet.getParameter<std::vector<double> >("TOBerrors");
120  std::vector<double> TIDerrors = theParameterSet.getParameter<std::vector<double> >("TIDerrors");
121  std::vector<double> TECerrors = theParameterSet.getParameter<std::vector<double> >("TECerrors");
122 
123  if (TIBerrors.size() < 3 || TOBerrors.size() < 4 || TIDerrors.size() < 4 || TECerrors.size() < 4) {
124  std::cout << "APE info not valid : please check test/run-converter.cfg" << std::endl;
125  return;
126  }
127 
128  AlignableModifier theModifier{};
129  AlignableTracker* theAlignableTracker = tr_align.getAlignableTracker();
130  align::Alignables::const_iterator iter;
131 
132  // TIB
133  const align::Alignables& theTIBhb = theAlignableTracker->innerHalfBarrels();
134  for (iter = theTIBhb.begin(); iter != theTIBhb.end(); ++iter) {
135  theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(0), TIBerrors.at(0), TIBerrors.at(0));
136  }
137  const align::Alignables& theTIBlayers = theAlignableTracker->innerBarrelLayers();
138  for (iter = theTIBlayers.begin(); iter != theTIBlayers.end(); ++iter) {
139  theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(1), TIBerrors.at(1), TIBerrors.at(1));
140  }
141  const align::Alignables& theTIBgd = theAlignableTracker->innerBarrelGeomDets();
142  for (iter = theTIBgd.begin(); iter != theTIBgd.end(); ++iter) {
143  theModifier.addAlignmentPositionErrorLocal(*iter, TIBerrors.at(2), TIBerrors.at(2), TIBerrors.at(2));
144  }
145 
146  // TOB
147  const align::Alignables& theTOBhb = theAlignableTracker->outerHalfBarrels();
148  for (iter = theTOBhb.begin(); iter != theTOBhb.end(); ++iter) {
149  theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(0), TOBerrors.at(0), TOBerrors.at(1));
150  }
151  const align::Alignables& theTOBrods = theAlignableTracker->outerBarrelRods();
152  for (iter = theTOBrods.begin(); iter != theTOBrods.end(); ++iter) {
153  theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(2), TOBerrors.at(2), TOBerrors.at(2));
154  }
155  const align::Alignables& theTOBgd = theAlignableTracker->outerBarrelGeomDets();
156  for (iter = theTOBgd.begin(); iter != theTOBgd.end(); ++iter) {
157  theModifier.addAlignmentPositionErrorLocal(*iter, TOBerrors.at(3), TOBerrors.at(3), TOBerrors.at(3));
158  }
159 
160  // TID
161  const align::Alignables& theTIDs = theAlignableTracker->TIDs();
162  for (iter = theTIDs.begin(); iter != theTIDs.end(); ++iter) {
163  theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(0), TIDerrors.at(0), TIDerrors.at(0));
164  }
165  const align::Alignables& theTIDdiscs = theAlignableTracker->TIDLayers();
166  for (iter = theTIDdiscs.begin(); iter != theTIDdiscs.end(); ++iter) {
167  theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(1), TIDerrors.at(1), TIDerrors.at(1));
168  }
169  const align::Alignables& theTIDrings = theAlignableTracker->TIDRings();
170  for (iter = theTIDrings.begin(); iter != theTIDrings.end(); ++iter) {
171  theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(2), TIDerrors.at(2), TIDerrors.at(2));
172  }
173  const align::Alignables& theTIDgd = theAlignableTracker->TIDGeomDets();
174  for (iter = theTIDgd.begin(); iter != theTIDgd.end(); ++iter) {
175  theModifier.addAlignmentPositionErrorLocal(*iter, TIDerrors.at(3), TIDerrors.at(3), TIDerrors.at(3));
176  }
177 
178  // TEC
179  const align::Alignables& theTECs = theAlignableTracker->endCaps();
180  for (iter = theTECs.begin(); iter != theTECs.end(); ++iter) {
181  theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(0), TECerrors.at(0), TECerrors.at(0));
182  }
183  const align::Alignables& theTECdiscs = theAlignableTracker->endcapLayers();
184  for (iter = theTECdiscs.begin(); iter != theTECdiscs.end(); ++iter) {
185  theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(1), TECerrors.at(1), TECerrors.at(1));
186  }
187  const align::Alignables& theTECpetals = theAlignableTracker->endcapPetals();
188  for (iter = theTECpetals.begin(); iter != theTECpetals.end(); ++iter) {
189  theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(2), TECerrors.at(2), TECerrors.at(2));
190  }
191  const align::Alignables& theTECgd = theAlignableTracker->endcapGeomDets();
192  for (iter = theTECgd.begin(); iter != theTECgd.end(); ++iter) {
193  theModifier.addAlignmentPositionErrorLocal(*iter, TECerrors.at(3), TECerrors.at(3), TECerrors.at(3));
194  }
195 }
196 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TkRotation< Scalar >
AlignableTracker::outerBarrelGeomDets
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
Definition: AlignableTracker.h:57
SurveyDataReader
Definition: SurveyDataReader.h:15
AlignableTracker::TIDLayers
Alignables & TIDLayers()
Return TID layers.
Definition: AlignableTracker.h:93
SurveyDataConverter::applycoarseinfo
bool applycoarseinfo
Definition: SurveyDataConverter.h:55
SurveyDataConverter::theParameterSet
edm::ParameterSet theParameterSet
Definition: SurveyDataConverter.h:50
AlignableModifier
Definition: AlignableModifier.h:23
MessageLogger.h
align::Scalars
std::vector< Scalar > Scalars
Definition: Utilities.h:26
ESHandle.h
TrackerScenarioBuilder
Builds a scenario from configuration and applies it to the alignable tracker.
Definition: TrackerScenarioBuilder.h:24
SurveyDataConverter::applyFineSurveyInfo
void applyFineSurveyInfo(TrackerAlignment &tr_align, const MapType &map)
Definition: SurveyDataConverter.cc:66
SurveyDataConverter::SurveyDataConverter
SurveyDataConverter(const edm::ParameterSet &iConfig)
Definition: SurveyDataConverter.cc:18
TrackerTopology
Definition: TrackerTopology.h:16
AlignableTracker::innerHalfBarrels
Alignables & innerHalfBarrels()
Return TIB half barrels.
Definition: AlignableTracker.h:36
gather_cfg.cout
cout
Definition: gather_cfg.py:144
AlignableTracker::innerBarrelGeomDets
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
Definition: AlignableTracker.h:55
TrackerAlignment::saveToDB
void saveToDB()
Definition: TrackerAlignment.cc:241
TrackerAlignment::getAlignableTracker
AlignableTracker * getAlignableTracker()
Definition: TrackerAlignment.h:21
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
AlignableTracker::endCaps
Alignables & endCaps()
Return TECs.
Definition: AlignableTracker.h:40
SurveyDataConverter::analyze
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: SurveyDataConverter.cc:21
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignableTracker::outerBarrelRods
Alignables & outerBarrelRods()
Return outer barrel rods.
Definition: AlignableTracker.h:72
AlignableTracker::endcapGeomDets
Alignables & endcapGeomDets()
Return endcap GeomDets.
Definition: AlignableTracker.h:61
SurveyDataConverter::adderrors
bool adderrors
Definition: SurveyDataConverter.h:55
SurveyDataConverter::applyfineinfo
bool applyfineinfo
Definition: SurveyDataConverter.h:55
MakerMacros.h
TrackerTopology.h
AlignableModifier.h
TrackerScenarioBuilder.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignableTracker::innerBarrelLayers
Alignables & innerBarrelLayers()
Return inner barrel layers.
Definition: AlignableTracker.h:85
TrackerScenarioBuilder::applyScenario
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the tracker.
Definition: TrackerScenarioBuilder.cc:39
edm::ESHandle< TrackerTopology >
AlignableTracker
Definition: AlignableTracker.h:17
AlignableTracker::TIDRings
Alignables & TIDRings()
Return TID rings.
Definition: AlignableTracker.h:78
SurveyDataConverter
Definition: SurveyDataConverter.h:26
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SurveyDataReader::readFile
void readFile(const std::string &textFileName, const std::string &fileType, const TrackerTopology *tTopo)
Read given text file.
Definition: SurveyDataReader.cc:17
TrackerAlignment
Definition: TrackerAlignment.h:15
SurveyDataConverter::applyAPEs
void applyAPEs(TrackerAlignment &tr_align)
Definition: SurveyDataConverter.cc:114
edm::ParameterSet
Definition: ParameterSet.h:47
SurveyDataConverter::MisalignScenario
edm::ParameterSet MisalignScenario
Definition: SurveyDataConverter.h:51
AlignableTracker::endcapLayers
Alignables & endcapLayers()
Return endcap layers.
Definition: AlignableTracker.h:91
SurveyDataConverter::MapType
SurveyDataReader::MapType MapType
Definition: SurveyDataConverter.h:27
iEvent
int iEvent
Definition: GenABIO.cc:224
AlignableTracker::endcapPetals
Alignables & endcapPetals()
Return encap petals.
Definition: AlignableTracker.h:76
AlignableTracker::outerHalfBarrels
Alignables & outerHalfBarrels()
Return TOB half barrels.
Definition: AlignableTracker.h:34
TrackerAlignment.h
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
SurveyDataConverter::applyCoarseSurveyInfo
void applyCoarseSurveyInfo(TrackerAlignment &tr_align)
Definition: SurveyDataConverter.cc:104
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
TrackerAlignment::moveAlignableTIBTIDs
void moveAlignableTIBTIDs(int rawId, const align::Scalars &globalDisplacements, const align::RotationType &backwardRotation, const align::RotationType &forwardRotation, bool toAndFro)
Definition: TrackerAlignment.cc:210
SurveyDataConverter.h
Exception
Definition: hltDiff.cc:245
SurveyDataConverter::NFILES
static const int NFILES
Definition: SurveyDataConverter.h:39
Alignable.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignableTracker::TIDGeomDets
Alignables & TIDGeomDets()
Return TID GeomDets.
Definition: AlignableTracker.h:63
genParticles_cff.map
map
Definition: genParticles_cff.py:11
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
SurveyDataReader::detIdMap
const MapType & detIdMap() const
Definition: SurveyDataReader.h:27
edm::Event
Definition: Event.h:73
cuy.ii
ii
Definition: cuy.py:590
AlignableTracker::TIDs
Alignables & TIDs()
Return TIDs.
Definition: AlignableTracker.h:44