Belle II Software  release-08-01-10
CDCDedx1DCellAlgorithm.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 <reconstruction/dbobjects/CDCDedx1DCell.h>
12 #include <calibration/CalibrationAlgorithm.h>
13 #include <framework/database/DBObjPtr.h>
14 
15 #include <TF1.h>
16 #include <TLine.h>
17 #include <TMath.h>
18 #include <TH1F.h>
19 #include <TH1D.h>
20 #include <TBox.h>
21 #include <TString.h>
22 #include <TCanvas.h>
23 
24 namespace Belle2 {
34 
35  public:
36 
41 
46 
50  void setGlobalEntaBins(int value) {fnEntaBinG = value;}
51 
55  void setAsymmetricBins(bool value) {IsLocalBin = value;}
56 
60  void setRotationSymBins(bool value) {IsRS = value;}
61 
65  void setMonitoringPlots(bool value) {IsMakePlots = value;}
66 
70  void setOutFilePrefix(const std::string& value) {fSetPrefix = value;}
71 
75  int GetRotationSymmericBin(int nbin, int ibin)
76  {
77 
78  if (nbin % 4 != 0)return -1;
79  int jbin;
80  if (ibin <= nbin / 4) jbin = ibin + nbin / 2 ;
81  else if (ibin > 3 * nbin / 4) jbin = ibin - nbin / 2 ;
82  else jbin = ibin;
83 
84  return jbin;
85  }
86 
90  void GetVariableBin(int nbin, std::vector<int>& nBinEnta0to100Per)
91  {
92 
93  if (nbin % 8 != 0) {
94  std::cout << "Please select global in multiple of 8 " << std::endl;
95  return ;
96  }
97 
98  int jbin = -1;
99  std::vector<int> nBinEnta0to25Per;
100  for (int ibin = 0; ibin < nbin / 4; ibin++) {
101  if (ibin < nbin / 8) jbin++;
102  else if (TMath::Abs(ibin - nbin / 8) % 2 == 0)jbin++;
103  nBinEnta0to25Per.push_back(jbin);
104  }
105 
106  std::vector<int> temp = nBinEnta0to25Per;
107  std::reverse(temp.begin(), temp.end());
108 
109  std::vector<int> nBinEnta25to50Per; //second half (0 to pi/2)
110  for (unsigned int it = 0; it < temp.size(); ++it)nBinEnta25to50Per.push_back(2 * jbin - temp.at(it) + 1);
111 
112  std::vector<int> nBinEnta0to50Per = nBinEnta0to25Per;
113  nBinEnta0to50Per.insert(nBinEnta0to50Per.end(), nBinEnta25to50Per.begin(), nBinEnta25to50Per.end());
114 
115  std::vector<int> nBinEnta50to100Per;
116  for (unsigned int it = 0; it < nBinEnta0to50Per.size(); ++it) {
117  nBinEnta50to100Per.push_back(nBinEnta0to50Per.at(nBinEnta0to50Per.size() - 1) + nBinEnta0to50Per.at(it) + 1);
118  }
119 
120  nBinEnta0to100Per = nBinEnta0to50Per;
121  nBinEnta0to100Per.insert(nBinEnta0to100Per.end(), nBinEnta50to100Per.begin(), nBinEnta50to100Per.end());
122 
123  TH1D* tempEnta = new TH1D("tempEnta", "tempEnta", fnEntaBinG, feaLE, feaUE);
124  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(1)); //first and last manual
125  for (unsigned int i = 0; i < nBinEnta0to100Per.size() - 1; ++i) {
126  if (nBinEnta0to100Per.at(i) < nBinEnta0to100Per.at(i + 1)) {
127  double binval = tempEnta->GetBinLowEdge(i + 1) + tempEnta->GetBinWidth(i + 1);
128  if (TMath::Abs(binval) < 10e-5)binval = 0; //avoid infinite deep
129  fEntaBinValues.push_back(binval);
130  } else continue;
131  }
132  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(fnEntaBinG) + tempEnta->GetBinWidth(fnEntaBinG));
133  delete tempEnta;
134 
135  }
136  protected:
140  virtual EResult calibrate() override;
141 
142 
143  private:
144 
154  Double_t feaLE;
155  Double_t feaUE;
156  Double_t feaBS;
158  std::string fSetPrefix;
159  std::vector<int> fEntaBinNums;
160  std::vector<double> fEntaBinValues;
162  bool IsLocalBin;
163  bool IsMakePlots;
164  bool IsRS;
166  };
168 } // namespace Belle2
A calibration algorithm for CDC dE/dx electron: 1D enta cleanup correction.
CDCDedx1DCellAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
bool IsRS
if rotation symmtery requested
bool IsLocalBin
if local variable bins requested
std::vector< double > fEntaBinValues
Vector for doca asym bin values.
void setMonitoringPlots(bool value)
funtion to set flag active for plotting
Double_t feaBS
Binwidth edge of enta angle.
void setOutFilePrefix(const std::string &value)
adding suffix to filenae for uniqueness in each iter
void setAsymmetricBins(bool value)
Set asym bins flag to on or off.
std::vector< int > fEntaBinNums
Vector for enta asym bin values.
int fnEntaBinL
etna angle bins, Local
std::string fSetPrefix
suffix to filename
virtual ~CDCDedx1DCellAlgorithm()
Destructor.
void setRotationSymBins(bool value)
Set rotation sys flag to on or off.
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.
virtual EResult calibrate() override
1D cell algorithm
int fnEntaBinG
Save arithmetic and truncated mean for the 'dedx' values.
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.