12 #include "G4LogicalVolumeStore.hh"
15 #include "DD4hep/Filter.h"
29 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget initialized for " << detTypes.size() <<
" detector types";
31 for (
unsigned int ii = 0;
ii < detTypes.size(); ++
ii) {
32 edm::LogInfo(
"MaterialBudget") <<
"Type[" <<
ii <<
"] : " << detTypes[
ii] <<
" with " << constituents[
ii]
33 <<
", order " << stackOrder[
ii] <<
" constituents --> ";
34 for (
int kk = 0;
kk < constituents[
ii]; ++
kk) {
37 if (nc < detNames.size()) {
39 level = detLevels[nc];
42 edm::LogInfo(
"MaterialBudget") <<
" Constituent[" <<
kk <<
"]: " << name <<
" at level " <<
level;
45 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget Stop condition for " << etaRegions.size() <<
" eta regions";
46 for (
unsigned int ii = 0;
ii < etaRegions.size(); ++
ii) {
47 edm::LogInfo(
"MaterialBudget") <<
"Region[" <<
ii <<
"] : Eta < " << etaRegions[
ii] <<
" boundary type "
48 << regionTypes[
ii] <<
" limit " << boundaries[
ii];
56 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
57 std::vector<G4LogicalVolume*>::const_iterator lvcite;
59 unsigned int kount =
detNames.size();
60 for (
unsigned int ii = 0;
ii < kount; ++
ii)
63 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
66 static_cast<std::string>(dd4hep::dd::noNamespace((*lvcite)->GetName())).c_str()) == 0) {
80 name = dd4hep::dd::noNamespace(
logVolumes[
ii]->GetName());
100 const G4Track* aTrack = (*trk)();
101 const G4ThreeVector& mom = aTrack->GetMomentum();
102 if (mom.theta() != 0) {
111 double theEnergy = aTrack->GetTotalEnergy();
112 int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding());
113 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudgetHcalHistos: Track " << aTrack->GetTrackID() <<
" Code " << theID
114 <<
" Energy " << theEnergy / CLHEP::GeV <<
" GeV; Eta " <<
eta_ <<
" Phi "
115 <<
phi_ / CLHEP::deg <<
" PT " << mom.perp() / CLHEP::GeV <<
" GeV *****";
121 G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
122 double step = aStep->GetStepLength();
123 double radl = material->GetRadlen();
124 double intl = material->GetNuclearInterLength();
126 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
127 unsigned int indx =
detTypes.size();
131 if (
detLevels[nc +
kk] <= (
int)((touch->GetHistoryDepth()) + 1)) {
132 int jj = (int)((touch->GetHistoryDepth()) + 1) -
detLevels[nc +
kk];
133 if ((touch->GetVolume(jj)->GetLogicalVolume()) ==
logVolumes[nc +
kk]) {
139 nc += (
unsigned int)(constituents[
ii]);
146 radLen[indx] += (step / radl);
147 intLen[indx] += (step / intl);
149 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget::Step in "
150 << dd4hep::dd::noNamespace(touch->GetVolume(0)->GetLogicalVolume()->GetName())
151 <<
" Index " << indx <<
" Step " << step <<
" RadL " << step / radl <<
" IntL "
156 G4Track*
track = aStep->GetTrack();
157 track->SetTrackStatus(fStopAndKill);
194 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget::Volume[" << ii <<
"]: " << name <<
" eta " <<
eta_ <<
" == Step "
206 <<
"please add it to config file";
213 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget: Booking user "
214 <<
"histos === with " << binEta <<
" bins "
215 <<
"in eta from " << minEta <<
" to " << maxEta <<
" and " << binPhi <<
" bins "
216 <<
"in phi from " << -maxPhi <<
" to " <<
maxPhi;
220 for (
unsigned int i = 0;
i <=
detTypes.size();
i++) {
225 sprintf(name,
"%d",
i + 100);
226 sprintf(title,
"MB(X0) prof Eta in %s", named.c_str());
227 me100.push_back(tfile->
make<TProfile>(name, title, binEta, minEta, maxEta));
228 sprintf(name,
"%d",
i + 200);
229 sprintf(title,
"MB(L0) prof Eta in %s", named.c_str());
230 me200.push_back(tfile->
make<TProfile>(name, title, binEta, minEta, maxEta));
231 sprintf(name,
"%d",
i + 300);
232 sprintf(title,
"MB(Step) prof Eta in %s", named.c_str());
233 me300.push_back(tfile->
make<TProfile>(name, title, binEta, minEta, maxEta));
234 sprintf(name,
"%d",
i + 400);
235 sprintf(title,
"MB(X0) prof Phi in %s", named.c_str());
236 me400.push_back(tfile->
make<TProfile>(name, title, binPhi, -maxPhi, maxPhi));
237 sprintf(name,
"%d",
i + 500);
238 sprintf(title,
"MB(L0) prof Phi in %s", named.c_str());
239 me500.push_back(tfile->
make<TProfile>(name, title, binPhi, -maxPhi, maxPhi));
240 sprintf(name,
"%d",
i + 600);
241 sprintf(title,
"MB(Step) prof Phi in %s", named.c_str());
242 me600.push_back(tfile->
make<TProfile>(name, title, binPhi, -maxPhi, maxPhi));
245 edm::LogInfo(
"MaterialBudget") <<
"MaterialBudget: Booking user "
246 <<
"histos done ===";
250 G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
251 if (aStep->GetPostStepPoint() !=
nullptr)
252 hitPoint = aStep->GetPostStepPoint()->GetPosition();
253 double rr = hitPoint.perp();
259 edm::LogInfo(
"MaterialBudget") <<
" MaterialBudget::Eta " <<
eta_ <<
" in Region[" <<
ii <<
"] with "
264 if (rr >= boundaries[ii] - 0.001)
267 if (zz >= boundaries[ii] - 0.001)
272 edm::LogInfo(
"MaterialBudget") <<
" MaterialBudget::Stop after R = " << rr <<
" and Z = " << zz;
278 edm::LogInfo(
"MaterialBudget") <<
" MaterialBudget:: R = " << rr <<
" and Z = " << zz <<
" Flag " << flag;
T getUntrackedParameter(std::string const &, T const &) const
std::vector< TProfile * > me300
std::vector< int > detLevels
std::vector< double > intLen
std::vector< std::string > detNames
T * make(const Args &...args) const
make new ROOT object
std::vector< int > regionTypes
std::vector< double > stepLen
~MaterialBudget() override
MaterialBudget(const edm::ParameterSet &)
std::vector< TProfile * > me600
std::vector< TProfile * > me100
void book(const edm::ParameterSet &)
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
Abs< T >::type abs(const T &t)
bool stopAfter(const G4Step *)
Log< level::Info, false > LogInfo
std::vector< TProfile * > me400
std::vector< TProfile * > me200
T getParameter(std::string const &) const
std::vector< TProfile * > me500
std::vector< double > boundaries
std::vector< std::string > detTypes
std::vector< double > etaRegions
std::vector< int > stackOrder
std::vector< double > radLen
std::vector< G4LogicalVolume * > logVolumes
std::vector< int > constituents