Belle II Software  release-08-01-10
CDCDedxBadWires.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 <framework/logging/Logger.h>
12 
13 #include <iostream>
14 #include <fstream>
15 #include <string>
16 #include <TObject.h>
17 #include <TString.h>
18 
19 namespace Belle2 {
29  class CDCDedxBadWires: public TObject {
30 
31  public:
32 
37 
41  explicit CDCDedxBadWires(const std::vector<double>& badwires): m_badwires(badwires) {};
42 
47 
51  void setBadWireStatus(int wire, bool status)
52  {
53  if (wire < 0 || (unsigned)wire >= m_badwires.size())
54  B2WARNING("Asking for a CDC Wire that is not found!");
55  else {
56  if (status)m_badwires[wire] = 1.0;
57  else m_badwires[wire] = 0.0;
58  }
59  }
60 
64  bool getBadWireStatus(int wire) const
65  {
66  if (wire < 0 || (unsigned)wire >= m_badwires.size()) {
67  B2WARNING("Asking for a CDC Wire that is not found!");
68  }
69 
70  bool status = kFALSE;
71  if (m_badwires[wire] == 0)return kTRUE;
72  return status;
73  }
74 
78  void printBadWireStatus(bool save = true, std::string sfx = "local") const
79  {
80 
81  std::ofstream fBadWires;
82  if (save)fBadWires.open(Form("cdcdedx_badwires_%s.txt", sfx.c_str()));
83 
84  unsigned int badcount = 0, goodcount = 0;
85  std::cout << "List of bad wires" << std::endl;
86 
87  for (int jwire = 0; jwire < 14336; jwire++) {
88  if (m_badwires.at(jwire) == 0) {
89  badcount++;
90  std::cout << "\t" << badcount << ": wire # " << jwire << std::endl;
91  if (save)fBadWires << jwire << "\n";
92  } else goodcount++;
93  }
94 
95  if ((badcount + goodcount) != m_badwires.size())
96  std::cout << "Wire sum is not 14336" << std::endl;
97  else
98  std::cout << "\t Total bad wires # " << badcount << std::endl;
99 
100  fBadWires.close();
101  }
102 
103  private:
104 
105  std::vector<double> m_badwires;
108  };
110 } // end namespace Belle2
dE/dx wire gain calibration constants
std::vector< double > m_badwires
dE/dx gains for each wire
CDCDedxBadWires()
Default constructor.
void printBadWireStatus(bool save=true, std::string sfx="local") const
print all wire numbers
ClassDef(CDCDedxBadWires, 1)
ClassDef.
bool getBadWireStatus(int wire) const
Return wire gain.
void setBadWireStatus(int wire, bool status)
Set wire gain.
~CDCDedxBadWires()
Destructor.
CDCDedxBadWires(const std::vector< double > &badwires)
Constructor.
Abstract base class for different kinds of events.