33 namespace tracksToTrajectories {
41 using namespace tracksToTrajectories;
54 static void globalEndJob(
Count const* iCount);
75 if (type ==
"Default")
76 theTrackTransformer = std::make_unique<TrackTransformer>(trackTransformerParam, consumesCollector());
77 else if (type ==
"GlobalCosmicMuonsForAlignment")
78 theTrackTransformer = std::make_unique<TrackTransformerForGlobalCosmicMuons>(trackTransformerParam);
79 else if (type ==
"CosmicMuonsForAlignment")
80 theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(trackTransformerParam);
83 <<
"The selected algorithm does not exist"
85 <<
"Possible choices are:"
87 <<
"Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]";
90 produces<vector<Trajectory>>(
"Refitted");
91 produces<TrajTrackAssociationCollection>(
"Refitted");
98 constexpr
char metname[] =
"Reco|TrackingTools|TracksToTrajectories";
103 if (theNFailures != 0)
104 LogWarning(metname) <<
"During the refit there were " << theNFailures <<
" out of " << theNTracks
105 <<
" tracks, i.e. failure rate is: " << double(theNFailures) / theNTracks;
107 LogTrace(metname) <<
"Refit of the tracks done without any failure";
114 constexpr
char metname[] =
"Reco|TrackingTools|TracksToTrajectories";
117 theTrackTransformer->setServices(setup);
120 auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
127 event.getByToken(theTracksToken, tracks);
130 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(trajectoryCollectionRefProd,
tracks);
136 for (
auto const& newTrack : *tracks) {
137 ++(globalCache()->theNTracks);
139 auto const& trajectoriesSM = theTrackTransformer->transform(newTrack);
141 if (!trajectoriesSM.empty()) {
143 trajectoryCollection->push_back(trajectoriesSM.front());
146 trajTrackMap->insert(
Ref<vector<Trajectory>>(trajectoryCollectionRefProd, trajectoryIndex++),
149 LogTrace(metname) <<
"Error in the Track refitting. This should not happen";
150 ++(globalCache()->theNFailures);
153 LogTrace(metname) <<
"Load the Trajectory Collection";
154 event.put(
move(trajectoryCollection),
"Refitted");
155 event.put(
move(trajTrackMap),
"Refitted");
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
std::atomic< int > theNFailures
const std::string metname
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::TrackCollection > theTracksToken
auto const & tracks
cannot be loose
TracksToTrajectories(const edm::ParameterSet &, const Count *)
Constructor.
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
std::unique_ptr< TrackTransformerBase > theTrackTransformer
~TracksToTrajectories() override
Destructor.
T getParameter(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
Convert a reco::TrackCollection into std::vector<Trajectory>
static void globalEndJob(Count const *iCount)
static std::unique_ptr< Count > initializeGlobalCache(edm::ParameterSet const &)
Log< level::Warning, false > LogWarning
std::atomic< int > theNTracks