ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillTracks.cc
Revision: 1.9
Committed: Tue Jul 1 11:31:42 2008 UTC (16 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +1 -1 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
Old fillers removed

File Contents

# Content
1 // $Id: FillTracks.cc,v 1.8 2008/06/20 17:52:57 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/FillTracks.h"
4 #include "FWCore/MessageLogger/interface/MessageLogger.h"
5 #include "FWCore/Framework/interface/ESHandle.h"
6 #include "DataFormats/Common/interface/Handle.h"
7 #include "FWCore/ServiceRegistry/interface/Service.h"
8 #include "DataFormats/TrackReco/interface/Track.h"
9 #include "DataFormats/TrackReco/interface/TrackFwd.h"
10 #include "MitAna/DataTree/interface/Names.h"
11 #include "MitProd/TreeService/interface/TreeService.h"
12 #include "MitAna/DataUtil/interface/TreeWriter.h"
13
14 using namespace std;
15 using namespace edm;
16 using namespace mithep;
17
18 //-------------------------------------------------------------------------------------------------
19 FillTracks::FillTracks(const edm::ParameterSet &cfg) :
20 tracks_(new mithep::Array<mithep::Track>()),
21 trackSource_(cfg.getUntrackedParameter<string>("trackSource", "generalTracks")),
22 trackBranch_(cfg.getUntrackedParameter<string>("trackBrname", Names::gkTrackBrn))
23 {
24 }
25
26 //-------------------------------------------------------------------------------------------------
27 FillTracks::~FillTracks()
28 {
29 }
30
31 //-------------------------------------------------------------------------------------------------
32 void FillTracks::analyze(const edm::Event &event,
33 const edm::EventSetup &setup)
34 {
35 tracks_->Reset();
36
37 Handle<reco::TrackCollection> theTrackProduct;
38 try {
39 event.getByLabel(trackSource_, theTrackProduct);
40 } catch (cms::Exception& ex) {
41 edm::LogError("FillTracks") << "Error! Can not get collection with label "
42 << trackSource_ << endl;
43 throw edm::Exception(edm::errors::Configuration, "FillTracks:analyze()\n")
44 << "Error! Can not get collection with label " << trackSource_ << endl;
45 }
46
47 const reco::TrackCollection Tracks = *(theTrackProduct.product());
48
49 int nTracks = 0;
50 for (reco::TrackCollection::const_iterator inTrack = Tracks.begin();
51 inTrack != Tracks.end(); ++inTrack) {
52
53 mithep::Track* outTrack = new mithep::Track(inTrack->phi(),inTrack->d0(),inTrack->pt(),
54 inTrack->dz(),inTrack->theta());
55
56 outTrack->SetErrors(inTrack->phiError(),
57 inTrack->d0Error(),
58 inTrack->ptError(),
59 inTrack->dzError(),
60 inTrack->thetaError());
61 outTrack->SetCharge(inTrack->charge());
62
63 tracks_->AddCopy(outTrack);
64 nTracks++;
65 }
66 tracks_->Trim();
67 }
68
69 //-------------------------------------------------------------------------------------------------
70 void FillTracks::beginJob(const edm::EventSetup &setup)
71 {
72 Service<TreeService> ts;
73 TreeWriter *tws = ts->get();
74 if (! tws) {
75 throw edm::Exception(edm::errors::Configuration, "FillTracks::beginJob()\n")
76 << "Could not get pointer to Tree with name " << tws->GetName() << "\n";
77 return;
78 }
79
80 tws->AddBranch(trackBranch_.c_str(),&tracks_);
81 }
82
83 //-------------------------------------------------------------------------------------------------
84 void FillTracks::endJob()
85 {
86 edm::LogInfo("FillMuons::endJob") << "Ending Job" << endl;
87 }