35 LogDebug(
"CSCTFUnpacker|ctor")<<
"Started ...";
46 LogDebug(
"CSCTFUnpacker|ctor")<<
"Verifying slot<->sector map from 'vint32 slot2sector'";
47 for(
int slot=0; slot<22; slot++)
48 if( slot2sector[slot]<0 || slot2sector[slot]>12 )
49 throw cms::Exception(
"Invalid configuration")<<
"CSCTFUnpacker: sector index is set out of range (slot2sector["<<slot<<
"]="<<slot2sector[slot]<<
", should be [0-12])";
51 slot2sector.resize(32);
55 if( mappingFile.length() ){
56 LogDebug(
"CSCTFUnpacker|ctor") <<
"Define ``mapping'' only if you want to screw up real geometry";
59 LogDebug(
"CSCTFUnpacker|ctor") <<
"Generating default hw<->geometry mapping";
64 for(
int sector=1; sector<=6; sector++)
76 produces<CSCCorrelatedLCTDigiCollection>();
77 produces<L1CSCTrackCollection>();
78 produces<L1CSCStatusDigiCollection>();
79 produces<CSCTriggerContainer<csctf::TrackStub> >(
"DT");
95 auto LCTProduct = std::make_unique<CSCCorrelatedLCTDigiCollection>();
96 auto trackProduct = std::make_unique<L1CSCTrackCollection>();
97 auto statusProduct = std::make_unique<L1CSCStatusDigiCollection>();
98 auto dtProduct = std::make_unique<CSCTriggerContainer<csctf::TrackStub>>();
102 if( fedData.
size()==0 )
continue;
106 if( unpacking_status==0 ){
110 for(std::vector<const CSCSPEvent *>::const_iterator spItr=SPs.begin(); spItr!=SPs.end(); spItr++){
128 for(
unsigned int tbin=0; tbin<sp->
header().
nTBINs(); tbin++){
136 for(
unsigned int FPGA=0; FPGA<5; FPGA++)
137 for(
unsigned int MPClink=0; MPClink<3; ++MPClink){
138 std::vector<CSCSP_MEblock> lct = sp->
record(tbin).
LCT(FPGA,MPClink);
139 if( lct.size()==0 )
continue;
142 (1<<lct[0].receiver_status_frame1())|
143 (1<<lct[0].receiver_status_frame2())|
144 ((lct[0].aligment_fifo()?1:0)<<4);
145 status.
mpc_link_id |= (lct[0].link()<<2)|lct[0].mpc();
147 int station = ( FPGA ? FPGA : 1 );
152 if( sector>6 ) sector -= 6;
157 int subsector = ( FPGA>1 ? 0 : FPGA+1 );
158 int cscid = lct[0].csc() ;
163 LCTProduct->insertDigi(
id,
165 0,lct[0].vp(),lct[0].
quality(),lct[0].wireGroup(),
168 (lct[0].tbin()+(central_lct_bx-central_sp_bx)),
169 lct[0].link(), lct[0].BXN(), 0, cscid )
172 edm::LogInfo(
"CSCTFUnpacker|produce") << e.
what() <<
"Not adding digi to collection in event " 173 <<sp->
header().
L1A()<<
" (endcap="<<endcap<<
",station="<<station<<
",sector="<<sector<<
",subsector="<<subsector<<
",cscid="<<cscid<<
",spSlot="<<sp->
header().
slot()<<
")";
178 std::vector<CSCSP_MBblock> mbStubs = sp->
record(tbin).
mbStubs();
179 for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
184 if( sector>6 ) sector -= 6;
189 const unsigned int csc2dt[6][2] = {{2,3},{4,5},{6,7},{8,9},{10,11},{12,1}};
190 DTChamberId id((endcap==1?2:-2),1, csc2dt[sector-1][iter->id()-1]);
191 CSCCorrelatedLCTDigi base(0,iter->vq(),iter->quality(),iter->cal(),iter->flag(),iter->bc0(),iter->phi_bend(),tbin+(central_lct_bx-central_sp_bx),iter->id(),iter->bxn(),iter->timingError(),iter->BXN());
193 dtProduct->push_back(dtStub);
197 unsigned int trkNumber=0;
198 for(std::vector<CSCSP_SPblock>::const_iterator iter=tracks.begin(); iter!=tracks.end(); iter++,trkNumber++){
203 if( track.first.m_sector>6 ) track.first.m_sector -= 6;
209 track.first.m_lphi = iter->phi();
210 track.first.m_ptAddress = iter->ptLUTaddress();
211 track.first.m_fr = iter->f_r();
212 track.first.m_ptAddress|=(iter->f_r() << 21);
214 track.first.setStationIds(iter->ME1_id(),iter->ME2_id(),iter->ME3_id(),iter->ME4_id(),iter->MB_id());
215 track.first.setTbins(iter->ME1_tbin(), iter->ME2_tbin(), iter->ME3_tbin(), iter->ME4_tbin(), iter->MB_tbin() );
216 track.first.setBx(iter->tbin()-central_sp_bx);
217 track.first.setBits(iter->syncErr(), iter->bx0(), iter->bc0());
219 track.first.setLocalPhi(iter->phi());
220 track.first.setEtaPacked(iter->eta());
221 track.first.setChargePacked(iter->charge());
223 track.first.m_output_link = iter->id();
224 if( track.first.m_output_link ){
226 track.first.setChargeValidPacked((iter->f_r()?(sp->
record(tbin).
ptSpy()&0x80)>>8:(sp->
record(tbin).
ptSpy()&0x8000)>>15));
228 track.first.m_rank = 0;
229 track.first.setChargeValidPacked(0);
231 track.first.setFineHaloPacked(iter->halo());
233 track.first.m_winner = iter->MS_id()&(1<<trkNumber);
235 std::vector<CSCSP_MEblock> lcts = iter->LCTs();
236 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++){
237 int station = ( lct->spInput()>6 ? (lct->spInput()-1)/3 : 1 );
238 int subsector = ( lct->spInput()>6 ? 0 : (lct->spInput()-1)/3 + 1 );
240 CSCDetId id =
mapping->
detId(track.first.m_endcap,station,track.first.m_sector,subsector,lct->csc(),0);
241 track.second.insertDigi(
id,
243 0,lct->vp(),lct->quality(),lct->wireGroup(),
244 (
swapME1strips && lct->csc()<=3 && station==1 && track.first.m_endcap==2 && lct[0].strip()<65 ? 65 - lct[0].strip() : lct[0].strip() ),
245 lct->pattern(),lct->l_r(),
246 (lct->tbin()+(central_lct_bx-central_sp_bx)),
247 lct->link(), lct->BXN(), 0, lct->csc() )
250 edm::LogInfo(
"CSCTFUnpacker|produce") << e.
what() <<
"Not adding track digi to collection in event" 251 <<sp->
header().
L1A()<<
" (endcap="<<track.first.m_endcap<<
",station="<<station<<
",sector="<<track.first.m_sector<<
",subsector="<<subsector<<
",cscid="<<lct->csc()<<
",spSlot="<<sp->
header().
slot()<<
")";
255 std::vector<CSCSP_MBblock> mbStubs = iter->dtStub();
256 for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
258 track.second.insertDigi(
id,
259 CSCCorrelatedLCTDigi(iter->phi(),iter->vq(),iter->quality()+100,iter->cal(),iter->flag(),iter->bc0(),iter->phi_bend(),tbin+(central_lct_bx-central_sp_bx),iter->id(),iter->bxn(),iter->timingError(),iter->BXN())
263 trackProduct->push_back( track );
266 statusProduct->second.push_back( status );
269 edm::LogError(
"CSCTFUnpacker|produce")<<
" problem of unpacking TF event: 0x"<<std::hex<<unpacking_status<<
std::dec<<
" code";
272 statusProduct->first = unpacking_status;
T getParameter(std::string const &) const
unsigned int unpack(const unsigned short *buf, unsigned int length)
std::vector< CSCSP_MBblock > mbStubs(void) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
CSCTFUnpacker(const edm::ParameterSet &pset)
unsigned int SEs(void) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< CSCSP_MEblock > LCT(unsigned int mpc, unsigned int link) const
unsigned int AFs(void) const
char const * what() const override
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
unsigned int VPs(void) const
unsigned int ptSpy(void) const
size_t size() const
Lenght of the data buffer in bytes.
void addRecord(int rendcap, int rstation, int rsector, int rsubsector, int rcscid, int cendcap, int cstation, int csector, int csubsector, int ccscid)
void produce(edm::Event &e, const edm::EventSetup &c)
int orbit_counter(void) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< CSCSP_SPblock > tracks(void) const
const CSCSPRecord & record(unsigned int tbin) const
int track_counter(void) const
std::vector< int > slot2sector
unsigned int SMs(void) const
unsigned int BXs(void) const
base
Make Sure CMSSW is Setup ##.
const CSCSPCounters & counters(void) const
unsigned short fmm_status
CSCTriggerMapping * mapping
std::vector< const CSCSPEvent * > SPs_fast(void) const
const CSCSPHeader & header(void) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::pair< csc::L1Track, CSCCorrelatedLCTDigiCollection > L1CSCTrack
unsigned short link_status[15]
CSCDetId detId(int endcap, int station, int sector, int subsector, int cscid, int layer=0) const
unsigned short mpc_link_id