CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ConversionSeedFilter Class Reference

#include <RecoTracker/TkSeedGenerator/src/ConversionSeedFilter.cc>

Inheritance diagram for ConversionSeedFilter:
edm::stream::EDProducer<>

Public Member Functions

 ConversionSeedFilter (const edm::ParameterSet &)
 
 ~ConversionSeedFilter () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void getKine (const TrajectoryStateOnSurface &tsos, double *vars)
 
TrajectoryStateOnSurface getTSOS (const TrajectorySeed &ts)
 
TrajectoryStateOnSurface getTSOS (const reco::Track &tk)
 
TrajectoryStateOnSurface getTSOS (const Trajectory &tj, const TrajectorySeed &ts)
 
bool isCompatible (double *vars1, double *vars2)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void SearchAmongSeeds (const TrajectorySeedCollection *pInPos, const TrajectorySeedCollection *pInNeg, TrajectorySeedCollection &selectedColl, std::vector< bool > &idxPosColl1, std::vector< bool > &idxPosColl2)
 
void SearchAmongTracks (const TrajectorySeedCollection *pInSeed, const reco::TrackCollection *pInTk, TrajectorySeedCollection &selectedColl, std::vector< bool > &idxPosColl)
 
void SearchAmongTrajectories (const TrajectorySeedCollection *pInSeed, const Trajectory *InTj, TrajectorySeedCollection &selectedColl, std::vector< bool > &idxPosColl)
 

Private Attributes

double deltaCotThetaCut
 
double deltaPhiCut
 
double deltaRCut
 
double deltaZCut
 
edm::EDGetTokenT< TrajectorySeedCollectioninputCollSeedNeg
 
edm::EDGetTokenT< TrajectorySeedCollectioninputCollSeedPos
 
edm::EDGetTokenT< TrajTrackAssociationCollectioninputTrajectory
 
uint32_t maxInputSeeds
 
bool takeAll
 
edm::ESHandle< TrackerGeometrytheG
 
edm::ESHandle< MagneticFieldtheMF
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 41 of file ConversionSeedFilter.cc.

Constructor & Destructor Documentation

ConversionSeedFilter::ConversionSeedFilter ( const edm::ParameterSet cfg)
explicit

Definition at line 69 of file ConversionSeedFilter.cc.

69  :
70  //inputCollTkPos(cfg.getParameter<edm::InputTag>("tkCollectionPos")),
71  inputCollSeedPos(consumes<TrajectorySeedCollection>(cfg.getParameter<edm::InputTag>("seedCollectionPos"))),
72  //inputCollTkNeg(cfg.getParameter<edm::InputTag>("tkCollectionNeg")),
73  inputCollSeedNeg(consumes<TrajectorySeedCollection>(cfg.getParameter<edm::InputTag>("seedCollectionNeg"))),
74  inputTrajectory(consumes<TrajTrackAssociationCollection>(cfg.getParameter<edm::InputTag>("inputTrajectory"))),
75  deltaPhiCut(cfg.getParameter<double>("deltaPhiCut")),
76  deltaCotThetaCut(cfg.getParameter<double>("deltaCotThetaCut")),
77  deltaRCut(cfg.getParameter<double>("deltaRCut")),
78  deltaZCut(cfg.getParameter<double>("deltaZCut")),
79  maxInputSeeds(cfg.getParameter<uint32_t>("maxInputSeeds")),
80  takeAll(cfg.getParameter<bool>("takeAll"))
81 {
82  produces<TrajectorySeedCollection>();
83 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TrajectorySeedCollection > inputCollSeedNeg
edm::EDGetTokenT< TrajectorySeedCollection > inputCollSeedPos
edm::EDGetTokenT< TrajTrackAssociationCollection > inputTrajectory
ConversionSeedFilter::~ConversionSeedFilter ( )
override

Definition at line 86 of file ConversionSeedFilter.cc.

86 {}

Member Function Documentation

void ConversionSeedFilter::getKine ( const TrajectoryStateOnSurface tsos,
double *  vars 
)
private

Definition at line 270 of file ConversionSeedFilter.cc.

References DEFINE_FWK_MODULE, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), funct::tan(), PV3DBase< T, PVType, FrameType >::theta(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by isCompatible(), SearchAmongSeeds(), SearchAmongTracks(), and SearchAmongTrajectories().

270  {
271 
272  vars[0] = tsos.globalMomentum().phi(); //phi
273  vars[1] = 2/tan(tsos.globalMomentum().theta()); //cotTheta
274  vars[2] = tsos.globalPosition().perp(); //R
275  vars[3] = tsos.globalPosition().z(); //Z
276 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T z() const
Definition: PV3DBase.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
GlobalVector globalMomentum() const
vars
Definition: DeepTauId.cc:77
TrajectoryStateOnSurface ConversionSeedFilter::getTSOS ( const TrajectorySeed ts)
private

Definition at line 229 of file ConversionSeedFilter.cc.

References PTrajectoryStateOnDet::detId(), TrackerGeometry::idToDet(), edm::ESHandle< T >::product(), TrajectorySeed::startingState(), GeomDet::surface(), theG, theMF, and trajectoryStateTransform::transientState().

Referenced by getTSOS(), SearchAmongSeeds(), SearchAmongTracks(), and SearchAmongTrajectories().

229  {
230 
232  DetId detId(state.detId());
234 }
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
unsigned int detId() const
edm::ESHandle< MagneticField > theMF
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const TrackerGeomDet * idToDet(DetId) const override
edm::ESHandle< TrackerGeometry > theG
T const * product() const
Definition: ESHandle.h:86
TrajectoryStateOnSurface ConversionSeedFilter::getTSOS ( const reco::Track tk)
private

Definition at line 237 of file ConversionSeedFilter.cc.

References getTSOS(), trajectoryStateTransform::innerStateOnSurface(), edm::ESHandle< T >::product(), theG, and theMF.

237  {
239 }
edm::ESHandle< MagneticField > theMF
edm::ESHandle< TrackerGeometry > theG
T const * product() const
Definition: ESHandle.h:86
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
TrajectoryStateOnSurface ConversionSeedFilter::getTSOS ( const Trajectory tj,
const TrajectorySeed ts 
)
private

Definition at line 242 of file ConversionSeedFilter.cc.

References Trajectory::closestMeasurement(), PTrajectoryStateOnDet::detId(), TrackerGeometry::idToDet(), isCompatible(), AlCaHLTBitMon_ParallelJobs::p, PTrajectoryStateOnDet::parameters(), LocalTrajectoryParameters::position(), TrajectorySeed::startingState(), GeomDet::surface(), theG, Surface::toGlobal(), and TrajectoryMeasurement::updatedState().

242  {
243 
245  DetId detId(state.detId());
246  GlobalPoint p = theG->idToDet(detId)->surface().toGlobal(state.parameters().position());
247  return tj.closestMeasurement(p).updatedState();
248 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
LocalPoint position() const
Local x and y position coordinates.
TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const
Definition: Trajectory.cc:256
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
unsigned int detId() const
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
const TrackerGeomDet * idToDet(DetId) const override
TrajectoryStateOnSurface const & updatedState() const
edm::ESHandle< TrackerGeometry > theG
const LocalTrajectoryParameters & parameters() const
bool ConversionSeedFilter::isCompatible ( double *  vars1,
double *  vars2 
)
private

Definition at line 251 of file ConversionSeedFilter.cc.

References deltaCotThetaCut, reco::deltaPhi(), hiPixelPairStep_cff::deltaPhi, deltaPhiCut, boostedElectronIsolation_cff::deltaR, deltaRCut, deltaZCut, and getKine().

Referenced by getTSOS(), SearchAmongSeeds(), SearchAmongTracks(), and SearchAmongTrajectories().

251  {
252 
253  double deltaPhi = fabs(reco::deltaPhi(vars1[0],vars2[0]) );
254  double deltaCotTheta = fabs( vars1[1]-vars2[1] );
255  double deltaR = fabs( vars1[2]-vars2[2] );
256  double deltaZ = fabs( vars1[3]-vars2[3] );
257  /*
258  std::cout << "\nnewCheck" << std::endl;
259  if(deltaPhi>deltaPhiCut) std::cout << "\nko deltaphi" << deltaPhi;
260  if(deltaCotTheta>deltaCotThetaCut ) std::cout << "\nko deltaCt " << deltaCotTheta;
261  if(deltaR>deltaRCut ) std::cout << "\nko deltaR " << deltaR;
262  if(deltaZ>deltaZCut ) std::cout << "\nko deltaZ " << deltaZ;
263  if(deltaPhi<deltaPhiCut && deltaCotTheta<deltaCotThetaCut && deltaR<deltaRCut && deltaZ<deltaZCut) std::cout << "\nok :)\n";
264  */
265  return deltaPhi<deltaPhiCut && deltaCotTheta<deltaCotThetaCut && deltaR<deltaRCut && deltaZ<deltaZCut;
266 
267 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
void ConversionSeedFilter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 89 of file ConversionSeedFilter.cc.

References TrackValidation_cff::association, edm::AssociationMap< Tag >::begin(), reco::TrackBase::charge(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edm::AssociationMap< Tag >::end(), edm::EventSetup::get(), edm::Event::getByToken(), inputCollSeedNeg, inputCollSeedPos, inputTrajectory, edm::HandleBase::isValid(), maxInputSeeds, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), mps_fire::result, SearchAmongSeeds(), SearchAmongTrajectories(), edm::AssociationMap< Tag >::size(), takeAll, theG, theMF, and HiIsolationCommonParameters_cff::track.

89  {
90  using namespace edm;
91  using namespace std;
94 
95  // Handle<reco::TrackCollection> pInTkPos; iEvent.getByLabel(inputCollTkPos,pInTkPos);
96  // Handle<reco::TrackCollection> pInTkNeg; iEvent.getByLabel(inputCollTkNeg,pInTkNeg);
97 
98  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociations; iEvent.getByToken(inputTrajectory,trajTrackAssociations);
99 
100  iSetup.get<TrackerDigiGeometryRecord>().get(theG);
101  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
102 
103  auto result = std::make_unique<TrajectorySeedCollection>();
104 
105  TrajectorySeedCollection selectedColl;
106 
107  if(takeAll){
108  result->insert(result->end(),pInPos->begin(),pInPos->end());
109  result->insert(result->end(),pInNeg->begin(),pInNeg->end());
110  }else{
111  edm::LogInfo("ConversionSeedFilter") << "takeAll " << takeAll ;
112  if (pInPos->size()<maxInputSeeds && pInNeg->size()<maxInputSeeds) {
113 
114  std::vector<bool> idxPosColl1(pInPos->size(),false);
115  std::vector<bool> idxPosColl2(pInNeg->size(),false);
116  selectedColl.reserve(pInPos->size());
117 
118  edm::LogInfo("ConversionSeedFilter") << "New Event \t Pos " << pInPos->size() << " \t Neg " << pInNeg->size() << std::endl;
119 
120  SearchAmongSeeds(pInPos.product(),pInNeg.product(),selectedColl,idxPosColl1,idxPosColl2);
121  //SearchAmongTracks(pInPos.product(),pInTkNeg.product(),selectedColl,idxPosColl1);
122  //SearchAmongTracks(pInNeg.product(),pInTkPos.product(),selectedColl,idxPosColl2);
123 
124  if(trajTrackAssociations.isValid()){
125  edm::LogInfo("ConversionSeedFilter") << "Reconstructed tracks " << trajTrackAssociations->size() << std::endl;
126  for( TrajTrackAssociationCollection::const_iterator association = trajTrackAssociations->begin();
127  association != trajTrackAssociations->end(); association++) {
128  const Trajectory* traj = association->key.get();
129  const reco::Track* track = association->val.get();
130 
131  //edm::LogInfo("ConversionSeedFilter") << "Traj charge " << track->charge() << std::endl;
132 
133  if(track->charge()<0){SearchAmongTrajectories(pInPos.product(),traj,selectedColl,idxPosColl1);}
134  else {SearchAmongTrajectories(pInNeg.product(),traj,selectedColl,idxPosColl2);}
135 
136  }
137  }
138  }
139  result->insert(result->end(),selectedColl.begin(),selectedColl.end());
140  }
141 
142 
143  edm::LogInfo("ConversionSeedFilter") << "\nNew Event : result size " << result->size()<< std::endl;
144 
145  iEvent.put(std::move(result));
146 
147 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const_iterator end() const
last iterator over the map (read only)
edm::EDGetTokenT< TrajectorySeedCollection > inputCollSeedNeg
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< TrajectorySeedCollection > inputCollSeedPos
edm::EDGetTokenT< TrajTrackAssociationCollection > inputTrajectory
void SearchAmongSeeds(const TrajectorySeedCollection *pInPos, const TrajectorySeedCollection *pInNeg, TrajectorySeedCollection &selectedColl, std::vector< bool > &idxPosColl1, std::vector< bool > &idxPosColl2)
std::vector< TrajectorySeed > TrajectorySeedCollection
void SearchAmongTrajectories(const TrajectorySeedCollection *pInSeed, const Trajectory *InTj, TrajectorySeedCollection &selectedColl, std::vector< bool > &idxPosColl)
bool isValid() const
Definition: HandleBase.h:74
edm::ESHandle< MagneticField > theMF
size_type size() const
map size
T const * product() const
Definition: Handle.h:74
HLT enums.
T get() const
Definition: EventSetup.h:71
int charge() const
track electric charge
Definition: TrackBase.h:606
const_iterator begin() const
first iterator over the map (read only)
edm::ESHandle< TrackerGeometry > theG
def move(src, dest)
Definition: eostools.py:511
void ConversionSeedFilter::SearchAmongSeeds ( const TrajectorySeedCollection pInPos,
const TrajectorySeedCollection pInNeg,
TrajectorySeedCollection selectedColl,
std::vector< bool > &  idxPosColl1,
std::vector< bool > &  idxPosColl2 
)
private

Definition at line 151 of file ConversionSeedFilter.cc.

References getKine(), getTSOS(), isCompatible(), and SearchAmongTracks().

Referenced by produce().

151  {
152 
153  for (TrajectorySeedCollection::const_iterator iS1=pInPos->begin(); iS1!=pInPos->end(); ++iS1){
154  bool pushed1 = false;
155 
156  double vars1[4];
157  getKine(getTSOS(*iS1),vars1);
158 
159  for (TrajectorySeedCollection::const_iterator iS2=pInNeg->begin(); iS2!=pInNeg->end(); ++iS2){
160 
161  double vars2[4];
162  getKine(getTSOS(*iS2),vars2);
163 
164  if(isCompatible(vars1,vars2)){
165  edm::LogInfo("ConversionSeedFilter") << "[SearchAmongSeeds] match in pos " << iS1-pInPos->begin() << " " << iS2-pInNeg->begin() << std::endl;
166  if (!pushed1) {
167  idxPosColl1[iS1-pInPos->begin()]=true;
168  selectedColl.push_back(*iS1);
169  pushed1 = true;
170  }
171  if(!idxPosColl2[iS2-pInNeg->begin()]){
172  selectedColl.push_back(*iS2);
173  idxPosColl2[iS2-pInNeg->begin()]=true;
174  }
175  }
176  }
177  }
178 }
void getKine(const TrajectoryStateOnSurface &tsos, double *vars)
TrajectoryStateOnSurface getTSOS(const TrajectorySeed &ts)
bool isCompatible(double *vars1, double *vars2)
void ConversionSeedFilter::SearchAmongTracks ( const TrajectorySeedCollection pInSeed,
const reco::TrackCollection pInTk,
TrajectorySeedCollection selectedColl,
std::vector< bool > &  idxPosColl 
)
private

Definition at line 181 of file ConversionSeedFilter.cc.

References getKine(), getTSOS(), isCompatible(), and SearchAmongTrajectories().

Referenced by SearchAmongSeeds().

181  {
182 
183  for (TrajectorySeedCollection::const_iterator iS1=pInSeed->begin(); iS1!=pInSeed->end(); ++iS1){
184 
185  if(idxPosColl[iS1-pInSeed->begin()])
186  continue;
187 
188  double vars1[4];
189  getKine(getTSOS(*iS1),vars1);
190 
191  for (reco::TrackCollection::const_iterator iS2=pInTk->begin(); iS2!=pInTk->end(); ++iS2){
192 
193  double vars2[4];
194  getKine(getTSOS(*iS2),vars2);
195 
196  if(isCompatible(vars1,vars2)){
197  edm::LogInfo("ConversionSeedFilter") << "[SearchAmongTracks] match in pos " << iS1-pInSeed->begin() << std::endl;
198  idxPosColl[iS1-pInSeed->begin()]=true;
199  selectedColl.push_back(*iS1);
200  continue;
201  }
202  }
203  }
204 }
void getKine(const TrajectoryStateOnSurface &tsos, double *vars)
TrajectoryStateOnSurface getTSOS(const TrajectorySeed &ts)
bool isCompatible(double *vars1, double *vars2)
void ConversionSeedFilter::SearchAmongTrajectories ( const TrajectorySeedCollection pInSeed,
const Trajectory InTj,
TrajectorySeedCollection selectedColl,
std::vector< bool > &  idxPosColl 
)
private

Definition at line 207 of file ConversionSeedFilter.cc.

References getKine(), getTSOS(), and isCompatible().

Referenced by produce(), and SearchAmongTracks().

207  {
208 
209  for (TrajectorySeedCollection::const_iterator iS1=pInSeed->begin(); iS1!=pInSeed->end(); ++iS1){
210 
211  if(idxPosColl[iS1-pInSeed->begin()])
212  continue;
213 
214  double vars1[4];
215  getKine(getTSOS(*iS1),vars1);
216 
217  double vars2[4];
218  getKine(getTSOS(*InTj,*iS1),vars2);
219 
220  if(isCompatible(vars1,vars2)){
221  edm::LogInfo("ConversionSeedFilter") << "[SearchAmongTrajectories] match seed in pos " << iS1-pInSeed->begin() << " of " << pInSeed->size() << " seed charge " << iS1->startingState().parameters().charge()<<std::endl;
222  idxPosColl[iS1-pInSeed->begin()]=true;
223  selectedColl.push_back(*iS1);
224  }
225  }
226 }
void getKine(const TrajectoryStateOnSurface &tsos, double *vars)
TrajectoryStateOnSurface getTSOS(const TrajectorySeed &ts)
bool isCompatible(double *vars1, double *vars2)

Member Data Documentation

double ConversionSeedFilter::deltaCotThetaCut
private

Definition at line 61 of file ConversionSeedFilter.cc.

Referenced by isCompatible().

double ConversionSeedFilter::deltaPhiCut
private

Definition at line 61 of file ConversionSeedFilter.cc.

Referenced by isCompatible().

double ConversionSeedFilter::deltaRCut
private

Definition at line 61 of file ConversionSeedFilter.cc.

Referenced by isCompatible().

double ConversionSeedFilter::deltaZCut
private

Definition at line 61 of file ConversionSeedFilter.cc.

Referenced by isCompatible().

edm::EDGetTokenT<TrajectorySeedCollection> ConversionSeedFilter::inputCollSeedNeg
private

Definition at line 59 of file ConversionSeedFilter.cc.

Referenced by produce().

edm::EDGetTokenT<TrajectorySeedCollection> ConversionSeedFilter::inputCollSeedPos
private

Definition at line 58 of file ConversionSeedFilter.cc.

Referenced by produce().

edm::EDGetTokenT<TrajTrackAssociationCollection> ConversionSeedFilter::inputTrajectory
private

Definition at line 60 of file ConversionSeedFilter.cc.

Referenced by produce().

uint32_t ConversionSeedFilter::maxInputSeeds
private

Definition at line 65 of file ConversionSeedFilter.cc.

Referenced by produce().

bool ConversionSeedFilter::takeAll
private

Definition at line 66 of file ConversionSeedFilter.cc.

Referenced by produce().

edm::ESHandle<TrackerGeometry> ConversionSeedFilter::theG
private

Definition at line 63 of file ConversionSeedFilter.cc.

Referenced by getTSOS(), and produce().

edm::ESHandle<MagneticField> ConversionSeedFilter::theMF
private

Definition at line 64 of file ConversionSeedFilter.cc.

Referenced by getTSOS(), and produce().