Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-08 05:11:45

0001 #ifndef L1_DUMMY_PRODUCER_H
0002 #define L1_DUMMY_PRODUCER_H
0003 
0004 /*\class L1DummyProducer
0005  *\description produces simplified, random L1 trigger digis
0006  *\usage pattern and monitoring software test and validation
0007  *\author Nuno Leonardo (CERN)
0008  *\date 07.07
0009  */
0010 
0011 // system includes
0012 #include <memory>
0013 #include <string>
0014 #include <iostream>
0015 #include <fstream>
0016 #include <iomanip>
0017 #include <vector>
0018 #include <algorithm>
0019 #include "TMath.h"
0020 #include <bitset>
0021 #include <atomic>
0022 
0023 // common includes
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/global/EDProducer.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0030 
0031 // l1 dataformats, d|e record includes
0032 #include "DataFormats/HcalDigi/interface/HcalTriggerPrimitiveDigi.h"
0033 #include "DataFormats/L1CSCTrackFinder/interface/L1Track.h"
0034 #include "L1Trigger/HardwareValidation/interface/DEtrait.h"
0035 
0036 // random # generator
0037 #include "CLHEP/Random/RandomEngine.h"
0038 #include "CLHEP/Random/RandGaussQ.h"
0039 
0040 class L1DummyProducer : public edm::global::EDProducer<> {
0041 public:
0042   explicit L1DummyProducer(const edm::ParameterSet&);
0043   ~L1DummyProducer() override;
0044 
0045 private:
0046   //virtual void beginRun(edm::Run&, const edm::EventSetup&);
0047   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0048 
0049 public:
0050   template <class T>
0051   void SimpleDigi(int nevt, CLHEP::HepRandomEngine*, std::unique_ptr<T>& data, int type = 0) const;
0052 
0053 private:
0054   int verbose_;
0055   int verbose() const { return verbose_; }
0056   mutable std::atomic<int> nevt_;
0057 
0058   bool m_doSys[dedefs::DEnsys];
0059   std::string instName[dedefs::DEnsys][5];
0060 
0061   double EBase_;
0062   double ESigm_;
0063 };
0064 
0065 template <class T>
0066 void L1DummyProducer::SimpleDigi(int, CLHEP::HepRandomEngine*, std::unique_ptr<T>& data, int type) const {
0067   /*collections generated in specializations below*/
0068 }
0069 
0070 template <>
0071 inline void L1DummyProducer::SimpleDigi(int,
0072                                         CLHEP::HepRandomEngine* engine,
0073                                         std::unique_ptr<EcalTrigPrimDigiCollection>& data,
0074                                         int type) const {
0075   if (verbose())
0076     std::cout << "L1DummyProducer::SimpleDigi<EcalTrigPrimDigiCollection>....\n" << std::flush;
0077   int side = (engine->flat() > 0.5) ? -1 : 1;
0078   int ieta = (int)(1 + 17 * engine->flat());  //1-17
0079   int iphi = (int)(1 + 72 * engine->flat());  //1-72
0080   const EcalTrigTowerDetId e_id(side, EcalBarrel, ieta, iphi, 0);
0081   EcalTriggerPrimitiveDigi e_digi(e_id);
0082   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0083   bool fg = (engine->flat() > 0.5);
0084   int ttf = (int)(8 * engine->flat());  //0-7
0085   EcalTriggerPrimitiveSample e_sample(energy, fg, ttf);
0086   e_digi.setSize(1);  //set sampleOfInterest to 0
0087   e_digi.setSample(0, e_sample);
0088   data->push_back(e_digi);
0089   //EcalTriggerPrimitiveSample(int encodedEt, bool finegrain, int triggerFlag);
0090   //const EcalTrigTowerDetId e_id( zside , EcalBarrel, etaTT, phiTT, 0);
0091   if (verbose())
0092     std::cout << "L1DummyProducer::SimpleDigi<EcalTrigPrimDigiCollection> end.\n" << std::flush;
0093 }
0094 
0095 template <>
0096 inline void L1DummyProducer::SimpleDigi(int,
0097                                         CLHEP::HepRandomEngine* engine,
0098                                         std::unique_ptr<HcalTrigPrimDigiCollection>& data,
0099                                         int type) const {
0100   if (verbose())
0101     std::cout << "L1DummyProducer::SimpleDigi<HcalTrigPrimDigiCollection>....\n" << std::flush;
0102   int side = (engine->flat() > 0.5) ? -1 : 1;
0103   int ieta = (int)(1 + 17 * engine->flat());
0104   int iphi = (int)(1 + 72 * engine->flat());
0105   const HcalTrigTowerDetId h_id(side * ieta, iphi);
0106   HcalTriggerPrimitiveDigi h_digi(h_id);
0107   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0108   HcalTriggerPrimitiveSample h_sample(energy, false, 0, 0);
0109   h_digi.setSize(1);  //set sampleOfInterest to 0
0110   h_digi.setSample(0, h_sample);
0111   data->push_back(h_digi);
0112   //HcalTriggerPrimitiveSample(int encodedEt, bool finegrain, int slb, int slbchan);
0113   //HcalTrigTowerDetId(int ieta, int iphi);
0114   if (verbose())
0115     std::cout << "L1DummyProducer::SimpleDigi<HcalTrigPrimDigiCollection> end.\n" << std::flush;
0116 }
0117 
0118 template <>
0119 inline void L1DummyProducer::SimpleDigi(int nevt,
0120                                         CLHEP::HepRandomEngine* engine,
0121                                         std::unique_ptr<L1CaloEmCollection>& data,
0122                                         int type) const {
0123   if (verbose())
0124     std::cout << "L1DummyProducer::SimpleDigi<L1CaloEmCollection>....\n" << std::flush;
0125   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0126   unsigned rank = energy & 0x3f;
0127   unsigned region = (engine->flat() > 0.5 ? 0 : 1);
0128   unsigned card = (unsigned)(7 * engine->flat());
0129   unsigned crate = (unsigned)(18 * engine->flat());
0130   bool iso = (engine->flat() > 0.4);
0131   uint16_t index = (unsigned)(4 * engine->flat());
0132   int16_t bx = nevt;
0133   L1CaloEmCand cand(rank, region, card, crate, iso, index, bx);
0134   data->push_back(cand);
0135   //L1CaloEmCand(unsigned rank, unsigned region, unsigned card, unsigned crate, bool iso, uint16_t index, int16_t bx);
0136   if (verbose())
0137     std::cout << "L1DummyProducer::SimpleDigi<L1CaloEmCollection> end.\n" << std::flush;
0138 }
0139 
0140 template <>
0141 inline void L1DummyProducer::SimpleDigi(int,
0142                                         CLHEP::HepRandomEngine* engine,
0143                                         std::unique_ptr<L1CaloRegionCollection>& data,
0144                                         int type) const {
0145   if (verbose())
0146     std::cout << "L1DummyProducer::SimpleDigi<L1CaloRegionCollection>....\n" << std::flush;
0147   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0148   unsigned et = energy & 0x3ff;
0149   bool overFlow = false;  //(engine->flat()>0.4);
0150   bool tauVeto = false;   //(engine->flat()>0.3);
0151   bool mip = false;       //(engine->flat()>0.1);
0152   bool quiet = false;     //(engine->flat()>0.6);
0153   unsigned crate = (unsigned)(18 * engine->flat());
0154   unsigned card = (unsigned)(7 * engine->flat());
0155   unsigned rgn = crate % 2;  //(engine->flat()>0.5?0:1);
0156   L1CaloRegion cand(et, overFlow, tauVeto, mip, quiet, crate, card, rgn);
0157   data->push_back(cand);
0158   //L1CaloRegion(unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn);
0159   if (verbose())
0160     std::cout << "L1DummyProducer::SimpleDigi<L1CaloRegionCollection> end.\n" << std::flush;
0161 }
0162 
0163 template <>
0164 inline void L1DummyProducer::SimpleDigi(int,
0165                                         CLHEP::HepRandomEngine* engine,
0166                                         std::unique_ptr<L1GctEmCandCollection>& data,
0167                                         int type) const {
0168   if (verbose())
0169     std::cout << "L1DummyProducer::SimpleDigi<L1GctEmCandCollection>....\n" << std::flush;
0170   bool iso;        //= type==0;
0171   switch (type) {  // 0 iso, 1 noniso
0172     case 0:
0173       iso = true;
0174       break;
0175     case 1:
0176       iso = false;
0177       break;
0178     default:
0179       throw cms::Exception("L1DummyProducerInvalidType")
0180           << "L1DummyProducer::SimpleDigi production of L1GctEmCandCollection "
0181           << " invalid type: " << type << std::endl;
0182   }
0183   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0184   unsigned rank = energy & 0x3f;
0185   unsigned phi = (unsigned)(18 * engine->flat());
0186   unsigned eta = (unsigned)(7 * engine->flat());
0187   if (engine->flat() > 0.5)  //-z (eta sign)
0188     eta = (eta & 0x7) + (0x1 << 3);
0189   L1GctEmCand cand(rank, phi, eta, iso);
0190   data->push_back(cand);
0191   // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
0192   //L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso);
0193   if (verbose())
0194     std::cout << "L1DummyProducer::SimpleDigi<L1GctEmCandCollection> end.\n" << std::flush;
0195 }
0196 
0197 template <>
0198 inline void L1DummyProducer::SimpleDigi(int,
0199                                         CLHEP::HepRandomEngine* engine,
0200                                         std::unique_ptr<L1GctJetCandCollection>& data,
0201                                         int type) const {
0202   if (verbose())
0203     std::cout << "L1DummyProducer::SimpleDigi<L1GctJetCandCollection>....\n" << std::flush;
0204   bool isFor, isTau;
0205   switch (type) {  // 0 cen, 1 for, 2 tau
0206     case 0:
0207       isFor = false;
0208       isTau = false;
0209       break;
0210     case 1:
0211       isFor = true;
0212       isTau = false;
0213       break;
0214     case 2:
0215       isFor = false;
0216       isTau = true;
0217       break;
0218     default:
0219       throw cms::Exception("L1DummyProducerInvalidType")
0220           << "L1DummyProducer::SimpleDigi production of L1GctJetCandCollection "
0221           << " invalid type: " << type << std::endl;
0222   }
0223 
0224   int energy = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0225   unsigned rank = energy & 0x3f;
0226   unsigned phi = (unsigned)(18 * engine->flat());
0227   unsigned eta = (unsigned)(7 * engine->flat());
0228   if (engine->flat() > 0.5)  //-z (eta sign)
0229     eta = (eta & 0x7) + (0x1 << 3);
0230   L1GctJetCand cand(rank, phi, eta, isTau, isFor);
0231   data->push_back(cand);
0232   //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor);
0233   if (verbose())
0234     std::cout << "L1DummyProducer::SimpleDigi<L1GctJetCandCollection> end.\n" << std::flush;
0235 }
0236 
0237 template <>
0238 inline void L1DummyProducer::SimpleDigi(int,
0239                                         CLHEP::HepRandomEngine* engine,
0240                                         std::unique_ptr<L1MuRegionalCandCollection>& data,
0241                                         int type) const {
0242   if (verbose())
0243     std::cout << "L1DummyProducer::SimpleDigi<L1MuRegionalCandCollection>....\n" << std::flush;
0244   //typedef std::vector<L1MuRegionalCand>     L1MuRegionalCandCollection;
0245   assert(type >= 0 && type < 4);
0246   unsigned type_idx = type;  //tType: 0 DT, 1 bRPC, 2 CSC, 3 fRPC
0247   int bx = 0;
0248   unsigned phi, eta, pt, charge, ch_valid, finehalo, quality;
0249   float phiv(0.), etav(0.), ptv(0.);  //linear translation? 0.2pi,-2.5..2.5,0..100
0250   for (int i = 0; i < 4; i++) {
0251     phi = (int)(144 * engine->flat());  //8bits, 0..143
0252     eta = (int)(63 * engine->flat());   //6bits code
0253     phiv = phi * 2 * TMath::Pi() / 144.;
0254     etav = 2.5 * (-1 + 2 * eta / 63.);
0255     pt = ((int)(32 * engine->flat())) & 0x1f;  //5bits: 0..31
0256     ptv = 100 * (pt / 31.);
0257     charge = (engine->flat() > 0.5 ? 0 : 1);
0258     ;
0259     ch_valid = 0;
0260     finehalo = 0;
0261     quality = (int)(8 * engine->flat());  //3bits: 0..7
0262     L1MuRegionalCand cand(type_idx, phi, eta, pt, charge, ch_valid, finehalo, quality, bx);
0263     cand.setPhiValue(phiv);
0264     cand.setEtaValue(etav);
0265     cand.setPtValue(ptv);
0266     data->push_back(cand);
0267   }
0268   //L1MuRegionalCand(unsigned type_idx, unsigned phi, unsigned eta, unsigned pt,
0269   //unsigned charge, unsigned ch_valid, unsigned finehalo, unsigned quality, int bx);
0270   if (verbose())
0271     std::cout << "L1DummyProducer::SimpleDigi<L1MuRegionalCandCollection> end.\n" << std::flush;
0272 }
0273 
0274 template <>
0275 inline void L1DummyProducer::SimpleDigi(int nevt,
0276                                         CLHEP::HepRandomEngine* engine,
0277                                         std::unique_ptr<L1MuDTTrackContainer>& data,
0278                                         int type) const {
0279   assert(type == 0);
0280   int type_idx = type;  //choose data type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC
0281   if (verbose())
0282     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTTrackContainer>....\n" << std::flush;
0283   std::unique_ptr<L1MuRegionalCandCollection> tracks(new L1MuRegionalCandCollection());
0284   SimpleDigi(nevt, engine, tracks, type_idx);
0285   typedef std::vector<L1MuDTTrackCand> L1MuDTTrackCandCollection;
0286   std::unique_ptr<L1MuDTTrackCandCollection> tracksd(new L1MuDTTrackCandCollection());
0287   for (L1MuRegionalCandCollection::const_iterator it = tracks->begin(); it != tracks->end(); it++) {
0288     L1MuDTTrackCand* cnd = new L1MuDTTrackCand();
0289     cnd->setDataWord(it->getDataWord());
0290     cnd->setBx(it->bx());
0291     tracksd->push_back(L1MuDTTrackCand());
0292     tracksd->push_back(*cnd);
0293   }
0294   data->setContainer(*tracksd);
0295   if (verbose())
0296     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTTrackContainer> end.\n" << std::flush;
0297   //L1MuDTTrackCand( unsigned dataword, int bx, int uwh, int usc, int utag,
0298   //                 int adr1, int adr2, int adr3, int adr4, int utc );
0299 }
0300 
0301 template <>
0302 inline void L1DummyProducer::SimpleDigi(int,
0303                                         CLHEP::HepRandomEngine* engine,
0304                                         std::unique_ptr<L1MuDTChambPhContainer>& data,
0305                                         int type) const {
0306   if (verbose())
0307     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambPhContainer>....\n" << std::flush;
0308   typedef std::vector<L1MuDTChambPhDigi> Phi_Container;
0309   int ntrk = 4;
0310   Phi_Container tracks(ntrk);
0311   int ubx, uwh, usc, ust, uphr, uphb, uqua, utag, ucnt;
0312   for (int i = 0; i < ntrk; i++) {
0313     ubx = 0;                               //bxNum()  - bx
0314     uwh = (int)(-2 + 5 * engine->flat());  //whNum()  - wheel
0315     usc = (int)(12 * engine->flat());      //scNum()  - sector
0316     ust = (int)(1. + 4 * engine->flat());  //stNum()  - station
0317     uphr = 0;                              //phi()    - radialAngle
0318     uphb = 0;                              //phiB()   - bendingAngle
0319     uqua = (int)(8 * engine->flat());      //code()   - qualityCode
0320     utag = 0;                              //Ts2Tag() - Ts2TagCode
0321     ucnt = 0;                              //BxCnt()  - BxCntCode
0322 
0323     L1MuDTChambPhDigi cand(ubx, uwh, usc, ust, uphr, uphb, uqua, utag, ucnt);
0324     tracks.push_back(cand);
0325   }
0326   data->setContainer(tracks);
0327   //L1MuDTChambPhDigi( int ubx, int uwh, int usc, int ust,
0328   //    int uphr, int uphb, int uqua, int utag, int ucnt );
0329   if (verbose())
0330     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambPhContainer> end.\n" << std::flush;
0331 }
0332 
0333 template <>
0334 inline void L1DummyProducer::SimpleDigi(int,
0335                                         CLHEP::HepRandomEngine* engine,
0336                                         std::unique_ptr<L1MuDTChambThContainer>& data,
0337                                         int type) const {
0338   if (verbose())
0339     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambThContainer>....\n" << std::flush;
0340   typedef std::vector<L1MuDTChambThDigi> The_Container;
0341   int ntrk = 4;
0342   The_Container tracks(ntrk);
0343   int ubx, uwh, usc, ust, uos[7], uqa[7];
0344   for (int i = 0; i < ntrk; i++) {
0345     ubx = 0;
0346     uwh = (int)(-2 + 5 * engine->flat());
0347     usc = (int)(12 * engine->flat());
0348     ust = (int)(1. + 4 * engine->flat());
0349     for (int j = 0; j < 7; j++) {
0350       uos[j] = (engine->flat() > 0.5 ? 0 : 1);
0351       uqa[j] = (engine->flat() > 0.5 ? 0 : 1);
0352     }
0353     L1MuDTChambThDigi cand(ubx, uwh, usc, ust, uos, uqa);
0354     tracks.push_back(cand);
0355   }
0356   data->setContainer(tracks);
0357   //L1MuDTChambThDigi( int ubx, int uwh, int usc, int ust,
0358   //             int* uos, [int* uqual] );
0359   //"DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0360   if (verbose())
0361     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambThContainer> end.\n" << std::flush;
0362 }
0363 
0364 template <>
0365 inline void L1DummyProducer::SimpleDigi(int nevt,
0366                                         CLHEP::HepRandomEngine* engine,
0367                                         std::unique_ptr<L1MuGMTCandCollection>& data,
0368                                         int type) const {
0369   if (verbose())
0370     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTCandCollection>....\n" << std::flush;
0371   //typedef std::vector<L1MuGMTCand>          L1MuGMTCandCollection;
0372   L1MuGMTCand cand(0, nevt);
0373   //cand.setPhiPacked();//8bits
0374   //cand.setPtPacked ();//5bits
0375   //cand.setQuality  ();//3bits
0376   //cand.setEtaPacked();//6bits
0377   //cand.setIsolation();//1bit
0378   //cand.setMIP      ();//1bit
0379   //cand.setChargePacked();//0:+, 1:-, 2:undef, 3:sync
0380   //cand.setBx       (nevt);
0381   //set physical values
0382   double eng = EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine);
0383   double phi = 2 * TMath::Pi() * engine->flat();
0384   double eta = 2.5 * (-1 + 2 * engine->flat());
0385   cand.setPtValue(eng);
0386   cand.setPhiValue(phi);
0387   cand.setEtaValue(eta);
0388   unsigned engp = (unsigned)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0389   unsigned phip = (unsigned)(255 * engine->flat());
0390   unsigned etap = (unsigned)(63 * engine->flat());
0391   cand.setPtPacked(engp & 0x1f);
0392   cand.setPhiPacked(phip & 0x7f);
0393   cand.setEtaPacked(etap & 0x3f);
0394   double r = engine->flat();
0395   cand.setIsolation(r > 0.2);
0396   cand.setMIP(r > 0.7);
0397   cand.setChargePacked(r > 0.5 ? 0 : 1);
0398   cand.setBx(0);
0399   data->push_back(cand);
0400   if (verbose())
0401     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTCandCollection> end.\n" << std::flush;
0402 }
0403 
0404 template <>
0405 inline void L1DummyProducer::SimpleDigi(int nevt,
0406                                         CLHEP::HepRandomEngine* engine,
0407                                         std::unique_ptr<L1MuGMTReadoutCollection>& data,
0408                                         int type) const {
0409   if (verbose())
0410     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTReadoutCollection>....\n" << std::flush;
0411   L1MuGMTReadoutRecord rec(0);
0412   int bxn = nevt;
0413   rec.setBxNr(bxn);
0414   rec.setEvNr(bxn);
0415   rec.setBxInEvent(0);
0416   std::unique_ptr<L1MuRegionalCandCollection> trks_dttf(new L1MuRegionalCandCollection);
0417   std::unique_ptr<L1MuRegionalCandCollection> trks_rpcb(new L1MuRegionalCandCollection);
0418   std::unique_ptr<L1MuRegionalCandCollection> trks_csc(new L1MuRegionalCandCollection);
0419   std::unique_ptr<L1MuRegionalCandCollection> trks_rpcf(new L1MuRegionalCandCollection);
0420   SimpleDigi(nevt, engine, trks_dttf, 0);
0421   SimpleDigi(nevt, engine, trks_rpcb, 1);
0422   SimpleDigi(nevt, engine, trks_csc, 2);
0423   SimpleDigi(nevt, engine, trks_rpcf, 3);
0424   for (int i = 0; i < 4; i++) {
0425     rec.setInputCand(i, trks_dttf->at(i));       //dt  : 0..3
0426     rec.setInputCand(i + 4, trks_rpcb->at(i));   //rpcb: 4..7
0427     rec.setInputCand(i + 8, trks_csc->at(i));    //csc : 8..11
0428     rec.setInputCand(i + 12, trks_rpcf->at(i));  //rpcf:12..15
0429   }
0430   for (int nr = 0; nr < 4; nr++) {
0431     int eng = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0432     rec.setGMTBrlCand(nr, eng & 0x11, eng & 0x11);  //set GMT barrel candidate
0433     rec.setGMTFwdCand(nr, eng & 0x11, eng & 0x11);  //set GMT forward candidate
0434     rec.setGMTCand(nr, eng & 0x11);                 //set GMT candidate (does not store rank)
0435     int eta = (int)(14 * engine->flat());           //0..13
0436     int phi = (int)(18 * engine->flat());           //0..17
0437     rec.setMIPbit(eta, phi);
0438     rec.setQuietbit(eta, phi);
0439   }
0440   data->addRecord(rec);
0441   ///tbd: add GMT extended cand(!)
0442   //rec.setBCERR(int bcerr);
0443   //rec.setGMTBrlCand(int nr, L1MuGMTExtendedCand const& cand);
0444   //rec.setGMTFwdCand(int nr, L1MuGMTExtendedCand const& cand);
0445   //rec.setGMTCand   (int nr, L1MuGMTExtendedCand const& cand);
0446   //rec.setInputCand (int nr, L1MuRegionalCand const& cand);
0447   //L1MuGMTReadoutCollection :: std::vector<L1MuGMTReadoutRecord> m_Records;
0448   //L1MuGMTReadoutCollection(int nbx) { m_Records.reserve(nbx); };
0449   //L1MuGMTExtendedCand(unsigned data, unsigned rank, int bx=0) : L1MuGMTCand (data, bx), m_rank(rank) {}
0450   if (verbose())
0451     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTReadoutCollection> end.\n" << std::flush;
0452 }
0453 
0454 template <>
0455 inline void L1DummyProducer::SimpleDigi(int,
0456                                         CLHEP::HepRandomEngine*,
0457                                         std::unique_ptr<LTCDigiCollection>& data,
0458                                         int type) const {
0459   if (verbose())
0460     std::cout << "L1DummyProducer::SimpleDigi<LTCDigiCollection>....\n" << std::flush;
0461   //LTCs are FED id 816-823
0462   /*  
0463       6 64-bit words
0464       uint64_t *ld = (uint64_t*)data;
0465       
0466       word0: 59:56  4 bit    ld[0]>>56 & 0xf         trigType
0467              55:32 24 bit    ld[0]>>32 & 0x00ffffff  eventID
0468              31:20 12 bit    ld[0]>>20 & 0xfff       bunchNumber
0469              19: 8 12 bit    ld[0]>> 8 & 0x00000fff  sourceID (816-823?)
0470 
0471       word1: 63:32 32 bit    ld[1]>>32 & 0xffffffff  orbitNumber
0472              31:24 8 bit     ld[1]>>24 & 0xff        versionNumber
0473               3: 0 4 bit     ld[1      & 0xf         daqPartition  
0474 
0475       word2: 63:32 32 bit    ld[0]>>32 & 0xffffffff  runNumber
0476              31: 0 32 bit    ld[0]     & 0xffffffff  eventNumber
0477 
0478       word3: 63:32 32 bit    ld[3]>>32 & 0xffffffff  trigInhibitNumber
0479              31: 0 32 bit    ld[3]     & 0xffffffff  trigInputStat  
0480 
0481       word4: 63:0 64 bit     ld[4]                   bstGpsTime
0482 
0483       word5: (empty)
0484   */
0485   //need to make up something meaningfull to produce here..
0486   //LTCDigi(const unsigned char* data);
0487   if (verbose())
0488     std::cout << "L1DummyProducer::SimpleDigi<LTCDigiCollection> end.\n" << std::flush;
0489 }
0490 
0491 template <>
0492 inline void L1DummyProducer::SimpleDigi(int,
0493                                         CLHEP::HepRandomEngine* engine,
0494                                         std::unique_ptr<CSCCorrelatedLCTDigiCollection>& data,
0495                                         int type) const {
0496   if (verbose())
0497     std::cout << "L1DummyProducer::SimpleDigi<CSCCorrelatedLCTDigiCollection>....\n" << std::flush;
0498   //typedef MuonDigiCollection<CSCDetId,CSCCorrelatedLCTDigi> CSCCorrelatedLCTDigiCollection;
0499   //CSCCorrelatedLCTDigi(const int trknmb, const int valid, const int quality, const int keywire, const int strip, const int clct_pattern, const int bend, const int bx, const int& mpclink = 0, const uint16_t & bx0=0, const uint16_t & syncErr = 0, const uint16_t & cscID=0);
0500   CSCCorrelatedLCTDigi dg = CSCCorrelatedLCTDigi();
0501   //tbd: set non-trivial random values
0502   dg.clear();  // set contents to zero
0503   //CSCDetId( int iendcap, int istation, int iring, int ichamber, int ilayer = 0 );
0504   static constexpr int MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1;
0505   static constexpr int MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6;
0506 
0507   float rnd = engine->flat();
0508   int ec = (int)(MIN_ENDCAP + (MAX_ENDCAP - MIN_ENDCAP) * rnd + 1);
0509   int st = (int)(MIN_STATION + (MAX_STATION - MIN_STATION) * rnd + 1);
0510   int rg = (int)(MIN_RING + (MAX_RING - MIN_RING) * rnd + 1);
0511   int ch = (int)(MIN_CHAMBER + (MAX_CHAMBER - MIN_CHAMBER) * rnd + 1);
0512   int lr = (int)(MIN_LAYER + (MAX_LAYER - MIN_LAYER) * rnd + 1);
0513   CSCDetId did = CSCDetId(ec, st, rg, ch, lr);
0514   //CSCDetId did = CSCDetId();   //DetId(DetId::Muon, MuonSubdetId::CSC)
0515   //MuonDigiCollection::insertDigi(const IndexType& index, const DigiType& digi)
0516   data->insertDigi(did, dg);
0517   if (verbose())
0518     std::cout << "L1DummyProducer::SimpleDigi<CSCCorrelatedLCTDigiCollection> end.\n" << std::flush;
0519 }
0520 
0521 template <>
0522 inline void L1DummyProducer::SimpleDigi(int nevt,
0523                                         CLHEP::HepRandomEngine* engine,
0524                                         std::unique_ptr<L1CSCTrackCollection>& data,
0525                                         int type) const {
0526   if (verbose())
0527     std::cout << "L1DummyProducer::SimpleDigi<L1CSCTrackCollection>...\n" << std::flush;
0528   std::unique_ptr<CSCCorrelatedLCTDigiCollection> dgcoll(new CSCCorrelatedLCTDigiCollection);
0529   SimpleDigi(nevt, engine, dgcoll, 0);
0530   csc::L1Track l1trk = csc::L1Track();
0531   std::unique_ptr<L1MuRegionalCandCollection> regcoll(new L1MuRegionalCandCollection);
0532   SimpleDigi(nevt, engine, regcoll, 2);
0533   L1MuRegionalCand regcand = *(regcoll->begin());
0534   l1trk.setDataWord(regcand.getDataWord());
0535   l1trk.setBx(regcand.bx());
0536   l1trk.setPhiValue(regcand.phiValue());
0537   l1trk.setEtaValue(regcand.etaValue());
0538   l1trk.setPtValue(regcand.ptValue());
0539   L1CSCTrack l1csctrk = std::make_pair(l1trk, *dgcoll);
0540   data->push_back(l1csctrk);
0541   //typedef std::vector<L1CSCTrack> L1CSCTrackCollection;
0542   //typedef std::pair<csc::L1Track,CSCCorrelatedLCTDigiCollection> L1CSCTrack;
0543   //L1Track() : L1MuRegionalCand(), m_name("csc::L1Track") { setType(2); setPtPacked(0); }
0544   //L1MuRegionalCand(unsigned dataword = 0, int bx = 0);
0545   if (verbose())
0546     std::cout << "L1DummyProducer::SimpleDigi<L1CSCTrackCollection> end.\n" << std::flush;
0547 }
0548 
0549 #endif