17 const int ievt = evt.
id().
event();
18 if (formula_.get() !=
nullptr) {
21 digis->reserve(170 * 360);
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);
29 cout <<
"(" << iEta0 <<
"," << iPhi0 <<
"): ";
30 digis->push_back(
EBDetId(iEta1, iPhi));
34 uint16_t encodedAdc = (uint16_t)formula_->Eval(iEta0, iPhi0, ievt - 1,
t);
36 cout << encodedAdc << ((
t < (nSamples - 1)) ?
"\t" :
"\n");
37 dframe[
t] = encodedAdc;
45 if (tpFormula_.get() !=
nullptr) {
47 tps->reserve(56 * 72);
49 for (
int iTtEta0 = 0; iTtEta0 < 56; ++iTtEta0) {
50 for (
int iTtPhi0 = 0; iTtPhi0 < 72; ++iTtPhi0) {
51 int iTtEta1 = cIndex2iTtEta(iTtEta0);
52 int iTtPhi = cIndex2iTtPhi(iTtPhi0);
55 cout <<
"(" << iTtEta0 <<
"," << iTtPhi0 <<
"): ";
56 int zside = iTtEta1 < 0 ? -1 : 1;
64 uint16_t encodedTp = (uint16_t)tpFormula_->Eval(iTtEta0, iTtPhi0, ievt - 1,
t);
67 cout <<
"TP(" << iTtEta0 <<
"," << iTtPhi0 <<
") = " << encodedTp << ((
t < (nSamples - 1)) ?
"\t" :
"\n");
70 tps->push_back(tpframe);
75 if (simHitFormula_.get() !=
nullptr) {
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);
82 cout <<
"(" << iEta0 <<
"," << iPhi0 <<
"): ";
84 double em = simHitFormula_->Eval(iEta0, iPhi0, ievt - 1);
100 string simHitFormula = pset.
getParameter<
string>(
"simHitFormula");
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)");
128 replaceAll(simHitFormula,
"ebm",
"(ieta0<85)");
129 replaceAll(simHitFormula,
"ebp",
"(ieta0>84)");
134 if (!formula.empty()) {
135 formula_ = unique_ptr<TFormula>(
new TFormula(
"f", formula.c_str()));
138 throw cms::Exception(
"Error in EcalSimpleProducer 'formula' config.");
140 produces<EBDigiCollection>();
141 produces<EEDigiCollection>();
143 if (!tpFormula.empty()) {
144 tpFormula_ = unique_ptr<TFormula>(
new TFormula(
"f", tpFormula.c_str()));
147 throw cms::Exception(
"Error in EcalSimpleProducer 'tpFormula' config.");
149 produces<EcalTrigPrimDigiCollection>();
151 if (!simHitFormula.empty()) {
152 simHitFormula_ = unique_ptr<TFormula>(
new TFormula(
"f", simHitFormula.c_str()));
156 "Error in EcalSimpleProducer " 157 "'simHitFormula' config.");
159 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
160 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
167 while ((pos = s.find(from, pos)) != string::npos) {
169 s.replace(pos, from.size(), to);
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PCaloHit > PCaloHitContainer
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 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_
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
void replaceAll(std::string &s, const std::string &from, const std::string &to) const