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
 
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)
 
 ~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
 
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 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 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

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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 7 of file RctInputTextToDigi.cc.

References MessageLogger_cfi::cerr, and inputStream_.

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

Definition at line 31 of file RctInputTextToDigi.cc.

References inputStream_.

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

Member Function Documentation

void RctInputTextToDigi::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 203 of file RctInputTextToDigi.cc.

203  {
204  // open input file to read all events
205  // inputStream_.open(inputFile_.fullPath().c_str());
206  // std::cout << "beginJob entered" << std::endl;
207 }
void RctInputTextToDigi::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 211 of file RctInputTextToDigi.cc.

References DEFINE_FWK_MODULE.

211  {
212  // close input file
213  // inputStream_.close();
214 }
void RctInputTextToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 44 of file RctInputTextToDigi.cc.

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

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

Member Data Documentation

edm::FileInPath RctInputTextToDigi::inputFile_
private

Definition at line 62 of file RctInputTextToDigi.h.

std::ifstream RctInputTextToDigi::inputStream_
private

Definition at line 63 of file RctInputTextToDigi.h.

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

L1RCTLookupTables* RctInputTextToDigi::lookupTables_
private

Definition at line 66 of file RctInputTextToDigi.h.

Referenced by produce().

int RctInputTextToDigi::nEvent_
private

Definition at line 64 of file RctInputTextToDigi.h.

Referenced by produce().

bool RctInputTextToDigi::oldVersion_
private

Definition at line 65 of file RctInputTextToDigi.h.

Referenced by produce().