Add the possibility to read a user-defined event bank in CaloHits.d
I open this issue because frequently it happens to me to customize the NA64 MC code https://gitlab.cern.ch/P348/na64-simulation in order to produce, in CaloHits.d
, one or more new banks for specific studies. For example, to study the decay of hadrons, I added a new section called DECAYTRUTH
, to record the decay products of the primary particle (in case this decays in the setup).
DECAYTRUTH
<n_lines following this>
PID Px Py Pz Vx Vy Vz
PID Px Py Pz Vx Vy Vz
...
PID Px Py Pz Vx Vy Vz
Then, I modified my local copy of p348reco
to parse this block:
else if (mytag == "DECAYTRUTH"){
int nD=0;
int PID;
double Dpx,Dpy,Dpz;
double Dvx,Dvy,Dvz;
inFile >> nD;
for (int iD=0;iD<nD;iD++){
inFile>>nD>>Dpx>>Dpy>>Dpz>>Dvx>>Dvy>>Dvz;
//Do something with the obtained values
}
}
This approach has the clear drawback of breaking compatibility with the central repository - any time a modification is introduced in p348reco.h
and I do a git pull, I get a conflict.
I'd suggest to introduce a more general approach to allow any user to add any new bank in the CaloHits.d
and have p348reco.h
compatible with it.
- Define a new block
USERBANK
with the following syntax:
USERBANK
n
line-1
line-2
...
line-n
with n
being the number of lines following n (ideally >0, but should also handle the case n=0).
- Introduce a new member in the struct
MCtruth
,vector<string> userbank
- Add a code like the following to read the new section of
CaloHits.d
else if (mytag == "USERBANK") {
int nL;
string ss;
inFile >> nL;
inFile.ignore(1000, '\n'); //to be compatible with the use of getline below
for (int ii = 0; ii < nL; ii++) {
getline(inFile, ss);
e.mc->userbank.push_back(ss);
}
continue; //to avoid the ignore instruction at the end of the "mytag" parsing
}
At this point, in any reconstruction code based on p348reco
it will be possible to properly parse the content of USERBANK
.
@akorneev @bbantoob @kirsanov @rdusaev may I ask your feedback on this?