8#include <tracking/trackFindingCDC/findlets/minimal/BadBoardADCDetector.h>
10#include <tracking/trackingUtilities/rootification/StoreWrappedObjPtr.h>
11#include <tracking/trackingUtilities/rootification/StoreWrapper.h>
12#include <tracking/trackingUtilities/utilities/StringManipulation.h>
13#include <framework/core/ModuleParamList.templateDetails.h>
14#include <cdc/geometry/CDCGeometryPar.h>
15#include <cdc/dataobjects/CDCHit.h>
20using namespace TrackFindingCDC;
40 return "Detect boards with bad ADC values and mark hits accordingly";
44 const std::string& prefix)
46 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"badADCaverageMin"),
48 "Minimal value of average ADC to consider board bad",
50 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"badADCaverageMax"),
52 "Maximal value of average ADC to consider a board as bad",
54 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"badTOTaverageMin"),
56 "Minimal value of average TOT to consider board bad",
64 std::map <int, double> BoardADC;
65 std::map <int, double> BoardTOT;
66 std::map <int, int> BoardCount;
67 for (
auto& wireHit : wireHits) {
68 auto board = geometryPar.
getBoardID(wireHit.getWireID());
69 BoardCount[board] += 1;
70 BoardADC[board] += (*wireHit.getHit()).getADCCount();
71 BoardTOT[board] += (*wireHit.getHit()).getTOT();
74 for (
auto&
pair : BoardADC) {
75 int board =
pair.first;
76 BoardADC[board] /= BoardCount[board];
77 BoardTOT[board] /= BoardCount[board];
81 for (
auto& wireHit : wireHits) {
82 auto board = geometryPar.
getBoardID(wireHit.getWireID());
84 wireHit->setBoardWithBadADCFlag();
86 wireHit->setBoardWithBadTOTFlag();
97 for (
unsigned int iBoard = 1; iBoard < c_nBoards; iBoard += 1) {
98 if (BoardCount.find(iBoard) == BoardCount.end() ||
m_badBoardsFromDB->isDeadBoard(iBoard, dummyEff)) {
99 storeVector->push_back(iBoard);
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.
bool create(bool replace=false)
Create a default object in the data store.
BadBoardADCDetector()
Default constructor.
int m_badTOTaverageMin
Min TOT value for the average.
void initialize() final
Initialization.
void beginRun() final
begin run
int m_badADCaverageMin
Min ADC value for the average.
DBObjPtr< CDCBadBoards > m_badBoardsFromDB
Pointer to the CDCBadBoards payload.
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.
int m_badADCaverageMax
Max ADC value for the average.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_DontWriteOut|DataStore::c_ErrorIfAlreadyRegistered)
Register the object/array in the DataStore.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.