14 #include <fwk/CoordinateSystemRegistry.h>
15 #include <fwk/CentralConfig.h>
17 #include <det/Detector.h>
19 #include <evt/Event.h>
20 #include <evt/ShowerSimData.h>
22 #include <utl/ErrorLogger.h>
23 #include <utl/ShowerParticleIterator.h>
24 #include <utl/Particle.h>
25 #include <utl/UTMPoint.h>
27 #include <atm/Atmosphere.h>
28 #include <atm/ProfileResult.h>
35 #include <TFitResult.h>
47 fWriteRootFile(false),
48 fRootFileName(
"dummyFile.root")
52 MuonProfileBuilder::~MuonProfileBuilder()
60 CentralConfig::GetInstance()->
GetTopBranch(
"MuonProfileBuilder");
76 const double zenith = (-simShower.
GetDirection()).GetTheta(localCS);
83 const atm::Atmosphere& theAtm = det::Detector::GetInstance().GetAtmosphere();
87 const double histLowerBound = 0.;
88 const double histUpperBound = 2000.;
89 const double binSize = 5.;
90 const int nBins = (histUpperBound-histLowerBound)/binSize;
97 TH1D survivingMuons(
"surviving",
"surviving muons", nBins, histLowerBound, histUpperBound);
98 TH1D decayedMuons(
"decayed",
"decayed muons", nBins, histLowerBound, histUpperBound);
99 TH1D allMuons(
"all",
"all muons", nBins, histLowerBound, histUpperBound);
107 type = particleIt->GetType();
110 || type == Particle::eDecayedMuon || type == Particle::eDecayedAntiMuon))
114 if (!particleIt->HasProductionPoint())
120 double prod_height = particleIt->GetProductionPoint().GetZ(coreCS) + coreHeight;
121 double x_prod = DepthVsHeight.
Y(prod_height)/cos(zenith);
122 double weight = particleIt->GetWeight();
125 survivingMuons.Fill(x_prod/(
gram/
cm2), weight);
126 else if (type == Particle::eDecayedMuon || type == Particle::eDecayedAntiMuon)
127 decayedMuons.Fill(x_prod/(
gram/
cm2), weight);
129 allMuons.Fill(x_prod/(
gram/
cm2), weight);
132 if (i % 100000 == 0) {
134 msg <<
"read " << i <<
" muons";
141 double histMax = allMuons.GetMaximum();
142 double maxBin = allMuons.GetMaximumBin();
147 for (
int i = 0; i < nBins; ++i) {
148 binContent = allMuons.GetBinContent(i);
149 if (binContent > .7*histMax && firstFitBin == 0)
151 if (binContent < .7*histMax && firstFitBin > 0 && lastFitBin == 0 && i > maxBin)
155 double firstValue = allMuons.GetBinCenter(firstFitBin);
156 double lastValue = allMuons.GetBinCenter(lastFitBin);
158 TF1 func(
"func",
"[0] + [2] * (x - [1])**2 + [3] * (x - [1])**3", firstValue, lastValue);
159 func.SetParameters(histMax, allMuons.GetBinCenter(maxBin), -1, 0);
160 double XmaxMu = allMuons.Fit(
"func",
"RS")->Parameter(1);
164 msg <<
"fitted muon production profile between "
165 << firstValue <<
" g/cm2 and "
166 << lastValue <<
" g/cm2. "
167 <<
"XmaxMu = " << XmaxMu <<
" g/cm2. " << endl;
175 msg <<
"overwriting longitudinal profiles for muons";
180 survivingMuons.Write();
181 decayedMuons.Write();
193 for (
int i = 0; i < nBins; ++i) {
194 profileSurviving.
PushBack(survivingMuons.GetBinCenter(i)*
gram/
cm2, survivingMuons.GetBin(i));
195 profileDecayed.
PushBack(decayedMuons.GetBinCenter(i)*
gram/
cm2, decayedMuons.GetBin(i));
196 profileAll.
PushBack(allMuons.GetBinCenter(i)*
gram/
cm2, allMuons.GetBin(i));
214 MuonProfileBuilder::Finish()
Branch GetTopBranch() const
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
Iterator to retrieve particles from utl::VShowerParticlList.
Top of the interface to Atmosphere information.
utl::ShowerParticleIterator GroundParticlesEnd() const
Report success to RunController.
Class to hold and convert a point in geodetic coordinates.
Class to hold collection (x,y) points and provide interpolation between them.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
void PushBack(const double x, const double y)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
Interface class to access Shower Simulated parameters.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
void MakeLongitudinalProfile(const utl::TabulatedFunction &lp, const ProfileType type=eCharged)
Make the longitudinal charge profile of the shower.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
Class describing the Atmospheric profile.
const utl::Point & GetPosition() const
Get the position of the shower core.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
void SetXmaxMu(const double XmaxMu)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
ResultFlag
Flag returned by module methods to the RunController.
std::string fRootFileName
utl::ShowerParticleIterator GroundParticlesBegin() const
bool HasLongitudinalProfile(const ProfileType type=eCharged) const
Check initialization of the longitudinal profile.
const utl::TabulatedFunction & GetLongitudinalProfile(const ProfileType type=eCharged) const
Get the longitudinal charge profile of the shower.