Fix the parsing of DM Truth in MC
In the current version, the p348reco function RecoEvent RunP348ReadMC(std::ifstream& inFile)
reads:
RecoEvent RunP348ReadMC(std::ifstream& inFile)
{
RecoEvent e;
e.mc = std::shared_ptr<MCTruth>(new MCTruth);
string mytag;
while (getline(inFile, mytag)) {
if(mytag == "VERSION") {
...
} else if(mytag == "RUN") {
...
} else if(mytag == "EVENT") {
...
} else if(mytag == "MCTRUTH") {
...
} else if(mytag == "DMTRUTH") {
if(MCFileFormatVersion < 8)
{
double ea, adx, ady, adz, aa;
inFile >> ea >> adx >> ady >> adz >> aa;
}
else
{
double dmxp,dmyp,dmzp,dmxd,dmyd,dmzd,dmpex,dmpey,dmpez,dmppx,dmppy,dmppz;
inFile >> e.mc->DME0 >> e.mc->DMParentID >> e.mc->DME >> dmxp >> dmyp >> dmzp >> dmxd >> dmyd >> dmzd >> dmpex >> dmpey >> dmpez >> dmppx >> dmppy >> dmppz >> e.mc->DMTRID1 >> e.mc->DMTRID2;
//assign it
e.mc->DMP.SetXYZ(dmxp,dmyp,dmzp);
e.mc->DMD.SetXYZ(dmxd,dmyd,dmzd);
e.mc->DMPE.SetXYZM(dmpex,dmpey,dmpez,emass);
e.mc->DMPP.SetXYZM(dmppx,dmppy,dmppz,emass);
}
}
...
If a MC run with DM simulation is performed, some events will contain the "DMTRUTH" part in CaloHits.d output file (those were a DM particle is produced), some will not. For events with no "DMTRUTH" part, the relevant values are not filled, and it seems to me they keep the value from the previous DM event, possibly as a consequence of using a std::shared_ptr.
I propose to initialize the e.mc->DME0 variable to -1, the e.mc->DME variable to -1 and the e.mc->DMParentID to 0 to flag an event where no DM particles are produced.