Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "CondTools/DT/plugins/DTHVCheckWithHysteresis.h"
00014
00015
00016
00017
00018 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00019 #include "FWCore/PluginManager/interface/ModuleDef.h"
00020 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
00021
00022
00023
00024
00025 #include <iostream>
00026
00027 namespace cond { namespace service {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 DTHVCheckWithHysteresis::DTHVCheckWithHysteresis(
00038 const edm::ParameterSet & iConfig,
00039 edm::ActivityRegistry & iAR ) {
00040 if ( instance == 0 ) {
00041 std::cout << "create DTHVCheckWithHysteresis" << std::endl;
00042 minHVl = new float[4];
00043 minHVh = new float[4];
00044 maxHV = new float[4];
00045 minHVl[0] = 3000.0;
00046 minHVl[1] = 3000.0;
00047 minHVl[2] = 1200.0;
00048 minHVl[3] = 600.0;
00049 minHVh[0] = 3500.0;
00050 minHVh[1] = 3500.0;
00051 minHVh[2] = 1700.0;
00052 minHVh[3] = 1100.0;
00053 maxHV[0] = 4000.0;
00054 maxHV[1] = 4000.0;
00055 maxHV[2] = 2200.0;
00056 maxHV[3] = 1600.0;
00057 maxCurrent = 30.0;
00058 oldStatusA = new std::map<int,int>;
00059 oldStatusC = new std::map<int,int>;
00060 oldStatusS = new std::map<int,int>;
00061 instance = this;
00062 }
00063 }
00064
00065
00066
00067
00068 DTHVCheckWithHysteresis::~DTHVCheckWithHysteresis() {
00069 }
00070
00071
00072
00073
00074
00075 DTHVAbstractCheck::flag DTHVCheckWithHysteresis::checkCurrentStatus(
00076 int rawId, int type,
00077 float valueA, float valueC, float valueS,
00078 const std::map<int,timedMeasurement>& snapshotValues,
00079 const std::map<int,int>& aliasMap,
00080 const std::map<int,int>& layerMap ) {
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 float minHV[4];
00121
00122
00123
00124
00125
00126
00127 DTWireId chlId( rawId );
00128 int part = chlId.wire() - 10;
00129 DTHVAbstractCheck::flag flag;
00130 flag.a = flag.c = flag.s = 0;
00131
00132 std::map<int,int>::iterator chanIter;
00133 if ( ( ( chanIter = oldStatusA->find( rawId ) ) != oldStatusA->end() ) &&
00134 ( chanIter->second % 2 ) ) minHV[part] = minHVh[part];
00135 else minHV[part] = minHVl[part];
00136 if ( ( ( chanIter = oldStatusS->find( rawId ) ) != oldStatusS->end() ) &&
00137 ( chanIter->second % 2 ) ) minHV[ 2] = minHVh[ 2];
00138 else minHV[ 2] = minHVl[ 2];
00139 if ( ( ( chanIter = oldStatusC->find( rawId ) ) != oldStatusC->end() ) &&
00140 ( chanIter->second % 2 ) ) minHV[ 3] = minHVh[ 3];
00141 else minHV[ 3] = minHVl[ 3];
00142
00143 if ( type == 1 ) {
00144 if ( valueA < minHV[part] ) flag.a = 1;
00145 if ( valueA > maxHV[part] ) flag.a = 2;
00146 if ( valueS < minHV[ 2] ) flag.s = 1;
00147 if ( valueS > maxHV[ 2] ) flag.s = 2;
00148 if ( valueC < minHV[ 3] ) flag.c = 1;
00149 if ( valueC > maxHV[ 3] ) flag.c = 2;
00150 if ( ( chanIter = oldStatusA->find( rawId ) ) == oldStatusA->end() )
00151 oldStatusA->insert( std::pair<int,int>( rawId, flag.a ) );
00152 else chanIter->second = flag.a;
00153 if ( ( chanIter = oldStatusC->find( rawId ) ) == oldStatusC->end() )
00154 oldStatusC->insert( std::pair<int,int>( rawId, flag.c ) );
00155 else chanIter->second = flag.c;
00156 if ( ( chanIter = oldStatusS->find( rawId ) ) == oldStatusS->end() )
00157 oldStatusS->insert( std::pair<int,int>( rawId, flag.s ) );
00158 else chanIter->second = flag.s;
00159 }
00160 if ( type == 2 ) {
00161 float voltA = 0.0;
00162 float voltS = 0.0;
00163 float voltC = 0.0;
00164 DTLayerId lay = chlId.layerId();
00165 int l_p = chlId.wire();
00166 DTWireId chA( lay, l_p );
00167 DTWireId chS( lay, 12 );
00168 DTWireId chC( lay, 13 );
00169
00170 std::map<int,int>::const_iterator layerIter;
00171 std::map<int,int>::const_iterator layerIend = layerMap.end();
00172 std::map<int,timedMeasurement>::const_iterator snapIter;
00173 std::map<int,timedMeasurement>::const_iterator snapIend =
00174 snapshotValues.end();
00175 int chan;
00176 if ( ( layerIter = layerMap.find( chA.rawId() ) ) != layerIend ) {
00177 chan = ( layerIter->second * 10 ) + l_p;
00178 if ( ( snapIter = snapshotValues.find( chan ) ) != snapIend ) {
00179 voltA = snapIter->second.second;
00180 }
00181 }
00182 if ( ( layerIter = layerMap.find( chS.rawId() ) ) != layerIend ) {
00183 chan = ( layerIter->second * 10 ) + 2;
00184 if ( ( snapIter = snapshotValues.find( chan ) ) != snapIend ) {
00185 voltS = snapIter->second.second;
00186 }
00187 }
00188 if ( ( layerIter = layerMap.find( chC.rawId() ) ) != layerIend ) {
00189 chan = ( layerIter->second * 10 ) + 3;
00190 if ( ( snapIter = snapshotValues.find( chan ) ) != snapIend ) {
00191 voltC = snapIter->second.second;
00192 }
00193 }
00194 if ( ( valueA > maxCurrent ) &&
00195 ( voltA >= minHV[part] ) ) flag.a = 4;
00196 if ( ( valueS > maxCurrent ) &&
00197 ( voltS >= minHV[ 2] ) ) flag.s = 4;
00198 if ( ( valueC > maxCurrent ) &&
00199 ( voltC >= minHV[ 3] ) ) flag.c = 4;
00200 }
00201
00202 return flag;
00203
00204 }
00205
00206
00207 void DTHVCheckWithHysteresis::setStatus(
00208 int rawId,
00209 int flagA, int flagC, int flagS,
00210 const std::map<int,timedMeasurement>& snapshotValues,
00211 const std::map<int,int>& aliasMap,
00212 const std::map<int,int>& layerMap ) {
00213
00214
00215 std::map<int,int>::iterator chanIter;
00216 if ( ( chanIter = oldStatusA->find( rawId ) ) == oldStatusA->end() )
00217 oldStatusA->insert( std::pair<int,int>( rawId, flagA ) );
00218 else chanIter->second = flagA;
00219 if ( ( chanIter = oldStatusC->find( rawId ) ) == oldStatusA->end() )
00220 oldStatusC->insert( std::pair<int,int>( rawId, flagC ) );
00221 else chanIter->second = flagC;
00222 if ( ( chanIter = oldStatusS->find( rawId ) ) == oldStatusA->end() )
00223 oldStatusS->insert( std::pair<int,int>( rawId, flagS ) );
00224 else chanIter->second = flagS;
00225 return;
00226 }
00227
00228
00229 DEFINE_FWK_SERVICE( DTHVCheckWithHysteresis );
00230 } }
00231
00232