Belle II Software  release-05-02-19
CDCDedx1DCellAlgorithm.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: jikumar, jvbennett *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <reconstruction/dbobjects/CDCDedx1DCell.h>
14 #include <calibration/CalibrationAlgorithm.h>
15 #include <framework/database/DBObjPtr.h>
16 
17 #include <TF1.h>
18 #include <TLine.h>
19 #include <TMath.h>
20 #include <TH1F.h>
21 #include <TH1D.h>
22 #include <TBox.h>
23 #include <TString.h>
24 #include <TCanvas.h>
25 
26 namespace Belle2 {
35  class CDCDedx1DCellAlgorithm : public CalibrationAlgorithm {
36 
37  public:
38 
43 
47  virtual ~CDCDedx1DCellAlgorithm() {}
48 
52  void setGlobalEntaBins(int value) {fnEntaBinG = value;}
53 
57  void setAsymmetricBins(bool value) {IsLocalBin = value;}
58 
62  void setRotationSymBins(bool value) {IsRS = value;}
63 
67  void setMonitoringPlots(bool value) {IsMakePlots = value;}
68 
72  void setOutFilePrefix(const std::string& value) {fSetPrefix = value;}
73 
77  int GetRotationSymmericBin(int nbin, int ibin)
78  {
79 
80  if (nbin % 4 != 0)return -1;
81  int jbin;
82  if (ibin <= nbin / 4) jbin = ibin + nbin / 2 ;
83  else if (ibin > 3 * nbin / 4) jbin = ibin - nbin / 2 ;
84  else jbin = ibin;
85 
86  return jbin;
87  }
88 
92  void GetVariableBin(int nbin, std::vector<int>& nBinEnta0to100Per)
93  {
94 
95  if (nbin % 8 != 0) {
96  std::cout << "Please select global in multiple of 8 " << std::endl;
97  return ;
98  }
99 
100  int jbin = -1;
101  std::vector<int> nBinEnta0to25Per;
102  for (int ibin = 0; ibin < nbin / 4; ibin++) {
103  if (ibin < nbin / 8) jbin++;
104  else if (TMath::Abs(ibin - nbin / 8) % 2 == 0)jbin++;
105  nBinEnta0to25Per.push_back(jbin);
106  }
107 
108  std::vector<int> temp = nBinEnta0to25Per;
109  std::reverse(temp.begin(), temp.end());
110 
111  std::vector<int> nBinEnta25to50Per; //second half (0 to pi/2)
112  for (unsigned int it = 0; it < temp.size(); ++it)nBinEnta25to50Per.push_back(2 * jbin - temp.at(it) + 1);
113 
114  std::vector<int> nBinEnta0to50Per = nBinEnta0to25Per;
115  nBinEnta0to50Per.insert(nBinEnta0to50Per.end(), nBinEnta25to50Per.begin(), nBinEnta25to50Per.end());
116 
117  std::vector<int> nBinEnta50to100Per;
118  for (unsigned int it = 0; it < nBinEnta0to50Per.size(); ++it) {
119  nBinEnta50to100Per.push_back(nBinEnta0to50Per.at(nBinEnta0to50Per.size() - 1) + nBinEnta0to50Per.at(it) + 1);
120  }
121 
122  nBinEnta0to100Per = nBinEnta0to50Per;
123  nBinEnta0to100Per.insert(nBinEnta0to100Per.end(), nBinEnta50to100Per.begin(), nBinEnta50to100Per.end());
124 
125  TH1D* tempEnta = new TH1D("tempEnta", "tempEnta", fnEntaBinG, feaLE, feaUE);
126  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(1)); //first and last manual
127  for (unsigned int i = 0; i < nBinEnta0to100Per.size() - 1; ++i) {
128  if (nBinEnta0to100Per.at(i) < nBinEnta0to100Per.at(i + 1)) {
129  double binval = tempEnta->GetBinLowEdge(i + 1) + tempEnta->GetBinWidth(i + 1);
130  if (TMath::Abs(binval) < 10e-5)binval = 0; //avoid infinite deep
131  fEntaBinValues.push_back(binval);
132  } else continue;
133  }
134  fEntaBinValues.push_back(tempEnta->GetBinLowEdge(fnEntaBinG) + tempEnta->GetBinWidth(fnEntaBinG));
135  delete tempEnta;
136 
137  }
138  protected:
142  virtual EResult calibrate() override;
143 
144 
145  private:
146 
153  int fnEntaBinG;
154  int fnEntaBinL;
156  Double_t feaLE;
157  Double_t feaUE;
158  Double_t feaBS;
160  std::string fSetPrefix;
161  std::vector<int> fEntaBinNums;
162  std::vector<double> fEntaBinValues;
164  bool IsLocalBin;
165  bool IsMakePlots;
166  bool IsRS;
168  };
170 } // namespace Belle2
Belle2::CDCDedx1DCellAlgorithm::fnEntaBinL
int fnEntaBinL
etna angle bins, Local
Definition: CDCDedx1DCellAlgorithm.h:162
Belle2::CDCDedx1DCellAlgorithm::IsLocalBin
bool IsLocalBin
if local variable bins requested
Definition: CDCDedx1DCellAlgorithm.h:172
Belle2::CDCDedx1DCellAlgorithm::feaBS
Double_t feaBS
Binwidth edge of enta angle.
Definition: CDCDedx1DCellAlgorithm.h:166
Belle2::CDCDedx1DCellAlgorithm::setGlobalEntaBins
void setGlobalEntaBins(int value)
Set etna angle bins, Global.
Definition: CDCDedx1DCellAlgorithm.h:60
Belle2::CDCDedx1DCellAlgorithm::setMonitoringPlots
void setMonitoringPlots(bool value)
funtion to set flag active for plotting
Definition: CDCDedx1DCellAlgorithm.h:75
Belle2::CDCDedx1DCellAlgorithm::fEntaBinNums
std::vector< int > fEntaBinNums
Vector for enta asym bin values.
Definition: CDCDedx1DCellAlgorithm.h:169
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCDedx1DCellAlgorithm::IsMakePlots
bool IsMakePlots
produce plots for status
Definition: CDCDedx1DCellAlgorithm.h:173
Belle2::CDCDedx1DCellAlgorithm::setRotationSymBins
void setRotationSymBins(bool value)
Set rotation sys flag to on or off.
Definition: CDCDedx1DCellAlgorithm.h:70
Belle2::CDCDedx1DCellAlgorithm::fEntaBinValues
std::vector< double > fEntaBinValues
Vector for doca asym bin values.
Definition: CDCDedx1DCellAlgorithm.h:170
Belle2::CDCDedx1DCellAlgorithm::~CDCDedx1DCellAlgorithm
virtual ~CDCDedx1DCellAlgorithm()
Destructor.
Definition: CDCDedx1DCellAlgorithm.h:55
Belle2::CalibrationAlgorithm::EResult
EResult
The result of calibration.
Definition: CalibrationAlgorithm.h:50
Belle2::CDCDedx1DCellAlgorithm::CDCDedx1DCellAlgorithm
CDCDedx1DCellAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
Definition: CDCDedx1DCellAlgorithm.cc:29
Belle2::CDCDedx1DCellAlgorithm::GetVariableBin
void GetVariableBin(int nbin, std::vector< int > &nBinEnta0to100Per)
funtion to set variable bins
Definition: CDCDedx1DCellAlgorithm.h:100
Belle2::CDCDedx1DCellAlgorithm::IsRS
bool IsRS
if rotation symmtery requested
Definition: CDCDedx1DCellAlgorithm.h:174
Belle2::CDCDedx1DCellAlgorithm::setAsymmetricBins
void setAsymmetricBins(bool value)
Set asym bins flag to on or off.
Definition: CDCDedx1DCellAlgorithm.h:65
Belle2::CDCDedx1DCellAlgorithm::feaUE
Double_t feaUE
Upper edge of enta angle.
Definition: CDCDedx1DCellAlgorithm.h:165
Belle2::CDCDedx1DCellAlgorithm::fSetPrefix
std::string fSetPrefix
suffix to filename
Definition: CDCDedx1DCellAlgorithm.h:168
Belle2::CDCDedx1DCellAlgorithm::feaLE
Double_t feaLE
Lower edge of enta angle.
Definition: CDCDedx1DCellAlgorithm.h:164
Belle2::CDCDedx1DCellAlgorithm::fnEntaBinG
int fnEntaBinG
Save arithmetic and truncated mean for the 'dedx' values.
Definition: CDCDedx1DCellAlgorithm.h:161
Belle2::CDCDedx1DCellAlgorithm::setOutFilePrefix
void setOutFilePrefix(const std::string &value)
adding suffix to filenae for uniqueness in each iter
Definition: CDCDedx1DCellAlgorithm.h:80
Belle2::CDCDedx1DCellAlgorithm::calibrate
virtual EResult calibrate() override
1D cell algorithm
Definition: CDCDedx1DCellAlgorithm.cc:48
Belle2::CDCDedx1DCellAlgorithm::GetRotationSymmericBin
int GetRotationSymmericBin(int nbin, int ibin)
funtion to set rotation symmetry
Definition: CDCDedx1DCellAlgorithm.h:85