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