CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCTFUnpacker Class Reference

#include <CSCTFUnpacker.h>

Inheritance diagram for CSCTFUnpacker:
edm::stream::EDProducer<>

Public Member Functions

 CSCTFUnpacker (const edm::ParameterSet &pset)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~CSCTFUnpacker (void) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

int m_maxBX
 
int m_minBX
 
CSCTriggerMappingmapping
 
edm::InputTag producer
 
edm::EDGetTokenT< FEDRawDataCollectionRaw_token
 
std::vector< int > slot2sector
 
bool swapME1strips
 
CSCTFEvent tfEvent
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 23 of file CSCTFUnpacker.h.

Constructor & Destructor Documentation

CSCTFUnpacker::CSCTFUnpacker ( const edm::ParameterSet pset)

Definition at line 34 of file CSCTFUnpacker.cc.

References CSCTriggerMapping::addRecord(), makeMuonMisalignmentScenario::endcap, Exception, lumiContext::fill, edm::ParameterSet::getParameter(), LogDebug, m_maxBX, m_minBX, mapping, producer, Raw_token, slot2sector, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, and swapME1strips.

35  LogDebug("CSCTFUnpacker|ctor")<<"Started ...";
36 
37  // Edges of the time window, which LCTs are put into (unlike tracks, which are always centred around 0):
38  m_minBX = pset.getParameter<int>("MinBX"); //3
39  m_maxBX = pset.getParameter<int>("MaxBX"); //9
40 
41  // Swap: if(swapME1strips && me1b && !zplus) strip = 65 - strip; // 1-64 -> 64-1 :
42  swapME1strips = pset.getParameter<bool>("swapME1strips");
43 
44  // Initialize slot<->sector assignment
45  slot2sector = pset.getParameter< std::vector<int> >("slot2sector");
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])";
50  // Just for safety (in case of bad data):
51  slot2sector.resize(32);
52 
53  // As we use standard CSC digi containers, we have to initialize mapping:
54  std::string mappingFile = pset.getParameter<std::string>("mappingFile");
55  if( mappingFile.length() ){
56  LogDebug("CSCTFUnpacker|ctor") << "Define ``mapping'' only if you want to screw up real geometry";
57  mapping = new CSCTriggerMappingFromFile(mappingFile);
58  } else {
59  LogDebug("CSCTFUnpacker|ctor") << "Generating default hw<->geometry mapping";
60  class M: public CSCTriggerSimpleMapping{ void fill(void) override{} };
61  mapping = new M();
62  for(int endcap=1; endcap<=2; endcap++)
63  for(int station=1; station<=4; station++)
64  for(int sector=1; sector<=6; sector++)
65  for(int csc=1; csc<=9; csc++){
66  if( station==1 ){
67  mapping->addRecord(endcap,station,sector,1,csc,endcap,station,sector,1,csc);
68  mapping->addRecord(endcap,station,sector,2,csc,endcap,station,sector,2,csc);
69  } else
70  mapping->addRecord(endcap,station,sector,0,csc,endcap,station,sector,0,csc);
71  }
72  }
73 
74  producer = pset.getParameter<edm::InputTag>("producer");
75 
76  produces<CSCCorrelatedLCTDigiCollection>();
77  produces<L1CSCTrackCollection>();
78  produces<L1CSCStatusDigiCollection>();
79  produces<CSCTriggerContainer<csctf::TrackStub> >("DT");
80 
81  Raw_token = consumes<FEDRawDataCollection>(producer);
82 
83 }
#define LogDebug(id)
T getParameter(std::string const &) const
edm::InputTag producer
Definition: CSCTFUnpacker.h:37
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
Definition: CSCTFUnpacker.h:39
void addRecord(int rendcap, int rstation, int rsector, int rsubsector, int rcscid, int cendcap, int cstation, int csector, int csubsector, int ccscid)
std::vector< int > slot2sector
Definition: CSCTFUnpacker.h:34
Definition: L1Track.h:19
CSCTriggerMapping * mapping
Definition: CSCTFUnpacker.h:28
CSCTFUnpacker::~CSCTFUnpacker ( void  )
override

Definition at line 85 of file CSCTFUnpacker.cc.

References mapping.

85  {
86  if( mapping ) delete mapping;
87 }
CSCTriggerMapping * mapping
Definition: CSCTFUnpacker.h:28

Member Function Documentation

void CSCTFUnpacker::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 89 of file CSCTFUnpacker.cc.

References L1CSCSPStatusDigi::af, CSCSPRecord::AFs(), runEdmFileComparison::base, L1CSCSPStatusDigi::bx, CSCSPHeader::BXN(), CSCSPRecord::BXs(), CSCSPEvent::counters(), FEDRawData::data(), TauDecayModes::dec, CSCTriggerMapping::detId(), CSCSPHeader::endcap(), makeMuonMisalignmentScenario::endcap, FEDRawDataCollection::FEDData(), L1CSCSPStatusDigi::fmm_status, edm::Event::getByToken(), CSCSPEvent::header(), triggerObjects_cff::id, createfilelist::int, CSCSPHeader::L1A(), L1CSCSPStatusDigi::l1a_bxn, CSCSPRecord::LCT(), L1CSCSPStatusDigi::link_status, m_maxBX, m_minBX, mapping, FEDNumbering::MAXCSCTFFEDID, CSCSPRecord::mbStubs(), FEDNumbering::MINCSCTFFEDID, eostools::move(), L1CSCSPStatusDigi::mpc_link_id, CSCSPHeader::nTBINs(), L1CSCSPStatusDigi::orbit_cnt, CSCSPCounters::orbit_counter(), listBenchmarks::pattern, CSCSPRecord::ptSpy(), edm::Event::put(), jets_cff::quality, Raw_token, matplotRender::rawdata, CSCSPEvent::record(), L1CSCSPStatusDigi::se, CSCSPHeader::sector(), CSCSPRecord::SEs(), FEDRawData::size(), CSCSPHeader::slot(), slot2sector, L1CSCSPStatusDigi::sm, CSCSPRecord::SMs(), L1CSCSPStatusDigi::sp_slot, CSCTFEvent::SPs_fast(), relativeConstraints::station, mps_update::status, CSCSPHeader::status(), digitizers_cfi::strip, swapME1strips, tfEvent, HiIsolationCommonParameters_cff::track, L1CSCSPStatusDigi::track_cnt, CSCSPCounters::track_counter(), l1t::tracks, CSCSPRecord::tracks(), CSCTFEvent::unpack(), L1CSCSPStatusDigi::vp, CSCSPRecord::VPs(), and cms::Exception::what().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

89  {
90  // Get a handle to the FED data collection
92  e.getByToken(Raw_token,rawdata);
93 
94  // create the collection of CSC wire and strip digis as well as of DT stubs, which we receive from DTTF
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>>();
99 
100  for(int fedid=FEDNumbering::MINCSCTFFEDID; fedid<=FEDNumbering::MAXCSCTFFEDID; fedid++){
101  const FEDRawData& fedData = rawdata->FEDData(fedid);
102  if( fedData.size()==0 ) continue;
103  //LogDebug("CSCTFUnpacker|produce");
104  //if( monitor ) monitor->process((unsigned short*)fedData.data());
105  unsigned int unpacking_status = tfEvent.unpack((unsigned short*)fedData.data(),fedData.size()/2);
106  if( unpacking_status==0 ){
107  // There may be several SPs in event
108  std::vector<const CSCSPEvent*> SPs = tfEvent.SPs_fast();
109  // Cycle over all of them
110  for(std::vector<const CSCSPEvent *>::const_iterator spItr=SPs.begin(); spItr!=SPs.end(); spItr++){
111  const CSCSPEvent *sp = *spItr;
112 
114  status.sp_slot = sp->header().slot();
115  status.l1a_bxn = sp->header().BXN();
116  status.fmm_status = sp->header().status();
117  status.track_cnt = sp->counters().track_counter();
118  status.orbit_cnt = sp->counters().orbit_counter();
119 
120  // Finds central LCT BX
121  // assumes window is odd number of bins
122  int central_lct_bx = (m_maxBX + m_minBX)/2;
123 
124  // Find central SP BX
125  // assumes window is odd number of bins
126  int central_sp_bx = int(sp->header().nTBINs()/2);
127 
128  for(unsigned int tbin=0; tbin<sp->header().nTBINs(); tbin++){
129 
130  status.se |= sp->record(tbin).SEs();
131  status.sm |= sp->record(tbin).SMs();
132  status.bx |= sp->record(tbin).BXs();
133  status.af |= sp->record(tbin).AFs();
134  status.vp |= sp->record(tbin).VPs();
135 
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.empty() ) continue;
140 
141  status.link_status[lct[0].spInput()] |=
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();
146 
147  int station = ( FPGA ? FPGA : 1 );
148  int endcap=0, sector=0;
149  if( slot2sector[sp->header().slot()] ){
150  endcap = slot2sector[sp->header().slot()]/7 + 1;
151  sector = slot2sector[sp->header().slot()];
152  if( sector>6 ) sector -= 6;
153  } else {
154  endcap = (sp->header().endcap()?1:2);
155  sector = sp->header().sector();
156  }
157  int subsector = ( FPGA>1 ? 0 : FPGA+1 );
158  int cscid = lct[0].csc() ;
159 
160  try{
161  CSCDetId id = mapping->detId(endcap,station,sector,subsector,cscid,0);
162  // corrlcts now have no layer associated with them
163  LCTProduct->insertDigi(id,
165  0,lct[0].vp(),lct[0].quality(),lct[0].wireGroup(),
166  (swapME1strips && cscid<=3 && station==1 && endcap==2 && lct[0].strip()<65 ? 65 - lct[0].strip() : lct[0].strip() ),
167  lct[0].pattern(),lct[0].l_r(),
168  (lct[0].tbin()+(central_lct_bx-central_sp_bx)),
169  lct[0].link(), lct[0].BXN(), 0, cscid )
170  );
171  } catch(cms::Exception &e) {
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()<<")";
174  }
175 
176  }
177 
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++){
180  int endcap, sector;
181  if( slot2sector[sp->header().slot()] ){
182  endcap = slot2sector[sp->header().slot()]/7 + 1;
183  sector = slot2sector[sp->header().slot()];
184  if( sector>6 ) sector -= 6;
185  } else {
186  endcap = (sp->header().endcap()?1:2);
187  sector = sp->header().sector();
188  }
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());
192  csctf::TrackStub dtStub(base,id,iter->phi(),0);
193  dtProduct->push_back(dtStub);
194  }
195 
196  std::vector<CSCSP_SPblock> tracks = sp->record(tbin).tracks();
197  unsigned int trkNumber=0;
198  for(std::vector<CSCSP_SPblock>::const_iterator iter=tracks.begin(); iter!=tracks.end(); iter++,trkNumber++){
200  if( slot2sector[sp->header().slot()] ){
201  track.first.m_endcap = slot2sector[sp->header().slot()]/7 + 1;
202  track.first.m_sector = slot2sector[sp->header().slot()];
203  if( track.first.m_sector>6 ) track.first.m_sector -= 6;
204  } else {
205  track.first.m_endcap = (sp->header().endcap()?1:2);
206  track.first.m_sector = sp->header().sector();
207  }
208 
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);
213 
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());
218 
219  track.first.setLocalPhi(iter->phi());
220  track.first.setEtaPacked(iter->eta());
221  track.first.setChargePacked(iter->charge());
222 
223  track.first.m_output_link = iter->id();
224  if( track.first.m_output_link ){
225  track.first.m_rank = (iter->f_r()?sp->record(tbin).ptSpy()&0x7F:(sp->record(tbin).ptSpy()&0x7F00)>>8);
226  track.first.setChargeValidPacked((iter->f_r()?(sp->record(tbin).ptSpy()&0x80)>>8:(sp->record(tbin).ptSpy()&0x8000)>>15));
227  } else {
228  track.first.m_rank = 0;
229  track.first.setChargeValidPacked(0);
230  }
231  track.first.setFineHaloPacked(iter->halo());
232 
233  track.first.m_winner = iter->MS_id()&(1<<trkNumber);
234 
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 );
239  try{
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() )
248  );
249  } catch(cms::Exception &e) {
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()<<")";
252  }
253  }
254 
255  std::vector<CSCSP_MBblock> mbStubs = iter->dtStub();
256  for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
257  CSCDetId id = mapping->detId(track.first.m_endcap,1,track.first.m_sector,iter->id(),1,0);
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())
260  );
261  }
262 
263  trackProduct->push_back( track );
264  }
265  }
266  statusProduct->second.push_back( status );
267  }
268  } else {
269  edm::LogError("CSCTFUnpacker|produce")<<" problem of unpacking TF event: 0x"<<std::hex<<unpacking_status<<std::dec<<" code";
270  }
271 
272  statusProduct->first = unpacking_status;
273 
274  } //end of fed cycle
275  e.put(std::move(dtProduct),"DT");
276  e.put(std::move(LCTProduct)); // put processed lcts into the event.
277  e.put(std::move(trackProduct));
278  e.put(std::move(statusProduct));
279 }
unsigned int L1A(void) const
Definition: CSCSPHeader.h:75
unsigned int unpack(const unsigned short *buf, unsigned int length)
Definition: CSCTFEvent.cc:6
std::vector< CSCSP_MBblock > mbStubs(void) const
Definition: CSCSPRecord.cc:100
unsigned int SEs(void) const
Definition: CSCSPRecord.h:84
unsigned short l1a_bxn
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
unsigned long orbit_cnt
std::vector< CSCSP_MEblock > LCT(unsigned int mpc, unsigned int link) const
Definition: CSCSPRecord.cc:85
unsigned int AFs(void) const
Definition: CSCSPRecord.h:86
char const * what() const override
Definition: Exception.cc:103
unsigned long track_cnt
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
Definition: CSCTFUnpacker.h:39
unsigned int VPs(void) const
Definition: CSCSPRecord.h:83
unsigned int ptSpy(void) const
Definition: CSCSPRecord.h:89
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
unsigned int nTBINs(void) const
Definition: CSCSPHeader.h:92
int orbit_counter(void) const
Definition: CSCSPCounters.h:32
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< CSCSP_SPblock > tracks(void) const
Definition: CSCSPRecord.cc:92
const CSCSPRecord & record(unsigned int tbin) const
Definition: CSCSPEvent.h:21
int track_counter(void) const
Definition: CSCSPCounters.h:31
std::vector< int > slot2sector
Definition: CSCTFUnpacker.h:34
unsigned int SMs(void) const
Definition: CSCSPRecord.h:85
unsigned int sector(void) const
Definition: CSCSPHeader.h:80
unsigned short sm
unsigned int BXs(void) const
Definition: CSCSPRecord.h:87
base
Make Sure CMSSW is Setup ##.
unsigned short sp_slot
const CSCSPCounters & counters(void) const
Definition: CSCSPEvent.h:18
unsigned short fmm_status
unsigned int BXN(void) const
Definition: CSCSPHeader.h:74
unsigned int endcap(void) const
Definition: CSCSPHeader.h:84
CSCTriggerMapping * mapping
Definition: CSCTFUnpacker.h:28
unsigned short se
std::vector< const CSCSPEvent * > SPs_fast(void) const
Definition: CSCTFEvent.h:24
const CSCSPHeader & header(void) const
Definition: CSCSPEvent.h:17
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
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
CSCTFEvent tfEvent
Definition: CSCTFUnpacker.h:30
unsigned short mpc_link_id
def move(src, dest)
Definition: eostools.py:511
unsigned int slot(void) const
Definition: CSCSPHeader.h:77
unsigned int status(void) const
Definition: CSCSPHeader.h:90

Member Data Documentation

int CSCTFUnpacker::m_maxBX
private

Definition at line 25 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

int CSCTFUnpacker::m_minBX
private

Definition at line 25 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

CSCTriggerMapping* CSCTFUnpacker::mapping
private

Definition at line 28 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), produce(), and ~CSCTFUnpacker().

edm::InputTag CSCTFUnpacker::producer
private

Definition at line 37 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker().

edm::EDGetTokenT<FEDRawDataCollection> CSCTFUnpacker::Raw_token
private

Definition at line 39 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

std::vector<int> CSCTFUnpacker::slot2sector
private

Definition at line 34 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

bool CSCTFUnpacker::swapME1strips
private

Definition at line 26 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

CSCTFEvent CSCTFUnpacker::tfEvent
private

Definition at line 30 of file CSCTFUnpacker.h.

Referenced by produce().