35 #include "CLHEP/Random/RandGaussQ.h"
38 #include "G4SDManager.hh"
39 #include "G4VProcess.hh"
40 #include "G4HCofThisEvent.hh"
41 #include "CLHEP/Units/GlobalSystemOfUnits.h"
42 #include "CLHEP/Units/GlobalPhysicalConstants.h"
54 produces<HcalTB02HistoClass>();
56 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis:: Initialised as observer of "
57 <<
"BeginOfJob/BeginOfEvent/EndOfEvent with "
58 <<
"Parameter values:\n \thcalOnly = " <<
hcalOnly;
71 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis is deleting";
87 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis: =====> Begin of event = "
88 << (*evt) ()->GetEventID();
97 <<
"HcalTB02Analysis requires the RandomNumberGeneratorService\n"
98 <<
"which is not present in the configuration file. "
99 <<
"You must add the service\n in the configuration file or "
100 <<
"remove the modules that require it.";
102 CLHEP::RandGaussQ randGauss(rng->
getEngine());
105 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis::Fill event "
106 << (*evt)()->GetEventID();
109 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
114 int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
117 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd
118 <<
" of ID " << HCHCid <<
" is obtained at " <<theHCHC;
121 nentries = theHCHC->entries();
122 if (nentries==0)
return;
131 XTALSid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
136 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd
137 <<
" of ID " << XTALSid <<
" is obtained at "
139 xentries = theXTHC->entries();
140 if (xentries==0)
return;
143 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: There are " << nentries
144 <<
" HCal hits, and" << xentries <<
" xtal hits";
146 float ETot=0., xETot=0.;
149 int scintID=0, xtalID=0;
153 if (HCHCid >= 0 && theHCHC > 0) {
154 for ( ihit = 0; ihit < nentries; ihit++) {
159 float enEm = aHit->
getEM();
179 float TowerEne[8][18], TowerEneCF[8][18], LayerEne[19], EnRing[100];
180 for (
int iphi=0 ; iphi<8; iphi++) {
181 for (
int jeta=0 ; jeta<18; jeta++) {
182 TowerEne[iphi][jeta]=0.;
183 TowerEneCF[iphi][jeta]=0.;
187 for (
int ilayer=0; ilayer<19; ilayer++) LayerEne[ilayer]=0.;
188 for (
int iring=0; iring<100; iring++) EnRing[iring]=0.;
197 if ( (layer!=17) && (layer!=18) ) {
203 TowerEne[(int)phi][(
int)
eta] += ETot;
205 TowerEneCF[(int)phi][(
int)
eta] += ETot*(1.+ 0.1*randGauss.fire() );
206 double dR=0.08727*
std::sqrt( (eta-8.)*(eta-8.) + (phi-3.)*(phi-3.) );
207 EnRing[(int)(dR/0.01)] += ETot;
210 LayerEne[layer] += ETot;
214 for (
int ilayer=0 ; ilayer<19 ; ilayer++) {
218 for (
int iring=0; iring<100; iring++)
221 for (
int iphi=0 ; iphi<8; iphi++) {
222 for (
int jeta=0 ; jeta<18; jeta++) {
225 SEnergyN += TowerEneCF[iphi][jeta] + 3.*randGauss.fire();
233 double Rand = 3.*randGauss.fire();
235 if ( (iphi>=0) && (iphi<7) ) {
236 if ( (jeta>=5) && (jeta<12) ) {
241 if ( (iphi>=1) && (iphi<6) ) {
242 if ( (jeta>=6) && (jeta<11) ) {
260 G4PrimaryParticle* thePrim=0;
261 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
262 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Event has " << nvertex
266 <<
"ERROR: no vertex";
268 for (
int i = 0 ;
i<nvertex;
i++) {
270 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
273 <<
"ERROR: pointer to vertex = 0";
275 int npart = avertex->GetNumberOfParticle();
276 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis::Vertex number :" <<
i
277 <<
" with " << npart <<
" particles";
278 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
282 double px=0.,py=0.,pz=0.;
285 px = thePrim->GetPx();
286 py = thePrim->GetPy();
287 pz = thePrim->GetPz();
291 <<
" ERROR: primary has p=0 ";
293 float costheta = pz/
pInit;
296 if (px != 0)
phi = atan(py/px);
300 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis:: End Of Event ERROR: could"
301 <<
" not find primary ";
313 if (XTALSid >= 0 && theXTHC > 0) {
314 for (
int xihit = 0; xihit < xentries; xihit++) {
318 float xenEm = xaHit->
getEM();
319 float xenhad = xaHit->
getHadr();
325 float xCrysEne[7][7];
326 for (
int irow=0 ; irow<7; irow++) {
327 for (
int jcol=0 ; jcol<7; jcol++) {
328 xCrysEne[irow][jcol]=0.;
334 int xtalID = (*is).first;
335 xETot = (*is).second;
337 int irow = (int)(xtalID/100.);
338 int jcol = (int)(xtalID-100.*irow);
341 xCrysEne[irow][jcol] = xETot;
343 float dR=
std::sqrt( 0.01619*0.01619*(jcol-3)*(jcol-3) +
344 0.01606*0.01606*(irow-3)*(irow-3) );
347 if ( (irow>0) && (irow<6) ) {
348 if ( (jcol>0) && (jcol<6) ) {
351 xE5x5MatrixN += xCrysEne[irow][jcol] + 108.5*randGauss.fire();
353 if ( (irow>1) && (irow<5) ) {
354 if ( (jcol>1) && (jcol<5) ) {
356 xE3x3MatrixN += xCrysEne[irow][jcol] +108.5*randGauss.fire();
366 if ( theXTHC != 0 ) {
376 int iEvt = (*evt)()->GetEventID();
378 std::cout <<
" Event " << iEvt << std::endl;
379 else if ((iEvt < 100) && (iEvt%10 == 0))
380 std::cout <<
" Event " << iEvt << std::endl;
381 else if ((iEvt < 1000) && (iEvt%100 == 0))
382 std::cout <<
" Event " << iEvt << std::endl;
383 else if ((iEvt < 10000) && (iEvt%1000 == 0))
384 std::cout <<
" Event " << iEvt << std::endl;
T getParameter(std::string const &) const
void set_Ntimesli(float v)
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_SIMWATCHER(type)
void set_xEentry(float v)
void fillTransProf(float u, float v)
Geom::Theta< T > theta() const
int getphiID(int sID) const
double getIncidentEnergy() const
void fillEvent(HcalTB02HistoClass &)
virtual ~HcalTB02Analysis()
std::map< int, float > energyInCrystals
HcalTB02Analysis(const edm::ParameterSet &p)
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
int getlayerID(int sID) const
void fillAllTime(float v)
Tan< T >::type tan(const T &t)
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...
void update(const BeginOfEvent *evt)
This routine will be called when the appropriate signal arrives.
virtual void produce(edm::Event &, const edm::EventSetup &)
void set_partType(float v)
int getTimeSliceID() const
std::vector< std::string > names
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
void fillProfile(int ilayer, float value)
int getetaID(int sID) const
uint32_t getUnitID() const
Power< A, B >::type pow(const A &a, const B &b)