1 |
loizides |
1.1 |
// $Id: FillerGlobalMuons.cc,v 1.3 2008/06/18 19:17:21 loizides Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerElectrons.h"
|
4 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
7 |
|
|
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
|
8 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
9 |
|
|
#include "DataFormats/EgammaCandidates/interface/PixelMatchGsfElectron.h"
|
10 |
|
|
#include "DataFormats/EgammaCandidates/interface/PixelMatchGsfElectronFwd.h"
|
11 |
|
|
|
12 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
13 |
|
|
//#include "MitAna/DataTree/interface/Muon.h"
|
14 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
15 |
|
|
|
16 |
|
|
using namespace std;
|
17 |
|
|
using namespace edm;
|
18 |
|
|
using namespace mithep;
|
19 |
|
|
|
20 |
|
|
//-------------------------------------------------------------------------------------------------
|
21 |
|
|
FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg,
|
22 |
|
|
const GsfTrackMap* gsfTrackMap, const TrackMap* trackerTrackMap) :
|
23 |
|
|
BaseFiller(cfg, "Electrons"),
|
24 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
|
25 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
|
26 |
|
|
electrons_(new mithep::ElectronArr),
|
27 |
|
|
gsfTrackMap_(gsfTrackMap),
|
28 |
|
|
trackerTrackMap_(trackerTrackMap)
|
29 |
|
|
{
|
30 |
|
|
// Constructor.
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
//-------------------------------------------------------------------------------------------------
|
34 |
|
|
FillerElectrons::~FillerElectrons()
|
35 |
|
|
{
|
36 |
|
|
// Destructor.
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
//-------------------------------------------------------------------------------------------------
|
40 |
|
|
void FillerElectrons::BookDataBlock(TreeWriter &tws)
|
41 |
|
|
{
|
42 |
|
|
// Add electron branch to our tree.
|
43 |
|
|
|
44 |
|
|
tws.AddBranch(mitName_.c_str(),&electrons_);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
//-------------------------------------------------------------------------------------------------
|
48 |
|
|
void FillerElectrons::FillDataBlock(const edm::Event &event,
|
49 |
|
|
const edm::EventSetup &setup)
|
50 |
|
|
{
|
51 |
|
|
// Fill electrons from edm collection into our collection.
|
52 |
|
|
|
53 |
|
|
electrons_->Reset();
|
54 |
|
|
|
55 |
|
|
try {
|
56 |
|
|
event.getByLabel(edmName_,electronProduct_);
|
57 |
|
|
} catch (cms::Exception& ex) {
|
58 |
|
|
edm::LogError("FillerElectrons") << "Error! Cannot get collection with label "
|
59 |
|
|
<< edmName_ << endl;
|
60 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillerElectrons:FillDataBlock()\n")
|
61 |
|
|
<< "Error! Cannot get collection with label " << edmName_ << endl;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
const reco::PixelMatchGsfElectronCollection inElectrons = *(electronProduct_.product());
|
65 |
|
|
|
66 |
|
|
for (reco::PixelMatchGsfElectronCollection::const_iterator iM = inElectrons.begin();
|
67 |
|
|
iM != inElectrons.end(); ++iM) {
|
68 |
|
|
|
69 |
|
|
mithep::Electron* outElectron = electrons_->AddNew();
|
70 |
|
|
if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
|
71 |
|
|
outElectron->SetGsfTrack(gsfTrackMap_->GetMit(iM->gsfTrack()));
|
72 |
|
|
if (trackerTrackMap_ && iM->track().isNonnull())
|
73 |
|
|
outElectron->SetTrackerTrack(trackerTrackMap_->GetMit(iM->track()));
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
electrons_->Trim();
|
77 |
|
|
}
|