CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UECalibration.h
Go to the documentation of this file.
1 #ifndef __HiJetAlgos_UECalibration_h__
2 #define __HiJetAlgos_UECalibration_h__
3 
5 // SVD Block Predictor
6 #include <fstream>
7 #include <sstream>
8 
10 
12  explicit UECalibration(bool isRealData = true, bool isCalo = false){
13  np[0] = 3; // Number of reduced PF ID (track, ECAL, HCAL)
14  np[1] = 15; // Number of pseudorapidity block
15  np[2] = 5; // Fourier series order
16  np[3] = 2; // Re or Im
17  np[4] = 82; // Number of feature parameter
18 
19  ni0[0] = np[1];
20  ni0[1] = 344;
21 
22  ni1[0] = np[1];
23  ni1[1] = 344;
24 
25  ni2[0] = np[1];
26  ni2[1] = 82;
27 
28  index = 0;
29 
30  unsigned int Nnp_full = np[0] * np[1] * np[2] * np[3] * np[4];
31  unsigned int Nnp = np[0] * np[1] * (1 + (np[2] - 1) * np[3]) * np[4];
32  unsigned int Nni0 = ni0[0]*ni0[1];
33  unsigned int Nni1 = ni1[0]*ni1[1];
34  unsigned int Nni2 = ni2[0]*ni2[1];
35 
36  memset(ue_predictor_pf, 0, Nnp_full * sizeof(float));
37  memset(ue_interpolation_pf0, 0, Nni0 * sizeof(float));
38  memset(ue_interpolation_pf1, 0, Nni1 * sizeof(float));
39  memset(ue_interpolation_pf2, 0, Nni2 * sizeof(float));
40 
41  std::string calibrationFile;
42 
43  if(isCalo){
44  if(isRealData) calibrationFile = "RecoHI/HiJetAlgos/data/ue_calibrations_calo_data.txt";
45  if(!isRealData) calibrationFile = "RecoHI/HiJetAlgos/data/ue_calibrations_calo_mc.txt";
46  }else{
47  if(isRealData) calibrationFile = "RecoHI/HiJetAlgos/data/ue_calibrations_pf_data.txt";
48  if(!isRealData) calibrationFile = "RecoHI/HiJetAlgos/data/ue_calibrations_pf_mc.txt";
49  }
50 
51  edm::FileInPath ueData(calibrationFile.data());
52  std::string qpDataName = ueData.fullPath();
53  std::ifstream in( qpDataName.c_str() );
54  std::string line;
55 
56  while( std::getline( in, line)){
57  if(!line.size() || line[0]=='#') {
58  continue;
59  }
60  std::istringstream linestream(line);
61  float val;
62  int bin0, bin1, bin2, bin3, bin4;
63  if(index < Nnp){
64  // cout<<"predictor "<<bin0<<" "<<bin1<<" "<<bin2<<" "<<bin3<<" "<<bin4<<" "<<val<<endl;
65  linestream>>bin0>>bin1>>bin2>>bin3>>bin4>>val;
66  ue_predictor_pf[bin0][bin1][bin2][bin3][bin4] = val;
67  }else if(index < Nnp + Nni0){
68  // cout<<"inter_0 "<<bin0<<" "<<bin1<<" "<<bin2<<" "<<bin3<<" "<<bin4<<" "<<val<<endl;
69  linestream>>bin0>>bin1>>val;
70  ue_interpolation_pf0[bin0][bin1] = val;
71  }else if(index < Nnp + Nni0 + Nni1){
72  // cout<<"inter_1 "<<bin0<<" "<<bin1<<" "<<bin2<<" "<<bin3<<" "<<bin4<<" "<<val<<endl;
73  linestream>>bin0>>bin1>>val;
74  ue_interpolation_pf1[bin0][bin1] = val;
75  }else if(index < Nnp + Nni0 + Nni1 + Nni2){
76  // cout<<"inter_2 "<<bin0<<" "<<bin1<<" "<<bin2<<" "<<bin3<<" "<<bin4<<" "<<val<<endl;
77  linestream>>bin0>>bin1>>val;
78  ue_interpolation_pf2[bin0][bin1] = val;
79  }
80  ++index;
81  }
82  }
83 
84  unsigned int index,
85  np[5],
86  ni0[2],
87  ni1[2],
88  ni2[2];
89 
90  float ue_predictor_pf[3][15][5][2][82],
91  ue_interpolation_pf0[15][344],
92  ue_interpolation_pf1[15][344],
93  ue_interpolation_pf2[15][82];
94 
95 };
96 
97 
98 #endif
99 
100 
101 
unsigned int ni0[2]
Definition: UECalibration.h:84
unsigned int index
Definition: UECalibration.h:84
unsigned int ni2[2]
Definition: UECalibration.h:84
unsigned int np[5]
Definition: UECalibration.h:84
unsigned int ni1[2]
Definition: UECalibration.h:84
UECalibration(bool isRealData=true, bool isCalo=false)
Definition: UECalibration.h:12
float ue_interpolation_pf0[15][344]
Definition: UECalibration.h:90
float ue_predictor_pf[3][15][5][2][82]
Definition: UECalibration.h:90
std::string fullPath() const
Definition: FileInPath.cc:171
float ue_interpolation_pf1[15][344]
Definition: UECalibration.h:90
float ue_interpolation_pf2[15][82]
Definition: UECalibration.h:90