CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SolidsForOnline.cc
Go to the documentation of this file.
1 #include <memory>
2 
8 
13 
15 
16 #include <iostream>
17 #include <istream>
18 #include <fstream>
19 #include <string>
20 
21 
23 
24 public:
25 
26  explicit SolidsForOnline( const edm::ParameterSet& );
28 
29  virtual void analyze( const edm::Event&, const edm::EventSetup& );
30  virtual void beginRun( const edm::Run&, const edm::EventSetup& );
31 
32 private:
33 
34  std::string filename_;
35 };
36 
38 
39 
41 
43  std::cout << "analyze does nothing" << std::endl;
44 }
45 
46 void SolidsForOnline::beginRun( const edm::Run&, const edm::EventSetup& iSetup ) {
47 
48 // TRD1 and Trapezoid can be in the same files.
49 
50  std::string solidsFileName("SOLIDS.dat"); //added by Jie Chen
51  std::string boxFileName("BOXES.dat");
52 
53  std::string tubesFileName("TUBES.dat");
54  std::string polyHedraFileName("POLYHEDRAS.dat");
55  std::string polyConeFileName("POLYCONES.dat");
56  std::string conesFileName("CONES.dat");
57  std::string pseudoTrapFileName("PSEUDOTRAPEZOIDS.dat");
58  std::string trapFileName("TRAPEZOIDS.dat");
59  std::string boolSolidsFileName("BOOLEANSOLIDS.dat");
60  std::string reflectionSolidsFileName("REFLECTIONSOLIDS.dat");
61  std::string torusFileName("TORUS.dat");
62 
63  std::ofstream solidsOS(solidsFileName.c_str());
64  std::ofstream boxOS(boxFileName.c_str());
65  std::ofstream tubeOS(tubesFileName.c_str());
66  std::ofstream polyHOS(polyHedraFileName.c_str());
67  std::ofstream polyCOS(polyConeFileName.c_str());
68  std::ofstream coneOS(conesFileName.c_str());
69  std::ofstream ptrapOS(pseudoTrapFileName.c_str());
70  std::ofstream trapOS(trapFileName.c_str());
71  std::ofstream boolOS(boolSolidsFileName.c_str());
72  std::ofstream reflectionOS(reflectionSolidsFileName.c_str());
73  std::ofstream torusOS(torusFileName.c_str());
74 
75  std::cout << "SolidsForOnline Analyzer..." << std::endl;
76 
78 
79  iSetup.get<IdealGeometryRecord>().get( "", pDD );
80 
81  const DDCompactView & cpv = *pDD;
82  DDCompactView::graph_type gra = cpv.graph();
83 
84  DDSolid::iterator<DDSolid> sit(DDSolid::begin()), sed(DDSolid::end());
85  for (; sit != sed; ++sit) {
86  if (! sit->isDefined().second) continue;
87  const DDSolid& solid = *sit;
89  solidsOS<<solid.name()<<","<<DDSolidShapesName::name(solid.shape())
90  << std::endl;
91 
92 
93  switch (solid.shape())
94  {
95  case ddunion:
96  {
97  //for bool solid
98  DDBooleanSolid boolSolid(solid);
99  boolOS << boolSolid.name() << "," ;
100  boolOS << "U";
101  boolOS << "," << boolSolid.translation().x()
102  << "," << boolSolid.translation().y()
103  << "," << boolSolid.translation().z()
104  << "," << boolSolid.solidA().name()
105  << "," << boolSolid.solidB().name()
106  << "," << boolSolid.rotation().name()
107  << std::endl;
108 
109  break;
110  }
111  case ddsubtraction:
112  {
113  DDBooleanSolid boolSolid(solid);
114  boolOS << boolSolid.name() << "," ;
115  boolOS << "S";
116  boolOS << "," << boolSolid.translation().x()
117  << "," << boolSolid.translation().y()
118  << "," << boolSolid.translation().z()
119  << "," << boolSolid.solidA().name()
120  << "," << boolSolid.solidB().name()
121  << "," << boolSolid.rotation().name()
122  << std::endl;
123  break;
124  }
125  case ddintersection:
126  {
127 
128  //for bool solid
129  DDBooleanSolid boolSolid(solid);
130  // if translation is == identity there are no parameters.
131  // if there is no rotation the name will be ":"
132  //std::string rotName = boolSolid.rotation().toString();
133  //if (rotName == ":") {
134  // rotName = "rotations:UNIT";
135  //}
136  boolOS << boolSolid.name() << "," ;
137  boolOS << "I";
138  boolOS << "," << boolSolid.translation().x()
139  << "," << boolSolid.translation().y()
140  << "," << boolSolid.translation().z()
141  << "," << boolSolid.solidA().name()
142  << "," << boolSolid.solidB().name()
143  << "," << boolSolid.rotation().name()
144  << std::endl;
145 
146  break;
147 
148  }
149  case ddreflected:
150  {
151  DDReflectionSolid reflection(solid);
152  reflectionOS<<reflection.name()<<","
153  <<reflection.unreflected().name()
154  <<std::endl;
155  break;
156  }
157  case ddbox:
158  {
159  DDBox box(solid);
160  //std::cout<<"box shape is"<<solid.shape()<<std::endl;
161  boxOS<<box.name()<<",";
162  boxOS<<2.0*box.halfX()<<","<<2.0*box.halfY()<<","<<2.0*box.halfZ()<<std::endl;
163  break;
164  }
165 
166  case ddpseudotrap:
167  {
168  DDPseudoTrap pseudoTrap(solid);
169 
170  ptrapOS<<pseudoTrap.name() <<",";
171  ptrapOS<<pseudoTrap.x1() <<","<<pseudoTrap.x2() <<","
172  <<pseudoTrap.halfZ()*2. <<","<<pseudoTrap.y1() <<","
173  <<pseudoTrap.y2() <<","<<pseudoTrap.radius()<<","
174  <<pseudoTrap.atMinusZ()
175  << std::endl;
176 
177  break;
178  }
179 
180  case ddtubs:
181  {
182  //same as ddtrunctubs, Tube element is simply a Tube Section
183  //with the angle going from zero to 360 degrees.
184  //cutAtStart, cutAtDelta, and cutInside. are all zero
185  //then they are tubes
186  DDTubs tubs(solid);
187  tubeOS<<tubs.name()<<","<<tubs.rIn()<<","
188  <<tubs.rOut()<<","<<tubs.zhalf()*2.0<<","
189  <<tubs.startPhi()<<","<<tubs.deltaPhi()<<","
190  <<"0"<<","<<"0"<<","
191  <<"0"
192  <<std::endl;
193 
194  break;
195  }
196  case ddtrap: // trd1s is included into this case
197  {
198  DDTrap trap(solid);
199  trapOS<<trap.name()<<",";
200  trapOS<<trap.alpha1()<<","<<trap.alpha2()<<","
201  <<trap.x1()<<","<<trap.x2()<<","
202  <<trap.halfZ()*2.0<<","<<trap.y1()<<","
203  <<trap.y2()<<","
204  <<trap.phi()<<","<<trap.theta()<<","
205  <<trap.x3()<<","<<trap.x4()
206  <<std::endl;
207  break;
208  }
209  case ddcons:
210  {
211  DDCons cons(solid);
212  coneOS<<cons.name()<<","<<cons.zhalf()*2.0<<","
213  <<cons.rInMinusZ()<<","
214  <<cons.rOutMinusZ()<<","<<cons.rInPlusZ()<<","
215  <<cons.rOutPlusZ()<<","<<cons.phiFrom()<<","
216  <<cons.deltaPhi()
217  <<std::endl;
218 
219  break;
220  }
221 
222  case ddpolycone_rz:
223  {
224  //rz_zs=rz if it's ddpolycone_rz
225  DDPolycone polyCone(solid);
226  polyCOS<<polyCone.name()<<","<<polyCone.startPhi()
227  <<","<<polyCone.deltaPhi()<<","<<"RZ"
228  <<std::endl;
229  break;
230  }
231  case ddpolyhedra_rz:
232  {
233  DDPolyhedra polyHedra(solid);
234  polyHOS<<polyHedra.name()<<",";
235  polyHOS<<polyHedra.sides()<<","<<polyHedra.startPhi()
236  <<","<<polyHedra.deltaPhi()<<","<<"RZ"
237  <<std::endl;
238  break;
239  }
240  case ddpolycone_rrz:{
241  //rz_zs=zs if it's ddpolycone_rrz
242  DDPolycone polyCone(solid);
243  polyCOS<<polyCone.name()<<","<<polyCone.startPhi()
244  <<","<<polyCone.deltaPhi()<<","<<"ZS"
245  <<std::endl;
246  break;
247  }
248  case ddpolyhedra_rrz:
249  {
250 
251  DDPolyhedra polyHedra(solid);
252  polyHOS<<polyHedra.name()<<",";
253  polyHOS<<polyHedra.sides()<<","<<polyHedra.startPhi()
254  <<","<<polyHedra.deltaPhi()<<","<<"ZS"
255  <<std::endl;
256  break;
257  }
258 
259  case ddtrunctubs:{
260 
261  DDTruncTubs tubs(solid);
262  tubeOS<<tubs.name()<<","<<tubs.rIn()<<","
263  <<tubs.rOut()<<","<<tubs.zHalf()*2.0<<","
264  <<tubs.startPhi()<<","<<tubs.deltaPhi()<<","
265  <<tubs.cutAtStart()<<","<<tubs.cutAtDelta()<<","
266  <<tubs.cutInside()
267  <<std::endl;
268  break;
269  }
270 
271  case ddtorus: {
272  DDTorus torus(solid);
273  torusOS<<torus.name()<<","<<torus.rMin()<<","
274  <<torus.rMax()<<","<<torus.rTorus()<<","
275  <<torus.startPhi()<<","<<torus.deltaPhi()
276  <<std::endl;
277  break;
278  }
279 
280  case ddshapeless:{
281  // DDShapelessSolid shapeless(solid);
282  //shapelessOS<<shapeless.name()
283  // <<std::endl;
284 
285 // return new PSolid( solid.toString(), solid.parameters()
286 // , solid.shape() );
287  break;
288  }
289  case dd_not_init:
290  default:
291  throw cms::Exception("DDException") << "DDDToPersFactory::solid(...) either not inited or no such solid.";
292  break;
293  }
294 
295 
296  }
297  solidsOS.close();
298  boxOS.close();
299 
300  tubeOS.close();
301  polyHOS.close();
302  polyCOS.close();
303  coneOS.close();
304  ptrapOS.close();
305  trapOS.close();
306  boolOS.close();
307  reflectionOS.close();
308 }
309 
310 //define this as a plug-in
double zhalf(void) const
Definition: DDSolid.cc:458
double startPhi(void) const
Definition: DDSolid.cc:415
double cutAtStart(void) const
truncation at begin of the tube-section
Definition: DDSolid.cc:211
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:167
bool cutInside(void) const
true, if truncation is on the inner side of the tube-section
Definition: DDSolid.cc:215
double halfZ(void) const
Definition: DDSolid.cc:258
A truncated tube section.
Definition: DDSolid.h:132
double x1(void) const
Half-length along x of the side at y=-pDy1 of the face at -pDz.
Definition: DDSolid.cc:175
const N & name() const
Definition: DDBase.h:82
double zHalf(void) const
half of the z-Axis
Definition: DDSolid.cc:201
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
double y2(void) const
half length along y on +z
Definition: DDSolid.cc:236
double halfY(void) const
Definition: DDSolid.cc:256
double deltaPhi(void) const
angular span of the tube-section
Definition: DDSolid.cc:209
double phi(void) const
Azimuthal angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:171
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double rTorus(void) const
Definition: DDSolid.cc:487
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
double cutAtDelta(void) const
truncation at end of the tube-section
Definition: DDSolid.cc:213
double phiFrom(void) const
Definition: DDSolid.cc:468
double rIn(void) const
inner radius
Definition: DDSolid.cc:203
double rOutMinusZ(void) const
Definition: DDSolid.cc:462
double rOutPlusZ(void) const
Definition: DDSolid.cc:466
DDTranslation translation(void) const
Definition: DDSolid.cc:540
type of data representation of DDCompactView
Definition: DDCompactView.h:77
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
double y1(void) const
half length along y on -z
Definition: DDSolid.cc:234
DDSolid solidB(void) const
Definition: DDSolid.cc:550
double rMax(void) const
Definition: DDSolid.cc:485
SolidsForOnline(const edm::ParameterSet &)
std::string filename_
DDSolid unreflected(void) const
Definition: DDSolid.cc:272
int iEvent
Definition: GenABIO.cc:243
double x4(void) const
Half-length along x of the side at y=+pDy2 of the face at +pDz.
Definition: DDSolid.cc:185
DDRotation rotation(void) const
Definition: DDSolid.cc:535
static const char * name(DDSolidShape s)
Definition: DDSolidShapes.h:21
bool atMinusZ(void) const
true, if cut-out or rounding is on the -z side
Definition: DDSolid.cc:240
double halfZ(void) const
half of the z-Axis
Definition: DDSolid.cc:228
double startPhi(void) const
Definition: DDSolid.cc:511
double startPhi(void) const
Definition: DDSolid.cc:368
double deltaPhi(void) const
Definition: DDSolid.cc:370
Interface to a Trapezoid.
Definition: DDSolid.h:77
double y1(void) const
Half-length along y of the face at -pDz.
Definition: DDSolid.cc:173
double rInMinusZ(void) const
Definition: DDSolid.cc:460
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
double rMin(void) const
Definition: DDSolid.cc:483
double rOut(void) const
Definition: DDSolid.cc:509
int sides(void) const
Definition: DDSolid.cc:413
DDSolid solidA(void) const
Definition: DDSolid.cc:545
double deltaPhi(void) const
Definition: DDSolid.cc:470
double deltaPhi(void) const
Definition: DDSolid.cc:513
double startPhi(void) const
Definition: DDSolid.cc:489
double halfX(void) const
Definition: DDSolid.cc:254
double deltaPhi(void) const
Definition: DDSolid.cc:491
Interface to a Box.
Definition: DDSolid.h:162
const T & get() const
Definition: EventSetup.h:55
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
Definition: DDSolid.cc:179
double alpha2(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy2 to the centre at y=+pDy2 of t...
Definition: DDSolid.cc:187
double startPhi(void) const
angular start of the tube-section
Definition: DDSolid.cc:207
double x2(void) const
Half-length along x of the side at y=+pDy1 of the face at -pDz.
Definition: DDSolid.cc:177
double zhalf(void) const
Definition: DDSolid.cc:505
double deltaPhi(void) const
Definition: DDSolid.cc:417
double y2(void) const
Half-length along y of the face at +pDz.
Definition: DDSolid.cc:181
static DDI::Store< DDName, DDI::Solid * >::iterator begin()
Definition: DDBase.h:70
double rInPlusZ(void) const
Definition: DDSolid.cc:464
tuple cout
Definition: gather_cfg.py:121
virtual void analyze(const edm::Event &, const edm::EventSetup &)
static DDI::Store< DDName, DDI::Solid * >::iterator end()
Definition: DDBase.h:69
double x2(void) const
half length along x on +z
Definition: DDSolid.cc:232
double rIn(void) const
Definition: DDSolid.cc:507
double rOut(void) const
outer radius
Definition: DDSolid.cc:205
double theta(void) const
Polar angle of the line joining the centres of the faces at -/+pDz.
Definition: DDSolid.cc:169
double x3(void) const
Half-length along x of the side at y=-pDy2 of the face at +pDz.
Definition: DDSolid.cc:183
double x1(void) const
half length along x on -z
Definition: DDSolid.cc:230
Definition: Run.h:33
double radius(void) const
radius of the cut-out (neg.) or rounding (pos.)
Definition: DDSolid.cc:238