11 #include "TParticle.h" 13 #include "TPolyMarker3D.h" 14 #include "TPolyMarker.h" 15 #include "TPolyLine.h" 16 #include "TPolyLine3D.h" 17 #include "TDatabasePDG.h" 20 #include "nuevdb/EventDisplayBase/View2D.h" 21 #include "nuevdb/EventDisplayBase/View3D.h" 22 #include "CoreUtils/ServiceUtil.h" 30 #include "DetectorInfo/DetectorProperties.h" 39 void writeErrMsg(
const char* fcn,
43 <<
" failed with message:\n" 60 double world[3] = {geom->TPCXCent(),geom->TPCYCent(),geom->TPCZCent()};
62 if (
minx>world[0]-geom->TPCRadius())
63 minx = world[0]-geom->TPCRadius();
64 if (
maxx<world[0]+geom->TPCRadius())
65 maxx = world[0]+geom->TPCRadius();
66 if (
miny>world[1]-geom->TPCRadius())
67 miny = world[1]-geom->TPCRadius();
68 if (
maxy<world[1]+geom->TPCRadius())
69 maxy = world[1]+geom->TPCRadius();
70 if (
minz>world[2]-geom->TPCLength()/2.)
71 minz = world[2]-geom->TPCLength()/2.;
72 if (
maxz<world[2]+geom->TPCLength()/2.)
73 maxz = world[2]+geom->TPCLength()/2.;
93 std::vector<const simb::MCTruth*> mctruth;
96 for (
unsigned int i = 0; i<mctruth.size(); ++i) {
105 int jmax = TMath::Min(20,mctruth[i]->NParticles());
106 for (
int j=0; j<jmax; ++j) {
110 sprintf(buff,
"#color[%d]{%s #scale[0.75]{[%.1f GeV/c]}}",
116 sprintf(buff,
"#color[%d]{%s}",
121 if (firstin==
false) incoming +=
" + ";
126 if (firstout==
false) outgoing +=
" + ";
131 if (origin==
"" && incoming==
"") {
135 mctext = origin+incoming+
" #rightarrow "+outgoing;
137 TLatex& latex = view->AddLatex(0.03, 0.2, mctext.c_str());
138 latex.SetTextSize(0.6);
153 std::vector<const simb::MCTruth*> mctruth;
155 std::cout<<
"\nMCTruth Ptcl trackID PDG P T Moth Process\n";
156 for (
unsigned int i=0; i<mctruth.size(); ++i) {
157 for (
int j=0; j<mctruth[i]->NParticles(); ++j) {
160 int KE = 1000 * (p.
E() - p.
Mass());
171 std::cout<<
"Note: Momentum, P, and kinetic energy, T, in MeV/c\n";
185 double xcent = geo->TPCXCent();
186 double ycent = geo->TPCYCent();
187 double zcent = geo->TPCZCent();
193 std::vector<const simb::MCParticle*> plist;
201 int neutralColor(12);
203 int neutrinoColor(38);
215 std::map<int, const simb::MCParticle*> trackToMcParticleMap;
218 double minPartEnergy(0.01);
220 std::cout <<
"MC particle listing (limit 20)" <<
std::endl;
221 std::cout <<
" ID PDG Px Py Pz E (GeV) origin (cm) " <<
std::endl;
223 for(
size_t p = 0;
p < plist.size(); ++
p){
225 trackToMcParticleMap[plist[
p]->TrackId()] = plist[
p];
230 int pdgCode(mcPart->
PdgCode());
233 double partCharge = partPDG ? partPDG->Charge() : 0.;
234 double partEnergy = mcPart->
E();
238 printf(
"%6d %12d %8.3f %8.3f %8.3f %8.3f ",(
int)
p,pdgCode,mcPart->
Px(),mcPart->
Py(),mcPart->
Pz(),partEnergy);
241 double xPos = mcTraj.
X(0) + xcent;
242 double yPos = mcTraj.
Y(0) + ycent;
243 double zPos = mcTraj.
Z(0) + zcent;
244 printf(
"%8.3f %8.3f %8.3f\n",xPos, yPos, zPos);
256 if ( !drawopt->fShowNeutrals && partCharge > -0.1 && partCharge < 0.1)
continue;
259 if (pdgCode == 22 && partEnergy < drawopt->fPhotonEnergyCut)
continue;
262 if (pdgCode == 2112 && partEnergy < drawopt->fNeutronEnergyCut)
continue;
265 if ( partEnergy < drawopt->fOtherNeutralEnergyCut && partCharge > -0.1 && partCharge < 0.1
266 && pdgCode != 22 && pdgCode != 2112)
continue;
270 if (pdgCode >= 1000000000)
continue;
271 if (pdgCode == 111)
continue;
279 if (!mcTraj.
empty() && partEnergy > minPartEnergy && mcPart->
TrackId() < 100000000){
285 int numTrajPoints = mcTraj.
size();
287 std::unique_ptr<double[]> hitPositions(
new double[3*numTrajPoints]);
290 for(
int hitIdx = 0; hitIdx < numTrajPoints; hitIdx++){
291 double xPos = mcTraj.
X(hitIdx) + xcent;
292 double yPos = mcTraj.
Y(hitIdx) + ycent;
293 double zPos = mcTraj.
Z(hitIdx) + zcent;
296 if (xPos < minx || xPos >
maxx || yPos < miny || yPos >
maxy|| zPos < minz || zPos >
maxz)
continue;
300 if (xPos > xMinimum && xPos < xMaximum){
301 hitPositions[3*hitCount ] = zPos;
302 hitPositions[3*hitCount + 1] = xPos;
303 hitPositions[3*hitCount + 2] = yPos;
308 TPolyLine3D& pl(view->AddPolyLine3D(1, colorIdx, 1, 1));
311 if (partCharge == 0.){
312 pl.SetLineColor(neutralColor);
316 pl.SetPolyLine(hitCount, hitPositions.get(),
"");
321 std::map<const simb::MCParticle*, std::vector<std::vector<double> > > partToPosMap;
325 std::map<const simb::MCParticle*, std::vector<std::vector<double> > >
::iterator partToPosMapItr;
327 for(partToPosMapItr = partToPosMap.begin(); partToPosMapItr != partToPosMap.end(); ++partToPosMapItr)
333 if (!mcPart || partToPosMapItr->second.empty())
continue;
339 int markerIdx(kFullDotSmall);
343 colorIdx = grayedColor;
348 TPolyMarker3D&
pm = view->AddPolyMarker3D(partToPosMapItr->second.size(), colorIdx, markerIdx, markerSize);
351 for(
size_t posIdx = 0; posIdx < partToPosMapItr->second.size(); posIdx++){
352 const std::vector<double>& posVec = partToPosMapItr->second[posIdx];
354 double xCoord = posVec[0];
357 if (xCoord > xMinimum && xCoord < xMaximum)
358 pm.SetPoint(posIdx, posVec[2], xCoord, posVec[1]);
363 std::vector<const simb::MCTruth*> mctruth;
367 for (
unsigned int idx = 0; idx < mctruth.size(); idx++){
369 for (
int particleIdx = 0; particleIdx < mctruth[idx]->NParticles(); particleIdx++){
377 TVector3 particlePosition(mcPart.
Vx(),mcPart.
Vy(),mcPart.
Vz());
380 TVector3 oppPartDir(-mcPart.
Px(),-mcPart.
Py(),-mcPart.
Pz());
382 if (oppPartDir.Mag2() > 0.) oppPartDir.SetMag(1.);
385 double arcLenToDraw = 50.0;
388 if (arcLenToDraw > 0.){
390 TPolyLine3D& pl(view->AddPolyLine3D(2, neutrinoColor, 1, 2));
394 pl.SetPoint(0,particlePosition.Z()+zcent,particlePosition.X()+xcent,particlePosition.Y()+ycent);
396 particlePosition +=
std::min(arcLenToDraw + 10.,1000.) * oppPartDir;
398 pl.SetPoint(1,particlePosition.Z()+zcent,particlePosition.X()+xcent,particlePosition.Y()+ycent);
411 std::vector<const simb::MCParticle*>& plist)
419 std::vector<const simb::MCParticle*>
temp;
425 for(
unsigned int i = 0; i < plcol.
vals().size(); ++i){
426 temp.push_back(plcol.
vals().at(i));
431 writeErrMsg(
"GetRawDigits", e);
440 std::vector<const simb::MCTruth*>& mcvec)
446 std::vector<const simb::MCTruth*>
temp;
450 auto mctcol = evt.
getMany<std::vector<simb::MCTruth> >();
451 for(
size_t mctc = 0; mctc < mctcol.size(); ++mctc){
454 for(
size_t i = 0; i < mclistHandle->size(); ++i){
455 temp.push_back(&(mclistHandle->at(i)));
461 writeErrMsg(
"GetMCTruth", e);
double E(const int i=0) const
double Z(const size_type i) const
double X(const size_type i) const
std::map< int, bool > fHighlite
int GetMCTruth(const art::Event &evt, std::vector< const simb::MCTruth * > &mctruth)
double Py(const int i=0) const
void MCTruth3D(const art::Event &evt, evdb::View3D *view)
static const char * LatexName(int pdgcode)
Convert PDG code to a latex string (root-style)
const simb::MCTrajectory & Trajectory() const
double Px(const int i=0) const
art::InputTag fG4ModuleLabel
module label producing sim::SimChannel objects
void MCTruthLongText(const art::Event &evt, evdb::View2D *view)
std::string Process() const
void HiLite(int trkId, bool hlt=true)
void MCTruthShortText(const art::Event &evt, evdb::View2D *view)
double Y(const size_type i) const
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
double P(const int i=0) const
static int ColorFromPDG(int pdgcode)
bool fShowMCTruthTrajectories
int GetParticle(const art::Event &evt, std::vector< const simb::MCParticle * > &plist)
Q_EXPORT QTSManip setw(int w)
General GArSoft Utilities.
double Vx(const int i=0) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double Pz(const int i=0) const
double Vz(const int i=0) const
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
LArSoft geometry interface.
art framework interface to geometry description
double Vy(const int i=0) const
constexpr Point origin()
Returns a origin position with a point of the specified type.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
bool fShowMCTruthFullSize