CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
L1RCTSaveInput Class Reference

#include <L1RCTSaveInput.h>

Inheritance diagram for L1RCTSaveInput:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 L1RCTSaveInput (const edm::ParameterSet &)
 
 ~L1RCTSaveInput () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::InputTag ecalDigisLabel
 
std::string fileName
 
edm::InputTag hcalDigisLabel
 
std::ofstream ofs
 
L1RCTrct
 
L1RCTLookupTablesrctLookupTables
 
bool useDebugTpgScales
 
bool useEcal
 
bool useHcal
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

src/L1RCTSaveInput/src/L1RCTSaveInput.cc

Description: Saves the input event from TPGs for loading simulated events in hardware

Implementation: Kind of kludgy – should think of a better way in future

Definition at line 39 of file L1RCTSaveInput.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file L1RCTSaveInput.cc.

References MessageLogger_cfi::cerr, cmsRelvalreport::exit, fileName, and ofs.

46  : fileName(conf.getUntrackedParameter<std::string>("rctTestInputFile")),
48  useEcal(conf.getParameter<bool>("useEcal")),
49  useHcal(conf.getParameter<bool>("useHcal")),
50  ecalDigisLabel(conf.getParameter<edm::InputTag>("ecalDigisLabel")),
51  hcalDigisLabel(conf.getParameter<edm::InputTag>("hcalDigisLabel")),
52  useDebugTpgScales(conf.getParameter<bool>("useDebugTpgScales")) {
53  ofs.open(fileName.c_str(), std::ios::app);
54  if (!ofs) {
55  std::cerr << "Could not create " << fileName << std::endl;
56  exit(1);
57  }
58 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag ecalDigisLabel
L1RCTLookupTables * rctLookupTables
std::string fileName
std::ofstream ofs
Definition: L1RCT.h:20
edm::InputTag hcalDigisLabel
L1RCTSaveInput::~L1RCTSaveInput ( )
override

Definition at line 60 of file L1RCTSaveInput.cc.

References rct, and rctLookupTables.

60  {
61  if (rct != nullptr)
62  delete rct;
63  if (rctLookupTables != nullptr)
64  delete rctLookupTables;
65 }
L1RCTLookupTables * rctLookupTables

Member Function Documentation

void L1RCTSaveInput::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
override

Definition at line 67 of file L1RCTSaveInput.cc.

References EnergyCorrector::c, gather_cfg::cout, TauDecayModes::dec, L1RCT::digiInput(), MillePedeFileConverter_cfg::e, digitizers_cfi::ecal, EcalBarrel, L1RCT::ecalCompressedET(), ecalDigisLabel, EcalEndcap, L1RCT::ecalFineGrainBit(), edm::EventSetup::get(), EcalTPGScale::getTPGInGeV(), h, digitizers_cfi::hcal, L1RCT::hcalCompressedET(), hcalDigisLabel, CaloTPGTranscoder::hcaletValue(), L1RCT::hcalFineGrainBit(), edm::HandleBase::isValid(), L1RCTLookupTables::lookup(), L1CaloEcalScale::nBinEta, L1CaloHcalScale::nBinEta, L1CaloEcalScale::nBinRank, L1CaloHcalScale::nBinRank, nEvents, ofs, edm::ESHandle< T >::product(), alignCSCRings::r, rct, rctLookupTables, alignCSCRings::s, L1CaloHcalScale::setBin(), L1CaloEcalScale::setBin(), L1RCTLookupTables::setChannelMask(), L1RCTLookupTables::setEcalScale(), EcalTPGScale::setEventSetup(), L1RCTLookupTables::setHcalScale(), L1RCTLookupTables::setL1CaloEtScale(), L1RCTLookupTables::setRCTParameters(), and useDebugTpgScales.

68  {
69  edm::ESHandle<L1RCTParameters> rctParameters;
70  eventSetup.get<L1RCTParametersRcd>().get(rctParameters);
71  const L1RCTParameters *r = rctParameters.product();
73  eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask);
74  const L1RCTChannelMask *c = channelMask.product();
76  eventSetup.get<L1EmEtScaleRcd>().get(emScale);
77  const L1CaloEtScale *s = emScale.product();
78 
82 
83  if (useDebugTpgScales) {
84  // use old-style scales
86  eventSetup.get<CaloTPGRecord>().get(transcoder);
87  const CaloTPGTranscoder *h_tpg = transcoder.product();
88 
89  EcalTPGScale *e_tpg = new EcalTPGScale();
90  e_tpg->setEventSetup(eventSetup);
91 
92  L1CaloEcalScale *ecalScale = new L1CaloEcalScale();
93  L1CaloHcalScale *hcalScale = new L1CaloHcalScale();
94 
95  // create input scales, werner's code
96  // ECAL
97  std::cout << "ECAL Pos " << L1CaloEcalScale::nBinRank << std::endl;
98  for (unsigned short ieta = 1; ieta <= L1CaloEcalScale::nBinEta; ++ieta) {
99  for (unsigned short irank = 0; irank < L1CaloEcalScale::nBinRank;
100  ++irank) {
101  std::cout << ieta << " " << irank;
102  EcalSubdetector subdet = (ieta <= 17) ? EcalBarrel : EcalEndcap;
103  double etGeVPos =
104  e_tpg->getTPGInGeV(irank, EcalTrigTowerDetId(1, // +ve eta
105  subdet, ieta,
106  1)); // dummy phi value
107  ecalScale->setBin(irank, ieta, 1, etGeVPos);
108  std::cout << etGeVPos << ", ";
109  }
110  std::cout << std::endl;
111  }
112  std::cout << std::endl;
113 
114  std::cout << "ECAL Neg" << std::endl;
115  for (unsigned short ieta = 1; ieta <= L1CaloEcalScale::nBinEta; ++ieta) {
116  for (unsigned short irank = 0; irank < L1CaloEcalScale::nBinRank;
117  ++irank) {
118  EcalSubdetector subdet = (ieta <= 17) ? EcalBarrel : EcalEndcap;
119 
120  std::cout << ieta << " " << irank;
121  double etGeVNeg =
122  e_tpg->getTPGInGeV(irank,
123  EcalTrigTowerDetId(-1, // -ve eta
124  subdet, ieta,
125  2)); // dummy phi value
126  ecalScale->setBin(irank, ieta, -1, etGeVNeg);
127  std::cout << etGeVNeg << ", ";
128  }
129  std::cout << std::endl;
130  }
131  std::cout << std::endl;
132 
133  // HCAL
134  std::cout << "HCAL" << std::endl;
135  for (unsigned short ieta = 1; ieta <= L1CaloHcalScale::nBinEta; ++ieta) {
136  for (unsigned short irank = 0; irank < L1CaloHcalScale::nBinRank;
137  ++irank) {
138  double etGeV = h_tpg->hcaletValue(ieta, irank);
139 
140  hcalScale->setBin(irank, ieta, 1, etGeV);
141  hcalScale->setBin(irank, ieta, -1, etGeV);
142  std::cout << etGeV << ", ";
143  std::cout << std::endl;
144  }
145  std::cout << std::endl;
146  }
147 
148  // set the input scales
149  rctLookupTables->setEcalScale(ecalScale);
150  rctLookupTables->setHcalScale(hcalScale);
151 
152  delete e_tpg;
153 
154  } else {
156  eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
157  const L1CaloHcalScale *h = hcalScale.product();
159  eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
160  const L1CaloEcalScale *e = ecalScale.product();
161 
164  }
165 
168  event.getByLabel(ecalDigisLabel, ecal);
169  event.getByLabel(hcalDigisLabel, hcal);
172  if (ecal.isValid()) {
173  ecalColl = *ecal;
174  }
175  if (hcal.isValid()) {
176  hcalColl = *hcal;
177  }
178  rct->digiInput(ecalColl, hcalColl);
179  static int nEvents = 0;
180  if (nEvents == 0) {
181  ofs << "Crate = 0-17" << std::endl
182  << "Card = 0-7 within the crate" << std::endl
183  << "Tower = 0-31 covers 4 x 8 covered by the card" << std::endl
184  << "EMAddr(0:8) = EMFGBit(0:0)+CompressedEMET(1:8)" << std::endl
185  << "HDAddr(0:8) = HDFGBit(0:0)+CompressedHDET(1:8) - note: "
186  "HDFGBit(0:0) is not part of the hardware LUT address"
187  << std::endl
188  << "LutOut(0:17)= "
189  "LinearEMET(0:6)+HoEFGVetoBit(7:7)+LinearJetET(8:16)+ActivityBit(17:"
190  "17)"
191  << std::endl
192  << "Event"
193  << "\t"
194  << "Crate"
195  << "\t"
196  << "Card"
197  << "\t"
198  << "Tower"
199  << "\t"
200  << "EMAddr"
201  << "\t"
202  << "HDAddr"
203  << "\t"
204  << "LUTOut" << std::endl;
205  }
206  if (nEvents < 64) {
207  for (unsigned short iCrate = 0; iCrate < 18; iCrate++) {
208  for (unsigned short iCard = 0; iCard < 7; iCard++) {
209  // tower numbered from 0-31
210  for (unsigned short iTower = 0; iTower < 32; iTower++) {
211  unsigned short ecal = rct->ecalCompressedET(iCrate, iCard, iTower);
212  unsigned short hcal = rct->hcalCompressedET(iCrate, iCard, iTower);
213  unsigned short fgbit = rct->ecalFineGrainBit(iCrate, iCard, iTower);
214  unsigned short mubit = rct->hcalFineGrainBit(iCrate, iCard, iTower);
215  unsigned long lutOutput =
216  rctLookupTables->lookup(ecal, hcal, fgbit, iCrate, iCard, iTower);
217  ofs << std::hex << nEvents << "\t" << iCrate << "\t" << iCard << "\t"
218  << iTower << "\t" << ecal * 2 + fgbit << "\t" << hcal * 2 + mubit
219  << "\t" << lutOutput << std::dec << std::endl;
220  }
221  }
222  }
223  }
224  nEvents++;
225 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
unsigned short hcalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:74
edm::InputTag ecalDigisLabel
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
L1RCTLookupTables * rctLookupTables
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
unsigned short hcalFineGrainBit(int crate, int card, int tower)
Definition: L1RCT.h:77
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
void setHcalScale(const L1CaloHcalScale *hcalScale)
unsigned short ecalFineGrainBit(int crate, int card, int tower)
Definition: L1RCT.h:71
unsigned short ecalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:68
static const unsigned short nBinRank
bool isValid() const
Definition: HandleBase.h:74
void setL1CaloEtScale(const L1CaloEtScale *etScale)
std::ofstream ofs
void setEcalScale(const L1CaloEcalScale *ecalScale)
void setRCTParameters(const L1RCTParameters *rctParameters)
static const unsigned short nBinRank
void digiInput(const EcalTrigPrimDigiCollection &ecalCollection, const HcalTrigPrimDigiCollection &hcalCollection)
Definition: L1RCT.cc:109
T get() const
Definition: EventSetup.h:71
static const unsigned short nBinEta
static const unsigned short nBinEta
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
UInt_t nEvents
Definition: hcalCalib.cc:41
EcalSubdetector
T const * product() const
Definition: ESHandle.h:86
void setChannelMask(const L1RCTChannelMask *channelMask)
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
edm::InputTag hcalDigisLabel

Member Data Documentation

edm::InputTag L1RCTSaveInput::ecalDigisLabel
private

Definition at line 51 of file L1RCTSaveInput.h.

Referenced by analyze().

std::string L1RCTSaveInput::fileName
private

Definition at line 46 of file L1RCTSaveInput.h.

Referenced by L1RCTSaveInput().

edm::InputTag L1RCTSaveInput::hcalDigisLabel
private

Definition at line 52 of file L1RCTSaveInput.h.

Referenced by analyze().

std::ofstream L1RCTSaveInput::ofs
private

Definition at line 54 of file L1RCTSaveInput.h.

Referenced by analyze(), and L1RCTSaveInput().

L1RCT* L1RCTSaveInput::rct
private

Definition at line 48 of file L1RCTSaveInput.h.

Referenced by analyze(), and ~L1RCTSaveInput().

L1RCTLookupTables* L1RCTSaveInput::rctLookupTables
private

Definition at line 47 of file L1RCTSaveInput.h.

Referenced by analyze(), and ~L1RCTSaveInput().

bool L1RCTSaveInput::useDebugTpgScales
private

Definition at line 53 of file L1RCTSaveInput.h.

Referenced by analyze().

bool L1RCTSaveInput::useEcal
private

Definition at line 49 of file L1RCTSaveInput.h.

bool L1RCTSaveInput::useHcal
private

Definition at line 50 of file L1RCTSaveInput.h.