CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TracksToTrajectories.cc
Go to the documentation of this file.
2 
6 
11 
14 
18 
19 using namespace std;
20 using namespace edm;
21 
24  theNTracks(0),theNFailures(0){
25 
26  theTracksLabel = parameterSet.getParameter<InputTag>("Tracks");
27 
28  ParameterSet trackTransformerParam = parameterSet.getParameter<ParameterSet>("TrackTransformer");
29 
30  string type = parameterSet.getParameter<string>("Type");
31 
32  if(type == "Default") theTrackTransformer = new TrackTransformer(trackTransformerParam);
33  else if(type == "GlobalCosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForGlobalCosmicMuons(trackTransformerParam);
34  else if(type == "CosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForCosmicMuons(trackTransformerParam);
35  else{
36  throw cms::Exception("TracksToTrajectories")
37  <<"The selected algorithm does not exist"
38  << "\n"
39  << "Possible choices are:"
40  << "\n"
41  << "Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]";
42  }
43 
44  produces<vector<Trajectory> >("Refitted");
45  produces<TrajTrackAssociationCollection>("Refitted");
46 }
47 
48 
52 }
53 
55  const string metname = "Reco|TrackingTools|TracksToTrajectories";
56 
57  if(theNFailures!=0)
58  LogWarning(metname) << "During the refit there were "
59  << theNFailures << " out of " << theNTracks << " tracks, i.e. failure rate is: " << double(theNFailures)/theNTracks;
60  else{
61  LogTrace(metname) << "Refit of the tracks done without any failure";
62  }
63 }
64 
65 
68 
69  const string metname = "Reco|TrackingTools|TracksToTrajectories";
70 
72 
73  // Collection of Trajectory
74  auto_ptr<vector<Trajectory> > trajectoryCollection(new vector<Trajectory>);
75 
76  // Get the reference
77  RefProd<vector<Trajectory> > trajectoryCollectionRefProd
78  = event.getRefBeforePut<vector<Trajectory> >("Refitted");
79 
80  // Association map between Trajectory and Track
81  auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection);
82 
83  // Get the RecTrack collection from the event
85  event.getByLabel(theTracksLabel,tracks);
86 
87  Ref<vector<Trajectory> >::key_type trajectoryIndex = 0;
88  reco::TrackRef::key_type trackIndex = 0;
89 
90  // Loop over the Rec tracks
91  for (reco::TrackCollection::const_iterator newTrack = tracks->begin();
92  newTrack != tracks->end(); ++newTrack) {
93 
94  ++theNTracks;
95 
96  vector<Trajectory> trajectoriesSM = theTrackTransformer->transform(*newTrack);
97 
98  if(!trajectoriesSM.empty()){
99  // Load the trajectory in the Trajectory Container
100  trajectoryCollection->push_back(trajectoriesSM.front());
101 
102  // Make the association between the Trajectory and the original Track
103  trajTrackMap->insert(Ref<vector<Trajectory> >(trajectoryCollectionRefProd,trajectoryIndex++),
104  reco::TrackRef(tracks,trackIndex++));
105  }
106  else{
107  LogTrace(metname) << "Error in the Track refitting. This should not happen";
108  ++theNFailures;
109  }
110  }
111  LogTrace(metname)<<"Load the Trajectory Collection";
112  event.put(trajectoryCollection,"Refitted");
113  event.put(trajTrackMap,"Refitted");
114 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
virtual ~TracksToTrajectories()
Destructor.
TracksToTrajectories(const edm::ParameterSet &)
Constructor.
const std::string metname
virtual void setServices(const edm::EventSetup &)=0
set the services needed by the TrackTransformers
TrackTransformerBase * theTrackTransformer
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#define LogTrace(id)
tuple tracks
Definition: testEve_cfg.py:39
virtual std::vector< Trajectory > transform(const reco::Track &) const =0
Convert a reco::Track into Trajectory.
virtual void produce(edm::Event &, const edm::EventSetup &)
Convert a reco::TrackCollection into std::vector&lt;Trajectory&gt;
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168