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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 CastorFastClusterProducer (const edm::ParameterSet &)
 
 ~CastorFastClusterProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

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

Private Member Functions

virtual void beginRun (edm::Run &, edm::EventSetup const &)
 
virtual void endRun ()
 
double make_noise ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

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

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

Definition at line 17 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 55 of file CastorFastClusterProducer.cc.

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

Definition at line 65 of file CastorFastClusterProducer.cc.

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

Member Function Documentation

void CastorFastClusterProducer::beginRun ( edm::Run run,
edm::EventSetup const &  es 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 365 of file CastorFastClusterProducer.cc.

366 {
367 }
void CastorFastClusterProducer::endRun ( void  )
privatevirtual

Definition at line 371 of file CastorFastClusterProducer.cc.

371  {
372 }
double CastorFastClusterProducer::make_noise ( )
private

Definition at line 349 of file CastorFastClusterProducer.cc.

References query::result.

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

Implements edm::EDProducer.

Definition at line 80 of file CastorFastClusterProducer.cc.

References a, reco::Candidate::energy(), reco::Candidate::eta(), Gamma, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), i, funct::log(), L1TEmulatorMonitor_cff::p, reco::Candidate::pdgId(), reco::Candidate::phi(), funct::pow(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), csvReporter::r, dt_offlineAnalysis_common_cff::reco, ExpressReco_HICollisions_FallBack::sigma, mathSSE::sqrt(), cond::rpcobtemp::temp, tmax, and ExpressReco_HICollisions_FallBack::x.

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

81 {
82  using namespace edm;
83  using namespace reco;
84  using namespace std;
85  using namespace TMath;
86 
87  //
88  // Make CastorCluster objects
89  //
90 
91  //cout << "entering event" << endl;
92 
94  iEvent.getByLabel("genParticles", genParticles);
95 
96  // make pointer to towers that will be made
97  auto_ptr<CastorClusterCollection> CastorClusters (new CastorClusterCollection);
98 
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 
125  for (int i=0;i<16;i++) {
126  depthplus[i].clear();
127  depthmin[i].clear();
128  fhotplus[i].clear();
129  fhotmin[i].clear();
130  energyplus[i].clear();
131  energymin[i].clear();
132  }
133  */
134 
135  //cout << "declared everything" << endl;
136 
137  // start particle loop
138  for (size_t i = 0; i < genParticles->size(); ++i) {
139  const Candidate & p = (*genParticles)[i];
140 
141  // select particles in castor
142  if ( fabs(p.eta()) > 5.2 && fabs(p.eta()) < 6.6) {
143 
144  //cout << "found particle in castor, start calculating" << endl;
145 
146  // declare energies
147  double gaus_E = -1.;
148  double emEnergy = 0.;
149  double hadEnergy = 0.;
150  //double fhot = 0.;
151  //double depth = 0.;
152 
153  // add energies - em: if particle is e- or gamma
154  if (p.pdgId() == 11 || p.pdgId() == 22) {
155 
156  while ( gaus_E < 0.) {
157  // apply energy smearing with gaussian random generator
158  TRandom3 r(0);
159  // use sigma/E parametrization for the EM sections of CASTOR TB 2007 results
160  double sigma = p.energy()*(sqrt(pow(0.044,2) + pow(0.513/sqrt(p.energy()),2)));
161  gaus_E = r.Gaus(p.energy(),sigma);
162  }
163 
164  // calculate electromagnetic electron/photon energy leakage
165  double tmax;
166  double a;
167  double cte;
168  if ( p.pdgId() == 11) { cte = -0.5; } else { cte = 0.5; }
169  tmax = 1.0*(log(gaus_E/0.0015)+cte);
170  a = tmax*0.5 + 1;
171  double leakage;
172  double x = 0.5*19.38;
173  leakage = gaus_E - gaus_E*Gamma(a,x);
174 
175  // add emEnergy
176  emEnergy = gaus_E - leakage;
177  // add hadEnergy leakage
178  hadEnergy = leakage;
179 
180  // make cluster
181  ClusterPoint pt1;
182  if (p.eta() > 0.) {ClusterPoint temp(88.5,5.9,p.phi()); pt1 = temp;}
183  if (p.eta() < 0.) {ClusterPoint temp(88.5,-5.9,p.phi()); pt1 = temp;}
184  Point pt2(pt1);
185  CastorTowerRefVector refvector;
186  CastorClusters->push_back(reco::CastorCluster(gaus_E,pt2,emEnergy,hadEnergy,emEnergy/gaus_E,0.,0.,0.,0.,refvector));
187 
188  } else {
189 
190  while (gaus_E < 0.) {
191  // apply energy smearing with gaussian random generator
192  TRandom3 r(0);
193  // use sigma/E parametrization for the HAD sections of CASTOR TB 2007 results
194  double sigma = p.energy()*(sqrt(pow(0.121,2) + pow(1.684/sqrt(p.energy()),2)));
195  gaus_E = r.Gaus(p.energy(),sigma);
196  }
197 
198  // add hadEnergy
199  hadEnergy = gaus_E;
200 
201  // make cluster
202  ClusterPoint pt1;
203  if (p.eta() > 0.) {ClusterPoint temp(88.5,5.9,p.phi()); pt1 = temp;}
204  if (p.eta() < 0.) {ClusterPoint temp(88.5,-5.9,p.phi()); pt1 = temp;}
205  Point pt2(pt1);
206  CastorTowerRefVector refvector;
207  CastorClusters->push_back(reco::CastorCluster(gaus_E,pt2,0.,hadEnergy,0.,0.,0.,0.,0.,refvector));
208  }
209 
210  /*
211  // make tower
212 
213  // set sector
214  int sector = -1;
215  for (int j = 0; j < 16; j++) {
216  double a = -M_PI + j*0.3927;
217  double b = -M_PI + (j+1)*0.3927;
218  if ( (p.phi() > a) && (p.phi() < b)) {
219  sector = j;
220  }
221  }
222 
223  // set eta
224  if (p.eta() > 0) {
225  castorplus[0][sector] = castorplus[0][sector] + gaus_E;
226  castorplus[1][sector] = castorplus[1][sector] + emEnergy;
227  castorplus[2][sector] = castorplus[2][sector] + hadEnergy;
228 
229  depthplus[sector].push_back(depth);
230  fhotplus[sector].push_back(fhot);
231  energyplus[sector].push_back(gaus_E);
232  //cout << "filled vectors" << endl;
233  //cout << "energyplus size = " << energyplus[sector].size() << endl;
234  //cout << "depthplus size = " << depthplus[sector].size() << endl;
235  //cout << "fhotplus size = " << fhotplus[sector].size() << endl;
236 
237  } else {
238  castormin[0][sector] = castormin[0][sector] + gaus_E;
239  castormin[1][sector] = castormin[1][sector] + emEnergy;
240  castormin[2][sector] = castormin[2][sector] + hadEnergy;
241 
242 
243  depthmin[sector].push_back(depth);
244  fhotmin[sector].push_back(fhot);
245  energymin[sector].push_back(gaus_E);
246  //cout << "filled vectors" << endl;
247 
248  }
249  */
250 
251  }
252 
253  }
254 
255  /*
256  // substract pedestals/noise
257  for (int j = 0; j < 16; j++) {
258  double hadnoise = 0.;
259  for (int i=0;i<12;i++) {
260  hadnoise = hadnoise + make_noise();
261  }
262  castorplus[0][j] = castorplus[0][j] - hadnoise - make_noise() - make_noise();
263  castormin[0][j] = castormin[0][j] - hadnoise - make_noise() - make_noise();
264  castorplus[1][j] = castorplus[1][j] - make_noise() - make_noise();
265  castormin[1][j] = castormin[1][j] - make_noise() - make_noise();
266  castorplus[2][j] = castorplus[2][j] - hadnoise;
267  castormin[2][j] = castormin[2][j] - hadnoise;
268 
269  // set possible negative values to zero
270  if (castorplus[0][j] < 0.) castorplus[0][j] = 0.;
271  if (castormin[0][j] < 0.) castormin[0][j] = 0.;
272  if (castorplus[1][j] < 0.) castorplus[1][j] = 0.;
273  if (castormin[1][j] < 0.) castormin[1][j] = 0.;
274  if (castorplus[2][j] < 0.) castorplus[2][j] = 0.;
275  if (castormin[2][j] < 0.) castormin[2][j] = 0.;
276  }
277  */
278 
279  /*
280  // store towers from castor arrays
281  // eta = 5.9
282  for (int j=0;j<16;j++) {
283  if (castorplus[0][j] > 0.) {
284 
285  double fem = 0.;
286  fem = castorplus[1][j]/castorplus[0][j];
287  ClusterPoint pt1(88.5,5.9,castorplus[3][j]);
288  Point pt2(pt1);
289 
290  // parametrize depth and fhot from full sim
291  // get fit parameters from energy
292  // get random number according to distribution with fit parameters
293  double depth_mean = 0.;
294  double fhot_mean = 0.;
295  double sum_energy = 0.;
296 
297  //cout << "energyplus size = " << energyplus[j].size()<< endl;
298  for (size_t p = 0; p<energyplus[j].size();p++) {
299  depth_mean = depth_mean + depthplus[j][p]*energyplus[j][p];
300  fhot_mean = fhot_mean + fhotplus[j][p]*energyplus[j][p];
301  sum_energy = sum_energy + energyplus[j][p];
302  }
303  depth_mean = depth_mean/sum_energy;
304  fhot_mean = fhot_mean/sum_energy;
305  cout << "computed depth/fhot" << endl;
306 
307 
308  //std::vector<CastorCell> usedCells;
309  CastorCellRefVector 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  //std::vector<CastorCell> usedCells;
339  CastorCellRefVector refvector;
340  CastorClusters->push_back(reco::CastorCluster(castormin[0][j],pt2,castormin[1][j],castormin[2][j],fem,depth_mean,fhot_mean,refvector));
341  }
342  }
343  */
344 
345  iEvent.put(CastorClusters);
346 
347 }
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:84
T sqrt(T t)
Definition: SSEVec.h:28
math::XYZPoint Point
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
virtual int pdgId() const =0
PDG identifier.
static const double tmax[3]
Log< T >::type log(const T &t)
Definition: Log.h:22
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:61
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