58 wn0=33; wn1=0; wn2=0; wn3=-1;
59 memcpy(wnbuf,
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",36);
64 sprintf(modName,
"DR%iM",m+1);
70 sprintf(eleName,
"D%i",m+1);
77 if (builder && paramFile.Length() > 0) {
78 TFile* file =
new TFile(paramFile.Data(),
"READ");
79 if (file==NULL || file->IsOpen()== kFALSE) {
80 Error(
"createAdditionalGeometry",
"Parameter file %s not found", paramFile.Data());
87 vector<HGeomMdcWirePlane>& pWirePlanes = mdcWirePlanes->
getWirePlanes();
89 for (UInt_t np=0; np<pWirePlanes.size(); np++) {
92 if (pMother==NULL || pMother->
isActive()==kFALSE)
continue;
93 Double_t planeX[4], planeY[4];
94 for (Int_t i=0; i<4; i++) {
96 planeX[i] = point->
getX();
97 planeY[i] = point->
getY();
99 Int_t medId[2] = {-1,-1};
100 for (Int_t i = 0; i <= plane.
planeType &&
rc; i++) {
104 if (medId[i] <= 0) medId[i] = builder->
createMedium(medium);
106 Error(
"createAdditionalGeometry",
107 "Medium %s not created",plane.
wireMedium[i].Data());
111 Error(
"createAdditionalGeometry",
112 "Medium %s not found in list of media",plane.
wireMedium[i].Data());
121 Float_t halfDist = wireDist * 0.5;
123 Double_t posX = 0., posY = 0., posZ = 0.;
124 Double_t at = (planeY[1] - planeY[0]) / (planeX[1] - planeX[0]);
125 Double_t bt = planeY[0] - at * planeX[0];
126 Double_t halfLengthCenter = (planeY[1] - planeY[0]) * 0.5;
128 generateWireName(wireName);
136 copyNum = wireNum + 1;
137 arrIndex = addWireObject(wireNum, wireName, copyNum, 0, radius, halfLengthCenter, posX, posY, posZ);
139 pWire = wireObjects[arrIndex];
145 }
while ((posX+radius) <= planeX[0]);
146 Int_t maxCopyNumLeft = copyNum;
151 generateWireName(wireName);
153 Double_t y = at * (posX + radius) + bt;
154 Double_t halfLength = (planeY[1] - y) / 2.;
155 posZ = halfLengthCenter - halfLength;
156 addWireObject(wireNum, wireName, copyNum, 0, radius, halfLength, posX, posY, posZ);
159 }
while ((posX+halfDist) < planeX[1]);
160 Int_t maxInd = wireObjects.size();
164 for (Int_t i=0; i<maxInd &&
rc; i++) {
165 pWire = wireObjects[i];
170 Error(
"createAdditionalGeometry",
171 "Plane %s wire %i not created",plane.
planeName.Data(),i);
177 Error(
"createAdditionalGeometry",
178 "Plane %s wire %i not positioned",plane.
planeName.Data(),i);
183 for (Int_t i=1; i<maxInd &&
rc; i++) {
184 pWire = wireObjects[i];
187 copyNum += maxCopyNumLeft -1;
200 totNumWires += wireNum;
210 Double_t sinWireOr = TMath::Sin(wireOrient*TMath::DegToRad());
211 Double_t cosWireOr = TMath::Cos(wireOrient*TMath::DegToRad());
212 Double_t arr[] = {sinWireOr, 0., cosWireOr, 0., 1., 0., -cosWireOr, 0., sinWireOr};
218 Double_t planeCenter[2];
219 planeCenter[0] = (planeX[0] + planeX[1] + planeX[2] + planeX[3]) * .25;
220 planeCenter[1] = (planeY[0] + planeY[1] + planeY[2] + planeY[3]) * .25;
221 for (Int_t i=0; i<4; i++) {
222 planeX[i] -= planeCenter[0];
223 planeY[i] -= planeCenter[1];
228 Double_t at[4], bt[4];
230 at[0] = (planeY[1] - planeY[0]) / (planeX[1] - planeX[0]);
231 Double_t dy = radius * cosWireOr;
232 Double_t dx1 = dy / at[0];
234 if (wireOrient > 0.) {
235 dx2 = radius * (sinWireOr + cosWireOr / at[0]);
237 dx2 = -radius * (sinWireOr - cosWireOr / at[0]);
239 planeX[0] = planeX[0] + dx1 - dx2;
240 planeY[0] = planeY[0] + dy;
241 planeX[1] = planeX[1] - dx1 - dx2;
242 planeY[1] = planeY[1] - dy;
243 planeX[2] = -planeX[1];
244 planeY[2] = planeY[1];
245 planeX[3] = -planeX[0];
246 planeY[3] = planeY[0];
249 for (Int_t i1=0; i1<4; i1++) {
252 at[i1] = (planeY[i2] - planeY[i1]) / (planeX[i2] - planeX[i1]);
253 bt[i1] = planeY[i1] - at[i1] * planeX[i1];
258 Double_t a = TMath::Tan(wireOrient*TMath::DegToRad());
259 Int_t numWiresPlane=0;
260 for(Int_t wireNum=0; wireNum<plane.
numWires; wireNum++) {
261 Int_t wireType = wireNum%2;
265 Double_t yWire = wireNum * plane.
wireDist - wireOffset;
266 Double_t b = yWire/cosWireOr - planeCenter[1];
267 Double_t x1 = (bt[0]-b)/(a-at[0]);
268 Double_t x2 = (bt[2]-b)/(a-at[2]);
269 Double_t y1 = a*x1+b;
270 Double_t y2 = a*x2+b;
271 Int_t nLine1 = (x1>=planeX[0] && x1<=planeX[1] && y1>=planeY[0] && y1<=planeY[1]) ? 0:-1;
272 Int_t nLine2 = (x2<=planeX[3] && x2>=planeX[2] && y2>=planeY[3] && y2<=planeY[2]) ? 2:-1;
273 if(nLine1<0 && nLine2 <0) {
278 x1 = (bt[1]-b)/(a-at[1]);
279 if(x1<planeX[2]) x1 = (bt[3]-b)/(a-at[3]);
281 }
else if(nLine2<0) {
282 x2 = (bt[1]-b)/(a-at[1]);
283 if(x2>planeX[1]) x2 = (bt[3]-b)/(a-at[3]);
286 Double_t wireLength = TMath::Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
287 Double_t posX = (x2 + x1) * .5;
289 Double_t posZ = (y2 + y1) * .5;
294 generateWireName(wireName);
295 HGeomMdcWire wire(wireNum, wireName, 1, wireType, radius, wireLength * 0.5, posX, posY, posZ);
298 Error(
"createAdditionalGeometry",
299 "Plane %s wire %i not created",plane.
planeName.Data(),wireNum);
304 Error(
"createAdditionalGeometry",
305 "Plane %s wire %i not positioned",plane.
planeName.Data(),wireNum);
309 totNumWires += numWiresPlane;
314 cout<<
" Wires created: "<<totNumWires<<endl;
315 delete mdcWirePlanes;
316 mdcWirePlanes = NULL;
318 Warning(
"createAdditionalGeometry",
"HGeomMdcWires not found in parameter file %s", paramFile.Data());
340 vName.Form(
"%c%c%c%c",wnbuf[wn0],wnbuf[wn1],wnbuf[wn2],wnbuf[wn3]);
346 for(UInt_t i = 0; i < wireObjects.size(); i ++) {
347 if (wireObjects[i]) {
348 delete wireObjects[i];
356 Double_t hlen, Double_t xpos, Double_t ypos, Double_t zpos) {
360 wireObjects.push_back(wire);
361 return (wireObjects.size()-1);
Bool_t createAdditionalGeometry(HGeomBuilder *, const TString &, HGeomMedia *)
virtual void fillMdcCommonBlock(HGeomNode *)
virtual Bool_t positionNode(HGeomMdcWire *, HGeomNode *, Int_t)
const Char_t * getEleName(Int_t)
ClassImp(HGeomMdc) HGeomMdc
virtual Bool_t createVolume(HGeomMdcWire *, Int_t)
void setCopyNode(HGeomMdcWire *p)
void setMatrix(const Double_t *)
void generateWireName(TString &vName)
void setWireNumber(Int_t wn)
HGeomVector * getPoint(const Int_t n)
virtual Int_t createMedium(HGeomMedium *)=0
const Char_t * getModuleName(Int_t)
vector< HGeomMdcWirePlane > & getWirePlanes()
Int_t addWireObject(Int_t, TString &, Int_t, Int_t, Float_t, Double_t, Double_t, Double_t, Double_t)
void setCopyNumber(Int_t cn)
virtual Int_t createRotation(HGeomRotation *)