CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCTFPacker Class Reference
Inheritance diagram for CSCTFPacker:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CSCTFPacker (const edm::ParameterSet &conf)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~CSCTFPacker (void) override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

unsigned short activeSectors
 
int central_lct_bx
 
int central_sp_bx
 
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollectionCSCCDC_Tok
 
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
 
FILE * file
 
edm::EDGetTokenT< L1CSCTrackCollectionL1CSCTr_Tok
 
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::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 15 of file CSCTFPacker.cc.

Constructor & Destructor Documentation

◆ CSCTFPacker()

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

Definition at line 61 of file CSCTFPacker.cc.

References activeSectors, central_lct_bx, central_sp_bx, CSCCDC_Tok, CSCTC_Tok, file, edm::ParameterSet::getParameter(), ProducerED_cfi::InputTag, edm::InputTag::instance(), createfilelist::int, L1CSCTr_Tok, edm::InputTag::label(), lctProducer, m_maxBX, m_minBX, mbProducer, nTBINs, download_sqlite_cfg::outputFile, putBufferToEvent, AlCaHLTBitMon_QueryRunRegistry::string, swapME1strips, trackProducer, and zeroSuppression.

62  // "Readout" configuration
63  zeroSuppression = conf.getParameter<bool>("zeroSuppression");
64  nTBINs = conf.getParameter<int>("nTBINs");
65  activeSectors = conf.getParameter<int>("activeSectors");
66 
67  // Configuration that controls CMSSW specific stuff
68  putBufferToEvent = conf.getParameter<bool>("putBufferToEvent");
69  std::string outputFile = conf.getParameter<std::string>("outputFile");
70  lctProducer = conf.getParameter<edm::InputTag>("lctProducer");
71  mbProducer = conf.getParameter<edm::InputTag>("mbProducer");
72  trackProducer = conf.getParameter<edm::InputTag>("trackProducer");
73 
74  // Swap: if(swapME1strips && me1b && !zplus) strip = 65 - strip; // 1-64 -> 64-1 :
75  swapME1strips = conf.getParameter<bool>("swapME1strips");
76 
77  file = nullptr;
78  if (outputFile.length() && (file = fopen(outputFile.c_str(), "wt")) == nullptr)
79  throw cms::Exception("OutputFile ") << "CSCTFPacker: cannot open output file (errno=" << errno
80  << "). Try outputFile=\"\"";
81 
82  // BX window bounds in CMSSW:
83  m_minBX = conf.getParameter<int>("MinBX"); //3
84  m_maxBX = conf.getParameter<int>("MaxBX"); //9
85 
86  // Finds central LCT BX
87  // assumes window is odd number of bins
88  central_lct_bx = (m_maxBX + m_minBX) / 2;
89  // Find central SP BX
90  // assumes window is odd number of bins
91  central_sp_bx = int(nTBINs / 2);
92 
93  produces<FEDRawDataCollection>("CSCTFRawData");
94 
95  CSCTC_Tok =
96  consumes<CSCTriggerContainer<csctf::TrackStub> >(edm::InputTag(mbProducer.label(), mbProducer.instance()));
97  CSCCDC_Tok = consumes<CSCCorrelatedLCTDigiCollection>(edm::InputTag(lctProducer.label(), lctProducer.instance()));
98  L1CSCTr_Tok = consumes<L1CSCTrackCollection>(edm::InputTag(trackProducer.label(), trackProducer.instance()));
99 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string const & instance() const
Definition: InputTag.h:37
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
Definition: CSCTFPacker.cc:31
edm::InputTag trackProducer
Definition: CSCTFPacker.cc:17
bool putBufferToEvent
Definition: CSCTFPacker.cc:22
unsigned short activeSectors
Definition: CSCTFPacker.cc:21
bool zeroSuppression
Definition: CSCTFPacker.cc:19
edm::InputTag lctProducer
Definition: CSCTFPacker.cc:17
bool swapME1strips
Definition: CSCTFPacker.cc:24
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > CSCCDC_Tok
Definition: CSCTFPacker.cc:30
edm::InputTag mbProducer
Definition: CSCTFPacker.cc:17
int central_sp_bx
Definition: CSCTFPacker.cc:28
int central_lct_bx
Definition: CSCTFPacker.cc:28
FILE * file
Definition: CSCTFPacker.cc:26
unsigned short nTBINs
Definition: CSCTFPacker.cc:20
edm::EDGetTokenT< L1CSCTrackCollection > L1CSCTr_Tok
Definition: CSCTFPacker.cc:32

◆ ~CSCTFPacker()

CSCTFPacker::~CSCTFPacker ( void  )
override

Definition at line 101 of file CSCTFPacker.cc.

References file.

101  {
102  if (file)
103  fclose(file);
104 }
FILE * file
Definition: CSCTFPacker.cc:26

Member Function Documentation

◆ produce()

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

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::one::EDProducerBase.

Definition at line 106 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, caHitNtupletGeneratorKernels::counters, CSCSP_MEblock::csc_id, CSCCDC_Tok, CSCTC_Tok, data, CSCSP_SPblock::deltaPhi12_, CSCSP_SPblock::deltaPhi23_, dt, MillePedeFileConverter_cfg::e, CSCSP_MEblock::err_prop_cnt, CSCSP_SPblock::eta_, l1t_dqm_sourceclient-live_cfg::fedRawData, file, CSCSP_MBblock::flag_, CSCSP_SPblock::front_rear, CSCSP_SPblock::halo_, RecoTauValidation_cfi::header, CSCSP_MBblock::id_, CSCSP_SPblock::id_, edm::HandleBase::isValid(), L1CSCTr_Tok, edm::InputTag::label(), CSCSP_MEblock::left_right, 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, eostools::move(), CSCSP_MEblock::mpc_id, CSCSP_SPblock::ms_id, nTBINs, CSCSP_SPblock::phi_, CSCSP_MBblock::phi_, CSCSP_MBblock::phi_bend_, edm::Handle< T >::product(), 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, CSCSP_SPblock::se, CSCSPRecord::se_bits, nano_mu_digi_cff::sector, FEDHeader::set(), FEDTrailer::set(), CSCSP_SPblock::sign_, CSCSPRecord::sm_bits, CSCSPRecord::spare_1, relativeConstraints::station, swapME1strips, trackProducer, DiMuonV_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, testProducerWithPsetDescEmpty_cfi::x1, and zeroSuppression.

106  {
108  e.getByToken(CSCCDC_Tok, corrlcts);
109 
110  CSCSP_MEblock meDataRecord[12][7][5][9][2]; // LCT in sector X, tbin Y, station Z, csc W, and lct I
111  bzero(&meDataRecord, sizeof(meDataRecord));
112  CSCSPRecord meDataHeader[12][7]; // Data Block Header for sector X and tbin Y
113  bzero(&meDataHeader, sizeof(meDataHeader));
114 
116  csc != corrlcts.product()->end();
117  csc++) {
118  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
119  int lctId = 0;
120  for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range1.first; lct != range1.second; lct++, lctId++) {
121  int station = (*csc).first.station() - 1;
122  int cscId = (*csc).first.triggerCscId() - 1;
123  int sector = (*csc).first.triggerSector() - 1 + ((*csc).first.endcap() == 1 ? 0 : 6);
124  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
125  int tbin = lct->getBX() - (central_lct_bx - central_sp_bx); // Shift back to hardware BX window definition
126  if (tbin > 6 || tbin < 0) {
127  edm::LogError("CSCTFPacker|produce") << " LCT's BX=" << tbin << " is out of 0-6 window";
128  continue;
129  }
130  int fpga = (subSector ? subSector - 1 : station + 1);
132 
133  // If Det Id is within range
134  if (sector < 0 || sector > 11 || station < 0 || station > 3 || cscId < 0 || cscId > 8 || lctId < 0 || lctId > 1) {
135  edm::LogInfo("CSCTFPacker: CSC digi are out of range: ")
136  << "sector=" << sector << ", station=" << station << ", cscId=" << cscId << ", lctId=" << lctId;
137  continue;
138  }
139 
140  meDataRecord[sector][tbin][fpga][cscId][lctId].clct_pattern_number = lct->getPattern();
141  meDataRecord[sector][tbin][fpga][cscId][lctId].quality_ = lct->getQuality();
142  meDataRecord[sector][tbin][fpga][cscId][lctId].wire_group_id = lct->getKeyWG();
143 
144  meDataRecord[sector][tbin][fpga][cscId][lctId].clct_pattern_id =
145  (swapME1strips && cscId < 3 && station == 0 && (*csc).first.endcap() == 2 && lct->getStrip() < 65
146  ? 65 - lct->getStrip()
147  : lct->getStrip());
148  meDataRecord[sector][tbin][fpga][cscId][lctId].csc_id = (*csc).first.triggerCscId();
149  meDataRecord[sector][tbin][fpga][cscId][lctId].left_right = lct->getBend();
150  meDataRecord[sector][tbin][fpga][cscId][lctId].bx0_ = 0; //?;
151  meDataRecord[sector][tbin][fpga][cscId][lctId].bc0_ = 0; //?;
152 
153  meDataRecord[sector][tbin][fpga][cscId][lctId].me_bxn = 0; //?
154  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_er1 = 0; // dummy
155  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_dv1 = 0; // dummy
156  meDataRecord[sector][tbin][fpga][cscId][lctId].aligment_fifo_full = 0; // dummy
157 
158  meDataRecord[sector][tbin][fpga][cscId][lctId].link_id = lct->getMPCLink();
159  meDataRecord[sector][tbin][fpga][cscId][lctId].mpc_id = 0; // Join with above?
160  meDataRecord[sector][tbin][fpga][cscId][lctId].err_prop_cnt = 0; // dummy
161  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_er2 = 0; // dummy
162  meDataRecord[sector][tbin][fpga][cscId][lctId].receiver_status_dv2 = 0; // dummy
163  meDataRecord[sector][tbin][fpga][cscId][lctId].aligment_fifo_empty = 0; // dummy
164 
165  if (lct->isValid()) {
166  switch ((meDataHeader[sector][tbin].vp_bits >> (fpga * 3)) & 0x7) {
167  case 0x0:
168  meDataHeader[sector][tbin].vp_bits |= (0x1 << (fpga * 3));
169  break;
170  case 0x1:
171  meDataHeader[sector][tbin].vp_bits |= (0x3 << (fpga * 3));
172  break;
173  case 0x3:
174  meDataHeader[sector][tbin].vp_bits |= (0x7 << (fpga * 3));
175  break;
176  default:
177  edm::LogInfo("CSCTFPacker: more than 3 LCTs from a single MPC in one BX!!!");
178  continue;
179  break;
180  }
181  meDataRecord[sector][tbin][fpga][cscId][lctId].valid_pattern = 1; // for later use
182  }
183  meDataHeader[sector][tbin].vq_a = 0; // no digi yet?
184  meDataHeader[sector][tbin].vq_b = 0; // no digi yet?
185  meDataHeader[sector][tbin].se_bits = 0; // dummy
186  meDataHeader[sector][tbin].sm_bits = 0; // dummy
187  meDataHeader[sector][tbin].af_bits = 0; // dummy
188  meDataHeader[sector][tbin].bx_bits = 0; //(lct->getBX()&??<< (fpga*3));
189 
190  meDataHeader[sector][tbin].spare_1 = 0; // for later use
191  }
192  }
193 
194  CSCSP_MBblock mbDataRecord[12][2][7]; // LCT in sector X, subsector Z, tbin Y
195  bzero(&mbDataRecord, sizeof(mbDataRecord));
197  if (mbProducer.label() != "null") {
198  e.getByToken(CSCTC_Tok, barrelStubs);
199  if (barrelStubs.isValid()) {
200  std::vector<csctf::TrackStub> stubs = barrelStubs.product()->get();
201  for (std::vector<csctf::TrackStub>::const_iterator dt = stubs.begin(); dt != stubs.end(); dt++) {
202  int sector = dt->sector() - 1 + (dt->endcap() == 1 ? 0 : 6);
203  int subSector = dt->subsector() - 1;
204  int tbin = dt->getBX() - (central_lct_bx - central_sp_bx); // Shift back to hardware BX window definition
205  if (tbin < 0 || tbin > 6 || sector < 0 || sector > 11 || subSector < 0 || subSector > 11) {
206  edm::LogInfo("CSCTFPacker: CSC DT digi are out of range: ")
207  << " sector=" << sector << " subSector=" << subSector << " tbin=" << tbin;
208  continue;
209  }
210  mbDataRecord[sector][subSector][tbin].quality_ = dt->getQuality();
211  mbDataRecord[sector][subSector][tbin].phi_bend_ = dt->getBend();
212  mbDataRecord[sector][subSector][tbin].flag_ = dt->getStrip();
213  mbDataRecord[sector][subSector][tbin].cal_ = dt->getKeyWG();
214  mbDataRecord[sector][subSector][tbin].phi_ = dt->phiPacked();
215  mbDataRecord[sector][subSector][tbin].bxn1_ = (dt->getBX0() >> 1) & 0x1;
216  mbDataRecord[sector][subSector][tbin].bxn0_ = dt->getBX0() & 0x1;
217  mbDataRecord[sector][subSector][tbin].bc0_ = dt->getPattern();
218  mbDataRecord[sector][subSector][tbin].mb_bxn_ = dt->getCSCID();
219  switch (subSector) {
220  case 0:
221  meDataHeader[sector][tbin].vq_a = 1;
222  break;
223  case 1:
224  meDataHeader[sector][tbin].vq_b = 1;
225  break;
226  default:
227  edm::LogInfo("CSCTFPacker: subSector=") << subSector;
228  break;
229  }
230  mbDataRecord[sector][subSector][tbin].id_ = dt->getMPCLink(); // for later use
231  }
232  }
233  }
234 
235  CSCSP_SPblock spDataRecord[12][7][3]; // Up to 3 tracks in sector X and tbin Y
236  bzero(&spDataRecord, sizeof(spDataRecord));
237  int nTrk[12][7];
238  bzero(&nTrk, sizeof(nTrk));
239 
241  if (trackProducer.label() != "null") {
242  e.getByToken(L1CSCTr_Tok, tracks);
243 
244  for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk != tracks->end(); trk++) {
245  int sector = 6 * (trk->first.endcap() - 1) + trk->first.sector() - 1;
246  int tbin = trk->first.BX() + central_sp_bx; // Shift back to hardware BX window definition
247  //std::cout<<"Track["<<nTrk[sector][tbin]<<"] sector: "<<sector<<" tbin: "<<tbin<<std::endl;
248  if (tbin > 6 || tbin < 0) {
249  edm::LogError("CSCTFPacker|analyze") << " Track's BX=" << tbin << " is out of 0-6 window";
250  continue;
251  }
252  if (sector < 0 || sector > 11) {
253  edm::LogError("CSCTFPacker|analyze") << " Track's sector=" << sector << " is out of range";
254  continue;
255  }
256  spDataRecord[sector][tbin][nTrk[sector][tbin]].phi_ = trk->first.localPhi();
257  spDataRecord[sector][tbin][nTrk[sector][tbin]].sign_ = (trk->first.ptLUTAddress() >> 20) & 0x1;
258  spDataRecord[sector][tbin][nTrk[sector][tbin]].front_rear = trk->first.front_rear();
259  spDataRecord[sector][tbin][nTrk[sector][tbin]].charge_ = trk->first.charge_packed(); //
260  spDataRecord[sector][tbin][nTrk[sector][tbin]].eta_ = trk->first.eta_packed();
261 
262  spDataRecord[sector][tbin][nTrk[sector][tbin]].halo_ = trk->first.finehalo_packed();
263  spDataRecord[sector][tbin][nTrk[sector][tbin]].se = 0; // dummy
264  spDataRecord[sector][tbin][nTrk[sector][tbin]].deltaPhi12_ = trk->first.ptLUTAddress() & 0xFF;
265  spDataRecord[sector][tbin][nTrk[sector][tbin]].deltaPhi23_ = (trk->first.ptLUTAddress() >> 8) & 0xF;
266  spDataRecord[sector][tbin][nTrk[sector][tbin]].bxn0_ = 0; //dummy
267  spDataRecord[sector][tbin][nTrk[sector][tbin]].bc0_ = 0; //dummy
268 
269  spDataRecord[sector][tbin][nTrk[sector][tbin]].me1_id = trk->first.me1ID();
270  spDataRecord[sector][tbin][nTrk[sector][tbin]].me2_id = trk->first.me2ID();
271  spDataRecord[sector][tbin][nTrk[sector][tbin]].me3_id = trk->first.me3ID();
272  spDataRecord[sector][tbin][nTrk[sector][tbin]].me4_id = trk->first.me4ID();
273  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_id = trk->first.mb1ID();
274  spDataRecord[sector][tbin][nTrk[sector][tbin]].ms_id = 0; // don't care winner()
275 
276  // Warning, digi copying was broken for <= CMSSW_3_8_x! The 5 lines of code below will give problems there:
277  spDataRecord[sector][tbin][nTrk[sector][tbin]].me1_tbin = trk->first.me1Tbin();
278  spDataRecord[sector][tbin][nTrk[sector][tbin]].me2_tbin = trk->first.me2Tbin();
279  spDataRecord[sector][tbin][nTrk[sector][tbin]].me3_tbin = trk->first.me3Tbin();
280  spDataRecord[sector][tbin][nTrk[sector][tbin]].me4_tbin = trk->first.me4Tbin();
281  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_tbin = trk->first.mb1Tbin();
282  // As the MB stubs are not saved in simulation, we want to introduce an artificial ids
283  if (trk->first.mb1ID()) {
284  int subSector = (trk->first.mb1ID() - 1) % 2;
285  int MBtbin = tbin - spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_tbin;
286  if (subSector < 0 || subSector > 1 || MBtbin < 0 || MBtbin > 7 || !mbDataRecord[sector][subSector][MBtbin].id_)
287  spDataRecord[sector][tbin][nTrk[sector][tbin]].mb_id = (subSector ? 6 : 5);
288  }
289  spDataRecord[sector][tbin][nTrk[sector][tbin]].id_ = nTrk[sector][tbin] + 1; // for later use
290 
291  nTrk[sector][tbin]++;
292  switch (nTrk[sector][tbin]) {
293  case 1:
294  meDataHeader[sector][tbin].mode1 = (trk->first.ptLUTAddress() >> 16) & 0xF;
295  break;
296  case 2:
297  meDataHeader[sector][tbin].mode2 = (trk->first.ptLUTAddress() >> 16) & 0xF;
298  break;
299  case 3:
300  meDataHeader[sector][tbin].mode3 = (trk->first.ptLUTAddress() >> 16) & 0xF;
301  break;
302  default:
303  edm::LogInfo("More than 3 tracks from one SP in the BX");
304  continue;
305  break;
306  }
307  }
308  }
309 
311  bzero(&header, sizeof(header));
312 
313  header.header_mark_1 = 0x9;
314  header.header_mark_2 = 0x9;
315  header.header_mark_3 = 0x9;
316  header.header_mark_4 = 0x9;
317 
318  header.header_mark_5 = 0xA;
319  header.header_mark_6 = 0xA;
320  header.header_mark_7 = 0xA;
321  header.header_mark_8 = 0xA;
322 
323  header.csr_dfc = nTBINs;
324  header.csr_dfc |= (zeroSuppression ? 0x8 : 0x0);
325  header.csr_dfc |= 0x7F0; // All FPGAs are active
326  header.skip = 0;
327  header.sp_ersv = 2; // Format version with block of counters
328 
330  bzero(&counters, sizeof(counters));
331 
332  CSCSPTrailer trailer;
333  bzero(&trailer, sizeof(trailer));
334 
335  trailer.trailer_mark_1 = 0xF;
336  trailer.trailer_mark_2 = 0xF;
337  trailer.trailer_mark_3 = 0x7;
338  trailer.trailer_mark_4 = 0xF;
339  trailer.trailer_mark_5 = 0xF;
340  trailer.trailer_mark_6 = 0xF;
341  trailer.trailer_mark_7 = 0xE;
342  trailer.trailer_mark_8 = 0xE;
343  trailer.trailer_mark_9 = 0xE;
344  trailer.trailer_mark_10 = 0xE;
345 
346  unsigned short spDDUrecord[700 * 12], *pos = spDDUrecord; // max length
347  bzero(&spDDUrecord, sizeof(spDDUrecord));
348  int eventNumber = e.id().event();
349  *pos++ = 0x0000;
350  *pos++ = 0x0000;
351  *pos++ = 0xFFFF & eventNumber;
352  *pos++ = 0x5000 | (eventNumber >> 16);
353  *pos++ = 0x0000;
354  *pos++ = 0x8000;
355  *pos++ = 0x0001;
356  *pos++ = 0x8000;
357  *pos++ = 0x0000;
358  *pos++ = 0x0000;
359  *pos++ = 0x0000;
360  *pos++ = 0x0000;
361 
362  for (int sector = 0; sector < 12; sector++) {
363  if (!(activeSectors & (1 << sector)))
364  continue;
365  header.sp_trigger_sector = sector + 1;
366  memcpy(pos, &header, 16);
367  pos += 8;
368  memcpy(pos, &counters, 8);
369  pos += 4;
370 
371  for (int tbin = 0; tbin < nTBINs; tbin++) {
372  memcpy(pos, &meDataHeader[sector][tbin], 16);
373  pos += 8;
374  for (int fpga = 0; fpga < 5; fpga++) {
375  int nLCTs = 0;
376  for (int link = 0; link < 3; link++) {
377  for (int cscId = 0; cscId < 9; cscId++)
378  for (int lctId = 0; lctId < 2; lctId++)
379  // Only 3 LCT per BX from the same fpga are allowed (to be valid):
380  if (meDataRecord[sector][tbin][fpga][cscId][lctId].valid_pattern &&
381  meDataRecord[sector][tbin][fpga][cscId][lctId].link_id == link + 1) {
382  memcpy(pos, &meDataRecord[sector][tbin][fpga][cscId][lctId], 8);
383  pos += 4;
384  nLCTs++;
385  }
386  }
387  if (!zeroSuppression)
388  pos += 4 * (3 - nLCTs);
389  }
390  for (int subSector = 0; subSector < 2; subSector++)
391  if (!zeroSuppression || (subSector == 0 && meDataHeader[sector][tbin].vq_a) ||
392  (subSector == 1 && meDataHeader[sector][tbin].vq_b)) {
393  memcpy(pos, &mbDataRecord[sector][subSector][tbin], 8);
394  pos += 4;
395  }
396  for (int trk = 0; trk < 3; trk++) {
397  if (!zeroSuppression || spDataRecord[sector][tbin][trk].id_) {
398  memcpy(pos, &spDataRecord[sector][tbin][trk], 8);
399  pos += 4;
400  }
401  }
402  }
403  memcpy(pos, &trailer, 16);
404  pos += 8;
405  }
406 
407  *pos++ = 0x8000;
408  *pos++ = 0x8000;
409  *pos++ = 0xFFFF;
410  *pos++ = 0x8000;
411  *pos++ = 0x0000;
412  *pos++ = 0x0000;
413  *pos++ = 0x0000;
414  *pos++ = 0x0000;
415  *pos++ = 0x0000;
416  *pos++ = 0x0000;
417  *pos++ = 0x0000;
418  *pos++ = 0x0000;
419 
420  if (putBufferToEvent) {
421  auto data = std::make_unique<FEDRawDataCollection>();
422  FEDRawData& fedRawData = data->FEDData((unsigned int)FEDNumbering::MINCSCTFFEDID);
423  fedRawData.resize((pos - spDDUrecord) * sizeof(unsigned short));
424  std::copy((unsigned char*)spDDUrecord, (unsigned char*)pos, fedRawData.data());
425  FEDHeader csctfFEDHeader(fedRawData.data());
426  csctfFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, FEDNumbering::MINCSCTFFEDID);
427  FEDTrailer csctfFEDTrailer(fedRawData.data() + (fedRawData.size() - 8));
428  csctfFEDTrailer.set(fedRawData.data() + (fedRawData.size() - 8),
429  fedRawData.size() / 8,
430  evf::compute_crc(fedRawData.data(), fedRawData.size()),
431  0,
432  0);
433  e.put(std::move(data), "CSCTFRawData");
434  }
435 
436  if (file)
437  fwrite(spDDUrecord, 2, pos - spDDUrecord, file);
438 }
unsigned me1_id
Definition: CSCSP_SPblock.h:28
unsigned bx_bits
Definition: CSCSPRecord.h:34
unsigned phi_
Definition: CSCSP_MBblock.h:17
float dt
Definition: AMPTWrapper.h:136
unsigned deltaPhi23_
Definition: CSCSP_SPblock.h:22
unsigned eta_
Definition: CSCSP_SPblock.h:15
unsigned trailer_mark_10
Definition: CSCSPTrailer.h:43
unsigned me_bxn
Definition: CSCSP_MEblock.h:23
unsigned mb_tbin
Definition: CSCSP_SPblock.h:40
unsigned front_rear
Definition: CSCSP_SPblock.h:13
unsigned trailer_mark_2
Definition: CSCSPTrailer.h:13
unsigned trailer_mark_4
Definition: CSCSPTrailer.h:17
unsigned aligment_fifo_empty
Definition: CSCSP_MEblock.h:36
unsigned spare_1
Definition: CSCSPRecord.h:21
unsigned trailer_mark_6
Definition: CSCSPTrailer.h:28
T const * product() const
Definition: Handle.h:70
unsigned clct_pattern_number
Definition: CSCSP_MEblock.h:10
unsigned mb_id
Definition: CSCSP_SPblock.h:32
unsigned me3_tbin
Definition: CSCSP_SPblock.h:38
unsigned bx0_
Definition: CSCSP_MEblock.h:19
unsigned aligment_fifo_full
Definition: CSCSP_MEblock.h:27
unsigned trailer_mark_3
Definition: CSCSPTrailer.h:14
unsigned trailer_mark_7
Definition: CSCSPTrailer.h:32
std::string const & label() const
Definition: InputTag.h:36
unsigned af_bits
Definition: CSCSPRecord.h:31
unsigned sign_
Definition: CSCSP_SPblock.h:12
Log< level::Error, false > LogError
unsigned me2_id
Definition: CSCSP_SPblock.h:29
unsigned bc0_
Definition: CSCSP_MBblock.h:20
unsigned csc_id
Definition: CSCSP_MEblock.h:17
unsigned left_right
Definition: CSCSP_MEblock.h:18
unsigned deltaPhi12_
Definition: CSCSP_SPblock.h:21
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > CSCTC_Tok
Definition: CSCTFPacker.cc:31
unsigned mode2
Definition: CSCSPRecord.h:17
unsigned cal_
Definition: CSCSP_MBblock.h:14
unsigned flag_
Definition: CSCSP_MBblock.h:13
unsigned bxn1_
Definition: CSCSP_MBblock.h:18
unsigned me2_tbin
Definition: CSCSP_SPblock.h:37
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
unsigned clct_pattern_id
Definition: CSCSP_MEblock.h:16
unsigned halo_
Definition: CSCSP_SPblock.h:16
unsigned receiver_status_dv2
Definition: CSCSP_MEblock.h:34
edm::InputTag trackProducer
Definition: CSCTFPacker.cc:17
unsigned receiver_status_dv1
Definition: CSCSP_MEblock.h:25
unsigned trailer_mark_1
Definition: CSCSPTrailer.h:11
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
unsigned receiver_status_er2
Definition: CSCSP_MEblock.h:33
unsigned phi_bend_
Definition: CSCSP_MBblock.h:11
unsigned int id_
Definition: CSCSP_MBblock.h:39
unsigned trailer_mark_8
Definition: CSCSPTrailer.h:35
unsigned bc0_
Definition: CSCSP_MEblock.h:20
unsigned receiver_status_er1
Definition: CSCSP_MEblock.h:24
Definition: L1Track.h:19
unsigned me3_id
Definition: CSCSP_SPblock.h:30
unsigned int id_
Definition: CSCSP_SPblock.h:57
unsigned charge_
Definition: CSCSP_SPblock.h:14
bool putBufferToEvent
Definition: CSCTFPacker.cc:22
Log< level::Info, false > LogInfo
unsigned short activeSectors
Definition: CSCTFPacker.cc:21
unsigned trailer_mark_5
Definition: CSCSPTrailer.h:25
bool zeroSuppression
Definition: CSCTFPacker.cc:19
unsigned mode3
Definition: CSCSPRecord.h:18
std::pair< const_iterator, const_iterator > Range
bool swapME1strips
Definition: CSCTFPacker.cc:24
std::vector< DigiType >::const_iterator const_iterator
static int triggerSubSectorFromLabels(int station, int chamber)
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > CSCCDC_Tok
Definition: CSCTFPacker.cc:30
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag mbProducer
Definition: CSCTFPacker.cc:17
int central_sp_bx
Definition: CSCTFPacker.cc:28
unsigned mode1
Definition: CSCSPRecord.h:16
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
int central_lct_bx
Definition: CSCTFPacker.cc:28
unsigned quality_
Definition: CSCSP_MEblock.h:11
unsigned wire_group_id
Definition: CSCSP_MEblock.h:12
unsigned vq_a
Definition: CSCSPRecord.h:19
unsigned mpc_id
Definition: CSCSP_MEblock.h:31
unsigned me4_tbin
Definition: CSCSP_SPblock.h:39
unsigned bxn0_
Definition: CSCSP_MBblock.h:19
unsigned err_prop_cnt
Definition: CSCSP_MEblock.h:32
unsigned se_bits
Definition: CSCSPRecord.h:24
static void set(unsigned char *header, uint8_t triggerType, uint32_t lvl1ID, uint16_t bxID, uint16_t sourceID, uint8_t version=0, bool moreHeaders=false)
Set all fields in the header.
Definition: FEDHeader.cc:25
FILE * file
Definition: CSCTFPacker.cc:26
unsigned vq_b
Definition: CSCSPRecord.h:20
unsigned mb_bxn_
Definition: CSCSP_MBblock.h:23
unsigned trailer_mark_9
Definition: CSCSPTrailer.h:39
unsigned short nTBINs
Definition: CSCTFPacker.cc:20
unsigned bc0_
Definition: CSCSP_SPblock.h:25
unsigned int valid_pattern
Definition: CSCSP_MEblock.h:52
unsigned bxn0_
Definition: CSCSP_SPblock.h:24
unsigned phi_
Definition: CSCSP_SPblock.h:11
def move(src, dest)
Definition: eostools.py:511
unsigned link_id
Definition: CSCSP_MEblock.h:30
unsigned ms_id
Definition: CSCSP_SPblock.h:33
unsigned me1_tbin
Definition: CSCSP_SPblock.h:36
unsigned sm_bits
Definition: CSCSPRecord.h:28
unsigned quality_
Definition: CSCSP_MBblock.h:9
edm::EDGetTokenT< L1CSCTrackCollection > L1CSCTr_Tok
Definition: CSCTFPacker.cc:32
unsigned vp_bits
Definition: CSCSPRecord.h:13
unsigned me4_id
Definition: CSCSP_SPblock.h:31

Member Data Documentation

◆ activeSectors

unsigned short CSCTFPacker::activeSectors
private

Definition at line 21 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ central_lct_bx

int CSCTFPacker::central_lct_bx
private

Definition at line 28 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ central_sp_bx

int CSCTFPacker::central_sp_bx
private

Definition at line 28 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ CSCCDC_Tok

edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> CSCTFPacker::CSCCDC_Tok
private

Definition at line 30 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ CSCTC_Tok

edm::EDGetTokenT<CSCTriggerContainer<csctf::TrackStub> > CSCTFPacker::CSCTC_Tok
private

Definition at line 31 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ file

FILE* CSCTFPacker::file
private

◆ L1CSCTr_Tok

edm::EDGetTokenT<L1CSCTrackCollection> CSCTFPacker::L1CSCTr_Tok
private

Definition at line 32 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ lctProducer

edm::InputTag CSCTFPacker::lctProducer
private

Definition at line 17 of file CSCTFPacker.cc.

Referenced by CSCTFPacker().

◆ m_maxBX

int CSCTFPacker::m_maxBX
private

Definition at line 28 of file CSCTFPacker.cc.

Referenced by CSCTFPacker().

◆ m_minBX

int CSCTFPacker::m_minBX
private

Definition at line 28 of file CSCTFPacker.cc.

Referenced by CSCTFPacker().

◆ mbProducer

edm::InputTag CSCTFPacker::mbProducer
private

Definition at line 17 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ nTBINs

unsigned short CSCTFPacker::nTBINs
private

Definition at line 20 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ putBufferToEvent

bool CSCTFPacker::putBufferToEvent
private

Definition at line 22 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ swapME1strips

bool CSCTFPacker::swapME1strips
private

Definition at line 24 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ trackProducer

edm::InputTag CSCTFPacker::trackProducer
private

Definition at line 17 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().

◆ zeroSuppression

bool CSCTFPacker::zeroSuppression
private

Definition at line 19 of file CSCTFPacker.cc.

Referenced by CSCTFPacker(), and produce().