Belle II Software  release-08-01-10
CDCDedx2DCellAlgorithm.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <calibration/CalibrationAlgorithm.h>
12 
13 #include <TH1F.h>
14 
15 #include <iostream>
16 
17 namespace Belle2 {
27 
28  public:
29 
34 
39 
43  void setGlobalEntaBins(int value) {fnEntaBinG = value;}
44 
48  void setGlobalDocaBins(int value) {fnDocaBinG = value;}
49 
53  void setAsymmetricBins(bool value) {IsLocalBin = value;}
54 
58  void setRotationSymmetry(bool value) {IsRS = value;}
59 
63  void setOutFilePrefix(const std::string& value) {fSetPrefix = value;}
64 
68  void setMonitoringPlots(bool value = false) {IsMakePlots = value;}
72  int GetRotationSymmericBin(int nbin, int ibin)
73  {
74 
75  if (nbin % 4 != 0)return -1;
76  int jbin;
77  if (ibin <= nbin / 4) jbin = ibin + nbin / 2 ;
78  else if (ibin > 3 * nbin / 4) jbin = ibin - nbin / 2 ;
79  else jbin = ibin;
80 
81  return jbin;
82  }
83 
87  void GetVariableBin(int nbin, std::vector<int>& nBinEnta0to100Per)
88  {
89 
90  if (nbin % 8 != 0) {
91  std::cout << "Please select global in multiple of 8 " << std::endl;
92  return ;
93  }
94 
95  int jbin = -1;
96  std::vector<int> nBinEnta0to25Per;
97  for (int ibin = 0; ibin < nbin / 4; ibin++) {
98  if (ibin < nbin / 8) jbin++;
99  else if (TMath::Abs(ibin - nbin / 8) % 2 == 0)jbin++;
100  nBinEnta0to25Per.push_back(jbin);
101  }
102 
103  std::vector<int> temp = nBinEnta0to25Per;
104  std::reverse(temp.begin(), temp.end());
105 
106  std::vector<int> nBinEnta25to50Per; //second half (0 to pi/2)
107  for (unsigned int it = 0; it < temp.size(); ++it)nBinEnta25to50Per.push_back(2 * jbin - temp.at(it) + 1);
108 
109  std::vector<int> nBinEnta0to50Per = nBinEnta0to25Per;
110  nBinEnta0to50Per.insert(nBinEnta0to50Per.end(), nBinEnta25to50Per.begin(), nBinEnta25to50Per.end());
111 
112  std::vector<int> nBinEnta50to100Per;
113  for (unsigned int it = 0; it < nBinEnta0to50Per.size(); ++it) {
114  nBinEnta50to100Per.push_back(nBinEnta0to50Per.at(nBinEnta0to50Per.size() - 1) + nBinEnta0to50Per.at(it) + 1);
115  }
116 
117  nBinEnta0to100Per = nBinEnta0to50Per;
118  nBinEnta0to100Per.insert(nBinEnta0to100Per.end(), nBinEnta50to100Per.begin(), nBinEnta50to100Per.end());
119 
120  TH1F* tempEnta = new TH1F("tempEnta", "tempEnta", fnEntaBinG, feaLE, feaUE);
121  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(1)); //first and last manual
122  for (unsigned int i = 0; i < nBinEnta0to100Per.size() - 1; ++i) {
123  if (nBinEnta0to100Per.at(i) < nBinEnta0to100Per.at(i + 1)) {
124  double binval = tempEnta->GetBinLowEdge(i + 1) + tempEnta->GetBinWidth(i + 1);
125  if (TMath::Abs(binval) < 10e-5)binval = 0; //avoid infinite deep
126  fEntaBinValues.push_back(binval);
127  } else continue;
128  }
129  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(fnEntaBinG) + tempEnta->GetBinWidth(fnEntaBinG));
130  delete tempEnta;
131  }
132 
133 
134  protected:
135 
139  virtual EResult calibrate() override;
140 
141  private:
142 
153  Double_t feaLE;
154  Double_t feaUE;
155  Double_t feaBS;
157  Double_t fdocaLE;
158  Double_t fdocaUE;
159  Double_t fdocaBS;
161  std::string fSetPrefix;
162  std::vector<int> fDocaBinNums;
163  std::vector<double> fDocaBinValues;
165  std::vector<int> fEntaBinNums;
166  std::vector<double> fEntaBinValues;
168  bool IsLocalBin;
169  bool IsMakePlots;
170  bool IsRS;
171  };
173 } // namespace Belle2
A calibration algorithm for CDC dE/dx electron 2D enta vs doca correction.
bool IsRS
if rotation symmtery requested
bool IsLocalBin
if local variable bin requested
std::vector< double > fEntaBinValues
Vector for doca asym bin values.
Double_t fdocaUE
Upper edge of doca.
Double_t fdocaLE
Lower edge of doca.
int fnDocaBinG
doca angle bins, Global
Double_t feaBS
Binwidth edge of enta angle.
void setOutFilePrefix(const std::string &value)
adding prefix to filenae for uniqueness in each iter
std::vector< double > fDocaBinValues
Vector for doca asym bin #.
void setAsymmetricBins(bool value)
Set asym bins flag to on or off.
std::vector< int > fEntaBinNums
Vector for enta asym bin values.
int fnDocaBinL
doca angle bins, Local
CDCDedx2DCellAlgorithm()
Constructor: Sets the description the properties and the parameters of the algorithm.
int fnEntaBinL
etna angle bins, Local
std::string fSetPrefix
prefix to filename
Double_t fdocaBS
Binwidth edge of doca.
void setGlobalDocaBins(int value)
Set doca angle bins, Global anything is fine for the moment.
int GetRotationSymmericBin(int nbin, int ibin)
funtion to set rotation symmetry
bool IsMakePlots
produce plots for status
void setGlobalEntaBins(int value)
Set etna angle bins, Global in multiple of 8.
virtual EResult calibrate() override
2D Cell algorithm algorithm
int fnEntaBinG
Save arithmetic and truncated mean for the 'dedx' values.
void setRotationSymmetry(bool value)
Set asym bins flag to on or off.
void setMonitoringPlots(bool value=false)
funtion to set flag active for plotting
virtual ~CDCDedx2DCellAlgorithm()
Destructor.
std::vector< int > fDocaBinNums
Vector for enta asym bin #.
Double_t feaLE
Lower edge of enta angle.
void GetVariableBin(int nbin, std::vector< int > &nBinEnta0to100Per)
funtion to set variable bins
Double_t feaUE
Upper edge of enta angle.
Base class for calibration algorithms.
EResult
The result of calibration.
Abstract base class for different kinds of events.