16 #include <TDirectory.h>
58 x0_vs_phi =
new TProfile(x0NamePhi.c_str(),
"X_{0} vs. #phi",
bins, -M_PI,
60 l0_vs_phi =
new TProfile(l0NamePhi.c_str(),
"L_{0} vs. #phi",
bins, -M_PI,
99 std::vector<std::tuple<float, float, float, float>>
boxes;
120 float eta,
const std::vector<Region>& regions) {
122 auto inputFile = TFile::Open(inFile.c_str());
123 auto inputTree =
dynamic_cast<TTree*
>(inputFile->Get(treeName.c_str()));
124 if (inputTree ==
nullptr) {
129 TCanvas* materialCanvas =
130 new TCanvas(
"materialCanvas",
"Materials", 100, 100, 620, 400);
131 materialCanvas->cd();
133 inputTree->Draw(
"mat_A>>hA(200,0.5,200.5)");
134 TH1F* histA =
dynamic_cast<TH1F*
>(gDirectory->Get(
"hA"));
137 auto outputFile = TFile::Open(outFile.c_str(),
"recreate");
141 std::vector<float>* stepLength =
new std::vector<float>;
142 std::vector<float>* stepX0 =
new std::vector<float>;
143 std::vector<float>* stepL0 =
new std::vector<float>;
144 std::vector<float>* stepA =
new std::vector<float>;
146 std::vector<float>* stepX =
new std::vector<float>;
147 std::vector<float>* stepY =
new std::vector<float>;
148 std::vector<float>* stepZ =
new std::vector<float>;
150 inputTree->SetBranchAddress(
"v_eta", &v_eta);
151 inputTree->SetBranchAddress(
"v_phi", &v_phi);
152 inputTree->SetBranchAddress(
"mat_step_length", &stepLength);
154 inputTree->SetBranchAddress(
"mat_X0", &stepX0);
155 inputTree->SetBranchAddress(
"mat_L0", &stepL0);
156 inputTree->SetBranchAddress(
"mat_A", &stepA);
158 inputTree->SetBranchAddress(
"mat_x", &stepX);
159 inputTree->SetBranchAddress(
"mat_y", &stepY);
160 inputTree->SetBranchAddress(
"mat_z", &stepZ);
163 unsigned int entries = inputTree->GetEntries();
165 #ifdef BOOST_AVAILABLE
166 std::cout <<
"*** Event Loop: " << std::endl;
171 for (
auto& region : regions) {
172 const auto rName = region.name;
175 std::map<unsigned int, MaterialHistograms> mCache;
179 for (
unsigned int ib = 1;
ib <= 200; ++
ib) {
180 if (histA->GetBinContent(
ib) > 0.) {
185 for (
unsigned int ie = 0; ie < entries; ++ie) {
187 inputTree->GetEntry(ie);
189 #ifdef BOOST_AVAILABLE
190 ++event_loop_progress;
194 size_t steps = stepLength->size();
195 for (
unsigned int is = 0; is <
steps; ++is) {
196 float x = stepX->at(is);
197 float y = stepY->at(is);
198 float z = stepZ->at(is);
199 float r = std::hypot(x, y);
201 if (!region.inside(r, z)) {
205 float step = stepLength->at(is);
206 float X0 = stepX0->at(is);
207 float L0 = stepL0->at(is);
210 auto& all = mCache[0];
211 all.s_x0 += step /
X0;
212 all.s_l0 += step / L0;
214 unsigned int sA = histA->FindBin(stepA->at(is));
216 auto currentIt = mCache.find(sA);
217 if (currentIt == mCache.end()) {
218 throw std::runtime_error{
"Unknown atomic number " +
221 auto& current = currentIt->second;
222 current.s_x0 += step /
X0;
223 current.s_l0 += step / L0;
226 for (
auto& [key, cache] : mCache) {
227 cache.fillAndClear(v_eta, v_phi);
232 for (
auto [key, cache] : mCache) {
248 delete materialCanvas;