test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CSCSPEvent Class Reference

#include <CSCSPEvent.h>

Public Member Functions

const CSCSPCounterscounters (void) const throw ()
 
 CSCSPEvent (void)
 
const CSCSPHeaderheader (void) const throw ()
 
const CSCSPRecordrecord (unsigned int tbin) const throw ()
 
const CSCSPTrailertrailer (void) const throw ()
 
bool unpack (const unsigned short *&buf) throw ()
 

Private Attributes

CSCSPCounters counters_
 
CSCSPHeader header_
 
CSCSPRecord record_ [7]
 
CSCSPTrailer trailer_
 

Detailed Description

Definition at line 9 of file CSCSPEvent.h.

Constructor & Destructor Documentation

CSCSPEvent::CSCSPEvent ( void  )
inline

Definition at line 25 of file CSCSPEvent.h.

25 {}

Member Function Documentation

const CSCSPCounters& CSCSPEvent::counters ( void  ) const
throw (
)
inline

Definition at line 18 of file CSCSPEvent.h.

References counters_.

Referenced by CSCTFUnpacker::produce().

18 { return counters_; }
CSCSPCounters counters_
Definition: CSCSPEvent.h:12
const CSCSPHeader& CSCSPEvent::header ( void  ) const
throw (
)
inline

Definition at line 17 of file CSCSPEvent.h.

References header_.

Referenced by CSCTFUnpacker::produce().

17 { return header_; }
CSCSPHeader header_
Definition: CSCSPEvent.h:11
const CSCSPRecord& CSCSPEvent::record ( unsigned int  tbin) const
throw (
)
inline

Definition at line 21 of file CSCSPEvent.h.

References record_.

Referenced by CSCTFUnpacker::produce().

21 { return record_[tbin]; }
CSCSPRecord record_[7]
Definition: CSCSPEvent.h:13
const CSCSPTrailer& CSCSPEvent::trailer ( void  ) const
throw (
)
inline

Definition at line 19 of file CSCSPEvent.h.

References trailer_.

19 { return trailer_; }
CSCSPTrailer trailer_
Definition: CSCSPEvent.h:14
bool CSCSPEvent::unpack ( const unsigned short *&  buf)
throw (
)

if( track.ME1_tbin()>2 ) unpackError |= true; // because bxaDepth<=2

if( track.ME2_tbin()>2 ) unpackError |= true; // because bxaDepth<=2

if( track.ME3_tbin()>2 ) unpackError |= true; // because bxaDepth<=2

if( track.ME4_tbin()>2 ) unpackError |= true; // because bxaDepth<=2

if( track.MB_tbin()>2 ) unpackError |= true; // because bxaDepth<=2

Definition at line 6 of file CSCSPEvent.cc.

References CSCSP_SPblock::dt_, CSCSP_SPblock::dtFilled, end, CSCSP_SPblock::lct_, CSCSP_SPblock::lctFilled, CSCSP_SPblock::MB_id(), CSCSP_SPblock::MB_tbin(), CSCSP_SPblock::ME1_id(), CSCSP_SPblock::ME1_tbin(), CSCSP_SPblock::ME2_id(), CSCSP_SPblock::ME2_tbin(), CSCSP_SPblock::ME3_id(), CSCSP_SPblock::ME3_tbin(), CSCSP_SPblock::ME4_id(), CSCSP_SPblock::ME4_tbin(), CSCSP_SPblock::mode(), and timeUnitHelper::unpack().

6  {
7  bool unpackError = false;
8 
9  if( (buf[0]&0xF000) != 0x9000 || (buf[1]&0xF000) != 0x9000 || (buf[2]&0xF000) != 0x9000 || (buf[3]&0xF000) != 0x9000 ||
10  (buf[4]&0xF000) != 0xA000 || (buf[5]&0xF000) != 0xA000 || (buf[6]&0xF000) != 0xA000 || (buf[7]&0xF000) != 0xA000 )
11  return true;
12  else
13  unpackError |= header_.unpack(buf);
14 
15  if( !header_.empty() ){
16  // Block of Counters is added in format version 4.3 (dated by 05/27/2007)
17  if( header_.format_version() )
18  unpackError |= counters_.unpack(buf);
19 
20  if( header_.format_version()<3 || !header_.suppression() ){
21  for(unsigned short tbin=0; tbin<header_.nTBINs(); tbin++)
22  unpackError |= record_[tbin].unpack(buf,header_.active(),header_.suppression(),tbin);
23  } else {
24  // For the v.5.3 zero supression tbin has to be identified from the Data Block Header (BH2d word), as opposed to plain counting when empty records are not suppressed
25  for(unsigned short tbin=0, actual_tbin = (buf[7] >> 8) & 0x7; tbin<header_.nTBINs(); tbin++){
26  bzero(&(record_[tbin]),sizeof(record_[tbin]));
27  // Check if we ran into the trailer (happens once all the records were read out)
28  if( (buf[0]&0xF000)==0xF000 && (buf[1]&0xF000)==0xF000 && (buf[2]&0xF000)==0xF000 && (buf[3]&0xF000)==0xF000 &&
29  (buf[4]&0xF000)==0xE000 && (buf[5]&0xF000)==0xE000 && (buf[6]&0xF000)==0xE000 && (buf[7]&0xF000)==0xE000 ) break;
30  // Skip supressed empty tbins in the format version >=5.3
31  if( tbin+1 != actual_tbin ) continue;
32  // Unpack the record
33  unpackError |= record_[tbin].unpack(buf,header_.active(),header_.suppression(),tbin);
34  actual_tbin = (buf[7] >> 8) & 0x7;
35  }
36  }
37 
38  // Link initial LCTs to the tracks in each time bin
39  for(unsigned short tbin=0; tbin<header_.nTBINs(); tbin++){
40  for(unsigned short trk=0; trk<3; trk++){
41  CSCSP_SPblock &track = record_[tbin].sp[trk];
42  if( track.ME1_id()==0 && track.ME2_id()==0 && track.ME3_id()==0 && track.ME4_id()==0 && track.MB_id()==0 ) continue;
43  // The key LCT identified by the BXA algorithm is the second earliest LCT
44  int second_earliest_lct_delay = -1; // this is going to be a # tbins the key LCT was delayed to allign with the latest LCT
45  if( track.mode() != 15 && track.mode() != 11 ){ // BXA works only on non halo tracks and non-singles
46  // BXA algorithm is not trivial: first let's order all the delays (MEx_tbin), which are aligning LCTs to the tbin of the latest LCT
47  std::map< int, std::list<int> > timeline;
48  if( track.ME1_id() ) timeline[track.ME1_tbin()].push_back(1);
49  if( track.ME2_id() ) timeline[track.ME2_tbin()].push_back(2);
50  if( track.ME3_id() ) timeline[track.ME3_tbin()].push_back(3);
51  if( track.ME4_id() ) timeline[track.ME4_tbin()].push_back(4);
52  if( track.MB_id() ) timeline[track.MB_tbin() ].push_back(5);
53  int earliest_lct_delay = -1; //, second_earliest_lct_delay = -1;
54  // Going from largest to smallest delay (earliest LCT pops up first in the loop)
55  for(int delay=7; delay>=0 && second_earliest_lct_delay==-1; delay--){
56  std::list<int>::const_iterator iter = timeline[delay].begin();
57  while( iter != timeline[delay].end() && second_earliest_lct_delay==-1 ){
58  if( earliest_lct_delay==-1 ) earliest_lct_delay=delay;
59  else if( second_earliest_lct_delay==-1 ) second_earliest_lct_delay=delay;
60  iter++;
61  }
62  }
63  } else second_earliest_lct_delay = 0;
64 
65  // MEx_tbin are LCTs delays shifting all of them to the bx of last LCT used to build a track
66  // let's convert delays to TBINs keeping in mind that absolute_lct_tbin = track_tbin + (second_earliest_delay - lct_delay)
67  if( track.ME1_id() ){ // if track contains LCT from the ME1
68  unsigned int mpc = ( track.ME1_id()>3 ? 1 : 0 );
69  int ME1_tbin = tbin + second_earliest_lct_delay - track.ME1_tbin();
71  if( ME1_tbin>=0 && ME1_tbin<7 ) {
72  std::vector<CSCSP_MEblock> lcts = record_[ME1_tbin].LCTs(mpc);
73  for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
74  // Due to old MPC firmware link information was not accessible for some data:
75  //if( lct->link()==(mpc?track.ME1_id()-3:track.ME1_id()) ){
76  if( ((lct->spInput()-1)%3+1)==(mpc?track.ME1_id()-3:track.ME1_id()) ){
77  track.lct_[0] = *lct;
78  track.lctFilled[0] = true;
79  }
80  }
81  }
82  if( track.ME2_id() ){ // ... ME2
83  int ME2_tbin = tbin + second_earliest_lct_delay - track.ME2_tbin();
85  if( ME2_tbin>=0 && ME2_tbin<7 ) {
86  std::vector<CSCSP_MEblock> lcts = record_[ME2_tbin].LCTs(2);
87  for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
88  // Due to old MPC firmware link information was not accessible for some data:
89  //if( lct->link()==track.ME2_id() ){
90  if( ((lct->spInput()-1)%3+1)==track.ME2_id() ){
91  track.lct_[1] = *lct;
92  track.lctFilled[1] = true;
93  }
94  }
95  }
96  if( track.ME3_id() ){ // ... ME3
97  int ME3_tbin = tbin + second_earliest_lct_delay - track.ME3_tbin();
99  if( ME3_tbin>=0 && ME3_tbin<7 ) {
100  std::vector<CSCSP_MEblock> lcts = record_[ME3_tbin].LCTs(3);
101  for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
102  // Due to old MPC firmware link information was not accessible for some data:
103  //if( lct->link()==track.ME3_id() ){
104  if( ((lct->spInput()-1)%3+1)==track.ME3_id() ){
105  track.lct_[2] = *lct;
106  track.lctFilled[2] = true;
107  }
108  }
109  }
110  if( track.ME4_id() ){ // ... fourth station
111  int ME4_tbin = tbin + second_earliest_lct_delay - track.ME4_tbin();
113  if( ME4_tbin>=0 && ME4_tbin<7 ) {
114  std::vector<CSCSP_MEblock> lcts = record_[ME4_tbin].LCTs(4);
115  for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
116  // Due to old MPC firmware link information was not accessible for some data:
117  //if( lct->link()==track.ME4_id() ){
118  if( ((lct->spInput()-1)%3+1)==track.ME4_id() ){
119  track.lct_[3] = *lct;
120  track.lctFilled[3] = true;
121  }
122  }
123  }
124  if( track.MB_id() ){ // ... barrel
125  int MB_tbin = tbin + second_earliest_lct_delay - track.MB_tbin();
127  if( MB_tbin>=0 && MB_tbin<7 ) {
128  std::vector<CSCSP_MBblock> stubs = record_[MB_tbin].mbStubs();
129  for(std::vector<CSCSP_MBblock>::const_iterator stub=stubs.begin(); stub!=stubs.end(); stub++)
130  if( (stub->id()==1 && track.MB_id()%2==1) || (stub->id()==2 && track.MB_id()%2==0) ){
131  track.dt_ = *stub;
132  track.dtFilled = true;
133  }
134  }
135  }
136  }
137  }
138  }
139  unpackError |= trailer_.unpack(buf);
140 
141  return unpackError;
142 }
unsigned int MB_tbin(void) const
Definition: CSCSP_SPblock.h:85
std::vector< CSCSP_MBblock > mbStubs(void) const
Definition: CSCSPRecord.cc:100
unsigned int ME4_tbin(void) const
Definition: CSCSP_SPblock.h:84
CSCSPTrailer trailer_
Definition: CSCSPEvent.h:14
bool unpack(const unsigned short *&buf)
Definition: CSCSPEvent.cc:6
unsigned int MB_id(void) const
Definition: CSCSP_SPblock.h:78
CSCSPRecord record_[7]
Definition: CSCSPEvent.h:13
bool suppression(void) const
Definition: CSCSPHeader.h:94
CSCSPCounters counters_
Definition: CSCSPEvent.h:12
int format_version(void) const
Definition: CSCSPHeader.h:101
CSCSP_SPblock sp[3]
Definition: CSCSPRecord.h:61
bool unpack(const unsigned short *&buf)
Definition: CSCSPTrailer.h:69
unsigned int mode(void) const
bool unpack(const unsigned short *&buf, unsigned int nonmasked_data_blocks, bool empty_blocks_suppressed, unsigned int tbin)
Definition: CSCSPRecord.cc:5
bool lctFilled[4]
Definition: CSCSP_SPblock.h:48
bool unpack(const unsigned short *&buf)
Definition: CSCSPHeader.h:104
unsigned int nTBINs(void) const
Definition: CSCSPHeader.h:92
unsigned int ME3_id(void) const
Definition: CSCSP_SPblock.h:76
CSCSP_MEblock lct_[4]
Definition: CSCSP_SPblock.h:45
CSCSPHeader header_
Definition: CSCSPEvent.h:11
#define end
Definition: vmac.h:37
CSCSP_MBblock dt_
Definition: CSCSP_SPblock.h:46
unsigned int ME3_tbin(void) const
Definition: CSCSP_SPblock.h:83
unsigned int ME2_tbin(void) const
Definition: CSCSP_SPblock.h:82
std::vector< CSCSP_MEblock > LCTs(void) const
Definition: CSCSPRecord.cc:69
unsigned int ME1_id(void) const
Definition: CSCSP_SPblock.h:74
unsigned int ME1_tbin(void) const
Definition: CSCSP_SPblock.h:81
unsigned int ME2_id(void) const
Definition: CSCSP_SPblock.h:75
bool empty(void) const
Definition: CSCSPHeader.h:99
unsigned int ME4_id(void) const
Definition: CSCSP_SPblock.h:77
unsigned int active(void) const
Definition: CSCSPHeader.h:97
bool unpack(const unsigned short *&buf)
Definition: CSCSPCounters.h:27

Member Data Documentation

CSCSPCounters CSCSPEvent::counters_
private

Definition at line 12 of file CSCSPEvent.h.

Referenced by counters().

CSCSPHeader CSCSPEvent::header_
private

Definition at line 11 of file CSCSPEvent.h.

Referenced by header().

CSCSPRecord CSCSPEvent::record_[7]
private

Definition at line 13 of file CSCSPEvent.h.

Referenced by record().

CSCSPTrailer CSCSPEvent::trailer_
private

Definition at line 14 of file CSCSPEvent.h.

Referenced by trailer().