32 #include "CLHEP/Random/RandGaussQ.h"
35 #include "G4SDManager.hh"
36 #include "G4VProcess.hh"
37 #include "G4HCofThisEvent.hh"
38 #include "CLHEP/Units/GlobalSystemOfUnits.h"
39 #include "CLHEP/Units/GlobalPhysicalConstants.h"
51 produces<HcalTB02HistoClass>();
53 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis:: Initialised as observer of "
54 <<
"BeginOfJob/BeginOfEvent/EndOfEvent with "
55 <<
"Parameter values:\n \thcalOnly = " <<
hcalOnly;
68 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis is deleting";
84 edm::LogInfo(
"HcalTBSim") <<
"HcalTB02Analysis: =====> Begin of event = "
85 << (*evt) ()->GetEventID();
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.";
99 CLHEP::RandGaussQ randGauss(rng->
getEngine());
102 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis::Fill event "
103 << (*evt)()->GetEventID();
106 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
111 int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
114 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd
115 <<
" of ID " << HCHCid <<
" is obtained at " <<theHCHC;
118 nentries = theHCHC->entries();
119 if (nentries==0)
return;
128 XTALSid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
133 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd
134 <<
" of ID " << XTALSid <<
" is obtained at "
136 xentries = theXTHC->entries();
137 if (xentries==0)
return;
140 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: There are " << nentries
141 <<
" HCal hits, and" << xentries <<
" xtal hits";
143 float ETot=0., xETot=0.;
146 int scintID=0, xtalID=0;
150 if (HCHCid >= 0 && theHCHC > 0) {
151 for ( ihit = 0; ihit < nentries; ihit++) {
156 float enEm = aHit->
getEM();
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.;
184 for (
int ilayer=0; ilayer<19; ilayer++) LayerEne[ilayer]=0.;
185 for (
int iring=0; iring<100; iring++) EnRing[iring]=0.;
194 if ( (layer!=17) && (layer!=18) ) {
200 TowerEne[(int)phi][(
int)
eta] += ETot;
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;
207 LayerEne[layer] += ETot;
211 for (
int ilayer=0 ; ilayer<19 ; ilayer++) {
215 for (
int iring=0; iring<100; iring++)
218 for (
int iphi=0 ; iphi<8; iphi++) {
219 for (
int jeta=0 ; jeta<18; jeta++) {
222 SEnergyN += TowerEneCF[iphi][jeta] + 3.*randGauss.fire();
230 double Rand = 3.*randGauss.fire();
232 if ( (iphi>=0) && (iphi<7) ) {
233 if ( (jeta>=5) && (jeta<12) ) {
238 if ( (iphi>=1) && (iphi<6) ) {
239 if ( (jeta>=6) && (jeta<11) ) {
257 G4PrimaryParticle* thePrim=0;
258 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
259 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis :: Event has " << nvertex
263 <<
"ERROR: no vertex";
265 for (
int i = 0 ;
i<nvertex;
i++) {
267 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
270 <<
"ERROR: pointer to vertex = 0";
272 int npart = avertex->GetNumberOfParticle();
273 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis::Vertex number :" <<
i
274 <<
" with " << npart <<
" particles";
275 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
279 double px=0.,py=0.,pz=0.;
282 px = thePrim->GetPx();
283 py = thePrim->GetPy();
284 pz = thePrim->GetPz();
288 <<
" ERROR: primary has p=0 ";
290 float costheta = pz/
pInit;
293 if (px != 0)
phi = atan(py/px);
297 LogDebug(
"HcalTBSim") <<
"HcalTB02Analysis:: End Of Event ERROR: could"
298 <<
" not find primary ";
310 if (XTALSid >= 0 && theXTHC > 0) {
311 for (
int xihit = 0; xihit < xentries; xihit++) {
315 float xenEm = xaHit->
getEM();
316 float xenhad = xaHit->
getHadr();
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.;
331 int xtalID = (*is).first;
332 xETot = (*is).second;
334 int irow = (int)(xtalID/100.);
335 int jcol = (int)(xtalID-100.*irow);
338 xCrysEne[irow][jcol] = xETot;
340 float dR=
std::sqrt( 0.01619*0.01619*(jcol-3)*(jcol-3) +
341 0.01606*0.01606*(irow-3)*(irow-3) );
344 if ( (irow>0) && (irow<6) ) {
345 if ( (jcol>0) && (jcol<6) ) {
348 xE5x5MatrixN += xCrysEne[irow][jcol] + 108.5*randGauss.fire();
350 if ( (irow>1) && (irow<5) ) {
351 if ( (jcol>1) && (jcol<5) ) {
353 xE3x3MatrixN += xCrysEne[irow][jcol] +108.5*randGauss.fire();
363 if ( theXTHC != 0 ) {
373 int iEvt = (*evt)()->GetEventID();
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;
T getParameter(std::string const &) const
void set_Ntimesli(float v)
T getUntrackedParameter(std::string const &, T const &) const
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)