43 #include "G4HCofThisEvent.hh" 44 #include "G4SDManager.hh" 47 #include "G4ThreeVector.hh" 48 #include "G4VProcess.hh" 50 #include <CLHEP/Random/RandGaussQ.h> 51 #include <CLHEP/Random/Randomize.h> 52 #include <CLHEP/Units/SystemOfUnits.h> 53 #include <CLHEP/Units/PhysicalConstants.h> 61 class HepRandomEngine;
84 std::unique_ptr<HcalTB02Histo>
histo;
89 const std::vector<std::string>
names;
111 hcalOnly(m_Anal.getUntrackedParameter<
bool>(
"HcalClusterOnly",
true)),
113 produces<HcalTB02HistoClass>();
115 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis:: Initialised as observer of " 116 <<
"BeginOfJob/BeginOfEvent/EndOfEvent with " 117 <<
"Parameter values:\n \thcalOnly = " <<
hcalOnly;
136 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis: =====> Begin of event = " << (*evt)()->GetEventID();
142 CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
143 CLHEP::RandGaussQ randGauss(*engine);
147 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis::Fill event " << (*evt)()->GetEventID();
150 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
155 int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
158 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd <<
" of ID " << HCHCid
159 <<
" is obtained at " << theHCHC;
162 nentries = theHCHC->entries();
173 XTALSid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
176 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd <<
" of ID " << XTALSid
177 <<
" is obtained at " << theXTHC;
179 xentries = theXTHC->entries();
185 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: There are " << nentries <<
" HCal hits, and" << xentries
188 float ETot = 0., xETot = 0.;
189 int scintID = 0, xtalID = 0;
194 if (HCHCid >= 0 && theHCHC !=
nullptr) {
195 for (ihit = 0; ihit < nentries; ihit++) {
198 int layer = org->getlayerID(scintID);
199 float enEm = aHit->
getEM();
219 float TowerEne[8][18], TowerEneCF[8][18], LayerEne[19], EnRing[100];
227 for (
int ilayer = 0; ilayer < 19; ilayer++)
228 LayerEne[ilayer] = 0.;
229 for (
int iring = 0; iring < 100; iring++)
235 int layer = org->getlayerID((*is).first);
238 float eta = org->getetaID((*is).first);
239 float phi = org->getphiID((*is).first);
242 int iphi =
static_cast<int>(
phi);
243 int ieta =
static_cast<int>(
eta);
246 TowerEneCF[
iphi][
ieta] += ETot * (1. + 0.1 * randGauss.fire());
248 EnRing[
static_cast<int>(
dR / 0.01)] += ETot;
251 LayerEne[
layer] += ETot;
254 for (
int ilayer = 0; ilayer < 19; ilayer++) {
255 histo->fillProfile(ilayer, LayerEne[ilayer] / GeV);
258 for (
int iring = 0; iring < 100; iring++)
259 histo->fillTransProf(0.01 * iring + 0.005, EnRing[iring] / GeV);
265 double Rand = 3. * randGauss.fire();
287 G4PrimaryParticle* thePrim =
nullptr;
288 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
290 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Event has " << nvertex <<
" vertex";
294 <<
"ERROR: no vertex";
296 for (
int i = 0;
i < nvertex;
i++) {
297 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
298 if (avertex ==
nullptr) {
300 <<
"ERROR: pointer to vertex = 0";
303 int npart = avertex->GetNumberOfParticle();
304 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis::Vertex number :" <<
i <<
" with " <<
npart <<
" particles";
306 if (thePrim ==
nullptr)
307 thePrim = avertex->GetPrimary(trackID);
311 double px = 0.,
py = 0., pz = 0.;
313 if (thePrim !=
nullptr) {
314 px = thePrim->GetPx();
315 py = thePrim->GetPy();
316 pz = thePrim->GetPz();
320 <<
" ERROR: primary has p=0 ";
322 float costheta = pz /
pInit;
331 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis:: End Of Event ERROR: could not find primary ";
343 if (XTALSid >= 0 && theXTHC !=
nullptr) {
344 for (
int xihit = 0; xihit < xentries; xihit++) {
347 float xenEm = xaHit->
getEM();
348 float xenhad = xaHit->
getHadr();
354 float xCrysEne[7][7];
355 for (
int irow = 0; irow < 7; irow++) {
356 for (
int jcol = 0; jcol < 7; jcol++) {
357 xCrysEne[irow][jcol] = 0.;
362 int xtalID = (*is).first;
363 xETot = (*is).second;
365 int irow =
static_cast<int>(xtalID / 100.);
366 int jcol =
static_cast<int>(xtalID - 100. * irow);
369 xCrysEne[irow][jcol] = xETot;
371 float dR =
std::sqrt(0.01619 * 0.01619 * (jcol - 3) * (jcol - 3) + 0.01606 * 0.01606 * (irow - 3) * (irow - 3));
372 histo->fillTransProf(
dR, xETot * 1.05);
374 if ((irow > 0) && (irow < 6)) {
375 if ((jcol > 0) && (jcol < 6)) {
377 xE5x5MatrixN += xCrysEne[irow][jcol] + 108.5 * randGauss.fire();
379 if ((irow > 1) && (irow < 5)) {
380 if ((jcol > 1) && (jcol < 5)) {
382 xE3x3MatrixN += xCrysEne[irow][jcol] + 108.5 * randGauss.fire();
391 if (theXTHC !=
nullptr) {
400 int iEvt = (*evt)()->GetEventID();
403 else if ((iEvt < 100) && (iEvt % 10 == 0))
405 else if ((iEvt < 1000) && (iEvt % 100 == 0))
407 else if ((iEvt < 10000) && (iEvt % 1000 == 0))
Log< level::Info, true > LogVerbatim
void set_Ntimesli(float v)
#define DEFINE_SIMWATCHER(type)
std::map< int, float > energyInScints
void set_xEentry(float v)
~HcalTB02Analysis() override
const HcalTB02Analysis & operator=(const HcalTB02Analysis &)=delete
void produce(edm::Event &, const edm::EventSetup &) override
const std::string names[nVars_]
void fillEvent(HcalTB02HistoClass &)
const edm::ParameterSet m_Anal
HcalTB02Analysis(const edm::ParameterSet &p)
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
std::unique_ptr< HcalTB02Histo > histo
Tan< T >::type tan(const T &t)
std::map< int, float > primaries
const std::vector< std::string > names
int getTimeSliceID() const
void set_partType(float v)
uint32_t getUnitID() const
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
Log< level::Warning, false > LogWarning
double getIncidentEnergy() const
Power< A, B >::type pow(const A &a, const B &b)
std::map< int, float > energyInCrystals