CMS 3D CMS Logo

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

#include <EcalSimpleProducer.h>

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

Public Member Functions

void beginJob () override
 
 EcalSimpleProducer (const edm::ParameterSet &pset)
 
void produce (edm::Event &evt, const edm::EventSetup &) override
 
 ~EcalSimpleProducer () 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
 
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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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

int cIndex2iEta (int iEta0) const
 
int cIndex2iPhi (int iPhi0) const
 
int cIndex2iTtEta (int iEta0) const
 
int cIndex2iTtPhi (int iPhi0) const
 
void replaceAll (std::string &s, const std::string &from, const std::string &to) const
 

Private Attributes

std::unique_ptr< TFormula > formula_
 
std::unique_ptr< TFormula > simHitFormula_
 
std::unique_ptr< TFormula > tpFormula_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase 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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
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 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<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

This edm producer generates Ecal Digis (data frames and TPGs) according to a given pattern. The pattern is defined as function of event id, crystal/TT, and time sample. Only barrel is currently supported for the crystal channel data.

Module parameters (in addition to standard source parameters):

The crystal ADC formula is parametrized with the following variables:

The trigger primitive formula is parametrized with the following variables:

In both formulae 'itt0' shortcut can be used for the trigger tower index within the SM starting at 0 from lowest relative eta and lowest phi and increasing first with phi then with eta. The syntax for the formula is the syntax defined in ROOT TFormula

Definition at line 38 of file EcalSimpleProducer.h.

Constructor & Destructor Documentation

EcalSimpleProducer::EcalSimpleProducer ( const edm::ParameterSet pset)

Constructs an EcalSimpleProducer

Parameters
psetCMSSW configuration
sdescdescription of this input source

Definition at line 99 of file EcalSimpleProducer.cc.

References submitPVValidationJobs::err, Exception, EcalElecEmulTccOnlyExample_cfg::formula, formula_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), replaceAll(), simHitFormula_, EcalElecEmulTccOnlyExample_cfg::tpFormula, tpFormula_, and verbose_.

99  : EDProducer() {
100  string formula = pset.getParameter<string>("formula");
101  string tpFormula = pset.getParameter<string>("tpFormula");
102  string simHitFormula = pset.getParameter<string>("simHitFormula");
103 
104  verbose_ = pset.getUntrackedParameter<bool>("verbose", false);
105  // replaceAll(formula, "itt0",
106  // "((((ieta0<85)*(84-ieta0)+(ieta0>=85)*(ieta0-85))/5-18)*4+((iphi0/5+2)%4))");
107  replaceAll(formula, "ebm", "(ieta0<85)");
108  replaceAll(formula, "ebp", "(ieta0>84)");
109  replaceAll(formula, "ieta0", "x");
110  replaceAll(formula, "iphi0", "y");
111  replaceAll(formula, "ievt0", "z");
112  replaceAll(formula, "isample0", "t");
113  // cout << "----------> " << formula << endl;
114 
115  replaceAll(tpFormula, "itt0", "((ieta0<28)*(27-ieta0)+(ieta0>=28)*(ieta0-28))*4+(iphi0+2)%4");
116  replaceAll(tpFormula, "eb", "(ieta0>10 && ieta0<45)");
117  replaceAll(tpFormula, "ebm", "(ieta0>10 && ieta0<28)");
118  replaceAll(tpFormula, "ebp", "(ieta0>27 && ieta0<45)");
119  replaceAll(tpFormula, "ee", "(ieta0<11 || ieta0>44)");
120  replaceAll(tpFormula, "eem", "(ieta0<11)");
121  replaceAll(tpFormula, "eep", "(ieta0>44)");
122  replaceAll(tpFormula, "ieta0", "x");
123  replaceAll(tpFormula, "iphi0", "y");
124  replaceAll(tpFormula, "ievt0", "z");
125  replaceAll(tpFormula, "isample0", "t");
126  // cout << "----------> " << tpFormula << endl;
127 
128  // replaceAll(simHitormula, "itt0",
129  // "((((ieta0<85)*(84-ieta0)+(ieta0>=85)*(ieta0-85))/5-18)*4+((iphi0/5+2)%4))");
130  replaceAll(simHitFormula, "ebm", "(ieta0<85)");
131  replaceAll(simHitFormula, "ebp", "(ieta0>84)");
132  replaceAll(simHitFormula, "ieta0", "x");
133  replaceAll(simHitFormula, "iphi0", "y");
134  replaceAll(simHitFormula, "ievt0", "z");
135 
136  if (!formula.empty()) {
137  formula_ = std::make_unique<TFormula>("f", formula.c_str());
138  Int_t err = formula_->Compile();
139  if (err != 0) {
140  throw cms::Exception("Error in EcalSimpleProducer 'formula' config.");
141  }
142  produces<EBDigiCollection>();
143  produces<EEDigiCollection>();
144  }
145  if (!tpFormula.empty()) {
146  tpFormula_ = std::make_unique<TFormula>("f", tpFormula.c_str());
147  Int_t err = tpFormula_->Compile();
148  if (err != 0) {
149  throw cms::Exception("Error in EcalSimpleProducer 'tpFormula' config.");
150  }
151  produces<EcalTrigPrimDigiCollection>();
152  }
153  if (!simHitFormula.empty()) {
154  simHitFormula_ = std::make_unique<TFormula>("f", simHitFormula.c_str());
155  Int_t err = simHitFormula_->Compile();
156  if (err != 0) {
157  throw cms::Exception(
158  "Error in EcalSimpleProducer "
159  "'simHitFormula' config.");
160  }
161  produces<edm::PCaloHitContainer>("EcalHitsEB");
162  produces<edm::PCaloHitContainer>("EcalHitsEE");
163  }
164 }
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< TFormula > simHitFormula_
std::unique_ptr< TFormula > tpFormula_
std::unique_ptr< TFormula > formula_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void replaceAll(std::string &s, const std::string &from, const std::string &to) const
EcalSimpleProducer::~EcalSimpleProducer ( )
inlineoverride

Destructor

Definition at line 49 of file EcalSimpleProducer.h.

49 {};

Member Function Documentation

void EcalSimpleProducer::beginJob ( void  )
inlineoverridevirtual

Called at start of job.

Parameters
esthe event setup

Reimplemented from edm::one::EDProducerBase.

Definition at line 54 of file EcalSimpleProducer.h.

54 {};
int EcalSimpleProducer::cIndex2iEta ( int  iEta0) const
inlineprivate

Converts c-array index (contiguous integer starting from 0) to std CMSSW ECAL crystal eta index.

Parameters
iEta0c-array index. '0' postfix reminds the index starts from 0
Returns
std CMSSW ECAL crystal index.

Definition at line 77 of file EcalSimpleProducer.h.

77 { return (iEta0 < 85) ? iEta0 - 85 : iEta0 - 84; }
int EcalSimpleProducer::cIndex2iPhi ( int  iPhi0) const
inlineprivate

Converts c-array index (contiguous integer starting from 0) to std CMSSW ECAL crystal phi index.

Parameters
iPhi0c-array index. '0' postfix reminds the index starts from 0
Returns
std CMSSW ECAL crystal index.

Definition at line 84 of file EcalSimpleProducer.h.

84 { return (iPhi0 + 10) % 360 + 1; }
int EcalSimpleProducer::cIndex2iTtEta ( int  iEta0) const
inlineprivate

Converts c-array index (contiguous integer starting from 0) to std CMSSW ECAL trigger tower eta index.

Parameters
iEta0c-array index. '0' postfix reminds the index starts from 0
Returns
std CMSSW ECAL trigger tower index.

Definition at line 91 of file EcalSimpleProducer.h.

91 { return (iEta0 < 28) ? iEta0 - 28 : iEta0 - 27; }
int EcalSimpleProducer::cIndex2iTtPhi ( int  iPhi0) const
inlineprivate

Converts c-array index (contiguous integer starting from 0) to std CMSSW ECAL trigger tower phi index.

Parameters
iPhi0c-array index. '0' postfix reminds the index starts from 0
Returns
std CMSSW ECAL trigger tower index.

Definition at line 98 of file EcalSimpleProducer.h.

98 { return iPhi0 + 1; }
void EcalSimpleProducer::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

The main method. It produces the event.

Parameters
evt[out] produced event.

Implements edm::one::EDProducerBase.

Definition at line 18 of file EcalSimpleProducer.cc.

References funct::abs(), gather_cfg::cout, EcalTriggerTower, edm::EventID::event(), edm::EventBase::id(), eostools::move(), hgc_digi::nSamples, edm::Event::put(), EcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), submitPVValidationJobs::t, and ecaldqm::zside().

18  {
19  const int ievt = evt.id().event();
20  if (formula_.get() != nullptr) {
21  unique_ptr<EBDigiCollection> digis(new EBDigiCollection);
22 
23  digis->reserve(170 * 360);
24 
25  const int nSamples = digis->stride();
26  for (int iEta0 = 0; iEta0 < 170; ++iEta0) {
27  for (int iPhi0 = 0; iPhi0 < 360; ++iPhi0) {
28  int iEta1 = cIndex2iEta(iEta0);
29  int iPhi = cIndex2iPhi(iPhi0);
30  if (verbose_)
31  cout << "(" << iEta0 << "," << iPhi0 << "): ";
32  digis->push_back(EBDetId(iEta1, iPhi));
33  DataFrame dframe(digis->back());
34 
35  for (int t = 0; t < nSamples; ++t) {
36  uint16_t encodedAdc = (uint16_t)formula_->Eval(iEta0, iPhi0, ievt - 1, t);
37  if (verbose_)
38  cout << encodedAdc << ((t < (nSamples - 1)) ? "\t" : "\n");
39  dframe[t] = encodedAdc;
40  }
41  }
42  }
43  evt.put(std::move(digis));
44  // puts an empty digi collecion for endcap:
45  evt.put(std::make_unique<EEDigiCollection>());
46  }
47  if (tpFormula_.get() != nullptr) {
48  unique_ptr<EcalTrigPrimDigiCollection> tps = std::make_unique<EcalTrigPrimDigiCollection>();
49  tps->reserve(56 * 72);
50  const int nSamples = 5;
51  for (int iTtEta0 = 0; iTtEta0 < 56; ++iTtEta0) {
52  for (int iTtPhi0 = 0; iTtPhi0 < 72; ++iTtPhi0) {
53  int iTtEta1 = cIndex2iTtEta(iTtEta0);
54  int iTtPhi = cIndex2iTtPhi(iTtPhi0);
55 
56  if (verbose_)
57  cout << "(" << iTtEta0 << "," << iTtPhi0 << "): ";
58  int zside = iTtEta1 < 0 ? -1 : 1;
59  EcalTriggerPrimitiveDigi tpframe(EcalTrigTowerDetId(zside, EcalTriggerTower, abs(iTtEta1), iTtPhi));
60 
61  tpframe.setSize(nSamples);
62 
63  if (verbose_)
64  cout << "TP: ";
65  for (int t = 0; t < nSamples; ++t) {
66  uint16_t encodedTp = (uint16_t)tpFormula_->Eval(iTtEta0, iTtPhi0, ievt - 1, t);
67 
68  if (verbose_)
69  cout << "TP(" << iTtEta0 << "," << iTtPhi0 << ") = " << encodedTp << ((t < (nSamples - 1)) ? "\t" : "\n");
70  tpframe.setSample(t, EcalTriggerPrimitiveSample(encodedTp));
71  }
72  tps->push_back(tpframe);
73  }
74  }
75  evt.put(std::move(tps));
76  }
77  if (simHitFormula_.get() != nullptr) { // generation of barrel sim hits
78  unique_ptr<PCaloHitContainer> hits = std::make_unique<PCaloHitContainer>();
79  for (int iEta0 = 0; iEta0 < 170; ++iEta0) {
80  for (int iPhi0 = 0; iPhi0 < 360; ++iPhi0) {
81  int iEta1 = cIndex2iEta(iEta0);
82  int iPhi = cIndex2iPhi(iPhi0);
83  if (verbose_)
84  cout << "(" << iEta0 << "," << iPhi0 << "): ";
85 
86  double em = simHitFormula_->Eval(iEta0, iPhi0, ievt - 1);
87  double eh = 0.;
88  double t = 0.;
89  const PCaloHit hit(EBDetId(iEta1, iPhi).rawId(), em, eh, t, 0, 0);
90  hits->push_back(hit);
91  }
92  }
93  evt.put(std::move(hits), "EcalHitsEB");
94  // puts an empty digi collecion for endcap:
95  evt.put(std::make_unique<PCaloHitContainer>(), "EcalHitsEE");
96  }
97 }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
int cIndex2iTtEta(int iEta0) const
std::unique_ptr< TFormula > simHitFormula_
std::unique_ptr< TFormula > tpFormula_
int cIndex2iEta(int iEta0) const
int zside(DetId const &)
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::unique_ptr< TFormula > formula_
constexpr size_t nSamples
int cIndex2iPhi(int iPhi0) const
edm::EventID id() const
Definition: EventBase.h:59
tuple cout
Definition: gather_cfg.py:144
int cIndex2iTtPhi(int iPhi0) const
void EcalSimpleProducer::replaceAll ( std::string &  s,
const std::string &  from,
const std::string &  to 
) const
private

Help function to replace a pattern within a string. Every occurance of the pattern is replaced. An exact match is performed: no wild card.

Parameters
sstring to operate on
patternto replace.
stringto substitute to the pattern

Definition at line 166 of file EcalSimpleProducer.cc.

Referenced by EcalSimpleProducer().

166  {
167  string::size_type pos = 0;
168  // cout << "replaceAll(" << s << "," << from << "," << to << ")\n";
169  while ((pos = s.find(from, pos)) != string::npos) {
170  // cout << "replace(" << pos << "," << from.size() << "," << to << ")\n";
171  s.replace(pos, from.size(), to);
172  // cout << " -> " << s << "\n";
173  }
174 }
uint16_t size_type

Member Data Documentation

std::unique_ptr<TFormula> EcalSimpleProducer::formula_
private

Formula defining the data frame samples

Definition at line 105 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

std::unique_ptr<TFormula> EcalSimpleProducer::simHitFormula_
private

Formula defining the sim hits

Definition at line 113 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

std::unique_ptr<TFormula> EcalSimpleProducer::tpFormula_
private

Formula defining the trigger primitives

Definition at line 109 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

bool EcalSimpleProducer::verbose_
private

Verbosity switch

Definition at line 117 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().