Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:53

0001 #include "SimPPS/RPDigiProducer/plugins/DeadChannelsManager.h"
0002 #include "CondFormats/PPSObjects/interface/TotemSymbId.h"
0003 #include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
0004 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0005 #include "SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.h"
0006 #include <map>
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 DeadChannelsManager::DeadChannelsManager() { analysisMaskPresent = false; }
0010 
0011 DeadChannelsManager::DeadChannelsManager(const TotemAnalysisMask* _analysisMask) {
0012   analysisMask = _analysisMask;
0013   analysisMaskPresent = true;
0014 }
0015 
0016 bool DeadChannelsManager::isChannelDead(RPDetId detectorId, unsigned short stripNumber) {
0017   unsigned int symbolicId = RPDisplacementGenerator::rawToDecId(detectorId) * 10;  //convert to symbolic ID
0018 
0019   unsigned int vfat = stripNumber / 128;
0020   symbolicId += vfat;                      //add vfatID to symbolic ID
0021   stripNumber = stripNumber - vfat * 128;  //convert strip number to a number from range <0; 127>
0022   TotemSymbID totemSymbolicId;
0023   totemSymbolicId.symbolicID = symbolicId;
0024   if (analysisMaskPresent) {
0025     std::map<TotemSymbID, TotemVFATAnalysisMask>::const_iterator vfatIter =
0026         analysisMask->analysisMask.find(totemSymbolicId);
0027     if (vfatIter != analysisMask->analysisMask.end()) {
0028       TotemVFATAnalysisMask vfatMask = vfatIter->second;
0029       //if channel is dead return true
0030       if (vfatMask.fullMask || vfatMask.maskedChannels.find(stripNumber) != vfatMask.maskedChannels.end()) {
0031         return true;
0032       }
0033     }
0034   }
0035   return false;
0036 }
0037 
0038 void DeadChannelsManager::displayMap() {
0039   if (analysisMaskPresent) {
0040     std::map<TotemSymbID, TotemVFATAnalysisMask>::const_iterator vfatIter;
0041     for (vfatIter = analysisMask->analysisMask.begin(); vfatIter != analysisMask->analysisMask.end(); vfatIter++) {
0042       LogDebug("PPSDigiProducer::DeadChannelsManager") << vfatIter->first.symbolicID << "\n";
0043       TotemVFATAnalysisMask am = vfatIter->second;
0044       if (am.fullMask) {
0045         LogDebug("PPSDigiProducer::DeadChannelsManager") << "   full mask\n";
0046       } else {
0047         std::set<unsigned char>::iterator setIterator;
0048         for (setIterator = am.maskedChannels.begin(); setIterator != am.maskedChannels.end(); setIterator++) {
0049           LogDebug("PPSDigiProducer::DeadChannelsManager") << "   " << (int)(*setIterator) << "\n";
0050         }
0051       }
0052     }
0053   }
0054 }