CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 21 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 push_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 DDFilteredView::addFilter(), CSCWireGroupPackage::alignmentPinToFirstWire, DDSpecificsFilter::AND, CSCNumberingScheme::baseNumberToUnitNumber(), CSCDetId::chamber(), CSCWireGroupPackage::consecutiveGroups, filterCSVwithJSON::copy, CSCDetId, ddsubtraction, cond::rpcobgas::detid, CSCDetId::endcap(), DDSpecificsFilter::equals, alcazmumu_cfi::filter, first, DDFilteredView::firstChild(), DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), i, RecoIdealGeometry::insert(), 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(), DDSpecificsFilter::setCriteria(), DDSolid::shape(), DDLogicalPart::solid(), DDBooleanSolid::solidA(), DDFilteredView::specifics(), CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), DDFilteredView::translation(), relativeConstraints::value, CSCChamberSpecs::whatChamberType(), CSCWireGroupPackage::wideWidthOfWirePlane, CSCWireGroupPackage::wiresInEachGroup, and CSCWireGroupPackage::wireSpacing.

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

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

Member Data Documentation

std::string CSCGeometryParsFromDD::myName
private

Definition at line 39 of file CSCGeometryParsFromDD.h.

Referenced by build().