1 |
loizides |
1.7 |
// $Id: FillerPhotons.cc,v 1.6 2008/07/14 21:01:00 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 |
loizides |
1.7 |
FillerPhotons::FillerPhotons(const edm::ParameterSet &cfg, bool active) :
|
20 |
loizides |
1.5 |
BaseFiller(cfg,"Photons",active),
|
21 |
bendavid |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","photons")),
|
22 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkPhotonBrn)),
|
23 |
loizides |
1.7 |
conversionMapName_(Conf().getUntrackedParameter<string>("conversionMapName","")),
|
24 |
loizides |
1.5 |
photons_(new mithep::PhotonArr(16)),
|
25 |
loizides |
1.7 |
conversionMap_(0)
|
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.7 |
// Add photon branch to tree and get the map.
|
42 |
loizides |
1.2 |
|
43 |
bendavid |
1.1 |
tws.AddBranch(mitName_.c_str(),&photons_);
|
44 |
loizides |
1.7 |
|
45 |
|
|
conversionMap_ = OS()->get<ConversionMap>(conversionMapName_.c_str());
|
46 |
bendavid |
1.1 |
}
|
47 |
|
|
|
48 |
loizides |
1.2 |
//--------------------------------------------------------------------------------------------------
|
49 |
bendavid |
1.1 |
void FillerPhotons::FillDataBlock(const edm::Event &event,
|
50 |
|
|
const edm::EventSetup &setup)
|
51 |
|
|
{
|
52 |
loizides |
1.2 |
// Fill photon array.
|
53 |
bendavid |
1.1 |
|
54 |
|
|
photons_->Reset();
|
55 |
loizides |
1.4 |
|
56 |
|
|
Handle<reco::PhotonCollection> hPhotonProduct;
|
57 |
|
|
GetProduct(edmName_, hPhotonProduct, event);
|
58 |
|
|
|
59 |
|
|
const reco::PhotonCollection inPhotons = *(hPhotonProduct.product());
|
60 |
bendavid |
1.1 |
|
61 |
loizides |
1.2 |
for (reco::PhotonCollection::const_iterator iP = inPhotons.begin();
|
62 |
|
|
iP != inPhotons.end(); ++iP) {
|
63 |
|
|
|
64 |
loizides |
1.5 |
mithep::Photon *outPhoton = photons_->Allocate();
|
65 |
loizides |
1.2 |
new (outPhoton) mithep::Photon(iP->px(),iP->py(),iP->pz(),iP->energy());
|
66 |
|
|
if (iP->isConverted() && conversionMap_) {
|
67 |
|
|
std::vector<reco::ConversionRef> conversionRefs = iP->conversions();
|
68 |
|
|
for (std::vector<reco::ConversionRef>::const_iterator conversionRef =
|
69 |
|
|
conversionRefs.begin(); conversionRef != conversionRefs.end(); ++conversionRef) {
|
70 |
|
|
outPhoton->AddConversion(conversionMap_->GetMit(*conversionRef));
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
bendavid |
1.1 |
}
|
74 |
loizides |
1.2 |
|
75 |
bendavid |
1.1 |
photons_->Trim();
|
76 |
|
|
}
|