AliPhysics  bba8f44 (bba8f44)
PrepareHV_SM1819.C
Go to the documentation of this file.
1 
2 
3 #include <TChain.h>
4 #include <TNtuple.h>
5 #include <TObjArray.h>
6 #include <TSystem.h>
7 #include <TString.h>
8 #include <TH1F.h>
9 #include <TVector.h>
10 #include <TRefArray.h>
11 #include <TArrayS.h>
12 #include "TError.h"
13 #include "TTree.h"
14 #include "TClonesArray.h"
15 #include "TGraphErrors.h"
16 #include "TPostScript.h"
17 #include "TLegend.h"
18 #include "TH2I.h"
19 #include "TF1.h"
20 #include "TStyle.h"
21 #include "TCanvas.h"
22 #include "TPolyLine.h"
23 #include "TLine.h"
24 #include "TFile.h"
25 #include "TMath.h"
26 #include "TLeaf.h"
27 #include "TBranch.h"
28 
29 
30 //#include "/cebaf/cebaf/EMCAL/cosmicsAnalysis/macros/defineMyPalette40All.C"
31 
32 
33  char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
34  char SMnumber[][100]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
35 
36 
39  char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
41  const int kNbColEMCAL=48;
42  const int kNbRowEMCAL=24;
43  const int kNbSMEMCAL=10;
45  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
46  const int kNbSMEMCALthird=2;
47  const int kNbColDCAL=32;
49  const int kNbSMDCAL=6;
52  const int kNbSMDCALthird=2;
53  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
54  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
55  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
56  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
60 
61 
75 
79 void PrepareHV_SM1819(int nbSM)
80 {int iSM,iCol,iRow,sm,col,row,k,offset;
81  double tabP2[4],tabCoeffs[kNbSMtot][kNbColMax][kNbRowMax],tabHV[kNbSMtot][kNbColMax][kNbRowMax];
82  double hv,coeff;
83  tabP2[0]=0.03;
84  tabP2[1]=0.025;
85  tabP2[2]=0.02;
86  tabP2[3]=0.01;
87 
88  if ((nbSM != 18) && (nbSM != 19))
89  {printf("Wrong SM number.\n");
90  return;
91  }
92 
93  FILE *fch = new FILE;
94  fch = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/createOCDB_4_with2015data/multiplyPi0CalibrationFactors_TextToHisto_Final.txt","r");
95  //Convention is offline mapping. Need to swap to electronic mapping.
96  //Coeff convention is pi0 calib in the file read.
97  for (iSM=0;iSM<kNbSMtot;iSM++)
98  {for (iCol=0;iCol<kTabNbCol[SMdetType[iSM]];iCol++)
99  {for (iRow=0;iRow<kTabNbRow[SMdetType[iSM]];iRow++)
100  {fscanf(fch," %d %d %d %lf\n",&sm,&col,&row,&coeff);
101  if ((sm != iSM) || (col != iCol) || (row != iRow)) printf("=========== Out of sync OCDB (%d %d %d) vs (%d %d %d) ============\n",sm,col,row,iSM,iCol,iRow);
102  if (nbSM == 18) tabCoeffs[sm][col][row]=1./coeff;
103  else tabCoeffs[sm][(kTabNbCol[SMdetType[iSM]]-1)-col][(kTabNbRow[SMdetType[iSM]]-1)-row]=1./coeff;
104  }
105  }
106  }
107 
108  fclose(fch);
109 
110  fch = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/recalculateHV_4_with2015data/output_HVrecalculation_pass2_createSetBiasScripts/SMA12/NewBias.txt","r");
111  //In this file, the voltages actually applied to SM18 during calib data-taking were rows 16-23. Those actually applied to SM19 were rows 0-7.
112  //Convention is electronic mapping.
113  offset=0;
114  if (nbSM == 18) offset=16;
115  for (iCol=0;iCol<kTabNbCol[SMdetType[nbSM]];iCol++)
116  {for (iRow=0;iRow<kNbRowMax;iRow++)
117  {fscanf(fch," %d %d %lf\n",&col,&row,&hv);
118  if ((col != iCol) || (row != iRow)) printf("=========== Out of sync HV (%d %d %d) vs (%d %d %d) ============\n",nbSM,col,row,nbSM,iCol,iRow);
119  tabHV[nbSM][col][row]=hv;
120  }
121  }
122 
123  fclose(fch);
124 
125  for (iCol=0;iCol<kTabNbCol[SMdetType[nbSM]];iCol++)
126  {for (iRow=0;iRow<kNbRowDCALthird;iRow++)
127  {coeff=tabCoeffs[nbSM][iCol][iRow];
128  hv=tabHV[nbSM][iCol][iRow+offset];
129  printf("%d %d %d %d coeff %f prevHV %7.3f",nbSM,iCol,iRow,iRow+16,coeff,hv);
130  if (coeff == 1.) printf(" no HV change");
131  else
132  {printf(" HVs");
133  for (k=0;k<4;k++)
134  {printf(" %6.2f",hv+log(coeff)/tabP2[k]);
135  if (k == 1) printf("**");
136  }
137  }
138  printf("\n");
139  }
140  }
141 
142 
143  return;
144  }
145 
146 
147 
148 
149 
150 
const int kNbColMax
const int kNbRowDCALthird
char SMnumber[][100]
const int kNbRowEMCALthird
const int kNbColDCALthird
const int kNbColDCAL
const int kNbRowEMCAL
const int kNbSMEMCAL
const int kNbRowMax
const int kNbSMtot
const int kTabNbCol[4]
int SMdetType[]
const int kNbColEMCAL
const int kNbSMDCAL
const int kNbSMDCALthird
const int kTabNbSM[4]
const int kNbSMEMCALthird
char SMP2Name[][100]
const int kNbRowDCAL
const int kNbColEMCALthird
int detTypeType[]
void PrepareHV_SM1819(int nbSM)
const int kTabNbRow[4]
const int kNbColOffsetDCAL
char detTypeString[][100]