StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHybridBadAnodes.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtHybridBadAnodes.cc,v 1.1 2002/02/15 22:44:06 munhoz Exp $
4  *
5  * Author: Marcelo Munhoz
6  *
7  ***************************************************************************
8  *
9  * Description: Flags Bad anodes on hybrids
10  *
11  ***************************************************************************/
13 // //
14 // It represents the BadAnodes on a hybrid data. //
15 // //
17 
18 #include "StSvtHybridBadAnodes.hh"
19 
20 StSvtHybridBadAnodes::StSvtHybridBadAnodes()
21 {
22  mNBadAnodes = 0;
23 
24  for (int i=0;i<MAX_NUMBER_OF_ANODES;i++) {
25  mBadAnode[i] = 0;
26  mOverloadedAdc[i] = 0;
27  mNullAdc[i] = 0;
28  mHighOccup[i] = 0;
29  mBadRMS[i] = 0;
30  }
31 }
32 
33 StSvtHybridBadAnodes::StSvtHybridBadAnodes(int barrel, int ladder, int wafer, int hybrid) :
34  StSvtHybridObject(barrel, ladder, wafer, hybrid)
35 {
36  mNBadAnodes = 0;
37 
38  for (int i=0;i<MAX_NUMBER_OF_ANODES;i++) {
39  mBadAnode[i] = 0;
40  mOverloadedAdc[i] = 0;
41  mNullAdc[i] = 0;
42  mHighOccup[i] = 0;
43  mBadRMS[i] = 0;
44  }
45 }
46 
47 StSvtHybridBadAnodes::~StSvtHybridBadAnodes()
48 {}
49 
50 void StSvtHybridBadAnodes::setBadAnode(int anode)
51 {
52  if (!mBadAnode[anode-1]) {
53  mBadAnode[anode-1] = kTRUE;
54  mNBadAnodes++;
55  }
56 }
57 
58 void StSvtHybridBadAnodes::setNotBadAnode(int anode)
59 {
60  if (mBadAnode[anode-1]) {
61  mBadAnode[anode-1] = kFALSE;
62  mNBadAnodes--;
63  }
64 }
65 
66 Bool_t StSvtHybridBadAnodes::isBadAnode(int anode)
67 {
68  return mBadAnode[anode-1];
69 }
70 
71 void StSvtHybridBadAnodes::addOverloadedAdc(int anode, Bool_t isBad, int nEvents)
72 {
73  if (isBad) {
74  mOverloadedAdc[anode-1] = (mOverloadedAdc[anode-1]*(nEvents-1) + 1)/nEvents;
75  setBadAnode(anode);
76  }
77  else
78  mOverloadedAdc[anode-1] = (mOverloadedAdc[anode-1]*(nEvents-1))/nEvents;
79 }
80 
81 void StSvtHybridBadAnodes::addNullAdc(int anode, Bool_t isBad, int nEvents)
82 {
83  if (isBad) {
84  mNullAdc[anode-1] = (mNullAdc[anode-1]*(nEvents-1) + 1)/nEvents;
85  setBadAnode(anode);
86  }
87  else
88  mNullAdc[anode-1] = (mNullAdc[anode-1]*(nEvents-1))/nEvents;
89 }
90 
91 void StSvtHybridBadAnodes::addHighOccup(int anode, Bool_t isBad, int nEvents)
92 {
93  if (isBad) {
94  mHighOccup[anode-1] = (mHighOccup[anode-1]*(nEvents-1) + 1)/nEvents;
95  setBadAnode(anode);
96  }
97  else
98  mHighOccup[anode-1] = (mHighOccup[anode-1]*(nEvents-1))/nEvents;
99 }
100 
101 void StSvtHybridBadAnodes::addBadRMS(int anode, Bool_t isBad, int nEvents)
102 {
103  if (isBad) {
104  mBadRMS[anode-1] = (mBadRMS[anode-1]*(nEvents-1) + 1)/nEvents;
105  setBadAnode(anode);
106  }
107  else
108  mBadRMS[anode-1] = (mBadRMS[anode-1]*(nEvents) + 1)/nEvents;
109 }
110 
111 void StSvtHybridBadAnodes::reset()
112 {
113  mNBadAnodes = 0;
114 
115  for (int i=0;i<MAX_NUMBER_OF_ANODES;i++) {
116  mBadAnode[i] = 0;
117  mOverloadedAdc[i] = 0;
118  mNullAdc[i] = 0;
119  mHighOccup[i] = 0;
120  mBadRMS[i] = 0;
121  }
122 }