#include #include #include #include #include #include #include class IReconGlobalValidTree: public COMET::ICOMETEventLoopFunction { public: IReconGlobalValidTree() {} virtual ~IReconGlobalValidTree() {} void Initialize(); void Finalize(COMET::ICOMETOutput* output); bool operator () (COMET::ICOMETEvent& event); IReconGlobalUtils fUtils; }; //************************************************************** void IReconGlobalValidTree::Initialize(){ //************************************************************** COMET::vman().AddTreeValid("COMETValidTree"); } //************************************************************** bool IReconGlobalValidTree::operator () (COMET::ICOMETEvent& event) { //************************************************************** COMET::IHandle GlobRec = event.GetFit("ReconGlobal"); if ( GlobRec ) { COMET::IHandle allTracks = GlobRec->GetResultsContainer("final"); if ( allTracks ) { // std::cout << std::endl; // std::cout << "********** SUMMARY OF GLOBAL RECON *****************" << std::endl; // COMET::tman().DumpContainerWithHistory(*allTracks); // std::cout << "****************************************************" << std::endl; // std::cout << std::endl; for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconGlobal"); // Get the inner object (P0D+TRACKER) if (!((*it)->UsesDetector(COMET::IReconBase::kTPC)) || (*it)->CheckStatus(COMET::IReconBase::kLikelihoodFit)) continue; COMET::IHandle innerObject = *it; if (innerObject->UsesDetector(COMET::IReconBase::kSMRD)) innerObject = COMET::tman().GetConstituentNotUsingDetector(innerObject,COMET::IReconBase::kSMRD); if (innerObject->UsesDetector(COMET::IReconBase::kECal)) innerObject = COMET::tman().GetConstituentNotUsingDetector(innerObject,COMET::IReconBase::kECal); if (innerObject->UsesDetector(COMET::IReconBase::kDSECal)) innerObject = COMET::tman().GetConstituentNotUsingDetector(innerObject,COMET::IReconBase::kDSECal); COMET::IHandle ThePID = innerObject; if (ThePID){ const COMET::IReconObjectContainer& alter = ThePID->GetAlternates(); for ( std::vector< COMET::IHandle >::const_iterator ot=alter.begin(); ot!=alter.end(); ot++ ){ COMET::vman().FillTreeValid("COMETValidTree", *ot, "ReconGlobalAltPID"); } } } } } COMET::IHandle P0dRec = event.GetFit("ReconP0D"); if ( P0dRec ) { COMET::IHandle allVertices = P0dRec->GetResultsContainer("final"); COMET::IHandle allTracks( new COMET::IReconObjectContainer("p0d")); fUtils.GetObjectsFromVertices(allVertices, allTracks); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconP0D"); } } } COMET::IHandle TrackerRec = event.GetFit("ReconTracker"); if ( TrackerRec ) { COMET::IHandle allTracks = TrackerRec->GetResultsContainer("final"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconTracker"); } } } COMET::IHandle TpcRec = event.GetFit("ReconTPC"); if ( TpcRec ) { COMET::IHandle allTracks = TpcRec->GetResultsContainer("final"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconTPC"); } } } COMET::IHandle FgdRec = event.GetFit("ReconFGD"); if ( FgdRec ) { COMET::IHandle allIsoTracks = FgdRec->GetResultsContainer("FGDPids"); if ( allIsoTracks ) { for ( COMET::IReconObjectContainer::iterator it=allIsoTracks->begin(); it!=allIsoTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconFGD"); } } COMET::IHandle allTracks = FgdRec->GetResultsContainer("fittedFgdTpcReconObjects"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconFGD"); } } } COMET::IHandle EcalRec = event.GetFit("ReconECal"); if ( EcalRec ) { COMET::IHandle allTracks = EcalRec->GetResultsContainer("final"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconECal"); } } } COMET::IHandle P0decalRec = event.GetFit("ReconP0DECal"); if ( P0decalRec ) { COMET::IHandle allTracks = P0decalRec->GetResultsContainer("final"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconP0DECal"); } } } COMET::IHandle SmrdRec = event.GetFit("ReconSMRD"); if ( SmrdRec ) { COMET::IHandle allTracks = SmrdRec->GetResultsContainer("final"); if ( allTracks ) { for ( COMET::IReconObjectContainer::iterator it=allTracks->begin(); it!=allTracks->end(); it++ ){ COMET::vman().FillTreeValid("COMETValidTree", *it, "ReconSMRD"); } } } return false; } //***************************************************************************** void IReconGlobalValidTree::Finalize (COMET::ICOMETOutput* output){ //***************************************************************************** //Remove COMET Structure from outputted root file. output->Delete("COMETEvents;*"); output->Delete("COMETGeometry*;*"); } //***************************************************************************** int main(int argc, char **argv) { //***************************************************************************** IReconGlobalValidTree userCode; cometEventLoop(argc,argv,userCode); }