// Used MvdUtil as a template // Hubert van Hecke July 2001 // #include "MvdGeoRd.hh" #include "fstream.h" //----------------------------------------------------------- // Author : Hubert van Hecke //----------------------------------------------------------- // Read the mvd geometry from a data base or file // Based on the fortran version // Input: data base file // load it into a geometry data structure //----------------------------------------------------------- const int MAX = 132; // max line length int mvdread(int date){ int istat, jdate; char line[MAX], line2[MAX]; char aconfig[650]; char all_names[350]; // list the volume float p1,p2,p3,p4,p5,p6,p7,p8,p9,p10; if (date > 20010101){ cout <<"\n MvdGeoRd: MVD year-2 configuration for date "<< date << endl; strcpy(aconfig, // translate aconfig to imcm(1->12,IB->OT,E->W) // <-----SOUTH----> <-----NORTH----> // pads 1 2 3 4 5 6 7 8 9 10 11 12 pads // ------+--------------------------------------+------------------------- " 0 | 0 0 0 1 1 1 1 1 1 0 0 0 | 1 \n"// IT " 0 | 0 0 0 1 1 1 1 1 1 0 0 0 | 1 \n"// IM " 0 | 0 1 1 1 1 1 1 1 1 1 1 0 | 1 \n"// IB " 0 | 0 1 1 1 1 1 1 1 1 1 1 0 | 1 \n"// OB EAST " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OM " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OT //----------+--------------------------------------+------------------------- " 0 | 0 0 0 0 1 1 1 1 0 0 0 0 | 1 \n"// IT " 0 | 0 0 0 1 1 1 1 1 1 0 0 0 | 1 \n"// IM " 0 | 0 1 1 1 1 1 1 1 1 1 1 0 | 1 \n"// IB WEST " 0 | 0 1 1 1 1 1 1 1 1 1 1 0 | 1 \n"// OB " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OM " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n");// OT //----------+--------------------------------------+------------------------- // 123456789\123456789\123456789\123456789\123456789\ // List the volume strcpy(all_names, // names we need to "HALL 1" "VERT 1" // make this config. "VCG0 1" "VCG0 2" "VCG0 3" "VCG0 4" "VCG0 5" "VCG0 6" // 24 cages "VCG0 7" "VCG0 8" "VCG0 9" "VCG0 10" "VCG0 11" "VCG0 12" "VCG0 13" "VCG0 14" "VCG0 15" "VCG0 16" "VCG0 17" "VCG0 18" "VCG0 19" "VCG0 20" "VCG0 21" "VCG0 22" "VCG0 23" "VCG0 24" // And the silicon: "VSI4 1" "VSI4 2" "VSI4 3" "VAI4 1" "VSO4 1" "VAO4 1" // '4'-cage "VSI3 1" "VSI3 2" "VAI3 1" "VSO3 1" "VAO3 1" // '3'-cage "VSI2 1" "VAI2 1" "VSO2 1" "VAO2 1" // '2'-cage "VPMB 1" "VPMB 2" "VPAD 1"); // pads } else if (date > 20000101){ cout <<"\n MvdGeoRd: MVD year-1 configuration for date "<< date << endl; strcpy(aconfig, // translate aconfig to imcm(1->12,IB->OT,E->W) // <-----SOUTH----> <-----NORTH----> // pads 1 2 3 4 5 6 7 8 9 10 11 12 pads // ------+--------------------------------------+------------------------- " 0 | 0 0 0 0 0 0 1 1 1 0 0 0 | 1 \n"// IT " 0 | 0 0 0 0 0 0 1 1 1 0 0 0 | 1 \n"// IM " 0 | 0 0 0 0 0 0 1 1 1 1 1 0 | 1 \n"// IB " 0 | 0 0 0 0 0 0 1 1 1 1 1 0 | 1 \n"// OB EAST " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OM " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OT //----------+--------------------------------------+------------------------- " 0 | 0 0 0 0 0 0 1 1 0 0 0 0 | 1 \n"// IT " 0 | 0 0 0 0 0 0 1 1 1 0 0 0 | 1 \n"// IM " 0 | 0 0 0 0 0 0 1 1 1 1 1 0 | 1 \n"// IB WEST " 0 | 0 0 0 0 0 0 1 1 1 1 1 0 | 1 \n"// OB " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n"// OM " 0 | 0 0 0 0 0 0 0 0 0 0 0 0 | 1 \n");// OT //----------+--------------------------------------+------------------------- // 123456789\123456789\123456789\123456789\123456789\ // list the volume strcpy(all_names, // names we need to "HALL 1" "VERT 1" // make this config. "VCG0 1" "VCG0 2" "VCG0 3" "VCG0 4" "VCG0 5" "VCG0 6" // 24 cages "VCG0 7" "VCG0 8" "VCG0 9" "VCG0 10" "VCG0 11" "VCG0 12" "VCG0 13" "VCG0 14" "VCG0 15" "VCG0 16" "VCG0 17" "VCG0 18" "VCG0 19" "VCG0 20" "VCG0 21" "VCG0 22" "VCG0 23" "VCG0 24" // And the silicon: "VSI4 1" "VSI4 2" "VSI4 3" "VAI4 1" "VSO4 1" "VAO4 1" // '4'-cage "VSI3 1" "VSI3 2" "VAI3 1" "VSO3 1" "VAO3 1" // '3'-cage "VSI2 1" "VAI2 1" "VSO2 1" "VAO2 1" // '2'-cage "VPMB 1" "VPMB 2" "VPAD 1"); // pads } else{ cout <<"\n MvdGeoRd: MVD year-? configuration for date" << date << endl; strcpy(aconfig, // translate aconfig to imcm(1->12,IB->OT,E->W) // <-----SOUTH----> <-----NORTH----> // pads 1 2 3 4 5 6 7 8 9 10 11 12 pads // ------+--------------------------------------+------------------------- " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IT " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IM " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IB " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// OB EAST " 1 | 1 1 0 0 0 0 0 0 0 0 1 1 | 1 \n"// OM " 1 | 1 1 0 0 0 0 0 0 0 0 1 1 | 1 \n"// OT //----------+--------------------------------------+------------------------- " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IT " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IM " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// IB WEST " 1 | 1 1 1 1 1 1 1 1 1 1 1 1 | 1 \n"// OB " 1 | 1 1 0 0 0 0 0 0 0 0 1 1 | 1 \n"// OM " 1 | 1 1 0 0 0 0 0 0 0 0 1 1 | 1 \n");// OT //----------+--------------------------------------+------------------------- // 123456789\123456789\123456789\123456789\123456789\ // list the volume strcpy(all_names, // names we need to "HALL 1" "VERT 1" // make this config. "VCG0 1" "VCG0 2" "VCG0 3" "VCG0 4" "VCG0 5" "VCG0 6" // 24 cages "VCG0 7" "VCG0 8" "VCG0 9" "VCG0 10" "VCG0 11" "VCG0 12" "VCG0 13" "VCG0 14" "VCG0 15" "VCG0 16" "VCG0 17" "VCG0 18" "VCG0 19" "VCG0 20" "VCG0 21" "VCG0 22" "VCG0 23" "VCG0 24" // And the silicon: "VSI4 1" "VSI4 2" "VSI4 3" "VAI4 1" "VSO4 1" "VAO4 1" // '4'-cage "VSI6 1" "VSI6 2" "VSI6 3" "VAI6 1" "VSO6 1" "VSO6 2" // '6'-cage "VSO6 3" "VAO6 1" // "VPMB 1" "VPMB 2" "VPAD 1" " "); // pads } // end of date-based configuration definition cout << " aconfig: \n"<< aconfig << endl; int imcm[13][7][3]; // 12 in z, 6 in phi, 2 in East-West int jconfig = 0; // now translate string aconfig squeeze (aconfig); // remove blanks etc. for (int iew=1; iew<=2; iew++){ // copy into 3D array imcm for (int igrp=1; igrp<=6; igrp++){ // loop over z, group and east- for (int iz=0; iz<=13; iz++){ // -west. if (iz>=1 && iz<=12){ imcm[iz][igrp][iew] = int(aconfig[jconfig]) - int('0'); } // MCM groups 1-6 // else if (iz==0) // south pads // else if (iz==13) // north pads jconfig++; } // loop over z 1+12+1 } // loop over group 1-6 } // loop over east,west cout << "imcm 3,2,2= " << imcm[3][2][2] << endl; cout << "imcm 4,2,2= " << imcm[4][2][2] << endl; cout << "imcm 11,4,1= " << imcm[11][4][1] << endl; cout << "imcm 11,5,1= " << imcm[11][5][1] << endl; int ivol = index(all_names,"HALL 1")/7 +1; cout <<" HALL 1 position: "<=0){ // name was requested //cout << line << "\n"; char mother[5]; float xyz[3], x, y, z; int irot, iseen, icol; char only[5]; char comm[2]; // get the rest: istat = parseline(line,6, mother, x, y, z, irot, only, iseen, icol, comm); cout << jdate<<" "< 0 && jdate <= 501230) jdate = jdate + 20000000; else if (jdate >= 501231 && jdate <= 991231) jdate = jdate + 19000000; return 1; // } // end parseline ( ,1, ) //==========================================================================// void squeeze(char* line){ //--------------------------------------------------------------------------// // This function removes blanks, newlines and | from the input // string 'line' and returns 'line' with null after the last // non-blank character. // July 2001 HvH //--------------------------------------------------------------------------// int slen = strlen(line); char line2[slen]; int k=0; for (int j=0; j= 0) return 1; return 0; } // end is_comment //==========================================================================// int index(char* line, char* elem){ int lenline = strlen(line); int lenelem = strlen(elem); int i=0; int j; // declare outside while loop while (i<=lenline-lenelem){ j=0; while (j<=lenelem){ if (line[i+j] != elem[j]) break; j++; } if (j==lenelem) break; i++; } //end while if ((i+lenelem-1 == lenline) && (j != lenelem+1)) i = -lenelem; return i; } // end index //==========================================================================//