00001
00002
00003
00004
00005
00011
00012
00013
00014
00015
00016
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/Utilities/interface/Exception.h"
00020
00021
00022 #include "L1Trigger/L1GctAnalyzer/interface/GctFibreAnalyzer.h"
00023
00024
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
00050 if (!CheckFibreWord(*f)){
00051 edm::LogInfo("GCT fibre data error") << "Missing phase bit (clock) in fibre data " << (*f);
00052 }
00053
00054
00055 if (CheckForBC0(*f) && (f==fibre->begin())) {
00056 bc0=true;
00057 }
00058
00059
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
00066 if (m_doLogicalID) CheckLogicalID(*f);
00067
00068
00069 if (m_doCounter) CheckCounter(*f);
00070
00071 }
00072 }
00073
00074 bool GctFibreAnalyzer::CheckForBC0(const L1GctFibreWord fibre)
00075 {
00076
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
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
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
00103 int sourceFibreNumber, sourceLogicalID;
00104
00105 sourceFibreNumber = (fibre.data() & 0x7)-1;
00106 sourceLogicalID = (fibre.data() & 0x7F00) >> 8;
00107
00108
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
00138 int concLogicalID;
00139
00140 if (concRctCrate>=9){
00141 concLogicalID=8*(concRctCrate-9)+4;
00142 } else {
00143 concLogicalID=8*(concRctCrate);
00144 }
00145
00146
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
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
00167 int cycle0Data, cycle1Data;
00168
00169 cycle0Data = fibre.data() & 0x20007FFF;
00170 cycle1Data = (fibre.data() >> 16) & 0x20007FFF;
00171
00172
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
00181 edm::LogInfo("GCT fibre counter data") << " Fibre data: cycle0=" << cycle0Data
00182 << " cycle1=" << cycle1Data
00183 << " " << fibre;
00184 }
00185
00186
00187
00188
00189