CMS 3D CMS Logo

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

#include <RctInputTextToDigi.h>

Inheritance diagram for RctInputTextToDigi:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RctInputTextToDigi (const edm::ParameterSet &)
 
 ~RctInputTextToDigi () 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 Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::FileInPath inputFile_
 
std::ifstream inputStream_
 
L1RCTLookupTableslookupTables_
 
int nEvent_
 
bool oldVersion_
 
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcdparamsToken_
 

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

L1Trigger/TextToDigi/plugins/RctInputTextToDigi.h

Description: Creates an EcalTrigPrimDigiCollection and an HcalTrigPrimDigiCollection from a text file (formatted as read out from saveRCTInput module), for input to the L1Trigger/RegionalCaloTrigger module.

Definition at line 50 of file RctInputTextToDigi.h.

Constructor & Destructor Documentation

◆ RctInputTextToDigi()

RctInputTextToDigi::RctInputTextToDigi ( const edm::ParameterSet iConfig)
explicit

Definition at line 7 of file RctInputTextToDigi.cc.

References DMR_cfg::cerr, and inputStream_.

8  : inputFile_(iConfig.getParameter<edm::FileInPath>("inputFile")),
12  nEvent_(0),
13  oldVersion_(false) {
14  // register your products
15  /* Examples
16  produces<ExampleData2>();
17 
18  //if do put with a label
19  produces<ExampleData2>("label");
20  */
21 
22  produces<EcalTrigPrimDigiCollection>();
23  produces<HcalTrigPrimDigiCollection>();
24 
25  // now do what ever other initialization is needed
26 
27  if ((!inputStream_.is_open()) || (!inputStream_)) {
28  // not good!!
29  std::cerr << "Input file didn't open!!" << std::endl;
30  }
31  // if (inputStream_.eof()) {std::cout << "Real zeroth eof! " << std::endl;}
32 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string fullPath() const
Definition: FileInPath.cc:161
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcd > paramsToken_
L1RCTLookupTables * lookupTables_
edm::FileInPath inputFile_
std::ifstream inputStream_

◆ ~RctInputTextToDigi()

RctInputTextToDigi::~RctInputTextToDigi ( )
override

Definition at line 34 of file RctInputTextToDigi.cc.

References inputStream_.

34  {
35  // do anything here that needs to be done at desctruction time
36  // (e.g. close files, deallocate resources etc.)
37 
38  inputStream_.close();
39 }
std::ifstream inputStream_

Member Function Documentation

◆ beginJob()

void RctInputTextToDigi::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 196 of file RctInputTextToDigi.cc.

196  {
197  // open input file to read all events
198  // inputStream_.open(inputFile_.fullPath().c_str());
199  // std::cout << "beginJob entered" << std::endl;
200 }

◆ endJob()

void RctInputTextToDigi::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 204 of file RctInputTextToDigi.cc.

204  {
205  // close input file
206  // inputStream_.close();
207 }

◆ produce()

void RctInputTextToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 46 of file RctInputTextToDigi.cc.

References funct::abs(), nano_mu_local_reco_cff::bool, L1RCTParameters::calcIEta(), L1RCTParameters::calcIPhi(), gather_cfg::cout, FCDTask_cfi::crate, TauDecayModes::dec, EcalTriggerTower, edm::EventSetup::getData(), mps_fire::i, l1tPhase2CaloJetEmulator_cfi::iEta, iEvent, inputStream_, createfilelist::int, dqmiolumiharvest::j, lookupTables_, eostools::move(), nEvent_, oldVersion_, paramsToken_, alignCSCRings::r, L1RCTLookupTables::rctParameters(), L1RCTLookupTables::setRCTParameters(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), HcalTriggerPrimitiveDigi::setSize(), AlCaHLTBitMon_QueryRunRegistry::string, and l1tHGCalTowerProducer_cfi::tower.

46  {
47  using namespace edm;
48 
49  // std::cout << std::endl << std::endl << "Event number " << nEvent_ <<
50  // std::endl;
51 
52  // This next section taken directly from
53  // L1Trigger/RegionalCaloTrigger/plugins/L1RCTProducer.cc rev. 1.6
54  // Refresh configuration information every event
55  // Hopefully doesn't take too much time
56  const L1RCTParameters *r = &iSetup.getData(paramsToken_);
58 
59  std::unique_ptr<EcalTrigPrimDigiCollection> ecalTPs(new EcalTrigPrimDigiCollection());
60  std::unique_ptr<HcalTrigPrimDigiCollection> hcalTPs(new HcalTrigPrimDigiCollection());
61  ecalTPs->reserve(56 * 72);
62  hcalTPs->reserve(56 * 72 + 18 * 8); // includes HF
63  const int nEcalSamples = 1; // we only use 1 sample for each
64  const int nHcalSamples = 1;
65 
66  int fileEventNumber;
67 
68  // check to see if need to skip file header and do so before
69  // looping through entire event
70 
71  std::string junk;
72  // bool old_version = false;
73  if (nEvent_ == 0) {
74  // std::string junk;
75  unsigned short junk_counter = 0;
76  // bool old_version = false;
77  do {
78  if (inputStream_ >> junk) { /*std::cout << "Good: ";*/
79  }
80  // std::cout << "header junk was input: \"" << junk << "\"."
81  // << std::endl;
82  // for oldest version, which is same as newest version
83  // if((junk_counter == 11) && (junk.compare("0-32") == 0))
84  // {
85  // oldVersion_ = true;
86  // }
87  if ((junk_counter == 11) && (junk == "1-32")) {
88  oldVersion_ = true;
89  }
90  junk_counter++;
91  } while (junk != "LUTOut");
92  std::cout << "Skipped file header" << std::endl;
93  if (oldVersion_) {
94  std::cout << "oldVersion_ TRUE (tower 1-32)" << std::endl;
95  } else {
96  std::cout << "oldVersion_ FALSE (tower 0-31)" << std::endl;
97  }
98  }
99 
100  // can't actually read in phi and eta, file has crate card tower instead
101  // do a while loop for event number instead?? dunno
102  for (int i = 0; i < 72; i++) {
103  // negative eta, iEta -28 to -1
104  for (int j = 0; j < 56; j++) {
105  // calc ieta, iphi coords of tower
106  // ieta -28 to -1 or 1 to 28, iphi 1 to 72
107  // methods in CondFormats/L1TObjects/src/L1RCTParameters.cc
108 
109  unsigned short crate;
110  unsigned short card;
111  unsigned short tower;
112  unsigned eAddr;
113  unsigned hAddr;
114 
115  inputStream_ >> std::hex >> fileEventNumber >> crate >> card >> tower >> eAddr >> hAddr >> junk >> std::dec;
116 
117  if (oldVersion_) {
118  tower = tower - 1;
119  }
120  int encodedEtEcal = (int)(eAddr >> 1);
121  bool fineGrainEcal = (bool)(eAddr & 1);
122  int encodedEtHcal = (int)(hAddr >> 1);
123  bool fineGrainHcal = (bool)(hAddr & 1); // mip bit
124 
125  // std::cout << "Eventnumber " << fileEventNumber << "\tCrate "
126  // << crate << "\tCard " << card << "\tTower "
127  // << tower << " \teAddr " << eAddr <<"\thAddr "
128  // << hAddr << "\tjunk " << junk << std::endl;
129 
131  int iPhi = lookupTables_->rctParameters()->calcIPhi(crate, card, tower);
132  // transform rct iphi coords into global coords
133  iPhi = ((72 + 18 - iPhi) % 72);
134  if (iPhi == 0) {
135  iPhi = 72;
136  }
137  unsigned absIeta = abs(iEta);
138  int zSide = (iEta / absIeta);
139 
140  /*std::cout << "iEta " << iEta << "\tabsiEta " << absIeta
141  << "\tiPhi " << iPhi << "\tzSide "
142  << zSide << std::endl;
143  */
144 
145  // args to detid are zside, type of tower, absieta, iphi
146  // absieta and iphi must be between 1 and 127 inclusive
147 
148  EcalTriggerPrimitiveDigi ecalDigi(EcalTrigTowerDetId(zSide, EcalTriggerTower, absIeta, iPhi));
149  ecalDigi.setSize(nEcalSamples);
150 
151  // last arg is 3-bit trigger tower flag, which we don't use
152  // we only use 8-bit encoded et and 1-bit fg
153  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(encodedEtEcal, fineGrainEcal, 0));
154  // std::cout << ecalDigi << std::endl;
155  ecalTPs->push_back(ecalDigi);
156 
158 
159  hcalDigi.setSize(nHcalSamples);
160 
161  // last two arg's are slb and slb channel, which we don't need
162  hcalDigi.setSample(0, HcalTriggerPrimitiveSample(encodedEtHcal, fineGrainHcal, 0, 0));
163  // std::cout << hcalDigi << std::endl;
164  hcalTPs->push_back(hcalDigi);
165  }
166 
167  // also need to push_back HF digis!
168  // file input doesn't include HF, so need empty digis
169  for (int i = 0; i < 18; i++) {
170  for (int j = 0; j < 8; j++) {
171  // HF ieta: +- 29 through 32. HF iphi: 1,5,9,13,etc.
172  int hfIEta = (j % 4) + 29;
173  if (i < 9) {
174  hfIEta = hfIEta * (-1);
175  }
176  // iphi shift not implemented, but not necessary here --
177  // everything's filled with zeros so it's symmetric anyhow
178  int hfIPhi = (i % 9) * 8 + (j / 4) * 4 + 1;
179 
180  HcalTriggerPrimitiveDigi hfDigi(HcalTrigTowerDetId(hfIEta, hfIPhi));
181  hfDigi.setSize(1);
182  hfDigi.setSample(0, HcalTriggerPrimitiveSample(0, false, 0, 0));
183  hcalTPs->push_back(hfDigi);
184  }
185  }
186  }
187  iEvent.put(std::move(ecalTPs));
188  iEvent.put(std::move(hcalTPs));
189 
190  nEvent_++;
191  // std::cout << "Produce done" << std::endl;
192 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcd > paramsToken_
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const L1RCTParameters * rctParameters() const
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
L1RCTLookupTables * lookupTables_
std::ifstream inputStream_
void setRCTParameters(const L1RCTParameters *rctParameters)
HLT enums.
short calcIEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
def move(src, dest)
Definition: eostools.py:511
unsigned short calcIPhi(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const

Member Data Documentation

◆ inputFile_

edm::FileInPath RctInputTextToDigi::inputFile_
private

Definition at line 62 of file RctInputTextToDigi.h.

◆ inputStream_

std::ifstream RctInputTextToDigi::inputStream_
private

Definition at line 63 of file RctInputTextToDigi.h.

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

◆ lookupTables_

L1RCTLookupTables* RctInputTextToDigi::lookupTables_
private

Definition at line 64 of file RctInputTextToDigi.h.

Referenced by produce().

◆ nEvent_

int RctInputTextToDigi::nEvent_
private

Definition at line 66 of file RctInputTextToDigi.h.

Referenced by produce().

◆ oldVersion_

bool RctInputTextToDigi::oldVersion_
private

Definition at line 67 of file RctInputTextToDigi.h.

Referenced by produce().

◆ paramsToken_

edm::ESGetToken<L1RCTParameters, L1RCTParametersRcd> RctInputTextToDigi::paramsToken_
private

Definition at line 65 of file RctInputTextToDigi.h.

Referenced by produce().