Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:45

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  $Date: 2010/04/15 20:38:42 $
0005  *  $Revision: 1.4 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //-----------------------
0011 // This Class' Header --
0012 //-----------------------
0013 #include "CondTools/DT/plugins/DTHVCheckByAbsoluteValues.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0019 #include "FWCore/PluginManager/interface/ModuleDef.h"
0020 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
0021 
0022 //---------------
0023 // C++ Headers --
0024 //---------------
0025 #include <iostream>
0026 
0027 namespace cond {
0028   namespace service {
0029 
0030     //-------------------
0031     // Initializations --
0032     //-------------------
0033 
0034     //----------------
0035     // Constructors --
0036     //----------------
0037     DTHVCheckByAbsoluteValues::DTHVCheckByAbsoluteValues(const edm::ParameterSet& iConfig, edm::ActivityRegistry& iAR) {
0038       if (instance == nullptr) {
0039         std::cout << "create DTHVCheckByAbsoluteValues" << std::endl;
0040         minHV = new float[4];
0041         maxHV = new float[4];
0042         //    minHV[0] = 3500.0;
0043         //    minHV[1] = 3500.0;
0044         //    minHV[2] = 1400.0;
0045         //    minHV[3] =  800.0;
0046         minHV[0] = 3500.0;
0047         minHV[1] = 3500.0;
0048         minHV[2] = 1700.0;
0049         minHV[3] = 1100.0;
0050         maxHV[0] = 4000.0;
0051         maxHV[1] = 4000.0;
0052         maxHV[2] = 2200.0;
0053         maxHV[3] = 1600.0;
0054         maxCurrent = 30.0;
0055         instance = this;
0056       }
0057     }
0058 
0059     //--------------
0060     // Destructor --
0061     //--------------
0062     DTHVCheckByAbsoluteValues::~DTHVCheckByAbsoluteValues() {}
0063 
0064     //--------------
0065     // Operations --
0066     //--------------
0067     DTHVAbstractCheck::flag DTHVCheckByAbsoluteValues::checkCurrentStatus(
0068         int rawId,
0069         int type,
0070         float valueA,
0071         float valueC,
0072         float valueS,
0073         const std::map<int, timedMeasurement>& snapshotValues,
0074         const std::map<int, int>& aliasMap,
0075         const std::map<int, int>& layerMap) {
0076       // find all values for this channel
0077       //  ind dpid = 0;
0078       //  std::map<int,int>::const_iterator lpartIter;
0079       //  std::map<int,int>::const_iterator lpartIend = layerMap.end();
0080       //  if ( ( layerIter = layerMap.find( chp0 ) ) != layerIend )
0081       //      dpid = layerIter.second;
0082       //  std::map<int,timedMeasurement>::const_iterator snapIter;
0083       //  std::map<int,timedMeasurement>::const_iterator snapIend =
0084       //                                                 snapshotValues.end();
0085       //  float val1 = -999999.0;
0086       //  float val2 = -999999.0;
0087       //  int chan = dpId * 10;
0088       //  if ( ( snapIter = snapshotValues.find( chan + 1 ) ) != snapIend )
0089       //      val1 = snapIter->second.second;
0090       //  if ( ( snapIter = snapshotValues.find( chan + 2 ) ) != snapIend )
0091       //      val2 = snapIter->second.second;
0092 
0093       // find dp identifier for all channels in this layer
0094       //  DTLayerId lay = chlId.layerId();
0095       //  int chp0 = DTWireId( lay, 10 ).rawId();
0096       //  int chp1 = DTWireId( lay, 11 ).rawId();
0097       //  int chp2 = DTWireId( lay, 12 ).rawId();
0098       //  int chp3 = DTWireId( lay, 13 ).rawId();
0099       //  ind dpi0 = 0;
0100       //  ind dpi1 = 0;
0101       //  ind dpi2 = 0;
0102       //  ind dpi3 = 0;
0103       //  std::map<int,int>::const_iterator layerIter;
0104       //  std::map<int,int>::const_iterator layerIend = layerMap.end();
0105       //  if ( ( layerIter = layerMap.find( chp0 ) ) != layerIend )
0106       //      dpi0 = layerIter.second;
0107       //  if ( ( layerIter = layerMap.find( chp1 ) ) != layerIend )
0108       //      dpi1 = layerIter.second;
0109       //  if ( ( layerIter = layerMap.find( chp2 ) ) != layerIend )
0110       //      dpi2 = layerIter.second;
0111       //  if ( ( layerIter = layerMap.find( chp3 ) ) != layerIend )
0112       //      dpi3 = layerIter.second;
0113 
0114       DTWireId chlId(rawId);
0115       int part = chlId.wire() - 10;
0116       DTHVAbstractCheck::flag flag;
0117       flag.a = flag.c = flag.s = 0;
0118       if (type == 1) {
0119         if (valueA < minHV[part])
0120           flag.a = 1;
0121         if (valueA > maxHV[part])
0122           flag.a = 2;
0123         if (valueS < minHV[2])
0124           flag.s = 1;
0125         if (valueS > maxHV[2])
0126           flag.s = 2;
0127         if (valueC < minHV[3])
0128           flag.c = 1;
0129         if (valueC > maxHV[3])
0130           flag.c = 2;
0131       }
0132       if (type == 2) {
0133         float voltA = 0.0;
0134         float voltS = 0.0;
0135         float voltC = 0.0;
0136         DTLayerId lay = chlId.layerId();
0137         int l_p = chlId.wire();
0138         DTWireId chA(lay, l_p);
0139         DTWireId chS(lay, 12);
0140         DTWireId chC(lay, 13);
0141         std::map<int, int>::const_iterator layerIter;
0142         std::map<int, int>::const_iterator layerIend = layerMap.end();
0143         std::map<int, timedMeasurement>::const_iterator snapIter;
0144         std::map<int, timedMeasurement>::const_iterator snapIend = snapshotValues.end();
0145         int chan;
0146         if ((layerIter = layerMap.find(chA.rawId())) != layerIend) {
0147           chan = (layerIter->second * 10) + l_p;
0148           if ((snapIter = snapshotValues.find(chan)) != snapIend) {
0149             voltA = snapIter->second.second;
0150           }
0151         }
0152         if ((layerIter = layerMap.find(chS.rawId())) != layerIend) {
0153           chan = (layerIter->second * 10) + 2;
0154           if ((snapIter = snapshotValues.find(chan)) != snapIend) {
0155             voltS = snapIter->second.second;
0156           }
0157         }
0158         if ((layerIter = layerMap.find(chC.rawId())) != layerIend) {
0159           chan = (layerIter->second * 10) + 3;
0160           if ((snapIter = snapshotValues.find(chan)) != snapIend) {
0161             voltC = snapIter->second.second;
0162           }
0163         }
0164         if ((valueA > maxCurrent) && (voltA >= minHV[part]))
0165           flag.a = 4;
0166         if ((valueS > maxCurrent) && (voltS >= minHV[2]))
0167           flag.s = 4;
0168         if ((valueC > maxCurrent) && (voltC >= minHV[3]))
0169           flag.c = 4;
0170       }
0171       return flag;
0172     }
0173 
0174     DEFINE_FWK_SERVICE(DTHVCheckByAbsoluteValues);
0175   }  // namespace service
0176 }  // namespace cond