ATLAS Offline Software
Loading...
Searching...
No Matches
PixelChargeInterpolationCalibration.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef PixelChargeInterpolationCalibration_cxx
6#define PixelChargeInterpolationCalibration_cxx
7
8#include <iostream>
9#include <fstream>
10#include <vector>
11#include <string>
12
13#include <TDirectory.h>
14
19
20namespace PixelCalib{
21
32
34
42
44
46
47 TDirectory *current = gDirectory;
48 TDirectory *globaldir = gDirectory;
49 if(histofile != 0) globaldir = histofile;
50
51 globaldir->cd("ChargeInterpolation");
53 m_AnalogCalibration->Read();
54
55 current->cd();
56}
57
59
61
62 TDirectory *current = gDirectory;
63 TDirectory *globaldir = gDirectory;
64 if(writedir != 0) globaldir = writedir;
65
66 globaldir->mkdir("ChargeInterpolation")->cd();
67 m_DigitalCalibration->Write();
68 m_AnalogCalibration->Write();
69 m_plots->Write();
70
71 current->cd();
72
73}
74
76
78 Double_t alpha, Double_t DeltaRow, Double_t digresphi,
79 Double_t resphi, Double_t OmegaPhi,
80 Double_t TrkEta, Double_t DeltaCol, Double_t digreseta,
81 Double_t reseta, Double_t OmegaEta){
82
83 // hack to uniform constants for all layers and for all disks
84 int modifier = 0;
85 int totlayers = 3;
86 if(DetType == 0) totlayers = 1;
87 else if(DetType < 4) modifier = 1;
88 else modifier = 4;
89 // fill with the same values for the relevant layers
90 for(int iLayer = 0; iLayer < totlayers; iLayer++){
91 DetType = iLayer + modifier;
92 m_DigitalCalibration->Fill(DetType, GeVTrkPt,
93 TrkEta, DeltaCol, digreseta, OmegaEta,
94 alpha, DeltaRow, digresphi, OmegaPhi);
95 m_AnalogCalibration->Fill(DetType, GeVTrkPt,
96 TrkEta, DeltaCol, reseta, OmegaEta,
97 alpha, DeltaRow, resphi, OmegaPhi);
98 }
99
100}
101
103
104int PixelChargeInterpolationCalibration::Analyze( const std::string& output,
105 std::vector<std::string> &reference_names){
106
107 PixelChargeInterpolationParameters *DigitalParameters = 0;
108 PixelChargeInterpolationParameters *AnalogParameters = 0;
109
110 std::ofstream logfile;
111 logfile.open((output + ".log").c_str());
112 logfile << "Log file for the pixel calibration fits." << std::endl;
113
114 DigitalParameters = m_DigitalCalibration->Analyze(logfile);
115 AnalogParameters = m_AnalogCalibration->Analyze(logfile);
116
117 logfile.close();
118
119 std::string name = "PixelChargeInterpolationData-" + output;
120 size_t pos = output.find("PixelOfflineReco");
121 if(pos != std::string::npos){
122 name = "PixelChargeInterpolationData"
123 + output.substr(pos+16,std::string::npos);
124 }
125 DigitalParameters->Print(name);
126 name = "Analog-" + name;
127 AnalogParameters->Print(name);
128
129 m_plots = new PixelChargeInterpolationPlot(*DigitalParameters);
130 m_plots->AddReference(*AnalogParameters,
131 std::string("Fit on analog residual (should give 0)").c_str(),3,std::string("P"));
132 //std::cout << reference_names.size() << std::endl;
133 for(unsigned int i = 0 ; i < reference_names.size() ; i++ ){
134 //std::cout << reference_names[i] << std::endl;
135 std::ifstream fin((reference_names[i]).c_str());
136 if(!fin.fail()){
137 fin.close();
140 RefParameters->Load(reference_names[i]);
141 int color = 4+i;
142 if(color == 5) color = 1;
143 m_plots->AddReference(*RefParameters,reference_names[i],color,std::string("P"));
144 delete RefParameters;
145 }
146 }
147 m_plots->Plot(output);
148
149
150 return 0;
151}
152
153
154} // end of namespace PixelCalib
155
156#endif
int Analyze(const std::string &output, std::vector< std::string > &reference_names)
PixelChargeInterpolationCalibration(const std::string &tag, PixelChargeInterpolationParameters &parametersModel)
void Fill(int DetType, double GeVTrkPt, double alpha, double DeltaRow, double digresphi, double resphi, double OmegaPhi, double TrkEta, double DeltaCol, double digreseta, double reseta, double OmegaEta)