60 m_neuroTrigger3DH.initialize();
62 ? *m_CDCTrigger3DHMLPConditionsDB
63 : CDCTrigger3DHMLP::loadMLPFromFile<CDCTrigger3DHMLP>(m_fileName, m_arrayName);
64 m_neuroTrigger3DH.setMLP(mlp);
67 m_neuroTrigger3DH.createIntWeights();
69 m_neuroTrigger3DH.initializeCollections(m_hitCollectionName);
71 m_ndFinderTracks.isRequired(m_inputCollectionName);
72 m_trackSegmentHits.isRequired(m_hitCollectionName);
73 m_neuro3DHTracks.registerInDataStore(m_outputCollectionName);
75 m_ndFinderTracks.registerRelationTo(m_neuro3DHTracks);
76 m_ndFinderTracks.requireRelationTo(m_trackSegmentHits);
77 m_neuro3DHTracks.registerRelationTo(m_trackSegmentHits);
82 for (
int trackIdx = 0; trackIdx < m_ndFinderTracks.getEntries(); ++trackIdx) {
85 m_neuroTrigger3DH.calculateTrackParametersFixedPrecision(*m_ndFinderTracks[trackIdx]);
87 m_neuroTrigger3DH.calculateTrackParameters(*m_ndFinderTracks[trackIdx]);
89 m_neuroTrigger3DH.setEventTime(*m_ndFinderTracks[trackIdx]);
90 std::vector<size_t> hitIds = m_neuroTrigger3DH.load3DHits(*m_ndFinderTracks[trackIdx]);
91 std::vector<float> networkInput = m_neuroTrigger3DH.getInputVector(hitIds);
93 std::vector<float> networkPrediction;
95 networkPrediction = m_neuroTrigger3DH.runMLPFixedPrecision(networkInput);
97 networkPrediction = m_neuroTrigger3DH.runMLP(networkInput);
100 double trackPhi = m_ndFinderTracks[trackIdx]->getPhi0();
101 double trackOmega = m_ndFinderTracks[trackIdx]->getOmega();
102 double zPrediction = networkPrediction[0];
103 double cotPrediction = std::cos(networkPrediction[1]) / std::sin(networkPrediction[1]);
104 double classificationNNT = networkPrediction[2];
105 double classificationSTT = networkPrediction[3];
108 double trackTheta = std::atan2(1.0, cotPrediction);
109 if (trackTheta < 0) trackTheta += M_PI;
110 double totalMomentumPrediction = m_ndFinderTracks[trackIdx]->getPt() / std::sin(trackTheta);
114 m_neuro3DHTracks.appendNew(trackPhi, trackOmega, zPrediction, cotPrediction);
117 neuroTrack->setTime(m_neuroTrigger3DH.getEventTime());
118 neuroTrack->setFloatInput(networkInput);
119 neuroTrack->setTotalMomentum(totalMomentumPrediction);
120 neuroTrack->setNNTClassification(classificationNNT);
121 neuroTrack->setSTTClassification(classificationSTT);
122 neuroTrack->setQuadrant(m_ndFinderTracks[trackIdx]->getQuadrant());
123 neuroTrack->setValidTrackBit(m_ndFinderTracks[trackIdx]->getValidTrackBit());
126 bool nntBit = (classificationNNT > m_classificationCutNNT);
127 bool sttBit = (classificationSTT > m_classificationCutSTT);
128 neuroTrack->setNNTBit(nntBit);
129 neuroTrack->setSTTBit(sttBit);
132 m_ndFinderTracks[trackIdx]->addRelationTo(neuroTrack);
135 std::array<unsigned short, 9> tsVector{0};
136 for (
unsigned int hitIdx = 0; hitIdx < hitIds.size(); ++hitIdx) {
137 neuroTrack->addRelationTo(m_trackSegmentHits[hitIds[hitIdx]]);
138 unsigned short superLayer = m_trackSegmentHits[hitIds[hitIdx]]->getISuperLayer();
139 tsVector[superLayer] = m_trackSegmentHits[hitIds[hitIdx]]->getLeftRight();
141 neuroTrack->setTSVector(tsVector);