CMS 3D CMS Logo

TrackInfoProducer.cc

Go to the documentation of this file.
00001 #include "AnalysisAlgos/TrackInfoProducer/interface/TrackInfoProducer.h"
00002 // system include files
00003 #include <memory>
00004 // user include files
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00009 #include "DataFormats/Common/interface/EDProduct.h" 
00010 #include "AnalysisDataFormats/TrackInfo/interface/TrackInfo.h"
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012 #include "AnalysisDataFormats/TrackInfo/interface/TrackInfoTrackAssociation.h"
00013 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00014 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00015 TrackInfoProducer::TrackInfoProducer(const edm::ParameterSet& iConfig):
00016     conf_(iConfig),
00017     theAlgo_(iConfig)
00018 {
00019   produces<reco::TrackInfoCollection>();
00020   produces<reco::TrackInfoTrackAssociationCollection>();
00021 
00022 
00023 }
00024 
00025 
00026 void TrackInfoProducer::produce(edm::Event& theEvent, const edm::EventSetup& setup)
00027 {
00028    //
00029   // create empty output collections
00030   //
00031 
00032   std::auto_ptr<reco::TrackInfoCollection>    outputColl (new reco::TrackInfoCollection);
00033   std::auto_ptr<reco::TrackInfoTrackAssociationCollection>    TIassociationColl (new reco::TrackInfoTrackAssociationCollection);
00034   
00035   edm::InputTag TkTag = conf_.getParameter<edm::InputTag>("cosmicTracks");
00036   
00037   edm::Handle<std::vector<Trajectory> > TrajectoryCollection;
00038   edm::Handle<reco::TrackCollection > trackCollection;
00039   edm::Handle<TrajTrackAssociationCollection> assoMap;
00040     
00041   edm::ESHandle<TrackerGeometry> tkgeom;
00042   setup.get<TrackerDigiGeometryRecord>().get( tkgeom );
00043   const TrackerGeometry * tracker=&(* tkgeom);
00044     
00045   theEvent.getByLabel(TkTag,TrajectoryCollection);
00046   theEvent.getByLabel(TkTag,trackCollection);
00047   theEvent.getByLabel(TkTag,assoMap);
00048  
00049   //
00050   //run the algorithm  
00051   //
00052   reco::TrackInfo output;
00053   
00054   std::vector<Trajectory>::const_iterator traj_iterator;
00055   edm::LogInfo("TrackInfoProducer") << "Loop on trajectories";
00056   std::map<reco::TrackRef,unsigned int> trackid;
00057   int i=0;
00058 
00059  for(TrajTrackAssociationCollection::const_iterator it = assoMap->begin();it != assoMap->end(); ++it){
00060    const edm::Ref<std::vector<Trajectory> > traj = it->key;
00061    const reco::TrackRef track = it->val;
00062    trackid.insert(make_pair(track,i));
00063    i++;
00064    theAlgo_.run(traj,track,output,tracker);
00065    outputColl->push_back(*(new reco::TrackInfo(output)));
00066 
00067  }
00068  
00069 
00070     //put everything in the event
00071     edm::OrphanHandle<reco::TrackInfoCollection> rTrackInfo;
00072 
00073 //     if(forwardPredictedStateTag_!="") rTrackInfof = theEvent.put(outputFwdColl,forwardPredictedStateTag_ );
00074 //     if(backwardPredictedStateTag_!="") rTrackInfob =   theEvent.put(outputBwdColl,backwardPredictedStateTag_);
00075 //     if(updatedStateTag_!="") rTrackInfou =   theEvent.put(outputUpdatedColl,updatedStateTag_ );
00076 //     if(combinedStateTag_!="") rTrackInfoc =   theEvent.put(outputCombinedColl,combinedStateTag_ );
00077     rTrackInfo=theEvent.put(outputColl);
00078 
00079     for(std::map<reco::TrackRef,unsigned int>::iterator ref_iter=trackid.begin();ref_iter!=trackid.end();ref_iter++){
00080 
00081       TIassociationColl->insert( ref_iter->first,edm::Ref<reco::TrackInfoCollection>(rTrackInfo,ref_iter->second ));
00082     }
00083 
00084     theEvent.put(TIassociationColl); 
00085 }
00086 
00087 
00088 
00089 

Generated on Tue Jun 9 17:25:06 2009 for CMSSW by  doxygen 1.5.4