CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GctFibreAnalyzer Class Reference

#include <L1Trigger/L1GctAnalzyer/src/GctFibreAnalyzer.cc>

Inheritance diagram for GctFibreAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 GctFibreAnalyzer (const edm::ParameterSet &)
 
 ~GctFibreAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void CheckCounter (const L1GctFibreWord fibre)
 
bool CheckFibreWord (const L1GctFibreWord fibre)
 
bool CheckForBC0 (const L1GctFibreWord fibre)
 
void CheckLogicalID (const L1GctFibreWord fibre)
 

Private Attributes

bool m_doCounter
 
bool m_doLogicalID
 
edm::InputTag m_fibreSource
 
unsigned int m_numConsistentEvents
 
unsigned int m_numInconsistentPayloadEvents
 
unsigned int m_numZeroEvents
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Analyzer individual fibre channels from the source card.

Definition at line 32 of file GctFibreAnalyzer.h.

Constructor & Destructor Documentation

◆ GctFibreAnalyzer()

GctFibreAnalyzer::GctFibreAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 26 of file GctFibreAnalyzer.cc.

27  : m_fibreSource(iConfig.getUntrackedParameter<edm::InputTag>("FibreSource")),
28  m_doLogicalID(iConfig.getUntrackedParameter<bool>("doLogicalID")),
29  m_doCounter(iConfig.getUntrackedParameter<bool>("doCounter")),
30  m_numZeroEvents(0),
unsigned int m_numConsistentEvents
T getUntrackedParameter(std::string const &, T const &) const
unsigned int m_numZeroEvents
edm::InputTag m_fibreSource
unsigned int m_numInconsistentPayloadEvents

◆ ~GctFibreAnalyzer()

GctFibreAnalyzer::~GctFibreAnalyzer ( )
override

Definition at line 34 of file GctFibreAnalyzer.cc.

References m_doCounter, m_numConsistentEvents, m_numInconsistentPayloadEvents, and m_numZeroEvents.

34  {
35  edm::LogInfo("Zero Fibreword events") << "Total number of events with zero fibrewords: " << m_numZeroEvents;
36  edm::LogInfo("Inconsistent Payload events")
37  << "Total number of events with inconsistent payloads: " << m_numInconsistentPayloadEvents;
38  if (m_doCounter) {
39  edm::LogInfo("Successful events") << "Total number of Successful events: " << m_numConsistentEvents;
40  }
41 }
unsigned int m_numConsistentEvents
unsigned int m_numZeroEvents
Log< level::Info, false > LogInfo
unsigned int m_numInconsistentPayloadEvents

Member Function Documentation

◆ analyze()

void GctFibreAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 43 of file GctFibreAnalyzer.cc.

References CheckCounter(), CheckFibreWord(), CheckForBC0(), CheckLogicalID(), f, iEvent, m_doCounter, m_doLogicalID, m_fibreSource, m_numConsistentEvents, m_numInconsistentPayloadEvents, and m_numZeroEvents.

43  {
44  using namespace edm;
45 
47  iEvent.getByLabel(m_fibreSource, fibre);
48 
49  bool bc0 = false;
50  int flag_for_zeroes = 0;
51  int flag_for_inconsistent_events = 0;
52  unsigned int flag_for_consistency = 0;
53  int flag_for_consistent_events = 0;
54 
55  for (L1GctFibreCollection::const_iterator f = fibre->begin(); f != fibre->end(); f++) {
56  if (f->data() != 0) {
57  if (m_doCounter) {
58  if (f == fibre->begin()) {
59  flag_for_consistency = f->data();
60  } else if (flag_for_consistency == f->data()) {
61  flag_for_consistent_events++;
62  }
63  }
64 
65  // Check for corrupt fibre data
66  if (!CheckFibreWord(*f)) {
67  edm::LogInfo("GCT fibre data error") << "Missing phase bit (clock) in fibre data " << (*f);
68  }
69 
70  // Check for BC0
71  if (CheckForBC0(*f) && (f == fibre->begin())) {
72  bc0 = true;
73  }
74 
75  // Check for mismatch between fibres
76  if ((bc0 && !CheckForBC0(*f)) || (!bc0 && CheckForBC0(*f))) {
77  edm::LogInfo("GCT fibre data error") << "BC0 mismatch in fibre data " << (*f);
78  }
79 
80  // Check logical ID pattern
81  if (m_doLogicalID)
82  CheckLogicalID(*f);
83 
84  // Check counter pattern
85  if (m_doCounter)
86  CheckCounter(*f);
87 
88  flag_for_zeroes = 1;
89  } else {
90  //this basically checks that all the data is 0s by the time it gets to the last iteration
91  if (flag_for_zeroes == 0 && f == (fibre->end() - 1)) {
93  }
94  //if the zero flag is set to 1 and it managed to find its way into here then something is wrong!
95  if (flag_for_zeroes == 1) {
96  flag_for_inconsistent_events++;
97  }
98  }
99  }
100  //check for inconsistent events i.e. those with one(or more) zeroes, and the rest data
101  if (flag_for_inconsistent_events != 0) {
103  }
104  //check for consistent events with the counter
105  if (m_doCounter && flag_for_consistent_events != 0) {
107  }
108 }
unsigned int m_numConsistentEvents
bool CheckFibreWord(const L1GctFibreWord fibre)
int iEvent
Definition: GenABIO.cc:224
unsigned int m_numZeroEvents
double f[11][100]
void CheckLogicalID(const L1GctFibreWord fibre)
Log< level::Info, false > LogInfo
edm::InputTag m_fibreSource
bool CheckForBC0(const L1GctFibreWord fibre)
HLT enums.
void CheckCounter(const L1GctFibreWord fibre)
unsigned int m_numInconsistentPayloadEvents

◆ CheckCounter()

void GctFibreAnalyzer::CheckCounter ( const L1GctFibreWord  fibre)
private

Definition at line 128 of file GctFibreAnalyzer.cc.

References L1GctFibreWord::data().

Referenced by analyze().

128  {
129  // Remove MSB from both cycles
130  int cycle0Data, cycle1Data;
131 
132  cycle0Data = fibre.data() & 0x7FFF;
133  cycle1Data = (fibre.data() >> 16) & 0x7FFF;
134 
135  // Check to see if fibre numbers are consistent
136  if ((cycle0Data + 1) != cycle1Data) {
137  edm::LogInfo("GCT fibre data error") << "Fibre data not incrementing in cycles 0 and 1 "
138  << " Cycle 0 data=" << cycle0Data << " Cycle 1 data=" << cycle1Data << " "
139  << fibre;
140  }
141 
142  // For now just write out the data
143  edm::LogInfo("GCT fibre counter data") << " Fibre data: cycle0=" << cycle0Data << " cycle1=" << cycle1Data << " "
144  << fibre;
145 }
Log< level::Info, false > LogInfo
uint32_t data() const

◆ CheckFibreWord()

bool GctFibreAnalyzer::CheckFibreWord ( const L1GctFibreWord  fibre)
private

Definition at line 119 of file GctFibreAnalyzer.cc.

References L1GctFibreWord::data().

Referenced by analyze().

119  {
120  // Check that the phase or clock bit (MSB bit on cycle 1) is set as it should be
121  if (fibre.data() & 0x80000000) {
122  return true;
123  } else {
124  return false;
125  }
126 }
uint32_t data() const

◆ CheckForBC0()

bool GctFibreAnalyzer::CheckForBC0 ( const L1GctFibreWord  fibre)
private

Definition at line 110 of file GctFibreAnalyzer.cc.

References L1GctFibreWord::data().

Referenced by analyze().

110  {
111  // Check for BC0 on this event
112  if (fibre.data() & 0x8000) {
113  return true;
114  } else {
115  return false;
116  }
117 }
uint32_t data() const

◆ CheckLogicalID()

void GctFibreAnalyzer::CheckLogicalID ( const L1GctFibreWord  fibre)
private

Definition at line 147 of file GctFibreAnalyzer.cc.

References L1GctFibreWord::block(), L1GctFibreWord::data(), Exception, L1GctFibreWord::index(), and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by analyze().

147  {
148  //added by Jad Marrouche, May 08
149 
150  unsigned ref_jf_link[] = {1, 2, 3, 4, 1, 2, 3, 4};
151  //this array lists the link number ordering we expect from the 3 JFs in positive eta
152  //below, we modify indices 2 and 3 from 3,4 to 1,2 to represent negative eta
153 
154  unsigned ref_eta0_link[] = {3, 4, 3, 4, 3, 4};
155  //this array lists the link number ordering we expect from the ETA0
156 
157  unsigned ref_jf_type[] = {2, 2, 3, 3, 1, 1, 1, 1};
158  //this array lists the SC_type ordering we expect for the JFs
159 
160  unsigned ref_eta0_type[] = {2, 2, 2, 2, 2, 2};
161  //this array lists the SC_type ordering we expect for the ETA0 (for consistency)
162 
163  int eta_region, rct_phi_region, leaf_phi_region, jf_type, elec_type, local_source_card_id, source_card_id_read,
164  source_card_id_expected;
165 
166  // Check that data in cycle 0 and cycle 1 are equal
167  if ((fibre.data() & 0x7FFF) != ((fibre.data() & 0x7FFF0000) >> 16)) {
168  edm::LogInfo("GCT fibre data error") << "Fibre data different on cycles 0 and 1 " << fibre;
169  }
170 
171  //fibre.block() gives 0x90c etc
172  //fibre.index() runs from 0 to 6/8
173 
174  if ((fibre.block() >> 10) & 0x1) {
175  eta_region = 0; //negative eta region
176  ref_jf_link[2] = 1; //modify indices to represent neg_eta fibre mapping
177  ref_jf_link[3] = 2;
178  } else
179  eta_region = 1; //positive eta region
180 
181  if (((fibre.block() >> 8) & 0x7) == 0 || ((fibre.block() >> 8) & 0x7) == 4) //i.e. electron leaf cards
182  {
183  if ((fibre.block() & 0xFF) == 0x04)
184  elec_type = 1;
185  else if ((fibre.block() & 0xFF) == 0x84)
186  elec_type = 0;
187  else
188  throw cms::Exception("Unknown GCT fibre data block ") << fibre.block(); //else something screwed up
189 
190  rct_phi_region = (fibre.index() / 3) + (4 * elec_type);
191 
192  local_source_card_id = (4 * eta_region);
193 
194  source_card_id_expected = (8 * rct_phi_region) + local_source_card_id;
195 
196  source_card_id_read = (fibre.data() >> 8) & 0x7F;
197 
198  if (source_card_id_expected != source_card_id_read) {
199  edm::LogInfo("GCT fibre data error")
200  << "Electron Source Card IDs do not match "
201  << "Expected ID = " << source_card_id_expected << " ID read from data = " << source_card_id_read << " "
202  << fibre; //screwed up
203  }
204 
205  if ((fibre.data() & 0xFF) != (unsigned int)(2 + fibre.index() % 3)) {
206  edm::LogInfo("GCT fibre data error")
207  << "Electron Fibres do not match "
208  << "Expected Fibre = " << (2 + fibre.index() % 3) << " Fibre read from data = " << (fibre.data() & 0xFF)
209  << " " << fibre; //screwed up
210  }
211 
212  } else //i.e. jet leaf cards
213  {
214  //the reason we use these values for eta_region is so it is easy to add 4 to the local source card ID
215  //remember that 0x9.. 0xA.. and 0xB.. are +ve eta block headers
216  //whereas 0xD.., 0xE.. and 0xF.. are -ve eta
217  //can distinguish between them using the above mask and shift
218 
219  if ((fibre.block() & 0xFF) == 0x04)
220  jf_type = 1; //JF2
221  else if ((fibre.block() & 0xFF) == 0x0C)
222  jf_type = 2; //JF3
223  else if ((fibre.block() & 0xFF) == 0x84)
224  jf_type = -1; //ETA0
225  else if ((fibre.block() & 0xFF) == 0x8C)
226  jf_type = 0; //JF1
227  else
228  throw cms::Exception("Unknown GCT fibre data block ") << fibre.block(); //else something screwed up
229 
230  //edm::LogInfo("JF Type Info") << "JF TYPE = " << jf_type << " block = " << fibre; //INFO ONLY
231 
232  leaf_phi_region = ((fibre.block() >> 8) & 0x7) - 1; //0,1,2,3,4,5 for leaf cards
233  if (eta_region == 0)
234  leaf_phi_region--; //need to do this because block index goes 9.. A.. B.. D.. E.. F.. - 8 and C are reserved for electron leafs which are dealt with above
235  if (leaf_phi_region < 0 || leaf_phi_region > 5)
236  throw cms::Exception("Unknown Leaf Card ") << fibre.block();
237  //throw exception if number is outside 0-5 which means something screwed up
238  //if(leaf_phi_region <0 || leaf_phi_region >5) edm::LogInfo("GCT fibre data error") << "Unknown leaf card " << fibre;
239  //write to logger if number is outside 0-5 which means something screwed up
240 
241  if (jf_type == -1) {
242  //in this case fibre.index() runs from 0-5
243  //JF1 comes first, followed by JF2 and JF3
244 
245  if (fibre.index() <= 5) //the compiler warning is because fibre.index() is unsigned int and hence is always >=0
246  {
247  rct_phi_region = ((8 + ((leaf_phi_region % 3) * 3) + (fibre.index() / 2)) % 9);
248  //fibre.index()/2 will give 0 for 0,1 1 for 2,3 and 2 for 4,5
249 
250  //local_source_card_id = ref_eta0_type[ fibre.index() ] + (4 * (1 % eta_region));
251  //take the ones complement of the eta_region because this is the shared part (i.e. other eta0 region)
252  //this is done by (1 % eta_region) since 1%0 = 1 and 1%1=0
253  //FLAWED - since 1%0 is a floating point exception you idiot!
254 
255  local_source_card_id = ref_eta0_type[fibre.index()] + (4 + (eta_region * -4));
256  //this gives what you want - adds 4 when eta_region = 0 (neg) and adds 0 when eta_region = 1 (pos)
257 
258  source_card_id_expected = (8 * rct_phi_region) + local_source_card_id;
259  //from GCT_refdoc_v2_2.pdf
260 
261  source_card_id_read = (fibre.data() >> 8) & 0x7F;
262 
263  if (source_card_id_expected != source_card_id_read) {
264  edm::LogInfo("GCT fibre data error")
265  << "ETA0 Source Card IDs do not match "
266  << "Expected ID = " << source_card_id_expected << " ID read from data = " << source_card_id_read << " "
267  << fibre; //screwed up
268  }
269 
270  if ((fibre.data() & 0xFF) != ref_eta0_link[fibre.index()]) {
271  edm::LogInfo("GCT fibre data error")
272  << "ETA0 Fibres do not match "
273  << "Expected Fibre = " << ref_eta0_link[fibre.index()]
274  << " Fibre read from data = " << (fibre.data() & 0xFF) << " " << fibre; //screwed up
275  }
276  } else
277  edm::LogInfo("GCT fibre data error") << "ETA0 Fibre index out of bounds " << fibre;
278  //edm::LogInfo("Fibre Index Info") << "ETA0 Fibre index = " << fibre.index();
279  }
280 
281  if (jf_type >= 0) {
282  if (fibre.index() <= 7) {
283  rct_phi_region = ((8 + ((leaf_phi_region % 3) * 3) + jf_type) % 9); //see table below
284 
285  /*
286  Leaf Card | RCT crate | Jet Finder
287  ___________________________________________
288  LC3 | LC0 | 17 | 8 | JF1
289  | | 9 | 0 | JF2
290  | | 10 | 1 | JF3
291  ___________________________________________
292  LC4 | LC1 | 11 | 2 | JF1
293  | | 12 | 3 | JF2
294  | | 13 | 4 | JF3
295  ___________________________________________
296  LC5 | LC2 | 14 | 5 | JF1
297  | | 15 | 6 | JF2
298  | | 16 | 7 | JF3
299  ___________________________________________
300  The phase results in the 17/8 being at the top
301  This can be adjusted as necessary by changing
302  the number 8 added before modulo 9 operation
303  */
304 
305  local_source_card_id = ref_jf_type[fibre.index()] + (4 * eta_region);
306 
307  //since the SC sharing scheme renumbers SC 7 as SC3:
308  if (local_source_card_id == 7)
309  local_source_card_id = 3;
310  //there is probably a more elegant way to do this
311 
312  source_card_id_expected = (8 * rct_phi_region) + local_source_card_id;
313 
314  source_card_id_read = (fibre.data() >> 8) & 0x7F;
315 
316  if (source_card_id_expected != source_card_id_read) {
317  edm::LogInfo("GCT fibre data error")
318  << "Source Card IDs do not match "
319  << "Expected ID = " << source_card_id_expected << " ID read from data = " << source_card_id_read << " "
320  << fibre; //screwed up
321  }
322 
323  if ((fibre.data() & 0xFF) != ref_jf_link[fibre.index()]) {
324  edm::LogInfo("GCT fibre data error")
325  << "Fibres do not match "
326  << "Expected Fibre = " << ref_jf_link[fibre.index()]
327  << " Fibre read from data = " << (fibre.data() & 0xFF) << " " << fibre; //screwed up
328  }
329  } else
330  edm::LogInfo("GCT fibre data error") << "Fibre index out of bounds " << fibre;
331  }
332  }
333 }
uint16_t index() const
Log< level::Info, false > LogInfo
uint16_t block() const
uint32_t data() const

Member Data Documentation

◆ m_doCounter

bool GctFibreAnalyzer::m_doCounter
private

Definition at line 47 of file GctFibreAnalyzer.h.

Referenced by analyze(), and ~GctFibreAnalyzer().

◆ m_doLogicalID

bool GctFibreAnalyzer::m_doLogicalID
private

Definition at line 46 of file GctFibreAnalyzer.h.

Referenced by analyze().

◆ m_fibreSource

edm::InputTag GctFibreAnalyzer::m_fibreSource
private

Definition at line 45 of file GctFibreAnalyzer.h.

Referenced by analyze().

◆ m_numConsistentEvents

unsigned int GctFibreAnalyzer::m_numConsistentEvents
private

Definition at line 50 of file GctFibreAnalyzer.h.

Referenced by analyze(), and ~GctFibreAnalyzer().

◆ m_numInconsistentPayloadEvents

unsigned int GctFibreAnalyzer::m_numInconsistentPayloadEvents
private

Definition at line 49 of file GctFibreAnalyzer.h.

Referenced by analyze(), and ~GctFibreAnalyzer().

◆ m_numZeroEvents

unsigned int GctFibreAnalyzer::m_numZeroEvents
private

Definition at line 48 of file GctFibreAnalyzer.h.

Referenced by analyze(), and ~GctFibreAnalyzer().