1 |
loizides |
1.5 |
// $Id: FillerMuons.cc,v 1.4 2008/07/03 07:56:14 loizides Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerMuons.h"
|
4 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
7 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
8 |
|
|
#include "MitAna/DataTree/interface/Muon.h"
|
9 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
10 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
11 |
|
|
|
12 |
|
|
using namespace std;
|
13 |
|
|
using namespace edm;
|
14 |
|
|
using namespace mithep;
|
15 |
|
|
|
16 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
17 |
loizides |
1.2 |
FillerMuons::FillerMuons(const edm::ParameterSet &cfg, bool active,
|
18 |
|
|
const TrackMap *globalMap, const TrackMap *stdMap,
|
19 |
|
|
const TrackMap *stdVtxMap, const TrackMap* trackerMap) :
|
20 |
|
|
BaseFiller(cfg, "Muons", active),
|
21 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
|
22 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
|
23 |
|
|
muons_(new mithep::MuonArr),
|
24 |
|
|
globalTrackMap_(globalMap),
|
25 |
|
|
standaloneTrackMap_(stdMap),
|
26 |
|
|
standaloneVtxTrackMap_(stdVtxMap),
|
27 |
|
|
trackerTrackMap_(trackerMap)
|
28 |
|
|
{
|
29 |
|
|
// Constructor.
|
30 |
|
|
}
|
31 |
|
|
|
32 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
33 |
loizides |
1.1 |
FillerMuons::~FillerMuons()
|
34 |
|
|
{
|
35 |
|
|
// Destructor.
|
36 |
loizides |
1.5 |
|
37 |
|
|
delete muons_;
|
38 |
loizides |
1.1 |
}
|
39 |
|
|
|
40 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
41 |
loizides |
1.1 |
void FillerMuons::BookDataBlock(TreeWriter &tws)
|
42 |
|
|
{
|
43 |
|
|
// Add muons branch to tree.
|
44 |
|
|
|
45 |
|
|
tws.AddBranch(mitName_.c_str(),&muons_);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
49 |
loizides |
1.1 |
void FillerMuons::FillDataBlock(const edm::Event &event,
|
50 |
loizides |
1.4 |
const edm::EventSetup &setup)
|
51 |
loizides |
1.1 |
{
|
52 |
|
|
// Fill muon information.
|
53 |
|
|
|
54 |
|
|
muons_->Reset();
|
55 |
|
|
|
56 |
|
|
// get the muons collection
|
57 |
|
|
try {
|
58 |
bendavid |
1.3 |
event.getByLabel(edm::InputTag(edmName_),muonProduct_);
|
59 |
loizides |
1.5 |
} catch (cms::Exception &ex) {
|
60 |
loizides |
1.1 |
edm::LogError("FillerMuons") << "Error! Cannot get collection with label "
|
61 |
|
|
<< edmName_ << endl;
|
62 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
63 |
|
|
<< "Error! Cannot get collection with label " << edmName_ << endl;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
const reco::MuonCollection inMuons = *(muonProduct_.product());
|
67 |
|
|
|
68 |
|
|
for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
|
69 |
|
|
|
70 |
|
|
mithep::Muon* outMuon = muons_->AddNew();
|
71 |
|
|
|
72 |
|
|
if (globalTrackMap_ && iM->combinedMuon().isNonnull())
|
73 |
|
|
outMuon->SetGlobalTrack(globalTrackMap_->GetMit(iM->combinedMuon()));
|
74 |
|
|
|
75 |
|
|
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
76 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
77 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
78 |
|
|
outMuon->SetStandaloneTrack(standaloneVtxTrackMap_->GetMit(iM->standAloneMuon()));
|
79 |
|
|
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
80 |
|
|
outMuon->SetStandaloneTrack(standaloneTrackMap_->GetMit(iM->standAloneMuon()));
|
81 |
|
|
else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
82 |
|
|
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
83 |
|
|
}
|
84 |
|
|
if (trackerTrackMap_ && iM->track().isNonnull())
|
85 |
|
|
outMuon->SetTrackerTrack(trackerTrackMap_->GetMit(iM->track()));
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
muons_->Trim();
|
89 |
|
|
}
|