30 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Failed to open '%s' field! \033[0m",
38 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Failed to import '%s' field! \033[0m",
56 DIR *curr_dir = opendir(dirName.Data());
58 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Directory '%s' does not exist! \033[0m",
63 struct dirent *curr_file;
66 while((curr_file = readdir(curr_dir))) {
67 int len = strlen(curr_file->d_name);
69 if (len >= extention_len &&
70 !memcmp(curr_file->d_name + len - extention_len,
73 TString fileName = TString(directory) +
"/" + curr_file->d_name;
75 printf(
"Adding beam line element map '%s'\n", fileName.Data());
80 map->SetFieldScale(fieldScaler);
95 std::cout <<
"dirName = " << dirName << std::endl;
97 DIR *curr_dir = opendir(dirName.Data());
99 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Directory '%s' does not exist! \033[0m",
105 struct dirent *curr_file;
106 int extention_len = strlen(
".dat");
108 while((curr_file = readdir(curr_dir))) {
109 int len = strlen(curr_file->d_name);
111 if (len >= extention_len &&
112 !memcmp(curr_file->d_name + len - extention_len,
113 ".dat", extention_len)) {
114 TString fileName = dirName +
"/" + curr_file->d_name;
116 std::cout <<
"Getting ready to read in the text file with the field information" << std::endl;
118 FILE *fin = fopen(fileName.Data(),
"r");
120 printf(
"-E- EicBeamLineElementGrad::Initialize() -> fail to open '%s' file!\n", fileName.Data());
125 while (fgets(buffer, 1024, fin)) {
127 double centerX, centerY, centerZ, rZin, rZout, dOut,
length, angle, b, gradient;
129 if (!strlen(buffer) || buffer[0] ==
'#')
continue;
133 int ret = sscanf(buffer,
"%s %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %s %lf",
134 name, ¢erX, ¢erY, ¢erZ, &rZin, &rZout, &dOut, &length, &angle, &b, &gradient);
135 if (ret != 11)
continue;
137 printf(
"%10s -> %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n",
138 name, centerX, centerY, centerZ, rZin, rZout, dOut, length, angle, b, gradient);
141 EicBeamLineElementGrad *map =
new EicBeamLineElementGrad(name, centerX, centerY, centerZ, rZin, rZout, dOut, length, angle, b, gradient);
158 std::cout <<
"dirName = " << dirName << std::endl;
160 DIR *curr_dir = opendir(dirName.Data());
162 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Directory '%s' does not exist! \033[0m",
167 struct dirent *curr_file;
168 int extention_len = strlen(
".dat");
170 while((curr_file = readdir(curr_dir))) {
171 int len = strlen(curr_file->d_name);
173 if (len >= extention_len &&
174 !memcmp(curr_file->d_name + len - extention_len,
175 ".dat", extention_len))
178 TString fileName = dirName +
"/" + curr_file->d_name;
183 std::cout <<
"Getting ready to read in the text file with the field information" << std::endl;
187 fin.open(fileName.Data());
189 printf(
"-E- EicBeamLineElementGrad::Initialize() -> fail to open '%s' file!\n", fileName.Data());
193 std::cout <<
"its open..." << std::endl;
197 double mCenterX, mCenterY, mCenterZ, mRadius, mLength, mAngle, mB, mGradient;
201 for(
int i=0; i<6; i++)
203 fin.getline(buffer, 1024);
211 std::cout <<
"extract the information in the file" << std::endl;
214 if(fin >> mName >> mCenterZ >> mCenterX >> mCenterY >> mRadius >> mLength >> mAngle >> mB >> mGradient)
217 printf(
"Adding beam line element gradient '%s'\n", mName);
218 printf(
"%15.10f %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f\n",
219 mCenterX, mCenterY, mCenterZ, mRadius, mLength, mAngle, mB, mGradient);
278 fLogger->Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31m Failed to initialize '%s' field map! \033[0m",
303 for(
unsigned iq=0; iq<3; iq++)
309 if (!xx || !B || !
mMaps.size())
return -1;
322 for(
unsigned iq=0; iq<3; iq++)
340 TFile fout(fileName,
"RECREATE");
344 printf(
"-E- EicMagneticField::Export() -> failed to open '%s' for writing!\n", fileName);