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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RctInputTextToDigi (const edm::ParameterSet &)
 
 ~RctInputTextToDigi () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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.

8  : inputFile_(iConfig.getParameter<edm::FileInPath>("inputFile")),
10  nEvent_(0),
11  oldVersion_(false),
13  // register your products
14  /* Examples
15  produces<ExampleData2>();
16 
17  //if do put with a label
18  produces<ExampleData2>("label");
19  */
20 
21  produces<EcalTrigPrimDigiCollection>();
22  produces<HcalTrigPrimDigiCollection>();
23 
24  // now do what ever other initialization is needed
25 
26  if ((!inputStream_.is_open()) || (!inputStream_)) {
27  // not good!!
28  std::cerr << "Input file didn't open!!" << std::endl;
29  }
30  // if (inputStream_.eof()) {std::cout << "Real zeroth eof! " << std::endl;}
31 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, and inputStream_.

◆ ~RctInputTextToDigi()

RctInputTextToDigi::~RctInputTextToDigi ( )
override

Definition at line 33 of file RctInputTextToDigi.cc.

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

References inputStream_.

Member Function Documentation

◆ beginJob()

void RctInputTextToDigi::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 197 of file RctInputTextToDigi.cc.

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

◆ endJob()

void RctInputTextToDigi::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 205 of file RctInputTextToDigi.cc.

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

◆ produce()

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

Implements edm::EDProducer.

Definition at line 45 of file RctInputTextToDigi.cc.

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

References funct::abs(), electrons_cff::bool, L1RCTParameters::calcIEta(), L1RCTParameters::calcIPhi(), gather_cfg::cout, TauDecayModes::dec, EcalTriggerTower, edm::EventSetup::get(), get, mps_fire::i, L1TowerCalibrationProducer_cfi::iEta, iEvent, inputStream_, createfilelist::int, dqmiolumiharvest::j, lookupTables_, eostools::move(), nEvent_, oldVersion_, edm::ESHandle< T >::product(), alignCSCRings::r, L1RCTLookupTables::rctParameters(), L1RCTLookupTables::setRCTParameters(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), HcalTriggerPrimitiveDigi::setSize(), AlCaHLTBitMon_QueryRunRegistry::string, and hgcalTowerProducer_cfi::tower.

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 66 of file RctInputTextToDigi.h.

Referenced by produce().

◆ nEvent_

int RctInputTextToDigi::nEvent_
private

Definition at line 64 of file RctInputTextToDigi.h.

Referenced by produce().

◆ oldVersion_

bool RctInputTextToDigi::oldVersion_
private

Definition at line 65 of file RctInputTextToDigi.h.

Referenced by produce().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
RctInputTextToDigi::lookupTables_
L1RCTLookupTables * lookupTables_
Definition: RctInputTextToDigi.h:66
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
RctInputTextToDigi::inputFile_
edm::FileInPath inputFile_
Definition: RctInputTextToDigi.h:62
L1RCTParameters::calcIEta
short calcIEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
Definition: L1RCTParameters.cc:141
HcalTriggerPrimitiveSample
Definition: HcalTriggerPrimitiveSample.h:11
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1RCTParametersRcd
Definition: L1RCTParametersRcd.h:12
RctInputTextToDigi::nEvent_
int nEvent_
Definition: RctInputTextToDigi.h:64
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
edm::FileInPath
Definition: FileInPath.h:61
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
edm::ESHandle
Definition: DTSurvey.h:22
RctInputTextToDigi::inputStream_
std::ifstream inputStream_
Definition: RctInputTextToDigi.h:63
EcalTrigPrimDigiCollection
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
Definition: EcalDigiCollections.h:121
RctInputTextToDigi::oldVersion_
bool oldVersion_
Definition: RctInputTextToDigi.h:65
L1RCTLookupTables
Definition: L1RCTLookupTables.h:11
HcalTriggerPrimitiveDigi
Definition: HcalTriggerPrimitiveDigi.h:13
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
L1RCTLookupTables::rctParameters
const L1RCTParameters * rctParameters() const
Definition: L1RCTLookupTables.h:33
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
L1RCTParameters::calcIPhi
unsigned short calcIPhi(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
Definition: L1RCTParameters.cc:152
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalTriggerTower
Definition: EcalSubdetector.h:10
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
L1RCTLookupTables::setRCTParameters
void setRCTParameters(const L1RCTParameters *rctParameters)
Definition: L1RCTLookupTables.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1RCTParameters
Definition: L1RCTParameters.h:27
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
EcalTriggerPrimitiveSample
Definition: EcalTriggerPrimitiveSample.h:12
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
HcalTrigPrimDigiCollection
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
Definition: HcalDigiCollections.h:24
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14