StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
pedStat.C
1 
2 int pedStat(char runNum[10], int k=-1, TString path="./"){
3 
4  TFile *fd;
5  TFile *fdraw;
6  int jSector=0,jSubSect=0,jEta=0;
7  int mskDay=0;
8  const int mSec=12;
9  const int mSub=5;
10  const int mEta=12;
11  const int mSmdPlanes=2;
12  const int mSmdStrips=288;
13  char preL[4]="PQR";
14  int rNum=0;
15  char day[10];
16  char channel[10];
17  TString subdir = path; subdir+="StatFiles/";
18  char fileName[50];
19  char logFile[50];
20 
21  float minTPedPos=1.0,maxTPedPos=100.0;
22  float minMPedPos=1.0,maxMPedPos=400.0;
23  float minTSig=.5,maxTSig=2.5;
24  float minMSig=.3,maxMSig=1.5;
25  float deadentriesT=.998;
26  float deadentriesM=.9995;
27 
28  assert( !gSystem->Load("StEEmcStatus"));
29  oflPedStat *stat=new oflPedStat;
30 
31  FILE *fpout,*fplog;
32 
33  rNum=atoi(runNum+1);
34  printf("\n\n%s %d %d\n\n",runNum,k,rNum);
35 
36  strncpy(day,runNum+3,3);
37  day[3]='\0';
38 
39  TString fullname = path+"day"+day+"/outPed"+runNum+"/"+runNum+"fit.hist.root";
40  TString fullnameraw = path+"day"+day+"/outPed"+runNum+"/"+runNum+".hist.root";
41 
42  fd= new TFile(fullname);
43  if(fd==0){
44  printf("file %s not found\n",runNum);
45  return 1;
46  }
47 
48  fdraw= new TFile(fullnameraw);
49  if(fdraw==0){
50  printf("raw file %s not found\n",runNum);
51  return 1;
52  }
53 
54  strcpy(fileName,runNum);
55  strcat(fileName,".errs");
56  strcpy(logFile,runNum);
57  strcat(logFile,".log");
58 
59  TString Outname= subdir + fileName;
60  fpout=fopen(Outname.Data(),"w");
61  if(fpout==0){
62  printf("Output file not opened\n");
63  return 1;
64  }
65  TString logname=subdir + logFile;
66  fplog=fopen(logname.Data(),"w");
67  if(fplog==0){
68  printf("Log file not opened\n");
69  return 1;
70  }
71  int t=0;
72 
73  //initialize files for run
74  stat->initRun(k,fd,fdraw,fpout,fplog,rNum);
75 
76  // loop over all towers
77  for(jSector=0; jSector<12; jSector++)
78  { for (jSubSect=0;jSubSect<5;jSubSect++)
79  { for(jEta=0; jEta<12; jEta++)
80  {
81  sprintf(channel,"a%02dT%c%02d",jSector+1,'A'+jSubSect,jEta+1);
82  stat->procDetector(channel,maxTPedPos,minTPedPos,maxTSig,minTSig,deadentriesT,mskDay);
83  }
84  }
85  }
86 
87  // loop over mapmt strips
88  for(int jSector=0;jSector<mSec;jSector++) {
89  for(int uv= 0; uv < mSmdPlanes; uv++){
90  for(int lst=0;lst < mSmdStrips; lst++) {
91  sprintf(channel,"a%02d%c%03d",jSector+1,'U'+uv,lst+1);
92  stat->procDetector(channel,maxMPedPos,minMPedPos,maxMSig,minMSig,deadentriesM,mskDay);
93  }
94  }
95  //loop over all pre1, pre2, post shower
96  for(int jSubSect=0;jSubSect<mSub;jSubSect++) {
97  for(int jEta=0;jEta< mEta;jEta++) {
98  for(int prlst=0;prlst < 3; prlst++){
99 
100  sprintf(channel,"a%02d%c%c%02d",jSector+1,preL[prlst],'A'+jSubSect,jEta+1);
101  stat->procDetector(channel,maxMPedPos,minMPedPos,maxMSig,minMSig,deadentriesM,mskDay);
102  }
103  }
104  }
105  }
106 
107  printf("Closing files\n");
108  fclose(fpout);
109  fclose(fplog);
110  fd->Close("R");
111  fdraw->Close("R");
112  printf("all done\n");
113 
114  return 0;
115 }