AliPhysics  d9e9949 (d9e9949)
HVrecalculation.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 //#include "/cebaf/faivre/recherche/utilities/defineMyPalette2011.C"
40 
41 
42 namespace std {} using namespace std;
43 
44 
45 const double kMaxHV = 395.; // default max voltage limit; could possibly be relaxed in future
46 const double kMinHV = 210.; // Hexa encoding limit
47 const double coefFactorWanted=0.0162;
48 
49 
50 // voir http://dsilverm.web.cern.ch/dsilverm/fee/addrP2.html
51  char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
52  char SMcalibName[][100]={"US2","US1","EU2","EU1","US3","US5","US4","EU3","US7","US6","US8C0","US8C2","DCN1","DJP1","DUS2","DUS1","DJP2","DUS3","CN1A","CN1C"};
53  char SMnumber[][100]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
54 
57  char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
59  const int kNbColEMCAL=48;
60  const int kNbRowEMCAL=24;
61  const int kNbSMEMCAL=10;
63  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
64  const int kNbSMEMCALthird=2;
65  const int kNbColDCAL=32;
67  const int kNbSMDCAL=6;
70  const int kNbSMDCALthird=2;
71  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
72  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
73  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
74  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
78 
79  int lastSM;
80 
81 
127 
128 
132 void CalcNewHVperSM(TString hvFileName,TString paramFileName,int smNb,char *fchNameBase,FILE *outFile,FILE *badGainFileOut,double coeffOCDB[kNbSMtot][kNbColMax][kNbRowMax],double coeffCalib[kNbSMtot][kNbColMax][kNbRowMax],double forcedGainChange[kNbSMtot][kNbColMax][kNbRowMax],double forcedOCDBcoeff[kNbSMtot][kNbColMax][kNbRowMax],int flag[kNbSMtot][kNbColMax][kNbRowMax],TPostScript *ps,TCanvas *c1)
133 {int nbTowersAbove395,nbTowersBelowMin,nbTowersLargeModif,nbTowersBadHVscan,nbTowersProblem;
134  int icol,irow,expectSameE;
135  double hv,p0,p1,p2,gainChange,newHV,tmpNewHV;
136  double HVtab[kNbColMax][kNbRowMax]={{0.}};
137  double p0tab[kNbColMax][kNbRowMax]={{0.}};
138  double p1tab[kNbColMax][kNbRowMax]={{0.}};
139  double p2tab[kNbColMax][kNbRowMax]={{0.}};
140  double ampliIn,Eout1,Eout2,Ediff,initialGain,newGain;
141  //CUSTOMIZE customize every year :
142  double kMaxDeltaGainLook=2.0; //Will printf the tower above this.
143  double kMaxDeltaGainAuthorize=3.0; //Will suggest that number to any tower beyond that.
144  double kMaxDeltaHVgraph=50.;
145  //CUSTOMIZE customize every pass :
146  //Pass 0, 1, 2 :
147  double kMaxDeltaHVcut=10.;
148 
149  double kMaxEmismatchCut=0.01; //0.001 is OK but with flag -3 it's too hard. Put 0.01 instead (that's in %).
150 
151  printf("----- Calculating HV's for SM %d (%s)",smNb,detTypeString[SMdetType[smNb]]);
152  fprintf(outFile,"\n-------------- Calculating HV's for SM %d (%s)",smNb,detTypeString[SMdetType[smNb]]);
153  if ((smNb%2) == 0)
154  {printf(" (side A)\n");
155  fprintf(outFile," (side A) -----\n\n");
156  }
157  else
158  {printf(" (side C)\n");
159  fprintf(outFile," (side C) -----\n\n");
160  }
161 
162  // Check file existence and load the table of HV's :
163  FILE *inFile,*outHVFile,*outParamFile;
164  inFile=fopen(hvFileName.Data(),"r");
165  if(!inFile) {printf("File %s can not be found\n",hvFileName.Data());exit(-1);}
166  while(fscanf(inFile,"%d %d %lf\n",&icol,&irow,&hv)>0) HVtab[icol][irow]=hv;
167  fclose(inFile);
168 
169  inFile=fopen(paramFileName.Data(),"r");
170  if(!inFile) {printf("File %s can not be found\n",paramFileName.Data());exit(-1);}
171  while(fscanf(inFile,"%d %d %lf %lf %lf\n",&icol,&irow,&p0,&p1,&p2)>0)
172  {p0tab[icol][irow]=p0;
173  p1tab[icol][irow]=p1;
174  p2tab[icol][irow]=p2;
175  }
176  fclose(inFile);
177 
178  // Create some histograms :
179  TH1F *hEChange = new TH1F(Form("hEChange%d",smNb),Form("hEChange%d",smNb),80,-50.,50.);
180  hEChange->SetXTitle("(E_{2}-E_{1})/E_{1} (%)");
181  hEChange->SetYTitle("Counts");
182  hEChange->SetStats(0);
183  TH1F *hEChangeLogP = new TH1F(Form("hEChangeLogP%d",smNb),Form("hEChangeLogP%d",smNb),80,-3.,3.);
184  hEChangeLogP->SetXTitle("log [(E_{2}-E_{1})/E_{1} (%)]");
185  hEChangeLogP->SetYTitle("Counts");
186  hEChangeLogP->SetStats(0);
187  TH1F *hEChangeLogN = new TH1F(Form("hEChangeLogN%d",smNb),Form("hEChangeLogN%d",smNb),80,-3.,3.);
188  hEChangeLogN->SetXTitle("log [(E_{2}-E_{1})/E_{1} (%)]");
189  hEChangeLogN->SetYTitle("Counts");
190  hEChangeLogN->SetStats(0);
191  TH2F *h2HVdiffVsOCDB = new TH2F(Form("h2HVdiffVsOCDB%d",smNb),Form("h2HVdiffVsOCDB%d",smNb),80,0.,5.,80,-kMaxDeltaHVgraph,kMaxDeltaHVgraph);
192  h2HVdiffVsOCDB->SetXTitle("OCDB factor / 0.0162");
193  h2HVdiffVsOCDB->SetYTitle("NewHV - OldHV (V)");
194  h2HVdiffVsOCDB->SetStats(0);
195  h2HVdiffVsOCDB->SetContour(30);
196  TH2F *h2HVdiffVsOCDBZm = new TH2F(Form("h2HVdiffVsOCDBZm%d",smNb),Form("h2HVdiffVsOCDBZm%d",smNb),80,0.5,2.,80,-30.,30.);
197  h2HVdiffVsOCDBZm->SetXTitle("OCDB factor / 0.0162");
198  h2HVdiffVsOCDBZm->SetYTitle("NewHV - OldHV (V)");
199  h2HVdiffVsOCDBZm->SetStats(0);
200  h2HVdiffVsOCDBZm->SetContour(30);
201  TH2F *hSpaceHVbefore = new TH2F(Form("hSpaceHVbefore%d",smNb),Form("hSpaceHVbefore%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
202  hSpaceHVbefore->SetXTitle("Column");
203  hSpaceHVbefore->SetYTitle("Row");
204  hSpaceHVbefore->SetStats(0);
205  hSpaceHVbefore->SetContour(30);
206  TH2F *hSpaceHVafter = new TH2F(Form("hSpaceHVafter%d",smNb),Form("hSpaceHVafter%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
207  hSpaceHVafter->SetXTitle("Column");
208  hSpaceHVafter->SetYTitle("Row");
209  hSpaceHVafter->SetStats(0);
210  hSpaceHVafter->SetContour(30);
211  TH2F *hSpaceOCDBbefore = new TH2F(Form("hSpaceOCDBbefore%d",smNb),Form("hSpaceOCDBbefore%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
212  hSpaceOCDBbefore->SetXTitle("Column");
213  hSpaceOCDBbefore->SetYTitle("Row");
214  hSpaceOCDBbefore->SetStats(0);
215  hSpaceOCDBbefore->SetContour(30);
216  TH2F *hSpaceOCDBafter = new TH2F(Form("hSpaceOCDBafter%d",smNb),Form("hSpaceOCDBafter%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
217  hSpaceOCDBafter->SetXTitle("Column");
218  hSpaceOCDBafter->SetYTitle("Row");
219  hSpaceOCDBafter->SetStats(0);
220  hSpaceOCDBafter->SetContour(30);
221  TH2F *hSpaceAboveBefore = new TH2F(Form("hSpaceAboveBefore%d",smNb),Form("hSpaceAboveBefore%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
222  hSpaceAboveBefore->SetXTitle("Column");
223  hSpaceAboveBefore->SetYTitle("Row");
224  hSpaceAboveBefore->SetStats(0);
225  hSpaceAboveBefore->SetContour(30);
226  TH2F *hSpaceAboveAfter = new TH2F(Form("hSpaceAboveAfter%d",smNb),Form("hSpaceAboveAfter%d",smNb),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
227  hSpaceAboveAfter->SetXTitle("Column");
228  hSpaceAboveAfter->SetYTitle("Row");
229  hSpaceAboveAfter->SetStats(0);
230  hSpaceAboveAfter->SetContour(30);
231 
232  // Setup a few counters :
233  ampliIn=1.; //Nb of "photoelectrons" (arbitrary unit)
234  nbTowersAbove395=0;
235  nbTowersBelowMin=0;
236  nbTowersLargeModif=0;
237  nbTowersBadHVscan=0;
238  nbTowersProblem=0;
239 
240  // Loop over the towers to calculate the new HV's :
241  for(icol=0;icol<kTabNbCol[SMdetType[smNb]];icol++)
242  {for(irow=0;irow<kTabNbRow[SMdetType[smNb]];irow++)
243  //for(icol=4;icol<5;icol++)
244  // {for(irow=3;irow<4;irow++)
245  {hv=HVtab[icol][irow];
246  p0=p0tab[icol][irow];
247  p1=p1tab[icol][irow];
248  p2=p2tab[icol][irow];
249 //printf("%d %d %d HV %f coeff %f %f\n",smNb,icol,irow,hv,coeffCalib[smNb][icol][irow],0.0162/coeffOCDB[smNb][icol][irow]);
250  expectSameE=1;
251  hSpaceHVbefore->Fill(icol,irow,hv);
252  hSpaceOCDBbefore->Fill(icol,irow,coeffOCDB[smNb][icol][irow]/coefFactorWanted);
253  if (hv == kMaxHV) hSpaceAboveBefore->Fill(icol,irow,coeffOCDB[smNb][icol][irow]/coefFactorWanted);
254 
255  gainChange=coeffOCDB[smNb][icol][irow]/coefFactorWanted;
256  // Suggest discarding the towers with calib coeff = 1 (half of the time dead towers) :
257  if ((coeffCalib[smNb][icol][irow] == 1.0) && (flag[smNb][icol][irow] == 5)) //Don't escape again if tower has already seen at previous pass !
258  {fprintf(outFile,"######## Tower with calib coeff 1.0 (%d,%d,%d) ### do nothing.\n",smNb,icol,irow);
259  fprintf(badGainFileOut,"%d %2d %2d XXX2 %f %4.2f %f %f\n",smNb,icol,irow,gainChange,1.,forcedGainChange[smNb][icol][irow],forcedOCDBcoeff[smNb][icol][irow]);
260  nbTowersProblem++;
261  continue;
262  }
263 
264  // Check that the p0, p1, p2 parameters look OK (raw check) :
265  if ((p1==0.) && (p2==0.)) // LED HV-scan not good.
266  {fprintf(outFile,"######## Bad HV scan for tower (%d,%d,%d), HV %7.3f ### do nothing.\n",smNb,icol,irow,hv);
267  nbTowersBadHVscan++;
268  nbTowersProblem++;
269  continue;
270  }
271  if ((p1<=0.) || (p2<=0.))
272  {fprintf(outFile,"######## Bad HV scan parameters for tower (%d,%d,%d), HV %7.3f (params : %f %e %f) ### do nothing.\n",smNb,icol,irow,hv,p0,p1,p2);
273  nbTowersBadHVscan++;
274  nbTowersProblem++;
275  continue;
276  }
277  if ( (p0 + p1 * exp(p2*(hv-kMaxDeltaHVcut-10.))) < 0. )
278  {fprintf(outFile,"######## Bad HV scan value for tower (%d,%d,%d), HV %7.3f (params : %f %e %f) ### do nothing.\n",smNb,icol,irow,hv,p0,p1,p2);
279  nbTowersBadHVscan++;
280  nbTowersProblem++;
281  continue;
282  }
283 
284  // Check for a chosen, forced value.
285  // If there isn't, check that the required gain change isn't too far from 1.0.
286  if (flag[smNb][icol][irow] == 0) //Undecided tower (shouldn't be found...), copy as is.
287  {fprintf(badGainFileOut,"%d %2d %2d XXX %f %4.2f %f %f\n",smNb,icol,irow,gainChange,1.,forcedGainChange[smNb][icol][irow],forcedOCDBcoeff[smNb][icol][irow]);
288  nbTowersProblem++;
289  continue;
290  }
291  if (flag[smNb][icol][irow] == -3) //HV change was too large, forced gain and OCDB value.
292  {fprintf(badGainFileOut,"%d %2d %2d -3 %f %4.2f %f %f\n",smNb,icol,irow,gainChange,1.,forcedGainChange[smNb][icol][irow],forcedOCDBcoeff[smNb][icol][irow]);
293  gainChange=forcedGainChange[smNb][icol][irow];
294  initialGain = p0 + p1 * exp(p2*hv);
295  newGain = initialGain * gainChange;
296  Eout1=ampliIn*initialGain*coeffOCDB[smNb][icol][irow];
297  //expectSameE=0; //If the "-3" results from a too large HV change (most of the cases), the energies must be equal ! Some outliers may be caught by the printf.
298  if ((newGain-p0) > 0)
299  {newHV = log ( (newGain - p0)/p1 ) / p2;
300  HVtab[icol][irow]=newHV;
301  coeffOCDB[smNb][icol][irow]=forcedOCDBcoeff[smNb][icol][irow];
302  Eout2=ampliIn*(p0 + p1 * exp(p2*newHV))*coeffOCDB[smNb][icol][irow];
303  h2HVdiffVsOCDB->Fill(gainChange,newHV-hv);
304  h2HVdiffVsOCDBZm->Fill(gainChange,newHV-hv);
305  Ediff=100.*(Eout2-Eout1)/Eout1;
306  if (expectSameE == 1)
307  {hEChange->Fill(Ediff);
308  if (Eout2 > Eout1) hEChangeLogP->Fill(TMath::Log10(TMath::Abs(Ediff)));
309  if (Eout2 < Eout1) hEChangeLogN->Fill(TMath::Log10(TMath::Abs(Ediff)));
310  if (TMath::Abs(Ediff) > kMaxEmismatchCut)
311  {printf("##### E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
312  fprintf(outFile,"E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
313  }
314  }
315  continue;
316  }
317  else // LED HV-scan not good (can happen if changed HV scan between an execution and the next one) : tell it and move to the next tower.
318  {fprintf(outFile,"######## Negative in log for forced tower (%d,%d,%d), HV %7.3f and gain %5.3f (params : %f %e %f) ### do nothing.\n",smNb,icol,irow,hv,gainChange,p0,p1,p2);
319  continue;
320  }
321  }
322  if (forcedGainChange[smNb][icol][irow] != 0.)
323  {if ((flag[smNb][icol][irow] > 9) || (flag[smNb][icol][irow] == -4)) fprintf(badGainFileOut,"%d %2d %2d %d %f %4.2f %f %f\n",smNb,icol,irow,flag[smNb][icol][irow],gainChange,1.,forcedGainChange[smNb][icol][irow],forcedOCDBcoeff[smNb][icol][irow]); //Can't put these lines later because the older "gainChange" must be known. That causes this line to be issued a 2nd time (with different values) in badGainFileOut when deltaHV is too large. The latter line overwrites the previous anyway when the file is read back => that's OK even if the user doesn't cancel it manually. The line automatically disappears from the "bad gain" file at the next pass.
324  else fprintf(badGainFileOut,"%d %2d %2d %d %f %4.2f %f %f\n",smNb,icol,irow,flag[smNb][icol][irow]+10,gainChange,1.,forcedGainChange[smNb][icol][irow],forcedOCDBcoeff[smNb][icol][irow]);
325  gainChange=forcedGainChange[smNb][icol][irow];
326  }
327  else
328  {if (gainChange < 1./kMaxDeltaGainAuthorize)
329  {fprintf(outFile,"######## Gain change < factor 1/%4.2f for tower (%d,%d,%d), HV %7.3f and gain %5.3f ### do nothing.\n",kMaxDeltaGainAuthorize,smNb,icol,irow,hv,gainChange);
330  fprintf(badGainFileOut,"%d %2d %2d XXX-4 %f %4.2f %f %f\n",smNb,icol,irow,gainChange,1.,1./kMaxDeltaGainAuthorize,coefFactorWanted*1./kMaxDeltaGainAuthorize); //Have to setup both the gain change and the OCDB factor, as *that* OCDB factor is still the desired change (not yet the factor that will be written to file).
331  nbTowersLargeModif++;
332  nbTowersProblem++;
333  continue;
334  }
335  if (gainChange > kMaxDeltaGainAuthorize)
336  {fprintf(outFile,"######## Gain change > factor %4.2f for tower (%d,%d,%d), HV %7.3f and gain %5.3f ### do nothing.\n",kMaxDeltaGainAuthorize,smNb,icol,irow,hv,gainChange);
337  fprintf(badGainFileOut,"%d %2d %2d XXX-4 %f %4.2f %f %f\n",smNb,icol,irow,gainChange,1.,kMaxDeltaGainAuthorize,coefFactorWanted*kMaxDeltaGainAuthorize); //Have to setup both the gain change and the OCDB factor, as *that* OCDB factor is still the desired change (not yet the factor that will be written to file).
338  nbTowersLargeModif++;
339  nbTowersProblem++;
340  continue;
341  }
342  if ((gainChange < 1./kMaxDeltaGainLook) || (gainChange > kMaxDeltaGainLook))
343  {fprintf(outFile,"######## Gain change > factor %4.2f for tower (%d,%d,%d), HV %7.3f and gain %5.3f ### do nothing.\n",kMaxDeltaGainLook,smNb,icol,irow,hv,gainChange);
344  fprintf(badGainFileOut,"%d %2d %2d XXX1 %f %4.2f %4.2f %4.2f\n",smNb,icol,irow,gainChange,1.,0.,0.);
345  nbTowersLargeModif++;
346  nbTowersProblem++;
347  continue;
348  }
349  }
350  if ((flag[smNb][icol][irow] == 2) || (flag[smNb][icol][irow] == 12) || (flag[smNb][icol][irow] == 3) || (flag[smNb][icol][irow] == 13)) expectSameE=0;
351 
352  // Calculate the new HV :
353  newHV=hv;
354  initialGain = p0 + p1 * exp(p2*hv);
355  newGain = initialGain * gainChange;
356  Eout1=ampliIn*initialGain*coeffOCDB[smNb][icol][irow];
357  if ((newGain-p0) <= 0) // LED HV-scan not good.
358  {fprintf(outFile,"######## Negative in log for tower (%d,%d,%d), HV %7.3f and gain %5.3f (params : %f %e %f) ### do nothing.\n",smNb,icol,irow,hv,gainChange,p0,p1,p2);
359  nbTowersBadHVscan++;
360  nbTowersProblem++;
361  continue;
362  }
363  else
364  newHV = log ( (newGain - p0)/p1 ) / p2;
365  if (flag[smNb][icol][irow] == -4) coeffOCDB[smNb][icol][irow]=forcedOCDBcoeff[smNb][icol][irow]; //GainChange has been levelled off at kMaxDeltaGainAuthorize
366 
367  // Check the calculated newHV :
368  if (newHV < 0) // conversion failed: let's just keep the old custom value then
369  {fprintf(outFile,"######## Neg HV returned for tower (%d,%d,%d), HV %7.3f and gain %5.3f (params : %f %e %f) ### keeping previous value.\n",smNb,icol,irow,hv,gainChange,p0,p1,p2);
370  nbTowersProblem++;
371  continue;
372  }
373  if (TMath::Abs(newHV-hv) > kMaxDeltaHVcut)
374  {fprintf(outFile,"######## Too large HV change for tower (%d,%d,%d), HV %7.3f -> %7.3f with gain %5.3f (params : %f %e %f) ### do nothing, ",smNb,icol,irow,hv,newHV,gainChange,p0,p1,p2);
375  fprintf(badGainFileOut,"%d %2d %2d XXX-3 %f %4.2f ",smNb,icol,irow,gainChange,1.);
376  if (newHV > hv) tmpNewHV=TMath::Min(kMaxHV,hv+(kMaxDeltaHVcut-0.01)); //Use val-0.01 instead of val so that we're sure it doesn't get trapped again after correcting the gain.
377  else tmpNewHV=TMath::Max(kMinHV,hv-(kMaxDeltaHVcut-0.01));
378  newGain= p0 + p1 * exp(p2*tmpNewHV);
379  gainChange=newGain/initialGain;
380  fprintf(outFile,"suggest gain %f w/ OCDBcoeff %f\n",gainChange,coeffOCDB[smNb][icol][irow]/gainChange);
381  fprintf(badGainFileOut,"%f %f\n",gainChange,coeffOCDB[smNb][icol][irow]/gainChange);
382  nbTowersProblem++;
383  continue;
384  }
385  if (newHV < kMinHV)
386  {fprintf(outFile,"HV below min voltage for tower (%d,%d,%d), HV %7.3f -> %7.3f with gain %5.3f -- set to supply voltage %7.3f.\n",smNb,icol,irow,hv,newHV,gainChange,kMinHV);
387  nbTowersBelowMin++;
388  nbTowersProblem++;
389  newGain= p0 + p1 * exp(p2*kMinHV);
390  gainChange=newGain/initialGain;
391  coeffOCDB[smNb][icol][irow]=coeffOCDB[smNb][icol][irow]/gainChange;
392  HVtab[icol][irow]=kMinHV;
393  Eout2=ampliIn*newGain*coeffOCDB[smNb][icol][irow];
394  Ediff=100.*(Eout2-Eout1)/Eout1;
395  if (expectSameE == 1) //Energies are not equal when we force the gain change to be different from the calculated OCDB coeff.
396  {hEChange->Fill(Ediff);
397  if (Eout2 > Eout1) hEChangeLogP->Fill(TMath::Log10(TMath::Abs(Ediff)));
398  if (Eout2 < Eout1) hEChangeLogN->Fill(TMath::Log10(TMath::Abs(Ediff)));
399  if (TMath::Abs(Ediff) > kMaxEmismatchCut)
400  {printf("##### E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
401  fprintf(outFile,"E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
402  }
403  }
404  continue;
405  }
406  if (newHV>kMaxHV) // we reached a too high voltage: let's keep the max then
407  {fprintf(outFile,"HV above supply voltage for tower (%d,%d,%d), HV %7.3f -> %7.3f with gain %5.3f -- set to supply voltage %7.3f.\n",smNb,icol,irow,hv,newHV,gainChange,kMaxHV);
408  nbTowersAbove395++;
409  nbTowersProblem++;
410  newGain= p0 + p1 * exp(p2*kMaxHV);
411  gainChange=newGain/initialGain;
412  coeffOCDB[smNb][icol][irow]=coeffOCDB[smNb][icol][irow]/gainChange;
413  HVtab[icol][irow]=kMaxHV;
414  Eout2=ampliIn*newGain*coeffOCDB[smNb][icol][irow];
415  Ediff=100.*(Eout2-Eout1)/Eout1;
416  if (expectSameE == 1) //Energies are not equal when we force the gain change to be different from the calculated OCDB coeff.
417  {hEChange->Fill(Ediff);
418  if (Eout2 > Eout1) hEChangeLogP->Fill(TMath::Log10(TMath::Abs(Ediff)));
419  if (Eout2 < Eout1) hEChangeLogN->Fill(TMath::Log10(TMath::Abs(Ediff)));
420  if (TMath::Abs(Ediff) > kMaxEmismatchCut)
421  {printf("##### E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
422  fprintf(outFile,"E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
423  }
424  }
425  continue;
426  }
427  //everything ok
428  HVtab[icol][irow]=newHV;
429  coeffOCDB[smNb][icol][irow]=coefFactorWanted;
430  Eout2=ampliIn*(p0 + p1 * exp(p2*newHV))*coeffOCDB[smNb][icol][irow];
431 //if ((gainChange < 0.95) && (newHV-hv > -1)) printf("##### BAAAAD tower (%d,%d,%d) HV's %f %f, gainChange %f, p's %e %e %e\n",smNb,icol,irow,hv,newHV,gainChange,p0,p1,p2); /////////
432  h2HVdiffVsOCDB->Fill(gainChange,newHV-hv);
433  h2HVdiffVsOCDBZm->Fill(gainChange,newHV-hv);
434  Ediff=100.*(Eout2-Eout1)/Eout1;
435  if (expectSameE == 1) //Energies are not equal when we force the gain change to be different from the calculated OCDB coeff.
436  {hEChange->Fill(Ediff);
437  if (Eout2 > Eout1) hEChangeLogP->Fill(TMath::Log10(TMath::Abs(Ediff)));
438  if (Eout2 < Eout1) hEChangeLogN->Fill(TMath::Log10(TMath::Abs(Ediff)));
439  if (TMath::Abs(Ediff) > kMaxEmismatchCut)
440  {printf("##### E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
441  fprintf(outFile,"E mismatch tower (%d,%d,%d) : Eout1 = %f, Eout2 = %f HV %7.3f -> %7.3f => %7.3f w/ OCDB %f flag %d\n",smNb,icol,irow,Eout1,Eout2,hv,newHV,HVtab[icol][irow],coeffOCDB[smNb][icol][irow],flag[smNb][icol][irow]);
442  }
443  }
444  }
445  }
446 
447  // Write to file the new HV values and the new OCDB parameters :
448  outHVFile=fopen(Form("%s/%s/NewBias.txt",fchNameBase,SMP2Name[smNb]),"w");
449  outParamFile=fopen(Form("%s/%s/NewParamFactor.txt",fchNameBase,SMP2Name[smNb]),"w");
450  for(icol=0;icol<kTabNbCol[SMdetType[smNb]];icol++)
451  {for(irow=0;irow<kTabNbRow[SMdetType[smNb]];irow++)
452  {fprintf(outHVFile,"%d %d %f\n",icol,irow,HVtab[icol][irow]);
453  //Flip OCDB params from Grenoble/electonic mapping to Alice-offline mapping. HVs are kept in Grenoble/electonic mapping.
454  if ((smNb%2) == 0) fprintf(outParamFile,"%d %d %d %f\n",smNb,icol,irow,coeffOCDB[smNb][icol][irow]); //Side A.
455  else fprintf(outParamFile,"%d %d %d %f\n",smNb,(kTabNbCol[SMdetType[smNb]]-1)-icol,(kTabNbRow[SMdetType[smNb]]-1)-irow,coeffOCDB[smNb][icol][irow]); //Side C.
456  hSpaceHVafter->Fill(icol,irow,HVtab[icol][irow]);
457  hSpaceOCDBafter->Fill(icol,irow,coeffOCDB[smNb][icol][irow]/coefFactorWanted);
458  if (HVtab[icol][irow] == kMaxHV) hSpaceAboveAfter->Fill(icol,irow,coeffOCDB[smNb][icol][irow]/coefFactorWanted);
459  }
460  }
461  fclose(outHVFile);
462  fclose(outParamFile);
463 
464  fprintf(outFile,"\n\nNb towers above 395 V : %d\n",nbTowersAbove395);
465  fprintf(outFile,"Nb towers below min voltage : %d\n",nbTowersBelowMin);
466  fprintf(outFile,"Nb towers w/ too large gain : %d <--\n",nbTowersLargeModif);
467  fprintf(outFile,"Nb towers w/ bad HV scan : %d <--\n",nbTowersBadHVscan);
468  fprintf(outFile,"Nb other towers to look at : %d <--\n",nbTowersProblem-nbTowersAbove395-nbTowersBelowMin-nbTowersLargeModif-nbTowersBadHVscan);
469  fprintf(outFile,"Tot nb towers w/ problem : %d\n",nbTowersProblem);
470  fprintf(outFile,"\n");
471 
472  // Draw a few plots :
473  TLine *lineH = new TLine(h2HVdiffVsOCDBZm->GetXaxis()->GetXmin(),0.,h2HVdiffVsOCDBZm->GetXaxis()->GetXmax(),0.);
474  TLine *lineV = new TLine(1.,h2HVdiffVsOCDBZm->GetYaxis()->GetXmin(),1.,h2HVdiffVsOCDBZm->GetYaxis()->GetXmax());
475  ps->NewPage();
476  c1->Clear();
477  c1->Divide(2,3);
478  c1->cd(1);
479  hEChange->Draw();
480  gPad->SetLogy();
481  hEChange->Write();
482  c1->cd(3);
483  hEChangeLogP->Draw();
484  gPad->SetLogy();
485  hEChangeLogP->Write();
486  c1->cd(5);
487  hEChangeLogN->Draw();
488  gPad->SetLogy();
489  hEChangeLogN->Write();
490  c1->cd(2);
491  h2HVdiffVsOCDB->Draw("COLZ");
492  h2HVdiffVsOCDB->Write();
493  lineH->Draw();
494  lineV->Draw();
495  c1->cd(4);
496  h2HVdiffVsOCDBZm->Draw("COLZ");
497  h2HVdiffVsOCDBZm->Write();
498  lineH->Draw();
499  lineV->Draw();
500  c1->Update();
501 
502  ps->NewPage();
503  c1->Clear();
504  c1->Divide(2,3);
505  c1->cd(1);
506  hSpaceHVbefore->SetMinimum(kMinHV);
507  hSpaceHVbefore->SetMaximum(kMaxHV+5.);
508  hSpaceHVbefore->Draw("COLZ");
509  hSpaceHVbefore->Write();
510  c1->cd(2);
511  hSpaceHVafter->SetMinimum(kMinHV);
512  hSpaceHVafter->SetMaximum(kMaxHV+5.);
513  hSpaceHVafter->Draw("COLZ");
514  hSpaceHVafter->Write();
515  c1->cd(3);
516  hSpaceOCDBbefore->Draw("COLZ");
517  hSpaceOCDBbefore->Write();
518  c1->cd(4);
519  hSpaceOCDBafter->Draw("COLZ");
520  hSpaceOCDBafter->Write();
521  c1->cd(5);
522  hSpaceAboveBefore->Draw("COLZ");
523  hSpaceAboveBefore->Write();
524  c1->cd(6);
525  hSpaceAboveAfter->Draw("COLZ");
526  hSpaceAboveAfter->Write();
527  c1->Update();
528 
529  if (smNb < (lastSM-1)) //Otherwise, the plots on the last page don't show up. Not sure why.
530  {delete hEChange;
531  delete hEChangeLogP;
532  delete hEChangeLogN;
533  delete h2HVdiffVsOCDB;
534  delete h2HVdiffVsOCDBZm;
535  delete hSpaceHVbefore;
536  delete hSpaceHVafter;
537  delete hSpaceOCDBbefore;
538  delete hSpaceOCDBafter;
539  delete hSpaceAboveBefore;
540  delete hSpaceAboveAfter;
541  }
542 
543  return;
544  }
545 
546 
547 
560 void HVrecalculation(TString ident,int choiceArg=0b0100)
561 {int i,ism,icol,irow,choice,oldFlag;
562  int tabChoiceCalos[4],tmpChoice;
563  double paramFactor;
564  double val1,val2,val3,ocdbCoeff;
565 
566  //defineMyPalette2011(30,5);
567 
568  for (i=4-1;i>=0;i--)
569  {tmpChoice=choiceArg>>i;
570  tabChoiceCalos[i]=tmpChoice;
571  choiceArg-=tmpChoice*pow(2,i);
572  }
573  printf("\n\n---------------------------------\n| Running for :");
574  for (i=0;i<4;i++)
575  {if (tabChoiceCalos[i] == 1) printf(" %s",detTypeString[i]);
576  }
577  printf("\n");
578  if (tabChoiceCalos[0] == 1) lastSM=kNbSMEMCAL;
579  if (tabChoiceCalos[1] == 1) lastSM=kNbSMEMCAL+kNbSMEMCALthird;
580  if (tabChoiceCalos[2] == 1) lastSM=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL;
581  if (tabChoiceCalos[3] == 1) lastSM=kNbSMtot;
582 
583  // Setup filenames, including :
584  // - new directory created to store everything,
585  // - name of the file with the OCDB parameters,
586  // - name of the file (to be created) with the "bad [large] gain towers",
587  // - name of the file (**to provide**) with the wanted gain for towers with initially "bad [large] gain".
588  char fchNameBase[250],fchNameRoot[250],fchNamePs[250],fchNameOut[250],fchNameBadGainIn[250],fchNameBadGainOut[250];
589  FILE *inFile,*outFile,*badGainFileIn,*badGainFileOut,*OCDBcoeffsFile,*calibCoeffsFile;
590  sprintf(fchNameBase,"output_HVrecalculation_%s",ident.Data());
591  sprintf(fchNameRoot,"%s/%s.root",fchNameBase,fchNameBase);
592  sprintf(fchNamePs,"%s/%s.ps",fchNameBase,fchNameBase);
593  sprintf(fchNameOut,"%s/%s.out",fchNameBase,fchNameBase);
594  sprintf(fchNameBadGainOut,"%s/%s_badGain.txt",fchNameBase,fchNameBase);
595  gSystem->Exec(Form("mkdir %s",fchNameBase));
596  for (ism=0;ism<kNbSMtot;ism++) gSystem->Exec(Form("mkdir %s/%s",fchNameBase,SMP2Name[ism]));
597  outFile=fopen(fchNameOut,"w");
598 
599  inFile=fopen(fchNameBadGainOut,"r");
600  if (inFile)
601  {printf("File %s already exists, exiting.\n",fchNameBadGainOut);
602  fclose(inFile); //Must be inside the if-loop, otherwise breaks (tries to close a file that it didn't open because it didn't exist).
603  return;
604  }
605 
606  TFile *rootFileOut = new TFile(fchNameRoot,"RECREATE");
607  const int cWidth=500;
608  const int cHeight=(int)(500*(29./21.));
609  TCanvas *c1 = new TCanvas("c1","EMCal cosmics analysis",cWidth,cHeight);
610  TPostScript *ps = new TPostScript(fchNamePs,111);
611 
612  //CUSTOMIZE customize every year (OCDB coeffs + calib coeffs) :
613  const char fchNameOCDBcoeffsFile[] = "/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/OCDBparamsAfterCalib2015.txt";
614  const char fchNameCalibCoeffsFile[] = "/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_finalFile4HVcalculation_setUntrustedToOne.txt"; //This is used only to check which towers are dead (calib coeff = 1).
615 
616  //CUSTOMIZE customize at every pass :
617  //***** To be set by the user at every execution : *****//
618  //For pass0 :
619  //sprintf(fchNameBadGainIn,"000.txt");
620  //For pass1 :
621  //sprintf(fchNameBadGainIn,"/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/output_HVrecalculation_pass0/output_HVrecalculation_pass0_badGain_Custom.txt");
622  //For pass2 :
623  sprintf(fchNameBadGainIn,"/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/output_HVrecalculation_pass1/output_HVrecalculation_pass1_badGain_Custom.txt");
624 
625  printf("\n***** Will be using 'bad gain' correction file %s. PLEASE CHECK.\n",fchNameBadGainIn);
626  fprintf(outFile,"\nUse 'bad gain' correction file %s.\n",fchNameBadGainIn);
627  printf("Number of lines with 'XXX' :\n");
628  fprintf(outFile,"Number of lines with 'XXX' :\n");
629  gSystem->Exec(Form("grep -c XXX %s",fchNameBadGainIn));
630  gSystem->Exec(Form("grep -c XXX %s >> %s",fchNameBadGainIn,fchNameOut));
631  printf("\n\n");
632  fprintf(outFile,"\n\n");
633  fprintf(outFile,"Tower numbers are given in Grenoble/electronic convention.\n\n");
634 
635  // Load the calibration parameters from the OCDB text file :
636  double coeffOCDB[kNbSMtot][kNbColMax][kNbRowMax]={{{0.}}};
637  double coeffCalib[kNbSMtot][kNbColMax][kNbRowMax]={{{0.}}};
638  OCDBcoeffsFile = fopen(fchNameOCDBcoeffsFile,"r");
639  if(!OCDBcoeffsFile) {printf("File %s can not be found\n",fchNameOCDBcoeffsFile);exit(-1);}
640  while (fscanf(OCDBcoeffsFile,"%d %d %d %lf",&ism,&icol,&irow,&paramFactor)>0) //Flip from Alice-offline mapping to Grenoble/electronic mapping.
641  {if ((ism%2) == 0) coeffOCDB[ism][icol][irow]=paramFactor; //Side A.
642  else coeffOCDB[ism][(kTabNbCol[SMdetType[ism]]-1)-icol][(kTabNbRow[SMdetType[ism]]-1)-irow]=paramFactor; //Side C.
643  }
644  fclose(OCDBcoeffsFile);
645  // Load the calib coefficients used to produce the OCDB file :
646  calibCoeffsFile = fopen(fchNameCalibCoeffsFile,"r");
647  if(!calibCoeffsFile) {printf("File %s can not be found\n",fchNameCalibCoeffsFile);exit(-1);}
648  while (fscanf(calibCoeffsFile,"%d %d %d %d %lf",&oldFlag,&ism,&icol,&irow,&paramFactor)>0) //Flip from Alice-offline mapping to Grenoble/electronic mapping.
649  {if ((ism%2) == 0) coeffCalib[ism][icol][irow]=paramFactor; //Side A.
650  else coeffCalib[ism][(kTabNbCol[SMdetType[ism]]-1)-icol][(kTabNbRow[SMdetType[ism]]-1)-irow]=paramFactor; //Side C.
651  }
652  fclose(calibCoeffsFile);
653 
654  // Read bad gain correction file and store the desired gains :
655  printf("\n\nRead 'bad gain' correction file.\n");
656  double forcedGainChange[kNbSMtot][kNbColMax][kNbRowMax]={{{0.}}};
657  double forcedOCDBcoeff[kNbSMtot][kNbColMax][kNbRowMax]={{{0.}}};
658  int flag[kNbSMtot][kNbColMax][kNbRowMax]={{{0}}};
659  //Need to initialize by hand because {{{5}}} doesn't put "5" everywhere ; it's still initialized to 0 !
660  for (ism=0;ism<kNbSMtot;ism++)
661  {for (icol=0;icol<kNbColMax;icol++)
662  {for (irow=0;irow<kNbRowMax;irow++) flag[ism][icol][irow]=5;
663  }
664  }
665  //In table "flag" :
666  // -3 -> force gain *and* OCDB coeff,
667  // 0 -> 'bad gain' tower but not customized yet,
668  // 1 -> calculated OCDB coeff OK,
669  // 2 -> don't change HV,
670  // 3 -> apply hand-calculated HV change,
671  // 4 [obsolete] -> 'bad gain' tower already looked at in a previous pass,
672  // 11,12,13 -> 'bad gain' tower already looked at in a previous pass, with flag resp. 1, 2, 3.
673  // 5 -> not a 'bad gain' tower.
674  badGainFileIn=fopen(fchNameBadGainIn,"r");
675  if (!badGainFileIn)
676  {printf("##### 'Bad gain' correction file %s can not be found.\n##### CAUTION : is this the 1st pass ? #####\n\n",fchNameBadGainIn);
677  fprintf(outFile,"##### 'Bad gain' correction file %s can not be found.\n##### CAUTION : is this the 1st pass ? #####\n\n",fchNameBadGainIn);
678  }
679  else
680  {while (fscanf(badGainFileIn,"%d %d %d %d %lf %lf %lf %lf",&ism,&icol,&irow,&choice,&val1,&val2,&val3,&ocdbCoeff)>0) //Caution, do use %lf with doubles, not %f.
681  {switch (TMath::Abs(choice))
682  {case 1 : if (val3 != 0.0) printf("#### Check 'bad gain' correction file (%d,%d,%d) : choice %d while val3 %f (should be 0.)\n",ism,icol,irow,choice,val3);
683  case 11 : forcedGainChange[ism][icol][irow]=val1;
684  if (val2 != 1.0) printf("#### Check 'bad gain' correction file (%d,%d,%d) : choice %d while val2 %f (should be 1.)\n",ism,icol,irow,choice,val2);
685  if (ocdbCoeff != 0.0) printf("#### Check 'bad gain' correction file (%d,%d,%d) : choice %d while OCDB coeff %f (should be 0.)\n",ism,icol,irow,choice,ocdbCoeff);
686  break;
687  case 2 :
688  case 12 : forcedGainChange[ism][icol][irow]=val2;
689  break;
690  case 0 :
691  case 3 :
692  case 4 :
693  case 13 : forcedGainChange[ism][icol][irow]=val3;
694  if ((choice == -3) && (ocdbCoeff == 0.)) printf("#### Check 'bad gain' correction file (%d,%d,%d) : choice %d while OCDB coeff %f.\n",ism,icol,irow,choice,ocdbCoeff);
695  if (val3 == 0.) printf("#### Check 'bad gain' correction file (%d,%d,%d) : choice %d while val3 %f.\n",ism,icol,irow,choice,val3);
696  break;
697  default : printf("*** Unknown choice %d for (SM,col,row) (%d,%d,%d)\n",choice,ism,icol,irow);
698  fprintf(outFile,"*** Unknown choice %d for (SM,col,row) (%d,%d,%d)\n",choice,ism,icol,irow);
699  }
700  forcedOCDBcoeff[ism][icol][irow]=ocdbCoeff;
701  flag[ism][icol][irow]=choice;
702  }
703  fclose(badGainFileIn);
704  }
705  printf("\n");
706 
707  // Launch subroutine to calculate new HV's and new OCDB params for every SM :
708  badGainFileOut=fopen(fchNameBadGainOut,"w");
709  //CUSTOMIZE customize every year (HV files + LED scans) :
710  //Merging of HV scans LED 2013, 2012 and 2011 :
711  for (ism=0;ism<kNbSMtot;ism++)
712  //for (ism=0;ism<1;ism++)
713  {if (tabChoiceCalos[SMdetType[ism]] == 0) continue;
714  //CalcNewHVperSM(Form("/cebaf/faivre/recherche/calibPi0/biasSentByDavidMay2015/bias/%s/NewBias.txt",SMP2Name[ism]),Form("/cebaf/faivre/recherche/calibPi0/recalculateDCAL_HV_July2015/HVscanParametersGrenobleDCAL/HVscanParamsGrenobleDCAL/HvscanSM%s_%s_%s/parameters.txt",SMnumber[ism],SMcalibName[ism],SMP2Name[ism]),ism,fchNameBase,outFile,badGainFileOut,coeffOCDB,coeffCalib,forcedGainChange,forcedOCDBcoeff,flag,ps,c1); //This is WRONG.
715  CalcNewHVperSM(Form("/cebaf/faivre/recherche/calibPi0/recalculateDCAL_HV_July2015/output_HVrecalculationDCAL2015July_mergedWithEMCalHV_lowerTemperature_createBias/%s/NewBias.txt",SMP2Name[ism]),Form("/cebaf/faivre/recherche/calibPi0/recalculateDCAL_HV_July2015/HVscanParametersGrenobleDCAL/HVscanParamsGrenobleDCAL/HvscanSM%s_%s_%s/parameters.txt",SMnumber[ism],SMcalibName[ism],SMP2Name[ism]),ism,fchNameBase,outFile,badGainFileOut,coeffOCDB,coeffCalib,forcedGainChange,forcedOCDBcoeff,flag,ps,c1);
716  }
717 
718  fclose(badGainFileOut);
719 
720  // Close what has been opened :
721  ps->Close();
722  rootFileOut->Close();
723  fclose(outFile);
724 
725  return;
726  }
727 
728 
729 
730 
731 
732 
733 
734 
int detTypeType[]
const int kTabNbRow[4]
Definition: External.C:236
const int kNbColMax
const int kNbSMtot
TSystem * gSystem
const int kNbRowDCAL
int lastSM
char SMcalibName[][100]
const double kMinHV
const int kNbColOffsetDCAL
const int kNbRowEMCALthird
char SMP2Name[][100]
const int kTabNbSM[4]
void CalcNewHVperSM(TString hvFileName, TString paramFileName, int smNb, char *fchNameBase, FILE *outFile, FILE *badGainFileOut, double coeffOCDB[kNbSMtot][kNbColMax][kNbRowMax], double coeffCalib[kNbSMtot][kNbColMax][kNbRowMax], double forcedGainChange[kNbSMtot][kNbColMax][kNbRowMax], double forcedOCDBcoeff[kNbSMtot][kNbColMax][kNbRowMax], int flag[kNbSMtot][kNbColMax][kNbRowMax], TPostScript *ps, TCanvas *c1)
int SMdetType[]
const int kNbSMEMCALthird
const double kMaxHV
const int kNbSMEMCAL
const int kNbRowEMCAL
const int kNbSMDCALthird
const int kNbColEMCALthird
const int kNbRowDCALthird
const int kNbColDCAL
char SMnumber[][100]
const int kNbRowMax
const int kNbSMDCAL
char detTypeString[][100]
void HVrecalculation(TString ident, int choiceArg=0b0100)
const int kTabNbCol[4]
const int kNbColDCALthird
const double coefFactorWanted
const int kNbColEMCAL