67 TEveRGBAPalette* palette =
new TEveRGBAPalette(0, 500.0);
69 std::sort(hits.begin(), hits.end(),
71 return a.getEnergy() < b.getEnergy();
74 auto ecal_hits =
new TEveElementList(
"ECAL RecHits");
76 double energy = hit.getEnergy();
83 digiName.Form(
"%1.5g MeV", energy);
85 const UChar_t* rgb = palette->ColorFromValue(energy);
86 TColor* aColor =
new TColor();
87 Int_t color = aColor->GetColor((Int_t)rgb[0], (Int_t)rgb[1], (Int_t)rgb[2]);
91 0, 0, 0, color, 0, digiName);
93 ecal_hits->AddElement(ecalDigiHit);
96 ecal_hits->SetPickableRecursively(1);
102 TEveRGBAPalette* palette =
new TEveRGBAPalette(0, 100.0);
104 std::sort(hits.begin(), hits.end(),
106 return a.getEnergy() < b.getEnergy();
109 auto hcal_hits =
new TEveElementList(
"HCAL Rec Hits");
111 int pe = hit.getPE();
118 const UChar_t* rgb = palette->ColorFromValue(pe);
119 TColor* aColor =
new TColor();
120 Int_t color = aColor->GetColor((Int_t)rgb[0], (Int_t)rgb[1], (Int_t)rgb[2]);
123 digiName.Form(
"%d PEs, Section %d, Layer %d, Bar %d, Z %1.5g", pe,
124 id.section(),
id.layer(),
id.strip(), hit.getZPos());
129 hcal_hit_bb, 0, 0, 0, color, 0, digiName);
133 hcalDigiHit->SetRnrSelf(0);
135 hcal_hits->AddElement(hcalDigiHit);
140 hcal_hits->SetPickableRecursively(1);
145 TEveRGBAPalette* palette =
new TEveRGBAPalette(0, 4000.0);
147 auto eve_clusters =
new TEveElementList(
"Ecal Clusters");
151 clusterName.Form(
"ECAL Cluster %d", iC);
153 TEveElement* ecalCluster =
new TEveElementList(clusterName);
155 double energy = cluster.getEnergy();
156 std::vector<unsigned int> clusterHitIDs = cluster.getHitIDs();
158 int numHits = clusterHitIDs.size();
160 for (
int iHit = 0; iHit < numHits; iHit++) {
163 const UChar_t* rgb = palette->ColorFromValue(energy);
164 TColor* aColor =
new TColor();
166 aColor->GetColor((Int_t)rgb[0], (Int_t)rgb[1], (Int_t)rgb[2]);
171 ecalCluster->AddElement(ecalDigiHit);
174 ecalCluster->SetPickableRecursively(0);
176 ecalCluster->SetPickableRecursively(1);
179 eve_clusters->AddElement(ecalCluster);
183 eve_clusters->SetPickable(1);
189 if (hits.empty())
return;
194 if (
id.subdet() == ldmx::SubdetectorIDType::SD_TRACKER_RECOIL) {
197 auto recoil_tracker_hits =
new TEveElementList(
"Recoil Tracker Hits");
199 std::vector<float> xyzPos = hit.getPosition();
200 double energy = hit.getEdep();
203 recoilName.Form(
"Recoil Hit %d", iter);
210 kRed + 1, 0, recoilName);
211 recoil_tracker_hits->AddElement(recoilHit);
216 }
else if (
id.subdet() == ldmx::SubdetectorIDType::SD_SIM_SPECIAL) {
219 std::sort(hits.begin(), hits.end(),
221 return a.getTrackID() < b.getTrackID();
224 auto lastUniqueEntry =
225 std::unique(hits.begin(), hits.end(),
227 return a.getTrackID() == b.getTrackID();
230 hits.erase(lastUniqueEntry, hits.end());
232 auto leaving_ecal_sim_particles =
233 new TEveElementList(
"SimParticles leaving ECAL");
235 std::vector<double> pVec = spHit.getMomentum();
236 double p = pow(pow(pVec[0], 2) + pow(pVec[1], 2) + pow(pVec[2], 2), 0.5);
238 double E = spHit.getEnergy();
240 std::vector<float> simStart = spHit.getPosition();
241 std::vector<double> simDir = pVec;
243 pow(pow(simDir[0], 2) + pow(simDir[1], 2) + pow(simDir[2], 2), 0.5);
247 if (abs(simDir[0]) > 3500.0) {
248 scale = 500.0 / abs(simDir[0]);
251 if (abs(simDir[1]) > 3500.0 && abs(simDir[1]) > largest) {
252 scale = 500.0 / abs(simDir[1]);
255 if (abs(simDir[2]) > 3500.0 && abs(simDir[2]) > 3500) {
256 scale = 500.0 / abs(simDir[2]);
259 double r = pow(pow(scale * (simDir[0]), 2) + pow(scale * (simDir[1]), 2) +
260 pow(scale * (simDir[2]), 2),
262 signed int pdgID = spHit.getPdgID();
265 new TEveArrow(scale * simDir[0], scale * simDir[1], scale * simDir[2],
266 simStart[0], simStart[1], simStart[2]);
268 simArr->SetMainColor(kBlack);
269 simArr->SetTubeR(60 * 0.02 / r);
270 simArr->SetConeL(100 * 0.02 / r);
271 simArr->SetConeR(150 * 0.02 / r);
272 simArr->SetPickable(kTRUE);
274 simArr->SetRnrSelf(kFALSE);
278 name.Form(
"PDG = %d, p = %1.5g MeV/c", pdgID, p);
279 simArr->SetElementName(name);
280 leaving_ecal_sim_particles->AddElement(simArr);
285 EXCEPTION_RAISE(
"NotImp",
286 "SimTrackerHit drawing not implemented for subdet " +
287 std::to_string(
int(
id.subdet())));
293 if (hits.empty())
return;
298 TEveRGBAPalette* palette =
new TEveRGBAPalette(0, 100.0);
301 hits.begin(), hits.end(),
303 return a.getEdep() < b.getEdep();
306 if (
id.subdet() == ldmx::SubdetectorIDType::SD_HCAL) {
307 auto hcal_hits =
new TEveElementList(
"HCAL Sim Hits");
311 float edep = hit.getEdep();
313 const UChar_t* rgb = palette->ColorFromValue(edep);
314 TColor* aColor =
new TColor();
316 aColor->GetColor((Int_t)rgb[0], (Int_t)rgb[1], (Int_t)rgb[2]);
318 auto position{hit.getPosition()};
321 digiName.Form(
"%.2f MeV, Section %d, Layer %d, Bar %d, Z %1.5g",
322 hit.getEdep(),
id.section(),
id.layer(),
id.strip(),
326 position.at(0), position.at(1), position.at(2), 50., 50., 10., 0, 0,
327 0, color, 0, digiName);
330 hcal_hits->AddElement(eve_hit);
335 hcal_hits->SetPickableRecursively(1);
338 }
else if (
id.subdet() == ldmx::SubdetectorIDType::SD_ECAL) {
339 auto ecal_hits =
new TEveElementList(
"ECAL Sim Hits");
343 float edep = hit.getEdep();
345 const UChar_t* rgb = palette->ColorFromValue(edep);
346 TColor* aColor =
new TColor();
348 aColor->GetColor((Int_t)rgb[0], (Int_t)rgb[1], (Int_t)rgb[2]);
351 digiName.Form(
"%.2f MeV, Module %d, Layer %d, Cell %d", hit.getEdep(),
352 id.module(),
id.layer(),
id.cell());
354 auto position{hit.getPosition()};
357 position.at(0), position.at(1), position.at(2), 0, 0, 0, 1., 2.,
361 ecal_hits->AddElement(eve_hit);
366 ecal_hits->SetPickableRecursively(1);
370 EXCEPTION_RAISE(
"NotImp",
371 "SimCalorimeterHit drawing not implemented for subdet " +
372 std::to_string(
int(
id.subdet())));
377 static const std::map<int, char*> translation = {
378 {int(ldmx::SimParticle::ProcessType::unknown),
"unknown"},
379 {int(ldmx::SimParticle::ProcessType::annihil),
"annihil"},
380 {int(ldmx::SimParticle::ProcessType::compt),
"compt"},
381 {int(ldmx::SimParticle::ProcessType::conv),
"conv"},
382 {int(ldmx::SimParticle::ProcessType::electronNuclear),
"electronNuclear"},
383 {int(ldmx::SimParticle::ProcessType::eBrem),
"eBrem"},
384 {int(ldmx::SimParticle::ProcessType::eIoni),
"eIoni"},
385 {int(ldmx::SimParticle::ProcessType::msc),
"msc"},
386 {int(ldmx::SimParticle::ProcessType::phot),
"phot"},
387 {int(ldmx::SimParticle::ProcessType::photonNuclear),
"photonNuclear"},
388 {int(ldmx::SimParticle::ProcessType::GammaToMuPair),
"GammaToMuPair"},
389 {int(ldmx::SimParticle::ProcessType::eDarkBrem),
"eDarkBrem"}};
391 TString eve_list_name;
392 eve_list_name.Form(
"SimParticles above %.1f MeV",
simThresh_);
393 auto sim_particles =
new TEveElementList(eve_list_name);
395 for (
auto const& [track_id, particle] : particles) {
397 if (particle.getEnergy() - particle.getMass() <
simThresh_)
continue;
399 std::vector<double> pVec = particle.getMomentum();
401 pow(pow(pVec.at(0), 2) + pow(pVec.at(1), 2) + pow(pVec.at(2), 2), 0.5);
403 std::vector<double> simStart = particle.getVertex();
404 std::vector<double> simEnd = particle.getEndPoint();
405 std::vector<double> simDir = {0., 0., 0.};
406 for (
int i = 0; i < 3; i++) simDir[i] = simEnd.at(i) - simStart.at(i);
409 new TEveArrow(simDir.at(0), simDir.at(1), simDir.at(2), simStart.at(0),
410 simStart.at(1), simStart.at(2));
412 double r = pow(pow((simDir.at(0)), 2) + pow((simDir.at(1)), 2) +
413 pow((simDir.at(2)), 2),
416 simArr->SetMainColor(kBlack);
417 simArr->SetTubeR(60 * 0.02 / r);
418 simArr->SetConeL(100 * 0.02 / r);
419 simArr->SetConeR(150 * 0.02 / r);
420 simArr->SetPickable(kTRUE);
423 if (not particle.getParents().empty())
424 parent_id = particle.getParents().at(0);
427 name.Form(
"PDG = %d, p = %1.5g MeV/c from track ID %d via %s process",
428 particle.getPdgID(), p, parent_id,
429 translation.at(particle.getProcessType()));
430 simArr->SetElementName(name);
431 sim_particles->AddElement(simArr);
TEveGeoShape * drawRectPrism(Double_t xPos, Double_t yPos, Double_t zPos, Double_t dX, Double_t dY, Double_t dZ, Double_t xRot, Double_t yRot, Double_t zRot, Int_t color, Int_t transparency, TString name)
Draw a rectangular prism.
TEveGeoShape * drawHexPrism(Double_t xPos, Double_t yPos, Double_t zPos, Double_t xRot, Double_t yRot, Double_t zRot, Double_t h, Double_t r, Int_t color, Int_t transparency, TString name)
Draw a hexagonal prism.