#ifdef BAF df << "#dirdef SCT" << endl; df << "#open SCT" << endl; df << "#dirdef Barrel" << endl; df << "#open Barrel" << endl; #endif // We're going to read those parameters which interest // us from the preXml file, and then produce the // relevant output. // The xml file comes to us as the element called doc. // Since there' are potential name clashes everywhere, let's // restrict ourselves to looking in only that part of the preXml file // which is relevant to the SCT barrel and this particular geometry. // These are some macros that save a bit of typing. // All they do is read values from the preXml file // and store them in constants and const vectors. // They make use of the fact that I have the same // names for my variables both in this program AND // in the preXml file. You don't have to do it // this way if you don't want to. By way of example, // I've typed the first "read" in it's expanded form. #define DWSET(t,v) \ preXml:: t v ; \ useMy.fill( v , #v ); \ cout << "I found "<< #v <<" = "<< v << endl; #define DWSETARRAY(t,v,n) \ vector< preXml:: t > v ( n ) ; \ useMy.fill( v , #v ) ; \ { \ for(int i=0; i< n ;i++) { \ cout << "I found "<< #v <<"["< flange; { for (int i=0; isetName(o.str()); flange[i]->setTubs(r0Sup[i]-flLen[i], r0Sup[i], tckFl[i]); flange[i]->setMaterial("cheese"); barrelSection.addVolume(flange[i]); } } #endif // Here are nLay CloseOuts #ifdef BAF { for (int i=0; i closeOut; { for (int i=0; isetName(o.str()); closeOut[i]->setTubs(r0Sup[i]-tckClo[i], r0Sup[i], cOLen[i]); closeOut[i]->setMaterial("cheese"); barrelSection.addVolume(closeOut[i]); } } #endif // Here are nLay Supports #ifdef BAF { for (int i=0; i support; { for (int i=0; isetName(o.str()); support[i]->setTubs(r0Sup[i]-tckSup[i],r0Sup[i],2.*(zCylEnd-cOLen[i]-tckFl[i])); support[i]->setMaterial("cheese"); barrelSection.addVolume(support[i]); } } #endif // Here is the InsulationEnd #ifdef BAF { df << DWBegin("InsulationEnd"); df << DWTubs(rMin, rMax, tckIso); df << DWEnd("InsulationEnd"); } #else agdb::Solid & insulationEnd = barrelSection.adopt(new agdb::Solid()); insulationEnd.setName("sct_insulationEnd"); insulationEnd.setTubs(rMin, rMax, tckIso); insulationEnd.setMaterial("cheese"); barrelSection.addVolume(insulationEnd); #endif // Here is the InsulationCyl #ifdef BAF { df << DWBegin("InsulationCyl"); df << DWTubs(rMax-tckIso, rMax, 2.*zCylEnd); df << DWEnd("InsulationCyl"); } #else agdb::Solid & insulationCyl = barrelSection.adopt(new agdb::Solid()); insulationCyl.setName("sct_insulationCyl"); insulationCyl.setTubs(rMax-tckIso, rMax, 2.*zCylEnd); insulationCyl.setMaterial("cheese"); barrelSection.addVolume(insulationCyl); #endif // Here is are two BarrelModules, Type1 and Type2 (Positive/negative stereo) #ifdef BAF { for (int i=0; i<2; i++) { string name; if (i==0) { name=string("BarrelModuleType1"); } else { name=string("BarrelModuleType2"); } df << DWBegin(name); df << DWBox(moduleThickness, moduleWidth, moduleLength); // First the inner SECT if (i==0) { df << DWPlacement("SECT", -(sectThickness+sectGap)/2., 0, 0, +stereoInner/DWdegree, 0, 0); } else { df << DWPlacement("SECT", -(sectThickness+sectGap)/2., 0, 0, -stereoInner/DWdegree, 0, 0); } // now the outer SECT df << DWPlacement("SECT", +(sectThickness+sectGap)/2., 0, 0); df << DWEnd(name); } } #else agdb::PosXYZ & posInnerSectPos = barrelSection.adopt(new agdb::PosXYZ()); agdb::PosXYZ & negInnerSectPos = barrelSection.adopt(new agdb::PosXYZ()); agdb::PosXYZ & OuterSectPos1 = barrelSection.adopt(new agdb::PosXYZ()); agdb::PosXYZ & OuterSectPos2 = barrelSection.adopt(new agdb::PosXYZ()); posInnerSectPos.setVolume(sect); negInnerSectPos.setVolume(sect); OuterSectPos1.setVolume(sect); OuterSectPos2.setVolume(sect); posInnerSectPos.setXYZ(-(sectThickness+sectGap)/2., 0., 0.); negInnerSectPos.setXYZ(-(sectThickness+sectGap)/2., 0., 0.); OuterSectPos1.setXYZ(+(sectThickness+sectGap)/2., 0., 0.); OuterSectPos2.setXYZ(+(sectThickness+sectGap)/2., 0., 0.); posInnerSectPos.setRot(+stereoInner/DWdegree, 0., 0.); // LESTER Check sign negInnerSectPos.setRot(-stereoInner/DWdegree, 0., 0.); // LESTER Check sign agdb::Compos & posModule = barrelSection.adopt(new agdb::Compos()); agdb::Compos & negModule = barrelSection.adopt(new agdb::Compos()); posModule.setName("sct_posBarrelModule"); negModule.setName("sct_negBarrelModule"); posModule.addPos(posInnerSectPos); negModule.addPos(negInnerSectPos); posModule.addPos( OuterSectPos1); negModule.addPos( OuterSectPos2); barrelSection.addVolume(posModule); barrelSection.addVolume(negModule); #endif // That's the end of the barrel modules. // Here are the nLay types of ski. #ifdef BAF { int i; int sn; // This shall take values indicative of the // module type to use on each layer. for ((i=0, sn=2); i ski; { for (int i=0; isetName(o.str()); int sn; // Will oscillate with the radial staggering. int j; // Module number for ((sn=-1, j=0); jaddPos(modulePos); } barrelSection.addVolume(ski[i]); } } #endif // There end all the skis. { // Here comes the Barrel. (This is a long one.) int i; // Loop variable to represent the layer. int sn; // Dummy variable indicating skiType. #ifdef BAF df << DWBegin("Barrel"); df << DWTubs(rMin, rMax, hLen*2); #endif // First will position entities which // there are "one of" per layer. // Here starts the loop over the layers in the barrel. for ((sn=1,i=0); i=0); const double rad1 = sqrt(temp1)-max(tckLum, 2.*out2); const double rCab = rad1 + out2; const double yCab = max(wdthLum/2., rCab*tan((angle/4.)/DWradian)); const double wactrot = sectLength*sin(stRA/DWradian)+waferWidth*cos(stRA/DWradian); const double delX = layerRadius[i]+(-dXSki*cos(tilt/DWradian)+(wactrot/2.)*sin(tilt/DWradian)); const double delY = (+dXSki*sin(tilt/DWradian)+(wactrot/2.)*cos(tilt/DWradian)); const double alpha = angle/2.-atan(delY/delX)*DWradian; const double rLump = rad1 + tckLum/2.; // OK. That's all the variables we need to define. // Let's get going with the placements. #ifndef BAF // First we make a composition for the layer: agdb::Compos & layer = barrelSection.adopt(new agdb::Compos); layer.setName("sct_layer"+barrelSection.makeNumberString(i+1.)); barrelSection.addVolume(layer); // and then we place it in the barrel: agdb::PosXYZ & layerPos = barrelSection.adopt(new agdb::PosXYZ); layerPos.setVolume(layer); barrelCompos.addPos(layerPos); #endif // Position the Lump and Cables #ifdef BAF { df << DWPhisymm("SLMP", skisPerLayer[i], rLump); df << DWPhisymm("DoubleSCAB", skisPerLayer[i], sqrt(rCab*rCab+yCab*yCab), 0, 0,0,0, atan(yCab/rCab)*DWradian ); } #else agdb::MPosPhi & slmpPos = barrelSection.adopt(new agdb::MPosPhi); slmpPos.setVolume(slmp); slmpPos.setN(skisPerLayer[i]); slmpPos.setRZ(rLump, 0.); layer.addPos(slmpPos); agdb::MPosPhi & doubleScabPos = barrelSection.adopt(new agdb::MPosPhi); doubleScabPos.setVolume(doubleScab); doubleScabPos.setN(skisPerLayer[i]); doubleScabPos.setRZ(sqrt(rCab*rCab+yCab*yCab), 0.); doubleScabPos.setPhi0(atan(yCab/rCab)*DWradian); //LESTER Check sign layer.addPos(doubleScabPos); #endif // That's finished positioning the cables. // Here come the skis. #ifdef BAF { ostrstream o; o << "SkiType"<< i+1 << ends; string skiName = o.str(); df << DWPhisymm(skiName, skisPerLayer[i], layerRadius[i], 0, 0, 0, -tiltOfLayer[i], alpha+angle ); } #else agdb::MPosPhi & skiPos = barrelSection.adopt(new agdb::MPosPhi); skiPos.setVolume(ski[i]); skiPos.setN(skisPerLayer[i]); skiPos.setRZ(layerRadius[i], 0.); skiPos.setRot(0., 0., -tiltOfLayer[i]); //LESTER Check sign skiPos.setPhi0(alpha+angle); layer.addPos(skiPos); #endif // That completes the skis. // Position the CloseOuts, flanges and Supports #ifdef BAF { string closeOutName; string supportName; string flangeName; { ostrstream o; o << "CloseOut" << i+1 << ends; closeOutName=o.str(); } { ostrstream o; o << "Support" << i+1 << ends; supportName=o.str(); } { ostrstream o; o << "Flange" << i+1 << ends; flangeName=o.str(); } df << DWPlacement(flangeName, 0,0,+(zCylEnd-tckFl[i]/2.)); df << DWPlacement(flangeName, 0,0,-(zCylEnd-tckFl[i]/2.)); df << DWPlacement(closeOutName,0,0,+(zCylEnd-tckFl[i]-cOLen[i]/2.)); df << DWPlacement(closeOutName,0,0,-(zCylEnd-tckFl[i]-cOLen[i]/2.)); df << DWPlacement(supportName); } #else agdb::PosXYZ & posCloseOutPos = barrelSection.adopt(new agdb::PosXYZ); agdb::PosXYZ & negCloseOutPos = barrelSection.adopt(new agdb::PosXYZ); posCloseOutPos.setVolume(closeOut[i]); negCloseOutPos.setVolume(closeOut[i]); posCloseOutPos.setXYZ(0., 0., +(zCylEnd-tckFl[i]-cOLen[i]/2.)); negCloseOutPos.setXYZ(0., 0., -(zCylEnd-tckFl[i]-cOLen[i]/2.)); layer.addPos(posCloseOutPos); layer.addPos(negCloseOutPos); agdb::PosXYZ & posFlangePos = barrelSection.adopt(new agdb::PosXYZ); agdb::PosXYZ & negFlangePos = barrelSection.adopt(new agdb::PosXYZ); posFlangePos.setVolume(flange[i]); negFlangePos.setVolume(flange[i]); posFlangePos.setXYZ(0., 0., +(zCylEnd-tckFl[i]/2.)); negFlangePos.setXYZ(0., 0., -(zCylEnd-tckFl[i]/2.)); layer.addPos(posFlangePos); layer.addPos(negFlangePos); agdb::PosXYZ & supportPos = barrelSection.adopt(new agdb::PosXYZ); supportPos.setVolume(support[i]); layer.addPos(supportPos); #endif // That's all the CloseOuts, flanges and Supports done. } // End of loop over layers. // Now come the layer independent placements. // The insulating stuff #ifdef BAF df << DWPlacement("InsulationCyl"); df << DWPlacement("InsulationEnd",0,0,+(hLen-tckIso/2.)); df << DWPlacement("InsulationEnd",0,0,-(hLen-tckIso/2.)); #else agdb::PosXYZ & insulationCylPos = barrelSection.adopt(new agdb::PosXYZ); insulationCylPos.setVolume(insulationCyl); barrelCompos.addPos(insulationCylPos); agdb::PosXYZ & posInsulationEndPos = barrelSection.adopt(new agdb::PosXYZ); agdb::PosXYZ & negInsulationEndPos = barrelSection.adopt(new agdb::PosXYZ); posInsulationEndPos.setVolume(insulationEnd); negInsulationEndPos.setVolume(insulationEnd); posInsulationEndPos.setXYZ(0., 0., +(hLen-tckIso/2.)); negInsulationEndPos.setXYZ(0., 0., -(hLen-tckIso/2.)); barrelCompos.addPos(posInsulationEndPos); barrelCompos.addPos(negInsulationEndPos); #endif #ifdef BAF df << DWEnd("Barrel"); #endif } // That was the end of the Barrel and skis. #ifdef BAF df << "#close Barrel" << endl; { // Here is the SCT total df << DWBegin("SCT"); df << DWTubs(25.*DWcm, 55.*DWcm, 3.*DWm); // Guessed df << DWPlacement("Barrel"); df << DWEnd("SCT"); } // Here ends the SCT total df << "#close SCT" << endl; #endif