1 |
loizides |
1.4 |
// $Id: FillerPhotons.cc,v 1.3 2008/07/07 16:14:01 loizides Exp $
|
2 |
bendavid |
1.1 |
|
3 |
loizides |
1.2 |
#include "MitProd/TreeFiller/interface/FillerPhotons.h"
|
4 |
bendavid |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
7 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
8 |
|
|
#include "DataFormats/EgammaCandidates/interface/Photon.h"
|
9 |
|
|
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
|
10 |
|
|
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
|
11 |
|
|
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
|
12 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
13 |
|
|
|
14 |
|
|
using namespace std;
|
15 |
|
|
using namespace edm;
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
19 |
|
|
FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, bool active,
|
20 |
|
|
const ConversionMap *conversionMap) :
|
21 |
bendavid |
1.1 |
BaseFiller(cfg, "Photons", active),
|
22 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
|
23 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
|
24 |
loizides |
1.2 |
photons_(new mithep::Array<mithep::Photon>),
|
25 |
|
|
conversionMap_(conversionMap)
|
26 |
bendavid |
1.1 |
{
|
27 |
loizides |
1.2 |
// Constructor.
|
28 |
bendavid |
1.1 |
}
|
29 |
|
|
|
30 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
31 |
bendavid |
1.1 |
FillerPhotons::~FillerPhotons()
|
32 |
|
|
{
|
33 |
loizides |
1.2 |
// Destructor.
|
34 |
loizides |
1.3 |
|
35 |
|
|
delete photons_;
|
36 |
bendavid |
1.1 |
}
|
37 |
|
|
|
38 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
39 |
bendavid |
1.1 |
void FillerPhotons::BookDataBlock(TreeWriter &tws)
|
40 |
|
|
{
|
41 |
loizides |
1.2 |
// Add photon branch to tree.
|
42 |
|
|
|
43 |
bendavid |
1.1 |
tws.AddBranch(mitName_.c_str(),&photons_);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
47 |
bendavid |
1.1 |
void FillerPhotons::FillDataBlock(const edm::Event &event,
|
48 |
|
|
const edm::EventSetup &setup)
|
49 |
|
|
{
|
50 |
loizides |
1.2 |
// Fill photon array.
|
51 |
bendavid |
1.1 |
|
52 |
|
|
photons_->Reset();
|
53 |
loizides |
1.4 |
|
54 |
|
|
Handle<reco::PhotonCollection> hPhotonProduct;
|
55 |
|
|
GetProduct(edmName_, hPhotonProduct, event);
|
56 |
|
|
|
57 |
|
|
const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
|
58 |
bendavid |
1.1 |
|
59 |
loizides |
1.2 |
for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
|
60 |
|
|
iP != inPhotons.end(); ++iP) {
|
61 |
|
|
|
62 |
|
|
mithep::Photon* outPhoton = photons_->Allocate();
|
63 |
|
|
new (outPhoton) mithep::Photon(iP->px(),iP->py(),iP->pz(),iP->energy());
|
64 |
|
|
if (iP->isConverted() && conversionMap_) {
|
65 |
|
|
std::vector<reco::ConversionRef> conversionRefs = iP->conversions();
|
66 |
|
|
for (std::vector<reco::ConversionRef>::const_iterator conversionRef =
|
67 |
|
|
conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
|
68 |
|
|
outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
bendavid |
1.1 |
}
|
72 |
loizides |
1.2 |
|
73 |
bendavid |
1.1 |
photons_->Trim();
|
74 |
|
|
}
|