CMS 3D CMS Logo

GctFibreAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    GctFibreAnalyzer
00004 // Class:      GctFibreAnalyzer
00005 // 
00011 //
00012 // Original Author:  Alex Tapper
00013 //         Created:  Thu Jul 12 14:21:06 CEST 2007
00014 // $Id: GctFibreAnalyzer.cc,v 1.4 2007/07/25 13:32:20 tapper Exp $
00015 //
00016 //
00017 
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h" // Logger
00019 #include "FWCore/Utilities/interface/Exception.h" // Exceptions
00020 
00021 // Include file
00022 #include "L1Trigger/L1GctAnalyzer/interface/GctFibreAnalyzer.h"
00023 
00024 // Data format
00025 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00026 
00027 GctFibreAnalyzer::GctFibreAnalyzer(const edm::ParameterSet& iConfig):
00028   m_fibreSource(iConfig.getUntrackedParameter<edm::InputTag>("FibreSource")),
00029   m_doLogicalID(iConfig.getUntrackedParameter<bool>("doLogicalID")),
00030   m_doCounter(iConfig.getUntrackedParameter<bool>("doCounter"))
00031 {
00032 }
00033 
00034 GctFibreAnalyzer::~GctFibreAnalyzer()
00035 {
00036 }
00037 
00038 void GctFibreAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00039 {
00040   using namespace edm;
00041   
00042   Handle<L1GctFibreCollection> fibre;
00043   iEvent.getByLabel(m_fibreSource,fibre);
00044 
00045   bool bc0= false;
00046 
00047   for (L1GctFibreCollection::const_iterator f=fibre->begin(); f!=fibre->end(); f++){
00048 
00049     // Check for corrupt fibre data
00050     if (!CheckFibreWord(*f)){
00051       edm::LogInfo("GCT fibre data error") << "Missing phase bit (clock) in fibre data " << (*f);
00052     }
00053     
00054     // Check for BC0
00055     if (CheckForBC0(*f) && (f==fibre->begin())) {
00056       bc0=true;
00057     }
00058 
00059     // Check for mismatch between fibres
00060     if ((bc0 && !CheckForBC0(*f)) ||
00061         (!bc0 && CheckForBC0(*f))){
00062       edm::LogInfo("GCT fibre data error") << "BC0 mismatch in fibre data " << (*f);
00063     }
00064 
00065     // Check logical ID pattern
00066     if (m_doLogicalID) CheckLogicalID(*f);
00067 
00068     // Check counter pattern
00069     if (m_doCounter) CheckCounter(*f);
00070 
00071   }   
00072 }
00073 
00074 bool GctFibreAnalyzer::CheckForBC0(const L1GctFibreWord fibre)
00075 {
00076   // Check for BC0 on this event
00077   if (fibre.data() & 0x8000){
00078     return true;
00079   } else {
00080     return false;
00081   }
00082 }
00083 
00084 bool GctFibreAnalyzer::CheckFibreWord(const L1GctFibreWord fibre)
00085 {
00086   // Check that the phase or clock bit (MSB bit on cycle 1) is set as it should be
00087   if (fibre.data() & 0x80000000){
00088     return true;
00089   } else {
00090     return false;
00091   }
00092 }
00093 
00094 void GctFibreAnalyzer::CheckLogicalID(const L1GctFibreWord fibre)
00095 {
00096 
00097   // Check that data data in cycle 0 and cycle 1 are equal
00098   if ((fibre.data()&0x7FFF)!=((fibre.data()&0x7FFF0000)>>16)){
00099     edm::LogInfo("GCT fibre data error") << "Fibre data different on cycles 0 and 1 " << fibre;
00100   }
00101 
00102   // Decode the fibre data
00103   int sourceFibreNumber, sourceLogicalID;
00104     
00105   sourceFibreNumber = (fibre.data() & 0x7)-1; 
00106   sourceLogicalID   = (fibre.data() & 0x7F00) >> 8;
00107     
00108   // Calculate logical ID and fibre number from block and index
00109   int concFibreNumber, concRctCrate;
00110 
00111   switch (fibre.block()){
00112     
00113   case 0x89:
00114     concRctCrate = fibre.index()/3;
00115     concFibreNumber = 1+(fibre.index()%3);
00116     break;
00117 
00118   case 0x81:
00119     concRctCrate = 4+(fibre.index()/3);
00120     concFibreNumber = 1+(fibre.index()%3);
00121     break;
00122       
00123   case 0xc9:
00124     concRctCrate = 9+(fibre.index()/3);
00125     concFibreNumber = 1+(fibre.index()%3);
00126     break;
00127       
00128   case 0xc1:
00129     concRctCrate = 13+(fibre.index()/3);
00130     concFibreNumber = 1+(fibre.index()%3);
00131     break;
00132 
00133   default:
00134     throw cms::Exception("Unknown GCT fibre data block ") << fibre.block();    
00135   }
00136     
00137   // Calculate logical ID from crate and fibre number
00138   int concLogicalID;
00139     
00140   if (concRctCrate>=9){
00141     concLogicalID=8*(concRctCrate-9)+4;
00142   } else {
00143     concLogicalID=8*(concRctCrate);
00144   }
00145 
00146   // Check to see if logical IDs are consistent
00147   if (concLogicalID!=sourceLogicalID){
00148     edm::LogInfo("GCT fibre data error") << "Logical IDs are different " 
00149                                          << "Source card logical ID=" << sourceLogicalID
00150                                          << " Conc card logical ID=" << concLogicalID
00151                                          << " " << fibre;      
00152   }
00153 
00154   // Check to see if fibre numbers are consistent
00155   if (concFibreNumber!=sourceFibreNumber){
00156     edm::LogInfo("GCT fibre data error") << "Fibre numbers are different " 
00157                                          << "Source card fibre number=" << sourceFibreNumber
00158                                          << " Conc card fibre number=" << concFibreNumber
00159                                          << " " << fibre;      
00160   }
00161     
00162 }
00163 
00164 void GctFibreAnalyzer::CheckCounter(const L1GctFibreWord fibre)
00165 {
00166   // Remove MSB from both cycles
00167   int cycle0Data, cycle1Data;
00168   
00169   cycle0Data = fibre.data() & 0x20007FFF;
00170   cycle1Data = (fibre.data() >> 16) & 0x20007FFF;
00171 
00172   // Check to see if fibre numbers are consistent
00173   if ((cycle0Data+1)!=cycle1Data){
00174     edm::LogInfo("GCT fibre data error") << "Fibre data not incrementing in cycles 0 and 1 "
00175                                          << " Cycle 0 data=" << cycle0Data
00176                                          << " Cycle 1 data=" << cycle1Data
00177                                          << " " << fibre;      
00178   }  
00179   
00180   // For now just write out the data
00181   edm::LogInfo("GCT fibre counter data") << " Fibre data: cycle0=" << cycle0Data 
00182                                          << " cycle1=" << cycle1Data
00183                                          << " " << fibre;
00184 }
00185 
00186 
00187 
00188 
00189 

Generated on Tue Jun 9 17:40:17 2009 for CMSSW by  doxygen 1.5.4