CMS 3D CMS Logo

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