StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
writeIdealGains.C
1 void writeIdealGains(){
2 
3  const int etabin=12;
4  const float maxADC=4095;
5  const float maxEt=60;
6  const int strip=288;
7  const float eta[etabin]={1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
8  int tower[etabin];
9  float gain[etabin];
10  float err[etabin];
11  char mapt[100];
12  char title[100];
13  char tow[100];
14 
15  system("mkdir -p idealGain/");
16 
17  for (UInt_t i=0;i<etabin;i++){
18  int hold=i-etabin;
19  tower[i]=i+1;
20  gain[i]=maxADC/maxEt/cosh(eta[i]);
21  err[i]=0.0;
22  printf("eta bin %d is tower %d with eta = %f, gain =%f\n",i,tower[i],eta[i],gain[i]);
23  }
24 
25  //tower files
26  for (int k=0;k<etabin;k++){
27  sprintf(title,"sector%02d.Tgain",k+1);
28  FILE *file=fopen(title,"w"); assert(file);
29  fprintf(file,"#sector%02d/eemcPMTcal\n",k+1);
30  for (char zub='A';zub<='E';zub++){
31  for (int j=0;j<etabin;j++){
32  sprintf(tow,"%02dT%c%02d",k+1,zub,j+1);
33  fprintf(file,"%s %f %f\n",tow,gain[j],err[j]);
34 
35  }
36  }
37  fclose(file);
38  }
39 
40 
41  //smd,pre1,pre2,post (U/V,P,Q,R)
42  for (int k=0;k<etabin;k++){
43  sprintf(title,"sect%02dPIXgains.dat",k+1);
44  FILE *file2=fopen(title,"w"); assert(file2);
45  fprintf(file2,"#sector%02d/eemcPIXcal\n",k+1);
46  for (char zub='U';zub<='V';zub++){
47  for (int j=0;j<strip;j++){
48  sprintf(mapt,"%02d%c%03d",k+1,zub,j+1);
49  fprintf(file2,"%s %2.1f %f\n",mapt,23000,0.0);
50  }
51  }
52  for (char zub='P';zub<='R';zub++){
53  for (char sub='A';sub<='E';sub++){
54  for (int j=0;j<etabin;j++){
55  sprintf(mapt,"%02d%c%c%02d",k+1,zub,sub,j+1);
56  fprintf(file2,"%s %2.1f %f\n",mapt,23000.0,0.0);
57  }
58  }
59  }
60  fclose(file2);
61  }
62 
63  system("mv sect* idealGain/");
64 
65 }