CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions
CastorFastTowerProducer Class Reference

#include <FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc>

Inheritance diagram for CastorFastTowerProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorFastTowerProducer (const edm::ParameterSet &)
 
 ~CastorFastTowerProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () 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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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 Types

typedef std::vector< reco::CastorTowerCastorTowerCollection
 
typedef math::XYZPointD Point
 
typedef ROOT::Math::RhoEtaPhiPoint TowerPoint
 

Private Member Functions

double make_noise ()
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::stream::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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 18 of file CastorFastTowerProducer.h.

Member Typedef Documentation

Definition at line 30 of file CastorFastTowerProducer.h.

Definition at line 28 of file CastorFastTowerProducer.h.

typedef ROOT::Math::RhoEtaPhiPoint CastorFastTowerProducer::TowerPoint
private

Definition at line 29 of file CastorFastTowerProducer.h.

Constructor & Destructor Documentation

CastorFastTowerProducer::CastorFastTowerProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file CastorFastTowerProducer.cc.

57 {
58  //register your products
59  produces<CastorTowerCollection>();
60 
61  //now do what ever other initialization is needed
62 
63 }
CastorFastTowerProducer::~CastorFastTowerProducer ( )
override

Definition at line 66 of file CastorFastTowerProducer.cc.

67 {
68 
69  // do anything here that needs to be done at desctruction time
70  // (e.g. close files, deallocate resources etc.)
71 
72 }

Member Function Documentation

double CastorFastTowerProducer::make_noise ( )
private

Definition at line 369 of file CastorFastTowerProducer.cc.

References DEFINE_FWK_MODULE, diffTwoXMLs::r2, and mps_fire::result.

Referenced by produce().

369  {
370  double result = -1.;
371  TRandom3 r2(0);
372  double mu_noise = 0.053; // GeV (from 1.214 ADC) per channel
373  double sigma_noise = 0.027; // GeV (from 0.6168 ADC) per channel
374 
375  while (result < 0.) {
376  result = r2.Gaus(mu_noise,sigma_noise);
377  }
378 
379  return result;
380 }
void CastorFastTowerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 81 of file CastorFastTowerProducer.cc.

References a, funct::abs(), b, allConversions_cfi::d0, particleFlowClusterECALTimeSelected_cfi::depth, reco::Candidate::energy(), reco::Candidate::eta(), hcaldqm::quantity::fdepth, Gamma, GenHFHadronMatcher_cfi::genParticles, edm::Event::getByLabel(), mps_fire::i, cmsBatch::log, M_PI, make_noise(), SiStripPI::mean, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, reco::Candidate::pdgId(), reco::Candidate::phi(), funct::pow(), hiDetachedQuadStep_cff::pt1, hiDetachedQuadStep_cff::pt2, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), alignCSCRings::r, tmax, and x.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

82 {
83  using namespace edm;
84  using namespace reco;
85  using namespace std;
86  using namespace TMath;
87 
88  //
89  // Make CastorTower objects
90  //
91 
92  //cout << "entering event" << endl;
93 
95  iEvent.getByLabel("genParticles", genParticles);
96 
97  // make pointer to towers that will be made
98  unique_ptr<CastorTowerCollection> CastorTowers (new CastorTowerCollection);
99 
100  // declare castor array
101  double castorplus [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = 5.9
102  double castormin [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = -5.9
103  // set phi values of array sectors and everything else to zero
104  for (int j = 0; j < 16; j++) {
105  castorplus[3][j] = -2.94524 + j*0.3927;
106  castormin[3][j] = -2.94524 + j*0.3927;
107  castorplus[0][j] = 0.;
108  castormin[0][j] = 0.;
109  castorplus[1][j] = 0.;
110  castormin[1][j] = 0.;
111  castorplus[2][j] = 0.;
112  castormin[2][j] = 0.;
113  //castorplus[4][j] = 0.;
114  //castormin[4][j] = 0.;
115  }
116 
117  // declare properties vectors
118  vector<double> depthplus[16];
119  vector<double> depthmin[16];
120  vector<double> fhotplus [16];
121  vector<double> fhotmin [16];
122  vector<double> energyplus [16];
123  vector<double> energymin [16];
124  //vector<double> femplus [16];
125  //vector<double> femmin [16];
126 
127  for (int i=0;i<16;i++) {
128  depthplus[i].clear();
129  depthmin[i].clear();
130  fhotplus[i].clear();
131  fhotmin[i].clear();
132  energyplus[i].clear();
133  energymin[i].clear();
134  //femplus[i].clear();
135  //femmin[i].clear();
136  }
137 
138  //cout << "declared everything" << endl;
139 
140  // start particle loop
141  for (size_t i = 0; i < genParticles->size(); ++i) {
142  const Candidate & p = (*genParticles)[i];
143 
144  // select particles in castor
145  if ( fabs(p.eta()) > 5.2 && fabs(p.eta()) < 6.6) {
146 
147  //cout << "found particle in castor, start calculating" << endl;
148 
149  // declare energies
150  //double gaus_E = -1.;
151  double energy = -1.;
152  double emEnergy = 0.;
153  double hadEnergy = 0.;
154  double fhot = 0.;
155  double depth = 0.;
156  //double fem = 0.;
157 
158  // add energies - em: if particle is e- or gamma
159  if (p.pdgId() == 11 || p.pdgId() == 22) {
160 
161  // calculate primary tower energy for electrons
162  while ( energy < 0.) {
163  // apply energy smearing with gaussian random generator
164  TRandom3 r(0);
165  // use sigma/E parametrization from the full simulation
166  double mean = 1.0024*p.energy() - 0.3859;
167  double sigma = 0.0228*p.energy() + 2.1061;
168  energy = r.Gaus(mean,sigma);
169  }
170 
171  // calculate electromagnetic electron/photon energy leakage
172  double tmax;
173  double a;
174  double cte;
175  if ( p.pdgId() == 11) { cte = -0.5; } else { cte = 0.5; }
176  tmax = 1.0*(log(energy/0.0015)+cte);
177  a = tmax*0.5 + 1;
178  double leakage;
179  double x = 0.5*19.38;
180  leakage = energy - energy*Gamma(a,x);
181 
182  // add emEnergy
183  emEnergy = energy - leakage;
184  // add hadEnergy leakage
185  hadEnergy = leakage;
186 
187  // calculate EM depth from parametrization
188  double d0 = 0.2338 * pow(p.energy(),-0.1634);
189  double d1 = 5.4336 * pow(p.energy(),0.2410) + 14408.1025;
190  double d2 = 1.4692 * pow(p.energy(),0.1307) - 0.5216;
191  if (d0 < 0.) d0 = abs(d0);
192 
193  TF1 *fdepth = new TF1("fdepth","[0] * TMath::Exp(-0.5*( (x-[1])/[2] + TMath::Exp(-(x-[1])/[2])))",14400.,14460.);
194  fdepth->SetParameters(d0,d1,d2);
195  depth = fdepth->GetRandom();
196  fdepth->Delete();
197  if (p.eta() < 0.) depth = -1*depth;
198 
199  } else {
200 
201  // calculate primary tower energy for hadrons
202  while (energy < 0.) {
203  // apply energy smearing with gaussian random generator
204  TRandom3 r(0);
205  // use sigma/E parametrization from the full simulation
206  double mean = 0.8340*p.energy() - 8.5054;
207  double sigma = 0.1595*p.energy() + 3.1183;
208  energy = r.Gaus(mean,sigma);
209  }
210 
211  // add hadEnergy
212  hadEnergy = energy;
213 
214  // in the near future add fem parametrization
215 
216  // calculate depth for HAD particle from parametrization
217  double d0 = -0.000012 * p.energy() + 0.0661;
218  double d1 = 785.7524 * pow(p.energy(),0.0262) + 13663.4262;
219  double d2 = 9.8748 * pow(p.energy(),0.1720) + 37.0187;
220  if (d0 < 0.) d0 = abs(d0);
221 
222  TF1 *fdepth = new TF1("fdepth","[0] * TMath::Exp(-0.5*( (x-[1])/[2] + TMath::Exp(-(x-[1])/[2]) ))",14400.,15500.);
223  fdepth->SetParameters(d0,d1,d2);
224  depth = fdepth->GetRandom();
225  fdepth->Delete();
226  if (p.eta() < 0.) depth = -1*depth;
227 
228 
229  }
230 
231  // make tower
232 
233  // set sector
234  int sector = -1;
235  for (int j = 0; j < 16; j++) {
236  double a = -M_PI + j*0.3927;
237  double b = -M_PI + (j+1)*0.3927;
238  if ( (p.phi() > a) && (p.phi() < b)) {
239  sector = j;
240  }
241  }
242 
243  // set eta
244  if (p.eta() > 0) {
245  castorplus[0][sector] = castorplus[0][sector] + energy;
246  castorplus[1][sector] = castorplus[1][sector] + emEnergy;
247  castorplus[2][sector] = castorplus[2][sector] + hadEnergy;
248 
249  depthplus[sector].push_back(depth);
250  fhotplus[sector].push_back(fhot);
251  energyplus[sector].push_back(energy);
252  //cout << "filled vectors" << endl;
253  //cout << "energyplus size = " << energyplus[sector].size() << endl;
254  //cout << "depthplus size = " << depthplus[sector].size() << endl;
255  //cout << "fhotplus size = " << fhotplus[sector].size() << endl;
256 
257  } else {
258  castormin[0][sector] = castormin[0][sector] + energy;
259  castormin[1][sector] = castormin[1][sector] + emEnergy;
260  castormin[2][sector] = castormin[2][sector] + hadEnergy;
261 
262 
263  depthmin[sector].push_back(depth);
264  fhotmin[sector].push_back(fhot);
265  energymin[sector].push_back(energy);
266  //cout << "filled vectors" << endl;
267 
268  }
269 
270  }
271 
272  }
273 
274 
275  // add and substract pedestals/noise
276  for (int j = 0; j < 16; j++) {
277  double hadnoise = 0.;
278  double emnoise = 0.;
279  for (int i=0;i<12;i++) {
280  hadnoise = hadnoise + make_noise();
281  if (i<2) emnoise = emnoise + make_noise();
282  }
283 
284  hadnoise = hadnoise - 12*0.053;
285  emnoise = emnoise - 2*0.053;
286  if ( hadnoise < 0.) hadnoise = 0.;
287  if ( emnoise < 0.) emnoise = 0.;
288  double totnoise = hadnoise + emnoise;
289 
290  // add random noise
291  castorplus[0][j] = castorplus[0][j] + totnoise;
292  castormin[0][j] = castormin[0][j] + totnoise;
293  castorplus[1][j] = castorplus[1][j] + emnoise;
294  castormin[1][j] = castormin[1][j] + emnoise;
295  castorplus[2][j] = castorplus[2][j] + hadnoise;
296  castormin[2][j] = castormin[2][j] + hadnoise;
297 
298  //cout << "after constant substraction" << endl;
299  //cout << "total noise = " << castorplus[0][j] << " em noise = " << castorplus[1][j] << " had noise = " << castorplus[2][j] << endl;
300  //cout << "fem should be = " << castorplus[1][j]/castorplus[0][j] << endl;
301 
302  }
303 
304 
305  // store towers from castor arrays
306  // eta = 5.9
307  for (int j=0;j<16;j++) {
308  if (castorplus[0][j] != 0.) {
309 
310  double fem = 0.;
311  fem = castorplus[1][j]/castorplus[0][j];
312  TowerPoint pt1(88.5,5.9,castorplus[3][j]);
313  Point pt2(pt1);
314 
315  //cout << "fem became = " << castorplus[1][j]/castorplus[0][j] << endl;
316 
317  double depth_mean = 0.;
318  double fhot_mean = 0.;
319  double sum_energy = 0.;
320 
321  //cout << "energyplus size = " << energyplus[j].size()<< endl;
322  for (size_t p = 0; p<energyplus[j].size();p++) {
323  depth_mean = depth_mean + depthplus[j][p]*energyplus[j][p];
324  fhot_mean = fhot_mean + fhotplus[j][p]*energyplus[j][p];
325  sum_energy = sum_energy + energyplus[j][p];
326  }
327  depth_mean = depth_mean/sum_energy;
328  fhot_mean = fhot_mean/sum_energy;
329  //cout << "computed depth/fhot" << endl;
330 
331 
332  //std::vector<CastorCell> usedCells;
334  CastorTowers->push_back(reco::CastorTower(castorplus[0][j],pt2,castorplus[1][j],castorplus[2][j],fem,depth_mean,fhot_mean,refvector));
335  }
336  }
337  // eta = -5.9
338  for (int j=0;j<16;j++) {
339  if (castormin[0][j] != 0.) {
340  double fem = 0.;
341  fem = castormin[1][j]/castormin[0][j];
342  TowerPoint pt1(88.5,-5.9,castormin[3][j]);
343  Point pt2(pt1);
344 
345  double depth_mean = 0.;
346  double fhot_mean = 0.;
347  double sum_energy = 0.;
348 
349 
350  for (size_t p = 0; p<energymin[j].size();p++) {
351  depth_mean = depth_mean + depthmin[j][p]*energymin[j][p];
352  fhot_mean = fhot_mean + fhotmin[j][p]*energymin[j][p];
353  sum_energy = sum_energy + energymin[j][p];
354  }
355  depth_mean = depth_mean/sum_energy;
356  fhot_mean = fhot_mean/sum_energy;
357 
358 
359  //std::vector<CastorCell> usedCells;
361  CastorTowers->push_back(reco::CastorTower(castormin[0][j],pt2,castormin[1][j],castormin[2][j],fem,depth_mean,fhot_mean,refvector));
362  }
363  }
364 
365  iEvent.put(std::move(CastorTowers));
366 
367 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
ROOT::Math::RhoEtaPhiPoint TowerPoint
virtual double energy() const =0
energy
virtual int pdgId() const =0
PDG identifier.
math::XYZPoint Point
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
#define M_PI
static const double tmax[3]
virtual double eta() const =0
momentum pseudorapidity
double b
Definition: hdecay.h:120
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
dbl * Gamma
Definition: mlp_gen.cc:38
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
std::vector< CastorTower > CastorTowerCollection
collection of CastorTower objects
Definition: CastorTower.h:126
virtual double phi() const =0
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510