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::EDProducer &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 43 of file HcalTB02Analysis.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file HcalTB02Analysis.cc.

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

45  : histo(0) {
46 
47  edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("HcalTB02Analysis");
48  hcalOnly = m_Anal.getUntrackedParameter<bool>("HcalClusterOnly",true);
49  names = m_Anal.getParameter<std::vector<std::string> >("Names");
50 
51  produces<HcalTB02HistoClass>();
52 
53  edm::LogInfo("HcalTBSim") << "HcalTB02Analysis:: Initialised as observer of "
54  << "BeginOfJob/BeginOfEvent/EndOfEvent with "
55  << "Parameter values:\n \thcalOnly = " << hcalOnly;
56 
57  histo = new HcalTB02Histo(m_Anal);
58 }
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 60 of file HcalTB02Analysis.cc.

References finish(), and histo.

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

Member Function Documentation

void HcalTB02Analysis::clear ( void  )
private

Definition at line 415 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().

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

Definition at line 384 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().

384  {
385 
386  //Beam information
387  product.set_Nprim(float(primaries.size()));
388  product.set_partType(particleType);
389  product.set_Einit(pInit/GeV);
390  product.set_eta(eta);
391  product.set_phi(phi);
392  product.set_Eentry(incidentEnergy);
393 
394  //Calorimeter energy
395  product.set_ETot(SEnergy/GeV );
396  product.set_E7x7(E7x7Matrix/GeV );
397  product.set_E5x5(E5x5Matrix/GeV );
398  product.set_ETotN(SEnergyN/GeV);
399  product.set_E7x7N(E7x7MatrixN/GeV );
400  product.set_E5x5N(E5x5MatrixN/GeV );
401  product.set_NUnit(float(energyInScints.size()));
402  product.set_Ntimesli(float(maxTime));
403 
404  //crystal information
405  product.set_xEentry(xIncidentEnergy);
406  product.set_xNUnit(float(energyInCrystals.size()));
407  product.set_xETot(xSEnergy/GeV);
408  product.set_xETotN(xSEnergyN/GeV);
409  product.set_xE5x5(xE5x5Matrix/GeV);
410  product.set_xE3x3(xE3x3Matrix/GeV);
411  product.set_xE5x5N(xE5x5MatrixN/GeV);
412  product.set_xE3x3N(xE3x3MatrixN/GeV);
413 }
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 432 of file HcalTB02Analysis.cc.

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

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

Implements SimProducer.

Definition at line 75 of file HcalTB02Analysis.cc.

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

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 82 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().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 89 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, min, names, npart, particleType, phi, pInit, funct::pow(), primaries, sd, SEnergy, SEnergyN, mathSSE::sqrt(), 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().

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

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

float HcalTB02Analysis::E5x5MatrixN
private

Definition at line 83 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::E7x7Matrix
private

Definition at line 82 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::E7x7MatrixN
private

Definition at line 83 of file HcalTB02Analysis.h.

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

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

Definition at line 78 of file HcalTB02Analysis.h.

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

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

Definition at line 78 of file HcalTB02Analysis.h.

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

double HcalTB02Analysis::eta
private

Definition at line 81 of file HcalTB02Analysis.h.

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

std::string HcalTB02Analysis::fileNameTuple
private

Definition at line 74 of file HcalTB02Analysis.h.

bool HcalTB02Analysis::hcalOnly
private

Definition at line 73 of file HcalTB02Analysis.h.

Referenced by HcalTB02Analysis(), and update().

HcalTB02Histo* HcalTB02Analysis::histo
private

Definition at line 70 of file HcalTB02Analysis.h.

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

double HcalTB02Analysis::incidentEnergy
private

Definition at line 81 of file HcalTB02Analysis.h.

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

int HcalTB02Analysis::maxTime
private

Definition at line 84 of file HcalTB02Analysis.h.

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

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

Definition at line 75 of file HcalTB02Analysis.h.

Referenced by HcalTB02Analysis(), and update().

int HcalTB02Analysis::particleType
private

Definition at line 80 of file HcalTB02Analysis.h.

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

double HcalTB02Analysis::phi
private

Definition at line 81 of file HcalTB02Analysis.h.

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

double HcalTB02Analysis::pInit
private

Definition at line 81 of file HcalTB02Analysis.h.

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

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

Definition at line 79 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::SEnergy
private

Definition at line 82 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::SEnergyN
private

Definition at line 83 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xE3x3Matrix
private

Definition at line 87 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xE3x3MatrixN
private

Definition at line 88 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xE5x5Matrix
private

Definition at line 87 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xE5x5MatrixN
private

Definition at line 88 of file HcalTB02Analysis.h.

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

double HcalTB02Analysis::xIncidentEnergy
private

Definition at line 85 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xSEnergy
private

Definition at line 86 of file HcalTB02Analysis.h.

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

float HcalTB02Analysis::xSEnergyN
private

Definition at line 86 of file HcalTB02Analysis.h.

Referenced by clear(), and fillEvent().