Belle II Software development
CDCBadWires.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#pragma once
9
10#include <map>
11#include <algorithm>
12#include <iostream>
13#include <fstream>
14#include <iomanip>
15#include <TObject.h>
16#include <cdc/dataobjects/WireID.h>
17
18namespace Belle2 {
27 class CDCBadWires: public TObject {
28 public:
29
34
40 void setWire(const WireID& wid, double eff = 0)
41 {
42 m_wires.insert(std::pair(wid.getEWire(), eff));
43 }
44
51 void setWire(unsigned short iCLayer, unsigned short iWire, double eff = 0)
52 {
53 m_wires.insert(std::pair(WireID(iCLayer, iWire).getEWire(), eff));
54 }
55
59 unsigned short getEntries() const
60 {
61 return m_wires.size();
62 }
63
67 std::map<unsigned short, float> getWires() const
68 {
69 return m_wires;
70 }
71
77 bool isBadWire(const WireID& wid) const
78 {
79 std::map<unsigned short, float>::const_iterator it = m_wires.find(wid.getEWire());
80 if (it != m_wires.end() && it->second == 0.) {
81 return true;
82 } else {
83 return false;
84 }
85 }
86
93 bool isDeadWire(const WireID& wid, double& eff) const
94 {
95 std::map<unsigned short, float>::const_iterator it = m_wires.find(wid.getEWire());
96 if (it != m_wires.end() && 0. <= it->second && it->second < 1.) {
97 eff = it->second;
98 return true;
99 } else {
100 return false;
101 }
102 }
103
109 bool isHotWire(const WireID& wid) const
110 {
111 std::map<unsigned short, float>::const_iterator it = m_wires.find(wid.getEWire());
112 if (it != m_wires.end() && it->second > 1.) {
113 return true;
114 } else {
115 return false;
116 }
117 }
118
122 void dump() const
123 {
124 std::cout << " " << std::endl;
125 std::cout << "Bad wire list" << std::endl;
126 std::cout << "#entries= " << m_wires.size() << std::endl;
127 std::cout << "in order of ICLayer and IWire and EWire" << std::endl;
128
129 for (auto const ent : m_wires) {
130 std::cout << WireID(ent.first).getICLayer() << " " << WireID(ent.first).getIWire() << " " << ent.second << std::endl;
131 }
132 }
133
137 void outputToFile(std::string fileName) const
138 {
139 std::ofstream fout(fileName);
140
141 if (fout.bad()) {
142 B2ERROR("Specified output file could not be opened!");
143 } else {
144 for (auto const ent : m_wires) {
145 fout << std::setw(2) << std::right << WireID(ent.first).getICLayer() << " " << std::setw(3) << WireID(
146 ent.first).getIWire() << " " << ent.second << std::endl;
147 }
148 fout.close();
149 }
150 }
151
152 private:
153 std::map<unsigned short, float> m_wires;
156 };
157
159} // end namespace Belle2
Database object for bad wires.
Definition: CDCBadWires.h:27
void outputToFile(std::string fileName) const
Output the contents in text file format.
Definition: CDCBadWires.h:137
void setWire(const WireID &wid, double eff=0)
Set the wire in the list.
Definition: CDCBadWires.h:40
bool isDeadWire(const WireID &wid, double &eff) const
Check if dead wire.
Definition: CDCBadWires.h:93
bool isBadWire(const WireID &wid) const
Check if the wire is totally-dead (eff=0); to be replaced by isDeadWire() in future....
Definition: CDCBadWires.h:77
std::map< unsigned short, float > getWires() const
Get the whole list.
Definition: CDCBadWires.h:67
ClassDef(CDCBadWires, 2)
ClassDef.
void setWire(unsigned short iCLayer, unsigned short iWire, double eff=0)
Set the wire in the list.
Definition: CDCBadWires.h:51
unsigned short getEntries() const
Get the no.
Definition: CDCBadWires.h:59
CDCBadWires()
Default constructor.
Definition: CDCBadWires.h:33
std::map< unsigned short, float > m_wires
badwire list
Definition: CDCBadWires.h:153
bool isHotWire(const WireID &wid) const
Check if the wire is hot/noisy.
Definition: CDCBadWires.h:109
void dump() const
Print out contents.
Definition: CDCBadWires.h:122
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:145
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:154
Abstract base class for different kinds of events.