16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
25 std::vector<bool>& active) {
29 AssMap elemAssociatedToConv;
31 bool blockHasConversion = setLinks(blockRef,elemAssociatedToConv, active );
33 if ( blockHasConversion ) {
34 conversionCandidate_.clear();
35 setCandidates(blockRef,elemAssociatedToConv);
36 if (conversionCandidate_.size() > 0 ){
41 setActive(blockRef,elemAssociatedToConv, active);
43 std::vector<reco::PFCandidate>::iterator it;
44 for ( it = conversionCandidate_.begin(); it != conversionCandidate_.end(); ++it ) {
59 AssMap& elemAssociatedToConv,
60 std::vector<bool>& active ) {
62 bool conversionFound =
false;
63 typedef std::multimap<double, unsigned>::iterator IE;
73 unsigned convTrack1Ind=100;
74 unsigned convTrack2Ind=100;
75 unsigned convEcal1Ind=200;
76 unsigned convEcal2Ind=200;
77 unsigned convHcal1Ind=200;
78 unsigned convHcal2Ind=200;
80 for(
unsigned iElem=0; iElem<elements.
size(); iElem++) {
81 bool trackFromConv = elements[iElem].trackType( PFBlockElement::T_FROM_GAMMACONV);
83 if (!active[iElem])
continue;
84 if ( !trackFromConv )
continue;
85 conversionFound =
true;
90 std::multimap<unsigned, std::vector<unsigned> >::iterator
found = elemAssociatedToConv.find(iElem);
91 if ( found!= elemAssociatedToConv.end()) {
97 bool alreadyTaken=
false;
98 for ( std::multimap<
unsigned, std::vector<unsigned> >::iterator
i=elemAssociatedToConv.begin();
99 i!= elemAssociatedToConv.end(); ++
i) {
100 for (
unsigned int j=0;
j< (
i->second).
size(); ++
j ) {
101 if ( iElem == (
i->second)[
j] ) alreadyTaken=
true;
104 if ( alreadyTaken ) {
110 vector<unsigned> assElements(0);
111 vector<unsigned>::iterator iVec;
113 std::multimap<double, unsigned> ecalElems;
118 std::multimap<double, unsigned> hcalElems;
124 std::multimap<double, unsigned> trackElems;
131 if(trackElems.empty() ) {
135 if(ecalElems.empty() ) {
139 if(hcalElems.empty() ) {
148 for(IE iTk = hcalElems.begin(); iTk != hcalElems.end(); ++iTk ) {
149 unsigned index = iTk->second;
162 for(IE iTk = ecalElems.begin(); iTk != ecalElems.end(); ++iTk ) {
163 unsigned index = iTk->second;
169 iVec =
find ( assElements.begin(), assElements.end(),
index) ;
170 if ( index< 100 && iVec == assElements.end() ) assElements.push_back(index);
176 for(IE iTk = trackElems.begin(); iTk != trackElems.end(); ++iTk ) {
177 unsigned index = iTk->second;
181 if ( index< 100) assElements.push_back(index);
183 std::multimap<double, unsigned> ecalElems2;
189 for(IE iTk = ecalElems2.begin(); iTk != ecalElems2.end(); ++iTk ) {
190 unsigned index = iTk->second;
195 iVec =
find ( assElements.begin(), assElements.end(),
index) ;
196 if ( index< 100 && iVec== assElements.end() ) assElements.push_back(index);
201 std::multimap<double, unsigned> hcalElems2;
205 for(IE iTk = hcalElems.begin(); iTk != hcalElems.end(); ++iTk ) {
206 unsigned index = iTk->second;
211 std::cout <<
" Hcal-Track link found with " << convHcal2Ind << std::endl;
219 elemAssociatedToConv.insert(make_pair(convTrack1Ind, assElements));
238 return conversionFound;
244 AssMap& elemAssociatedToConv ) {
247 vector<unsigned int> elementsToAdd(0);
260 for ( std::multimap<
unsigned, std::vector<unsigned> >::iterator
i=elemAssociatedToConv.begin();
261 i!= elemAssociatedToConv.end(); ++
i) {
263 unsigned int iTrack =
i->first;
264 elementsToAdd.push_back(iTrack);
268 pairPx+=convTrackRef->innerMomentum().x();
269 pairPy+=convTrackRef->innerMomentum().y();
270 pairPz+=convTrackRef->innerMomentum().z();
276 unsigned int nEl= (
i->second).
size();
278 for (
unsigned int j=0;
j< nEl; ++
j ) {
279 unsigned int iEl = (
i->second)[
j];
288 pairPx+=convTrackRef->innerMomentum().x();
289 pairPy+=convTrackRef->innerMomentum().y();
290 pairPz+=convTrackRef->innerMomentum().z();
299 elementsToAdd.push_back(iEl);
308 momentum.SetPxPyPzE(pairPx , pairPy, pairPz, EcalEne);
312 float deltaCotTheta=origConv->pairCotThetaSeparation();
313 float phiTk1= origConv->tracks()[0]->innerMomentum().phi();
314 float phiTk2= origConv->tracks()[1]->innerMomentum().phi();
316 if(deltaPhi >
pi) {deltaPhi = deltaPhi - twopi;}
317 if(deltaPhi < -
pi) {deltaPhi = deltaPhi + twopi;}
320 if ( fabs(deltaCotTheta) < 0.05 &&
abs(deltaPhi<0.1) ) {
325 for (
unsigned int elad=0; elad<elementsToAdd.size();elad++){
338 conversionCandidate_.push_back( aCandidate);
353 AssMap& elemAssociatedToConv, std::vector<bool>& active ) {
356 for ( std::multimap<
unsigned, std::vector<unsigned> >::iterator
i=elemAssociatedToConv.begin();
357 i!= elemAssociatedToConv.end(); ++
i) {
358 unsigned int iConvTrk =
i->first;
359 active[iConvTrk]=
false;
361 for (
unsigned int j=0;
j< (
i->second).
size(); ++
j ) {
362 active[(
i->second)[
j]]=
false;
void setPs2Energy(float e2)
set corrected PS2 energy
void setPs1Energy(float e1)
set corrected PS1 energy
ParticleType
particle types
void setFlag(Flags theFlag, bool value)
set a given flag
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
double deltaPhi(float phi1, float phi2)
PFClusterRef clusterRef() const
void runPFConversion(const reco::PFBlockRef &blockRef, std::vector< bool > &active)
std::map< unsigned int, Link > LinkData
std::multimap< unsigned, std::vector< unsigned > > AssMap
const edm::OwnVector< reco::PFBlockElement > & elements() const
const LinkData & linkData() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void addElementInBlock(const reco::PFBlockRef &blockref, unsigned elementIndex)
add an element to the current PFCandidate
double energy() const
cluster energy
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
void setConversionRef(const reco::ConversionRef &ref)
set ref to original reco conversion
reco::TrackRef trackRef() const
void setActive(const reco::PFBlockRef &blockRef, AssMap &assToConv, std::vector< bool > &active)
void setCandidates(const reco::PFBlockRef &blockref, AssMap &assToConv)
Particle reconstructed by the particle flow algorithm.
bool setLinks(const reco::PFBlockRef &blockRef, AssMap &assToConv, std::vector< bool > &active)
tuple size
Write out results.
void setHcalEnergy(float ehRaw, float ehCorr)
set corrected Hcal energy