8 #include <EVENT/LCCollection.h>
9 #include <IMPL/LCCollectionVec.h>
10 #include <EVENT/ReconstructedParticle.h>
11 #include <EVENT/Cluster.h>
12 #include <UTIL/LCTypedVector.h>
13 #include <EVENT/Track.h>
14 #include <marlin/Exceptions.h>
15 #include <EVENT/Vertex.h>
18 #include "marlin/VerbosityLevels.h"
22 #include "TLorentzVector.h"
24 #include "TMVA/Reader.h"
31 using namespace lcio ;
32 using namespace marlin ;
36 using namespace isolep;
44 _description =
"IsolatedPhotonTaggingProcessor does whatever it does ..." ;
49 registerInputCollection( LCIO::RECONSTRUCTEDPARTICLE,
50 "InputPandoraPFOsCollection" ,
51 "Name of the PandoraPFOs collection" ,
53 std::string(
"PandoraPFOs") ) ;
55 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
56 "OutputPFOsWithoutIsoPhotonCollection",
57 "Name of the new PFOs collection without isolated photon",
59 std::string(
"PandoraPFOsWithoutIsoPhoton") );
61 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
62 "OutputIsoPhotonsCollection",
63 "Name of collection with the selected isolated photon",
65 std::string(
"ISOPhotons") );
67 registerProcessorParameter(
"DirOfISOPhotonWeights",
68 "Directory of Weights for the Isolated Photon MVA Classification" ,
70 std::string(
"isolated_photon_weights") ) ;
72 registerProcessorParameter(
"CutOnTheISOPhotonMVA",
73 "Cut on the mva output of isolated photon selection" ,
77 registerProcessorParameter(
"IsSelectingOneIsoPhoton",
78 "flag to select one most like isolated photon" ,
82 registerProcessorParameter(
"MinEForPhoton",
83 "Minimum energy for photon" ,
87 registerProcessorParameter(
"CosConeSmall",
88 "cosine of the smaller cone" ,
92 registerProcessorParameter(
"CosConeLarge",
93 "cosine of the larger cone" ,
97 registerProcessorParameter(
"RatioNeutralConeEnergy",
98 "Cut on the ratio of Neutral Cone Energy over Photon Energy" ,
102 registerProcessorParameter(
"RatioChargedConeEnergy",
103 "Cut on the ratio of Charged Cone Energy over Photon Energy" ,
110 streamlog_out(DEBUG) <<
"IsolatedPhotonTagging init called "
124 auto pPFOsWithoutIsoPhotonCollection = std::make_unique<LCCollectionVec>(LCIO::RECONSTRUCTEDPARTICLE);
125 auto pIsoPhotonCollection = std::make_unique<LCCollectionVec>(LCIO::RECONSTRUCTEDPARTICLE);
126 pPFOsWithoutIsoPhotonCollection->setSubset(
true);
127 pIsoPhotonCollection->setSubset(
true);
129 streamlog_out(DEBUG) <<
"Hello, Isolated Photon Tagging!" << endl;
132 LCCollection *colPFO = evt->getCollection(
_colPFOs);
134 Int_t nPFOs = colPFO->getNumberOfElements();
135 std::vector<lcio::ReconstructedParticle*> newPFOs;
136 std::vector<lcio::ReconstructedParticle*> isoPhotons;
137 FloatVec isoPhotonTagging;
140 float energy_photon_max = -1.;
141 for (Int_t i=0;i<nPFOs;i++) {
142 ReconstructedParticle *recPart =
dynamic_cast<ReconstructedParticle*
>(colPFO->getElementAt(i));
144 newPFOs.push_back(recPart);
145 Double_t energy = recPart->getEnergy();
146 Double_t charge = recPart->getCharge();
147 TVector3 momentum = TVector3(recPart->getMomentum());
148 TLorentzVector lortz = TLorentzVector(momentum,energy);
149 Double_t momentumMagnitude = momentum.Mag();
152 Double_t coneEnergy0[3] = {0.,0.,0.};
153 Double_t pLargeCone[4] = {0.,0.,0.,0.};
155 Double_t coneEN = coneEnergy0[1];
156 Double_t coneEC = coneEnergy0[2];
157 TLorentzVector lortzLargeCone = TLorentzVector(pLargeCone[0],pLargeCone[1],pLargeCone[2],pLargeCone[3]);
158 TVector3 momentumLargeCone = lortzLargeCone.Vect();
159 Double_t cosThetaWithLargeCone = 1.;
160 if (momentumLargeCone.Mag() > 0.0000001) {
161 cosThetaWithLargeCone = momentum.Dot(momentumLargeCone)/momentumMagnitude/momentumLargeCone.Mag();
163 Double_t energyRatioWithLargeCone = energy/(energy+lortzLargeCone.E());
164 Double_t pandoraID = recPart->getType();
165 if (TMath::Abs(charge) < 0.5 && pandoraID == 22) {
166 if (energy <
_minE)
continue;
170 isoPhotons.push_back(recPart);
173 if (energy > energy_photon_max) {
174 energy_photon_max = energy;
176 isoPhotons.push_back(recPart);
184 for (
auto* obj : isoPhotons) {
185 pIsoPhotonCollection->addElement(obj);
189 for (
auto * obj : newPFOs) {
190 if (std::find(isoPhotons.cbegin(), isoPhotons.cend(), obj) == isoPhotons.cend()) {
191 pPFOsWithoutIsoPhotonCollection->addElement(obj);
196 evt->addCollection(pPFOsWithoutIsoPhotonCollection.release(),
_colNewPFOs.c_str());
197 evt->addCollection(pIsoPhotonCollection.release(),
_colPhotons.c_str());
208 for (std::vector<TMVA::Reader*>::const_iterator ireader=
_readers.begin();ireader!=
_readers.end();++ireader) {
std::string _isolated_photon_weights
virtual void end()
Called after data processing for clean up.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
std::vector< TMVA::Reader * > _readers
Double_t getConeEnergy(ReconstructedParticle *recPart, LCCollection *colPFO, Double_t cosCone)
IsolatedPhotonTaggingProcessor aIsolatedPhotonTaggingProcessor
virtual void init()
Called at the begin of the job before anything is read.
processor for isolated photon tagging.
std::string _colPFOs
Input collection name.
IsolatedPhotonTaggingProcessor()
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
virtual void check(LCEvent *evt)