//Generator for CbmTrd Geometry //Update 20.11.08 //Changes made that geometry is now independent of //Trd-positions. //F. Uhlig #include #include #include #include #include #include #define PI 3.14159265 FILE *geofile; FILE *infofile; FILE *parameterfile; using namespace std; int TrdModules1(int, int, float, float, int, float, float*); //-------------------------------------------------------------------- int TrdModules1(int Station_number, int Layer_number, float frame_width, float Layer_thickness, int Chamber_number, float Position_Station1[][4], float* Detector_size_x) { // create box of air with size of 'Detector_size_x[0] x Detector_size_y[0]' and fill // this box with the // radiator, mylar foil, gas, pad plane which have a size of 'Active_area_x[0] x Active_area_y[0]' // the frames which have a width of 'frame_width' and are at the outer edges of the box bool first_time_Module1 = true; bool first_time_Module2 = true; bool first_time_Module3 = true; int Copy_number_Module1 = 1; int Copy_number_Module2 = 1; int Copy_number_Module3 = 1; int copy_number; float Active_area_x[3]; float Active_area_y[3]; Active_area_x[0] = Detector_size_x[0] - frame_width; Active_area_y[0] = Detector_size_x[0] / 2 - frame_width; Active_area_x[1] = Detector_size_x[1] - frame_width; Active_area_y[1] = Detector_size_x[1] / 2 - frame_width; Active_area_x[2] = Detector_size_x[2] - frame_width; Active_area_y[2] = Detector_size_x[2] / 2 - frame_width; float radiator_thickness = 14.5; float radiator_position = -15.5; float gas_thickness = 3.; float gas_position = 2.; float padplane_thickness = 0.015; float padplane_position = 5.015; float mylar_thickness = 0.75; float mylar_position = 5.78; float electronics_thickness = 0.035; float electronics_position = 6.565; float frame_thickness = 18.300; float frame_position = -11.7; for (int i=0; i< Chamber_number; i++){ int module_number = (int)Position_Station1[i][2]; int j = (int)Position_Station1[i][2]-1; if ( (first_time_Module1 && ( module_number == 1 )) || (first_time_Module2 && ( module_number == 2 )) || (first_time_Module3 && ( module_number == 3 ))) { if (first_time_Module1 && ( module_number == 1 ) ) { copy_number = Copy_number_Module1; } if (first_time_Module2 && ( module_number == 2 ) ) { copy_number = Copy_number_Module2; } if (first_time_Module3 && ( module_number == 3 ) ) { copy_number = Copy_number_Module3; } printf("Bin zum ersten mal hier. \n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number ,copy_number); fprintf(geofile,"trd%dlayer#%d\n",Station_number, Layer_number+1); fprintf(geofile,"BOX\n"); fprintf(geofile,"air\n"); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,-Detector_size_x[j]/2 , -Layer_thickness/2); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,Detector_size_x[j]/2 , -Layer_thickness/2); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,Detector_size_x[j]/2 , -Layer_thickness/2); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,-Detector_size_x[j]/2 , -Layer_thickness/2); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,-Detector_size_x[j]/2 , Layer_thickness/2); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,Detector_size_x[j]/2 , Layer_thickness/2); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,Detector_size_x[j]/2 , Layer_thickness/2); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,-Detector_size_x[j]/2 , Layer_thickness/2); fprintf(geofile,"%f %f %f\n", Position_Station1[i][0], Position_Station1[i][1], 0.); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dradiator\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"polypropylene\n"); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , -radiator_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , -radiator_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , -radiator_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , -radiator_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , radiator_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , radiator_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , radiator_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , radiator_thickness); fprintf(geofile,"%f %f %f\n",0. ,0. ,radiator_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dgas\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"TRDgas\n"); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , -gas_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , -gas_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , -gas_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , -gas_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , gas_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , gas_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , gas_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , gas_thickness); fprintf(geofile,"%f %f %f\n", 0., 0., gas_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dpadplane\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"goldcoatedcopper\n"); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] ,- padplane_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , -padplane_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] ,- padplane_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , -padplane_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , padplane_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , padplane_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , padplane_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , padplane_thickness); fprintf(geofile,"%f %f %f\n", 0., 0., padplane_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dmylar\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"mylar\n"); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , -mylar_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , -mylar_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , -mylar_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , -mylar_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , mylar_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , mylar_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , mylar_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , mylar_thickness); fprintf(geofile,"%f %f %f\n", 0., 0., mylar_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%delectronics\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"goldcoatedcopper\n"); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , -electronics_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , -electronics_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , -electronics_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , -electronics_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,-Active_area_y[j] , electronics_thickness); fprintf(geofile,"%f %f %f\n",Active_area_x[j] ,Active_area_y[j] , electronics_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,Active_area_y[j] , electronics_thickness); fprintf(geofile,"%f %f %f\n",-Active_area_x[j] ,-Active_area_y[j] , electronics_thickness); fprintf(geofile,"%f %f %f\n", 0., 0., electronics_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); if ( frame_width > 0.) { fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dcarbon1#1\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"carbon\n"); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,-frame_width/2 , -frame_thickness); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,frame_width/2 , -frame_thickness); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,frame_width/2 , -frame_thickness); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,-frame_width/2 , -frame_thickness); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,-frame_width/2 , frame_thickness); fprintf(geofile,"%f %f %f\n",Detector_size_x[j] ,frame_width/2 , frame_thickness); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,frame_width/2 , frame_thickness); fprintf(geofile,"%f %f %f\n",-Detector_size_x[j] ,-frame_width/2 , frame_thickness); fprintf(geofile,"%f %f %f\n", 0., (Active_area_y[j] + frame_width / 2 ), frame_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dcarbon1#2\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"%f %f %f\n", 0., -(Active_area_y[j] + frame_width / 2 ), frame_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dcarbon2#1\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"BOX\n"); fprintf(geofile,"carbon\n"); fprintf(geofile,"%f %f %f\n", frame_width/2, -Active_area_y[j], -frame_thickness); fprintf(geofile,"%f %f %f\n", frame_width/2, Active_area_y[j], -frame_thickness); fprintf(geofile,"%f %f %f\n", -frame_width/2, Active_area_y[j], -frame_thickness); fprintf(geofile,"%f %f %f\n", -frame_width/2, -Active_area_y[j], -frame_thickness); fprintf(geofile,"%f %f %f\n", frame_width/2, -Active_area_y[j], frame_thickness); fprintf(geofile,"%f %f %f\n", frame_width/2, Active_area_y[j], frame_thickness); fprintf(geofile,"%f %f %f\n", -frame_width/2, Active_area_y[j], frame_thickness); fprintf(geofile,"%f %f %f\n", -frame_width/2, -Active_area_y[j], frame_thickness); fprintf(geofile,"%f %f %f\n", (Active_area_x[j] + frame_width / 2 ), 0., frame_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%dcarbon2#2\n",Station_number, module_number); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"%f %f %f\n", -(Active_area_x[j] + frame_width / 2 ), 0., frame_position); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); } if (first_time_Module1 && ( module_number == 1 )) { first_time_Module1=false; Copy_number_Module1 = copy_number+1 ; } if (first_time_Module2 && ( module_number == 2 ) ) { first_time_Module2=false; Copy_number_Module2 = copy_number+1 ; } if (first_time_Module3 && ( module_number == 3 ) ) { first_time_Module3=false; Copy_number_Module3 = copy_number+1 ; } } else { if ( module_number == 1 ) { copy_number = Copy_number_Module1; } else if ( module_number == 2 ) { copy_number = Copy_number_Module2; } else if ( module_number == 3 ) { copy_number = Copy_number_Module3; } else { printf("There is something wrong. We don't have more than three different detector sizes\n"); printf("Break in TrdModules1.\n"); return 1; } fprintf(geofile,"//*********************************\n"); fprintf(geofile,"trd%dmod%d#%d\n",Station_number, module_number,copy_number); fprintf(geofile,"trd%dlayer#%d\n",Station_number, Layer_number+1); fprintf(geofile,"%f %f %f\n", Position_Station1[i][0], Position_Station1[i][1], 0.); if (Position_Station1[i][3] == 0) { //horizontal position fprintf(geofile,"1. 0. 0. 0. 1. 0. 0. 0. 1.\n"); } else { // vertical position fprintf(geofile,"0. 1. 0. -1. 0. 0. 0. 0. 1.\n"); } fprintf(geofile,"//*********************************\n"); if ( module_number == 1 ) { Copy_number_Module1 = copy_number+1 ; } if ( module_number == 2 ) { Copy_number_Module2 = copy_number+1 ; } if ( module_number == 3 ) { Copy_number_Module3 = copy_number+1 ; } } } return 0; } int main(void) { const char* c_str(); //-----------Files------------------------------------------------ string path = "./"; string geoname = path + "trd_segmented.geo" ; string infoname = path + "trd_segmented.info"; string parametername = path + "trd_segmented.txt"; geofile = fopen(geoname.c_str(), "w+"); infofile = fopen(infoname.c_str(), "w+"); parameterfile = fopen(parametername.c_str(), "w+"); //---------- Declaration of parameters --------------------------------------- float Distance[3]; // Distance between target an the front of the TRD stations float Station_thickness; // Thickness of one TRD station float Layer_thickness; // Thickness of one layer of a TRD station int Layer_number; // Number of detector layers per station int Station_number; // Number of TRD stations in the setup float Detector_size_x[3]; // length in mm of a detector module in x-direction float Detector_size_y[3]; // length in mm of a detector module in y-direction float Frame_width; // Width of detector frames in mm float Inner_radius[3]; // Inner acceptance in mm float Outer_radius[3]; // Outer acceptance in mm //--------- Initialization of parameters ------------------------------------- // Distance[0] = 4000; // Distance[1] = 6750; // Distance[2] = 9500; Distance[0] = 5000; Distance[1] = 7250; Distance[2] = 9500; Station_number = 3; Layer_number = 4; Layer_thickness = 60; Station_thickness = Layer_number * Layer_thickness; float Inner_acceptance[3] = {50, 50, 50}; float Outer_acceptance[3] = {500, 500, 500}; // Frame_width = 20; Frame_width = 0; //--------- Basic calculations ---------------------------------------------- // Here the size of the detector is calculated on the basis of the acceptance // which ranges from 50 to 500 mrad. // There is also a check if the detector station overlaps with the beampipe // Some basic information of the setup are written to the geofile fprintf(geofile,"//*********************************\n"); fprintf(geofile,"// This is the geometry file of the following configuration\n"); fprintf(geofile,"// Number of stations: %d\n",Station_number); fprintf(geofile,"// Number of layers per station: %d\n",Layer_number); fprintf(geofile,"//*******************************************\n"); for(int i = 0; i < Station_number; i++) { float bla=Inner_acceptance[i]/1000.; float bla1=Outer_acceptance[i]/1000.; // F.U. 20.02.07 // Outer radius increased by factor 1.5 to keep all modules in th // keeping volume since the size in y-direction // was increased by a factor of 1.5 // There is also a problem with the inner radius of station 2 which is // to large at the standard distance from the target. this has to be lower // by 12 cm Inner_radius[i] = Distance[i]*tan(bla); if ( i== 1 ) { Inner_radius[i] = 250.; } //Outer_radius[i] = Distance[i]*tan(bla1); Outer_radius[i] = Distance[i]*tan(bla1)*1.6; float radius_beampipe = 200.5; // constant radius after RICH if (Inner_radius[i] <= radius_beampipe) { printf("radius beampipe: %f\n",radius_beampipe); printf("inner radius trd: %f\n",Inner_radius[i]); Inner_radius[i]=radius_beampipe + 5; printf("Inner radius of trd station %d was inside the beam pipe. Increased radius to %f\n", i+1, Inner_radius[i]); } printf("inner radius trd: %f\n",Inner_radius[i]); printf("outer radius trd: %f\n",Outer_radius[i]); fprintf(geofile,"// Inner Radius of station %d: %f\n",i+1,Inner_radius[i]); fprintf(geofile,"// Outer Radius of station %d: %f\n",i+1,Outer_radius[i]); fprintf(geofile,"// z-position at the middle of the station %d: %f\n",i+1, Distance[i]+(Station_thickness/2)); fprintf(geofile,"//*******************************************\n"); } // Calculate the sizes of all three detector modules. All sizes depend on the radius // of the inner acceptance of the first station. // At least this is correct is the stations are at 5000, 7250 and 9500 mm. If this is // still okay when the stations are shifted has to be checked. Detector_size_x[0] = roundf(Inner_radius[0]); if ((int)Detector_size_x[0]%2) Detector_size_x[0]++; // Calculate size of the complete detector with frames in x-direction which is the double // size of the inner acceptance for geometrical reasons. The y-direction is twice as much // as the length in x-direction Detector_size_x[0] *= 2; Detector_size_y[0] = Detector_size_x[0] * 2; // Calculate the sizes of the lager detector modules according to the size of the smallest // modules. The calculations follow the geometrical layout of the stations. Detector_size_y[1] = Detector_size_y[0] * 3 / 2 ; Detector_size_x[1] = Detector_size_x[0] * 3 / 2 ; Detector_size_y[2] = Detector_size_y[0] * 2 ; Detector_size_x[2] = Detector_size_x[0] * 2 ; // calculate positions of small chambers in the first station // This is done according the geometrical layout of this station float x1 = Detector_size_x[0]; float y1 = 2 * Detector_size_x[0] + Detector_size_x[1] + Detector_size_x[2]; float x2 = Detector_size_x[0] / 2; float y2 = Detector_size_x[0]; float x3 = Detector_size_x[1]; float y3 = Detector_size_x[1] * 3 / 2; float x4 = Detector_size_x[2] / 2; float y4 = Detector_size_x[2] * 2; float x5 = Detector_size_x[2] * 3 / 2; float y5 = Detector_size_x[2] * 2; float x6a = Detector_size_x[2] * 7 /2; float y6a = Detector_size_x[2] * 2; float x7a = Detector_size_x[2] * 7 /2; float y7a = Detector_size_x[2]; float x8a = Detector_size_x[2] * 7 /2; float y8a = 0; cout << x1 <<" , " << y1 <<" , " << x2 <<" , " << y2 <<" , " << x3 <<" , " << y3 << endl; cout << x4 <<" , " << y4 <<" , " << x5 <<" , " << y5 << endl; cout << x6a <<" , " << y6a <<" , " << x7a <<" , " << y7a <<" , " << x8a <<" , " << y8a <