Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:05

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 = 0;   //whNum()  - wheel
0315     usc = 0;   //scNum()  - sector
0316     ust = 0;   //stNum()  - station
0317     uphr = 0;  //phi()    - radialAngle
0318     uphb = 0;  //phiB()   - bendingAngle
0319     uqua = 0;  //code()   - qualityCode
0320     utag = 0;  //Ts2Tag() - Ts2TagCode
0321     ucnt = 0;  //BxCnt()  - BxCntCode
0322     uwh = (int)(-2 + 5 * engine->flat());
0323     usc = (int)(12 * engine->flat());
0324     ust = (int)(1. + 4 * engine->flat());
0325     uqua = (int)(8 * engine->flat());
0326     L1MuDTChambPhDigi cand(ubx, uwh, usc, ust, uphr, uphb, uqua, utag, ucnt);
0327     tracks.push_back(cand);
0328   }
0329   data->setContainer(tracks);
0330   //L1MuDTChambPhDigi( int ubx, int uwh, int usc, int ust,
0331   //    int uphr, int uphb, int uqua, int utag, int ucnt );
0332   if (verbose())
0333     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambPhContainer> end.\n" << std::flush;
0334 }
0335 
0336 template <>
0337 inline void L1DummyProducer::SimpleDigi(int,
0338                                         CLHEP::HepRandomEngine* engine,
0339                                         std::unique_ptr<L1MuDTChambThContainer>& data,
0340                                         int type) const {
0341   if (verbose())
0342     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambThContainer>....\n" << std::flush;
0343   typedef std::vector<L1MuDTChambThDigi> The_Container;
0344   int ntrk = 4;
0345   The_Container tracks(ntrk);
0346   int ubx, uwh, usc, ust, uos[7], uqa[7];
0347   for (int i = 0; i < ntrk; i++) {
0348     ubx = 0;
0349     uwh = (int)(-2 + 5 * engine->flat());
0350     usc = (int)(12 * engine->flat());
0351     ust = (int)(1. + 4 * engine->flat());
0352     for (int j = 0; j < 7; j++) {
0353       uos[j] = (engine->flat() > 0.5 ? 0 : 1);
0354       uqa[j] = (engine->flat() > 0.5 ? 0 : 1);
0355     }
0356     L1MuDTChambThDigi cand(ubx, uwh, usc, ust, uos, uqa);
0357     tracks.push_back(cand);
0358   }
0359   data->setContainer(tracks);
0360   //L1MuDTChambThDigi( int ubx, int uwh, int usc, int ust,
0361   //             int* uos, [int* uqual] );
0362   //"DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0363   if (verbose())
0364     std::cout << "L1DummyProducer::SimpleDigi<L1MuDTChambThContainer> end.\n" << std::flush;
0365 }
0366 
0367 template <>
0368 inline void L1DummyProducer::SimpleDigi(int nevt,
0369                                         CLHEP::HepRandomEngine* engine,
0370                                         std::unique_ptr<L1MuGMTCandCollection>& data,
0371                                         int type) const {
0372   if (verbose())
0373     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTCandCollection>....\n" << std::flush;
0374   //typedef std::vector<L1MuGMTCand>          L1MuGMTCandCollection;
0375   L1MuGMTCand cand(0, nevt);
0376   //cand.setPhiPacked();//8bits
0377   //cand.setPtPacked ();//5bits
0378   //cand.setQuality  ();//3bits
0379   //cand.setEtaPacked();//6bits
0380   //cand.setIsolation();//1bit
0381   //cand.setMIP      ();//1bit
0382   //cand.setChargePacked();//0:+, 1:-, 2:undef, 3:sync
0383   //cand.setBx       (nevt);
0384   //set physical values
0385   double eng = EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine);
0386   double phi = 2 * TMath::Pi() * engine->flat();
0387   double eta = 2.5 * (-1 + 2 * engine->flat());
0388   cand.setPtValue(eng);
0389   cand.setPhiValue(phi);
0390   cand.setEtaValue(eta);
0391   unsigned engp = (unsigned)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0392   unsigned phip = (unsigned)(255 * engine->flat());
0393   unsigned etap = (unsigned)(63 * engine->flat());
0394   cand.setPtPacked(engp & 0x1f);
0395   cand.setPhiPacked(phip & 0x7f);
0396   cand.setEtaPacked(etap & 0x3f);
0397   double r = engine->flat();
0398   cand.setIsolation(r > 0.2);
0399   cand.setMIP(r > 0.7);
0400   cand.setChargePacked(r > 0.5 ? 0 : 1);
0401   cand.setBx(0);
0402   data->push_back(cand);
0403   if (verbose())
0404     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTCandCollection> end.\n" << std::flush;
0405 }
0406 
0407 template <>
0408 inline void L1DummyProducer::SimpleDigi(int nevt,
0409                                         CLHEP::HepRandomEngine* engine,
0410                                         std::unique_ptr<L1MuGMTReadoutCollection>& data,
0411                                         int type) const {
0412   if (verbose())
0413     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTReadoutCollection>....\n" << std::flush;
0414   L1MuGMTReadoutRecord rec(0);
0415   int bxn = nevt;
0416   rec.setBxNr(bxn);
0417   rec.setEvNr(bxn);
0418   rec.setBxInEvent(0);
0419   std::unique_ptr<L1MuRegionalCandCollection> trks_dttf(new L1MuRegionalCandCollection);
0420   std::unique_ptr<L1MuRegionalCandCollection> trks_rpcb(new L1MuRegionalCandCollection);
0421   std::unique_ptr<L1MuRegionalCandCollection> trks_csc(new L1MuRegionalCandCollection);
0422   std::unique_ptr<L1MuRegionalCandCollection> trks_rpcf(new L1MuRegionalCandCollection);
0423   SimpleDigi(nevt, engine, trks_dttf, 0);
0424   SimpleDigi(nevt, engine, trks_rpcb, 1);
0425   SimpleDigi(nevt, engine, trks_csc, 2);
0426   SimpleDigi(nevt, engine, trks_rpcf, 3);
0427   for (int i = 0; i < 4; i++) {
0428     rec.setInputCand(i, trks_dttf->at(i));       //dt  : 0..3
0429     rec.setInputCand(i + 4, trks_rpcb->at(i));   //rpcb: 4..7
0430     rec.setInputCand(i + 8, trks_csc->at(i));    //csc : 8..11
0431     rec.setInputCand(i + 12, trks_rpcf->at(i));  //rpcf:12..15
0432   }
0433   for (int nr = 0; nr < 4; nr++) {
0434     int eng = (int)(EBase_ + ESigm_ * CLHEP::RandGaussQ::shoot(engine));
0435     rec.setGMTBrlCand(nr, eng & 0x11, eng & 0x11);  //set GMT barrel candidate
0436     rec.setGMTFwdCand(nr, eng & 0x11, eng & 0x11);  //set GMT forward candidate
0437     rec.setGMTCand(nr, eng & 0x11);                 //set GMT candidate (does not store rank)
0438     int eta = (int)(14 * engine->flat());           //0..13
0439     int phi = (int)(18 * engine->flat());           //0..17
0440     rec.setMIPbit(eta, phi);
0441     rec.setQuietbit(eta, phi);
0442   }
0443   data->addRecord(rec);
0444   ///tbd: add GMT extended cand(!)
0445   //rec.setBCERR(int bcerr);
0446   //rec.setGMTBrlCand(int nr, L1MuGMTExtendedCand const& cand);
0447   //rec.setGMTFwdCand(int nr, L1MuGMTExtendedCand const& cand);
0448   //rec.setGMTCand   (int nr, L1MuGMTExtendedCand const& cand);
0449   //rec.setInputCand (int nr, L1MuRegionalCand const& cand);
0450   //L1MuGMTReadoutCollection :: std::vector<L1MuGMTReadoutRecord> m_Records;
0451   //L1MuGMTReadoutCollection(int nbx) { m_Records.reserve(nbx); };
0452   //L1MuGMTExtendedCand(unsigned data, unsigned rank, int bx=0) : L1MuGMTCand (data, bx), m_rank(rank) {}
0453   if (verbose())
0454     std::cout << "L1DummyProducer::SimpleDigi<L1MuGMTReadoutCollection> end.\n" << std::flush;
0455 }
0456 
0457 template <>
0458 inline void L1DummyProducer::SimpleDigi(int,
0459                                         CLHEP::HepRandomEngine*,
0460                                         std::unique_ptr<LTCDigiCollection>& data,
0461                                         int type) const {
0462   if (verbose())
0463     std::cout << "L1DummyProducer::SimpleDigi<LTCDigiCollection>....\n" << std::flush;
0464   //LTCs are FED id 816-823
0465   /*  
0466       6 64-bit words
0467       uint64_t *ld = (uint64_t*)data;
0468       
0469       word0: 59:56  4 bit    ld[0]>>56 & 0xf         trigType
0470              55:32 24 bit    ld[0]>>32 & 0x00ffffff  eventID
0471              31:20 12 bit    ld[0]>>20 & 0xfff       bunchNumber
0472              19: 8 12 bit    ld[0]>> 8 & 0x00000fff  sourceID (816-823?)
0473 
0474       word1: 63:32 32 bit    ld[1]>>32 & 0xffffffff  orbitNumber
0475              31:24 8 bit     ld[1]>>24 & 0xff        versionNumber
0476               3: 0 4 bit     ld[1      & 0xf         daqPartition  
0477 
0478       word2: 63:32 32 bit    ld[0]>>32 & 0xffffffff  runNumber
0479              31: 0 32 bit    ld[0]     & 0xffffffff  eventNumber
0480 
0481       word3: 63:32 32 bit    ld[3]>>32 & 0xffffffff  trigInhibitNumber
0482              31: 0 32 bit    ld[3]     & 0xffffffff  trigInputStat  
0483 
0484       word4: 63:0 64 bit     ld[4]                   bstGpsTime
0485 
0486       word5: (empty)
0487   */
0488   //need to make up something meaningfull to produce here..
0489   //LTCDigi(const unsigned char* data);
0490   if (verbose())
0491     std::cout << "L1DummyProducer::SimpleDigi<LTCDigiCollection> end.\n" << std::flush;
0492 }
0493 
0494 template <>
0495 inline void L1DummyProducer::SimpleDigi(int,
0496                                         CLHEP::HepRandomEngine* engine,
0497                                         std::unique_ptr<CSCCorrelatedLCTDigiCollection>& data,
0498                                         int type) const {
0499   if (verbose())
0500     std::cout << "L1DummyProducer::SimpleDigi<CSCCorrelatedLCTDigiCollection>....\n" << std::flush;
0501   //typedef MuonDigiCollection<CSCDetId,CSCCorrelatedLCTDigi> CSCCorrelatedLCTDigiCollection;
0502   //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);
0503   CSCCorrelatedLCTDigi dg = CSCCorrelatedLCTDigi();
0504   //tbd: set non-trivial random values
0505   dg.clear();  // set contents to zero
0506   //CSCDetId( int iendcap, int istation, int iring, int ichamber, int ilayer = 0 );
0507   static constexpr int MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1;
0508   static constexpr int MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6;
0509 
0510   float rnd = engine->flat();
0511   int ec = (int)(MIN_ENDCAP + (MAX_ENDCAP - MIN_ENDCAP) * rnd + 1);
0512   int st = (int)(MIN_STATION + (MAX_STATION - MIN_STATION) * rnd + 1);
0513   int rg = (int)(MIN_RING + (MAX_RING - MIN_RING) * rnd + 1);
0514   int ch = (int)(MIN_CHAMBER + (MAX_CHAMBER - MIN_CHAMBER) * rnd + 1);
0515   int lr = (int)(MIN_LAYER + (MAX_LAYER - MIN_LAYER) * rnd + 1);
0516   CSCDetId did = CSCDetId(ec, st, rg, ch, lr);
0517   //CSCDetId did = CSCDetId();   //DetId(DetId::Muon, MuonSubdetId::CSC)
0518   //MuonDigiCollection::insertDigi(const IndexType& index, const DigiType& digi)
0519   data->insertDigi(did, dg);
0520   if (verbose())
0521     std::cout << "L1DummyProducer::SimpleDigi<CSCCorrelatedLCTDigiCollection> end.\n" << std::flush;
0522 }
0523 
0524 template <>
0525 inline void L1DummyProducer::SimpleDigi(int nevt,
0526                                         CLHEP::HepRandomEngine* engine,
0527                                         std::unique_ptr<L1CSCTrackCollection>& data,
0528                                         int type) const {
0529   if (verbose())
0530     std::cout << "L1DummyProducer::SimpleDigi<L1CSCTrackCollection>...\n" << std::flush;
0531   std::unique_ptr<CSCCorrelatedLCTDigiCollection> dgcoll(new CSCCorrelatedLCTDigiCollection);
0532   SimpleDigi(nevt, engine, dgcoll, 0);
0533   csc::L1Track l1trk = csc::L1Track();
0534   std::unique_ptr<L1MuRegionalCandCollection> regcoll(new L1MuRegionalCandCollection);
0535   SimpleDigi(nevt, engine, regcoll, 2);
0536   L1MuRegionalCand regcand = *(regcoll->begin());
0537   l1trk.setDataWord(regcand.getDataWord());
0538   l1trk.setBx(regcand.bx());
0539   l1trk.setPhiValue(regcand.phiValue());
0540   l1trk.setEtaValue(regcand.etaValue());
0541   l1trk.setPtValue(regcand.ptValue());
0542   L1CSCTrack l1csctrk = std::make_pair(l1trk, *dgcoll);
0543   data->push_back(l1csctrk);
0544   //typedef std::vector<L1CSCTrack> L1CSCTrackCollection;
0545   //typedef std::pair<csc::L1Track,CSCCorrelatedLCTDigiCollection> L1CSCTrack;
0546   //L1Track() : L1MuRegionalCand(), m_name("csc::L1Track") { setType(2); setPtPacked(0); }
0547   //L1MuRegionalCand(unsigned dataword = 0, int bx = 0);
0548   if (verbose())
0549     std::cout << "L1DummyProducer::SimpleDigi<L1CSCTrackCollection> end.\n" << std::flush;
0550 }
0551 
0552 #endif