CMS 3D CMS Logo

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

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

Inheritance diagram for CastorFastClusterProducer:
edm::stream::EDProducer<>

Public Member Functions

 CastorFastClusterProducer (const edm::ParameterSet &)
 
 ~CastorFastClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

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

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT< reco::GenParticleCollectiontokGenPart_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

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

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

Definition at line 17 of file CastorFastClusterProducer.h.

Member Typedef Documentation

◆ CastorClusterCollection

Definition at line 29 of file CastorFastClusterProducer.h.

◆ ClusterPoint

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

Definition at line 28 of file CastorFastClusterProducer.h.

◆ Point

Definition at line 27 of file CastorFastClusterProducer.h.

Constructor & Destructor Documentation

◆ CastorFastClusterProducer()

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

Definition at line 52 of file CastorFastClusterProducer.cc.

53  : tokGenPart_(consumes<reco::GenParticleCollection>(edm::InputTag{"genParticles"})) {
54  //register your products
55  produces<CastorClusterCollection>();
56 
57  //now do what ever other initialization is needed
58 }
const edm::EDGetTokenT< reco::GenParticleCollection > tokGenPart_

◆ ~CastorFastClusterProducer()

CastorFastClusterProducer::~CastorFastClusterProducer ( )
override

Definition at line 60 of file CastorFastClusterProducer.cc.

60  {
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 }

Member Function Documentation

◆ make_noise()

double CastorFastClusterProducer::make_noise ( )
private

Definition at line 346 of file CastorFastClusterProducer.cc.

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

346  {
347  double result = -1.;
348  TRandom3 r2(0);
349  double mu_noise = 0.053; // GeV (from 1.214 ADC) per channel
350  double sigma_noise = 0.027; // GeV (from 0.6168 ADC) per channel
351 
352  while (result < 0.) {
353  result = r2.Gaus(mu_noise, sigma_noise);
354  }
355 
356  return result;
357 }

◆ produce()

void CastorFastClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 70 of file CastorFastClusterProducer.cc.

References a, AJJGenJetFilter_cfi::genParticles, mps_fire::i, iEvent, dqm-mbProfile::log, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, conifer::pow(), HLT_2023v12_cff::pt1, HLT_2023v12_cff::pt2, edm::RefVector< C, T, F >::push_back(), alignCSCRings::r, mathSSE::sqrt(), groupFilesInBlocks::temp, tmax, tokGenPart_, and x.

70  {
71  using namespace edm;
72  using namespace reco;
73  using namespace std;
74  using namespace TMath;
75 
76  //
77  // Make CastorCluster objects
78  //
79 
80  //cout << "entering event" << endl;
81 
83 
84  // make pointer to towers that will be made
85  unique_ptr<CastorClusterCollection> CastorClusters(new CastorClusterCollection);
86 
87  /*
88  // declare castor array
89  double castorplus [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = 5.9
90  double castormin [4][16]; // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position - eta = -5.9
91  // set phi values of array sectors and everything else to zero
92  for (int j = 0; j < 16; j++) {
93  castorplus[3][j] = -2.94524 + j*0.3927;
94  castormin[3][j] = -2.94524 + j*0.3927;
95  castorplus[0][j] = 0.;
96  castormin[0][j] = 0.;
97  castorplus[1][j] = 0.;
98  castormin[1][j] = 0.;
99  castorplus[2][j] = 0.;
100  castormin[2][j] = 0.;
101  //castorplus[4][j] = 0.;
102  //castormin[4][j] = 0.;
103  }
104 
105  // declare properties vectors
106  vector<double> depthplus[16];
107  vector<double> depthmin[16];
108  vector<double> fhotplus [16];
109  vector<double> fhotmin [16];
110  vector<double> energyplus [16];
111  vector<double> energymin [16];
112 
113  for (int i=0;i<16;i++) {
114  depthplus[i].clear();
115  depthmin[i].clear();
116  fhotplus[i].clear();
117  fhotmin[i].clear();
118  energyplus[i].clear();
119  energymin[i].clear();
120  }
121  */
122 
123  //cout << "declared everything" << endl;
124 
125  // start particle loop
126  for (size_t i = 0; i < genParticles->size(); ++i) {
127  const Candidate& p = (*genParticles)[i];
128 
129  // select particles in castor
130  if (fabs(p.eta()) > 5.2 && fabs(p.eta()) < 6.6) {
131  //cout << "found particle in castor, start calculating" << endl;
132 
133  // declare energies
134  double gaus_E = -1.;
135  double emEnergy = 0.;
136  double hadEnergy = 0.;
137  //double fhot = 0.;
138  //double depth = 0.;
139 
140  // add energies - em: if particle is e- or gamma
141  if (p.pdgId() == 11 || p.pdgId() == 22) {
142  while (gaus_E < 0.) {
143  // apply energy smearing with gaussian random generator
144  TRandom3 r(0);
145  // use sigma/E parametrization for the EM sections of CASTOR TB 2007 results
146  double sigma = p.energy() * (sqrt(pow(0.044, 2) + pow(0.513 / sqrt(p.energy()), 2)));
147  gaus_E = r.Gaus(p.energy(), sigma);
148  }
149 
150  // calculate electromagnetic electron/photon energy leakage
151  double tmax;
152  double a;
153  double cte;
154  if (p.pdgId() == 11) {
155  cte = -0.5;
156  } else {
157  cte = 0.5;
158  }
159  tmax = 1.0 * (log(gaus_E / 0.0015) + cte);
160  a = tmax * 0.5 + 1;
161  double leakage;
162  double x = 0.5 * 19.38;
163  leakage = gaus_E - gaus_E * Gamma(a, x);
164 
165  // add emEnergy
166  emEnergy = gaus_E - leakage;
167  // add hadEnergy leakage
168  hadEnergy = leakage;
169 
170  // make cluster
172  if (p.eta() > 0.) {
173  ClusterPoint temp(88.5, 5.9, p.phi());
174  pt1 = temp;
175  }
176  if (p.eta() < 0.) {
177  ClusterPoint temp(88.5, -5.9, p.phi());
178  pt1 = temp;
179  }
180  Point pt2(pt1);
181  CastorTowerRefVector refvector;
182  CastorClusters->push_back(
183  reco::CastorCluster(gaus_E, pt2, emEnergy, hadEnergy, emEnergy / gaus_E, 0., 0., 0., 0., refvector));
184 
185  } else {
186  while (gaus_E < 0.) {
187  // apply energy smearing with gaussian random generator
188  TRandom3 r(0);
189  // use sigma/E parametrization for the HAD sections of CASTOR TB 2007 results
190  double sigma = p.energy() * (sqrt(pow(0.121, 2) + pow(1.684 / sqrt(p.energy()), 2)));
191  gaus_E = r.Gaus(p.energy(), sigma);
192  }
193 
194  // add hadEnergy
195  hadEnergy = gaus_E;
196 
197  // make cluster
199  if (p.eta() > 0.) {
200  ClusterPoint temp(88.5, 5.9, p.phi());
201  pt1 = temp;
202  }
203  if (p.eta() < 0.) {
204  ClusterPoint temp(88.5, -5.9, p.phi());
205  pt1 = temp;
206  }
207  Point pt2(pt1);
208  CastorTowerRefVector refvector;
209  CastorClusters->push_back(reco::CastorCluster(gaus_E, pt2, 0., hadEnergy, 0., 0., 0., 0., 0., refvector));
210  }
211 
212  /*
213  // make tower
214 
215  // set sector
216  int sector = -1;
217  for (int j = 0; j < 16; j++) {
218  double a = -M_PI + j*0.3927;
219  double b = -M_PI + (j+1)*0.3927;
220  if ( (p.phi() > a) && (p.phi() < b)) {
221  sector = j;
222  }
223  }
224 
225  // set eta
226  if (p.eta() > 0) {
227  castorplus[0][sector] = castorplus[0][sector] + gaus_E;
228  castorplus[1][sector] = castorplus[1][sector] + emEnergy;
229  castorplus[2][sector] = castorplus[2][sector] + hadEnergy;
230 
231  depthplus[sector].push_back(depth);
232  fhotplus[sector].push_back(fhot);
233  energyplus[sector].push_back(gaus_E);
234  //cout << "filled vectors" << endl;
235  //cout << "energyplus size = " << energyplus[sector].size() << endl;
236  //cout << "depthplus size = " << depthplus[sector].size() << endl;
237  //cout << "fhotplus size = " << fhotplus[sector].size() << endl;
238 
239  } else {
240  castormin[0][sector] = castormin[0][sector] + gaus_E;
241  castormin[1][sector] = castormin[1][sector] + emEnergy;
242  castormin[2][sector] = castormin[2][sector] + hadEnergy;
243 
244 
245  depthmin[sector].push_back(depth);
246  fhotmin[sector].push_back(fhot);
247  energymin[sector].push_back(gaus_E);
248  //cout << "filled vectors" << endl;
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  edm::RefVector<edm::SortedCollection<CastorRecHit> > refvector;
309  CastorClusters->push_back(reco::CastorCluster(castorplus[0][j],pt2,castorplus[1][j],castorplus[2][j],fem,depth_mean,fhot_mean,refvector));
310  }
311  }
312  // eta = -5.9
313  for (int j=0;j<16;j++) {
314  if (castormin[0][j] > 0.) {
315  double fem = 0.;
316  fem = castormin[1][j]/castormin[0][j];
317  ClusterPoint pt1(88.5,-5.9,castormin[3][j]);
318  Point pt2(pt1);
319 
320  // parametrize depth and fhot from full sim
321  // get fit parameters from energy
322  // get random number according to distribution with fit parameters
323  double depth_mean = 0.;
324  double fhot_mean = 0.;
325  double sum_energy = 0.;
326 
327 
328  for (size_t p = 0; p<energymin[j].size();p++) {
329  depth_mean = depth_mean + depthmin[j][p]*energymin[j][p];
330  fhot_mean = fhot_mean + fhotmin[j][p]*energymin[j][p];
331  sum_energy = sum_energy + energymin[j][p];
332  }
333  depth_mean = depth_mean/sum_energy;
334  fhot_mean = fhot_mean/sum_energy;
335 
336 
337  edm::RefVector<edm::SortedCollection<CastorRecHit> > refvector;
338  CastorClusters->push_back(reco::CastorCluster(castormin[0][j],pt2,castormin[1][j],castormin[2][j],fem,depth_mean,fhot_mean,refvector));
339  }
340  }
341  */
342 
343  iEvent.put(std::move(CastorClusters));
344 }
std::vector< CastorCluster > CastorClusterCollection
collection of CastorCluster objects
constexpr int pow(int x)
Definition: conifer.h:24
const edm::EDGetTokenT< reco::GenParticleCollection > tokGenPart_
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
static const double tmax[3]
fixed size matrix
HLT enums.
Structure Point Contains parameters of Gaussian fits to DMRs.
double a
Definition: hdecay.h:121
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
ROOT::Math::RhoEtaPhiPoint ClusterPoint
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ tokGenPart_

const edm::EDGetTokenT<reco::GenParticleCollection> CastorFastClusterProducer::tokGenPart_
private

Definition at line 30 of file CastorFastClusterProducer.h.

Referenced by produce().