CMS 3D CMS Logo

EcalSimHitsValidProducer.cc
Go to the documentation of this file.
4 
11 
12 #include "G4Step.hh"
13 #include "G4SDManager.hh"
14 #include "G4PrimaryParticle.hh"
15 #include "G4PrimaryVertex.hh"
16 
17 #include <iostream>
18 
19 
21  ee1(0.0),ee4(0.0),ee9(0.0),ee16(0.0),ee25(0.0),
22  eb1(0.0),eb4(0.0),eb9(0.0),eb16(0.0),eb25(0.0),
23  totalEInEE(0.0),totalEInEB(0),totalEInES(0.0),totalEInEEzp(0.0),totalEInEEzm(0.0),
24  totalEInESzp(0.0),totalEInESzm(0.0),
25  totalHits(0),nHitsInEE(0),nHitsInEB(0),nHitsInES(0),nHitsIn1ES(0),nHitsIn2ES(0),
26  nCrystalInEB(0),nCrystalInEEzp(0),nCrystalInEEzm(0),
27  nHitsIn1ESzp(0),nHitsIn1ESzm(0),nHitsIn2ESzp(0),nHitsIn2ESzm(0),
28  thePID(0),
29  label(iPSet.getUntrackedParameter<std::string>("instanceLabel","EcalValidInfo") )
30 {
31  produces<PEcalValidInfo>(label);
32 
33  for ( int i = 0; i<26; i++ ) {
34  eBX0[i] = 0.0;
35  eEX0[i] = 0.0;
36  }
37 
38 }
39 
40 
42 
43 }
44 
45 void
47 {
48  std::unique_ptr<PEcalValidInfo> product(new PEcalValidInfo );
49  fillEventInfo(*product);
50  e.put(std::move(product),label);
51 }
52 
53 void
55 {
56  if( ee1 != 0 ){
57  product.ee1 = ee1;
58  product.ee4 = ee4;
59  product.ee9 = ee9;
60  product.ee16 = ee16;
61  product.ee25 = ee25;
62  for ( int i = 0; i<26; i++ ) {
63  product.eEX0.push_back( eEX0[i]);
64  }
65  }
66 
67  if( eb1 != 0 ){
68  product.eb1 = eb1;
69  product.eb4 = eb4;
70  product.eb9 = eb9;
71  product.eb16 = eb16;
72  product.eb25 = eb25;
73  for ( int i = 0; i<26; i++ ) {
74  product.eBX0.push_back( eBX0[i]);
75  }
76  }
77 
78  product.totalEInEE = totalEInEE;
79  product.totalEInEB = totalEInEB;
80  product.totalEInES = totalEInES;
81 
82  product.totalEInEEzp = totalEInEEzp;
83  product.totalEInEEzm = totalEInEEzm;
84 
85  product.totalEInESzp = totalEInESzp;
86  product.totalEInESzm = totalEInESzm;
87 
88  product.totalHits = totalHits;
89  product.nHitsInEE = nHitsInEE;
90  product.nHitsInEB = nHitsInEB;
91  product.nHitsInES = nHitsInES;
92  product.nHitsIn1ES = nHitsIn1ES;
93  product.nHitsIn2ES = nHitsIn2ES;
94  product.nCrystalInEB = nCrystalInEB;
96  product.nCrystalInEEzm = nCrystalInEEzm;
97 
98  product.nHitsIn1ESzp = nHitsIn1ESzp;
99  product.nHitsIn1ESzm = nHitsIn1ESzm;
100  product.nHitsIn2ESzp = nHitsIn2ESzp;
101  product.nHitsIn2ESzm = nHitsIn2ESzm;
102 
103 
104  product.eOf1ES = eOf1ES;
105  product.eOf2ES = eOf2ES;
106  product.zOfES = zOfES;
107 
108  product.eOf1ESzp = eOf1ESzp;
109  product.eOf1ESzm = eOf1ESzm;
110  product.eOf2ESzp = eOf2ESzp;
111  product.eOf2ESzm = eOf2ESzm;
112 
113 
116  product.eOfEECaloG4Hit = eOfEECaloG4Hit;
119  product.tOfEECaloG4Hit = tOfEECaloG4Hit;
120 
123  product.eOfESCaloG4Hit = eOfESCaloG4Hit;
124  product.tOfESCaloG4Hit = tOfESCaloG4Hit;
125 
128  product.eOfEBCaloG4Hit = eOfEBCaloG4Hit;
129  product.tOfEBCaloG4Hit = tOfEBCaloG4Hit;
130 
131 
132  product.theMomentum = theMomentum;
133  product.theVertex = theVertex;
134  product.thePID = thePID;
135 }
136 
137 void
139  ee1 = 0.0;
140  ee4 = 0.0;
141  ee9 = 0.0;
142  ee16 = 0.0;
143  ee25 = 0.0;
144 
145  eb1 = 0.0;
146  eb4 = 0.0;
147  eb9 = 0.0;
148  eb16 = 0.0;
149  eb25 = 0.0;
150 
151  totalEInEE = 0.0 ;
152  totalEInEB = 0.0 ;
153  totalEInES = 0.0 ;
154 
155  totalEInEEzp = 0.0 ;
156  totalEInEEzm = 0.0 ;
157  totalEInESzp = 0.0 ;
158  totalEInESzm = 0.0 ;
159 
160  totalHits = 0 ;
161  nHitsInEE = 0 ;
162  nHitsInEB = 0 ;
163  nHitsInES = 0 ;
164  nHitsIn1ES = 0 ;
165  nHitsIn2ES = 0 ;
166  nCrystalInEB = 0;
167  nCrystalInEEzp = 0;
168  nCrystalInEEzm = 0;
169 
170 
171  nHitsIn1ESzp = 0 ;
172  nHitsIn1ESzm = 0 ;
173  nHitsIn2ESzp = 0 ;
174  nHitsIn2ESzm = 0 ;
175 
176  for ( int i = 0; i<26; i++ ) {
177  eBX0[i] = 0.0;
178  eEX0[i] = 0.0;
179  }
180 
181  eOf1ES.clear();
182  eOf2ES.clear();
183  zOfES.clear();
184 
185  eOf1ESzp.clear();
186  eOf1ESzm.clear();
187  eOf2ESzp.clear();
188  eOf2ESzm.clear();
189 
190  phiOfEECaloG4Hit.clear();
191  etaOfEECaloG4Hit.clear();
192  tOfEECaloG4Hit.clear();
193  eOfEECaloG4Hit.clear();
194  eOfEEPlusCaloG4Hit.clear();
195  eOfEEMinusCaloG4Hit.clear();
196 
197  phiOfESCaloG4Hit.clear();
198  etaOfESCaloG4Hit.clear();
199  tOfESCaloG4Hit.clear();
200  eOfESCaloG4Hit.clear();
201 
202  phiOfEBCaloG4Hit.clear();
203  etaOfEBCaloG4Hit.clear();
204  tOfEBCaloG4Hit.clear();
205  eOfEBCaloG4Hit.clear();
206 }
207 
208 void
210 
211  int trackID = 0;
212  G4PrimaryParticle * thePrim = 0;
213  int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
214  if ( nvertex <= 0) {
215  edm::LogWarning("EcalSimHitsValidProducer")
216  <<" No Vertex in this Event!";
217  }else {
218  for ( int i = 0; i< nvertex; i++){
219  G4PrimaryVertex * avertex =(*evt)()->GetPrimaryVertex(i);
220  if ( avertex == 0 )
221  edm::LogWarning("EcalSimHitsValidProducer")
222  <<" Pointer to vertex is NULL!";
223  else {
224  float x0 = avertex->GetX0();
225  float y0 = avertex->GetY0();
226  float z0 = avertex->GetZ0();
227  float t0 = avertex->GetT0();
228  theVertex.SetCoordinates(x0,y0,z0,t0);
229 
230  int npart = avertex->GetNumberOfParticle();
231  if ( npart == 0)
232  edm::LogWarning("EcalSimHitsValidProducer")
233  <<" No primary particle in this event";
234  else {
235  if ( thePrim == 0)
236  thePrim = avertex->GetPrimary(trackID);
237  }
238  }
239  }
240 
241  // the direction of momentum of primary particles
242  double pInit =0; // etaInit =0, phiInit =0, // UNUSED
243  if ( thePrim != 0){
244  double px = thePrim -> GetPx();
245  double py = thePrim -> GetPy();
246  double pz = thePrim -> GetPz();
247  theMomentum.SetCoordinates(px,py,pz,0.);
248 
249  pInit =sqrt( pow(px,2.) + pow(py,2.) + pow(pz,2.));
250  if ( pInit == 0)
251  edm::LogWarning("EcalSimHitsValidProducer")
252  <<" Primary has p = 0 ; ";
253  else {
254  theMomentum.SetE(pInit);
255  // double costheta = pz/pInit; // UNUSED
256  // double theta = acos(std::min(std::max(costheta, -1.),1.)); // UNUSED
257  // etaInit = -log(tan(theta/2)); // UNUSED
258 
259  // if ( px != 0 || py != 0) phiInit = atan2(py,px); // UNUSED
260  }
261 
262  thePID = thePrim->GetPDGcode();
263  }else {
264  edm::LogWarning("EcalSimHitsValidProducer")
265  <<" Could not find the primary particle!!";
266  }
267  }
268  // hit map for EB for matrices
269  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
270  int EBHCid = G4SDManager::GetSDMpointer()->GetCollectionID("EcalHitsEB");
271  int EEHCid = G4SDManager::GetSDMpointer()->GetCollectionID("EcalHitsEE");
272  int SEHCid = G4SDManager::GetSDMpointer()->GetCollectionID("EcalHitsES");
273 
274 
275  CaloG4HitCollection* theEBHC = (CaloG4HitCollection*) allHC->GetHC(EBHCid);
276  CaloG4HitCollection* theEEHC = (CaloG4HitCollection*) allHC->GetHC(EEHCid);
277  CaloG4HitCollection* theSEHC = (CaloG4HitCollection*) allHC->GetHC(SEHCid);
278 
279  nHitsInEE = theEEHC->entries();
280  nHitsInEB = theEBHC->entries();
281  nHitsInES = theSEHC->entries();
283 
284  // EB Hit collection start
285  MapType ebmap;
286  for (int j=0; j<theEBHC->entries(); j++) {
287  CaloG4Hit* aHit = (*theEBHC)[j];
288  totalEInEB += aHit->getEnergyDeposit();
289  float he = aHit->getEnergyDeposit();
290  float htime = aHit->getTimeSlice();
291 
292  math::XYZPoint hpos = aHit->getEntry();
293  float htheta = hpos.theta();
294  float heta = -log(tan(htheta * 0.5));
295  float hphi = hpos.phi();
296 
297  phiOfEBCaloG4Hit.push_back( hphi);
298  etaOfEBCaloG4Hit.push_back(heta);
299  tOfEBCaloG4Hit.push_back(htime);
300  eOfEBCaloG4Hit.push_back(he);
301  uint32_t crystid = aHit->getUnitID();
302  ebmap[crystid] += aHit->getEnergyDeposit();
303 }
304 
305  nCrystalInEB = ebmap.size();
306 
307  // EE Hit collection start
308  MapType eemap,eezpmap,eezmmap;
309 
310  for (int j=0; j<theEEHC->entries(); j++) {
311  CaloG4Hit* aHit = (*theEEHC)[j];
312  totalEInEE += aHit->getEnergyDeposit();
313  float he = aHit->getEnergyDeposit();
314  float htime = aHit->getTimeSlice();
315 
316  math::XYZPoint hpos = aHit->getEntry();
317  float htheta = hpos.theta();
318  float heta = -log(tan(htheta * 0.5));
319  float hphi = hpos.phi();
320  phiOfEECaloG4Hit.push_back( hphi);
321  etaOfEECaloG4Hit.push_back(heta);
322  tOfEECaloG4Hit.push_back(htime);
323  eOfEECaloG4Hit.push_back(he);
324 
325  uint32_t crystid = aHit->getUnitID();
326  EEDetId myEEid(crystid);
327  if ( myEEid.zside() == -1 ) {
328  totalEInEEzm += aHit->getEnergyDeposit();
329  eOfEEMinusCaloG4Hit.push_back(he);
330  eezmmap[crystid] += aHit->getEnergyDeposit();
331  }
332  if ( myEEid.zside() == 1 ) {
333  totalEInEEzp += aHit->getEnergyDeposit();
334  eOfEEPlusCaloG4Hit.push_back(he);
335  eezpmap[crystid] += aHit->getEnergyDeposit();
336  }
337 
338 
339  eemap[crystid] += aHit->getEnergyDeposit();
340  }
341 
342  nCrystalInEEzm = eezmmap.size();
343  nCrystalInEEzp = eezpmap.size();
344 
345  //Hits from ES
346  for (int j=0; j<theSEHC->entries(); j++) {
347  CaloG4Hit* aHit = (*theSEHC)[j];
348  totalEInES += aHit->getEnergyDeposit();
349  ESDetId esid = ESDetId( aHit->getUnitID());
350 
351  if (esid.zside() == -1) {
352 
353  totalEInESzm += aHit->getEnergyDeposit();
354 
355  if (esid.plane() == 1) {
356  nHitsIn1ESzm++;
357  eOf1ESzm.push_back(aHit->getEnergyDeposit());
358  }else if ( esid.plane() == 2){
359  nHitsIn2ESzm++;
360  eOf2ESzm.push_back(aHit->getEnergyDeposit());
361  }
362  }
363  if (esid.zside() == 1) {
364 
365  totalEInESzp += aHit->getEnergyDeposit();
366 
367  if (esid.plane() == 1) {
368  nHitsIn1ESzp++;
369  eOf1ESzp.push_back(aHit->getEnergyDeposit());
370  }else if ( esid.plane() == 2){
371  nHitsIn2ESzp++;
372  eOf2ESzp.push_back(aHit->getEnergyDeposit());
373  }
374  }
375 
376 
377 
378  }
379 
380  uint32_t eemaxid = getUnitWithMaxEnergy(eemap);
381  uint32_t ebmaxid = getUnitWithMaxEnergy(ebmap);
382  if ( eemap[eemaxid] > ebmap[ebmaxid] ) {
383  uint32_t centerid = getUnitWithMaxEnergy(eemap);
384  EEDetId myEEid(centerid);
385  int ix = myEEid.ix();
386  int iy = myEEid.iy();
387  int iz = myEEid.zside();
388 
389  ee1 = energyInEEMatrix(1,1,ix,iy,iz,eemap);
390  ee9 = energyInEEMatrix(3,3,ix,iy,iz,eemap);
391  ee25= energyInEEMatrix(5,5,ix,iy,iz,eemap);
392  MapType neweemap;
393  if( fillEEMatrix(3,3,ix,iy,iz,neweemap, eemap)) {
394  ee4 = eCluster2x2(neweemap);
395  }
396  if ( fillEEMatrix(5,5,ix,iy,iz,neweemap, eemap)) {
397  ee16 = eCluster4x4(ee9,neweemap);
398  }
399  } else {
400  uint32_t ebcenterid = getUnitWithMaxEnergy(ebmap);
401  EBDetId myEBid(ebcenterid);
402  int bx = myEBid.ietaAbs();
403  int by = myEBid.iphi();
404  int bz = myEBid.zside();
405  eb1 = energyInEBMatrix(1,1,bx,by,bz,ebmap);
406  eb9 = energyInEBMatrix(3,3,bx,by,bz,ebmap);
407  eb25= energyInEBMatrix(5,5,bx,by,bz,ebmap);
408 
409  MapType newebmap;
410  if( fillEBMatrix(3,3,bx,by,bz,newebmap, ebmap)){
411  eb4 = eCluster2x2(newebmap);
412  }
413  if( fillEBMatrix(5,5,bx,by,bz,newebmap, ebmap)){
414  eb16 = eCluster4x4(eb9,newebmap);
415  }
416  }
417 
418 }
419 
420 void
421 EcalSimHitsValidProducer::update(const G4Step* aStep){
422  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
423  G4ThreeVector hitPoint = preStepPoint->GetPosition();
424  G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
425  G4String name = currentPV->GetName();
426  std::string crystal;
427  crystal.assign(name,0,4);
428 
429  float Edeposit = aStep->GetTotalEnergyDeposit();
430  if ( crystal == "EFRY"&& Edeposit > 0.0){
431  float z = hitPoint.z();
432  float detz = fabs(fabs(z)-3200);
433  int x0 = (int)floor( detz/8.9 );
434  if ( x0< 26){
435  eEX0[x0] += Edeposit;
436  }
437  }
438  if(crystal == "EBRY" && Edeposit > 0.0) {
439  float x = hitPoint.x();
440  float y = hitPoint.y();
441  float r = sqrt(x*x +y*y);
442  float detr = r -1290;
443  int x0 = (int)floor( detr/8.9);
444  eBX0[x0] += Edeposit;
445  }
446 
447 }
448 
449 bool EcalSimHitsValidProducer::fillEEMatrix(int nCellInEta, int nCellInPhi,
450  int CentralEta, int CentralPhi,int CentralZ,
451  MapType& fillmap, MapType& themap)
452 {
453  int goBackInEta = nCellInEta/2;
454  int goBackInPhi = nCellInPhi/2;
455 
456  int startEta = CentralEta - goBackInEta;
457  int startPhi = CentralPhi - goBackInPhi;
458 
459  int i = 0 ;
460  for ( int ieta = startEta; ieta < startEta+nCellInEta; ieta ++ ) {
461 
462  for( int iphi = startPhi; iphi < startPhi + nCellInPhi; iphi++ ) {
463  uint32_t index;
464 
465  if (EEDetId::validDetId(ieta, iphi,CentralZ)) {
466  index = EEDetId( ieta, iphi,CentralZ).rawId();
467  } else { continue; }
468 
469  fillmap[i++] = themap[index];
470  }
471  }
472  uint32_t centerid = getUnitWithMaxEnergy(themap);
473 
474  if ( fillmap[i/2] == themap[centerid] )
475  return true;
476  else
477  return false;
478 }
479 
480 bool EcalSimHitsValidProducer::fillEBMatrix(int nCellInEta, int nCellInPhi,
481  int CentralEta, int CentralPhi,int CentralZ,
482  MapType& fillmap, MapType& themap)
483 {
484  int goBackInEta = nCellInEta/2;
485  int goBackInPhi = nCellInPhi/2;
486 
487  int startEta = CentralZ*CentralEta - goBackInEta;
488  int startPhi = CentralPhi - goBackInPhi;
489 
490  int i = 0 ;
491  for ( int ieta = startEta; ieta < startEta+nCellInEta; ieta ++ ) {
492  for( int iphi = startPhi; iphi < startPhi + nCellInPhi; iphi++ ) {
493  uint32_t index;
494  if (abs(ieta) > 85 || abs(ieta)<1 ) { continue; }
495  if (iphi< 1) { index = EBDetId(ieta,iphi+360).rawId(); }
496  else if(iphi>360) { index = EBDetId(ieta,iphi-360).rawId(); }
497  else { index = EBDetId(ieta,iphi).rawId(); }
498  fillmap[i++] = themap[index];
499  }
500  }
501 
502  uint32_t ebcenterid = getUnitWithMaxEnergy(themap);
503 
504  if ( fillmap[i/2] == themap[ebcenterid] )
505  return true;
506  else
507  return false;
508 }
509 
510 
512  float E22=0.;
513  float e012 = themap[0]+themap[1]+themap[2];
514  float e036 = themap[0]+themap[3]+themap[6];
515  float e678 = themap[6]+themap[7]+themap[8];
516  float e258 = themap[2]+themap[5]+themap[8];
517 
518  if ( (e012>e678 || e012==e678) && (e036>e258 || e036==e258))
519  return E22=themap[0]+themap[1]+themap[3]+themap[4];
520  else if ( (e012>e678 || e012==e678) && (e036<e258 || e036==e258) )
521  return E22=themap[1]+themap[2]+themap[4]+themap[5];
522  else if ( (e012<e678 || e012==e678) && (e036>e258 || e036==e258))
523  return E22=themap[3]+themap[4]+themap[6]+themap[7];
524  else if ( (e012<e678|| e012==e678) && (e036<e258|| e036==e258) )
525  return E22=themap[4]+themap[5]+themap[7]+themap[8];
526  else {
527  return E22;
528  }
529 }
530 
532  float E44=0.;
533  float e0_4 = themap[0]+themap[1]+themap[2]+themap[3]+themap[4];
534  float e0_20 = themap[0]+themap[5]+themap[10]+themap[15]+themap[20];
535  float e4_24 = themap[4]+themap[9]+themap[14]+themap[19]+themap[24];
536  float e0_24 = themap[20]+themap[21]+themap[22]+themap[23]+themap[24];
537 
538  if ((e0_4>e0_24 || e0_4==e0_24) && (e0_20>e4_24|| e0_20==e4_24))
539  return E44=e33+themap[0]+themap[1]+themap[2]+themap[3]+themap[5]+themap[10]+themap[15];
540  else if ((e0_4>e0_24 || e0_4==e0_24) && (e0_20<e4_24 || e0_20==e4_24))
541  return E44=e33+themap[1]+themap[2]+themap[3]+themap[4]+themap[9]+themap[14]+themap[19];
542  else if ((e0_4<e0_24|| e0_4==e0_24) && (e0_20>e4_24 || e0_20==e4_24))
543  return E44=e33+themap[5]+themap[10]+themap[15]+themap[20]+themap[21]+themap[22]+themap[23];
544  else if ((e0_4<e0_24|| e0_4==e0_24) && (e0_20<e4_24 || e0_20==e4_24))
545  return E44=e33+themap[21]+themap[22]+themap[23]+themap[24]+themap[9]+themap[14]+themap[19];
546  else{
547  return E44;
548  }
549 }
550 
551 float EcalSimHitsValidProducer::energyInEEMatrix(int nCellInX, int nCellInY,
552  int centralX, int centralY,
553  int centralZ, MapType& themap){
554 
555  int ncristals = 0;
556  float totalEnergy = 0.;
557 
558  int goBackInX = nCellInX/2;
559  int goBackInY = nCellInY/2;
560  int startX = centralX-goBackInX;
561  int startY = centralY-goBackInY;
562 
563  for (int ix=startX; ix<startX+nCellInX; ix++) {
564  for (int iy=startY; iy<startY+nCellInY; iy++) {
565 
566  uint32_t index ;
567  if (EEDetId::validDetId(ix, iy,centralZ)) {
568  index = EEDetId(ix,iy,centralZ).rawId();
569  } else { continue; }
570 
571  totalEnergy += themap[index];
572  ncristals += 1;
573 
574  LogDebug("EcalSimHitsValidProducer")
575  << " EnergyInEEMatrix: ix - iy - E = " << ix
576  << " " << iy << " " << themap[index] ;
577 
578  }
579  }
580 
581  LogDebug("EcalSimHitsValidProducer")
582  << " EnergyInEEMatrix: energy in " << nCellInX
583  << " cells in x times " << nCellInY
584  << " cells in y matrix = " << totalEnergy
585  << " for " << ncristals << " crystals";
586 
587  return totalEnergy;
588 
589 }
590 
591 float EcalSimHitsValidProducer::energyInEBMatrix(int nCellInEta, int nCellInPhi,
592  int centralEta, int centralPhi,
593  int centralZ, MapType& themap){
594 
595  int ncristals = 0;
596  float totalEnergy = 0.;
597 
598  int goBackInEta = nCellInEta/2;
599  int goBackInPhi = nCellInPhi/2;
600  int startEta = centralZ*centralEta-goBackInEta;
601  int startPhi = centralPhi-goBackInPhi;
602 
603  for (int ieta=startEta; ieta<startEta+nCellInEta; ieta++) {
604  for (int iphi=startPhi; iphi<startPhi+nCellInPhi; iphi++) {
605 
606  uint32_t index ;
607  if (abs(ieta) > 85 || abs(ieta)<1 ) { continue; }
608  if (iphi< 1) { index = EBDetId(ieta,iphi+360).rawId(); }
609  else if(iphi>360) { index = EBDetId(ieta,iphi-360).rawId(); }
610  else { index = EBDetId(ieta,iphi).rawId(); }
611 
612  totalEnergy += themap[index];
613  ncristals += 1;
614 
615  LogDebug("EcalSimHitsValidProducer")
616  << " EnergyInEBMatrix: ieta - iphi - E = " << ieta
617  << " " << iphi << " " << themap[index];
618 
619  }
620  }
621 
622  LogDebug("EcalSimHitsValidProducer")
623  << " EnergyInEBMatrix: energy in " << nCellInEta
624  << " cells in eta times " << nCellInPhi
625  << " cells in phi matrix = " << totalEnergy
626  << " for " << ncristals << " crystals";
627 
628  return totalEnergy;
629 
630 }
631 
633 
634  uint32_t unitWithMaxEnergy = 0;
635  float maxEnergy = 0.;
636 
637  MapType::iterator iter;
638  for (iter = themap.begin(); iter != themap.end(); iter++) {
639 
640  if (maxEnergy < (*iter).second) {
641  maxEnergy = (*iter).second;
642  unitWithMaxEnergy = (*iter).first;
643  }
644  }
645 
646 
647  LogDebug("EcalSimHitsValidProducer")
648  << " Max energy of " << maxEnergy
649  << " MeV was found in Unit id 0x" << std::hex
650  << unitWithMaxEnergy << std::dec;
651 
652  return unitWithMaxEnergy;
653 }
654 
#define LogDebug(id)
FloatVector eOfEEMinusCaloG4Hit
FloatVector eOfESCaloG4Hit
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
int ix() const
Definition: EEDetId.h:76
FloatVector eOfEEPlusCaloG4Hit
FloatVector phiOfEECaloG4Hit
FloatVector tOfEECaloG4Hit
void produce(edm::Event &, const edm::EventSetup &)
FloatVector etaOfEECaloG4Hit
FloatVector phiOfEBCaloG4Hit
math::XYZTLorentzVector theMomentum
bool fillEEMatrix(int nCellInEta, int nCellInPhi, int CentralEta, int CentralPhi, int CentralZ, MapType &fillmap, MapType &themap)
FloatVector etaOfEBCaloG4Hit
math::XYZTLorentzVector theVertex
math::XYZTLorentzVector theMomentum
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::map< uint32_t, float, std::less< uint32_t > > MapType
void fillEventInfo(PEcalValidInfo &)
uint32_t getUnitWithMaxEnergy(MapType &themap)
T sqrt(T t)
Definition: SSEVec.h:18
bool fillEBMatrix(int nCellInEta, int nCellInPhi, int CentralEta, int CentralPhi, int CentralZ, MapType &fillmap, MapType &themap)
FloatVector eOfEBCaloG4Hit
float energyInEBMatrix(int nCellInX, int nCellInY, int centralX, int centralY, int centralZ, MapType &themap)
int zside() const
Definition: EEDetId.h:70
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:82
FloatVector phiOfESCaloG4Hit
int zside() const
Definition: ESDetId.h:45
float energyInEEMatrix(int nCellInX, int nCellInY, int centralX, int centralY, int centralZ, MapType &themap)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZTLorentzVector theVertex
FloatVector etaOfESCaloG4Hit
float eCluster2x2(MapType &themap)
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
int plane() const
Definition: ESDetId.h:47
double getTimeSlice() const
Definition: CaloG4Hit.h:70
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:50
FloatVector tOfESCaloG4Hit
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
EcalSimHitsValidProducer(const edm::ParameterSet &)
FloatVector tOfEBCaloG4Hit
FloatVector eOfEECaloG4Hit
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:49
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:47
float eCluster4x4(float e33, MapType &themap)