CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DCCEventBlock.cc
Go to the documentation of this file.
9 #include <sys/time.h>
10 
11 #include <iomanip>
12 #include <sstream>
13 
14 DCCEventBlock::DCCEventBlock( DCCDataUnpacker * u , EcalElectronicsMapper * m , bool hU, bool srpU, bool tccU, bool feU, bool memU, bool forceToKeepFRdata) :
15  unpacker_(u), mapper_(m), headerUnpacking_(hU), srpUnpacking_(srpU), tccUnpacking_(tccU), feUnpacking_(feU),memUnpacking_(memU), forceToKeepFRdata_(forceToKeepFRdata)
16 {
17 
18  // Build a Mem Unpacker Block
19  memBlock_ = new DCCMemBlock(u,m,this);
20 
21  // setup and initialize ch status vectors
22  for( int feChannel=1; feChannel <= 70; feChannel++) { feChStatus_.push_back(0); hlt_.push_back(1);}
23  for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccChStatus_.push_back(0);}
24 
25  // setup and initialize sync vectors
26  for( int feChannel=1; feChannel <= 70; feChannel++) { feBx_.push_back(-1); feLv1_.push_back(-1); }
27  for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccBx_.push_back(-1); tccLv1_.push_back(-1);}
28  srpBx_=-1;
29  srpLv1_=-1;
30 
31 }
32 
33 
35 
36  // reset sync vectors
37  for( int feChannel=1; feChannel <= 70; feChannel++) { feBx_[feChannel-1]=-1; feLv1_[feChannel-1]=-1; }
38  for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccBx_[tccChannel-1]=-1; tccLv1_[tccChannel-1]=-1;}
39  srpBx_=-1;
40  srpLv1_=-1;
41 
42 
43 }
44 
50 }
51 
52 
53 
56 }
57 
58 
59 
61 
63 
68 
69 }
70 
71 
72 
73 
75 
76 
77  EcalDCCHeaderBlock theDCCheader;
78 
79  // container for fed_id (601-654 for ECAL)
80  theDCCheader.setFedId(fedId_);
81 
82 
83  // this needs to be migrated to the ECAL mapping package
84 
85  // dccId is number internal to ECAL running 1.. 54.
86  // convention is that dccId = (fed_id - 600)
87  int dccId = mapper_->getActiveSM();
88  // DCCHeaders follow the same convenction
89  theDCCheader.setId(dccId);
90 
91 
92  theDCCheader.setRunNumber(runNumber_);
93  theDCCheader.setBasicTriggerType(triggerType_);
94  theDCCheader.setLV1(l1_);
95  theDCCheader.setBX(bx_);
96  theDCCheader.setOrbit(orbitCounter_);
97  theDCCheader.setErrors(dccErrors_);
98  theDCCheader.setSelectiveReadout(sr_);
99  theDCCheader.setZeroSuppression(zs_);
100  theDCCheader.setTestZeroSuppression(tzs_);
101  theDCCheader.setSrpStatus(srChStatus_);
102  theDCCheader.setTccStatus(tccChStatus_);
103  theDCCheader.setFEStatus(feChStatus_);
104 
105 
106  theDCCheader.setSRPLv1(srpLv1_);
107  theDCCheader.setSRPBx(srpBx_);
108  theDCCheader.setFELv1(feLv1_);
109  theDCCheader.setFEBx(feBx_);
110  theDCCheader.setTCCLv1(tccLv1_);
111  theDCCheader.setTCCBx(tccBx_);
112 
113 
114  EcalDCCHeaderRuntypeDecoder theRuntypeDecoder;
115  unsigned int DCCruntype = runType_;
116  unsigned int DCCdetTriggerType = detailedTriggerType_;
117  theRuntypeDecoder.Decode(triggerType_, DCCdetTriggerType , DCCruntype, &theDCCheader);
118 
119  // Add Header to collection
120  (*dccHeaders_)->push_back(theDCCheader);
121 
122 }
123 
124 void DCCEventBlock::display(std::ostream& o){
125  o<<"\n Unpacked Info for DCC Event Class"
126  <<"\n DW1 ============================="
127  <<"\n Fed Id "<<fedId_
128  <<"\n Bx "<<bx_
129  <<"\n L1 "<<l1_
130  <<"\n Trigger Type "<<triggerType_
131  <<"\n DW2 ============================="
132  <<"\n Length "<<blockLength_
133  <<"\n Dcc errors "<<dccErrors_
134  <<"\n Run number "<<runNumber_
135  <<"\n DW3 ============================="
136  <<"\n SR "<<sr_
137  <<"\n ZS "<<zs_
138  <<"\n TZS "<<tzs_
139  <<"\n SRStatus "<<srChStatus_;
140 
141  std::vector<short>::iterator it;
142  int i(0),k(0);
143  for(it = tccChStatus_.begin(); it!=tccChStatus_.end();it++,i++){
144  o<<"\n TCCStatus#"<<i<<" "<<(*it);
145  }
146 
147  i=0;
148  for(it = feChStatus_.begin();it!=feChStatus_.end();it++ ,i++){
149  if(!(i%14)){ o<<"\n DW"<<(k+3)<<" ============================="; k++; }
150  o<<"\n FEStatus#"<<i<<" "<<(*it);
151  }
152 
153  o<<"\n";
154 }
155 
156 
158  if(towerBlock_){ delete towerBlock_; }
159  if(tccBlock_) { delete tccBlock_; }
160  if(memBlock_) { delete memBlock_; }
161  if(srpBlock_) { delete srpBlock_; }
162 }
163 
164 
165 // -----------------------------------------------------------------------
166 // sync checking
167 
168 bool isSynced(const unsigned int dccBx,
169  const unsigned int bx,
170  const unsigned int dccL1,
171  const unsigned int l1,
172  const BlockType type,
173  const unsigned int fov)
174 {
175  // avoid checking for MC until EcalDigiToRaw bugfixed
176  // and to guarantee backward compatibility on RAW data
177  if ( fov < 1 ) return true;
178  // check the BX sync according the following rule:
179  //
180  // FE Block MEM Block TCC Block SRP Block DCC
181  // ------------------------------------------------------------------
182  // fe_bx == mem_bx == 0 tcc_bx == srp_bx == DCC_bx == 3564
183  // fe_bx == mem_bx == tcc_bx == srp_bx == DCC_bx != 3564
184 
185  const bool bxSynced =
186  ((type == FE_MEM) && (bx == 0) && (dccBx == 3564)) ||
187  ((type == FE_MEM) && (bx == dccBx) && (dccBx != 3564)) ||
188  ((type == TCC_SRP) && (bx == dccBx));
189 
190  // check the L1A sync:
191  //
192  // L1A counter relation is valid modulo 0xFFF:
193  // fe_l1 == mem_l1 == (DCC_l1-1) & 0xFFF
194  // tcc_l1 == srp_l1 == DCC_l1 & 0xFFF
195 
196  const bool l1Synced =
197  ((type == FE_MEM) && (l1 == ((dccL1 - 1) & 0xFFF))) ||
198  ((type == TCC_SRP) && (l1 == ( dccL1 & 0xFFF)));
199 
200  return (bxSynced && l1Synced);
201 }
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
bool isSynced(const unsigned int dccBx, const unsigned int bx, const unsigned int dccL1, const unsigned int l1, const BlockType type, const unsigned int fov)
void setSelectiveReadout(const bool &selectiveReadout)
DCCEventBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, bool hU, bool srpU, bool tccU, bool feU, bool memU, bool forceToKeepFRdata)
void enableSyncChecks()
unsigned int runType_
Definition: DCCEventBlock.h:98
EcalElectronicsMapper * mapper_
DCCFEBlock * towerBlock_
DCCSRPBlock * srpBlock_
void setFedId(const int &fedId)
void setBasicTriggerType(const short &triggerType)
void enableFeIdChecks()
std::auto_ptr< EcalRawDataCollection > * dccHeaders_
void setTCCBx(const std::vector< short > &tccBx)
DCCMemBlock * memBlock_
void setSRPBx(const short &srpBx)
unsigned int srChStatus_
Definition: DCCEventBlock.h:87
void setFEStatus(const std::vector< short > &feStatus)
void setRunNumber(const int &run)
unsigned int detailedTriggerType_
Definition: DCCEventBlock.h:99
std::vector< short > hlt_
Definition: DCCEventBlock.h:80
unsigned int blockLength_
Definition: DCCEventBlock.h:95
unsigned int triggerType_
Definition: DCCEventBlock.h:93
void setZeroSuppression(const bool &zeroSuppression)
DCCDataUnpacker * unpacker_
Definition: DCCEventBlock.h:73
virtual void updateCollectors()
Definition: DCCFEBlock.cc:20
unsigned int runNumber_
Definition: DCCEventBlock.h:97
std::vector< short > tccBx_
Definition: DCCEventBlock.h:83
unsigned int sr_
unsigned int l1_
Definition: DCCEventBlock.h:92
std::auto_ptr< EcalRawDataCollection > * dccHeadersCollection()
void updateCollectors()
Definition: DCCMemBlock.cc:29
std::vector< short > tccLv1_
Definition: DCCEventBlock.h:83
std::vector< short > feBx_
Definition: DCCEventBlock.h:82
void setTestZeroSuppression(const bool &testZeroSuppression)
unsigned int orbitCounter_
bool Decode(unsigned long TrTy, unsigned long detTrTy, unsigned long runType, EcalDCCHeaderBlock *theHeader)
void setTccStatus(const std::vector< short > &tccStatus)
int k[5][pyjets_maxn]
DCCTCCBlock * tccBlock_
std::vector< short > feChStatus_
Definition: DCCEventBlock.h:78
void setSRPLv1(const short &srpLv1)
void setErrors(const int &dccErrors)
void setFEBx(const std::vector< short > &feBx)
void setFELv1(const std::vector< short > &feLv1)
void updateCollectors()
std::vector< short > feLv1_
Definition: DCCEventBlock.h:82
void setSrpStatus(const short &srpStatus)
unsigned int bx_
Definition: DCCEventBlock.h:91
BlockType
void setOrbit(const int &orbit)
void enableFeIdChecks()
Definition: DCCFEBlock.h:32
virtual ~DCCEventBlock()
void setId(const int &dccId)
unsigned int zs_
void addHeaderToCollection()
void setLV1(const int &LV1)
void setBX(const int &BX)
unsigned int tzs_
void display(std::ostream &o)
std::vector< short > tccChStatus_
Definition: DCCEventBlock.h:79
void setTCCLv1(const std::vector< short > &tccLv1)
unsigned int fedId_
Definition: DCCEventBlock.h:90
unsigned int dccErrors_
Definition: DCCEventBlock.h:96