CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CSCTFUnpacker Class Reference

#include <CSCTFUnpacker.h>

Inheritance diagram for CSCTFUnpacker:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 CSCTFUnpacker (const edm::ParameterSet &pset)
 
void produce (edm::Event &e, const edm::EventSetup &c)
 
 ~CSCTFUnpacker (void)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 16 of file CSCTFUnpacker.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file CSCTFUnpacker.cc.

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

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

Definition at line 87 of file CSCTFUnpacker.cc.

References mapping.

87  {
88  if( mapping ) delete mapping;
89 }
CSCTriggerMapping * mapping
Definition: CSCTFUnpacker.h:21

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 91 of file CSCTFUnpacker.cc.

References L1CSCSPStatusDigi::af, CSCSPRecord::AFs(), newFWLiteAna::base, L1CSCSPStatusDigi::bx, CSCSPHeader::BXN(), CSCSPRecord::BXs(), CSCSPEvent::counters(), FEDRawData::data(), CSCTriggerMapping::detId(), Reference_intrackfit_cff::endcap, CSCSPHeader::endcap(), L1CSCSPStatusDigi::fmm_status, edm::Event::getByLabel(), CSCSPEvent::header(), errorMatrix2Lands_multiChannel::id, edm::InputTag::instance(), CSCSPHeader::L1A(), L1CSCSPStatusDigi::l1a_bxn, edm::InputTag::label(), CSCSPRecord::LCT(), link(), L1CSCSPStatusDigi::link_status, m_maxBX, m_minBX, mapping, FEDNumbering::MAXCSCTFFEDID, CSCSPRecord::mbStubs(), FEDNumbering::MINCSCTFFEDID, L1CSCSPStatusDigi::mpc_link_id, CSCSPHeader::nTBINs(), L1CSCSPStatusDigi::orbit_cnt, CSCSPCounters::orbit_counter(), listBenchmarks::pattern, producer, CSCSPRecord::ptSpy(), edm::Event::put(), lumiPlot::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, CSCSPHeader::status(), ntuplemaker::status, strip(), swapME1strips, tfEvent, L1CSCSPStatusDigi::track_cnt, CSCSPCounters::track_counter(), testEve_cfg::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().

91  {
92  // Get a handle to the FED data collection
95 
96  // create the collection of CSC wire and strip digis as well as of DT stubs, which we receive from DTTF
97  std::auto_ptr<CSCCorrelatedLCTDigiCollection> LCTProduct(new CSCCorrelatedLCTDigiCollection);
98  std::auto_ptr<L1CSCTrackCollection> trackProduct(new L1CSCTrackCollection);
99  std::auto_ptr<L1CSCStatusDigiCollection> statusProduct(new L1CSCStatusDigiCollection);
100  std::auto_ptr<CSCTriggerContainer<csctf::TrackStub> > dtProduct(new CSCTriggerContainer<csctf::TrackStub>);
101 
102  for(int fedid=FEDNumbering::MINCSCTFFEDID; fedid<=FEDNumbering::MAXCSCTFFEDID; fedid++){
103  const FEDRawData& fedData = rawdata->FEDData(fedid);
104  if( fedData.size()==0 ) continue;
105  //LogDebug("CSCTFUnpacker|produce");
106  //if( monitor ) monitor->process((unsigned short*)fedData.data());
107  unsigned int unpacking_status = tfEvent.unpack((unsigned short*)fedData.data(),fedData.size()/2);
108  if( unpacking_status==0 ){
109  // There may be several SPs in event
110  std::vector<const CSCSPEvent*> SPs = tfEvent.SPs_fast();
111  // Cycle over all of them
112  for(std::vector<const CSCSPEvent *>::const_iterator spItr=SPs.begin(); spItr!=SPs.end(); spItr++){
113  const CSCSPEvent *sp = *spItr;
114 
116  status.sp_slot = sp->header().slot();
117  status.l1a_bxn = sp->header().BXN();
118  status.fmm_status = sp->header().status();
119  status.track_cnt = sp->counters().track_counter();
120  status.orbit_cnt = sp->counters().orbit_counter();
121 
122  // Finds central LCT BX
123  // assumes window is odd number of bins
124  int central_lct_bx = (m_maxBX + m_minBX)/2;
125 
126  // Find central SP BX
127  // assumes window is odd number of bins
128  int central_sp_bx = int(sp->header().nTBINs()/2);
129 
130  for(unsigned int tbin=0; tbin<sp->header().nTBINs(); tbin++){
131 
132  status.se |= sp->record(tbin).SEs();
133  status.sm |= sp->record(tbin).SMs();
134  status.bx |= sp->record(tbin).BXs();
135  status.af |= sp->record(tbin).AFs();
136  status.vp |= sp->record(tbin).VPs();
137 
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;
142 
143  status.link_status[lct[0].spInput()] |=
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();
148 
149  int station = ( FPGA ? FPGA : 1 );
150  int endcap=0, sector=0;
151  if( slot2sector[sp->header().slot()] ){
152  endcap = slot2sector[sp->header().slot()]/7 + 1;
153  sector = slot2sector[sp->header().slot()];
154  if( sector>6 ) sector -= 6;
155  } else {
156  endcap = (sp->header().endcap()?1:2);
157  sector = sp->header().sector();
158  }
159  int subsector = ( FPGA>1 ? 0 : FPGA+1 );
160  int cscid = lct[0].csc() ;
161 
162  try{
163  CSCDetId id = mapping->detId(endcap,station,sector,subsector,cscid,0);
164  // corrlcts now have no layer associated with them
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() ),
169  lct[0].pattern(),lct[0].l_r(),
170  (lct[0].tbin()+(central_lct_bx-central_sp_bx)),
171  lct[0].link(), lct[0].BXN(), 0, cscid )
172  );
173  } catch(cms::Exception &e) {
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()<<")";
176  }
177 
178  }
179 
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++){
182  int endcap, sector;
183  if( slot2sector[sp->header().slot()] ){
184  endcap = slot2sector[sp->header().slot()]/7 + 1;
185  sector = slot2sector[sp->header().slot()];
186  if( sector>6 ) sector -= 6;
187  } else {
188  endcap = (sp->header().endcap()?1:2);
189  sector = sp->header().sector();
190  }
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());
194  csctf::TrackStub dtStub(base,id,iter->phi(),0);
195  dtProduct->push_back(dtStub);
196  }
197 
198  std::vector<CSCSP_SPblock> tracks = sp->record(tbin).tracks();
199  unsigned int trkNumber=0;
200  for(std::vector<CSCSP_SPblock>::const_iterator iter=tracks.begin(); iter!=tracks.end(); iter++,trkNumber++){
201  L1CSCTrack track;
202  if( slot2sector[sp->header().slot()] ){
203  track.first.m_endcap = slot2sector[sp->header().slot()]/7 + 1;
204  track.first.m_sector = slot2sector[sp->header().slot()];
205  if( track.first.m_sector>6 ) track.first.m_sector -= 6;
206  } else {
207  track.first.m_endcap = (sp->header().endcap()?1:2);
208  track.first.m_sector = sp->header().sector();
209  }
210 
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);
215 
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());
220 
221  track.first.setLocalPhi(iter->phi());
222  track.first.setEtaPacked(iter->eta());
223  track.first.setChargePacked(iter->charge());
224 
225  track.first.m_output_link = iter->id();
226  if( track.first.m_output_link ){
227  track.first.m_rank = (iter->f_r()?sp->record(tbin).ptSpy()&0x7F:(sp->record(tbin).ptSpy()&0x7F00)>>8);
228  track.first.setChargeValidPacked((iter->f_r()?(sp->record(tbin).ptSpy()&0x80)>>8:(sp->record(tbin).ptSpy()&0x8000)>>15));
229  } else {
230  track.first.m_rank = 0;
231  track.first.setChargeValidPacked(0);
232  }
233  track.first.setFineHaloPacked(iter->halo());
234 
235  track.first.m_winner = iter->MS_id()&(1<<trkNumber);
236 
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 );
241  try{
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() )
250  );
251  } catch(cms::Exception &e) {
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()<<")";
254  }
255  }
256 
257  std::vector<CSCSP_MBblock> mbStubs = iter->dtStub();
258  for(std::vector<CSCSP_MBblock>::const_iterator iter=mbStubs.begin(); iter!=mbStubs.end(); iter++){
259  CSCDetId id = mapping->detId(track.first.m_endcap,1,track.first.m_sector,iter->id(),1,0);
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())
262  );
263  }
264 
265  trackProduct->push_back( track );
266  }
267  }
268  statusProduct->second.push_back( status );
269  }
270  } else {
271  edm::LogError("CSCTFUnpacker|produce")<<" problem of unpacking TF event: 0x"<<std::hex<<unpacking_status<<std::dec<<" code";
272  }
273 
274  statusProduct->first = unpacking_status;
275 
276  } //end of fed cycle
277  e.put(dtProduct,"DT");
278  e.put(LCTProduct); // put processed lcts into the event.
279  e.put(trackProduct);
280  e.put(statusProduct);
281 }
virtual char const * what() const
Definition: Exception.cc:141
unsigned int L1A(void) const
Definition: CSCSPHeader.h:75
tuple base
Main Program
Definition: newFWLiteAna.py:92
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
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
unsigned short l1a_bxn
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
edm::InputTag producer
Definition: CSCTFUnpacker.h:30
unsigned long track_cnt
unsigned int VPs(void) const
Definition: CSCSPRecord.h:83
std::vector< L1CSCTrack > L1CSCTrackCollection
unsigned int ptSpy(void) const
Definition: CSCSPRecord.h:89
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:47
unsigned int nTBINs(void) const
Definition: CSCSPHeader.h:92
int orbit_counter(void) const
Definition: CSCSPCounters.h:30
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:29
std::vector< int > slot2sector
Definition: CSCTFUnpacker.h:27
unsigned int SMs(void) const
Definition: CSCSPRecord.h:85
std::pair< int, std::vector< L1CSCSPStatusDigi > > L1CSCStatusDigiCollection
unsigned int sector(void) const
Definition: CSCSPHeader.h:80
unsigned short sm
unsigned int BXs(void) const
Definition: CSCSPRecord.h:87
unsigned short sp_slot
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const CSCSPCounters & counters(void) const
Definition: CSCSPEvent.h:18
unsigned short fmm_status
unsigned int BXN(void) const
Definition: CSCSPHeader.h:74
tuple tracks
Definition: testEve_cfg.py:39
unsigned int endcap(void) const
Definition: CSCSPHeader.h:84
CSCTriggerMapping * mapping
Definition: CSCTFUnpacker.h:21
std::string const & label() const
Definition: InputTag.h:25
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:29
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
dictionary rawdata
Definition: lumiPlot.py:393
tuple status
Definition: ntuplemaker.py:245
CSCTFEvent tfEvent
Definition: CSCTFUnpacker.h:23
std::string const & instance() const
Definition: InputTag.h:26
unsigned short mpc_link_id
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 18 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

int CSCTFUnpacker::m_minBX
private

Definition at line 18 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

CSCTriggerMapping* CSCTFUnpacker::mapping
private

Definition at line 21 of file CSCTFUnpacker.h.

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

edm::InputTag CSCTFUnpacker::producer
private

Definition at line 30 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

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

Definition at line 27 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

bool CSCTFUnpacker::swapME1strips
private

Definition at line 19 of file CSCTFUnpacker.h.

Referenced by CSCTFUnpacker(), and produce().

CSCTFEvent CSCTFUnpacker::tfEvent
private

Definition at line 23 of file CSCTFUnpacker.h.

Referenced by produce().