CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/CSCRawToDigi/src/CSCTMBMiniScope.cc

Go to the documentation of this file.
00001 //_________________________________________________________
00002 //
00003 //  CSCTMBMiniScope July 2010  Alexander Sakharov                            
00004 //  Unpacks TMB Logic MiniScope Analyzer and stores in CSCTMBMiniScope.h  
00005 //_________________________________________________________
00006 //
00007 
00008 
00009 #include "EventFilter/CSCRawToDigi/interface/CSCTMBMiniScope.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include <iostream>
00012 
00013 CSCTMBMiniScope::CSCTMBMiniScope(unsigned short *buf,int Line6b07,int Line6E07) {
00014 
00015   size_ = UnpackMiniScope(buf,Line6b07,Line6E07);
00016 
00017 } 
00018 
00019 
00020 int CSCTMBMiniScope::UnpackMiniScope(unsigned short *buf,int Line6b07,int Line6E07) {
00021 
00022 
00023   if((Line6E07-Line6b07) != 0) {
00024 
00026     miniScopeTbinCount = buf[Line6b07+1] & 0x00FF;
00027     miniScopeTbinPreTrigger = (buf[Line6b07+1] >> 8) & 0x000F;
00028     
00029     LogTrace("CSCTMBMiniScope") << " MiniScope Found | Tbin: " << miniScopeTbinCount <<
00030                  " | Tbin Pretrigger: " << miniScopeTbinPreTrigger << std::endl;
00031         
00032      miniScopeAdress.clear();
00033      miniScopeData.clear();
00034 
00035      for(int i=0; i<miniScopeTbinCount; i++){
00036         miniScopeAdress.push_back(284+i);
00037         miniScopeData.push_back(buf[Line6b07 + 1+i]);
00038      }
00039      
00040      //print();
00041   } 
00042 
00043 
00044   return (Line6E07-Line6b07 + 1);
00045 
00046 } 
00047 
00048 std::vector<int> CSCTMBMiniScope::getChannelsInTbin(int data) const {
00049                  std::vector<int> channelInTbin;
00050                  channelInTbin.clear();
00051                  for(int k=0; k<14; k++){
00052                               int chBit=0;
00053                               chBit = (data >> k) & 0x1;
00054                               if(chBit !=0)
00055                               channelInTbin.push_back(k);
00056         }
00057         return channelInTbin;
00058 }
00059 
00060 
00061 void CSCTMBMiniScope::print() const {
00062      for(unsigned int k=0; k<getAdr().size();++k){
00063            if(k==0){
00064              std::cout << " Adr = " << getAdr()[k] << " | Data: " 
00065                                      << std::hex <<  getData()[k] << std::dec << std::endl;
00066            }
00067            else{
00068            std::cout << " Adr = " << getAdr()[k] << " | Data: " 
00069                                      << std::hex <<  getData()[k] << std::dec << " ==>| Ch# ";
00070                                       for(unsigned int j=0; j<getChannelsInTbin(getData()[k]).size(); j++){
00071                                          std::cout << " " << getChannelsInTbin(getData()[k])[j];
00072                                       }
00073                                      std::cout << std::endl;
00074            }
00075            }
00076 }