40 LogDebug(
"CSCTFUnpacker|ctor")<<
"Started ...";
51 LogDebug(
"CSCTFUnpacker|ctor")<<
"Verifying slot<->sector map from 'vint32 slot2sector'";
52 for(
int slot=0; slot<22; slot++)
53 if( slot2sector[slot]<0 || slot2sector[slot]>12 )
54 throw cms::Exception(
"Invalid configuration")<<
"CSCTFUnpacker: sector index is set out of range (slot2sector["<<slot<<
"]="<<slot2sector[slot]<<
", should be [0-12])";
56 slot2sector.resize(32);
60 if( mappingFile.length() ){
61 LogDebug(
"CSCTFUnpacker|ctor") <<
"Define ``mapping'' only if you want to screw up real geometry";
64 LogDebug(
"CSCTFUnpacker|ctor") <<
"Generating default hw<->geometry mapping";
69 for(
int sector=1; sector<=6; sector++)
70 for(
int csc=1; csc<=9; csc++){
81 produces<CSCCorrelatedLCTDigiCollection>();
82 produces<L1CSCTrackCollection>();
83 produces<L1CSCStatusDigiCollection>();
84 produces<CSCTriggerContainer<csctf::TrackStub> >(
"DT");
103 const FEDRawData& fedData = rawdata->FEDData(fedid);
104 if( fedData.
size()==0 )
continue;
108 if( unpacking_status==0 ){
112 for(std::vector<const CSCSPEvent *>::const_iterator spItr=SPs.begin(); spItr!=SPs.end(); spItr++){
130 for(
unsigned int tbin=0; tbin<sp->
header().
nTBINs(); tbin++){
138 for(
unsigned int FPGA=0; FPGA<5; FPGA++)
139 for(
unsigned int MPClink=0; MPClink<3; ++MPClink){
140 std::vector<CSCSP_MEblock> lct = sp->
record(tbin).
LCT(FPGA,MPClink);
141 if( lct.size()==0 )
continue;
144 (1<<lct[0].receiver_status_frame1())|
145 (1<<lct[0].receiver_status_frame2())|
146 ((lct[0].aligment_fifo()?1:0)<<4);
147 status.
mpc_link_id |= (lct[0].link()<<2)|lct[0].mpc();
149 int station = ( FPGA ? FPGA : 1 );
154 if( sector>6 ) sector -= 6;
159 int subsector = ( FPGA>1 ? 0 : FPGA+1 );
160 int cscid = lct[0].csc() ;
165 LCTProduct->insertDigi(
id,
167 0,lct[0].vp(),lct[0].quality(),lct[0].wireGroup(),
168 (
swapME1strips && cscid<=3 && station==1 && endcap==2 && lct[0].strip()<65 ? 65 - lct[0].strip() : lct[0].strip() ),
170 (lct[0].tbin()+(central_lct_bx-central_sp_bx)),
171 lct[0].
link(), lct[0].BXN(), 0, cscid )
174 edm::LogInfo(
"CSCTFUnpacker|produce") << e.
what() <<
"Not adding digi to collection in event "
175 <<sp->
header().
L1A()<<
" (endcap="<<endcap<<
",station="<<station<<
",sector="<<sector<<
",subsector="<<subsector<<
",cscid="<<cscid<<
",spSlot="<<sp->
header().
slot()<<
")";
180 std::vector<CSCSP_MBblock> mbStubs = sp->
record(tbin).
mbStubs();
181 for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
186 if( sector>6 ) sector -= 6;
191 const unsigned int csc2dt[6][2] = {{2,3},{4,5},{6,7},{8,9},{10,11},{12,1}};
192 DTChamberId id((endcap==1?2:-2),1, csc2dt[sector-1][iter->id()-1]);
193 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());
195 dtProduct->push_back(dtStub);
199 unsigned int trkNumber=0;
200 for(std::vector<CSCSP_SPblock>::const_iterator iter=tracks.begin(); iter!=tracks.end(); iter++,trkNumber++){
205 if( track.first.m_sector>6 ) track.first.m_sector -= 6;
211 track.first.m_lphi = iter->phi();
212 track.first.m_ptAddress = iter->ptLUTaddress();
213 track.first.m_fr = iter->f_r();
214 track.first.m_ptAddress|=(iter->f_r() << 21);
216 track.first.setStationIds(iter->ME1_id(),iter->ME2_id(),iter->ME3_id(),iter->ME4_id(),iter->MB_id());
217 track.first.setTbins(iter->ME1_tbin(), iter->ME2_tbin(), iter->ME3_tbin(), iter->ME4_tbin(), iter->MB_tbin() );
218 track.first.setBx(iter->tbin()-central_sp_bx);
219 track.first.setBits(iter->syncErr(), iter->bx0(), iter->bc0());
221 track.first.setLocalPhi(iter->phi());
222 track.first.setEtaPacked(iter->eta());
223 track.first.setChargePacked(iter->charge());
225 track.first.m_output_link = iter->id();
226 if( track.first.m_output_link ){
228 track.first.setChargeValidPacked((iter->f_r()?(sp->
record(tbin).
ptSpy()&0x80)>>8:(sp->
record(tbin).
ptSpy()&0x8000)>>15));
230 track.first.m_rank = 0;
231 track.first.setChargeValidPacked(0);
233 track.first.setFineHaloPacked(iter->halo());
235 track.first.m_winner = iter->MS_id()&(1<<trkNumber);
237 std::vector<CSCSP_MEblock> lcts = iter->LCTs();
238 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++){
239 int station = ( lct->spInput()>6 ? (lct->spInput()-1)/3 : 1 );
240 int subsector = ( lct->spInput()>6 ? 0 : (lct->spInput()-1)/3 + 1 );
242 CSCDetId id =
mapping->
detId(track.first.m_endcap,station,track.first.m_sector,subsector,lct->csc(),0);
243 track.second.insertDigi(
id,
245 0,lct->vp(),lct->quality(),lct->wireGroup(),
246 (
swapME1strips && lct->csc()<=3 && station==1 && track.first.m_endcap==2 && lct[0].strip()<65 ? 65 - lct[0].strip() : lct[0].strip() ),
247 lct->pattern(),lct->l_r(),
248 (lct->tbin()+(central_lct_bx-central_sp_bx)),
249 lct->link(), lct->BXN(), 0, lct->csc() )
252 edm::LogInfo(
"CSCTFUnpacker|produce") << e.
what() <<
"Not adding track digi to collection in event"
253 <<sp->
header().
L1A()<<
" (endcap="<<track.first.m_endcap<<
",station="<<station<<
",sector="<<track.first.m_sector<<
",subsector="<<subsector<<
",cscid="<<lct->csc()<<
",spSlot="<<sp->
header().
slot()<<
")";
257 std::vector<CSCSP_MBblock> mbStubs = iter->dtStub();
258 for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
260 track.second.insertDigi(
id,
261 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())
265 trackProduct->push_back( track );
268 statusProduct->second.push_back( status );
271 edm::LogError(
"CSCTFUnpacker|produce")<<
" problem of unpacking TF event: 0x"<<std::hex<<unpacking_status<<std::dec<<
" code";
274 statusProduct->first = unpacking_status;
277 e.
put(dtProduct,
"DT");
280 e.
put(statusProduct);
virtual char const * what() const
T getParameter(std::string const &) const
unsigned int unpack(const unsigned short *buf, unsigned int length)
std::vector< CSCSP_MBblock > mbStubs(void) const
CSCTFUnpacker(const edm::ParameterSet &pset)
unsigned int SEs(void) const
std::vector< CSCSP_MEblock > LCT(unsigned int mpc, unsigned int link) const
unsigned int AFs(void) const
unsigned int VPs(void) const
std::vector< L1CSCTrack > L1CSCTrackCollection
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)
std::string link(std::string &nm, std::string &ns)
void produce(edm::Event &e, const edm::EventSetup &c)
int orbit_counter(void) const
std::vector< CSCSP_SPblock > tracks(void) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
const CSCSPRecord & record(unsigned int tbin) const
int track_counter(void) const
std::vector< int > slot2sector
unsigned int SMs(void) const
std::pair< int, std::vector< L1CSCSPStatusDigi > > L1CSCStatusDigiCollection
unsigned int BXs(void) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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