148 string geoFilePath = getenv(
"CGEMGEOMSVCROOT");
150 cout <<
"IFILE " << m_iFile << endl;
154 geoFilePath +=
"/dat/cgem_model_1_default.txt";
157 geoFilePath +=
"/dat/cgem_model_2_default.txt";
160 geoFilePath +=
"/dat/cgem_model_3_default.txt";
163 geoFilePath +=
"/dat/cgem_model_4_default.txt";
166 geoFilePath +=
"/dat/cgem_model_5_default.txt";
169 geoFilePath +=
"/dat/cgem_model_6_default.txt";
173 geoFilePath +=
"/dat/cgem_model_oldgeom.txt";
177 cout <<
"Warning in CgemGeomSvc::initGeom(): The geometry will be constructed through default model!" << endl;
178 geoFilePath +=
"/dat/cgem_model_6_default.txt";
181 cout <<
"INFO in CgemGeomSvc::initGeom(): Geometry will be constructed through File: "
182 << geoFilePath << endl;
185 ifstream fin(geoFilePath.c_str(), ios::in);
188 cout <<
"Error in CgemGeomSvc::initGeom(): Fail to open geomtry file: " << endl;
189 cout << geoFilePath << endl;
195 if(m_debugCout) cout << left <<
"=======get BesMdcGeoParameter from CgemGeomSvc=======" << endl;
198 std::getline(fin, strcom);
199 std::getline(fin, strcom);
202 if(m_debugCout) cout <<
"N_CgemLayer : " << left << setw(8) << m_N_CgemLayer
203 <<
"N_GemFoil : " << left << setw(8) << m_N_GemFoil << endl;
204 std::getline(fin, strcom);
205 std::getline(fin, strcom);
206 std::getline(fin, strcom);
207 double rLayer, lenLayer, numSheet, wSheet, aStereo, wPitchX, wPitchV, wStripX, wStripV, nChannelX, nChannelV;
208 double phi_start[3][2], dX_start_strip[3][2], dV_start_strip[3][2];
210 for (
int i=0; i < m_N_CgemLayer; i++)
212 fin >> rLayer >> lenLayer >> numSheet >> wSheet >> aStereo >> wPitchX >> wPitchV
213 >> wStripX >> wStripV >> nChannelX >> nChannelV
214 >> phi_start[i][0] >> phi_start[i][1]
215 >> dX_start_strip[i][0] >> dX_start_strip[i][1]
216 >> dV_start_strip[i][0] >> dV_start_strip[i][1]
217 >> gap_d[i] >> m_Orientation;
221 m_T_Gap_D[i] = gap_d[i];
235 std::getline(fin, strcom);
239 double ncMaterials[3];
240 double tc_cu1[3],tc_kapton1[3], tc_epoxy0[3],tc_carbonf[3],tc_epoxy1[3],tc_honeycomb[3],tc_rohacell1[3],tc_epoxy2[3],tc_kapton2[3],tc_epoxy3[3],tc_rohacell2[3],tc_epoxy4[3],tc_kapton3[3],tc_cu2[3];
241 std::getline(fin, strcom);
246 fin >>nmc_Materials[0]>>nmc_Materials[1]>>nmc_Materials[2]>>nmc_Materials[3]>>nmc_Materials[4]>>nmc_Materials[5]
247 >>nmc_Materials[6]>>nmc_Materials[7]>>nmc_Materials[8]>>nmc_Materials[9]>>nmc_Materials[10]>>nmc_Materials[11]
248 >>nmc_Materials[12]>>nmc_Materials[13]>>nmc_Materials[14];
249 for (
int i=0; i < m_N_CgemLayer; i++)
251 std::getline(fin,strcom);
252 fin >>ncMaterials[i]>>tc_cu1[i]>>tc_kapton1[i]>>tc_epoxy0[i]>>tc_carbonf[i]>>tc_epoxy1[i]>>tc_honeycomb[i]>>tc_rohacell1[i]
253 >>tc_epoxy2[i]>>tc_kapton2[i]>>tc_epoxy3[i]>>tc_rohacell2[i]>>tc_epoxy4[i]>>tc_kapton3[i]>>tc_cu2[i];
255 cout <<
"Error : CgemGeomSvc::initGeom(), Number of materials in Cathode[Layer "<<i<<
"] is wrong!" << endl;
256 cout <<
"It must be less than " <<
N_MATERIAL_MAX <<
" and is " << ncMaterials[i] << endl;
257 cout <<
"please, either increase N_MATERIAL_MAX or decrease m_N_Cathode1_Materials" << endl;
262 double ngMaterials[3];
263 double tg_cu1[3],tg_kapton[3],tg_cu2[3],r_i_hole[3],r_o1_hole[3],r_o2_hole[3],l_hole[3];
264 double tg_gt1[3],tg_gt2[3],tg_gi[3];
265 std::getline(fin,strcom);
266 std::getline(fin,strcom);
267 for (
int i=0;i<m_N_CgemLayer;i++)
269 std::getline(fin,strcom);
270 fin>>tg_gt1[i]>>tg_gt2[i]>>tg_gi[i];
272 std::getline(fin,strcom);
273 std::getline(fin,strcom);
274 fin >>nmg_Materials[0]>>nmg_Materials[1]>>nmg_Materials[2]>>nmg_Materials[3];
275 for (
int i=0;i<m_N_CgemLayer;i++)
277 std::getline(fin,strcom);
278 fin>>ngMaterials[i]>>tg_cu1[i]>>tg_kapton[i]>>tg_cu2[i]>>r_i_hole[i]>>r_o1_hole[i]>>r_o2_hole[i]>>l_hole[i];
283 double naMaterials[3];
284 double ta_cu1[3],ta_kapton1[3],ta_cu2[3],ta_epoxy1[3],ta_kapton2[3],ta_epoxy2[3],ta_rohacell1[3];
285 double ta_carbonf1[3], ta_kapton3[3], ta_epoxy3[3], ta_honeycomb[3],ta_kapton4[3],ta_epoxy4[3],ta_rohacell2[3];
286 double ta_carbonf2[3],ta_epoxy5[3],ta_cu3[3],ta_kapton5[3], ta_kapton6[3], ta_cu4[3];
287 std::getline(fin,strcom);
288 std::getline(fin,strcom);
289 fin >>nma_Materials[0]>>nma_Materials[1]>>nma_Materials[2]>>nma_Materials[3]>>nma_Materials[4]>>nma_Materials[5]
290 >>nma_Materials[6]>>nma_Materials[7]>>nma_Materials[8]>>nma_Materials[9]>>nma_Materials[10]>>nma_Materials[11]
291 >>nma_Materials[12]>>nma_Materials[13]>>nma_Materials[14]>>nma_Materials[15]>>nma_Materials[16]>>nma_Materials[17]>>nma_Materials[18]
292 >>nma_Materials[19]>>nma_Materials[20];
293 for (
int i=0;i<m_N_CgemLayer;i++)
295 std::getline(fin,strcom);
296 fin >>naMaterials[i]>>ta_cu1[i]>>ta_kapton1[i]>>ta_cu2[i]>>ta_epoxy1[i]>>ta_kapton2[i]>>ta_epoxy2[i]>>ta_rohacell1[i]
297 >>ta_carbonf1[i]>>ta_kapton3[i]>>ta_epoxy3[i]>>ta_honeycomb[i]>>ta_kapton4[i]>>ta_epoxy4[i]>>ta_rohacell2[i]
298 >>ta_carbonf2[i]>>ta_epoxy5[i]>>ta_cu3[i]>>ta_kapton5[i]>>ta_kapton6[i]>>ta_cu4[i]
299 >>m_B_strip_x_on>>m_B_strip_v_on;
301 cout <<
"Error : CgemGeomSvc::initGeom(), Number of materials in Anode[L"<<i<<
"] is wrong!" << endl;
302 cout <<
"It must be less than " <<
N_MATERIAL_MAX <<
" and is " << naMaterials[i] << endl;
303 cout <<
"please, either increase N_MATERIAL_MAX or decrease N_Materials" << endl;
309 std::getline(fin, strcom);
310 std::getline(fin, strcom);
312 if(m_debugCout) cout <<
"cable density " << m_Rho_Cable << endl;
315 std::getline(fin, strcom);
316 std::getline(fin, strcom);
317 std::getline(fin, strcom);
318 double r_i_separator,r_o_separator,l_separator;
319 double t_al1,t_al2,t_carbonf;
320 fin >> r_i_separator >> r_o_separator >> l_separator;
322 std::getline(fin, strcom);
323 std::getline(fin, strcom);
324 fin >> t_al1 >> t_carbonf>> t_al2;
327 m_CgemSeparator->
setInnerR(r_i_separator);
328 m_CgemSeparator->
setOuterR(r_o_separator);
336 std::getline(fin, strcom);
337 std::getline(fin, strcom);
338 std::getline(fin, strcom);
339 fin >> m_R_i_Cgem >> m_R_o_Cgem >> m_L_Cgem;
341 std::getline(fin, strcom);
342 std::getline(fin, strcom);
343 std::getline(fin, strcom);
345 if(m_debugCout) cout <<
"Cgem passive elements are switched " << m_passive << endl;
347 double T_Cathode,T_Anode, T_GemFoil;
348 for (
int i=0; i < m_N_CgemLayer; i++) {
349 T_Cathode = tc_cu1[i]+tc_kapton1[i]+tc_epoxy0[i]+tc_carbonf[i]+tc_epoxy1[i]+tc_honeycomb[i]+tc_rohacell1[i]+tc_epoxy2[i]+tc_kapton2[i]+tc_epoxy3[i]+tc_rohacell2[i]+tc_epoxy4[i]+tc_kapton3[i]+tc_cu2[i];
350 m_T_Cathode[i] = T_Cathode;
352 T_Anode = ta_cu1[i]+ta_kapton1[i]+ta_cu2[i]+ta_epoxy1[i]+ta_kapton2[i]+ta_epoxy2[i]+ta_rohacell1[i]+ta_carbonf1[i]+ta_kapton3[i]+ta_epoxy3[i]+ta_honeycomb[i]+ta_kapton4[i]+ta_epoxy4[i]+ta_rohacell2[i]+ta_carbonf2[i]+ta_epoxy5[i]+ta_cu3[i]+ta_kapton5[i]+ta_kapton6[i]+ta_cu4[i];
353 m_T_Anode[i] = T_Anode;
355 T_GemFoil = tg_cu1[i]+tg_kapton[i]+tg_cu2[i];
356 m_T_CgemLayer[i] = T_Cathode+ gap_d[i] + tg_gt1[i] + tg_gt2[i] + tg_gi[i] + T_GemFoil*3 + T_Anode;
360 cout << left <<
"R_CgemLayer " << left <<
"L_CgemLayer "
361 << left <<
"N_Sheet " << left <<
"W_Sheet "
362 << left <<
"A_Stereo " << left <<
"W_Pitch_X "
363 << left <<
"W_Pitch_V "<< left <<
"W_Strip_X "
364 << left <<
"W_Strip_V "<< left <<
"N_Channel_Phi "
365 << left <<
"N_Channel_V " << left <<
"Orientation " << endl;
379 cout << left <<
"T_Cathode L"<<i << left <<
"T_GemFoil L"<<i << left <<
"T_Anode L"<<i
380 << left <<
"T_CgemLayer "<<i << endl;
381 cout << left << setw(10) << T_Cathode << left << setw(10) << T_GemFoil
382 << left << setw(8) << T_Anode << left << setw(9) << m_T_CgemLayer[i] << endl;
386 cout <<
"thickness " << m_T_CgemLayer[i] << endl;
391 m_CgemLayer[i]->
setOuterROfCgemLayer(m_CgemLayer[i]->getInnerROfCgemLayer() + m_T_CgemLayer[i]);
395 if(fReversed ==
false) {
397 m_CgemLayer[i]->
setOuterROfCathode( m_CgemLayer[i]->getInnerROfCgemLayer() + T_Cathode);
400 m_CgemLayer[i]->
setInnerROfCathode( m_CgemLayer[i]->getOuterROfCgemLayer() - T_Cathode);
416 inner_r_cathode[imat]+=tc_cu1[i];
421 inner_r_cathode[imat]+=tc_kapton1[i];
426 inner_r_cathode[imat]+=tc_epoxy0[i];
431 inner_r_cathode[imat]+=tc_carbonf[i];
436 inner_r_cathode[imat]+=tc_epoxy1[i];
441 inner_r_cathode[imat]+=tc_honeycomb[i];
446 inner_r_cathode[imat]+=tc_rohacell1[i];
451 inner_r_cathode[imat]+=tc_epoxy2[i];
456 inner_r_cathode[imat]+=tc_kapton2[i];
461 inner_r_cathode[imat]+=tc_epoxy3[i];
466 inner_r_cathode[imat]+=tc_rohacell2[i];
471 inner_r_cathode[imat]+=tc_epoxy4[i];
476 inner_r_cathode[imat]+=tc_kapton3[i];
481 inner_r_cathode[imat]+=tc_cu2[i];
483 if(m_debugCout) cout <<
" CATHODE CU INNER " << inner_r_cathode[imat] <<
" OUTER " << inner_r_cathode[imat]+tc_cu2[i] << endl;
492 if(m_debugCout) cout <<
"breaking" << endl;
495 inner_r_cathode[imat + 1] = inner_r_cathode[imat];
496 if(fReversed ==
false) counter++;
501 cout <<
"T_cathode: " << setw(15) <<T_Cathode;
536 if(fReversed ==
false) {
537 if (fabs((m_CgemLayer[i]->getOuterROfCathode() / m_CgemLayer[i]->getOuterROfCathodeCu2()) - 1) > FLT_EPSILON){
538 cout << fabs(m_CgemLayer[i]->getOuterROfCathode() - m_CgemLayer[i]->getOuterROfCathodeCu2()) << endl;
541 <<
", FLT_EPSILON = " << FLT_EPSILON << endl;
542 cout <<
"Error : CgemGeomSvc::initGeom(), Cathode size is wrong!" << endl;
547 if (fabs((m_CgemLayer[i]->getInnerROfCathode() / m_CgemLayer[i]->getInnerROfCathodeCu1()) - 1) > FLT_EPSILON){
548 cout << fabs(m_CgemLayer[i]->getInnerROfCathode() - m_CgemLayer[i]->getInnerROfCathodeCu1()) << endl;
551 <<
", FLT_EPSILON = " << FLT_EPSILON << endl;
552 cout <<
"Error : CgemGeomSvc::initGeom(), Cathode size is wrong!" << endl;
558 if(fReversed ==
false) {
559 m_CgemLayer[i]->
setInnerROfGapD( m_CgemLayer[i]->getOuterROfCathode() );
560 m_CgemLayer[i]->
setOuterROfGapD( m_CgemLayer[i]->getOuterROfCathode() + gap_d[i] );
561 m_CgemLayer[i]->
setInnerROfGapT1( m_CgemLayer[i]->getOuterROfGapD() + tg_cu1[i]+tg_kapton[i]+tg_cu2[i] );
562 m_CgemLayer[i]->
setOuterROfGapT1( m_CgemLayer[i]->getInnerROfGapT1() + tg_gt1[i] );
563 m_CgemLayer[i]->
setInnerROfGapT2( m_CgemLayer[i]->getOuterROfGapT1() + tg_cu1[i]+tg_kapton[i]+tg_cu2[i]);
564 m_CgemLayer[i]->
setOuterROfGapT2( m_CgemLayer[i]->getInnerROfGapT2() + tg_gt2[i] );
565 m_CgemLayer[i]->
setInnerROfGapI( m_CgemLayer[i]->getOuterROfGapT2() + tg_cu1[i]+tg_kapton[i]+tg_cu2[i] );
566 m_CgemLayer[i]->
setOuterROfGapI( m_CgemLayer[i]->getInnerROfGapI() + tg_gi[i]);
569 m_CgemLayer[i]->
setOuterROfGapD( m_CgemLayer[i]->getInnerROfCathode() );
570 m_CgemLayer[i]->
setInnerROfGapD( m_CgemLayer[i]->getInnerROfCathode() - gap_d[i]);
571 m_CgemLayer[i]->
setOuterROfGapT1( m_CgemLayer[i]->getInnerROfGapD() - tg_cu1[i]-tg_kapton[i]-tg_cu2[i]);
572 m_CgemLayer[i]->
setInnerROfGapT1( m_CgemLayer[i]->getOuterROfGapT1() - tg_gt1[i]);
573 m_CgemLayer[i]->
setOuterROfGapT2( m_CgemLayer[i]->getInnerROfGapT1() - tg_cu1[i]-tg_kapton[i]-tg_cu2[i] );
574 m_CgemLayer[i]->
setInnerROfGapT2( m_CgemLayer[i]->getOuterROfGapT2() - tg_gt2[i]);
575 m_CgemLayer[i]->
setOuterROfGapI( m_CgemLayer[i]->getInnerROfGapT2() - tg_cu1[i]-tg_kapton[i]-tg_cu2[i]);
576 m_CgemLayer[i]->
setInnerROfGapI( m_CgemLayer[i]->getOuterROfGapI() - tg_gi[i]);
581 cout <<
"Geom foil&gap " << setw(15) << gap_d[i] << setw(15)
582 << tg_cu1[i]+tg_kapton[i]+tg_cu2[i] << setw(15) << tg_gt1[i]
583 << setw(15) << tg_gt2[i] << setw(15) << tg_gi[i] << endl;
585 cout <<
"gaps: -----------------------------" << endl;
597 if (m_N_GemFoil != 3){
598 cout <<
"Error : CgemGeomSvc::initGeom(), GemFoil number in code is 3! If m_N_GemFoil != 3,you should modify the code,especially the gap information!" << endl;
602 double R_i_GemFoil[3] = {0};
603 if(fReversed ==
false) {
614 for(
int j=0; j < m_N_GemFoil; j++){
622 double m_t_foil_list[
N_MATERIAL_MAX] = {tg_cu1[i], tg_kapton[i], tg_cu2[i]};
624 inner_r_foil[0] = R_i_GemFoil[j];
626 if(fReversed ==
true) counter = ngMaterials[i] - 1;
634 for(
int imat = 0; imat < ngMaterials[i]; imat++) {
635 outer_r_foil[imat] = inner_r_foil[imat] + m_t_foil_list[counter];
655 if(imat == ngMaterials[i] - 1) {
656 if(m_debugCout) cout <<
"breaking" << endl;
659 inner_r_foil[imat + 1] = outer_r_foil[imat];
660 if(fReversed ==
false) counter++;
671 cout <<
"Geom foil: layer " << i <<
" " << j << endl;
672 cout << setw(15) << tg_cu1[i] << setw(15)
673 << tg_kapton[i] << setw(15) << tg_cu2[i] << endl;
690 cout <<
"GEM" << endl;
700 cout <<
"GEM" << endl;
712 if(fReversed ==
false) {
714 m_CgemLayer[i]->
setOuterROfAnode( m_CgemLayer[i]->getOuterROfGapI() + T_Anode );
717 m_CgemLayer[i]->
setInnerROfAnode( m_CgemLayer[i]->getInnerROfGapI() - T_Anode);
727 ta_cu1[i],ta_kapton1[i],ta_cu2[i],ta_epoxy1[i],ta_kapton2[i],ta_epoxy2[i],ta_rohacell1[i],ta_carbonf1[i],ta_kapton3[i],ta_epoxy3[i],ta_honeycomb[i],ta_kapton4[i],ta_epoxy4[i],ta_rohacell2[i],ta_carbonf2[i],ta_epoxy5[i],ta_cu3[i],ta_kapton5[i],ta_kapton6[i],ta_cu4[i]
735 outer_r_anode[imat] = inner_r_anode[imat] + m_t_anode_list[counter];
824 if(m_debugCout) cout <<
"breaking" << endl;
827 inner_r_anode[imat + 1] = outer_r_anode[imat];
828 if(fReversed ==
false) counter++;
833 cout <<
"ANODE: " << endl;
876 cout <<
"X strip description is " << m_B_strip_x_on <<
" and V strip description is " << m_B_strip_v_on << endl;
880 if(fReversed ==
false) {
881 if(fabs((m_CgemLayer[i]->getOuterROfAnode() / m_CgemLayer[i]->getOuterROfCgemLayer())-1) > FLT_EPSILON){
882 cout << fabs(m_CgemLayer[i]->getOuterROfAnode() - m_CgemLayer[i]->getOuterROfCgemLayer()) << endl;
883 cout << FLT_EPSILON << endl;
884 cout <<
"Error : CgemLayer size is wrong!" << endl;
889 if(fabs((m_CgemLayer[i]->getInnerROfAnode() / m_CgemLayer[i]->getInnerROfCgemLayer())-1) > FLT_EPSILON){
890 cout << fabs(m_CgemLayer[i]->getInnerROfAnode() - m_CgemLayer[i]->getInnerROfCgemLayer()) << endl;
891 cout << FLT_EPSILON << endl;
892 cout <<
"Error : CgemLayer size is wrong!" << endl;
898 m_CgemLayer[i]->
print();
908 double width_sheet=rXstrips*CLHEP::twopi/nSheet;
909 if(m_debugCout) cout<<
"construct CgemReadoutPlanes: "<<endl;
913 for(
int j=0; j<nSheet; j++){
914 if(m_debugCout) cout<<
"------ layer "<<i<<
", sheet "<<j<<
" ------ "<<endl;
915 double rStrips = 0.5*(rXstrips+rVstrips);
916 dX_start_strip[i][j]=(2.*
M_PI*rStrips-m_CgemLayer[i]->
getNumberOfChannelX()*m_CgemLayer[i]->getWidthOfPitchX())/(2.*nSheet)*rXstrips/rStrips;
919 phi_start[i][j], dX_start_strip[i][j],
920 dV_start_strip[i][j],
922 -0.5*m_CgemLayer[i]->getLengthOfCgemLayer(),
923 m_CgemLayer[i]->getLengthOfCgemLayer(),
924 m_CgemLayer[i]->getNumberOfChannelX()/nSheet,
925 m_CgemLayer[i]->getNumberOfChannelV()/nSheet,
926 m_CgemLayer[i]->getWidthOfPitchX(),
927 m_CgemLayer[i]->getWidthOfStripX(),
928 m_CgemLayer[i]->getWidthOfPitchV(),
929 m_CgemLayer[i]->getWidthOfStripV(),
930 m_CgemLayer[i]->getAngleOfStereo(),
931 m_CgemLayer[i]->getMiddleROfGapD(),
932 m_CgemLayer[i]->getOuterROfGapD()
938 if(m_debugCout) cout <<
"INFO : CgemGeomSvc::initGeom(), Successfully input geometry parameters!" << endl;
947 cout <<
"====================CGEM Information=========================" << endl;
948 cout <<
"R_i_Cgem " <<
"R_o_Cgem " <<
"L_Cgem" << endl;
949 cout << left << setw(10) << m_R_i_Cgem
950 << left << setw(10) << m_R_o_Cgem
951 << left << setw(10) << m_L_Cgem << endl;
952 cout <<
"====================CGEM Information End!====================" << endl;
956 cout <<
"************************ FINAL CHECK OF THE DIMENSIONS" << endl;
957 for(
int ilayer = 0; ilayer < 3; ilayer++) {
960 cout <<
"inner global radius of layer" << ilayer <<
": " << m_CgemLayer[ilayer]->
getInnerROfCgemLayer()
965 for(
int ifoil = 0; ifoil < 3; ifoil++) {
966 cout <<
"inner radius of gem" << ifoil <<
": " << m_foil[ilayer][ifoil]->
getInnerROfCgemFoil()
970 cout <<
"inner radius of anode: " << m_CgemLayer[ilayer]->
getInnerROfAnode()