CMS 3D CMS Logo

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

#include <EcalFEtoDigi.h>

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

Public Member Functions

 EcalFEtoDigi (const edm::ParameterSet &)
 
 ~EcalFEtoDigi () 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
 method called once each job just before starting event loop More...
 
EcalTriggerPrimitiveSample create_TPSample (TCCinput, const edm::EventSetup &)
 create EcalTriggerPrimitiveSample from input data (line) More...
 
EcalTriggerPrimitiveSample create_TPSampleTcp (TCCinput, const edm::EventSetup &)
 create EcalTriggerPrimitiveSample in tcp format (uncomrpessed energy) More...
 
EcalTrigTowerDetId create_TTDetId (TCCinput)
 create EcalTrigTowerDetId from input data (line) More...
 
void endJob () override
 method called once each job just after ending the event loop More...
 
void getLUT (unsigned int *lut, const int towerId, const edm::EventSetup &) const
 return the LUT from eventSetup More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 method called to produce the data More...
 
void readInput ()
 open and read in input (flat) data file More...
 
int SMidToTCCid (const int) const
 translate input supermodule id into TCC id (barrel) More...
 

Private Attributes

const std::string basename_
 
const bool debug_
 
const int fileEventOffset_
 
TCCInputData inputdata_ [N_SM]
 
std::ofstream outfile
 
bool singlefile
 
int sm_
 
const edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcdtpgLutGroupToken_
 
const edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcdtpgLutIdMapToken_
 
const bool useIdentityLUT_
 

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

Definition at line 38 of file EcalFEtoDigi.h.

Constructor & Destructor Documentation

◆ EcalFEtoDigi()

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

Definition at line 3 of file EcalFEtoDigi.cc.

References singlefile, and sm_.

6  basename_(iConfig.getUntrackedParameter<std::string>("FlatBaseName", "ecal_tcc_")),
7  useIdentityLUT_(iConfig.getUntrackedParameter<bool>("UseIdentityLUT", false)),
8  sm_(iConfig.getUntrackedParameter<int>("SuperModuleId", -1)),
9  fileEventOffset_(iConfig.getUntrackedParameter<int>("FileEventOffset", 0)),
10  debug_(iConfig.getUntrackedParameter<bool>("debugPrintFlag", false)) {
11  singlefile = (sm_ == -1) ? false : true;
12 
13  produces<EcalTrigPrimDigiCollection>();
14  produces<EcalTrigPrimDigiCollection>("formatTCP");
15 }
const edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > tpgLutGroupToken_
Definition: EcalFEtoDigi.h:55
T getUntrackedParameter(std::string const &, T const &) const
const bool useIdentityLUT_
Definition: EcalFEtoDigi.h:61
const int fileEventOffset_
Definition: EcalFEtoDigi.h:65
const std::string basename_
Definition: EcalFEtoDigi.h:60
const edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > tpgLutIdMapToken_
Definition: EcalFEtoDigi.h:56
const bool debug_
Definition: EcalFEtoDigi.h:66

◆ ~EcalFEtoDigi()

EcalFEtoDigi::~EcalFEtoDigi ( )
inlineoverride

Definition at line 41 of file EcalFEtoDigi.h.

41 {}

Member Function Documentation

◆ beginJob()

void EcalFEtoDigi::beginJob ( void  )
overrideprivatevirtual

method called once each job just before starting event loop

check SM numbering convetion: 1-38 [or -1 flag to indicate all sm's are to be read in]
debug: open file for recreating input copy

Reimplemented from edm::one::EDProducerBase.

Definition at line 277 of file EcalFEtoDigi.cc.

References debug_, Exception, outfile, readInput(), and sm_.

277  {
280  if (sm_ != -1 && (sm_ < 1 || sm_ > 36))
281  throw cms::Exception("EcalFEtoDigiInvalidDetId") << "EcalFEtoDigi: Adapt SM numbering convention.\n";
282 
284  if (debug_)
285  outfile.open("inputcopy.txt");
286 
287  readInput();
288 }
void readInput()
open and read in input (flat) data file
const bool debug_
Definition: EcalFEtoDigi.h:66
std::ofstream outfile
Definition: EcalFEtoDigi.h:67

◆ create_TPSample()

EcalTriggerPrimitiveSample EcalFEtoDigi::create_TPSample ( TCCinput  data,
const edm::EventSetup evtSetup 
)
private

create EcalTriggerPrimitiveSample from input data (line)

setup look up table

compress energy 10 -> 8 bit

crate sample

Definition at line 216 of file EcalFEtoDigi.cc.

References create_TTDetId(), data, debug_, getLUT(), mps_fire::i, DetId::rawId(), l1tHGCalTowerProducer_cfi::tower, and useIdentityLUT_.

Referenced by produce().

216  {
217  int tower = create_TTDetId(data).rawId();
218  int Et = data.get_energy();
219  bool tt_fg = data.get_fg();
220  // unsigned input = data.input;
221  // int Et = input & 0x3ff; //get bits 0-9
222  // bool tt_fg = input & 0x400; //get bit number 10
223 
225  unsigned int lut_[1024];
226  if (!useIdentityLUT_)
227  getLUT(lut_, tower, evtSetup);
228  else
229  for (int i = 0; i < 1024; i++)
230  lut_[i] = i; // identity lut!
231 
233  int lut_out = lut_[Et];
234  int ttFlag = (lut_out & 0x700) >> 8;
235  int cEt = (lut_out & 0xff);
236 
238  if (debug_ && data.get_energy() != 0)
239  printf(
240  "[EcalFEtoDigi] Creating sample; input:0x%X (Et:0x%x) cEt:0x%x "
241  "fg:%d ttflag:0x%x \n",
242  data.input,
243  Et,
244  cEt,
245  tt_fg,
246  ttFlag);
247 
248  EcalTriggerPrimitiveSample e_sample(cEt, tt_fg, ttFlag);
249 
250  return e_sample;
251 }
const bool useIdentityLUT_
Definition: EcalFEtoDigi.h:61
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const
return the LUT from eventSetup
const bool debug_
Definition: EcalFEtoDigi.h:66
EcalTrigTowerDetId create_TTDetId(TCCinput)
create EcalTrigTowerDetId from input data (line)

◆ create_TPSampleTcp()

EcalTriggerPrimitiveSample EcalFEtoDigi::create_TPSampleTcp ( TCCinput  data,
const edm::EventSetup evtSetup 
)
private

create EcalTriggerPrimitiveSample in tcp format (uncomrpessed energy)

setup look up table

Definition at line 254 of file EcalFEtoDigi.cc.

References create_TTDetId(), data, getLUT(), mps_fire::i, DetId::rawId(), l1tHGCalTowerProducer_cfi::tower, and useIdentityLUT_.

Referenced by produce().

254  {
255  int tower = create_TTDetId(data).rawId();
256  int Et = data.get_energy();
257  bool tt_fg = data.get_fg();
258 
260  unsigned int lut_[1024];
261  if (!useIdentityLUT_)
262  getLUT(lut_, tower, evtSetup);
263  else
264  for (int i = 0; i < 1024; i++)
265  lut_[i] = i; // identity lut!
266 
267  int lut_out = lut_[Et];
268  int ttFlag = (lut_out & 0x700) >> 8;
269  int tcpdata = ((ttFlag & 0x7) << 11) | ((tt_fg & 0x1) << 10) | (Et & 0x3ff);
270 
271  EcalTriggerPrimitiveSample e_sample(tcpdata);
272 
273  return e_sample;
274 }
const bool useIdentityLUT_
Definition: EcalFEtoDigi.h:61
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const
return the LUT from eventSetup
EcalTrigTowerDetId create_TTDetId(TCCinput)
create EcalTrigTowerDetId from input data (line)

◆ create_TTDetId()

EcalTrigTowerDetId EcalFEtoDigi::create_TTDetId ( TCCinput  data)
private

create EcalTrigTowerDetId from input data (line)

construct the EcalTrigTowerDetId object

Definition at line 177 of file EcalFEtoDigi.cc.

References data, debug_, EcalBarrel, sm_, and ecaldqm::zside().

Referenced by create_TPSample(), create_TPSampleTcp(), and produce().

177  {
178  // (EcalBarrel only)
179  static const int kTowersInPhi = 4;
180 
181  int iTT = data.tower;
182  int zside = (sm_ > 18) ? -1 : +1;
183  int SMid = sm_;
184 
185  int jtower = iTT - 1;
186  int etaTT = jtower / kTowersInPhi + 1;
187  int phiTT;
188  if (zside < 0)
189  phiTT = (SMid - 19) * kTowersInPhi + jtower % kTowersInPhi;
190  else
191  phiTT = (SMid - 1) * kTowersInPhi + kTowersInPhi - (jtower % kTowersInPhi) - 1;
192 
193  phiTT++;
194  // needed as phi=0 (iphi=1) is at middle of lower SMs (1 and 19), need shift
195  // by 2
196  phiTT = phiTT - 2;
197  if (phiTT <= 0)
198  phiTT = 72 + phiTT;
199 
201  if (debug_ && data.get_energy() != 0)
202  printf(
203  "[EcalFEtoDigi] Creating EcalTrigTowerDetId "
204  "(SMid,itt)=(%d,%d)->(eta,phi)=(%d,%d) \n",
205  SMid,
206  iTT,
207  etaTT,
208  phiTT);
209 
210  EcalTrigTowerDetId e_id(zside, EcalBarrel, etaTT, phiTT, 0);
211 
212  return e_id;
213 }
int zside(DetId const &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
const bool debug_
Definition: EcalFEtoDigi.h:66

◆ endJob()

void EcalFEtoDigi::endJob ( void  )
overrideprivatevirtual

method called once each job just after ending the event loop

Reimplemented from edm::one::EDProducerBase.

Definition at line 291 of file EcalFEtoDigi.cc.

References outfile.

291  {
292  if (outfile.is_open())
293  outfile.close();
294 }
std::ofstream outfile
Definition: EcalFEtoDigi.h:67

◆ getLUT()

void EcalFEtoDigi::getLUT ( unsigned int *  lut,
const int  towerId,
const edm::EventSetup evtSetup 
) const
private

return the LUT from eventSetup

Definition at line 300 of file EcalFEtoDigi.cc.

References edm::EventSetup::getData(), mps_fire::i, ecaldqm::towerId(), tpgLutGroupToken_, and tpgLutIdMapToken_.

Referenced by create_TPSample(), and create_TPSampleTcp().

300  {
301  const EcalTPGGroups::EcalTPGGroupsMap &lutGrpMap = evtSetup.getData(tpgLutGroupToken_).getMap();
302  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId);
303  uint32_t lutGrp = 999;
304  if (itgrp != lutGrpMap.end())
305  lutGrp = itgrp->second;
306 
307  const EcalTPGLutIdMap::EcalTPGLutMap &lutMap = evtSetup.getData(tpgLutIdMapToken_).getMap();
308  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp);
309  if (itLut != lutMap.end()) {
310  const unsigned int *theLut = (itLut->second).getLut();
311  for (unsigned int i = 0; i < 1024; i++)
312  lut[i] = theLut[i];
313  }
314 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > tpgLutGroupToken_
Definition: EcalFEtoDigi.h:55
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
const edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > tpgLutIdMapToken_
Definition: EcalFEtoDigi.h:56
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr

◆ produce()

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

method called to produce the data

event counter

re-read input (needed in case of event-by-event input production)

create EcalTrigTowerDetId

create EcalTriggerPrimitiveDigi

create EcalTriggerPrimitiveSample

set sample

add to EcalTrigPrimDigiCollection

set sample (uncompressed format)

add to EcalTrigPrimDigiCollection (uncompressed format)

print & debug

in case no info was found for the event:need to create something

Implements edm::one::EDProducerBase.

Definition at line 18 of file EcalFEtoDigi.cc.

References EcalTriggerPrimitiveDigi::compressedEt(), gather_cfg::cout, create_TPSample(), create_TPSampleTcp(), create_TTDetId(), debug_, TauDecayModes::dec, fileEventOffset_, EcalTriggerPrimitiveDigi::fineGrain(), mps_fire::i, EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), iEvent, inputdata_, EcalTrigTowerDetId::iphi(), eostools::move(), N_SM, outfile, EcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), singlefile, EcalTriggerPrimitiveDigi::size(), sm_, and EcalTriggerPrimitiveDigi::ttFlag().

18  {
20  static int current_bx = -1;
21  current_bx++;
22 
24  // readInput();
25 
26  if (debug_)
27  std::cout << "[EcalFEtoDigi::produce] producing event " << current_bx << std::endl;
28 
29  std::unique_ptr<EcalTrigPrimDigiCollection> e_tpdigis(new EcalTrigPrimDigiCollection);
30  std::unique_ptr<EcalTrigPrimDigiCollection> e_tpdigisTcp(new EcalTrigPrimDigiCollection);
31 
32  std::vector<TCCinput>::const_iterator it;
33 
34  for (int i = 0; i < N_SM; i++) {
35  if (!singlefile)
36  sm_ = i + 1;
37 
38  for (it = inputdata_[i].begin(); it != inputdata_[i].end(); it++) {
39  if (!(*it).is_current(current_bx + fileEventOffset_))
40  continue;
41  else if (debug_ && (*it).input != 0)
42  std::cout << "[EcalFEtoDigi] "
43  << "\tsupermodule:" << sm_ << "\tevent: " << current_bx << "\tbx: " << (*it).bunchCrossing
44  << "\tvalue:0x" << std::setfill('0') << std::setw(4) << std::hex << (*it).input << std::setfill(' ')
45  << std::dec << std::endl;
46 
48  const EcalTrigTowerDetId e_id = create_TTDetId(*it);
49 
50  // EcalElectronicsMapping theMapping;
51  // const EcalTrigTowerDetId e_id
52  //= theMapping.getTrigTowerDetId(SMidToTCCid(sm_),(*it).tower);
53  // EcalElectronicsMapping::getTrigTowerDetId(int TCCid, int iTT)
54 
58 
60  EcalTriggerPrimitiveSample e_sample = create_TPSample(*it, iSetup);
61  EcalTriggerPrimitiveSample e_sampleTcp = create_TPSampleTcp(*it, iSetup);
62 
64  e_digi->setSize(1); // set sampleOfInterest to 0
65  e_digi->setSample(0, e_sample);
66 
68  e_tpdigis->push_back(*e_digi);
69 
71  e_digiTcp->setSize(1); // set sampleOfInterest to 0
72  e_digiTcp->setSample(0, e_sampleTcp);
73 
75  e_tpdigisTcp->push_back(*e_digiTcp);
76 
77  if (debug_)
78  outfile << (*it).tower << '\t' << (*it).bunchCrossing << '\t' << std::setfill('0') << std::hex << "0x"
79  << std::setw(4) << (*it).input << '\t' << "0" << std::dec << std::setfill(' ') << std::endl;
80 
82  if (debug_ && (*it).input != 0)
83  std::cout << "[EcalFEtoDigi] debug id: " << e_digi->id() << "\n\t" << std::dec
84  << "\tieta: " << e_digi->id().ieta() << "\tiphi: " << e_digi->id().iphi()
85  << "\tsize: " << e_digi->size() << "\tfg: " << (e_digi->fineGrain() ? 1 : 0) << std::hex << "\tEt: 0x"
86  << e_digi->compressedEt() << " (0x" << (*it).get_energy() << ")"
87  << "\tttflag: 0x" << e_digi->ttFlag() << std::dec << std::endl;
88 
89  delete e_digi;
90  delete e_digiTcp;
91  }
92 
93  if (singlefile)
94  break;
95  }
96 
98  if (e_tpdigis->empty()) {
99  std::cout << "[EcalFEtoDigi] creating empty collection for the event!\n";
101  e_tpdigis->push_back(*e_digi);
102  }
103 
104  iEvent.put(std::move(e_tpdigis));
105  iEvent.put(std::move(e_tpdigisTcp), "formatTCP");
106 }
bool fineGrain() const
get the fine-grain bit of interesting sample
int ieta() const
get the tower ieta
const EcalTrigTowerDetId & id() const
TCCInputData inputdata_[N_SM]
Definition: EcalFEtoDigi.h:58
int iEvent
Definition: GenABIO.cc:224
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
static const int N_SM
Definition: EcalFEtoDigi.h:36
int compressedEt() const
get the encoded/compressed Et of interesting sample
EcalTriggerPrimitiveSample create_TPSampleTcp(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample in tcp format (uncomrpessed energy)
const int fileEventOffset_
Definition: EcalFEtoDigi.h:65
int ttFlag() const
get the Trigger tower Flag of interesting sample
int iphi() const
get the tower iphi
EcalTriggerPrimitiveSample create_TPSample(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample from input data (line)
const bool debug_
Definition: EcalFEtoDigi.h:66
def move(src, dest)
Definition: eostools.py:511
std::ofstream outfile
Definition: EcalFEtoDigi.h:67
EcalTrigTowerDetId create_TTDetId(TCCinput)
create EcalTrigTowerDetId from input data (line)

◆ readInput()

void EcalFEtoDigi::readInput ( )
private

open and read in input (flat) data file

Definition at line 109 of file EcalFEtoDigi.cc.

References basename_, nano_mu_digi_cff::bx, l1ct::clear(), gather_cfg::cout, debug_, TauDecayModes::dec, f, fileEventOffset_, mps_fire::i, inputdata_, N_SM, alignCSCRings::s, singlefile, sm_, SMidToTCCid(), groupFilesInBlocks::tt, and heppy_batch::val.

Referenced by beginJob().

109  {
110  if (debug_)
111  std::cout << "\n[EcalFEtoDigi::readInput] Reading input data\n";
112 
113  if (!singlefile)
114  sm_ = -1;
115  for (int i = 0; i < N_SM; i++)
116  inputdata_[i].clear();
117 
118  std::stringstream s;
119  int tcc;
120 
121  for (int i = 0; i < N_SM; i++) {
122  tcc = (sm_ == -1) ? SMidToTCCid(i + 1) : SMidToTCCid(sm_);
123 
124  s.str("");
125  s << basename_ << tcc << ".txt";
126 
127  std::ifstream f(s.str().c_str());
128 
129  if (debug_) {
130  std::cout << " opening " << s.str().c_str() << "..." << std::endl;
131  if (!f.good())
132  std::cout << " skipped!";
133  std::cout << std::endl;
134  }
135  // if (!f.good() || f.eof())
136  // throw cms::Exception("BadInputFile")
137  // << "EcalFEtoDigi: cannot open file " << s.str().c_str() << std::endl;
138 
139  int n_bx = 0;
140  int tt;
141  int bx;
142  unsigned val;
143  int dummy;
144 
145  while (f.good()) {
146  if (f.eof())
147  break;
148  tt = 0;
149  bx = -1;
150  val = 0x0;
151  dummy = 0;
152  f >> tt >> bx >> std::hex >> val >> std::dec >> dummy;
153  if (bx == -1 || bx < fileEventOffset_)
154  continue;
155  if (!n_bx || (bx != (inputdata_[i].back()).bunchCrossing))
156  n_bx++;
157  TCCinput ttdata(tt, bx, val);
158  inputdata_[i].push_back(ttdata);
159 
160  if (debug_ && val != 0)
161  printf("\treading tower:%d bx:%d input:0x%x dummy:%2d\n", tt, bx, val, dummy);
162  }
163 
164  f.close();
165 
166  if (sm_ != -1)
167  break;
168  }
169 
170  if (debug_)
171  std::cout << "[EcalFEtoDigi::readInput] Done reading." << std::endl;
172 
173  return;
174 }
TCCInputData inputdata_[N_SM]
Definition: EcalFEtoDigi.h:58
int SMidToTCCid(const int) const
translate input supermodule id into TCC id (barrel)
Definition: TTTypes.h:54
static const int N_SM
Definition: EcalFEtoDigi.h:36
double f[11][100]
const int fileEventOffset_
Definition: EcalFEtoDigi.h:65
const std::string basename_
Definition: EcalFEtoDigi.h:60
void clear(EGIsoObj &c)
Definition: egamma.h:82
const bool debug_
Definition: EcalFEtoDigi.h:66

◆ SMidToTCCid()

int EcalFEtoDigi::SMidToTCCid ( const int  smid) const
private

translate input supermodule id into TCC id (barrel)

Definition at line 297 of file EcalFEtoDigi.cc.

Referenced by readInput().

297 { return (smid <= 18) ? smid + 55 - 1 : smid + 37 - 19; }

Member Data Documentation

◆ basename_

const std::string EcalFEtoDigi::basename_
private

Definition at line 60 of file EcalFEtoDigi.h.

Referenced by readInput().

◆ debug_

const bool EcalFEtoDigi::debug_
private

Definition at line 66 of file EcalFEtoDigi.h.

Referenced by beginJob(), create_TPSample(), create_TTDetId(), produce(), and readInput().

◆ fileEventOffset_

const int EcalFEtoDigi::fileEventOffset_
private

Definition at line 65 of file EcalFEtoDigi.h.

Referenced by produce(), and readInput().

◆ inputdata_

TCCInputData EcalFEtoDigi::inputdata_[N_SM]
private

Definition at line 58 of file EcalFEtoDigi.h.

Referenced by produce(), and readInput().

◆ outfile

std::ofstream EcalFEtoDigi::outfile
private

Definition at line 67 of file EcalFEtoDigi.h.

Referenced by beginJob(), endJob(), and produce().

◆ singlefile

bool EcalFEtoDigi::singlefile
private

Definition at line 63 of file EcalFEtoDigi.h.

Referenced by EcalFEtoDigi(), produce(), and readInput().

◆ sm_

int EcalFEtoDigi::sm_
private

Definition at line 62 of file EcalFEtoDigi.h.

Referenced by beginJob(), create_TTDetId(), EcalFEtoDigi(), produce(), and readInput().

◆ tpgLutGroupToken_

const edm::ESGetToken<EcalTPGLutGroup, EcalTPGLutGroupRcd> EcalFEtoDigi::tpgLutGroupToken_
private

Definition at line 55 of file EcalFEtoDigi.h.

Referenced by getLUT().

◆ tpgLutIdMapToken_

const edm::ESGetToken<EcalTPGLutIdMap, EcalTPGLutIdMapRcd> EcalFEtoDigi::tpgLutIdMapToken_
private

Definition at line 56 of file EcalFEtoDigi.h.

Referenced by getLUT().

◆ useIdentityLUT_

const bool EcalFEtoDigi::useIdentityLUT_
private

Definition at line 61 of file EcalFEtoDigi.h.

Referenced by create_TPSample(), and create_TPSampleTcp().