3 #include <TParticlePDG.h> 
    5 #include <HelixModel.hxx> 
    6 #include <ND280GeomId.hxx> 
    7 #include <ReconObjectUtils.hxx> 
    8 #include <ReconPrintout.hxx> 
    9 #include <TG4Trajectory.hxx> 
   10 #include <TG4TrajectoryPoint.hxx> 
   11 #include <TGeomIdManager.hxx> 
   12 #include <TEventReconUtils.hxx> 
   13 #include <TrackTruthInfo.hxx> 
   14 #include <TrackingUtils.hxx> 
   17 #include "TGeomInfo.hxx" 
   18 #include "TOARuntimeParams.hxx" 
   19 #include "TPrincipal.h" 
   20 #include "TRealDatum.hxx" 
   21 #include "TReconNode.hxx" 
   39     $Id: eventAnalysis TReconPerformanceEvalModule.cxx,2024/03/20:09:46:10,Alexander_J_Finch,lapw.lancs.ac.uk $" 
   42     const char* name, 
const char* title) {
 
   51       "ND::TReconPerformanceEvalModule::TGlobalReconObject", 200);
 
   60     ND::TND280Event& event) {
 
   65     ND::TND280Event& event) {
 
   66   return (fNGlobalReconObjects ? 
true : 
false);
 
   73   fOutputTree->Branch(
"NGlobalReconObject", &fNGlobalReconObjects,
 
   74                       "NGlobalReconObject/I", fBufferSize);
 
   77   fOutputTree->Branch(
"GlobalReconObject", &fGlobalReconObjects, fBufferSize,
 
   81   fOutputTree->Branch(
"HitInfo", &fHitInfo, fBufferSize, fSplitLevel);
 
   85   if (fFilledConfigTree) {
 
   87         "TReconPerformanceEvalModule",
 
   88         "Module: " << this->GetName()
 
   89                    << 
" has already written the config tree this run.");
 
   92   configTree->Branch(
"SaveAllGlobalNodes", &fSaveAllGlobalNodes,
 
   93                      "SaveAllGlobalNodes/O");
 
  100   fNGlobalReconObjects = 0;
 
  101   fGlobalReconObjects->Clear();
 
  104   ND::THandle<ND::TAlgorithmResult> globalResult = 
event.GetFit(
"oaRecon");
 
  107     ND280Verbose(
"Got global result for event ID " << event.GetEventId());
 
  108     for (ND::TDataVector::iterator dataIter = globalResult->begin();
 
  109          dataIter != globalResult->end(); ++dataIter) {
 
  111       std::string class_name = (*dataIter)->ClassName();
 
  112       TString object_name = (*dataIter)->GetName();
 
  114       if (class_name.find(
"ND::TReconObjectContainer") != std::string::npos &&
 
  115           object_name.EqualTo(
"final")) {
 
  116         ND::TReconObjectContainer* reconContainer =
 
  117             dynamic_cast<ND::TReconObjectContainer*
>(*dataIter);
 
  119         if (!reconContainer) {
 
  120           ND280Warn(
"Dynamic cast of ReconObjectContainer didn't work");
 
  124         for (ND::TReconObjectContainer::iterator reconIter =
 
  125                  reconContainer->begin();
 
  126              reconIter != reconContainer->end(); ++reconIter) {
 
  128           ND::THandle<ND::TReconBase> globalObject = (*reconIter);
 
  131               new ((*fGlobalReconObjects)[fNGlobalReconObjects])
 
  134           FillGlobalInfo(event, globalObject, globalReconObject);
 
  135           fNGlobalReconObjects++;
 
  137           ND::TReconObjectContainer conContainer =
 
  138               GetConstituentsOfInterest(globalObject);
 
  139           ND280Verbose(
"  Next PID - got " << conContainer.size()
 
  141                                            << globalObject->ConvertDetector());
 
  144           for (ND::TReconObjectContainer::iterator conIter =
 
  145                    conContainer.begin();
 
  146                conIter != conContainer.end(); ++conIter) {
 
  147             ND::THandle<ND::TReconBase> base = (*conIter);
 
  149             ND280Verbose(
"    " << base->ClassName() << 
" from " 
  150                                 << base->ConvertDetector());
 
  152                 new ((*(globalReconObject
 
  155             FillConstituentInfo(event, base, globalObject, constituent);
 
  161             std::string det = base->ConvertDetector();
 
  167           if (ContainsTracker(globalObject) && !IsOnlyTracker(globalObject)) {
 
  168             ND::TReconObjectContainer trackerConContainer =
 
  169                 GetDownToTracker(globalObject);
 
  170             ND280Verbose(
"  Next PID - got " 
  171                          << trackerConContainer.size()
 
  172                          << 
" constituents on way to tracker, " 
  173                          << globalObject->ConvertDetector());
 
  175             for (ND::TReconObjectContainer::iterator conIter =
 
  176                      trackerConContainer.begin();
 
  177                  conIter != trackerConContainer.end(); ++conIter) {
 
  178               ND::THandle<ND::TReconBase> base = (*conIter);
 
  180               ND280Verbose(
"    " << base->ClassName() << 
" from " 
  181                                   << base->ConvertDetector());
 
  186               FillDownToTrackerInfo(base, constituent);
 
  192           ND::TReconObjectContainer mConContainer =
 
  193               ReconObjectUtils::GetConstituentsRecursive(globalObject, 
true);
 
  194           ND280Verbose(
"  Got " << mConContainer.size()
 
  195                                 << 
" constituents for matching chi^2");
 
  197           for (ND::TReconObjectContainer::iterator conIter =
 
  198                    mConContainer.begin();
 
  199                conIter != mConContainer.end(); ++conIter) {
 
  200             ND::THandle<ND::TReconBase> base = (*conIter);
 
  202             if (base->Has<ND::TRealDatum>(
"matching_chi2ndf")) {
 
  206               double matchVal = TrackingUtils::GetMatchingChi2(*base);
 
  207               ND::THandle<ND::TReconObjectContainer> cons =
 
  208                   base->GetConstituents();
 
  210               if (cons && cons->size() == 2) {
 
  211                 ND::THandle<ND::TReconBase> con1 = cons->at(0);
 
  212                 ND::THandle<ND::TReconBase> con2 = cons->at(1);
 
  213                 matchInfo->
Det1 = con1->ConvertDetector();
 
  214                 matchInfo->
Det2 = con2->ConvertDetector();
 
  215                 matchInfo->
IsShower1 = TrackingUtils::IsShower(con1);
 
  216                 matchInfo->
IsShower2 = TrackingUtils::IsShower(con2);
 
  218                 matchInfo->
SetOK = 
true;
 
  230   ND::THandle<ND::TDataVector> hitsData = 
event.Get<ND::TDataVector>(
"hits");
 
  231   for (ND::TDataVector::iterator dataIter = hitsData->begin();
 
  232        dataIter != hitsData->end(); ++dataIter) {
 
  233     TString object_name = (*dataIter)->GetName();
 
  234     ND::THitSelection* hits = 
dynamic_cast<ND::THitSelection*
>(*dataIter);
 
  235     fHitInfo[object_name.Data()] = hits->size();
 
  243 ND::TReconObjectContainer
 
  245     ND::THandle<ND::TReconBase> input) {
 
  246   ND::TReconObjectContainer allCons;
 
  248   static const int NDETS = 19;
 
  249   ND::TReconBase::Status dets[NDETS] = {
 
  253       ND::TReconBase::kRightTECal,  ND::TReconBase::kLeftTECal,
 
  254       ND::TReconBase::kBottomTECal, ND::TReconBase::kTopTECal,
 
  255       ND::TReconBase::kRightPECal,  ND::TReconBase::kLeftPECal,
 
  256       ND::TReconBase::kBottomPECal, ND::TReconBase::kTopPECal,
 
  258       ND::TReconBase::kLeftSMRD,    ND::TReconBase::kBottomSMRD,
 
  259       ND::TReconBase::kTopSMRD};
 
  261   for (
int ii = 0; ii < NDETS; ii++) {
 
  262     ND::TReconObjectContainer cons =
 
  263         ReconObjectUtils::GetAllConstituentsInDetector(input, dets[ii]);
 
  264     for (ND::TReconObjectContainer::const_iterator it1 = cons.begin();
 
  265          it1 != cons.end(); it1++) {
 
  268       for (ND::TReconObjectContainer::const_iterator it2 = allCons.begin();
 
  269            it2 != allCons.end(); it2++) {
 
  270         if ((*it1) == (*it2)) {
 
  276         allCons.push_back(*it1);
 
  287     ND::THandle<ND::TReconBase> input) {
 
  288   ND::TReconObjectContainer allCons;
 
  290   if (IsOnlyTracker(input)) {
 
  291     allCons.push_back(input);
 
  292   } 
else if (ContainsTracker(input)) {
 
  293     allCons.push_back(input);
 
  294     ND::THandle<ND::TReconObjectContainer> cons = input->GetConstituents();
 
  297       for (ND::TReconObjectContainer::const_iterator it = cons->begin();
 
  298            it != cons->end(); it++) {
 
  299         ND::TReconObjectContainer moreCons = GetDownToTracker(*it);
 
  301         for (ND::TReconObjectContainer::const_iterator it2 = moreCons.begin();
 
  302              it2 != moreCons.end(); it2++) {
 
  303           allCons.push_back(*it2);
 
  313     ND::THandle<ND::TReconBase> input) {
 
  314   ND::TReconBase::Status notTrackerDets[14] = {
 
  315       ND::TReconBase::kDSECal,     ND::TReconBase::kRightTECal,
 
  316       ND::TReconBase::kLeftTECal,  ND::TReconBase::kBottomTECal,
 
  317       ND::TReconBase::kTopTECal,   ND::TReconBase::kRightPECal,
 
  318       ND::TReconBase::kLeftPECal,  ND::TReconBase::kBottomPECal,
 
  320       ND::TReconBase::kRightSMRD,  ND::TReconBase::kLeftSMRD,
 
  321       ND::TReconBase::kBottomSMRD, ND::TReconBase::kTopSMRD};
 
  324   for (
int ii = 0; ii < 14; ii++) {
 
  325     if (input->UsesDetector(notTrackerDets[ii])) {
 
  331   return ContainsTracker(input);
 
  335     ND::THandle<ND::TReconBase> input) {
 
  336   return (input->UsesDetector(ND::TReconBase::kTPC) ||
 
  337           input->UsesDetector(ND::TReconBase::kFGD));
 
  342     ND::TND280Event& event, ND::THandle<ND::TReconBase> reconObject,
 
  344   ND::THandle<ND::TReconState> globalState;
 
  347     globalState = reconObject->GetState();
 
  348   } 
catch (ND::EReconObject e) {
 
  349     ND280Warn(
"TReconBase with no state. Skip object!");
 
  353   output->
UniqueID = reconObject->GetUniqueID();
 
  354   output->
Momentum = GetStateMomentum(globalState);
 
  356   const double MomentumByRangeDefault = -10000;
 
  358       *reconObject, 
"prange_muon", MomentumByRangeDefault);
 
  360       *reconObject, 
"prange_muon_flipped", MomentumByRangeDefault);
 
  362       *reconObject, 
"prange_electron", MomentumByRangeDefault);
 
  364       *reconObject, 
"prange_electron_flipped", MomentumByRangeDefault);
 
  366       *reconObject, 
"prange_proton", MomentumByRangeDefault);
 
  368       *reconObject, 
"prange_proton_flipped", MomentumByRangeDefault);
 
  370   output->
Position = GetStatePosition(globalState);
 
  371   output->
Direction = GetStateDirection(globalState);
 
  372   output->
Quality = reconObject->GetQuality();
 
  373   output->
NDOF = reconObject->GetNDOF();
 
  377   ND::THandle<ND::TReconPID> pid = reconObject;
 
  379     output->
ParticleID = pid->ConvertParticleId();
 
  381     output->
Charge = pid->GetCharge();
 
  384   ND::TReconNodeContainer nodes = reconObject->GetNodes();
 
  385   for (ND::TReconNodeContainer::iterator it = nodes.begin(); it != nodes.end();
 
  395       ND::THandle<ND::TReconState> state = (*it)->GetState();
 
  396       FillGlobalStateInfo(state, nodeInfo->
NodeState);
 
  398       ND::THandle<ND::TReconBase> 
object = (*it)->GetObject();
 
  400         ND280Warn(
"Unable to get object of global node");
 
  402         ND::THandle<ND::TReconState> nodeState;
 
  404           nodeState = 
object->GetState();
 
  405         } 
catch (ND::EReconObject e) {
 
  406           ND280Warn(
"TReconBase with no state. Skip node!");
 
  410         FillGlobalStateInfo(nodeState, nodeInfo->
ObjectState);
 
  418   FillGlobalTruthInfo(event, reconObject, output->
Truth);
 
  420   output->
SetOK = 
true;
 
  428     ND::THandle<ND::TReconState> state) {
 
  429   TLorentzVector pos(-10000, -10000, -10000, -10000);
 
  431   ND::THandle<ND::TPIDState> pid = state;
 
  433     pos = pid->GetPosition();
 
  435   ND::THandle<ND::TTrackState> tr = state;
 
  437     pos = tr->GetPosition();
 
  439   ND::THandle<ND::TShowerState> sh = state;
 
  441     pos = sh->GetPosition();
 
  443   ND::THandle<ND::TClusterState> cl = state;
 
  445     pos = cl->GetPosition();
 
  447   ND::THandle<ND::TVertexState> ve = state;
 
  449     pos = ve->GetPosition();
 
  458     ND::THandle<ND::TReconState> state) {
 
  459   TLorentzVector pos(-10000, -10000, -10000, -10000);
 
  461   ND::THandle<ND::TPIDState> pid = state;
 
  463     pos = pid->GetPositionVariance();
 
  465   ND::THandle<ND::TTrackState> tr = state;
 
  467     pos = tr->GetPositionVariance();
 
  469   ND::THandle<ND::TShowerState> sh = state;
 
  471     pos = sh->GetPositionVariance();
 
  473   ND::THandle<ND::TClusterState> cl = state;
 
  475     pos = cl->GetPositionVariance();
 
  477   ND::THandle<ND::TVertexState> ve = state;
 
  479     pos = ve->GetPositionVariance();
 
  487     ND::THandle<ND::TReconState> state) {
 
  490   ND::THandle<ND::TPIDState> pid = state;
 
  492     mom = pid->GetMomentum();
 
  501     ND::THandle<ND::TReconState> state) {
 
  502   TVector3 dir(-10000, -10000, -10000);
 
  504   ND::THandle<ND::TPIDState> pid = state;
 
  506     dir = pid->GetDirection();
 
  508   ND::THandle<ND::TTrackState> tr = state;
 
  510     dir = tr->GetDirection();
 
  512   ND::THandle<ND::TShowerState> sh = state;
 
  514     dir = sh->GetDirection();
 
  524     ND::THandle<ND::TReconBase> 
object) {
 
  527   ND::THandle<ND::TReconTrack> tr = object;
 
  528   ND::THandle<ND::TReconShower> sh = object;
 
  529   ND::THandle<ND::TReconCluster> cl = object;
 
  530   ND::THandle<ND::TReconPID> pid = object;
 
  533     ND::THandle<ND::TReconObjectContainer> cons = 
object->GetConstituents();
 
  534     if (cons && cons->size() == 1) {
 
  535       ND::THandle<ND::TReconBase> con = cons->front();
 
  543     dep = tr->GetEDeposit();
 
  546     dep = sh->GetEDeposit();
 
  549     dep = cl->GetEDeposit();
 
  557     ND::THandle<ND::TReconBase> 
object) {
 
  558   ND::THandle<ND::TReconState> state;
 
  560   for (ND::TReconNodeContainer::const_reverse_iterator it =
 
  561            object->GetNodes().rbegin();
 
  562        it != 
object->GetNodes().rend(); it++) {
 
  563     state = (*it)->GetState();
 
  575     ND::THandle<ND::TReconBase> 
object) {
 
  576   ND::THandle<ND::TReconState> state;
 
  578   for (ND::TReconNodeContainer::const_iterator it = object->GetNodes().begin();
 
  579        it != 
object->GetNodes().end(); it++) {
 
  580     state = (*it)->GetState();
 
  593     ND::TND280Event& event, ND::THandle<ND::TReconBase> reconObject,
 
  597   output->
ClassName = reconObject->ClassName();
 
  599   output->
Quality = reconObject->GetQuality();
 
  600   output->
NDOF = reconObject->GetNDOF();
 
  601   output->
IsShower = TrackingUtils::IsShower(reconObject);
 
  602   output->
EDeposit = GetEDeposit(reconObject);
 
  604   if (ReconObjectUtils::GetOriginalObject(reconObject))
 
  606         ReconObjectUtils::GetOriginalObject(reconObject)->GetUniqueID();
 
  608     output->
UniqueID = reconObject->GetUniqueID();
 
  610   ND::THandle<ND::TReconPID> pid = reconObject;
 
  612     output->
ParticleID = pid->ConvertParticleId();
 
  616   if (reconObject->GetHits()) {
 
  617     output->
NumHits = reconObject->GetHits()->size();
 
  622   ND::THandle<ND::TRealDatum> averageTime =
 
  623       reconObject->Get<ND::TRealDatum>(
"averageHitTime");
 
  628   TVector3 refittedStatePos(-10000, -10000, -10000);
 
  630   ND::THandle<ND::TReconState> refittedState;
 
  632     refittedState = reconObject->GetState();
 
  633   } 
catch (ND::EReconObject e) {
 
  634     ND280Warn(
"TReconBase with no state.");
 
  637   if (!refittedState) {
 
  638     ND280Warn(
"      Unable to get state of refitted object");
 
  640     ND280Verbose(
"      Got refitted object state");
 
  643     refittedStatePos = GetStatePosition(refittedState).Vect();
 
  646     ND::THandle<ND::TReconNode> refittedFirstNode =
 
  647         TrackingUtils::GetFirstFittedNode(*reconObject);
 
  648     if (!refittedFirstNode) {
 
  649       ND280Warn(
"      Unable to get first node of refitted object");
 
  652       ND::THandle<ND::TReconState> refittedFirstNodeState =
 
  653           refittedFirstNode->GetState();
 
  654       if (!refittedFirstNodeState) {
 
  655         ND280Warn(
"      Unable to get first node state of refitted object");
 
  657         FillStateInfo(refittedFirstNodeState,
 
  662       ND::THandle<ND::TReconBase> refittedFirstNodeBase =
 
  663           refittedFirstNode->GetObject();
 
  664       if (!refittedFirstNodeBase) {
 
  665         ND280Warn(
"      Unable to get first node object of refitted object");
 
  668           FillStateInfo(refittedFirstNodeBase->GetState(),
 
  670         } 
catch (ND::EReconObject e) {
 
  671           ND280Warn(
"TReconBase first node with no state.");
 
  676     ND::THandle<ND::TReconNode> refittedLastNode =
 
  677         TrackingUtils::GetLastFittedNode(*reconObject);
 
  678     if (!refittedLastNode) {
 
  679       ND280Warn(
"      Unable to get last node of refitted object");
 
  682       ND::THandle<ND::TReconState> refittedLastNodeState =
 
  683           refittedLastNode->GetState();
 
  684       if (!refittedLastNodeState) {
 
  685         ND280Warn(
"      Unable to get last node state of refitted object");
 
  687         FillStateInfo(refittedLastNodeState,
 
  692       ND::THandle<ND::TReconBase> refittedLastNodeBase =
 
  693           refittedLastNode->GetObject();
 
  694       if (!refittedLastNodeBase) {
 
  695         ND280Warn(
"      Unable to get last node object of refitted object");
 
  698           FillStateInfo(refittedLastNodeBase->GetState(),
 
  700         } 
catch (ND::EReconObject e) {
 
  701           ND280Warn(
"TReconBase last node with no state.");
 
  708     ND::THandle<ND::TReconState> closestGlobalNodeState =
 
  709         TrackingUtils::GetFirstState(*globalObject);
 
  710     ND::TReconNodeContainer globalNodes = globalObject->GetNodes();
 
  711     double closestOffset = 1e10;
 
  713     ND280Verbose(
"      Got " << globalNodes.size() << 
" global nodes");
 
  715     for (ND::TReconNodeContainer::iterator it = globalNodes.begin();
 
  716          it != globalNodes.end(); it++) {
 
  717       ND::THandle<ND::TReconNode> node(*it);
 
  719         ND280Warn(
"        Unable to get node from global container");
 
  723       ND::THandle<ND::TReconState> thisState(node->GetState());
 
  725         ND280Warn(
"        Unable to get state of global node");
 
  730           (refittedStatePos - GetStatePosition(thisState).Vect()).Mag();
 
  731       if (thisOffset < closestOffset) {
 
  732         closestGlobalNodeState = thisState;
 
  733         closestOffset = thisOffset;
 
  737     if (!closestGlobalNodeState) {
 
  738       ND280Warn(
"      Didn't find closest global node state");
 
  740       ND280Verbose(
"      Got closest global node state");
 
  747       ND::THandle<ND::TReconState> projectedClosestGlobalNodeState(
 
  749       TVector3 snorm(0, 0, 1);
 
  750       std::string det = reconObject->ConvertDetector();
 
  752       if (det.find(
"LTECal") != std::string::npos ||
 
  753           det.find(
"RTECal") != std::string::npos) {
 
  754         snorm = TVector3(1, 0, 0);
 
  755       } 
else if (det.find(
"TTECal") != std::string::npos ||
 
  756                  det.find(
"BTECal") != std::string::npos) {
 
  757         snorm = TVector3(0, 1, 0);
 
  758       } 
else if (det.find(
"LPECal") != std::string::npos ||
 
  759                  det.find(
"RPECal") != std::string::npos) {
 
  760         snorm = TVector3(1, 0, 0);
 
  761       } 
else if (det.find(
"TPECal") != std::string::npos ||
 
  762                  det.find(
"BPECal") != std::string::npos) {
 
  763         snorm = TVector3(0, 1, 0);
 
  764       } 
else if (det.find(
"LSMRD") != std::string::npos ||
 
  765                  det.find(
"RSMRD") != std::string::npos) {
 
  766         snorm = TVector3(1, 0, 0);
 
  767       } 
else if (det.find(
"TSMRD") != std::string::npos ||
 
  768                  det.find(
"BSMRD") != std::string::npos) {
 
  769         snorm = TVector3(0, 1, 0);
 
  772       if (fabs(refittedStatePos.X()) < 5000 &&
 
  773           fabs(refittedStatePos.Y()) < 5000 &&
 
  774           fabs(refittedStatePos.Z()) < 5000) {
 
  775         if (ND::tman().PropagateToSurface(*closestGlobalNodeState,
 
  776                                           refittedStatePos, snorm,
 
  777                                           *projectedClosestGlobalNodeState)) {
 
  778           FillStateInfo(projectedClosestGlobalNodeState,
 
  781           ND280Warn(
"      Unable to propagate closest global node state");
 
  784         ND280Warn(
"      Attempted to propagate to bad position " 
  785                   << refittedStatePos.X() << 
", " << refittedStatePos.Y()
 
  786                   << 
", " << refittedStatePos.Z());
 
  795     ND::THandle<ND::TReconBase> original =
 
  796         ReconObjectUtils::GetOriginalObject(reconObject);
 
  801       } 
catch (ND::EReconObject e) {
 
  802         ND280Warn(
"      Unable to get state of unfitted object");
 
  805       ND::THandle<ND::TReconState> unfittedFirstState = GetFirstState(original);
 
  806       if (!unfittedFirstState) {
 
  807         ND280Warn(
"      Unable to get first state of unfitted object");
 
  812       ND::THandle<ND::TReconState> unfittedLastState = GetLastState(original);
 
  813       if (!unfittedLastState) {
 
  814         ND280Warn(
"      Unable to get last state of unfitted object");
 
  825       ExtrapolateToModuleAndFill(reconObject, output->
StateAtDSECal, 
"DS");
 
  826       ExtrapolateToModuleAndFill(reconObject, output->
StateAtTTECal, 
"TT");
 
  827       ExtrapolateToModuleAndFill(reconObject, output->
StateAtBTECal, 
"BT");
 
  828       ExtrapolateToModuleAndFill(reconObject, output->
StateAtLTECal, 
"LT");
 
  829       ExtrapolateToModuleAndFill(reconObject, output->
StateAtRTECal, 
"RT");
 
  830       ExtrapolateToModuleAndFill(reconObject, output->
StateAtP0D, 
"P0D");
 
  833         ExtrapolateToModuleAndFill(reconObject, output->
StateAtTPC2, 
"TPC2");
 
  837     output->
SetOK = 
true;
 
  843   FillConsTruthInfo(event, reconObject, output->
ConsTruth);
 
  850     ND::THandle<ND::TReconObjectContainer> input,
 
  851     ND::THandle<ND::TReconObjectContainer> output) {
 
  852   if (!input || !output) 
return;
 
  854   ND280Verbose(
"GetObjectsFromVertices: # objects = " << input->size());
 
  856   ND::TReconObjectContainer::const_iterator pp, pp1;
 
  857   for (pp = input->begin(); pp != input->end(); pp++) {
 
  858     ND280Verbose(
"Next input object: " << *pp);
 
  859     ND::THandle<ND::TReconVertex> vertex = *pp;
 
  861       ND::THandle<ND::TReconObjectContainer> cons = vertex->GetConstituents();
 
  863         ND280Verbose(
"   ---> # cons = " << cons->size());
 
  864         for (pp1 = cons->begin(); pp1 != cons->end(); pp1++) {
 
  865           output->push_back(*pp1);
 
  869       output->push_back(*pp);
 
  877     ND::THandle<ND::TReconBase> obj1, ND::THandle<ND::TReconBase> obj2) {
 
  878   ND::THandle<ND::TReconObjectContainer> hcon1 = obj1->GetConstituents();
 
  879   ND::THandle<ND::TReconObjectContainer> hcon2 = obj2->GetConstituents();
 
  881   if (ND::TND280Log::GetLogLevel(
"eventAnalysis") >= ND::TND280Log::VerboseLevel) {
 
  882     std::cout << 
"obj1 constituents:" << std::endl;
 
  883     ReconPrintout::DumpContainerWithHistory(*hcon1);
 
  884     std::cout << 
"obj2 constituents:" << std::endl;
 
  885     ReconPrintout::DumpContainerWithHistory(*hcon2);
 
  888   if (!hcon1 || !hcon2) {
 
  889     ND280Verbose(
"Unable to get constituents");
 
  893   ND::TReconObjectContainer con1 = (*hcon1);
 
  894   ND::TReconObjectContainer con2 = (*hcon2);
 
  896   if (con1.size() != con2.size()) {
 
  897     ND280Verbose(
"Constituent ROCs are different sizes: " 
  898                  << con1.size() << 
" vs " << con2.size());
 
  902   for (ND::TReconObjectContainer::iterator it1 = con1.begin();
 
  903        it1 != con1.end(); it1++) {
 
  904     bool foundMatch = 
false;
 
  906     for (ND::TReconObjectContainer::iterator it2 = con2.begin();
 
  907          it2 != con2.end(); it2++) {
 
  908       if ((*it1) == (*it2)) {
 
  926     ND::TND280Event& event, ND::THandle<ND::TReconBase> reconObject,
 
  928   ND::THandle<ND::TReconState> state;
 
  930     state = reconObject->GetState();
 
  931   } 
catch (ND::EReconObject e) {
 
  939   TVector3 statePos = GetStatePosition(state).Vect();
 
  940   ND::THandle<ND::TG4TrajectoryContainer> trajectories =
 
  941       event.Get<ND::TG4TrajectoryContainer>(
"truth/G4Trajectories");
 
  943   if (trajectories && reconObject->GetHits()) {
 
  946     int G4TrkId = TrackTruthInfo::GetG4TrajIDHits(
 
  948     ND::THandle<ND::TG4Trajectory> traj = trajectories->GetTrajectory(G4TrkId);
 
  950       ND280Verbose(
"      Got trajectory number " << G4TrkId);
 
  952       std::vector<ND::TG4TrajectoryPoint> trajPoints =
 
  953           traj->GetTrajectoryPoints();
 
  955       if (trajPoints.size() > 0) {
 
  956         output.
Charge = traj->GetParticle()->Charge() / 3.0;
 
  960         TVector3 closestOffset(-10000, -10000, -10000);
 
  962         for (std::vector<ND::TG4TrajectoryPoint>::iterator trajPointIt =
 
  964              trajPointIt != trajPoints.end(); trajPointIt++) {
 
  965           ND::TG4TrajectoryPoint trajPoint = (*trajPointIt);
 
  967           TVector3 thisOffset = (trajPoint.GetPosition().Vect() - statePos);
 
  968           if (fabs(thisOffset.Z()) < fabs(closestOffset.Z())) {
 
  969             closestOffset = thisOffset;
 
  970             output.
Momentum = trajPoint.GetMomentum().Mag();
 
  971             output.
Direction = trajPoint.GetMomentum().Unit();
 
  972             output.
Position = trajPoint.GetPosition();
 
  976         if (closestOffset.Mag() > 100) {
 
  977           ND280Verbose(
"      Closest MC trajectory point is offset by " 
  978                        << closestOffset.Mag());
 
  984       ND280Warn(
"      No trajectory number " << G4TrkId);
 
  986   } 
else if (event.GetContext().IsMC()) {
 
  987     ND280Warn(
"      No trajectories, yet is MC!!!");
 
  996     ND::TND280Event& event, ND::THandle<ND::TReconBase> reconObject,
 
  998   ND::THandle<ND::TReconState> state;
 
 1001     state = reconObject->GetState();
 
 1002   } 
catch (ND::EReconObject) {
 
 1010   TVector3 statePos = GetStatePosition(state).Vect();
 
 1011   ND::THandle<ND::TG4TrajectoryContainer> trajectories =
 
 1012       event.Get<ND::TG4TrajectoryContainer>(
"truth/G4Trajectories");
 
 1014   if (trajectories && reconObject->GetHits()) {
 
 1016     int G4TrkId = TrackTruthInfo::GetG4TrajIDHits(
 
 1018     ND::THandle<ND::TG4Trajectory> traj = trajectories->GetTrajectory(G4TrkId);
 
 1020       ND280Verbose(
"      Got trajectory number " << G4TrkId);
 
 1021       output.
Charge = traj->GetParticle()->Charge() / 3.0;
 
 1022       output.
Momentum = traj->GetInitialMomentum().Vect().Mag();
 
 1023       output.
Direction = traj->GetInitialMomentum().Vect().Unit();
 
 1024       output.
Position = traj->GetInitialPosition();
 
 1025       output.
SetOK = 
true;
 
 1027       ND280Warn(
"      No trajectory number " << G4TrkId);
 
 1029   } 
else if (event.GetContext().IsMC()) {
 
 1030     ND280Warn(
"      No trajectories, yet is MC!!!");
 
 1043   output.
Position = GetStatePosition(state);
 
 1045   output.
Momentum = GetStateMomentum(state);
 
 1046   output.
Direction = GetStateDirection(state);
 
 1048   output.
SetOK = 
true;
 
 1056   ND::THandle<ND::TReconState> state;
 
 1059     state = base->GetState();
 
 1060   } 
catch (ND::EReconObject e) {
 
 1069   output->
MatchingChi2 = TrackingUtils::GetMatchingChi2(*base);
 
 1070   output->
Position = GetStatePosition(state);
 
 1071   output->
Momentum = GetStateMomentum(state);
 
 1072   output->
Direction = GetStateDirection(state);
 
 1074   output->
SetOK = 
true;
 
 1093     std::string module) {
 
 1099   HelixModel* helix = 
new HelixModel();
 
 1100   ND::THandle<ND::TReconTrack> track = base;
 
 1103     ND::THandle<ND::TReconPID> pid = base;
 
 1104     ND::THandle<ND::TReconObjectContainer> conContainer =
 
 1105         base->GetConstituents();
 
 1106     if (conContainer->size() != 1) {
 
 1107       ND280Error(
"Constituent container has > 1 constituent!");
 
 1111     for (ND::TReconObjectContainer::iterator conIter = conContainer->begin();
 
 1112          conIter != conContainer->end(); ++conIter) {
 
 1113       ND::THandle<ND::TReconBase> base = (*conIter);
 
 1117         ND280Error(
"Tried to convert non-track to helix");
 
 1123   ND::THandle<ND::TTrackState> state;
 
 1125     state = track->GetState();
 
 1126   } 
catch (ND::EReconObject e) {
 
 1127     ND280Warn(
"Couldn't get track state.");
 
 1131   double x0 = state->GetPosition().X();
 
 1132   double y0 = state->GetPosition().Y();
 
 1133   double z0 = state->GetPosition().Z();
 
 1135   double tx0 = state->GetDirection().X();
 
 1136   double ty0 = state->GetDirection().Y() / state->GetDirection().Z();
 
 1138   double rho = state->GetCurvature();
 
 1140   helix->SetParameters(x0, y0, z0, tx0, ty0, rho);
 
 1142   double x, y, z, theta;
 
 1143   TVector3 minpos, maxpos, pos;
 
 1147   if (module == 
"DS" || module == 
"P0D") {
 
 1148     if (module == 
"DS") {
 
 1149       GetModuleBox(ND::GeomId::DSECal::Detector(), minpos, maxpos);
 
 1151       z = minpos.Z() + 30.5;
 
 1153       GetModuleBox(ND::GeomId::P0D::Detector(), minpos, maxpos);
 
 1155       z = maxpos.Z() - 42.0;
 
 1157     x = helix->XCoord(TVector3(0.0, 0.0, z), 2);
 
 1158     y = helix->YCoord(TVector3(0.0, 0.0, z), 2);
 
 1159     theta = helix->phiYZ(TVector3(0.0, 0.0, z), 2);
 
 1160   } 
else if (module == 
"TT" || module == 
"BT") {
 
 1161     if (module == 
"TT") {
 
 1162       GetModuleBox(ND::GeomId::TECal::Module(0, 2), minpos, maxpos);
 
 1164       y = minpos.Y() + 45.5;
 
 1166       GetModuleBox(ND::GeomId::TECal::Module(0, 0), minpos, maxpos);
 
 1168       y = maxpos.Y() - 45.5;
 
 1170     x = helix->XCoord(TVector3(0.0, y, 0.0), 1);
 
 1171     z = helix->ZCoord(TVector3(0.0, y, 0.0), 1);
 
 1172     theta = helix->phiYZ(TVector3(0.0, 0.0, z), 2);
 
 1173   } 
else if (module == 
"RT" || module == 
"LT") {
 
 1174     if (module == 
"RT") {
 
 1175       GetModuleBox(ND::GeomId::TECal::Module(0, 1), minpos, maxpos);
 
 1177       x = maxpos.X() - 55.5;
 
 1179       GetModuleBox(ND::GeomId::TECal::Module(1, 1), minpos, maxpos);
 
 1181       x = minpos.X() + 55.5;
 
 1183     y = helix->YCoord(TVector3(x, 0.0, 0.0), 0);
 
 1184     z = helix->ZCoord(TVector3(x, 0.0, 0.0), 0);
 
 1185     theta = helix->phiYZ(TVector3(0.0, 0.0, z), 2);
 
 1186   } 
else if (module == 
"TPC2") {
 
 1187     GetModuleBox(ND::GeomId::TPC::TPC2(), minpos, maxpos);
 
 1193     x = helix->XCoord(TVector3(0.0, 0.0, z), 2);
 
 1194     y = helix->YCoord(TVector3(0.0, 0.0, z), 2);
 
 1195     theta = helix->phiYZ(TVector3(0.0, 0.0, z), 2);
 
 1201   output.
Position = TVector3(x, y, z);
 
 1203   output.
SetOK = 
true;
 
 1214     TVector3 centre = 
id.GetPosition();
 
 1216     ND::TOADatabase::Get().GeomId().CdId(
id);
 
 1217     TGeoShape* vol = gGeoManager->GetCurrentVolume()->GetShape();
 
 1218     TGeoBBox* bbox = 
dynamic_cast<TGeoBBox*
>(vol);
 
 1220       TVector3 corner(bbox->GetDX(), bbox->GetDY(), bbox->GetDZ());
 
 1221       TVector3 globalcorner = ND::TGeomInfo::Get().LocalToMasterVect(
 
 1222           id, corner.X(), corner.Y(), corner.Z());
 
 1223       TVector3 min = centre - globalcorner;
 
 1224       TVector3 max = centre + globalcorner;
 
 1225       minpos.SetX(std::min(min.X(), max.X()));
 
 1226       minpos.SetY(std::min(min.Y(), max.Y()));
 
 1227       minpos.SetZ(std::min(min.Z(), max.Z()));
 
 1228       maxpos.SetX(std::max(min.X(), max.X()));
 
 1229       maxpos.SetY(std::max(min.Y(), max.Y()));
 
 1230       maxpos.SetZ(std::max(min.Z(), max.Z()));
 
 1232   } 
catch (ND::EGeomIdInvalid e) {
 
 1236     ND280Verbose(
" Invalid geometry id passed to GetModuleBox()");
 
 1249   output.
Position = GetStatePosition(state);
 
 1251   output.
Momentum = GetStateMomentum(state);
 
 1252   output.
Direction = GetStateDirection(state);
 
 1254   output.
SetOK = 
true;
 
 1262   Constituents = 
new TClonesArray(
 
 1263       "ND::TReconPerformanceEvalModule::TGlobalReconConstituent", 200);
 
 1264   Constituents->Clear();
 
 1267   NModuleConstituents = 
new std::map<std::string, int>();
 
 1269   GlobalNodes = 
new TClonesArray(
 
 1270       "ND::TReconPerformanceEvalModule::TGlobalReconNodeInfo", 200);
 
 1271   GlobalNodes->Clear();
 
 1273   NGlobalNodesSaved = 0;
 
 1275   DownToTrackerConstituents = 
new TClonesArray(
 
 1276       "ND::TReconPerformanceEvalModule::TDownToTrackerInfo", 200);
 
 1277   DownToTrackerConstituents->Clear();
 
 1278   NDownToTrackerConstituents = 0;
 
 1280   SubdetectorString = 
"FAILED";
 
 1282   ParticleID = 
"NOT_A_TRECONPID";
 
 1286   MomentumByRange = -10000;
 
 1288   Direction = TVector3(-10000, -10000, -10000);
 
 1291   MatchingChi2Info = 
new TClonesArray(
 
 1292       "ND::TReconPerformanceEvalModule::TMatchingChi2Info", 200);
 
 1293   MatchingChi2Info->Clear();
 
 1294   NMatchingChi2Info = 0;
 
 1302   ReconAlgorithm = 
"FAILED";
 
 1304   ClassName = 
"FAILED";
 
 1305   ParticleID = 
"NOT_A_TRECONPID";
 
 1307   AverageHitTime = -10000;
 
 1316   Position = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1319   Direction = TVector3(-10000, -10000, -10000);
 
 1321   Efficiency = -10000;
 
 1328   Position = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1331   Direction = TVector3(-10000, -10000, -10000);
 
 1333   Efficiency = -10000;
 
 1348   Position = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1349   PositionVariance = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1351   Direction = TVector3(-10000, -10000, -10000);
 
 1359   Position = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1360   PositionVariance = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1362   Direction = TVector3(-10000, -10000, -10000);
 
 1370   MatchingChi2 = -10000;
 
 1371   Position = TLorentzVector(-10000, -10000, -10000, -10000);
 
 1373   Direction = TVector3(-10000, -10000, -10000);
 
 1380   Position = TVector3(-10000, -10000, -10000);
 
 1390   MatchingChi2 = -10000;
 
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
std::string fDescription
A longish descrition of the analysis. 
std::string DetectorName(ESubdetector const subdet)
std::string fCVSID
Defined if an official tagged version. 
double GetTRealDatumValue(ND::THandle< ND::TReconBase > trb, char const *name, double const &defaultValue)
void SetNameTitle(char const *name, char const *title)
std::string fCVSTagName
Defined if an official tagged version. 
virtual void FillConfigTree(TTree *)