|
@@ -41,15 +41,17 @@ int main(int argc, char **argv)
|
|
|
{
|
|
|
|
|
|
TString iFileName, oFileName;
|
|
|
+ Bool_t writeAll = false;
|
|
|
if (argc < 5)
|
|
|
{
|
|
|
- std::cerr << "./reducedTreeCreator -i inputfile -o outputfile" << std::endl;
|
|
|
+ std::cerr << "./PicoDstConverter -i inputfile -o outputfile [optional: --all. Writes all events (event with no reco tracks). False by default.]" << std::endl;
|
|
|
return 1;
|
|
|
}
|
|
|
for (int i = 1; i < argc; i++)
|
|
|
{
|
|
|
if (std::string(argv[i]) != "-i" &&
|
|
|
- std::string(argv[i]) != "-o")
|
|
|
+ std::string(argv[i]) != "-o" &&
|
|
|
+ std::string(argv[i]) != "--all")
|
|
|
{
|
|
|
std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl;
|
|
|
return 1;
|
|
@@ -76,6 +78,11 @@ int main(int argc, char **argv)
|
|
|
std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl;
|
|
|
return 1;
|
|
|
}
|
|
|
+ if (std::string(argv[i]) == "--all")
|
|
|
+ {
|
|
|
+ writeAll = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -85,6 +92,12 @@ int main(int argc, char **argv)
|
|
|
///////////////////////////////////////////
|
|
|
//TChain *dstTree;
|
|
|
TFile *fi = new TFile(iFileName.Data(),"read");
|
|
|
+ if (!fi || fi->IsZombie())
|
|
|
+ {
|
|
|
+ std::cerr << "ERROR: Input file probably is empty. Exit the program." << std::endl;
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+
|
|
|
TTree *dstTree = (TTree*) fi->Get("mpdsim");
|
|
|
|
|
|
TFile *outFile = new TFile(oFileName.Data(), "RECREATE");
|
|
@@ -197,7 +210,7 @@ int main(int argc, char **argv)
|
|
|
UsedMCTracks.insert(mpdtrack->GetID());
|
|
|
PicoDstRecoTrack *recoTrack = (PicoDstRecoTrack*)recoTracks->ConstructedAt(itrack);
|
|
|
|
|
|
- recoTrack->SetInitialMcId(mpdtrack->GetID());
|
|
|
+ if (writeAll) recoTrack->SetInitialMcId(mpdtrack->GetID());
|
|
|
recoTrack->SetPx(mpdtrack->GetPx());
|
|
|
recoTrack->SetPy(mpdtrack->GetPy());
|
|
|
recoTrack->SetPz(mpdtrack->GetPz());
|
|
@@ -258,7 +271,7 @@ int main(int argc, char **argv)
|
|
|
InitMcNewMcId[imctrack] = mcTrackCounter;
|
|
|
}
|
|
|
PicoDstMCTrack *mcPicoTrack = (PicoDstMCTrack*)mcTracks->ConstructedAt(mcTrackCounter);
|
|
|
- mcPicoTrack->SetInitialId(imctrack);
|
|
|
+ if (writeAll) mcPicoTrack->SetInitialId(imctrack);
|
|
|
mcPicoTrack->SetPx(mctrack->GetPx());
|
|
|
mcPicoTrack->SetPy(mctrack->GetPy());
|
|
|
mcPicoTrack->SetPz(mctrack->GetPz());
|
|
@@ -275,6 +288,9 @@ int main(int argc, char **argv)
|
|
|
recoTrack->SetMcId(InitMcNewMcId[mpdtrack->GetID()]);
|
|
|
}
|
|
|
|
|
|
+ // Skip if the event has no recontructed tracks
|
|
|
+ if (recoTracks->GetEntriesFast() == 0 && !(writeAll)) continue;
|
|
|
+
|
|
|
outTree->Fill();
|
|
|
} // End of the Event loop
|
|
|
|