@@ -9,6 +9,9 @@ void PFTrackProducer::configure(framework::config::Parameters& ps) {
99 inputTrackCollName_ = ps.getParameter <std::string>(" inputTrackCollName" );
1010 input_pass_name_ = ps.getParameter <std::string>(" input_pass_name" );
1111 outputTrackCollName_ = ps.getParameter <std::string>(" outputTrackCollName" );
12+ doElectronTracking_ = ps.getParameter <bool >(" doElectronTracking" );
13+ minElectronMomentumZ_ = ps.getParameter <double >(" minElectronMomentumZ" );
14+ maxElectronTrackID_ = ps.getParameter <int >(" maxElectronTrackID" );
1215}
1316
1417double getP (const ldmx::SimTrackerHit& tk) {
@@ -28,14 +31,41 @@ void PFTrackProducer::produce(framework::Event& event) {
2831 std::vector<ldmx::SimTrackerHit> pfTracks;
2932 if (truthTracking_) {
3033 for (const auto & spHit : ecalSpHits) {
31- if (spHit.getTrackID () != 1 || fabs (240 - spHit.getPosition ()[2 ]) > 0.1 ||
32- spHit.getMomentum ()[2 ] <= 0 )
33- continue ;
3434 if (spHit.getPdgID () == 22 || spHit.getPdgID () == 2112 ) continue ;
35- pfTracks.push_back (spHit);
36- break ;
37- }
38- }
35+ if (fabs (240 - spHit.getPosition ()[2 ]) > 0.1 ) continue ;
36+ if (doElectronTracking_) { // only select electron SP hits
37+ if (spHit.getPdgID () != 11 ) continue ;
38+ if (spHit.getTrackID () < 2 &&
39+ spHit.getMomentum ()[2 ] > minElectronMomentumZ_) {
40+ // this is almost guaranteed to be a pileup beam electron! keep it
41+ pfTracks.push_back (spHit);
42+ ldmx_log (debug) << " Added beam electron SP hit: trackID="
43+ << spHit.getTrackID ()
44+ << " , pz = " << spHit.getMomentum ()[2 ];
45+ } else if (spHit.getTrackID () <= maxElectronTrackID_ &&
46+ spHit.getMomentum ()[2 ] > 5 ) {
47+ // require more than minimum forward momentum to catch recoil electron
48+ // candidates
49+ pfTracks.push_back (spHit);
50+ ldmx_log (debug) << " Adding SP hit: trackID=" << spHit.getTrackID ()
51+ << " , pdgID= " << spHit.getPdgID ()
52+ << " , pz = " << spHit.getMomentum ()[2 ];
53+ continue ;
54+ }
55+ } // if electron tracking
56+ else {
57+ if (spHit.getTrackID () != 1 ||
58+ fabs (240 - spHit.getPosition ()[2 ]) > 0.1 ||
59+ spHit.getMomentum ()[2 ] < 0 )
60+ continue ;
61+ pfTracks.push_back (spHit);
62+ ldmx_log (debug) << " Adding SP hit: trackID=" << spHit.getTrackID ()
63+ << " , pdgID= " << spHit.getPdgID ()
64+ << " , pz = " << spHit.getMomentum ()[2 ];
65+ break ;
66+ }
67+ } // over SP hits
68+ } // do truth tracking
3969 std::sort (pfTracks.begin (), pfTracks.end (),
4070 [](ldmx::SimTrackerHit a, ldmx::SimTrackerHit b) {
4171 return getP (a) > getP (b);
0 commit comments