@@ -125,20 +125,25 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
125125 double alphaW_layer = Math .toRadians (round / (numWires ));
126126
127127 // shift the wire end point +-20deg in XY plan
128- double thster = Math .toRadians (20.0d );
128+ double thster = Math .toRadians (- 20.0d );
129129 double zl = 300.0d ;
130130
131131 // Create AHDC sense wires
132- for (int wireId = 0 ; wireId < numWires ; wireId ++) {
132+ for (int iw = 0 ; iw < numWires ; iw ++) {
133133
134- // The point given by (wx, wy, wz) is the midpoint of the current wire.
135- double wx = -R_layer * Math .sin (alphaW_layer * wireId );
136- double wy = -R_layer * Math .cos (alphaW_layer * wireId );
134+ int wireId = iw + 1 + (int ) (numWires /2 );
135+ if (wireId >numWires ) wireId -= numWires ;
136+
137+ double wirePhiIndex = (numWires /2 ) + iw - 0.5 *(layerId -1 ); // start at phi=180
138+
139+ // The point given by (wx, wy, wz) is the origin of the current wire.
140+ double wx = R_layer * Math .cos (alphaW_layer * wirePhiIndex );
141+ double wy = R_layer * Math .sin (alphaW_layer * wirePhiIndex );
137142
138143 // Find the interesection of the current wire with the end-plate
139144 // planes by construciting a long line that passes through the midpoint
140- double wx_end = - R_layer * Math .sin (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
141- double wy_end = - R_layer * Math .cos (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
145+ double wx_end = R_layer * Math .cos (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
146+ double wy_end = R_layer * Math .sin (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
142147 Line3D line = new Line3D (wx , wy , 0 , wx_end , wy_end , zl );
143148
144149 Point3D lPoint = new Point3D ();
@@ -150,31 +155,31 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
150155 // Do not change the code above. It is for signal wires positioning
151156
152157 // Construct the cell around the signal wires created above top
153- double px_0 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId );
154- double py_0 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId );
155- double px_1 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId + alphaW_layer / 2 );
156- double py_1 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId + alphaW_layer / 2 );
157- double px_2 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId + alphaW_layer / 2 );
158- double py_2 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId + alphaW_layer / 2 );
159- double px_3 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId );
160- double py_3 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId );
161- double px_4 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId - alphaW_layer / 2 );
162- double py_4 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId - alphaW_layer / 2 );
163- double px_5 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId - alphaW_layer / 2 );
164- double py_5 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId - alphaW_layer / 2 );
158+ double px_0 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex );
159+ double py_0 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex );
160+ double px_1 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex + alphaW_layer / 2 );
161+ double py_1 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex + alphaW_layer / 2 );
162+ double px_2 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex + alphaW_layer / 2 );
163+ double py_2 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex + alphaW_layer / 2 );
164+ double px_3 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex );
165+ double py_3 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex );
166+ double px_4 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex - alphaW_layer / 2 );
167+ double py_4 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex - alphaW_layer / 2 );
168+ double px_5 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex - alphaW_layer / 2 );
169+ double py_5 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex - alphaW_layer / 2 );
165170 // bottom (do not forget to add the +20 deg. twist respect to the "straight" version)
166- double px_6 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
167- double py_6 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
168- double px_7 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
169- double py_7 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
170- double px_8 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
171- double py_8 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
172- double px_9 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
173- double py_9 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId + thster * (Math .pow (-1 , superlayerId )));
174- double px_10 = - (R_layer - 2 ) * Math .sin (alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
175- double py_10 = - (R_layer - 2 ) * Math .cos (alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
176- double px_11 = - (R_layer + 2 ) * Math .sin (alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
177- double py_11 = - (R_layer + 2 ) * Math .cos (alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
171+ double px_6 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
172+ double py_6 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
173+ double px_7 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
174+ double py_7 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
175+ double px_8 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
176+ double py_8 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
177+ double px_9 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
178+ double py_9 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex + thster * (Math .pow (-1 , superlayerId )));
179+ double px_10 = (R_layer - 2 ) * Math .cos (alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
180+ double py_10 = (R_layer - 2 ) * Math .sin (alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
181+ double px_11 = (R_layer + 2 ) * Math .cos (alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
182+ double py_11 = (R_layer + 2 ) * Math .sin (alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math .pow (-1 , superlayerId )));
178183
179184 // Group into points with (x,y,z) coordinates
180185 List <Point3D > firstF = new ArrayList <>();
@@ -195,25 +200,25 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye
195200 Point3D p_11 = new Point3D (px_11 , py_11 , zl );
196201 // defining a cell around a wireLine, must be counter-clockwise!
197202 firstF .add (p_0 );
198- firstF .add (p_1 );
199- firstF .add (p_2 );
200- firstF .add (p_3 );
201- firstF .add (p_4 );
202203 firstF .add (p_5 );
204+ firstF .add (p_4 );
205+ firstF .add (p_3 );
206+ firstF .add (p_2 );
207+ firstF .add (p_1 );
203208
204209 secondF .add (p_6 );
205- secondF .add (p_7 );
206- secondF .add (p_8 );
207- secondF .add (p_9 );
208- secondF .add (p_10 );
209210 secondF .add (p_11 );
211+ secondF .add (p_10 );
212+ secondF .add (p_9 );
213+ secondF .add (p_8 );
214+ secondF .add (p_7 );
210215
211216 // Create the cell and signal wire inside
212217 // PrismaticComponent(int componentId, List<Point3D> firstFace, List<Point3D> secondFace)
213218 // not possible to add directly PrismaticComponent class because it is an ABSTRACT
214219 // a new class should be created: public class NewClassWire extends PrismaticComponent {...}
215220 // 5 top points & 5 bottom points with convexe shape. Concave shape is not supported.
216- AlertDCWire wire = new AlertDCWire (wireId + 1 , wireLine , firstF , secondF );
221+ AlertDCWire wire = new AlertDCWire (wireId , wireLine , firstF , secondF );
217222 // Add wire object to the list
218223 layer .addComponent (wire );
219224 }
0 commit comments