AliPhysics  eb0e5d9 (eb0e5d9)
MergeThirdSMfilesIntoOne.C
Go to the documentation of this file.
1 #include <signal.h>
2 //#include <sys/time.h>
3 #include <stdio.h>
4 #include <vector>
5 #include <iostream>
6 #include <fstream>
7 #include <string>
8 #include <iosfwd>
9 #include <iostream>
10 #include <numeric>
11 #include <queue>
12 #include <set>
13 #include <sstream>
14 
15 #include <map>
16 #include <utility>
17 #include <iterator>
18 
19 
20 #include <TSystem.h> //To have gSystem known at compilation time
21 #include <TApplication.h>
22 #include <TChain.h>
23 #include <TF1.h>
24 #include <TH1F.h>
25 #include <TH2F.h>
26 #include <TFile.h>
27 #include <TCanvas.h>
28 #include <TFrame.h>
29 #include <TPostScript.h>
30 #include <TLine.h>
31 #include <TGaxis.h>
32 #include <TStyle.h>
33 #include <TGraphErrors.h>
34 #include <TMath.h>
35 #include <TMatrixF.h>
36 #include <TText.h>
37 
38 
39 
40 
41 namespace std {} using namespace std;
42 
43 
44 const double kMaxHV = 395.; // default max voltage limit; could possibly be relaxed in future
45 const double kMinHV = 210.; // Hexa encoding limit
46 const double coefFactorWanted=0.0162;
47 
48 
49 // voir http://dsilverm.web.cern.ch/dsilverm/fee/addrP2.html
50  char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
51  char SMcalibName[][100]={"US2","US1","EU2","EU1","US3","US5","US4","EU3","US7","US6","US8C0","US8C2","DCN1","DJP1","DUS2","DUS1","DJP2","DUS3","CN1A","CN1C"};
52  char SMnumber[][100]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
53 
56  char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
58  const int kNbColEMCAL=48;
59  const int kNbRowEMCAL=24;
60  const int kNbSMEMCAL=10;
62  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
63  const int kNbSMEMCALthird=2;
64  const int kNbColDCAL=32;
66  const int kNbSMDCAL=6;
69  const int kNbSMDCALthird=2;
70  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
71  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
72  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
73  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
77 
78  int lastSM;
79 
80 
92 
97 {int iCol,iRow,col,row;
98  double value;
99  double tabValueSM_0to7[kNbColEMCALthird][kNbRowEMCALthird];
100  double tabValueSM_16to23[kNbColEMCALthird][kNbRowEMCALthird];
101 
102  FILE *fileIn_0to7,*fileIn_16to23,*fileOut;
103 
104  const char fchNameIn_0to7[] = "/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/output_HVrecalculation_EMCALthirds_pass2/SMA5/NewBias.txt";
105  const char fchNameIn_16to23[] = "/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/output_HVrecalculation_EMCALthirds_pass2/SMC5/NewBias.txt";
106  const char fchNameOut[] = "NewFile_merged.txt";
107 
108  printf("\nRunning with : \n");
109  printf(" - file rows 0-7 : %s\n",fchNameIn_0to7);
110  printf(" - file rows 16-23 : %s\n",fchNameIn_16to23);
111 
112  fileIn_0to7 = fopen(fchNameIn_0to7,"r");
113  if (!fileIn_0to7) {printf("File %s can not be found\n",fchNameIn_0to7); exit(-1);}
114  while (fscanf(fileIn_0to7," %d %d %lf\n",&col,&row,&value) > 0)
115  {tabValueSM_0to7[col][row]=value;
116  }
117  fclose(fileIn_0to7);
118 
119  fileIn_16to23 = fopen(fchNameIn_16to23,"r");
120  if (!fileIn_16to23) {printf("File %s can not be found\n",fchNameIn_16to23); exit(-1);}
121  while (fscanf(fileIn_16to23," %d %d %lf\n",&col,&row,&value) > 0)
122  {tabValueSM_16to23[col][row]=value;
123  }
124  fclose(fileIn_16to23);
125 
126  fileOut = fopen(fchNameOut,"w");
127  for (iCol=0;iCol<kNbColMax;iCol++)
128  {for (iRow=0;iRow<kNbRowMax;iRow++)
129  {if (iRow < kNbRowEMCALthird) fprintf(fileOut,"%d %d %7.3f\n",iCol,iRow,tabValueSM_0to7[iCol][iRow]);
130  if ((iRow >= kNbRowEMCALthird) && (iRow < 2*kNbRowEMCALthird)) fprintf(fileOut,"%d %d 0\n",iCol,iRow);
131  if (iRow >= 2*kNbRowEMCALthird) fprintf(fileOut,"%d %d %7.3f\n",iCol,iRow,tabValueSM_16to23[iCol][iRow-2*kNbRowEMCALthird]);
132  }
133  }
134  fclose (fileOut);
135 
136 
137 
138  return;
139  }
140 
141 
142 
143 
144 
145 
146 
147 
const int kNbRowEMCAL
const int kNbRowMax
const int kTabNbRow[4]
const int kNbColOffsetDCAL
const int kNbColEMCAL
char SMnumber[][100]
const int kNbSMDCAL
const int kNbColMax
const int kNbRowDCALthird
const int kTabNbSM[4]
const int kNbSMEMCALthird
int detTypeType[]
const int kNbColDCALthird
const int kNbColDCAL
char SMcalibName[][100]
void MergeThirdSMfilesIntoOne()
const int kNbColEMCALthird
const int kTabNbCol[4]
const double kMinHV
const int kNbRowDCAL
int SMdetType[]
const int kNbRowEMCALthird
const int kNbSMEMCAL
const double kMaxHV
const int kNbSMDCALthird
char SMP2Name[][100]
char detTypeString[][100]
const double coefFactorWanted
const int kNbSMtot