CMS 3D CMS Logo

DTHVCheckWithHysteresis.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2010/04/02 14:10:27 $
5  * $Revision: 1.3 $
6  * \author Paolo Ronchese INFN Padova
7  *
8  */
9 
10 //-----------------------
11 // This Class' Header --
12 //-----------------------
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
21 
22 //---------------
23 // C++ Headers --
24 //---------------
25 #include <iostream>
26 
27 namespace cond {
28  namespace service {
29 
30  //-------------------
31  // Initializations --
32  //-------------------
33 
34  //----------------
35  // Constructors --
36  //----------------
38  if (instance == nullptr) {
39  std::cout << "create DTHVCheckWithHysteresis" << std::endl;
40  minHVl = new float[4];
41  minHVh = new float[4];
42  maxHV = new float[4];
43  minHVl[0] = 3000.0;
44  minHVl[1] = 3000.0;
45  minHVl[2] = 1200.0;
46  minHVl[3] = 600.0;
47  minHVh[0] = 3500.0;
48  minHVh[1] = 3500.0;
49  minHVh[2] = 1700.0;
50  minHVh[3] = 1100.0;
51  maxHV[0] = 4000.0;
52  maxHV[1] = 4000.0;
53  maxHV[2] = 2200.0;
54  maxHV[3] = 1600.0;
55  maxCurrent = 30.0;
56  oldStatusA = new std::map<int, int>;
57  oldStatusC = new std::map<int, int>;
58  oldStatusS = new std::map<int, int>;
59  instance = this;
60  }
61  }
62 
63  //--------------
64  // Destructor --
65  //--------------
67 
68  //--------------
69  // Operations --
70  //--------------
71  //int DTHVCheckWithHysteresis::checkCurrentStatus(
73  int rawId,
74  int type,
75  float valueA,
76  float valueC,
77  float valueS,
78  const std::map<int, timedMeasurement>& snapshotValues,
79  const std::map<int, int>& aliasMap,
80  const std::map<int, int>& layerMap) {
81  // find all values for this channel
82  // ind dpid = 0;
83  // std::map<int,int>::const_iterator lpartIter;
84  // std::map<int,int>::const_iterator lpartIend = layerMap.end();
85  // if ( ( layerIter = layerMap.find( chp0 ) ) != layerIend )
86  // dpid = layerIter.second;
87  // std::map<int,timedMeasurement>::const_iterator snapIter;
88  // std::map<int,timedMeasurement>::const_iterator snapIend =
89  // snapshotValues.end();
90  // float val1 = -999999.0;
91  // float val2 = -999999.0;
92  // int chan = dpId * 10;
93  // if ( ( snapIter = snapshotValues.find( chan + 1 ) ) != snapIend )
94  // val1 = snapIter->second.second;
95  // if ( ( snapIter = snapshotValues.find( chan + 2 ) ) != snapIend )
96  // val2 = snapIter->second.second;
97 
98  // find dp identifier for all channels in this layer
99  // DTLayerId lay = chlId.layerId();
100  // int chp0 = DTWireId( lay, 10 ).rawId();
101  // int chp1 = DTWireId( lay, 11 ).rawId();
102  // int chp2 = DTWireId( lay, 12 ).rawId();
103  // int chp3 = DTWireId( lay, 13 ).rawId();
104  // ind dpi0 = 0;
105  // ind dpi1 = 0;
106  // ind dpi2 = 0;
107  // ind dpi3 = 0;
108  // std::map<int,int>::const_iterator layerIter;
109  // std::map<int,int>::const_iterator layerIend = layerMap.end();
110  // if ( ( layerIter = layerMap.find( chp0 ) ) != layerIend )
111  // dpi0 = layerIter.second;
112  // if ( ( layerIter = layerMap.find( chp1 ) ) != layerIend )
113  // dpi1 = layerIter.second;
114  // if ( ( layerIter = layerMap.find( chp2 ) ) != layerIend )
115  // dpi2 = layerIter.second;
116  // if ( ( layerIter = layerMap.find( chp3 ) ) != layerIend )
117  // dpi3 = layerIter.second;
118 
119  float minHV[4];
120  // DTLayerId lay = chlId.layerId();
121  // int chp0 = DTWireId( lay, 10 ).rawId();
122  // int chp1 = DTWireId( lay, 11 ).rawId();
123  // int chp2 = DTWireId( lay, 12 ).rawId();
124  // int chp3 = DTWireId( lay, 13 ).rawId();
125 
126  DTWireId chlId(rawId);
127  int part = chlId.wire() - 10;
129  flag.a = flag.c = flag.s = 0;
130 
131  std::map<int, int>::iterator chanIter;
132  if (((chanIter = oldStatusA->find(rawId)) != oldStatusA->end()) && (chanIter->second % 2))
133  minHV[part] = minHVh[part];
134  else
135  minHV[part] = minHVl[part];
136  if (((chanIter = oldStatusS->find(rawId)) != oldStatusS->end()) && (chanIter->second % 2))
137  minHV[2] = minHVh[2];
138  else
139  minHV[2] = minHVl[2];
140  if (((chanIter = oldStatusC->find(rawId)) != oldStatusC->end()) && (chanIter->second % 2))
141  minHV[3] = minHVh[3];
142  else
143  minHV[3] = minHVl[3];
144 
145  if (type == 1) {
146  if (valueA < minHV[part])
147  flag.a = 1;
148  if (valueA > maxHV[part])
149  flag.a = 2;
150  if (valueS < minHV[2])
151  flag.s = 1;
152  if (valueS > maxHV[2])
153  flag.s = 2;
154  if (valueC < minHV[3])
155  flag.c = 1;
156  if (valueC > maxHV[3])
157  flag.c = 2;
158  if ((chanIter = oldStatusA->find(rawId)) == oldStatusA->end())
159  oldStatusA->insert(std::pair<int, int>(rawId, flag.a));
160  else
161  chanIter->second = flag.a;
162  if ((chanIter = oldStatusC->find(rawId)) == oldStatusC->end())
163  oldStatusC->insert(std::pair<int, int>(rawId, flag.c));
164  else
165  chanIter->second = flag.c;
166  if ((chanIter = oldStatusS->find(rawId)) == oldStatusS->end())
167  oldStatusS->insert(std::pair<int, int>(rawId, flag.s));
168  else
169  chanIter->second = flag.s;
170  }
171  if (type == 2) {
172  float voltA = 0.0;
173  float voltS = 0.0;
174  float voltC = 0.0;
175  DTLayerId lay = chlId.layerId();
176  int l_p = chlId.wire();
177  DTWireId chA(lay, l_p);
178  DTWireId chS(lay, 12);
179  DTWireId chC(lay, 13);
180 
181  std::map<int, int>::const_iterator layerIter;
182  std::map<int, int>::const_iterator layerIend = layerMap.end();
183  std::map<int, timedMeasurement>::const_iterator snapIter;
184  std::map<int, timedMeasurement>::const_iterator snapIend = snapshotValues.end();
185  int chan;
186  if ((layerIter = layerMap.find(chA.rawId())) != layerIend) {
187  chan = (layerIter->second * 10) + l_p;
188  if ((snapIter = snapshotValues.find(chan)) != snapIend) {
189  voltA = snapIter->second.second;
190  }
191  }
192  if ((layerIter = layerMap.find(chS.rawId())) != layerIend) {
193  chan = (layerIter->second * 10) + 2;
194  if ((snapIter = snapshotValues.find(chan)) != snapIend) {
195  voltS = snapIter->second.second;
196  }
197  }
198  if ((layerIter = layerMap.find(chC.rawId())) != layerIend) {
199  chan = (layerIter->second * 10) + 3;
200  if ((snapIter = snapshotValues.find(chan)) != snapIend) {
201  voltC = snapIter->second.second;
202  }
203  }
204  if ((valueA > maxCurrent) && (voltA >= minHV[part]))
205  flag.a = 4;
206  if ((valueS > maxCurrent) && (voltS >= minHV[2]))
207  flag.s = 4;
208  if ((valueC > maxCurrent) && (voltC >= minHV[3]))
209  flag.c = 4;
210  }
211 
212  return flag;
213  }
214 
216  int flagA,
217  int flagC,
218  int flagS,
219  const std::map<int, timedMeasurement>& snapshotValues,
220  const std::map<int, int>& aliasMap,
221  const std::map<int, int>& layerMap) {
222  // std::cout << "set status " << rawId << " "
223  // << flagA << " " << flagC << " " << flagS << std::endl;
224  std::map<int, int>::iterator chanIter;
225  if ((chanIter = oldStatusA->find(rawId)) == oldStatusA->end())
226  oldStatusA->insert(std::pair<int, int>(rawId, flagA));
227  else
228  chanIter->second = flagA;
229  if ((chanIter = oldStatusC->find(rawId)) == oldStatusA->end())
230  oldStatusC->insert(std::pair<int, int>(rawId, flagC));
231  else
232  chanIter->second = flagC;
233  if ((chanIter = oldStatusS->find(rawId)) == oldStatusA->end())
234  oldStatusS->insert(std::pair<int, int>(rawId, flagS));
235  else
236  chanIter->second = flagS;
237  return;
238  }
239 
241  } // namespace service
242 } // namespace cond
cond::service::DTHVCheckWithHysteresis::minHVl
float * minHVl
Definition: DTHVCheckWithHysteresis.h:72
service
Definition: service.py:1
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
cond::service::DTHVCheckWithHysteresis::oldStatusS
std::map< int, int > * oldStatusS
Definition: DTHVCheckWithHysteresis.h:78
cond::service::DTHVCheckWithHysteresis::DTHVCheckWithHysteresis
DTHVCheckWithHysteresis()
cond::service::DTHVCheckWithHysteresis::setStatus
void setStatus(int rawId, int flagA, int flagC, int flagS, const std::map< int, timedMeasurement > &snapshotValues, const std::map< int, int > &aliasMap, const std::map< int, int > &layerMap) override
Definition: DTHVCheckWithHysteresis.cc:215
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cond::service::DTHVCheckWithHysteresis::oldStatusA
std::map< int, int > * oldStatusA
Definition: DTHVCheckWithHysteresis.h:76
DEFINE_FWK_SERVICE
#define DEFINE_FWK_SERVICE(type)
Definition: ServiceMaker.h:105
part
part
Definition: HCALResponse.h:20
cond::service::DTHVCheckWithHysteresis::~DTHVCheckWithHysteresis
~DTHVCheckWithHysteresis() override
Definition: DTHVCheckWithHysteresis.cc:66
DTHVAbstractCheck::flag
Definition: DTHVAbstractCheck.h:48
DTWireId
Definition: DTWireId.h:12
cond::service::DTHVCheckWithHysteresis::minHVh
float * minHVh
Definition: DTHVCheckWithHysteresis.h:73
DTHVCheckWithHysteresis.h
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
DTLayerId
Definition: DTLayerId.h:12
ServiceMaker.h
cond
Definition: plugin.cc:23
cond::service::DTHVCheckWithHysteresis::oldStatusC
std::map< int, int > * oldStatusC
Definition: DTHVCheckWithHysteresis.h:77
edm::ParameterSet
Definition: ParameterSet.h:47
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
DTHVAbstractCheck::instance
static DTHVAbstractCheck * instance
Definition: DTHVAbstractCheck.h:80
ModuleDef.h
cond::service::DTHVCheckWithHysteresis::checkCurrentStatus
DTHVAbstractCheck::flag checkCurrentStatus(int rawId, int type, float valueA, float valueC, float valueS, const std::map< int, timedMeasurement > &snapshotValues, const std::map< int, int > &aliasMap, const std::map< int, int > &layerMap) override
check HV status
Definition: DTHVCheckWithHysteresis.cc:72
cond::service::DTHVCheckWithHysteresis::maxCurrent
float maxCurrent
Definition: DTHVCheckWithHysteresis.h:75
DTHVAbstractCheck::flag::c
int c
Definition: DTHVAbstractCheck.h:50
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DTWireId.h
DTHVAbstractCheck::flag::a
int a
Definition: DTHVAbstractCheck.h:49
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
cond::service::DTHVCheckWithHysteresis
Definition: DTHVCheckWithHysteresis.h:40
DTWireId::layerId
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
DTHVAbstractCheck::flag::s
int s
Definition: DTHVAbstractCheck.h:51
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
cond::service::DTHVCheckWithHysteresis::maxHV
float * maxHV
Definition: DTHVCheckWithHysteresis.h:74