CMS 3D CMS Logo

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 ()
 
 EcalSimpleProducer (const edm::ParameterSet &pset)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &)
 
virtual ~EcalSimpleProducer ()
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
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::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

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 97 of file EcalSimpleProducer.cc.

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

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

Destructor

Definition at line 50 of file EcalSimpleProducer.h.

50 {};

Member Function Documentation

void EcalSimpleProducer::beginJob ( void  )
inlinevirtual

Called at start of job.

Parameters
esthe event setup

Reimplemented from edm::one::EDProducerBase.

Definition at line 55 of file EcalSimpleProducer.h.

References produce(), replaceAll(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

55 {};
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 79 of file EcalSimpleProducer.h.

79  {
80  return (iEta0<85)?iEta0-85:iEta0-84;
81  }
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 88 of file EcalSimpleProducer.h.

88  {
89  return (iPhi0+10)%360+1;
90  }
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 97 of file EcalSimpleProducer.h.

97  {
98  return (iEta0<28)?iEta0-28:iEta0-27;
99  }
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 106 of file EcalSimpleProducer.h.

106  {
107  return iPhi0+1;
108  }
void EcalSimpleProducer::produce ( edm::Event evt,
const edm::EventSetup  
)
virtual

The main method. It produces the event.

Parameters
evt[out] produced event.

Definition at line 16 of file EcalSimpleProducer.cc.

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

Referenced by beginJob().

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

Referenced by beginJob(), and EcalSimpleProducer().

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

Member Data Documentation

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

Formula defining the data frame samples

Definition at line 115 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

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

Formula defining the sim hits

Definition at line 123 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

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

Formula defining the trigger primitives

Definition at line 119 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().

bool EcalSimpleProducer::verbose_
private

Verbosity switch

Definition at line 127 of file EcalSimpleProducer.h.

Referenced by EcalSimpleProducer().