CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCGeometryParsFromDD Class Reference

#include <CSCGeometryParsFromDD.h>

Public Member Functions

bool build (const DDCompactView *cview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig, CSCRecoDigiParameters &rdp)
 Build the geometry returning the RecoIdealGeometry and the CSCRecoDigiParameters objects. More...
 
 CSCGeometryParsFromDD ()
 Constructor. More...
 
virtual ~CSCGeometryParsFromDD ()
 Destructor. More...
 

Private Attributes

std::string myName
 

Detailed Description

Build the CSCGeometry from the DDD description.

Author
Tim Cox

Definition at line 20 of file CSCGeometryParsFromDD.h.

Constructor & Destructor Documentation

CSCGeometryParsFromDD::CSCGeometryParsFromDD ( )

Constructor.

Definition at line 20 of file CSCGeometryParsFromDD.cc.

20 : myName("CSCGeometryParsFromDD") {}
CSCGeometryParsFromDD::~CSCGeometryParsFromDD ( )
virtual

Destructor.

Definition at line 22 of file CSCGeometryParsFromDD.cc.

22 {}

Member Function Documentation

bool CSCGeometryParsFromDD::build ( const DDCompactView cview,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig,
CSCRecoDigiParameters rdp 
)

Build the geometry returning the RecoIdealGeometry and the CSCRecoDigiParameters objects.

crap: using a constructed wg to deconstruct it and put it in db... alternative? use temporary (not wg!) storage.

format as inserted is best documented by the actualy emplace_back statements below.

fupar size now becomes origSize+6+wg.wiresInEachGroup.size()+wg.consecutiveGroups.size()

end crap

Definition at line 24 of file CSCGeometryParsFromDD.cc.

References CSCWireGroupPackage::alignmentPinToFirstWire, CSCNumberingScheme::baseNumberToUnitNumber(), CSCDetId::chamber(), CSCWireGroupPackage::consecutiveGroups, filterCSVwithJSON::copy, ddsubtraction, TauDecayModes::dec, CSCDetId::endcap(), ALCARECOTkAlBeamHalo_cff::filter, dqmdumpme::first, DDFilteredView::firstChild(), dqmMemoryStats::float, DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), mps_fire::i, RecoIdealGeometry::insert(), createfilelist::int, CSCDetId::layer(), CSCWireGroupPackage::lengthOfWirePlane, LogDebug, DDFilteredView::logicalPart(), LogTrace, myName, CSCWireGroupPackage::narrowWidthOfWirePlane, DDFilteredView::next(), CSCWireGroupPackage::numberOfGroups, DDSolid::parameters(), CSCRecoDigiParameters::pChamberType, CSCRecoDigiParameters::pfupars, CSCRecoDigiParameters::pUserParOffset, CSCRecoDigiParameters::pUserParSize, CSCDetId::ring(), DDFilteredView::rotation(), edm::second(), DDSolid::shape(), DDLogicalPart::solid(), DDBooleanSolid::solidA(), DDFilteredView::specifics(), CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), DDFilteredView::translation(), CSCChamberSpecs::whatChamberType(), CSCWireGroupPackage::wideWidthOfWirePlane, CSCWireGroupPackage::wiresInEachGroup, and CSCWireGroupPackage::wireSpacing.

Referenced by CSCRecoIdealDBLoader::beginRun(), and CSCGeometryBuilderFromDDD::build().

27  {
28  std::string attribute = "MuStructure"; // could come from outside
29  std::string value = "MuonEndcapCSC"; // could come from outside
30 
31  // Asking for a specific section of the MuStructure
32 
33  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
34 
35  DDFilteredView fv(*cview, filter);
36 
37  bool doSubDets = fv.firstChild();
38 
39  if (!doSubDets) {
40  edm::LogError("CSCGeometryParsFromDD")
41  << "Can not proceed, no CSC parts found with the filter. The current node is: " << fv.logicalPart().toString();
42  return false;
43  }
44  int noOfAnonParams = 0;
45  std::vector<const DDsvalues_type*> spec = fv.specifics();
46  std::vector<const DDsvalues_type*>::const_iterator spit = spec.begin();
47  std::vector<double> uparvals;
48  std::vector<double> fpar;
49  std::vector<double> dpar;
50  std::vector<double> gtran(3);
51  std::vector<double> grmat(9);
52  std::vector<double> trm(9);
53  while (doSubDets) {
54  spec = fv.specifics();
55  spit = spec.begin();
56 
57  // get numbering information early for possible speed up of code.
58 
59  LogTrace(myName) << myName << ": create numbering scheme...";
60 
61  MuonDDDNumbering mdn(muonConstants);
62  MuonBaseNumber mbn = mdn.geoHistoryToBaseNumber(fv.geoHistory());
63  CSCNumberingScheme mens(muonConstants);
64 
65  LogTrace(myName) << myName << ": find detid...";
66 
67  int id = mens.baseNumberToUnitNumber(mbn); //@@ FIXME perhaps should return CSCDetId itself?
68 
69  LogTrace(myName) << myName << ": raw id for this detector is " << id << ", octal " << std::oct << id << ", hex "
70  << std::hex << id << std::dec;
71 
72  CSCDetId detid = CSCDetId(id);
73  int jendcap = detid.endcap();
74  int jstation = detid.station();
75  int jring = detid.ring();
76  int jchamber = detid.chamber();
77  int jlayer = detid.layer();
78 
79  // Package up the wire group info as it's decoded
81  uparvals.clear();
82  LogDebug(myName) << "size of spec=" << spec.size();
83 
84  // if the specs are made no need to get all this crap!
85  int chamberType = CSCChamberSpecs::whatChamberType(jstation, jring);
86  LogDebug(myName) << "Chamber Type: " << chamberType;
87  size_t ct = 0;
88  bool chSpecsAlreadyExist = false;
89  for (; ct < rdp.pChamberType.size(); ++ct) {
90  if (chamberType == rdp.pChamberType[ct]) {
91  break;
92  }
93  }
94  if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chamberType) {
95  // it was found, therefore no need to load all the intermediate crap from DD.
96  LogDebug(myName) << "already found a " << chamberType << " at index " << ct;
97  chSpecsAlreadyExist = true;
98  } else {
99  for (; spit != spec.end(); spit++) {
100  DDsvalues_type::const_iterator it = (**spit).begin();
101  for (; it != (**spit).end(); it++) {
102  LogDebug(myName) << "it->second.name()=" << it->second.name();
103  if (it->second.name() == "upar") {
104  uparvals.emplace_back(it->second.doubles().size());
105  for (double i : it->second.doubles()) {
106  uparvals.emplace_back(i);
107  }
108  LogDebug(myName) << "found upars ";
109  } else if (it->second.name() == "NoOfAnonParams") {
110  noOfAnonParams = static_cast<int>(it->second.doubles()[0]);
111  } else if (it->second.name() == "NumWiresPerGrp") {
112  //numWiresInGroup = it->second.doubles();
113  for (double i : it->second.doubles()) {
114  wg.wiresInEachGroup.emplace_back(int(i));
115  }
116  LogDebug(myName) << "found upars " << std::endl;
117  } else if (it->second.name() == "NumGroups") {
118  //numGroups = it->second.doubles();
119  for (double i : it->second.doubles()) {
120  wg.consecutiveGroups.emplace_back(int(i));
121  }
122  } else if (it->second.name() == "WireSpacing") {
123  wg.wireSpacing = it->second.doubles()[0];
124  } else if (it->second.name() == "AlignmentPinToFirstWire") {
125  wg.alignmentPinToFirstWire = it->second.doubles()[0];
126  } else if (it->second.name() == "TotNumWireGroups") {
127  wg.numberOfGroups = int(it->second.doubles()[0]);
128  } else if (it->second.name() == "LengthOfFirstWire") {
129  wg.narrowWidthOfWirePlane = it->second.doubles()[0];
130  } else if (it->second.name() == "LengthOfLastWire") {
131  wg.wideWidthOfWirePlane = it->second.doubles()[0];
132  } else if (it->second.name() == "RadialExtentOfWirePlane") {
133  wg.lengthOfWirePlane = it->second.doubles()[0];
134  }
135  }
136  }
137 
145  uparvals.emplace_back(wg.wireSpacing);
146  uparvals.emplace_back(wg.alignmentPinToFirstWire);
147  uparvals.emplace_back(wg.numberOfGroups);
148  uparvals.emplace_back(wg.narrowWidthOfWirePlane);
149  uparvals.emplace_back(wg.wideWidthOfWirePlane);
150  uparvals.emplace_back(wg.lengthOfWirePlane);
151  uparvals.emplace_back(wg.wiresInEachGroup.size());
152  for (CSCWireGroupPackage::Container::const_iterator it = wg.wiresInEachGroup.begin();
153  it != wg.wiresInEachGroup.end();
154  ++it) {
155  uparvals.emplace_back(*it);
156  }
157  for (CSCWireGroupPackage::Container::const_iterator it = wg.consecutiveGroups.begin();
158  it != wg.consecutiveGroups.end();
159  ++it) {
160  uparvals.emplace_back(*it);
161  }
163  }
164  fpar.clear();
165  // dpar = fv.logicalPart().solid().parameters();
166  if (fv.logicalPart().solid().shape() == DDSolidShape::ddsubtraction) {
167  const DDSubtraction& first = fv.logicalPart().solid();
168  const DDSubtraction& second = first.solidA();
169  const DDSolid& third = second.solidA();
170  dpar = third.parameters();
171  } else {
172  dpar = fv.logicalPart().solid().parameters();
173  }
174 
175  LogTrace(myName) << myName << ": noOfAnonParams=" << noOfAnonParams;
176  LogTrace(myName) << myName << ": fill fpar...";
177  LogTrace(myName) << myName << ": dpars are... " << dpar[4] / cm << ", " << dpar[8] / cm << ", " << dpar[3] / cm
178  << ", " << dpar[0] / cm;
179 
180  fpar.emplace_back((dpar[4] / cm));
181  fpar.emplace_back((dpar[8] / cm));
182  fpar.emplace_back((dpar[3] / cm));
183  fpar.emplace_back((dpar[0] / cm));
184 
185  LogTrace(myName) << myName << ": fill gtran...";
186 
187  gtran[0] = (float)1.0 * (fv.translation().X() / cm);
188  gtran[1] = (float)1.0 * (fv.translation().Y() / cm);
189  gtran[2] = (float)1.0 * (fv.translation().Z() / cm);
190 
191  LogTrace(myName) << myName << ": gtran[0]=" << gtran[0] << ", gtran[1]=" << gtran[1] << ", gtran[2]=" << gtran[2];
192 
193  LogTrace(myName) << myName << ": fill grmat...";
194 
195  fv.rotation().GetComponents(trm.begin(), trm.end());
196  size_t rotindex = 0;
197  for (size_t i = 0; i < 9; ++i) {
198  grmat[i] = (float)1.0 * trm[rotindex];
199  rotindex = rotindex + 3;
200  if ((i + 1) % 3 == 0) {
201  rotindex = (i + 1) / 3;
202  }
203  }
204  LogTrace(myName) << myName << ": looking for wire group info for layer "
205  << "E" << CSCDetId::endcap(id) << " S" << CSCDetId::station(id) << " R" << CSCDetId::ring(id)
206  << " C" << CSCDetId::chamber(id) << " L" << CSCDetId::layer(id);
207 
208  if (wg.numberOfGroups != 0) {
209  LogTrace(myName) << myName << ": fv.geoHistory: = " << fv.geoHistory();
210  LogTrace(myName) << myName << ": TotNumWireGroups = " << wg.numberOfGroups;
211  LogTrace(myName) << myName << ": WireSpacing = " << wg.wireSpacing;
212  LogTrace(myName) << myName << ": AlignmentPinToFirstWire = " << wg.alignmentPinToFirstWire;
213  LogTrace(myName) << myName << ": Narrow width of wire plane = " << wg.narrowWidthOfWirePlane;
214  LogTrace(myName) << myName << ": Wide width of wire plane = " << wg.wideWidthOfWirePlane;
215  LogTrace(myName) << myName << ": Length in y of wire plane = " << wg.lengthOfWirePlane;
216  LogTrace(myName) << myName << ": wg.consecutiveGroups.size() = " << wg.consecutiveGroups.size();
217  LogTrace(myName) << myName << ": wg.wiresInEachGroup.size() = " << wg.wiresInEachGroup.size();
218  LogTrace(myName) << myName << ": \tNumGroups\tWiresInGroup";
219  for (size_t i = 0; i < wg.consecutiveGroups.size(); i++) {
220  LogTrace(myName) << myName << " \t" << wg.consecutiveGroups[i] << "\t\t" << wg.wiresInEachGroup[i];
221  }
222  } else {
223  LogTrace(myName) << myName << ": DDD is MISSING SpecPars for wire groups";
224  }
225  LogTrace(myName) << myName << ": end of wire group info. ";
226 
227  LogTrace(myName) << myName << ":_z_ E" << jendcap << " S" << jstation << " R" << jring << " C" << jchamber << " L"
228  << jlayer << " gx=" << gtran[0] << ", gy=" << gtran[1] << ", gz=" << gtran[2]
229  << " thickness=" << fpar[2] * 2.;
230 
231  if (jlayer == 0) { // Can only build chambers if we're filtering them
232 
233  LogTrace(myName) << myName << ":_z_ frame=" << uparvals[31] / 10. << " gap=" << uparvals[32] / 10.
234  << " panel=" << uparvals[33] / 10. << " offset=" << uparvals[34] / 10.;
235 
236  if (jstation == 1 && jring == 1) {
237  // set up params for ME1a and ME1b and call buildChamber *for each*
238  // Both get the full ME11 dimensions
239 
240  // detid is for ME11 and that's what we're using for ME1b in the software
241 
242  rig.insert(id, gtran, grmat, fpar);
243  if (!chSpecsAlreadyExist) {
244  // rdp.pCSCDetIds.emplace_back(CSCDetId(id));
245  LogDebug(myName) << " inserting chamber type " << chamberType << std::endl;
246  rdp.pChamberType.emplace_back(chamberType);
247  rdp.pUserParOffset.emplace_back(rdp.pfupars.size());
248  rdp.pUserParSize.emplace_back(uparvals.size());
249  std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars));
250  }
251 
252  // No. of anonymous parameters per chamber type should be read from cscSpecs file...
253  // Only required for ME11 splitting into ME1a and ME1b values,
254  // If it isn't seen may as well try to get further but this value will depend
255  // on structure of the file so may not even match!
256  const int kNoOfAnonParams = 35;
257  if (noOfAnonParams == 0) {
258  noOfAnonParams = kNoOfAnonParams;
259  } // in case it wasn't seen
260 
261  // copy ME1a params from back to the front
262  std::copy(
263  uparvals.begin() + noOfAnonParams + 1, uparvals.begin() + (2 * noOfAnonParams) + 2, uparvals.begin() + 1);
264 
265  CSCDetId detid1a = CSCDetId(jendcap, 1, 4, jchamber, 0); // reset to ME1A
266  rig.insert(detid1a.rawId(), gtran, grmat, fpar);
267  int chtypeA = CSCChamberSpecs::whatChamberType(1, 4);
268  ct = 0;
269  for (; ct < rdp.pChamberType.size(); ++ct) {
270  if (chtypeA == rdp.pChamberType[ct]) {
271  break;
272  }
273  }
274  if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chtypeA) {
275  // then its in already, don't put it
276  LogDebug(myName) << "found chamber type " << chtypeA << " so don't put it in! ";
277  } else {
278  // rdp.pCSCDetIds.emplace_back(detid1a);
279  LogDebug(myName) << " inserting chamber type " << chtypeA;
280  rdp.pChamberType.emplace_back(chtypeA);
281  rdp.pUserParOffset.emplace_back(rdp.pfupars.size());
282  rdp.pUserParSize.emplace_back(uparvals.size());
283  std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars));
284  }
285 
286  } else {
287  rig.insert(id, gtran, grmat, fpar);
288  if (!chSpecsAlreadyExist) {
289  // rdp.pCSCDetIds.emplace_back(CSCDetId(id));
290  LogDebug(myName) << " inserting chamber type " << chamberType;
291  rdp.pChamberType.emplace_back(chamberType);
292  rdp.pUserParOffset.emplace_back(rdp.pfupars.size());
293  rdp.pUserParSize.emplace_back(uparvals.size());
294  std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars));
295  }
296  }
297 
298  } // filtering chambers.
299 
300  doSubDets = fv.next();
301  }
302  return true;
303 }
#define LogDebug(id)
int chamber() const
Definition: CSCDetId.h:62
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:121
static int whatChamberType(int istation, int iring)
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
int layer() const
Definition: CSCDetId.h:56
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
std::vector< float > pfupars
int endcap() const
Definition: CSCDetId.h:85
U second(std::pair< T, U > const &p)
std::vector< int > pChamberType
std::vector< int > pUserParOffset
Definition: value.py:1
#define LogTrace(id)
DDSolid solidA(void) const
Definition: DDSolid.cc:466
int ring() const
Definition: CSCDetId.h:68
std::vector< int > pUserParSize
int station() const
Definition: CSCDetId.h:79

Member Data Documentation

std::string CSCGeometryParsFromDD::myName
private

Definition at line 36 of file CSCGeometryParsFromDD.h.

Referenced by build().