Belle II Software development
BadBoardADCDetector.cc
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#include <tracking/trackFindingCDC/findlets/minimal/BadBoardADCDetector.h>
9
10#include <cdc/dataobjects/CDCHit.h>
11
12#include <tracking/trackingUtilities/utilities/StringManipulation.h>
13#include <framework/core/ModuleParamList.templateDetails.h>
14#include <cdc/geometry/CDCGeometryPar.h>
15
16#include <map>
17
18using namespace Belle2;
19using namespace TrackFindingCDC;
20
24
26{
27 return "Detect boards with bad ADC values and mark hits accordingly";
28}
29
31 const std::string& prefix)
32{
33 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "badADCaverageMin"),
35 "Minimal value of average ADC to consider board bad",
37 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "badTOTaverageMin"),
39 "Minimal value of average TOT to consider board bad",
41}
42
43void BadBoardADCDetector::apply(std::vector<TrackingUtilities::CDCWireHit>& wireHits)
44{
46 // first loop: average ADC per board
47 std::map <int, double> BoardADC;
48 std::map <int, double> BoardTOT;
49 std::map <int, int> BoardCount;
50 for (auto& wireHit : wireHits) {
51 auto board = geometryPar.getBoardID(wireHit.getWireID());
52 BoardCount[board] += 1;
53 BoardADC[board] += (*wireHit.getHit()).getADCCount();
54 BoardTOT[board] += (*wireHit.getHit()).getTOT();
55 };
56 // now compute the averages:
57 for (auto& pair : BoardADC) {
58 int board = pair.first;
59 BoardADC[board] /= BoardCount[board];
60 BoardTOT[board] /= BoardCount[board];
61 }
62
63 // second loop, set flag if board is problematic:
64 for (auto& wireHit : wireHits) {
65 auto board = geometryPar.getBoardID(wireHit.getWireID());
66 if (BoardADC[board] > m_badADCaverageMin)
67 wireHit->setBoardWithBadADCFlag();
68 if (BoardTOT[board] > m_badTOTaverageMin)
69 wireHit->setBoardWithBadTOTFlag();
70 }
71}
The Class for CDC Geometry Parameters.
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
The Module parameter list class.
int m_badTOTaverageMin
Min TOT value for the average.
int m_badADCaverageMin
Min ADC value for the average.
std::string getDescription() final
Short description of the findlet.
void apply(std::vector< TrackingUtilities::CDCWireHit > &wireHits) final
Main algorithm marking hit as background.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
STL class.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.