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 Member Functions | Private Attributes
HcalTB02Analysis Class Reference

#include <SimG4CMS/HcalTestBeam/interface/HcalTB02Analysis.h>

Inheritance diagram for HcalTB02Analysis:
SimProducer Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SimWatcher

Public Member Functions

 HcalTB02Analysis (const edm::ParameterSet &p)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
virtual ~HcalTB02Analysis ()
 
- Public Member Functions inherited from SimProducer
void registerProducts (edm::ProducerBase &iProd)
 
 SimProducer ()
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent *iT)
 
virtual ~Observer ()
 

Private Member Functions

void clear ()
 
void fillEvent (HcalTB02HistoClass &)
 
void finish ()
 
 HcalTB02Analysis (const HcalTB02Analysis &)
 
const HcalTB02Analysisoperator= (const HcalTB02Analysis &)
 
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

float E5x5Matrix
 
float E5x5MatrixN
 
float E7x7Matrix
 
float E7x7MatrixN
 
std::map< int, float > energyInCrystals
 
std::map< int, float > energyInScints
 
double eta
 
std::string fileNameTuple
 
bool hcalOnly
 
HcalTB02Histohisto
 
double incidentEnergy
 
int maxTime
 
std::vector< std::string > names
 
int particleType
 
double phi
 
double pInit
 
std::map< int, float > primaries
 
float SEnergy
 
float SEnergyN
 
float xE3x3Matrix
 
float xE3x3MatrixN
 
float xE5x5Matrix
 
float xE5x5MatrixN
 
double xIncidentEnergy
 
float xSEnergy
 
float xSEnergyN
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 

Detailed Description

Description: Analysis of 2004 Hcal Test beam simulation

Usage: A Simwatcher class and can be activated from Oscarproducer module

Definition at line 42 of file HcalTB02Analysis.h.

Constructor & Destructor Documentation

HcalTB02Analysis::HcalTB02Analysis ( const edm::ParameterSet p)

Definition at line 47 of file HcalTB02Analysis.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hcalOnly, histo, and names.

47  : histo(0) {
48 
49  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("HcalTB02Analysis");
50  hcalOnly = m_Anal.getUntrackedParameter<bool>("HcalClusterOnly",true);
51  names = m_Anal.getParameter<std::vector<std::string> >("Names");
52 
53  produces<HcalTB02HistoClass>();
54 
55  edm::LogInfo("HcalTBSim") << "HcalTB02Analysis:: Initialised as observer of "
56  << "BeginOfJob/BeginOfEvent/EndOfEvent with "
57  << "Parameter values:\n \thcalOnly = " << hcalOnly;
58 
59  histo = new HcalTB02Histo(m_Anal);
60 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
HcalTB02Histo * histo
std::vector< std::string > names
HcalTB02Analysis::~HcalTB02Analysis ( )
virtual

Definition at line 62 of file HcalTB02Analysis.cc.

References finish(), and histo.

62  {
63 
64  finish();
65 
66  if (histo) {
67  delete histo;
68  histo = 0;
69  }
70  edm::LogInfo("HcalTBSim") << "HcalTB02Analysis is deleting";
71 }
HcalTB02Histo * histo
HcalTB02Analysis::HcalTB02Analysis ( const HcalTB02Analysis )
private

Member Function Documentation

void HcalTB02Analysis::clear ( void  )
private

Definition at line 417 of file HcalTB02Analysis.cc.

References E5x5Matrix, E5x5MatrixN, E7x7Matrix, E7x7MatrixN, energyInCrystals, energyInScints, eta, incidentEnergy, maxTime, particleType, phi, pInit, primaries, SEnergy, SEnergyN, xE3x3Matrix, xE3x3MatrixN, xE5x5Matrix, xE5x5MatrixN, xIncidentEnergy, xSEnergy, and xSEnergyN.

Referenced by update().

417  {
418 
419  primaries.clear();
420  particleType = 0;
421  pInit = eta = phi = incidentEnergy = 0;
422 
424  E7x7MatrixN = E5x5MatrixN = 0;
425  energyInScints.clear();
426  maxTime = 0;
427 
428  xIncidentEnergy = 0;
429  energyInCrystals.clear();
432 }
std::map< int, float > energyInCrystals
std::map< int, float > primaries
std::map< int, float > energyInScints
void HcalTB02Analysis::fillEvent ( HcalTB02HistoClass product)
private

Definition at line 386 of file HcalTB02Analysis.cc.

References E5x5Matrix, E5x5MatrixN, E7x7Matrix, E7x7MatrixN, energyInCrystals, energyInScints, eta, incidentEnergy, maxTime, particleType, phi, pInit, primaries, SEnergy, SEnergyN, HcalTB02HistoClass::set_E5x5(), HcalTB02HistoClass::set_E5x5N(), HcalTB02HistoClass::set_E7x7(), HcalTB02HistoClass::set_E7x7N(), HcalTB02HistoClass::set_Eentry(), HcalTB02HistoClass::set_Einit(), HcalTB02HistoClass::set_eta(), HcalTB02HistoClass::set_ETot(), HcalTB02HistoClass::set_ETotN(), HcalTB02HistoClass::set_Nprim(), HcalTB02HistoClass::set_Ntimesli(), HcalTB02HistoClass::set_NUnit(), HcalTB02HistoClass::set_partType(), HcalTB02HistoClass::set_phi(), HcalTB02HistoClass::set_xE3x3(), HcalTB02HistoClass::set_xE3x3N(), HcalTB02HistoClass::set_xE5x5(), HcalTB02HistoClass::set_xE5x5N(), HcalTB02HistoClass::set_xEentry(), HcalTB02HistoClass::set_xETot(), HcalTB02HistoClass::set_xETotN(), HcalTB02HistoClass::set_xNUnit(), xE3x3Matrix, xE3x3MatrixN, xE5x5Matrix, xE5x5MatrixN, xIncidentEnergy, xSEnergy, and xSEnergyN.

Referenced by produce().

386  {
387 
388  //Beam information
389  product.set_Nprim(float(primaries.size()));
390  product.set_partType(particleType);
391  product.set_Einit(pInit/GeV);
392  product.set_eta(eta);
393  product.set_phi(phi);
394  product.set_Eentry(incidentEnergy);
395 
396  //Calorimeter energy
397  product.set_ETot(SEnergy/GeV );
398  product.set_E7x7(E7x7Matrix/GeV );
399  product.set_E5x5(E5x5Matrix/GeV );
400  product.set_ETotN(SEnergyN/GeV);
401  product.set_E7x7N(E7x7MatrixN/GeV );
402  product.set_E5x5N(E5x5MatrixN/GeV );
403  product.set_NUnit(float(energyInScints.size()));
404  product.set_Ntimesli(float(maxTime));
405 
406  //crystal information
407  product.set_xEentry(xIncidentEnergy);
408  product.set_xNUnit(float(energyInCrystals.size()));
409  product.set_xETot(xSEnergy/GeV);
410  product.set_xETotN(xSEnergyN/GeV);
411  product.set_xE5x5(xE5x5Matrix/GeV);
412  product.set_xE3x3(xE3x3Matrix/GeV);
413  product.set_xE5x5N(xE5x5MatrixN/GeV);
414  product.set_xE3x3N(xE3x3MatrixN/GeV);
415 }
void set_xE3x3N(float v)
void set_E5x5N(float v)
void set_Ntimesli(float v)
void set_NUnit(float v)
void set_Eentry(float v)
void set_xEentry(float v)
void set_xETotN(float v)
void set_Nprim(float v)
void set_E7x7(float v)
void set_ETotN(float v)
void set_Einit(float v)
void set_xETot(float v)
void set_E7x7N(float v)
std::map< int, float > energyInCrystals
void set_xE3x3(float v)
void set_xE5x5N(float v)
std::map< int, float > primaries
std::map< int, float > energyInScints
void set_E5x5(float v)
void set_partType(float v)
void set_ETot(float v)
void set_xE5x5(float v)
void set_xNUnit(float v)
void HcalTB02Analysis::finish ( )
private

Definition at line 434 of file HcalTB02Analysis.cc.

Referenced by progressbar.ProgressBar::__next__(), and ~HcalTB02Analysis().

434  {
435 
436  /*
437  //Profile
438  std::ofstream oFile;
439  oFile.open("profile.dat");
440  float st[19] = {0.8,
441  0.4, 0.4, 0.4, 0.4, 0.4,
442  0.4, 0.4, 0.4, 0.4, 0.4,
443  0.4, 0.4, 0.4, 0.4, 0.4,
444  0.8, 1.0, 1.0};
445 
446  //cm of material (brass) in front of scintillator layer i:
447 
448  float w[19] = {7.45, //iron !
449  6.00, 6.00, 6.00, 6.00, 6.00, //brass
450  6.00, 6.00, 6.00, 6.00, 6.60, //brass
451  6.60, 6.60, 6.60, 6.60, 6.60, //brass
452  8.90, 20.65, 19.5}; //brass,iron !
453 
454  for (int ilayer = 0; ilayer<19; ilayer++) {
455 
456  // Histogram mean and sigma calculated from the ROOT histos
457  edm::LogInfo("HcalTBSim") << "Layer number: " << ilayer << " Mean = "
458  << histo->getMean(ilayer) << " sigma = "
459  << histo->getRMS(ilayer) << " LThick= "
460  << w[ilayer] << " SThick= " << st[ilayer];
461 
462  oFile << ilayer << " " << histo->getMean(ilayer) << " "
463  << histo->getRMS(ilayer) << " " << w[ilayer] << " " << st[ilayer]
464  << std::endl;
465 
466  }
467  oFile.close();
468  */
469 }
const HcalTB02Analysis& HcalTB02Analysis::operator= ( const HcalTB02Analysis )
private
void HcalTB02Analysis::produce ( edm::Event e,
const edm::EventSetup  
)
virtual

Implements SimProducer.

Definition at line 77 of file HcalTB02Analysis.cc.

References fillEvent(), and edm::Event::put().

77  {
78 
79  std::auto_ptr<HcalTB02HistoClass> product(new HcalTB02HistoClass);
80  fillEvent(*product);
81  e.put(product);
82 }
void fillEvent(HcalTB02HistoClass &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void HcalTB02Analysis::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 84 of file HcalTB02Analysis.cc.

References clear().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

84  {
85 
86  edm::LogInfo("HcalTBSim") << "HcalTB02Analysis: =====> Begin of event = "
87  << (*evt) ()->GetEventID();
88  clear();
89 }
void HcalTB02Analysis::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 91 of file HcalTB02Analysis.cc.

References gather_cfg::cout, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, E5x5Matrix, E5x5MatrixN, E7x7Matrix, E7x7MatrixN, energyInCrystals, energyInScints, eta, edm::hlt::Exception, HcalTB02Histo::fillAllTime(), HcalTB02Histo::fillProfile(), HcalTB02Histo::fillTransProf(), CaloG4Hit::getEM(), edm::RandomNumberGenerator::getEngine(), HcalTB02HcalNumberingScheme::getetaID(), CaloG4Hit::getHadr(), CaloG4Hit::getIncidentEnergy(), HcalTB02HcalNumberingScheme::getlayerID(), HcalTB02HcalNumberingScheme::getphiID(), CaloG4Hit::getTimeSliceID(), CaloG4Hit::getTrackID(), CaloG4Hit::getUnitID(), hcalOnly, histo, i, incidentEnergy, edm::Service< T >::isAvailable(), create_public_lumi_plots::log, LogDebug, max(), maxTime, bookConverter::min, names, npart, particleType, phi, pInit, funct::pow(), primaries, sd, SEnergy, SEnergyN, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), theta(), cond::rpcobgas::time, xE3x3Matrix, xE3x3MatrixN, xE5x5Matrix, xE5x5MatrixN, xIncidentEnergy, and xSEnergy.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

91  {
92 
94  if ( ! rng.isAvailable()) {
95  throw cms::Exception("Configuration")
96  << "HcalTB02Analysis requires the RandomNumberGeneratorService\n"
97  << "which is not present in the configuration file. "
98  << "You must add the service\n in the configuration file or "
99  << "remove the modules that require it.";
100  }
101  CLHEP::RandGaussQ randGauss(rng->getEngine());
102 
103  // Look for the Hit Collection
104  LogDebug("HcalTBSim") << "HcalTB02Analysis::Fill event "
105  << (*evt)()->GetEventID();
106 
107  // access to the G4 hit collections
108  G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
109  int ihit = 0;
110 
111  // HCAL
112  std::string sd = names[0];
113  int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
114  CaloG4HitCollection* theHCHC = (CaloG4HitCollection*) allHC->GetHC(HCHCid);
116  LogDebug("HcalTBSim") << "HcalTB02Analysis :: Hit Collection for " << sd
117  << " of ID " << HCHCid << " is obtained at " <<theHCHC;
118 
119  int nentries = 0;
120  nentries = theHCHC->entries();
121  if (nentries==0) return;
122 
123  int xentries = 0;
124  int XTALSid=0;
125  CaloG4HitCollection* theXTHC=0;
126 
127  if (!hcalOnly) {
128  // XTALS
129  sd = names[1];
130  XTALSid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
131  // assert (XTALSid != 0);
132  theXTHC = (CaloG4HitCollection*) allHC->GetHC(XTALSid);
133  // assert (theXTHC != 0);
134  //HcalTB02XtalNumberingScheme *xorg = new HcalTB02XtalNumberingScheme();
135  LogDebug("HcalTBSim") << "HcalTB02Analysis :: Hit Collection for " << sd
136  << " of ID " << XTALSid << " is obtained at "
137  << theXTHC;
138  xentries = theXTHC->entries();
139  if (xentries==0) return;
140  }
141 
142  LogDebug("HcalTBSim") << "HcalTB02Analysis :: There are " << nentries
143  << " HCal hits, and" << xentries << " xtal hits";
144 
145  float ETot=0., xETot=0.;
146  //float maxE = 0.;
147  //int maxI=0,
148  int scintID=0, xtalID=0;
149 
150  // HCAL
151 
152  if (HCHCid >= 0 && theHCHC > 0) {
153  for ( ihit = 0; ihit < nentries; ihit++) {
154 
155  CaloG4Hit* aHit = (*theHCHC)[ihit];
156  scintID = aHit->getUnitID();
157  int layer = org->getlayerID(scintID);
158  float enEm = aHit->getEM();
159  float enhad = aHit->getHadr();
160 
161  if (layer==0) {
162  enEm =enEm/2.;
163  enhad=enhad/2.;
164  }
165 
166  energyInScints[scintID]+= enEm + enhad;
167  primaries[aHit->getTrackID()]+= enEm + enhad;
168  float time = aHit->getTimeSliceID();
169  if (time > maxTime) maxTime=(int)time;
170  histo->fillAllTime(time);
171 
172  }
173 
174  //
175  // Profile
176  //
177 
178  float TowerEne[8][18], TowerEneCF[8][18], LayerEne[19], EnRing[100];
179  for (int iphi=0 ; iphi<8; iphi++) {
180  for (int jeta=0 ; jeta<18; jeta++) {
181  TowerEne[iphi][jeta]=0.;
182  TowerEneCF[iphi][jeta]=0.;
183  }
184  }
185 
186  for (int ilayer=0; ilayer<19; ilayer++) LayerEne[ilayer]=0.;
187  for (int iring=0; iring<100; iring++) EnRing[iring]=0.;
188 
189  for (std::map<int,float>::iterator is = energyInScints.begin();
190  is!= energyInScints.end(); is++) {
191 
192  ETot = (*is).second;
193 
194  int layer = org->getlayerID((*is).first);
195 
196  if ( (layer!=17) && (layer!=18) ) {
197 
198  float eta = org->getetaID((*is).first);
199  float phi = org->getphiID((*is).first);
200 
201  SEnergy += ETot;
202  TowerEne[(int)phi][(int)eta] += ETot;
203 
204  TowerEneCF[(int)phi][(int)eta] += ETot*(1.+ 0.1*randGauss.fire() );
205  double dR=0.08727*std::sqrt( (eta-8.)*(eta-8.) + (phi-3.)*(phi-3.) );
206  EnRing[(int)(dR/0.01)] += ETot;
207  }
208 
209  LayerEne[layer] += ETot;
210 
211  }
212 
213  for (int ilayer=0 ; ilayer<19 ; ilayer++) {
214  histo->fillProfile(ilayer,LayerEne[ilayer]/GeV);
215  }
216 
217  for (int iring=0; iring<100; iring++)
218  histo->fillTransProf(0.01*iring+0.005,EnRing[iring]/GeV);
219 
220  for (int iphi=0 ; iphi<8; iphi++) {
221  for (int jeta=0 ; jeta<18; jeta++) {
222 
223  //SEnergyN += TowerEneCF[iphi][jeta] + 3.2*randGauss.fire(); // LHEP
224  SEnergyN += TowerEneCF[iphi][jeta] + 3.*randGauss.fire(); // QGSP
225 
226  //double dR=0.08727*sqrt( (jeta-8.)*(jeta-8.)+(iphi-3.)*(iphi-3.) );
227  //cout.testOut << " phi= " << iphi << " eta= " << jeta
228  // << " TowerEne[iphi,jeta]= " << TowerEne[iphi][jeta]
229  // << "dR= " << dR << endl;
230 
231  //double Rand = 3.2*randGauss.fire(); // LHEP
232  double Rand = 3.*randGauss.fire(); // QGSP
233 
234  if ( (iphi>=0) && (iphi<7) ) {
235  if ( (jeta>=5) && (jeta<12) ) {
236 
237  E7x7Matrix += TowerEne[iphi][jeta];
238  E7x7MatrixN += TowerEneCF[iphi][jeta] + Rand;
239 
240  if ( (iphi>=1) && (iphi<6) ) {
241  if ( (jeta>=6) && (jeta<11) ) {
242 
243  E5x5Matrix += TowerEne[iphi][jeta];
244  E5x5MatrixN += TowerEneCF[iphi][jeta] + Rand;
245 
246  }
247  }
248 
249  }
250  }
251 
252  }
253  }
254 
255  //
256  // Find Primary info:
257  //
258  int trackID = 0;
259  G4PrimaryParticle* thePrim=0;
260  G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
261  LogDebug("HcalTBSim") << "HcalTB02Analysis :: Event has " << nvertex
262  << " vertex";
263  if (nvertex==0)
264  edm::LogWarning("HcalTBSim") << "HcalTB02Analysis:: End Of Event "
265  << "ERROR: no vertex";
266 
267  for (int i = 0 ; i<nvertex; i++) {
268 
269  G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
270  if (avertex == 0) {
271  edm::LogWarning("HcalTBSim") << "HcalTB02Analysis:: End Of Event "
272  << "ERROR: pointer to vertex = 0";
273  } else {
274  int npart = avertex->GetNumberOfParticle();
275  LogDebug("HcalTBSim") << "HcalTB02Analysis::Vertex number :" << i
276  << " with " << npart << " particles";
277  if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
278  }
279  }
280 
281  double px=0.,py=0.,pz=0.;
282 
283  if (thePrim != 0) {
284  px = thePrim->GetPx();
285  py = thePrim->GetPy();
286  pz = thePrim->GetPz();
287  pInit = std::sqrt(pow(px,2.)+pow(py,2.)+pow(pz,2.));
288  if (pInit==0) {
289  edm::LogWarning("HcalTBSim") << "HcalTB02Analysis:: End Of Event "
290  << " ERROR: primary has p=0 ";
291  } else {
292  float costheta = pz/pInit;
293  float theta = acos(std::min(std::max(costheta,float(-1.)),float(1.)));
294  eta = -log(tan(theta/2));
295  if (px != 0) phi = atan(py/px);
296  }
297  particleType = thePrim->GetPDGcode();
298  } else {
299  LogDebug("HcalTBSim") << "HcalTB02Analysis:: End Of Event ERROR: could"
300  << " not find primary ";
301  }
302 
303  CaloG4Hit* firstHit =(*theHCHC)[0];
304  incidentEnergy = (firstHit->getIncidentEnergy()/GeV);
305 
306  }// number of Hits > 0
307 
308  if (!hcalOnly) {
309 
310  // XTALS
311 
312  if (XTALSid >= 0 && theXTHC > 0) {
313  for (int xihit = 0; xihit < xentries; xihit++) {
314 
315  CaloG4Hit* xaHit = (*theXTHC)[xihit];
316 
317  float xenEm = xaHit->getEM();
318  float xenhad = xaHit->getHadr();
319  xtalID = xaHit->getUnitID();
320 
321  energyInCrystals[xtalID]+= xenEm + xenhad;
322  }
323 
324  float xCrysEne[7][7];
325  for (int irow=0 ; irow<7; irow++) {
326  for (int jcol=0 ; jcol<7; jcol++) {
327  xCrysEne[irow][jcol]=0.;
328  }
329  }
330 
331  for (std::map<int,float>::iterator is = energyInCrystals.begin();
332  is!= energyInCrystals.end(); is++) {
333  int xtalID = (*is).first;
334  xETot = (*is).second;
335 
336  int irow = (int)(xtalID/100.);
337  int jcol = (int)(xtalID-100.*irow);
338 
339  xSEnergy += xETot;
340  xCrysEne[irow][jcol] = xETot;
341 
342  float dR=std::sqrt( 0.01619*0.01619*(jcol-3)*(jcol-3) +
343  0.01606*0.01606*(irow-3)*(irow-3) );
344  histo->fillTransProf(dR,xETot*1.05);
345 
346  if ( (irow>0) && (irow<6) ) {
347  if ( (jcol>0) && (jcol<6) ) {
348 
349  xE5x5Matrix += xCrysEne[irow][jcol];
350  xE5x5MatrixN += xCrysEne[irow][jcol] + 108.5*randGauss.fire();
351 
352  if ( (irow>1) && (irow<5) ) {
353  if ( (jcol>1) && (jcol<5) ) {
354  xE3x3Matrix += xCrysEne[irow][jcol];
355  xE3x3MatrixN += xCrysEne[irow][jcol] +108.5*randGauss.fire();
356  }
357  }
358  }
359  }
360 
361  }
362 
363  if (!hcalOnly) {
364  // assert(theXTHC);
365  if ( theXTHC != 0 ) {
366  CaloG4Hit* xfirstHit =(*theXTHC)[0];
367  xIncidentEnergy = xfirstHit->getIncidentEnergy()/GeV;
368  }
369  }
370 
371  }// number of Hits > 0
372 
373  }
374 
375  int iEvt = (*evt)()->GetEventID();
376  if (iEvt < 10)
377  std::cout << " Event " << iEvt << std::endl;
378  else if ((iEvt < 100) && (iEvt%10 == 0))
379  std::cout << " Event " << iEvt << std::endl;
380  else if ((iEvt < 1000) && (iEvt%100 == 0))
381  std::cout << " Event " << iEvt << std::endl;
382  else if ((iEvt < 10000) && (iEvt%1000 == 0))
383  std::cout << " Event " << iEvt << std::endl;
384 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void fillTransProf(float u, float v)
Geom::Theta< T > theta() const
double getIncidentEnergy() const
Definition: CaloG4Hit.h:65
double npart
Definition: HydjetWrapper.h:44
std::map< int, float > energyInCrystals
HcalTB02Histo * histo
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
void fillAllTime(float v)
bool isAvailable() const
Definition: Service.h:46
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::map< int, float > primaries
std::map< int, float > energyInScints
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
int getTrackID() const
Definition: CaloG4Hit.h:68
double sd
int getTimeSliceID() const
Definition: CaloG4Hit.h:71
double getEM() const
Definition: CaloG4Hit.h:59
std::vector< std::string > names
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
void fillProfile(int ilayer, float value)
tuple cout
Definition: gather_cfg.py:121
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double getHadr() const
Definition: CaloG4Hit.h:62

Member Data Documentation

float HcalTB02Analysis::E5x5Matrix
private

Definition at line 81 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::E5x5MatrixN
private

Definition at line 82 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::E7x7Matrix
private

Definition at line 81 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::E7x7MatrixN
private

Definition at line 82 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

std::map<int,float> HcalTB02Analysis::energyInCrystals
private

Definition at line 77 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

std::map<int,float> HcalTB02Analysis::energyInScints
private

Definition at line 77 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

double HcalTB02Analysis::eta
private

Definition at line 80 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

std::string HcalTB02Analysis::fileNameTuple
private

Definition at line 73 of file HcalTB02Analysis.h.

bool HcalTB02Analysis::hcalOnly
private

Definition at line 72 of file HcalTB02Analysis.h.

Referenced by HcalTB02Analysis(), and update().

HcalTB02Histo* HcalTB02Analysis::histo
private

Definition at line 69 of file HcalTB02Analysis.h.

Referenced by HcalTB02Analysis(), update(), and ~HcalTB02Analysis().

double HcalTB02Analysis::incidentEnergy
private

Definition at line 80 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

int HcalTB02Analysis::maxTime
private

Definition at line 83 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

std::vector<std::string> HcalTB02Analysis::names
private

Definition at line 74 of file HcalTB02Analysis.h.

Referenced by HcalTB02Analysis(), and update().

int HcalTB02Analysis::particleType
private

Definition at line 79 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

double HcalTB02Analysis::phi
private

Definition at line 80 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

double HcalTB02Analysis::pInit
private

Definition at line 80 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

std::map<int,float> HcalTB02Analysis::primaries
private

Definition at line 78 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::SEnergy
private

Definition at line 81 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::SEnergyN
private

Definition at line 82 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xE3x3Matrix
private

Definition at line 86 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xE3x3MatrixN
private

Definition at line 87 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xE5x5Matrix
private

Definition at line 86 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xE5x5MatrixN
private

Definition at line 87 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

double HcalTB02Analysis::xIncidentEnergy
private

Definition at line 84 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xSEnergy
private

Definition at line 85 of file HcalTB02Analysis.h.

Referenced by clear(), fillEvent(), and update().

float HcalTB02Analysis::xSEnergyN
private

Definition at line 85 of file HcalTB02Analysis.h.

Referenced by clear(), and fillEvent().