17 const int ievt = evt.
id().
event();
18 if(formula_.get()!=0){
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);
28 if(verbose_)
cout <<
"(" << iEta0 <<
"," << iPhi0 <<
"): ";
29 digis->push_back(
EBDetId(iEta1,iPhi));
33 uint16_t encodedAdc = (uint16_t)formula_->Eval(iEta0, iPhi0, ievt-1,
t);
34 if(verbose_)
cout << encodedAdc << ((
t<(nSamples-1))?
"\t":
"\n");
43 if(tpFormula_.get()!=0){
44 unique_ptr<EcalTrigPrimDigiCollection> tps
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);
53 if(verbose_)
cout <<
"(" << iTtEta0 <<
"," << iTtPhi0 <<
"): ";
54 int zside = iTtEta1<0?-1:1;
57 abs(iTtEta1), iTtPhi));
61 if(verbose_)
cout <<
"TP: ";
63 uint16_t encodedTp = (uint16_t)tpFormula_->Eval(iTtEta0, iTtPhi0, ievt-1,
t);
65 if(verbose_)
cout <<
"TP(" << iTtEta0 <<
"," << iTtPhi0 <<
") = " 66 << encodedTp << ((
t<(nSamples-1))?
"\t":
"\n");
69 tps->push_back(tpframe);
74 if(simHitFormula_.get()!=0){
75 unique_ptr<PCaloHitContainer>
hits 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 <<
"): ";
83 double em = simHitFormula_->Eval(iEta0, iPhi0, ievt-1);
101 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.size()!=0){
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.size()!=0){
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.size()!=0){
153 = unique_ptr<TFormula>(
new TFormula(
"f", simHitFormula.c_str()));
157 "'simHitFormula' config.");
159 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
160 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
168 while((pos=s.find(from, pos))!=string::npos){
170 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_
virtual void produce(edm::Event &evt, const edm::EventSetup &)
EcalSimpleProducer(const edm::ParameterSet &pset)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Abs< T >::type abs(const T &t)
std::unique_ptr< TFormula > formula_
constexpr size_t nSamples
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
void replaceAll(std::string &s, const std::string &from, const std::string &to) const