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
CSCTFPacker Class Reference

#include <CSCTFPacker.h>

Inheritance diagram for CSCTFPacker:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CSCTFPacker (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
 ~CSCTFPacker (void)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

unsigned short activeSectors
 
int central_lct_bx
 
int central_sp_bx
 
FILE * file
 
edm::InputTag lctProducer
 
int m_maxBX
 
int m_minBX
 
edm::InputTag mbProducer
 
unsigned short nTBINs
 
bool putBufferToEvent
 
bool swapME1strips
 
edm::InputTag trackProducer
 
bool zeroSuppression
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 12 of file CSCTFPacker.h.

Constructor & Destructor Documentation

CSCTFPacker::CSCTFPacker ( const edm::ParameterSet conf)
explicit

Definition at line 27 of file CSCTFPacker.cc.

References activeSectors, central_lct_bx, central_sp_bx, file, edm::ParameterSet::getParameter(), lctProducer, m_maxBX, m_minBX, mbProducer, nTBINs, NULL, download_sqlite_cfg::outputFile, putBufferToEvent, AlCaHLTBitMon_QueryRunRegistry::string, swapME1strips, trackProducer, and zeroSuppression.

27  :edm::EDProducer(){
28  // "Readout" configuration
29  zeroSuppression = conf.getParameter<bool>("zeroSuppression");
30  nTBINs = conf.getParameter<int> ("nTBINs");
31  activeSectors = conf.getParameter<int> ("activeSectors");
32 
33  // Configuration that controls CMSSW specific stuff
34  putBufferToEvent = conf.getParameter<bool>("putBufferToEvent");
35  std::string outputFile = conf.getParameter<std::string>("outputFile");
36  lctProducer = conf.getParameter<edm::InputTag>("lctProducer");
37  mbProducer = conf.getParameter<edm::InputTag>("mbProducer");
38  trackProducer = conf.getParameter<edm::InputTag>("trackProducer");
39 
40  // Swap: if(swapME1strips && me1b && !zplus) strip = 65 - strip; // 1-64 -> 64-1 :
41  swapME1strips = conf.getParameter<bool>("swapME1strips");
42 
43  file = 0;
44  if( outputFile.length() && (file = fopen(outputFile.c_str(),"wt"))==NULL )
45  throw cms::Exception("OutputFile ")<<"CSCTFPacker: cannot open output file (errno="<<errno<<"). Try outputFile=\"\"";
46 
47  // BX window bounds in CMSSW:
48  m_minBX = conf.getParameter<int>("MinBX"); //3
49  m_maxBX = conf.getParameter<int>("MaxBX"); //9
50 
51  // Finds central LCT BX
52  // assumes window is odd number of bins
53  central_lct_bx = (m_maxBX + m_minBX)/2;
54  // Find central SP BX
55  // assumes window is odd number of bins
56  central_sp_bx = int(nTBINs/2);
57 
58  produces<FEDRawDataCollection>("CSCTFRawData");
59 }
T getParameter(std::string const &) const
#define NULL
Definition: scimark2.h:8
edm::InputTag trackProducer
Definition: CSCTFPacker.h:14
bool putBufferToEvent
Definition: CSCTFPacker.h:19
unsigned short activeSectors
Definition: CSCTFPacker.h:18
bool zeroSuppression
Definition: CSCTFPacker.h:16
edm::InputTag lctProducer
Definition: CSCTFPacker.h:14
bool swapME1strips
Definition: CSCTFPacker.h:21
edm::InputTag mbProducer
Definition: CSCTFPacker.h:14
int central_sp_bx
Definition: CSCTFPacker.h:25
int central_lct_bx
Definition: CSCTFPacker.h:25
FILE * file
Definition: CSCTFPacker.h:23
unsigned short nTBINs
Definition: CSCTFPacker.h:17
CSCTFPacker::~CSCTFPacker ( void  )

Definition at line 61 of file CSCTFPacker.cc.

References file.

61  {
62  if( file ) fclose(file);
63 }
FILE * file
Definition: CSCTFPacker.h:23

Member Function Documentation

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

std::cout<<"Front data station: "<<station<<" sector: "<<sector<<" subSector: "<<subSector<<" tbin: "<<tbin<<" cscId: "<<cscId<<" fpga: "<<fpga<<" LCT_qual="<<lct->getQuality()<<" LCT_strip="<<lct->getStrip()<<" LCT_wire="<<lct->getKeyWG()<<std::endl;

Implements edm::EDProducer.

Definition at line 65 of file CSCTFPacker.cc.

References activeSectors, CSCSPRecord::af_bits, CSCSP_MEblock::aligment_fifo_empty, CSCSP_MEblock::aligment_fifo_full, CSCSP_MEblock::bc0_, CSCSP_MBblock::bc0_, CSCSP_SPblock::bc0_, CSCSP_MEblock::bx0_, CSCSPRecord::bx_bits, CSCSP_MBblock::bxn0_, CSCSP_SPblock::bxn0_, CSCSP_MBblock::bxn1_, CSCSP_MBblock::cal_, central_lct_bx, central_sp_bx, CSCSP_SPblock::charge_, CSCSP_MEblock::clct_pattern_id, CSCSP_MEblock::clct_pattern_number, evf::compute_crc(), filterCSVwithJSON::copy, CSCSP_MEblock::csc_id, CSCSPHeader::csr_dfc, FEDRawData::data(), data, CSCSP_SPblock::deltaPhi12_, CSCSP_SPblock::deltaPhi23_, dt, CSCSP_MEblock::err_prop_cnt, CSCSP_SPblock::eta_, edm::EventID::event(), file, CSCSP_MBblock::flag_, CSCSP_SPblock::front_rear, edm::Event::getByLabel(), CSCSP_SPblock::halo_, CSCSPHeader::header_mark_1, CSCSPHeader::header_mark_2, CSCSPHeader::header_mark_3, CSCSPHeader::header_mark_4, CSCSPHeader::header_mark_5, CSCSPHeader::header_mark_6, CSCSPHeader::header_mark_7, CSCSPHeader::header_mark_8, edm::EventBase::id(), CSCSP_MBblock::id_, CSCSP_SPblock::id_, edm::InputTag::instance(), edm::HandleBase::isValid(), edm::InputTag::label(), lctProducer, CSCSP_MEblock::left_right, link(), CSCSP_MEblock::link_id, CSCSP_MBblock::mb_bxn_, CSCSP_SPblock::mb_id, CSCSP_SPblock::mb_tbin, mbProducer, CSCSP_SPblock::me1_id, CSCSP_SPblock::me1_tbin, CSCSP_SPblock::me2_id, CSCSP_SPblock::me2_tbin, CSCSP_SPblock::me3_id, CSCSP_SPblock::me3_tbin, CSCSP_SPblock::me4_id, CSCSP_SPblock::me4_tbin, CSCSP_MEblock::me_bxn, FEDNumbering::MINCSCTFFEDID, CSCSPRecord::mode1, CSCSPRecord::mode2, CSCSPRecord::mode3, CSCSP_MEblock::mpc_id, CSCSP_SPblock::ms_id, nTBINs, CSCSP_SPblock::phi_, CSCSP_MBblock::phi_, CSCSP_MBblock::phi_bend_, edm::Handle< T >::product(), edm::Event::put(), putBufferToEvent, CSCSP_MBblock::quality_, CSCSP_MEblock::quality_, CSCSP_MEblock::receiver_status_dv1, CSCSP_MEblock::receiver_status_dv2, CSCSP_MEblock::receiver_status_er1, CSCSP_MEblock::receiver_status_er2, FEDRawData::resize(), CSCSP_SPblock::se, CSCSPRecord::se_bits, FEDTrailer::set(), FEDHeader::set(), CSCSP_SPblock::sign_, FEDRawData::size(), CSCSPHeader::skip, CSCSPRecord::sm_bits, CSCSPHeader::sp_ersv, CSCSPHeader::sp_trigger_sector, CSCSPRecord::spare_1, relativeConstraints::station, swapME1strips, trackProducer, testEve_cfg::tracks, CSCSPTrailer::trailer_mark_1, CSCSPTrailer::trailer_mark_10, CSCSPTrailer::trailer_mark_2, CSCSPTrailer::trailer_mark_3, CSCSPTrailer::trailer_mark_4, CSCSPTrailer::trailer_mark_5, CSCSPTrailer::trailer_mark_6, CSCSPTrailer::trailer_mark_7, CSCSPTrailer::trailer_mark_8, CSCSPTrailer::trailer_mark_9, CSCTriggerNumbering::triggerSubSectorFromLabels(), CSCSP_MEblock::valid_pattern, CSCSPRecord::vp_bits, CSCSPRecord::vq_a, CSCSPRecord::vq_b, CSCSP_MEblock::wire_group_id, and zeroSuppression.

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

65  {
68 
69  CSCSP_MEblock meDataRecord[12][7][5][9][2]; // LCT in sector X, tbin Y, station Z, csc W, and lct I
70  bzero(&meDataRecord,sizeof(meDataRecord));
71  CSCSPRecord meDataHeader[12][7]; // Data Block Header for sector X and tbin Y
72  bzero(&meDataHeader,sizeof(meDataHeader));
73 
74  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++){
75  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
76  int lctId=0;
77  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++,lctId++){
78  int station = (*csc).first.station()-1;
79  int cscId = (*csc).first.triggerCscId()-1;
80  int sector = (*csc).first.triggerSector()-1 + ( (*csc).first.endcap()==1 ? 0 : 6 );
81  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
82  int tbin = lct->getBX() - (central_lct_bx-central_sp_bx); // Shift back to hardware BX window definition
83  if( tbin>6 || tbin<0 ){
84  edm::LogError("CSCTFPacker|produce")<<" LCT's BX="<<tbin<<" is out of 0-6 window";
85  continue;
86  }
87  int fpga = ( subSector ? subSector-1 : station+1 );
89 
90  // If Det Id is within range
91  if( sector<0 || sector>11 || station<0 || station>3 || cscId<0 || cscId>8 || lctId<0 || lctId>1){
92  edm::LogInfo("CSCTFPacker: CSC digi are out of range: ")<<"sector="<<sector<<", station="<<station<<", cscId="<<cscId<<", lctId="<<lctId;
93  continue;
94  }
95 
96  meDataRecord[sector][tbin][fpga][cscId][lctId].clct_pattern_number = lct->getPattern();
97  meDataRecord[sector][tbin][fpga][cscId][lctId].quality_ = lct->getQuality();
98  meDataRecord[sector][tbin][fpga][cscId][lctId].wire_group_id = lct->getKeyWG();
99 
100  meDataRecord[sector][tbin][fpga][cscId][lctId].clct_pattern_id = (swapME1strips && cscId<3 && station==0 && (*csc).first.endcap()==2 && lct->getStrip()<65 ? 65 - lct->getStrip() : lct->getStrip() );
101  meDataRecord[sector][tbin][fpga][cscId][lctId].csc_id = (*csc).first.triggerCscId();
102  meDataRecord[sector][tbin][fpga][cscId][lctId].left_right = lct->getBend();
103  meDataRecord[sector][tbin][fpga][cscId][lctId].bx0_ = 0; //?;
104  meDataRecord[sector][tbin][fpga][cscId][lctId].bc0_ = 0; //?;
105 
106  meDataRecord[sector][tbin][fpga][cscId][lctId].me_bxn = 0; //?
107  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_er1 = 0; // dummy
108  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_dv1 = 0; // dummy
109  meDataRecord[sector][tbin][fpga][cscId][lctId].aligment_fifo_full = 0; // dummy
110 
111  meDataRecord[sector][tbin][fpga][cscId][lctId].link_id = lct->getMPCLink();
112  meDataRecord[sector][tbin][fpga][cscId][lctId].mpc_id = 0; // Join with above?
113  meDataRecord[sector][tbin][fpga][cscId][lctId].err_prop_cnt = 0; // dummy
114  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_er2 = 0; // dummy
115  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_dv2 = 0; // dummy
116  meDataRecord[sector][tbin][fpga][cscId][lctId].aligment_fifo_empty = 0; // dummy
117 
118  if( lct->isValid() ){
119  switch( (meDataHeader[sector][tbin].vp_bits>>(fpga*3)) & 0x7 ){
120  case 0x0: meDataHeader[sector][tbin].vp_bits |= (0x1 << (fpga*3)); break;
121  case 0x1: meDataHeader[sector][tbin].vp_bits |= (0x3 << (fpga*3)); break;
122  case 0x3: meDataHeader[sector][tbin].vp_bits |= (0x7 << (fpga*3)); break;
123  default :
124  edm::LogInfo("CSCTFPacker: more than 3 LCTs from a single MPC in one BX!!!");
125  continue;
126  break;
127  }
128  meDataRecord[sector][tbin][fpga][cscId][lctId].valid_pattern = 1; // for later use
129  }
130  meDataHeader[sector][tbin].vq_a = 0; // no digi yet?
131  meDataHeader[sector][tbin].vq_b = 0; // no digi yet?
132  meDataHeader[sector][tbin].se_bits = 0; // dummy
133  meDataHeader[sector][tbin].sm_bits = 0; // dummy
134  meDataHeader[sector][tbin].af_bits = 0; // dummy
135  meDataHeader[sector][tbin].bx_bits = 0;//(lct->getBX()&??<< (fpga*3));
136 
137  meDataHeader[sector][tbin].spare_1 = 0; // for later use
138  }
139  }
140 
141  CSCSP_MBblock mbDataRecord[12][2][7]; // LCT in sector X, subsector Z, tbin Y
142  bzero(&mbDataRecord,sizeof(mbDataRecord));
144  if( mbProducer.label() != "null" ){
145  e.getByLabel(mbProducer.label(),mbProducer.instance(),barrelStubs);
146  if( barrelStubs.isValid() ){
147  std::vector<csctf::TrackStub> stubs = barrelStubs.product()->get();
148  for(std::vector<csctf::TrackStub>::const_iterator dt=stubs.begin(); dt!=stubs.end(); dt++){
149  int sector = dt->sector()-1 + ( dt->endcap()==1 ? 0 : 6 );
150  int subSector = dt->subsector()-1;
151  int tbin = dt->getBX() - (central_lct_bx-central_sp_bx); // Shift back to hardware BX window definition
152  if( tbin<0 || tbin>6 || sector<0 || sector>11 || subSector<0 || subSector>11 ){
153  edm::LogInfo("CSCTFPacker: CSC DT digi are out of range: ")<<" sector="<<sector<<" subSector="<<subSector<<" tbin="<<tbin;
154  continue;
155  }
156  mbDataRecord[sector][subSector][tbin].quality_ = dt->getQuality();
157  mbDataRecord[sector][subSector][tbin].phi_bend_ = dt->getBend();
158  mbDataRecord[sector][subSector][tbin].flag_ = dt->getStrip();
159  mbDataRecord[sector][subSector][tbin].cal_ = dt->getKeyWG();
160  mbDataRecord[sector][subSector][tbin].phi_ = dt->phiPacked();
161  mbDataRecord[sector][subSector][tbin].bxn1_ =(dt->getBX0()>>1)&0x1;
162  mbDataRecord[sector][subSector][tbin].bxn0_ = dt->getBX0()&0x1;
163  mbDataRecord[sector][subSector][tbin].bc0_ = dt->getPattern();
164  mbDataRecord[sector][subSector][tbin].mb_bxn_ = dt->getCSCID();
165  switch(subSector){
166  case 0: meDataHeader[sector][tbin].vq_a = 1; break;
167  case 1: meDataHeader[sector][tbin].vq_b = 1; break;
168  default: edm::LogInfo("CSCTFPacker: subSector=")<<subSector; break;
169  }
170  mbDataRecord[sector][subSector][tbin].id_ = dt->getMPCLink(); // for later use
171  }
172  }
173  }
174 
175  CSCSP_SPblock spDataRecord[12][7][3]; // Up to 3 tracks in sector X and tbin Y
176  bzero(&spDataRecord,sizeof(spDataRecord));
177  int nTrk[12][7];
178  bzero(&nTrk,sizeof(nTrk));
179 
181  if( trackProducer.label() != "null" ){
183 
184  for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk!=tracks->end(); trk++){
185  int sector = 6*(trk->first.endcap()-1)+trk->first.sector()-1;
186  int tbin = trk->first.BX() + central_sp_bx; // Shift back to hardware BX window definition
187 //std::cout<<"Track["<<nTrk[sector][tbin]<<"] sector: "<<sector<<" tbin: "<<tbin<<std::endl;
188  if( tbin>6 || tbin<0 ){
189  edm::LogError("CSCTFPacker|analyze")<<" Track's BX="<<tbin<<" is out of 0-6 window";
190  continue;
191  }
192  if( sector<0 || sector>11 ){
193  edm::LogError("CSCTFPacker|analyze")<<" Track's sector="<<sector<<" is out of range";
194  continue;
195  }
196  spDataRecord[sector][tbin][nTrk[sector][tbin]].phi_ = trk->first.localPhi();
197  spDataRecord[sector][tbin][nTrk[sector][tbin]].sign_ =(trk->first.ptLUTAddress()>>20)&0x1;
198  spDataRecord[sector][tbin][nTrk[sector][tbin]].front_rear = trk->first.front_rear();
199  spDataRecord[sector][tbin][nTrk[sector][tbin]].charge_ = trk->first.charge_packed(); //
200  spDataRecord[sector][tbin][nTrk[sector][tbin]].eta_ = trk->first.eta_packed();
201 
202  spDataRecord[sector][tbin][nTrk[sector][tbin]].halo_ = trk->first.finehalo_packed();
203  spDataRecord[sector][tbin][nTrk[sector][tbin]].se = 0; // dummy
204  spDataRecord[sector][tbin][nTrk[sector][tbin]].deltaPhi12_= trk->first.ptLUTAddress()&0xFF;
205  spDataRecord[sector][tbin][nTrk[sector][tbin]].deltaPhi23_=(trk->first.ptLUTAddress()>>8)&0xF;
206  spDataRecord[sector][tbin][nTrk[sector][tbin]].bxn0_ = 0; //dummy
207  spDataRecord[sector][tbin][nTrk[sector][tbin]].bc0_ = 0; //dummy
208 
209  spDataRecord[sector][tbin][nTrk[sector][tbin]].me1_id = trk->first.me1ID();
210  spDataRecord[sector][tbin][nTrk[sector][tbin]].me2_id = trk->first.me2ID();
211  spDataRecord[sector][tbin][nTrk[sector][tbin]].me3_id = trk->first.me3ID();
212  spDataRecord[sector][tbin][nTrk[sector][tbin]].me4_id = trk->first.me4ID();
213  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_id = trk->first.mb1ID();
214  spDataRecord[sector][tbin][nTrk[sector][tbin]].ms_id = 0; // don't care winner()
215 
216  // Warning, digi copying was broken for <= CMSSW_3_8_x! The 5 lines of code below will give problems there:
217  spDataRecord[sector][tbin][nTrk[sector][tbin]].me1_tbin = trk->first.me1Tbin();
218  spDataRecord[sector][tbin][nTrk[sector][tbin]].me2_tbin = trk->first.me2Tbin();
219  spDataRecord[sector][tbin][nTrk[sector][tbin]].me3_tbin = trk->first.me3Tbin();
220  spDataRecord[sector][tbin][nTrk[sector][tbin]].me4_tbin = trk->first.me4Tbin();
221  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_tbin = trk->first.mb1Tbin();
222  // As the MB stubs are not saved in simulation, we want to introduce an artificial ids
223  if( trk->first.mb1ID() ){
224  int subSector = (trk->first.mb1ID() - 1)%2;
225  int MBtbin = tbin - spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_tbin;
226  if( subSector<0 || subSector>1 || MBtbin<0 || MBtbin>7 || !mbDataRecord[sector][subSector][MBtbin].id_ )
227  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_id = ( subSector ? 6 : 5 );
228  }
229  spDataRecord[sector][tbin][nTrk[sector][tbin]].id_ = nTrk[sector][tbin]+1; // for later use
230 
231  nTrk[sector][tbin]++;
232  switch(nTrk[sector][tbin]){
233  case 1: meDataHeader[sector][tbin].mode1 = (trk->first.ptLUTAddress()>>16)&0xF; break;
234  case 2: meDataHeader[sector][tbin].mode2 = (trk->first.ptLUTAddress()>>16)&0xF; break;
235  case 3: meDataHeader[sector][tbin].mode3 = (trk->first.ptLUTAddress()>>16)&0xF; break;
236  default:
237  edm::LogInfo("More than 3 tracks from one SP in the BX");
238  continue;
239  break;
240  }
241  }
242  }
243 
244  CSCSPHeader header;
245  bzero(&header,sizeof(header));
246 
247  header.header_mark_1 = 0x9;
248  header.header_mark_2 = 0x9;
249  header.header_mark_3 = 0x9;
250  header.header_mark_4 = 0x9;
251 
252  header.header_mark_5 = 0xA;
253  header.header_mark_6 = 0xA;
254  header.header_mark_7 = 0xA;
255  header.header_mark_8 = 0xA;
256 
257  header.csr_dfc = nTBINs;
258  header.csr_dfc |= ( zeroSuppression ? 0x8 : 0x0 );
259  header.csr_dfc |= 0x7F0; // All FPGAs are active
260  header.skip = 0;
261  header.sp_ersv = 2; // Format version with block of counters
262 
263  CSCSPCounters counters;
264  bzero(&counters,sizeof(counters));
265 
266  CSCSPTrailer trailer;
267  bzero(&trailer,sizeof(trailer));
268 
269  trailer.trailer_mark_1 = 0xF;
270  trailer.trailer_mark_2 = 0xF;
271  trailer.trailer_mark_3 = 0x7;
272  trailer.trailer_mark_4 = 0xF;
273  trailer.trailer_mark_5 = 0xF;
274  trailer.trailer_mark_6 = 0xF;
275  trailer.trailer_mark_7 = 0xE;
276  trailer.trailer_mark_8 = 0xE;
277  trailer.trailer_mark_9 = 0xE;
278  trailer.trailer_mark_10= 0xE;
279 
280  unsigned short spDDUrecord[700*12], *pos=spDDUrecord; // max length
281  bzero(&spDDUrecord,sizeof(spDDUrecord));
282  int eventNumber = e.id().event();
283  *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0xFFFF&eventNumber; *pos++ = 0x5000|(eventNumber>>16);
284  *pos++ = 0x0000; *pos++ = 0x8000; *pos++ = 0x0001; *pos++ = 0x8000;
285  *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000;
286 
287  for(int sector=0; sector<12; sector++){
288  if( !(activeSectors & (1<<sector)) ) continue;
289  header.sp_trigger_sector = sector+1;
290  memcpy(pos,&header,16);
291  pos+=8;
292  memcpy(pos,&counters,8);
293  pos+=4;
294 
295  for(int tbin=0; tbin<nTBINs; tbin++){
296  memcpy(pos,&meDataHeader[sector][tbin],16);
297  pos+=8;
298  for(int fpga=0; fpga<5; fpga++){
299  int nLCTs=0;
300  for(int link=0; link<3; link++){
301  for(int cscId=0; cscId<9; cscId++)
302  for(int lctId=0; lctId<2; lctId++)
303  // Only 3 LCT per BX from the same fpga are allowed (to be valid):
304  if( meDataRecord[sector][tbin][fpga][cscId][lctId].valid_pattern
305  && meDataRecord[sector][tbin][fpga][cscId][lctId].link_id==link+1 ){
306  memcpy(pos,&meDataRecord[sector][tbin][fpga][cscId][lctId],8);
307  pos+=4;
308  nLCTs++;
309  }
310  }
311  if( !zeroSuppression ) pos += 4*(3-nLCTs);
312  }
313  for(int subSector=0; subSector<2; subSector++)
314  if( !zeroSuppression || (subSector==0 && meDataHeader[sector][tbin].vq_a) || (subSector==1 && meDataHeader[sector][tbin].vq_b) ){
315  memcpy(pos,&mbDataRecord[sector][subSector][tbin],8);
316  pos+=4;
317  }
318  for(int trk=0; trk<3; trk++){
319  if( !zeroSuppression || spDataRecord[sector][tbin][trk].id_ ){
320  memcpy(pos,&spDataRecord[sector][tbin][trk],8);
321  pos+=4;
322  }
323  }
324  }
325  memcpy(pos,&trailer,16);
326  pos+=8;
327  }
328 
329  *pos++ = 0x8000; *pos++ = 0x8000; *pos++ = 0xFFFF; *pos++ = 0x8000;
330  *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000;
331  *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000; *pos++ = 0x0000;
332 
333  if( putBufferToEvent ){
334  std::auto_ptr<FEDRawDataCollection> data(new FEDRawDataCollection);
335  FEDRawData& fedRawData = data->FEDData((unsigned int)FEDNumbering::MINCSCTFFEDID);
336  fedRawData.resize((pos-spDDUrecord)*sizeof(unsigned short));
337  std::copy((unsigned char*)spDDUrecord,(unsigned char*)pos,fedRawData.data());
338  FEDHeader csctfFEDHeader (fedRawData.data());
339  csctfFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, FEDNumbering::MINCSCTFFEDID);
340  FEDTrailer csctfFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
341  csctfFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8), fedRawData.size()/8, evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
342  e.put(data,"CSCTFRawData");
343  }
344 
345  if(file) fwrite(spDDUrecord,2,pos-spDDUrecord,file);
346 }
unsigned header_mark_8
Definition: CSCSPHeader.h:63
unsigned sp_trigger_sector
Definition: CSCSPHeader.h:27
unsigned me1_id
Definition: CSCSP_SPblock.h:27
EventNumber_t event() const
Definition: EventID.h:44
unsigned bx_bits
Definition: CSCSPRecord.h:33
unsigned phi_
Definition: CSCSP_MBblock.h:15
float dt
Definition: AMPTWrapper.h:126
unsigned deltaPhi23_
Definition: CSCSP_SPblock.h:21
unsigned eta_
Definition: CSCSP_SPblock.h:15
unsigned trailer_mark_10
Definition: CSCSPTrailer.h:41
unsigned me_bxn
Definition: CSCSP_MEblock.h:19
unsigned mb_tbin
Definition: CSCSP_SPblock.h:39
unsigned front_rear
Definition: CSCSP_SPblock.h:13
unsigned trailer_mark_2
Definition: CSCSPTrailer.h:11
unsigned trailer_mark_4
Definition: CSCSPTrailer.h:15
unsigned aligment_fifo_empty
Definition: CSCSP_MEblock.h:30
unsigned spare_1
Definition: CSCSPRecord.h:21
unsigned skip
Definition: CSCSPHeader.h:62
unsigned trailer_mark_6
Definition: CSCSPTrailer.h:26
unsigned clct_pattern_number
Definition: CSCSP_MEblock.h:7
unsigned mb_id
Definition: CSCSP_SPblock.h:31
unsigned me3_tbin
Definition: CSCSP_SPblock.h:37
unsigned bx0_
Definition: CSCSP_MEblock.h:15
unsigned aligment_fifo_full
Definition: CSCSP_MEblock.h:22
unsigned trailer_mark_3
Definition: CSCSPTrailer.h:12
unsigned trailer_mark_7
Definition: CSCSPTrailer.h:30
unsigned af_bits
Definition: CSCSPRecord.h:30
unsigned sign_
Definition: CSCSP_SPblock.h:12
unsigned me2_id
Definition: CSCSP_SPblock.h:28
unsigned bc0_
Definition: CSCSP_MBblock.h:18
unsigned csc_id
Definition: CSCSP_MEblock.h:13
unsigned left_right
Definition: CSCSP_MEblock.h:14
unsigned deltaPhi12_
Definition: CSCSP_SPblock.h:20
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
unsigned mode2
Definition: CSCSPRecord.h:17
unsigned cal_
Definition: CSCSP_MBblock.h:12
unsigned flag_
Definition: CSCSP_MBblock.h:11
unsigned header_mark_7
Definition: CSCSPHeader.h:44
unsigned bxn1_
Definition: CSCSP_MBblock.h:16
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
unsigned me2_tbin
Definition: CSCSP_SPblock.h:36
unsigned header_mark_6
Definition: CSCSPHeader.h:29
unsigned clct_pattern_id
Definition: CSCSP_MEblock.h:12
unsigned halo_
Definition: CSCSP_SPblock.h:16
unsigned header_mark_1
Definition: CSCSPHeader.h:10
unsigned receiver_status_dv2
Definition: CSCSP_MEblock.h:29
edm::InputTag trackProducer
Definition: CSCTFPacker.h:14
unsigned receiver_status_dv1
Definition: CSCSP_MEblock.h:21
void resize(size_t newsize)
Definition: FEDRawData.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
unsigned header_mark_2
Definition: CSCSPHeader.h:13
unsigned trailer_mark_1
Definition: CSCSPTrailer.h:9
static void set(unsigned char *header, int evt_ty, int lvl1_ID, int bx_ID, int source_ID, int version=0, bool H=false)
Set all fields in the header.
Definition: FEDHeader.cc:40
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
unsigned receiver_status_er2
Definition: CSCSP_MEblock.h:28
unsigned sp_ersv
Definition: CSCSPHeader.h:26
unsigned phi_bend_
Definition: CSCSP_MBblock.h:9
unsigned int id_
Definition: CSCSP_MBblock.h:37
unsigned trailer_mark_8
Definition: CSCSPTrailer.h:33
unsigned bc0_
Definition: CSCSP_MEblock.h:16
unsigned receiver_status_er1
Definition: CSCSP_MEblock.h:20
bool isValid() const
Definition: HandleBase.h:76
unsigned header_mark_4
Definition: CSCSPHeader.h:19
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
unsigned me3_id
Definition: CSCSP_SPblock.h:29
unsigned header_mark_5
Definition: CSCSPHeader.h:23
unsigned int id_
Definition: CSCSP_SPblock.h:56
unsigned charge_
Definition: CSCSP_SPblock.h:14
bool putBufferToEvent
Definition: CSCTFPacker.h:19
unsigned short activeSectors
Definition: CSCTFPacker.h:18
unsigned trailer_mark_5
Definition: CSCSPTrailer.h:23
bool zeroSuppression
Definition: CSCTFPacker.h:16
unsigned csr_dfc
Definition: CSCSPHeader.h:61
tuple tracks
Definition: testEve_cfg.py:39
unsigned mode3
Definition: CSCSPRecord.h:18
edm::InputTag lctProducer
Definition: CSCTFPacker.h:14
unsigned header_mark_3
Definition: CSCSPHeader.h:16
bool swapME1strips
Definition: CSCTFPacker.h:21
std::vector< CSCCorrelatedLCTDigi >::const_iterator const_iterator
static int triggerSubSectorFromLabels(int station, int chamber)
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag mbProducer
Definition: CSCTFPacker.h:14
edm::EventID id() const
Definition: EventBase.h:56
int central_sp_bx
Definition: CSCTFPacker.h:25
unsigned mode1
Definition: CSCSPRecord.h:16
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int central_lct_bx
Definition: CSCTFPacker.h:25
unsigned quality_
Definition: CSCSP_MEblock.h:8
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
unsigned wire_group_id
Definition: CSCSP_MEblock.h:9
std::pair< const_iterator, const_iterator > Range
unsigned vq_a
Definition: CSCSPRecord.h:19
unsigned mpc_id
Definition: CSCSP_MEblock.h:26
unsigned me4_tbin
Definition: CSCSP_SPblock.h:38
unsigned bxn0_
Definition: CSCSP_MBblock.h:17
unsigned err_prop_cnt
Definition: CSCSP_MEblock.h:27
unsigned se_bits
Definition: CSCSPRecord.h:24
FILE * file
Definition: CSCTFPacker.h:23
unsigned vq_b
Definition: CSCSPRecord.h:20
unsigned mb_bxn_
Definition: CSCSP_MBblock.h:21
unsigned trailer_mark_9
Definition: CSCSPTrailer.h:37
unsigned short nTBINs
Definition: CSCTFPacker.h:17
unsigned bc0_
Definition: CSCSP_SPblock.h:24
std::string const & instance() const
Definition: InputTag.h:43
unsigned int valid_pattern
Definition: CSCSP_MEblock.h:46
unsigned bxn0_
Definition: CSCSP_SPblock.h:23
unsigned phi_
Definition: CSCSP_SPblock.h:11
unsigned link_id
Definition: CSCSP_MEblock.h:25
unsigned ms_id
Definition: CSCSP_SPblock.h:32
unsigned me1_tbin
Definition: CSCSP_SPblock.h:35
unsigned sm_bits
Definition: CSCSPRecord.h:27
unsigned quality_
Definition: CSCSP_MBblock.h:7
unsigned vp_bits
Definition: CSCSPRecord.h:13
unsigned me4_id
Definition: CSCSP_SPblock.h:30

Member Data Documentation

unsigned short CSCTFPacker::activeSectors
private

Definition at line 18 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

int CSCTFPacker::central_lct_bx
private

Definition at line 25 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

int CSCTFPacker::central_sp_bx
private

Definition at line 25 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

FILE* CSCTFPacker::file
private

Definition at line 23 of file CSCTFPacker.h.

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

edm::InputTag CSCTFPacker::lctProducer
private

Definition at line 14 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

int CSCTFPacker::m_maxBX
private

Definition at line 25 of file CSCTFPacker.h.

Referenced by CSCTFPacker().

int CSCTFPacker::m_minBX
private

Definition at line 25 of file CSCTFPacker.h.

Referenced by CSCTFPacker().

edm::InputTag CSCTFPacker::mbProducer
private

Definition at line 14 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

unsigned short CSCTFPacker::nTBINs
private

Definition at line 17 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

bool CSCTFPacker::putBufferToEvent
private

Definition at line 19 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

bool CSCTFPacker::swapME1strips
private

Definition at line 21 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

edm::InputTag CSCTFPacker::trackProducer
private

Definition at line 14 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().

bool CSCTFPacker::zeroSuppression
private

Definition at line 16 of file CSCTFPacker.h.

Referenced by CSCTFPacker(), and produce().