10#include <ecl/dataobjects/ECLElementNumbers.h>
67int main(
int argc,
char* argv[])
70 TString OutputDirectory =
".";
71 if (OutputDirectory ==
"") {
72 std::cout <<
"Error set output directory" << std::endl;
77 int Flag = atoi(argv[1]);
78 TString InputDirectory = OutputDirectory;
80 TString ParameterTreeOutputName = OutputDirectory +
"PhotonWaveformParameters.root";
81 if (Flag == 1) ParameterTreeOutputName =
"DigitWaveformParameters.root";
82 TFile* ParameterTreeOutputFile =
new TFile(ParameterTreeOutputName,
"RECREATE");
84 TTree* ParameterTree =
new TTree(
"ParTree",
"");
85 double PhotonWaveformPar[11];
86 double HadronWaveformPar[11];
87 double DiodeWaveformPar[11];
88 for (
int k = 0; k < 11; k++) {
89 PhotonWaveformPar[k] = 0;
90 HadronWaveformPar[k] = 0;
91 DiodeWaveformPar[k] = 0;
93 double mHadronRes = 0;
95 double mHadronMax = 0;
97 ParameterTree->Branch(
"PhotonPar", &PhotonWaveformPar,
"PhotonWaveformPar[11]/D");
98 ParameterTree->Branch(
"HadronPar", &HadronWaveformPar,
"HadronWaveformPar[11]/D");
99 ParameterTree->Branch(
"DiodePar", &DiodeWaveformPar,
"DiodeWaveformPar[11]/D");
100 ParameterTree->Branch(
"mHadronRes", &mHadronRes,
"mHadronRes/D");
101 ParameterTree->Branch(
"mDiodeRes", &mDiodeRes,
"mDiodeRes/D");
102 ParameterTree->Branch(
"mHadronMax", &mHadronMax,
"mHadronMax/D");
103 ParameterTree->Branch(
"mDiodeMax", &mDiodeMax,
"mDiodeMax/D");
106 ifstream PhotonFile(
"/home/belle2/longos/WaveformFitting/ecl/tools/params_gamma_shape.dat");
107 if (PhotonFile.is_open()) {
108 std::vector<double> templine(12);
110 for (
unsigned int j = 0; j < templine.size(); j++) PhotonFile >> templine[j];
111 cellIDcheck[int(templine[0]) - 1].PhotonWaveformPars.resize(11);
112 cellIDcheck[int(templine[0]) - 1].PhotonWaveformPars[0] = templine[1];
113 for (
int j = 0; j < 10; j++) cellIDcheck[
int(templine[0]) - 1].PhotonWaveformPars[j + 1] = templine[j + 2];
114 std::cout << int(templine[0]) <<
" " << templine[1] << endl;
118 std::cout <<
"ERROR cannot open photon param file." << endl;
122 for (
unsigned int f = 0; f < cellIDcheck.size(); f++) {
123 for (
int k = 0; k < 11; k++) PhotonWaveformPar[k] = cellIDcheck[f].PhotonWaveformPars[k];
124 ParameterTree->Fill();
126 }
else if (Flag == 1) {
128 for (
int k = 0; k < 874; k++) {
130 int high = (k + 1) * batch;
132 TFile* TempFile =
new TFile(InputDirectory + Form(
"HadronPars_Low%d_High%d.root", low, high),
"READ");
133 TTree* TempTree = (TTree*) TempFile->Get(
"HadronWaveformInfo");
134 double tHadronShapePars_A[11];
135 double tDiodeShapePars_A[11];
136 double tMaxResidualHadron_A;
137 double tMaxResidualDiode_A;
138 double tMaxValDiode_A;
139 double tMaxValHadron_A;
140 TempTree->SetBranchAddress(
"TempHadronPar11_A", &tHadronShapePars_A);
141 TempTree->SetBranchAddress(
"TempDiodePar11_A", &tDiodeShapePars_A);
142 TempTree->SetBranchAddress(
"MaxResHadron_A", &tMaxResidualHadron_A);
143 TempTree->SetBranchAddress(
"MaxResDiode_A", &tMaxResidualDiode_A);
144 TempTree->SetBranchAddress(
"MaxValDiode_A", &tMaxValDiode_A);
145 TempTree->SetBranchAddress(
"MaxValHadron_A", &tMaxValHadron_A);
147 for (
int j = 0; j < batch; j++) {
148 int tCellID = (k * batch) + j;
150 TempTree->GetEntry(j);
151 cellIDcheck[tCellID].HadronWaveformPars.resize(11);
152 cellIDcheck[tCellID].DiodeWaveformPars.resize(11);
153 for (
int p = 0; p < 11; p++) {
154 if (tHadronShapePars_A[p] > 100 || tHadronShapePars_A[p] < -100) {
155 std::cout <<
"Warning large parameter for: " << tCellID <<
" " << tHadronShapePars_A[p] << std::endl;
156 for (
int h = 0; h < 11; h++)std::cout << tHadronShapePars_A[h] <<
" , ";
157 std::cout << std::endl;
159 cellIDcheck[tCellID].HadronWaveformPars[p] = tHadronShapePars_A[p];
164 cellIDcheck[tCellID].MaxResHadron = tMaxResidualHadron_A;
165 cellIDcheck[tCellID].MaxValHadron = tMaxValHadron_A;
166 for (
int p = 0; p < 11; p++) cellIDcheck[tCellID].DiodeWaveformPars[p] = tDiodeShapePars_A[p];
167 cellIDcheck[tCellID].MaxResDiode = tMaxResidualDiode_A;
168 cellIDcheck[tCellID].MaxValDiode = tMaxValDiode_A;
174 for (
int k = 0; k < 11; k++) {
175 PhotonWaveformPar[k] = cellIDcheck[f].PhotonWaveformPars[k];
176 HadronWaveformPar[k] = cellIDcheck[f].HadronWaveformPars[k];
177 DiodeWaveformPar[k] = cellIDcheck[f].DiodeWaveformPars[k];
179 mHadronRes = cellIDcheck[f].MaxResHadron;
180 mDiodeRes = cellIDcheck[f].MaxResDiode;
181 mHadronMax = cellIDcheck[f].MaxValHadron;
182 mDiodeMax = cellIDcheck[f].MaxValDiode;
183 ParameterTree->Fill();
187 ParameterTreeOutputFile->cd();
188 ParameterTree->Write();
189 ParameterTreeOutputFile->Write();
190 ParameterTreeOutputFile->Close();
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
a struct to hold relevant Crystal information
vector< double > PhotonWaveformPars
photon waveform parameters
vector< double > HadronWaveformPars
hadron waveform parameters
vector< double > DiodeWaveformPars
diode waveform parameters