test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions
CastorFastClusterProducer Class Reference

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

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

Public Member Functions

 CastorFastClusterProducer (const edm::ParameterSet &)
 
 ~CastorFastClusterProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector
< reco::CastorCluster
CastorClusterCollection
 
typedef ROOT::Math::RhoEtaPhiPoint ClusterPoint
 
typedef math::XYZPointD Point
 

Private Member Functions

double make_noise ()
 
virtual 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::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 19 of file CastorFastClusterProducer.h.

Member Typedef Documentation

Definition at line 31 of file CastorFastClusterProducer.h.

typedef ROOT::Math::RhoEtaPhiPoint CastorFastClusterProducer::ClusterPoint
private

Definition at line 30 of file CastorFastClusterProducer.h.

Definition at line 29 of file CastorFastClusterProducer.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file CastorFastClusterProducer.cc.

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

Definition at line 66 of file CastorFastClusterProducer.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 CastorFastClusterProducer::make_noise ( )
private

Definition at line 348 of file CastorFastClusterProducer.cc.

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

348  {
349  double result = -1.;
350  TRandom3 r2(0);
351  double mu_noise = 0.053; // GeV (from 1.214 ADC) per channel
352  double sigma_noise = 0.027; // GeV (from 0.6168 ADC) per channel
353 
354  while (result < 0.) {
355  result = r2.Gaus(mu_noise,sigma_noise);
356  }
357 
358  return result;
359 }
tuple result
Definition: mps_fire.py:83
void CastorFastClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 81 of file CastorFastClusterProducer.cc.

References a, reco::Candidate::energy(), reco::Candidate::eta(), Gamma, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), i, dqm-mbProfile::log, AlCaHLTBitMon_ParallelJobs::p, reco::Candidate::pdgId(), reco::Candidate::phi(), funct::pow(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), alignCSCRings::r, dt_dqm_sourceclient_common_cff::reco, mathSSE::sqrt(), groupFilesInBlocks::temp, 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 CastorCluster 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  auto_ptr<CastorClusterCollection> CastorClusters (new CastorClusterCollection);
99 
100  /*
101  // declare castor array
102  double castorplus [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = 5.9
103  double castormin [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = -5.9
104  // set phi values of array sectors and everything else to zero
105  for (int j = 0; j < 16; j++) {
106  castorplus[3][j] = -2.94524 + j*0.3927;
107  castormin[3][j] = -2.94524 + j*0.3927;
108  castorplus[0][j] = 0.;
109  castormin[0][j] = 0.;
110  castorplus[1][j] = 0.;
111  castormin[1][j] = 0.;
112  castorplus[2][j] = 0.;
113  castormin[2][j] = 0.;
114  //castorplus[4][j] = 0.;
115  //castormin[4][j] = 0.;
116  }
117 
118  // declare properties vectors
119  vector<double> depthplus[16];
120  vector<double> depthmin[16];
121  vector<double> fhotplus [16];
122  vector<double> fhotmin [16];
123  vector<double> energyplus [16];
124  vector<double> energymin [16];
125 
126  for (int i=0;i<16;i++) {
127  depthplus[i].clear();
128  depthmin[i].clear();
129  fhotplus[i].clear();
130  fhotmin[i].clear();
131  energyplus[i].clear();
132  energymin[i].clear();
133  }
134  */
135 
136  //cout << "declared everything" << endl;
137 
138  // start particle loop
139  for (size_t i = 0; i < genParticles->size(); ++i) {
140  const Candidate & p = (*genParticles)[i];
141 
142  // select particles in castor
143  if ( fabs(p.eta()) > 5.2 && fabs(p.eta()) < 6.6) {
144 
145  //cout << "found particle in castor, start calculating" << endl;
146 
147  // declare energies
148  double gaus_E = -1.;
149  double emEnergy = 0.;
150  double hadEnergy = 0.;
151  //double fhot = 0.;
152  //double depth = 0.;
153 
154  // add energies - em: if particle is e- or gamma
155  if (p.pdgId() == 11 || p.pdgId() == 22) {
156 
157  while ( gaus_E < 0.) {
158  // apply energy smearing with gaussian random generator
159  TRandom3 r(0);
160  // use sigma/E parametrization for the EM sections of CASTOR TB 2007 results
161  double sigma = p.energy()*(sqrt(pow(0.044,2) + pow(0.513/sqrt(p.energy()),2)));
162  gaus_E = r.Gaus(p.energy(),sigma);
163  }
164 
165  // calculate electromagnetic electron/photon energy leakage
166  double tmax;
167  double a;
168  double cte;
169  if ( p.pdgId() == 11) { cte = -0.5; } else { cte = 0.5; }
170  tmax = 1.0*(log(gaus_E/0.0015)+cte);
171  a = tmax*0.5 + 1;
172  double leakage;
173  double x = 0.5*19.38;
174  leakage = gaus_E - gaus_E*Gamma(a,x);
175 
176  // add emEnergy
177  emEnergy = gaus_E - leakage;
178  // add hadEnergy leakage
179  hadEnergy = leakage;
180 
181  // make cluster
182  ClusterPoint pt1;
183  if (p.eta() > 0.) {ClusterPoint temp(88.5,5.9,p.phi()); pt1 = temp;}
184  if (p.eta() < 0.) {ClusterPoint temp(88.5,-5.9,p.phi()); pt1 = temp;}
185  Point pt2(pt1);
186  CastorTowerRefVector refvector;
187  CastorClusters->push_back(reco::CastorCluster(gaus_E,pt2,emEnergy,hadEnergy,emEnergy/gaus_E,0.,0.,0.,0.,refvector));
188 
189  } else {
190 
191  while (gaus_E < 0.) {
192  // apply energy smearing with gaussian random generator
193  TRandom3 r(0);
194  // use sigma/E parametrization for the HAD sections of CASTOR TB 2007 results
195  double sigma = p.energy()*(sqrt(pow(0.121,2) + pow(1.684/sqrt(p.energy()),2)));
196  gaus_E = r.Gaus(p.energy(),sigma);
197  }
198 
199  // add hadEnergy
200  hadEnergy = gaus_E;
201 
202  // make cluster
203  ClusterPoint pt1;
204  if (p.eta() > 0.) {ClusterPoint temp(88.5,5.9,p.phi()); pt1 = temp;}
205  if (p.eta() < 0.) {ClusterPoint temp(88.5,-5.9,p.phi()); pt1 = temp;}
206  Point pt2(pt1);
207  CastorTowerRefVector refvector;
208  CastorClusters->push_back(reco::CastorCluster(gaus_E,pt2,0.,hadEnergy,0.,0.,0.,0.,0.,refvector));
209  }
210 
211  /*
212  // make tower
213 
214  // set sector
215  int sector = -1;
216  for (int j = 0; j < 16; j++) {
217  double a = -M_PI + j*0.3927;
218  double b = -M_PI + (j+1)*0.3927;
219  if ( (p.phi() > a) && (p.phi() < b)) {
220  sector = j;
221  }
222  }
223 
224  // set eta
225  if (p.eta() > 0) {
226  castorplus[0][sector] = castorplus[0][sector] + gaus_E;
227  castorplus[1][sector] = castorplus[1][sector] + emEnergy;
228  castorplus[2][sector] = castorplus[2][sector] + hadEnergy;
229 
230  depthplus[sector].push_back(depth);
231  fhotplus[sector].push_back(fhot);
232  energyplus[sector].push_back(gaus_E);
233  //cout << "filled vectors" << endl;
234  //cout << "energyplus size = " << energyplus[sector].size() << endl;
235  //cout << "depthplus size = " << depthplus[sector].size() << endl;
236  //cout << "fhotplus size = " << fhotplus[sector].size() << endl;
237 
238  } else {
239  castormin[0][sector] = castormin[0][sector] + gaus_E;
240  castormin[1][sector] = castormin[1][sector] + emEnergy;
241  castormin[2][sector] = castormin[2][sector] + hadEnergy;
242 
243 
244  depthmin[sector].push_back(depth);
245  fhotmin[sector].push_back(fhot);
246  energymin[sector].push_back(gaus_E);
247  //cout << "filled vectors" << endl;
248 
249  }
250  */
251 
252  }
253 
254  }
255 
256  /*
257  // substract pedestals/noise
258  for (int j = 0; j < 16; j++) {
259  double hadnoise = 0.;
260  for (int i=0;i<12;i++) {
261  hadnoise = hadnoise + make_noise();
262  }
263  castorplus[0][j] = castorplus[0][j] - hadnoise - make_noise() - make_noise();
264  castormin[0][j] = castormin[0][j] - hadnoise - make_noise() - make_noise();
265  castorplus[1][j] = castorplus[1][j] - make_noise() - make_noise();
266  castormin[1][j] = castormin[1][j] - make_noise() - make_noise();
267  castorplus[2][j] = castorplus[2][j] - hadnoise;
268  castormin[2][j] = castormin[2][j] - hadnoise;
269 
270  // set possible negative values to zero
271  if (castorplus[0][j] < 0.) castorplus[0][j] = 0.;
272  if (castormin[0][j] < 0.) castormin[0][j] = 0.;
273  if (castorplus[1][j] < 0.) castorplus[1][j] = 0.;
274  if (castormin[1][j] < 0.) castormin[1][j] = 0.;
275  if (castorplus[2][j] < 0.) castorplus[2][j] = 0.;
276  if (castormin[2][j] < 0.) castormin[2][j] = 0.;
277  }
278  */
279 
280  /*
281  // store towers from castor arrays
282  // eta = 5.9
283  for (int j=0;j<16;j++) {
284  if (castorplus[0][j] > 0.) {
285 
286  double fem = 0.;
287  fem = castorplus[1][j]/castorplus[0][j];
288  ClusterPoint pt1(88.5,5.9,castorplus[3][j]);
289  Point pt2(pt1);
290 
291  // parametrize depth and fhot from full sim
292  // get fit parameters from energy
293  // get random number according to distribution with fit parameters
294  double depth_mean = 0.;
295  double fhot_mean = 0.;
296  double sum_energy = 0.;
297 
298  //cout << "energyplus size = " << energyplus[j].size()<< endl;
299  for (size_t p = 0; p<energyplus[j].size();p++) {
300  depth_mean = depth_mean + depthplus[j][p]*energyplus[j][p];
301  fhot_mean = fhot_mean + fhotplus[j][p]*energyplus[j][p];
302  sum_energy = sum_energy + energyplus[j][p];
303  }
304  depth_mean = depth_mean/sum_energy;
305  fhot_mean = fhot_mean/sum_energy;
306  cout << "computed depth/fhot" << endl;
307 
308 
309  edm::RefVector<edm::SortedCollection<CastorRecHit> > refvector;
310  CastorClusters->push_back(reco::CastorCluster(castorplus[0][j],pt2,castorplus[1][j],castorplus[2][j],fem,depth_mean,fhot_mean,refvector));
311  }
312  }
313  // eta = -5.9
314  for (int j=0;j<16;j++) {
315  if (castormin[0][j] > 0.) {
316  double fem = 0.;
317  fem = castormin[1][j]/castormin[0][j];
318  ClusterPoint pt1(88.5,-5.9,castormin[3][j]);
319  Point pt2(pt1);
320 
321  // parametrize depth and fhot from full sim
322  // get fit parameters from energy
323  // get random number according to distribution with fit parameters
324  double depth_mean = 0.;
325  double fhot_mean = 0.;
326  double sum_energy = 0.;
327 
328 
329  for (size_t p = 0; p<energymin[j].size();p++) {
330  depth_mean = depth_mean + depthmin[j][p]*energymin[j][p];
331  fhot_mean = fhot_mean + fhotmin[j][p]*energymin[j][p];
332  sum_energy = sum_energy + energymin[j][p];
333  }
334  depth_mean = depth_mean/sum_energy;
335  fhot_mean = fhot_mean/sum_energy;
336 
337 
338  edm::RefVector<edm::SortedCollection<CastorRecHit> > refvector;
339  CastorClusters->push_back(reco::CastorCluster(castormin[0][j],pt2,castormin[1][j],castormin[2][j],fem,depth_mean,fhot_mean,refvector));
340  }
341  }
342  */
343 
344  iEvent.put(CastorClusters);
345 
346 }
int i
Definition: DBlmapReader.cc:9
virtual double energy() const =0
energy
std::vector< CastorCluster > CastorClusterCollection
collection of CastorCluster objects
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T sqrt(T t)
Definition: SSEVec.h:18
math::XYZPoint Point
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
virtual int pdgId() const =0
PDG identifier.
static const double tmax[3]
double a
Definition: hdecay.h:121
dbl * Gamma
Definition: mlp_gen.cc:38
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:69
ROOT::Math::RhoEtaPhiPoint ClusterPoint
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity