Go to the documentation of this file.00001 #include "EventFilter/EcalRawToDigi/interface/DCCEventBlock.h"
00002 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
00003 #include "EventFilter/EcalRawToDigi/interface/EcalDCCHeaderRuntypeDecoder.h"
00004 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
00005 #include "EventFilter/EcalRawToDigi/interface/DCCFEBlock.h"
00006 #include "EventFilter/EcalRawToDigi/interface/DCCMemBlock.h"
00007 #include "EventFilter/EcalRawToDigi/interface/DCCTCCBlock.h"
00008 #include "EventFilter/EcalRawToDigi/interface/DCCSRPBlock.h"
00009 #include <sys/time.h>
00010
00011 #include <iomanip>
00012 #include <sstream>
00013
00014 DCCEventBlock::DCCEventBlock( DCCDataUnpacker * u , EcalElectronicsMapper * m , bool hU, bool srpU, bool tccU, bool feU, bool memU, bool forceToKeepFRdata) :
00015 unpacker_(u), mapper_(m), headerUnpacking_(hU), srpUnpacking_(srpU), tccUnpacking_(tccU), feUnpacking_(feU),memUnpacking_(memU), forceToKeepFRdata_(forceToKeepFRdata)
00016 {
00017
00018
00019 memBlock_ = new DCCMemBlock(u,m,this);
00020
00021
00022 for( int feChannel=1; feChannel <= 70; feChannel++) { feChStatus_.push_back(0); hlt_.push_back(1);}
00023 for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccChStatus_.push_back(0);}
00024
00025
00026 for( int feChannel=1; feChannel <= 70; feChannel++) { feBx_.push_back(-1); feLv1_.push_back(-1); }
00027 for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccBx_.push_back(-1); tccLv1_.push_back(-1);}
00028 srpBx_=-1;
00029 srpLv1_=-1;
00030
00031 }
00032
00033
00034 void DCCEventBlock::reset(){
00035
00036
00037 for( int feChannel=1; feChannel <= 70; feChannel++) { feBx_[feChannel-1]=-1; feLv1_[feChannel-1]=-1; }
00038 for( int tccChannel=1; tccChannel <= 4 ; tccChannel++){ tccBx_[tccChannel-1]=-1; tccLv1_[tccChannel-1]=-1;}
00039 srpBx_=-1;
00040 srpLv1_=-1;
00041
00042
00043 }
00044
00045 void DCCEventBlock::enableSyncChecks(){
00046 towerBlock_ ->enableSyncChecks();
00047 tccBlock_ ->enableSyncChecks();
00048 memBlock_ ->enableSyncChecks();
00049 srpBlock_ ->enableSyncChecks();
00050 }
00051
00052
00053
00054 void DCCEventBlock::enableFeIdChecks(){
00055 towerBlock_ ->enableFeIdChecks();
00056 }
00057
00058
00059
00060 void DCCEventBlock::updateCollectors(){
00061
00062 dccHeaders_ = unpacker_->dccHeadersCollection();
00063
00064 memBlock_ ->updateCollectors();
00065 tccBlock_ ->updateCollectors();
00066 srpBlock_ ->updateCollectors();
00067 towerBlock_ ->updateCollectors();
00068
00069 }
00070
00071
00072
00073
00074 void DCCEventBlock::addHeaderToCollection(){
00075
00076
00077 EcalDCCHeaderBlock theDCCheader;
00078
00079
00080 theDCCheader.setFedId(fedId_);
00081
00082
00083
00084
00085
00086
00087 int dccId = mapper_->getActiveSM();
00088
00089 theDCCheader.setId(dccId);
00090
00091
00092 theDCCheader.setRunNumber(runNumber_);
00093 theDCCheader.setBasicTriggerType(triggerType_);
00094 theDCCheader.setLV1(l1_);
00095 theDCCheader.setBX(bx_);
00096 theDCCheader.setOrbit(orbitCounter_);
00097 theDCCheader.setErrors(dccErrors_);
00098 theDCCheader.setSelectiveReadout(sr_);
00099 theDCCheader.setZeroSuppression(zs_);
00100 theDCCheader.setTestZeroSuppression(tzs_);
00101 theDCCheader.setSrpStatus(srChStatus_);
00102 theDCCheader.setTccStatus(tccChStatus_);
00103 theDCCheader.setFEStatus(feChStatus_);
00104
00105
00106 theDCCheader.setSRPLv1(srpLv1_);
00107 theDCCheader.setSRPBx(srpBx_);
00108 theDCCheader.setFELv1(feLv1_);
00109 theDCCheader.setFEBx(feBx_);
00110 theDCCheader.setTCCLv1(tccLv1_);
00111 theDCCheader.setTCCBx(tccBx_);
00112
00113
00114 EcalDCCHeaderRuntypeDecoder theRuntypeDecoder;
00115 unsigned int DCCruntype = runType_;
00116 unsigned int DCCdetTriggerType = detailedTriggerType_;
00117 theRuntypeDecoder.Decode(triggerType_, DCCdetTriggerType , DCCruntype, &theDCCheader);
00118
00119
00120 (*dccHeaders_)->push_back(theDCCheader);
00121
00122 }
00123
00124 void DCCEventBlock::display(std::ostream& o){
00125 o<<"\n Unpacked Info for DCC Event Class"
00126 <<"\n DW1 ============================="
00127 <<"\n Fed Id "<<fedId_
00128 <<"\n Bx "<<bx_
00129 <<"\n L1 "<<l1_
00130 <<"\n Trigger Type "<<triggerType_
00131 <<"\n DW2 ============================="
00132 <<"\n Length "<<blockLength_
00133 <<"\n Dcc errors "<<dccErrors_
00134 <<"\n Run number "<<runNumber_
00135 <<"\n DW3 ============================="
00136 <<"\n SR "<<sr_
00137 <<"\n ZS "<<zs_
00138 <<"\n TZS "<<tzs_
00139 <<"\n SRStatus "<<srChStatus_;
00140
00141 std::vector<short>::iterator it;
00142 int i(0),k(0);
00143 for(it = tccChStatus_.begin(); it!=tccChStatus_.end();it++,i++){
00144 o<<"\n TCCStatus#"<<i<<" "<<(*it);
00145 }
00146
00147 i=0;
00148 for(it = feChStatus_.begin();it!=feChStatus_.end();it++ ,i++){
00149 if(!(i%14)){ o<<"\n DW"<<(k+3)<<" ============================="; k++; }
00150 o<<"\n FEStatus#"<<i<<" "<<(*it);
00151 }
00152
00153 o<<"\n";
00154 }
00155
00156
00157 DCCEventBlock::~DCCEventBlock(){
00158 if(towerBlock_){ delete towerBlock_; }
00159 if(tccBlock_) { delete tccBlock_; }
00160 if(memBlock_) { delete memBlock_; }
00161 if(srpBlock_) { delete srpBlock_; }
00162 }
00163
00164
00165
00166
00167
00168 bool isSynced(const unsigned int dccBx,
00169 const unsigned int bx,
00170 const unsigned int dccL1,
00171 const unsigned int l1,
00172 const BlockType type,
00173 const unsigned int fov)
00174 {
00175
00176
00177 if ( fov < 1 ) return true;
00178
00179
00180
00181
00182
00183
00184
00185 const bool bxSynced =
00186 ((type == FE_MEM) && (bx == 0) && (dccBx == 3564)) ||
00187 ((type == FE_MEM) && (bx == dccBx) && (dccBx != 3564)) ||
00188 ((type == TCC_SRP) && (bx == dccBx));
00189
00190
00191
00192
00193
00194
00195
00196 const bool l1Synced =
00197 ((type == FE_MEM) && (l1 == ((dccL1 - 1) & 0xFFF))) ||
00198 ((type == TCC_SRP) && (l1 == ( dccL1 & 0xFFF)));
00199
00200 return (bxSynced && l1Synced);
00201 }