Belle II Software  release-05-01-25
CDCDedxBadWires.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jitendra Kumar *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/logging/Logger.h>
14 
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18 #include <TObject.h>
19 #include <TString.h>
20 
21 namespace Belle2 {
31  class CDCDedxBadWires: public TObject {
32 
33  public:
34 
39 
43  explicit CDCDedxBadWires(const std::vector<double>& badwires): m_badwires(badwires) {};
44 
48  ~CDCDedxBadWires() {};
49 
53  void setBadWireStatus(int wire, bool status)
54  {
55  if (wire < 0 || (unsigned)wire >= m_badwires.size())
56  B2WARNING("Asking for a CDC Wire that is not found!");
57  else {
58  if (status)m_badwires[wire] = 1.0;
59  else m_badwires[wire] = 0.0;
60  }
61  }
62 
66  bool getBadWireStatus(int wire) const
67  {
68  if (wire < 0 || (unsigned)wire >= m_badwires.size()) {
69  B2WARNING("Asking for a CDC Wire that is not found!");
70  }
71 
72  bool status = kFALSE;
73  if (m_badwires[wire] == 0)return kTRUE;
74  return status;
75  }
76 
80  void printBadWireStatus(bool save = true, std::string sfx = "local") const
81  {
82 
83  std::ofstream fBadWires;
84  if (save)fBadWires.open(Form("cdcdedx_badwires_%s.txt", sfx.c_str()));
85 
86  unsigned int badcount = 0, goodcount = 0;
87  std::cout << "List of bad wires" << std::endl;
88 
89  for (int jwire = 0; jwire < 14336; jwire++) {
90  if (m_badwires.at(jwire) == 0) {
91  badcount++;
92  std::cout << "\t" << badcount << ": wire # " << jwire << std::endl;
93  if (save)fBadWires << jwire << "\n";
94  } else goodcount++;
95  }
96 
97  if ((badcount + goodcount) != m_badwires.size())
98  std::cout << "Wire sum is not 14336" << std::endl;
99  else
100  std::cout << "\t Total bad wires # " << badcount << std::endl;
101 
102  fBadWires.close();
103  }
104 
105  private:
106 
107  std::vector<double> m_badwires;
110  };
112 } // end namespace Belle2
Belle2::CDCDedxBadWires::CDCDedxBadWires
CDCDedxBadWires()
Default constructor.
Definition: CDCDedxBadWires.h:46
Belle2::CDCDedxBadWires::~CDCDedxBadWires
~CDCDedxBadWires()
Destructor.
Definition: CDCDedxBadWires.h:56
Belle2::CDCDedxBadWires::printBadWireStatus
void printBadWireStatus(bool save=true, std::string sfx="local") const
print all wire numbers
Definition: CDCDedxBadWires.h:88
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCDedxBadWires::setBadWireStatus
void setBadWireStatus(int wire, bool status)
Set wire gain.
Definition: CDCDedxBadWires.h:61
Belle2::CDCDedxBadWires::m_badwires
std::vector< double > m_badwires
dE/dx gains for each wire
Definition: CDCDedxBadWires.h:115
Belle2::CDCDedxBadWires::getBadWireStatus
bool getBadWireStatus(int wire) const
Return wire gain.
Definition: CDCDedxBadWires.h:74
Belle2::CDCDedxBadWires::ClassDef
ClassDef(CDCDedxBadWires, 1)
ClassDef.