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/GlobalSystemOfUnits.h> 53 #include <CLHEP/Units/GlobalPhysicalConstants.h> 58 class HepRandomEngine;
81 std::unique_ptr<HcalTB02Histo>
histo;
86 const std::vector<std::string>
names;
108 hcalOnly(m_Anal.getUntrackedParameter<
bool>(
"HcalClusterOnly",
true)),
110 produces<HcalTB02HistoClass>();
112 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis:: Initialised as observer of " 113 <<
"BeginOfJob/BeginOfEvent/EndOfEvent with " 114 <<
"Parameter values:\n \thcalOnly = " <<
hcalOnly;
133 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis: =====> Begin of event = " << (*evt)()->GetEventID();
139 CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
140 CLHEP::RandGaussQ randGauss(*engine);
144 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis::Fill event " << (*evt)()->GetEventID();
147 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
152 int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
155 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd <<
" of ID " << HCHCid
156 <<
" is obtained at " << theHCHC;
159 nentries = theHCHC->entries();
170 XTALSid = G4SDManager::GetSDMpointer()->GetCollectionID(sd);
173 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Hit Collection for " << sd <<
" of ID " << XTALSid
174 <<
" is obtained at " << theXTHC;
176 xentries = theXTHC->entries();
182 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: There are " << nentries <<
" HCal hits, and" << xentries
185 float ETot = 0., xETot = 0.;
186 int scintID = 0, xtalID = 0;
191 if (HCHCid >= 0 && theHCHC !=
nullptr) {
192 for (ihit = 0; ihit < nentries; ihit++) {
195 int layer = org->getlayerID(scintID);
196 float enEm = aHit->
getEM();
216 float TowerEne[8][18], TowerEneCF[8][18], LayerEne[19], EnRing[100];
224 for (
int ilayer = 0; ilayer < 19; ilayer++)
225 LayerEne[ilayer] = 0.;
226 for (
int iring = 0; iring < 100; iring++)
232 int layer = org->getlayerID((*is).first);
235 float eta = org->getetaID((*is).first);
236 float phi = org->getphiID((*is).first);
239 int iphi =
static_cast<int>(
phi);
240 int ieta =
static_cast<int>(
eta);
243 TowerEneCF[
iphi][
ieta] += ETot * (1. + 0.1 * randGauss.fire());
245 EnRing[
static_cast<int>(
dR / 0.01)] += ETot;
248 LayerEne[
layer] += ETot;
251 for (
int ilayer = 0; ilayer < 19; ilayer++) {
252 histo->fillProfile(ilayer, LayerEne[ilayer] / GeV);
255 for (
int iring = 0; iring < 100; iring++)
256 histo->fillTransProf(0.01 * iring + 0.005, EnRing[iring] / GeV);
262 double Rand = 3. * randGauss.fire();
284 G4PrimaryParticle* thePrim =
nullptr;
285 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
287 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis :: Event has " << nvertex <<
" vertex";
291 <<
"ERROR: no vertex";
293 for (
int i = 0;
i < nvertex;
i++) {
294 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
295 if (avertex ==
nullptr) {
297 <<
"ERROR: pointer to vertex = 0";
300 int npart = avertex->GetNumberOfParticle();
301 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis::Vertex number :" <<
i <<
" with " <<
npart <<
" particles";
303 if (thePrim ==
nullptr)
304 thePrim = avertex->GetPrimary(trackID);
308 double px = 0.,
py = 0., pz = 0.;
310 if (thePrim !=
nullptr) {
311 px = thePrim->GetPx();
312 py = thePrim->GetPy();
313 pz = thePrim->GetPz();
317 <<
" ERROR: primary has p=0 ";
319 float costheta = pz /
pInit;
328 edm::LogVerbatim(
"HcalTBSim") <<
"HcalTB02Analysis:: End Of Event ERROR: could not find primary ";
340 if (XTALSid >= 0 && theXTHC !=
nullptr) {
341 for (
int xihit = 0; xihit < xentries; xihit++) {
344 float xenEm = xaHit->
getEM();
345 float xenhad = xaHit->
getHadr();
351 float xCrysEne[7][7];
352 for (
int irow = 0; irow < 7; irow++) {
353 for (
int jcol = 0; jcol < 7; jcol++) {
354 xCrysEne[irow][jcol] = 0.;
359 int xtalID = (*is).first;
360 xETot = (*is).second;
362 int irow =
static_cast<int>(xtalID / 100.);
363 int jcol =
static_cast<int>(xtalID - 100. * irow);
366 xCrysEne[irow][jcol] = xETot;
368 float dR =
std::sqrt(0.01619 * 0.01619 * (jcol - 3) * (jcol - 3) + 0.01606 * 0.01606 * (irow - 3) * (irow - 3));
369 histo->fillTransProf(
dR, xETot * 1.05);
371 if ((irow > 0) && (irow < 6)) {
372 if ((jcol > 0) && (jcol < 6)) {
374 xE5x5MatrixN += xCrysEne[irow][jcol] + 108.5 * randGauss.fire();
376 if ((irow > 1) && (irow < 5)) {
377 if ((jcol > 1) && (jcol < 5)) {
379 xE3x3MatrixN += xCrysEne[irow][jcol] + 108.5 * randGauss.fire();
388 if (theXTHC !=
nullptr) {
397 int iEvt = (*evt)()->GetEventID();
400 else if ((iEvt < 100) && (iEvt % 10 == 0))
402 else if ((iEvt < 1000) && (iEvt % 100 == 0))
404 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 &)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
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
Geom::Theta< T > theta() const
Power< A, B >::type pow(const A &a, const B &b)
std::map< int, float > energyInCrystals