Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:28

0001 //_________________________________________________________
0002 //
0003 //  CSCTMBMiniScope July 2010  Alexander Sakharov
0004 //  Unpacks TMB Logic MiniScope Analyzer and stores in CSCTMBMiniScope.h
0005 //_________________________________________________________
0006 //
0007 
0008 #include "EventFilter/CSCRawToDigi/interface/CSCTMBMiniScope.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include <iostream>
0011 
0012 CSCTMBMiniScope::CSCTMBMiniScope(const uint16_t *buf, int Line6b07, int Line6E07) {
0013   size_ = UnpackMiniScope(buf, Line6b07, Line6E07);
0014 
0015 }  ///CSCTMBMiniScope
0016 
0017 int CSCTMBMiniScope::UnpackMiniScope(const uint16_t *buf, int Line6b07, int Line6E07) {
0018   if ((Line6E07 - Line6b07) != 0) {
0019     /// Get tbin and tbin before pre-trigger
0020     miniScopeTbinCount = buf[Line6b07 + 1] & 0x00FF;
0021     miniScopeTbinPreTrigger = (buf[Line6b07 + 1] >> 8) & 0x000F;
0022 
0023     LogTrace("CSCTMBMiniScope") << " MiniScope Found | Tbin: " << miniScopeTbinCount
0024                                 << " | Tbin Pretrigger: " << miniScopeTbinPreTrigger << std::endl;
0025 
0026     miniScopeAdress.clear();
0027     miniScopeData.clear();
0028 
0029     for (int i = 0; i < miniScopeTbinCount; i++) {
0030       miniScopeAdress.push_back(284 + i);
0031       miniScopeData.push_back(buf[Line6b07 + 1 + i]);
0032     }
0033 
0034     //print();
0035   }  ///end if((Line6E07-Line6b07)
0036 
0037   return (Line6E07 - Line6b07 + 1);
0038 
0039 }  ///UnpackScope
0040 
0041 std::vector<int> CSCTMBMiniScope::getChannelsInTbin(int data) const {
0042   std::vector<int> channelInTbin;
0043   channelInTbin.clear();
0044   for (int k = 0; k < 14; k++) {
0045     int chBit = 0;
0046     chBit = (data >> k) & 0x1;
0047     if (chBit != 0)
0048       channelInTbin.push_back(k);
0049   }
0050   return channelInTbin;
0051 }
0052 
0053 void CSCTMBMiniScope::print() const {
0054   for (unsigned int k = 0; k < getAdr().size(); ++k) {
0055     if (k == 0) {
0056       std::cout << " Adr = " << getAdr()[k] << " | Data: " << std::hex << getData()[k] << std::dec << std::endl;
0057     } else {
0058       std::cout << " Adr = " << getAdr()[k] << " | Data: " << std::hex << getData()[k] << std::dec << " ==>| Ch# ";
0059       for (unsigned int j = 0; j < getChannelsInTbin(getData()[k]).size(); j++) {
0060         std::cout << " " << getChannelsInTbin(getData()[k])[j];
0061       }
0062       std::cout << std::endl;
0063     }
0064   }
0065 }