ATLAS Offline Software
Calib.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***********************************************************************************************
6 // CalibInfo - Class to store the calibration information
7 // ---------------------------------------
8 // begin : 01 11 2023
9 // email : sergi.rodriguez@cern.ch
10 //***********************************************************************************************
11 
12 #ifndef PIXCALIB_H
13 #define PIXCALIB_H
14 
15 #include "TKey.h"
16 #include "TString.h"
17 #include "TFile.h"
18 #include "TH1F.h"
19 #include "TF1.h"
20 #include "TH2F.h"
21 #include "TDirectoryFile.h"
22 #include "TGraphErrors.h"
25 
26 #include <map>
27 #include <iostream>
28 #include <array>
29 #include <cmath>
30 
31 
32 
33 
34 class Calib {
35  public:
36  Calib (int whichPart, bool saveFile, const std::string & moduleName = "") {
37  m_whichPart = whichPart;
38 
39  if(saveFile){
40  m_savefile = saveFile;
41  m_wFile = std::make_unique<TFile>(m_layers.at(whichPart)+".HIST.root","RECREATE");
42  }
43  if( not moduleName.empty() ){
44  m_runOneMOD = true;
45  m_testMOD = moduleName;
46  }
47  };
48  ~ Calib (){
49  if(m_savefile){
50  m_wFile->Write(0,TObject::kOverwrite);
51  m_wFile->Close();
52  }
53  };
54  bool fillThresholds(const pix::PixelMapping &pm, const std::string &inThrFile, std::map<unsigned int , std::vector<std::unique_ptr<CalibFrontEndInfo>> > &map_info);
55  bool fillTiming (const pix::PixelMapping &pm, const std::string &inTimFile, std::map<unsigned int , std::vector<std::unique_ptr<CalibFrontEndInfo>> > &map_info);
56  bool totFitting (const pix::PixelMapping &pm, const std::string &inTimFile, std::map<unsigned int , std::vector<std::unique_ptr<CalibFrontEndInfo>> > &map_info);
57 
58  private:
59 
60  bool m_savefile = false;
61  std::unique_ptr<TFile> m_wFile;
62 
63  bool m_runOneMOD = false;
64  TString m_testMOD = "";
65 
66  static constexpr float m_chi_error = 0.05;
67 
68  // privated vars
69  int m_whichPart = -1;
70  const std::array<TString, 4> m_MODprefixes{"L0", "L1", "L2", "D"};
71  const std::array<TString, 4> m_layers{"Blayer", "L1", "L2", "Disk"};
72 
73  static constexpr int m_etaBins = 144;
74  static constexpr int m_phiBins = 320;
75 
76  static constexpr int m_thrnbins = 200;
77  static constexpr float m_thrLo = 0.;
78  static constexpr float m_thrHi = 6000.;
79  static constexpr float m_sigLo = 0.;
80  static constexpr float m_sigHi = 500;
81 
82  static constexpr int m_timnbins = 300;
83  static constexpr float m_timLo = 1000.;
84  static constexpr float m_timHi = 7000.;
85 
86  static constexpr int m_totnbins = 255;
87  static constexpr float m_totLo = 0.;
88  static constexpr float m_totHi = 255.;
89  static constexpr int m_totsigNBins = 100;
90  static constexpr float m_totsigLo = 0.;
91  static constexpr float m_totsigHi = 1.;
92 
93  // injected charges
94  static constexpr int m_nFE = 16;
95  static constexpr int m_ncharge = 21;
96  static constexpr std::array<float, m_ncharge> m_chargeArr{ 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 12000, 14000, 16000, 18000, 20000, 25000};
97  static constexpr std::array<float, m_ncharge> m_chargeErrArr{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
98 
99  // injection starting point for fit
100  static constexpr int m_qthresh = 5;
101 
102  // privated functions
103  int chipId(int iphi, int ieta);
104  int pixelType(int iphi, int ieta, bool isForTOT = false);
105  TIter getRodIterator(const TFile & inputFile);
106  TIter getModuleIterator( TDirectoryFile* rodDir);
107  TH2F* get2DHistogramFromPath( TDirectoryFile* rodDir, const TString & moduleName, const TString & histName, int charge=-1);
108  bool moduleInPart(const TString & modName);
109  std::vector<float> getParams(const TF1 *f, unsigned int params);
110  std::vector<float> getParams_quality(const TF1 *f);
111  bool reFit_normalPix(std::vector<float> &params, std::vector<float> &q, std::vector<float> &qerr, std::vector<float> &tot, std::vector<float> &toterr, std::vector<float> &sig, std::vector<float> &sigerr, const unsigned int fe);
112  void graphTitles(const std::unique_ptr<TGraphErrors> &graph, const std::string &name, const std::string &Yname);
113 
114  class funcTot {
115  public:
116  // use constructor to customize your function object
117  double operator() (double *x, double *par) {
118  double ret = 9.9e10;
119  double num = x[0]+par[1];
120  double denom = x[0]+par[2];
121  if (denom != 0.0) ret = par[0]*(num/denom);
122  return ret;
123  }
124  };
125 
126  class funcDisp {
127  public:
128  // use constructor to customize your function object
129  double operator() (double *x, double *par) {
130  double ret = 9.9e10;
131  ret = par[0]+par[1]*x[0];
132  return ret;
133  }
134  };
135 
136 };
137 
138 #endif
Calib::funcDisp
Definition: Calib.h:126
Calib::m_chi_error
static constexpr float m_chi_error
Definition: Calib.h:66
Calib::m_layers
const std::array< TString, 4 > m_layers
Definition: Calib.h:71
Calib::m_phiBins
static constexpr int m_phiBins
Definition: Calib.h:74
Calib::chipId
int chipId(int iphi, int ieta)
Definition: Calib.cxx:716
Calib::m_nFE
static constexpr int m_nFE
Definition: Calib.h:94
Calib::getRodIterator
TIter getRodIterator(const TFile &inputFile)
Definition: Calib.cxx:753
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
Calib::m_chargeArr
static constexpr std::array< float, m_ncharge > m_chargeArr
Definition: Calib.h:96
Calib::pixelType
int pixelType(int iphi, int ieta, bool isForTOT=false)
Definition: Calib.cxx:732
Calib::m_MODprefixes
const std::array< TString, 4 > m_MODprefixes
Definition: Calib.h:70
Calib::m_savefile
bool m_savefile
Definition: Calib.h:60
PixelMapping.h
Calib::m_sigLo
static constexpr float m_sigLo
Definition: Calib.h:79
Calib::funcTot::operator()
double operator()(double *x, double *par)
Definition: Calib.h:117
Calib::m_thrLo
static constexpr float m_thrLo
Definition: Calib.h:77
Calib::m_totsigLo
static constexpr float m_totsigLo
Definition: Calib.h:90
Calib::m_timnbins
static constexpr int m_timnbins
Definition: Calib.h:82
Calib::m_totHi
static constexpr float m_totHi
Definition: Calib.h:88
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
Calib::getParams_quality
std::vector< float > getParams_quality(const TF1 *f)
Definition: Calib.cxx:796
x
#define x
Calib::m_thrHi
static constexpr float m_thrHi
Definition: Calib.h:78
Calib::m_timHi
static constexpr float m_timHi
Definition: Calib.h:84
Calib::m_timLo
static constexpr float m_timLo
Definition: Calib.h:83
CalibFrontEndInfo.h
Calib::m_chargeErrArr
static constexpr std::array< float, m_ncharge > m_chargeErrArr
Definition: Calib.h:97
Calib::reFit_normalPix
bool reFit_normalPix(std::vector< float > &params, std::vector< float > &q, std::vector< float > &qerr, std::vector< float > &tot, std::vector< float > &toterr, std::vector< float > &sig, std::vector< float > &sigerr, const unsigned int fe)
Definition: Calib.cxx:298
Calib::~ Calib
~ Calib()
Definition: Calib.h:48
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
Calib::m_wFile
std::unique_ptr< TFile > m_wFile
Definition: Calib.h:61
Calib::m_totsigHi
static constexpr float m_totsigHi
Definition: Calib.h:91
python.BuildSignatureFlags.sig
sig
Definition: BuildSignatureFlags.py:218
Calib::getModuleIterator
TIter getModuleIterator(TDirectoryFile *rodDir)
Definition: Calib.cxx:759
Calib::m_etaBins
static constexpr int m_etaBins
Definition: Calib.h:73
Calib::Calib
Calib(int whichPart, bool saveFile, const std::string &moduleName="")
Definition: Calib.h:36
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Calib
Definition: Calib.h:34
Calib::funcDisp::operator()
double operator()(double *x, double *par)
Definition: Calib.h:129
compute_lumi.denom
denom
Definition: compute_lumi.py:76
pix::PixelMapping
Definition: PixelMapping.h:18
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
Calib::m_qthresh
static constexpr int m_qthresh
Definition: Calib.h:100
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Calib::m_thrnbins
static constexpr int m_thrnbins
Definition: Calib.h:76
Calib::m_totsigNBins
static constexpr int m_totsigNBins
Definition: Calib.h:89
Calib::m_sigHi
static constexpr float m_sigHi
Definition: Calib.h:80
Calib::graphTitles
void graphTitles(const std::unique_ptr< TGraphErrors > &graph, const std::string &name, const std::string &Yname)
Definition: Calib.cxx:805
Calib::m_totnbins
static constexpr int m_totnbins
Definition: Calib.h:86
Calib::m_runOneMOD
bool m_runOneMOD
Definition: Calib.h:63
Calib::fillThresholds
bool fillThresholds(const pix::PixelMapping &pm, const std::string &inThrFile, std::map< unsigned int, std::vector< std::unique_ptr< CalibFrontEndInfo >> > &map_info)
Definition: Calib.cxx:532
BchCleanup.modName
modName
Definition: BchCleanup.py:201
Calib::moduleInPart
bool moduleInPart(const TString &modName)
Definition: Calib.cxx:779
Calib::m_ncharge
static constexpr int m_ncharge
Definition: Calib.h:95
Calib::getParams
std::vector< float > getParams(const TF1 *f, unsigned int params)
Definition: Calib.cxx:787
extractSporadic.q
list q
Definition: extractSporadic.py:98
Calib::get2DHistogramFromPath
TH2F * get2DHistogramFromPath(TDirectoryFile *rodDir, const TString &moduleName, const TString &histName, int charge=-1)
Definition: Calib.cxx:764
Calib::totFitting
bool totFitting(const pix::PixelMapping &pm, const std::string &inTimFile, std::map< unsigned int, std::vector< std::unique_ptr< CalibFrontEndInfo >> > &map_info)
Definition: Calib.cxx:15
Calib::m_whichPart
int m_whichPart
Definition: Calib.h:69
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
Calib::funcTot
Definition: Calib.h:114
Calib::m_totLo
static constexpr float m_totLo
Definition: Calib.h:87
Calib::fillTiming
bool fillTiming(const pix::PixelMapping &pm, const std::string &inTimFile, std::map< unsigned int, std::vector< std::unique_ptr< CalibFrontEndInfo >> > &map_info)
Definition: Calib.cxx:352
Calib::m_testMOD
TString m_testMOD
Definition: Calib.h:64