test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
RctInputTextToDigi Class Reference

#include <L1Trigger/TextToDigi/plugins/RctInputTextToDigi.h>

Inheritance diagram for RctInputTextToDigi:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RctInputTextToDigi (const edm::ParameterSet &)
 
 ~RctInputTextToDigi ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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

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 dtNoiseDBValidation_cfg::cerr, and inputStream_.

7  :
8  inputFile_(iConfig.getParameter<edm::FileInPath>("inputFile")),
10  nEvent_(0),
11  oldVersion_(false),
13 {
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  {
29  // not good!!
30  std::cerr << "Input file didn't open!!" << std::endl;
31  }
32  //if (inputStream_.eof()) {std::cout << "Real zeroth eof! " << std::endl;}
33 
34 }
T getParameter(std::string const &) const
L1RCTLookupTables * lookupTables_
edm::FileInPath inputFile_
std::ifstream inputStream_
std::string fullPath() const
Definition: FileInPath.cc:165
RctInputTextToDigi::~RctInputTextToDigi ( )

Definition at line 37 of file RctInputTextToDigi.cc.

References inputStream_.

38 {
39 
40  // do anything here that needs to be done at desctruction time
41  // (e.g. close files, deallocate resources etc.)
42 
43  inputStream_.close();
44 
45 }
std::ifstream inputStream_

Member Function Documentation

void RctInputTextToDigi::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 221 of file RctInputTextToDigi.cc.

222 {
223  // open input file to read all events
224  //inputStream_.open(inputFile_.fullPath().c_str());
225  //std::cout << "beginJob entered" << std::endl;
226 }
void RctInputTextToDigi::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 230 of file RctInputTextToDigi.cc.

231 {
232  // close input file
233  //inputStream_.close();
234 }
void RctInputTextToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 54 of file RctInputTextToDigi.cc.

References funct::abs(), L1RCTParameters::calcIEta(), L1RCTParameters::calcIPhi(), gather_cfg::cout, EcalTriggerTower, edm::EventSetup::get(), i, inputStream_, j, lookupTables_, nEvent_, oldVersion_, edm::Event::put(), alignCSCRings::r, L1RCTLookupTables::rctParameters(), L1RCTLookupTables::setRCTParameters(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), HcalTriggerPrimitiveDigi::setSize(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

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().