19 const int ievt = evt.
id().
event();
20 if (formula_.get() !=
nullptr) {
23 digis->reserve(170 * 360);
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);
31 cout <<
"(" << iEta0 <<
"," << iPhi0 <<
"): ";
32 digis->push_back(
EBDetId(iEta1, iPhi));
36 uint16_t encodedAdc = (uint16_t)formula_->Eval(iEta0, iPhi0, ievt - 1,
t);
39 dframe[
t] = encodedAdc;
45 evt.
put(std::make_unique<EEDigiCollection>());
47 if (tpFormula_.get() !=
nullptr) {
48 unique_ptr<EcalTrigPrimDigiCollection> tps = std::make_unique<EcalTrigPrimDigiCollection>();
49 tps->reserve(56 * 72);
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);
57 cout <<
"(" << iTtEta0 <<
"," << iTtPhi0 <<
"): ";
58 int zside = iTtEta1 < 0 ? -1 : 1;
66 uint16_t encodedTp = (uint16_t)tpFormula_->Eval(iTtEta0, iTtPhi0, ievt - 1,
t);
69 cout <<
"TP(" << iTtEta0 <<
"," << iTtPhi0 <<
") = " << encodedTp << ((
t < (
nSamples - 1)) ?
"\t" :
"\n");
72 tps->push_back(tpframe);
77 if (simHitFormula_.get() !=
nullptr) {
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);
84 cout <<
"(" << iEta0 <<
"," << iPhi0 <<
"): ";
86 double em = simHitFormula_->Eval(iEta0, iPhi0, ievt - 1);
95 evt.
put(std::make_unique<PCaloHitContainer>(),
"EcalHitsEE");
100 string formula =
pset.getParameter<
string>(
"formula");
102 string simHitFormula =
pset.getParameter<
string>(
"simHitFormula");
104 verbose_ =
pset.getUntrackedParameter<
bool>(
"verbose",
false);
115 replaceAll(
tpFormula,
"itt0",
"((ieta0<28)*(27-ieta0)+(ieta0>=28)*(ieta0-28))*4+(iphi0+2)%4");
130 replaceAll(simHitFormula,
"ebm",
"(ieta0<85)");
131 replaceAll(simHitFormula,
"ebp",
"(ieta0>84)");
140 throw cms::Exception(
"Error in EcalSimpleProducer 'formula' config.");
142 produces<EBDigiCollection>();
143 produces<EEDigiCollection>();
149 throw cms::Exception(
"Error in EcalSimpleProducer 'tpFormula' config.");
151 produces<EcalTrigPrimDigiCollection>();
153 if (!simHitFormula.empty()) {
154 simHitFormula_ = std::make_unique<TFormula>(
"f", simHitFormula.c_str());
158 "Error in EcalSimpleProducer " 159 "'simHitFormula' config.");
161 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
162 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
169 while ((
pos =
s.find(from,
pos)) != string::npos) {
171 s.replace(
pos, from.size(),
to);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< TFormula > simHitFormula_
std::unique_ptr< TFormula > tpFormula_
EcalSimpleProducer(const edm::ParameterSet &pset)
void replaceAll(std::string &s, const std::string &from, const std::string &to) const
void produce(edm::Event &evt, const edm::EventSetup &) override
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Abs< T >::type abs(const T &t)
std::unique_ptr< TFormula > formula_
EventNumber_t event() const