From e1a5c832962409ba808a3c5f2a440e3d994b3ec2 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Wed, 29 Apr 2015 09:36:21 +0200 Subject: [PATCH 01/13] adding ME0 for recolocal --- DataFormats/GEMRecHit/BuildFile.xml | 2 + DataFormats/GEMRecHit/interface/ME0RecHit.h | 113 ++++ .../GEMRecHit/interface/ME0RecHitCollection.h | 29 + DataFormats/GEMRecHit/interface/ME0Segment.h | 85 +++ .../interface/ME0SegmentCollection.h | 24 + DataFormats/GEMRecHit/src/ME0RecHit.cc | 78 +++ DataFormats/GEMRecHit/src/ME0Segment.cc | 112 ++++ DataFormats/GEMRecHit/src/classes.h | 18 +- DataFormats/GEMRecHit/src/classes_def.xml | 37 +- .../interface/ME0RecHitAlgoFactory.h | 17 + .../GEMRecHit/interface/ME0RecHitBaseAlgo.h | 60 ++ .../GEMRecHit/python/me0LocalReco_cff.py | 6 + .../GEMRecHit/python/me0RecHits_cfi.py | 9 + .../GEMRecHit/python/me0Segments_cfi.py | 17 + .../GEMRecHit/src/ME0RecHitAlgoFactory.cc | 14 + .../GEMRecHit/src/ME0RecHitBaseAlgo.cc | 42 ++ .../GEMRecHit/src/ME0RecHitProducer.cc | 104 ++++ .../GEMRecHit/src/ME0RecHitProducer.h | 61 ++ .../GEMRecHit/src/ME0RecHitStandardAlgo.cc | 55 ++ .../GEMRecHit/src/ME0RecHitStandardAlgo.h | 40 ++ RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc | 556 ++++++++++++++++++ RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h | 95 +++ .../GEMRecHit/src/ME0SegmentAlgorithm.h | 40 ++ .../GEMRecHit/src/ME0SegmentBuilder.cc | 75 +++ .../GEMRecHit/src/ME0SegmentBuilder.h | 50 ++ .../src/ME0SegmentBuilderPluginFactory.cc | 12 + .../src/ME0SegmentBuilderPluginFactory.h | 18 + .../GEMRecHit/src/ME0SegmentProducer.cc | 56 ++ .../GEMRecHit/src/ME0SegmentProducer.h | 35 ++ RecoLocalMuon/GEMRecHit/src/SealModule.cc | 23 +- 30 files changed, 1873 insertions(+), 10 deletions(-) create mode 100644 DataFormats/GEMRecHit/interface/ME0RecHit.h create mode 100644 DataFormats/GEMRecHit/interface/ME0RecHitCollection.h create mode 100644 DataFormats/GEMRecHit/interface/ME0Segment.h create mode 100644 DataFormats/GEMRecHit/interface/ME0SegmentCollection.h create mode 100644 DataFormats/GEMRecHit/src/ME0RecHit.cc create mode 100644 DataFormats/GEMRecHit/src/ME0Segment.cc create mode 100644 RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h create mode 100644 RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h create mode 100644 RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py create mode 100644 RecoLocalMuon/GEMRecHit/python/me0RecHits_cfi.py create mode 100644 RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitAlgoFactory.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc create mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h diff --git a/DataFormats/GEMRecHit/BuildFile.xml b/DataFormats/GEMRecHit/BuildFile.xml index 0b431e98854d6..be517a1f490cb 100644 --- a/DataFormats/GEMRecHit/BuildFile.xml +++ b/DataFormats/GEMRecHit/BuildFile.xml @@ -1,6 +1,8 @@ + + diff --git a/DataFormats/GEMRecHit/interface/ME0RecHit.h b/DataFormats/GEMRecHit/interface/ME0RecHit.h new file mode 100644 index 0000000000000..4fc81d4ee3ce6 --- /dev/null +++ b/DataFormats/GEMRecHit/interface/ME0RecHit.h @@ -0,0 +1,113 @@ +#ifndef DataFormats_ME0RecHit_H +#define DataFormats_ME0RecHit_H + +/** \class ME0RecHit +* +* RecHit for ME0 +* +* $Date: 2014/02/03 16:54:23 $ +* $Revision: 1.1 $ +* \author M. Maggi -- INFN Bari +*/ + +#include "DataFormats/TrackingRecHit/interface/RecHit2DLocalPos.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" + + +class ME0RecHit : public RecHit2DLocalPos { + public: + + ME0RecHit(const ME0DetId& me0Id, +float tof); + + /// Default constructor + ME0RecHit(); + + /// Constructor from a local position, gemId and digi time. + /// The 3-dimensional local error is defined as + /// resolution (the cell resolution) for the coordinate being measured + /// and 0 for the two other coordinates + ME0RecHit(const ME0DetId& me0Id, +float tof, +const LocalPoint& pos); + + + /// Constructor from a local position and error, gemId and bx. + ME0RecHit(const ME0DetId& me0Id, +float tof, +const LocalPoint& pos, +const LocalError& err); + + + /// Destructor + virtual ~ME0RecHit(); + + + /// Return the 3-dimensional local position + virtual LocalPoint localPosition() const { + return theLocalPosition; + } + + + /// Return the 3-dimensional error on the local position + virtual LocalError localPositionError() const { + return theLocalError; + } + + + virtual ME0RecHit* clone() const; + + + /// Access to component RecHits. + /// No components rechits: it returns a null vector + virtual std::vector recHits() const; + + + /// Non-const access to component RecHits. + /// No components rechits: it returns a null vector + virtual std::vector recHits(); + + + /// Set local position + void setPosition(LocalPoint pos) { + theLocalPosition = pos; + } + + + /// Set local position error + void setError(LocalError err) { + theLocalError = err; + } + + + /// Set the local position and its error + void setPositionAndError(LocalPoint pos, LocalError err) { + theLocalPosition = pos; + theLocalError = err; + } + + + /// Return the gemId + ME0DetId me0Id() const { + return theME0Id; + } + + float tof() const { + return theTOF; + } + + /// Comparison operator, based on the gemId and the digi time + bool operator==(const ME0RecHit& hit) const; + + private: + ME0DetId theME0Id; + float theTOF; + // Position and error in the Local Ref. Frame of the ME0Layer + LocalPoint theLocalPosition; + LocalError theLocalError; + +}; +#endif + +/// The ostream operator +std::ostream& operator<<(std::ostream& os, const ME0RecHit& hit); diff --git a/DataFormats/GEMRecHit/interface/ME0RecHitCollection.h b/DataFormats/GEMRecHit/interface/ME0RecHitCollection.h new file mode 100644 index 0000000000000..3b65df23d177e --- /dev/null +++ b/DataFormats/GEMRecHit/interface/ME0RecHitCollection.h @@ -0,0 +1,29 @@ +#ifndef DataFormats_ME0RecHitCollection_H +#define DataFormats_ME0RecHitCollection_H + +/** \class ME0RecHitCollection + * Collection of ME0RecHit for storage in the event + * + * $Date: 2013/04/24 16:54:23 $ + * $Revision: 1.1 $ + * \author M. Maggi - INFN Bari + */ + + +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" +#include "DataFormats/Common/interface/RangeMap.h" +#include "DataFormats/Common/interface/ClonePolicy.h" +#include "DataFormats/Common/interface/OwnVector.h" +#include + +typedef edm::RangeMap >, + edm::ClonePolicy > ME0RecHitCollection; + + +#endif + + + + diff --git a/DataFormats/GEMRecHit/interface/ME0Segment.h b/DataFormats/GEMRecHit/interface/ME0Segment.h new file mode 100644 index 0000000000000..c0014029131a9 --- /dev/null +++ b/DataFormats/GEMRecHit/interface/ME0Segment.h @@ -0,0 +1,85 @@ +#ifndef GEMRecHit_ME0Segment_h +#define GEMRecHit_ME0Segment_h + +/** \class ME0Segment derived by the CSC segment + * Describes a reconstructed track segment in the 6 layers of the ME0 system. + * This is 4-dimensional since it has an origin (x,y) and a direction (x,y) + * in the local coordinate system of the chamber. + * + * $Date: 2014/02/04 12:41:32 $ + * \author Marcello Maggi + */ + +#include +#include + +#include + +class ME0DetId; + +class ME0Segment GCC11_FINAL : public RecSegment { + +public: + + /// Default constructor + ME0Segment() : theChi2(0.){} + + /// Constructor + ME0Segment(const std::vector& proto_segment, LocalPoint origin, + LocalVector direction, AlgebraicSymMatrix errors, double chi2); + + /// Destructor + virtual ~ME0Segment(); + + //--- Base class interface + ME0Segment* clone() const { return new ME0Segment(*this); } + + LocalPoint localPosition() const { return theOrigin; } + LocalError localPositionError() const ; + + LocalVector localDirection() const { return theLocalDirection; } + LocalError localDirectionError() const ; + + /// Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y ) + AlgebraicVector parameters() const; + + /// Covariance matrix of parameters() + AlgebraicSymMatrix parametersError() const { return theCovMatrix; } + + /// The projection matrix relates the trajectory state parameters to the segment parameters(). + virtual AlgebraicMatrix projectionMatrix() const; + + virtual std::vector recHits() const; + + virtual std::vector recHits(); + + double chi2() const { return theChi2; }; + + virtual int dimension() const { return 4; } + + virtual int degreesOfFreedom() const { return 2*nRecHits() - 4;} + + //--- Extension of the interface + + const std::vector& specificRecHits() const { return theME0RecHits; } + + int nRecHits() const { return theME0RecHits.size(); } + + ME0DetId me0DetId() const { return geographicalId(); } + + float time() const; + + void print() const; + + private: + + std::vector theME0RecHits; + LocalPoint theOrigin; // in chamber frame - the GeomDet local coordinate system + LocalVector theLocalDirection; // in chamber frame - the GeomDet local coordinate system + AlgebraicSymMatrix theCovMatrix; // the covariance matrix + double theChi2; +}; + +std::ostream& operator<<(std::ostream& os, const ME0Segment& seg); + +#endif diff --git a/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h b/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h new file mode 100644 index 0000000000000..67c6db2a95350 --- /dev/null +++ b/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h @@ -0,0 +1,24 @@ +#ifndef DataFormats_ME0SegmentCollection_H +#define DataFormats_ME0SegmentCollection_H + +/** \class ME0SegmentCollection + * + * The collection of ME0Segment's. See \ref CSCSegmentCollection.h for details from which is derived. + * + * $Date: 2014/02/04 10:08:15 $ + * \author Marcello Maggi + */ + +#include +#include + +#include +#include +#include + +typedef edm::RangeMap > ME0SegmentCollection; + +#include +typedef edm::Ref ME0SegmentRef; + +#endif diff --git a/DataFormats/GEMRecHit/src/ME0RecHit.cc b/DataFormats/GEMRecHit/src/ME0RecHit.cc new file mode 100644 index 0000000000000..53d181aebc9e7 --- /dev/null +++ b/DataFormats/GEMRecHit/src/ME0RecHit.cc @@ -0,0 +1,78 @@ +/* + * See header file for a description of this class. + * + * $Date: 2013/04/24 16:54:24 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN Bari + */ + + +#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" + + +ME0RecHit::ME0RecHit(const ME0DetId& me0Id, float tof) : RecHit2DLocalPos(me0Id), + theME0Id(me0Id), theTOF(tof), theLocalPosition(), theLocalError() +{ +} + +ME0RecHit::ME0RecHit() : RecHit2DLocalPos(), + theME0Id(), theTOF(0.), theLocalPosition(), theLocalError() +{ +} + + +ME0RecHit::ME0RecHit(const ME0DetId& me0Id, float tof, const LocalPoint& pos) : RecHit2DLocalPos(me0Id), + theME0Id(me0Id), theTOF(tof), theLocalPosition(pos), theLocalError() +{ +} + + + +// Constructor from a local position and error, wireId and digi time. +ME0RecHit::ME0RecHit(const ME0DetId& me0Id, + float tof, + const LocalPoint& pos, + const LocalError& err) : RecHit2DLocalPos(me0Id), + theME0Id(me0Id), theTOF(tof), theLocalPosition(pos), theLocalError(err) +{ +} + +// Destructor +ME0RecHit::~ME0RecHit() +{ +} + + + +ME0RecHit * ME0RecHit::clone() const { + return new ME0RecHit(*this); +} + + +// Access to component RecHits. +// No components rechits: it returns a null vector +std::vector ME0RecHit::recHits() const { + std::vector nullvector; + return nullvector; +} +// Non-const access to component RecHits. +// No components rechits: it returns a null vector +std::vector ME0RecHit::recHits() { + std::vector nullvector; + return nullvector; +} + +// Comparison operator, based on the wireId and the digi time +bool ME0RecHit::operator==(const ME0RecHit& hit) const { + return this->geographicalId() == hit.geographicalId(); +} + + +// The ostream operator +std::ostream& operator<<(std::ostream& os, const ME0RecHit& hit) { + os << "pos: x = " << hit.localPosition().x() ; + os << " +/- " << sqrt(hit.localPositionError().xx())<<" cm"; + os<< " y = " << hit.localPosition().y() ; + os << " +/- " << sqrt(hit.localPositionError().yy())<<" cm"; + return os; +} diff --git a/DataFormats/GEMRecHit/src/ME0Segment.cc b/DataFormats/GEMRecHit/src/ME0Segment.cc new file mode 100644 index 0000000000000..9b5ed4eb10906 --- /dev/null +++ b/DataFormats/GEMRecHit/src/ME0Segment.cc @@ -0,0 +1,112 @@ +/** \file ME0egment.cc + * + * $Date: 2014/02/04 12:41:33 $ + * \author Marcello Maggi + */ + +#include +#include + +namespace { + // define a Super Layer Id from the first layer of the first rechits, and put to first layer + inline + DetId buildDetId(ME0DetId id) { + return ME0DetId(id.region(),1,id.chamber(),id.roll()); + } + +} + +ME0Segment::ME0Segment(const std::vector& proto_segment, LocalPoint origin, + LocalVector direction, AlgebraicSymMatrix errors, double chi2) : + RecSegment(buildDetId(proto_segment.front()->me0Id())), + theOrigin(origin), + theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){ + + for(unsigned int i=0; i ME0Segment::recHits() const{ + std::vector pointersOfRecHits; + for (std::vector::const_iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) { + pointersOfRecHits.push_back(&(*irh)); + } + return pointersOfRecHits; +} + +std::vector ME0Segment::recHits() { + + std::vector pointersOfRecHits; + for (std::vector::iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) { + pointersOfRecHits.push_back(&(*irh)); + } + return pointersOfRecHits; +} + +LocalError ME0Segment::localPositionError() const { + return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); +} + +LocalError ME0Segment::localDirectionError() const { + return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); +} + + +AlgebraicVector ME0Segment::parameters() const { + // For consistency with DT and CSC and what we require for the TrackingRecHit interface, + // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z) + + AlgebraicVector result(4); + + result[0] = theLocalDirection.x()/theLocalDirection.z(); + result[1] = theLocalDirection.y()/theLocalDirection.z(); + result[2] = theOrigin.x(); + result[3] = theOrigin.y(); + + return result; +} + + +AlgebraicMatrix ME0Segment::projectionMatrix() const { + static AlgebraicMatrix theProjectionMatrix( 4, 5, 0); + static bool isInitialized = false; + if (!isInitialized) { + theProjectionMatrix[0][1] = 1; + theProjectionMatrix[1][2] = 1; + theProjectionMatrix[2][3] = 1; + theProjectionMatrix[3][4] = 1; + isInitialized=true; + } + return theProjectionMatrix; +} + +float ME0Segment::time() const { + float averageTime=0; + for (std::vector::const_iterator itRH = theME0RecHits.begin(); + itRH != theME0RecHits.end(); ++itRH) { + const ME0RecHit *recHit = &(*itRH); + averageTime+=recHit->tof(); + } + averageTime=averageTime/(theME0RecHits.size()); + return averageTime; +} + +// +void ME0Segment::print() const { + std::cout << *this << std::endl; +} + +std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) { + os << "ME0Segment: local pos = " << seg.localPosition() << + " posErr = (" << sqrt(seg.localPositionError().xx())<<","< dummyrpc1; std::pair dummyrpc2; std::map > dummyrpcdetid1; std::map > dummyrpcdetid2; + std::map > dummyme0detid1; + std::map > dummyme0detid2; GEMRecHit rrh; std::vector vrh; GEMRecHitCollection c; edm::Wrapper w; + + ME0RecHit mrh; + std::vector vmrh; + ME0RecHitCollection mc; + edm::Wrapper mw; + + ME0Segment ms; + ME0SegmentCollection seg; + edm::Wrapper dwc1; + ME0SegmentRef ref; }; } diff --git a/DataFormats/GEMRecHit/src/classes_def.xml b/DataFormats/GEMRecHit/src/classes_def.xml index 64c85963465fa..149387471fcce 100644 --- a/DataFormats/GEMRecHit/src/classes_def.xml +++ b/DataFormats/GEMRecHit/src/classes_def.xml @@ -1,8 +1,8 @@ - - + + @@ -11,10 +11,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h new file mode 100644 index 0000000000000..69c0e558294a8 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h @@ -0,0 +1,17 @@ +#ifndef RecoLocalMuon_ME0RecHitAlgoFactory_H +#define RecoLocalMuon_ME0RecHitAlgoFactory_H + +/** \class ME0RecHitAlgoFactory + * Factory of seal plugins for 1D RecHit reconstruction algorithms. + * The plugins are concrete implementations of ME0RecHitBaseAlgo base class. + * + * $Date: 2014/02/04 10:16:32 $ + * $Revision: 1.1 $ + * \author M. Maggi - INFN Torino + */ +#include "FWCore/PluginManager/interface/PluginFactory.h" +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" + +typedef edmplugin::PluginFactory ME0RecHitAlgoFactory; +#endif + diff --git a/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h new file mode 100644 index 0000000000000..ca8718a3124c4 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h @@ -0,0 +1,60 @@ +#ifndef RecoLocalMuon_ME0RecHitBaseAlgo_H +#define RecoLocalMuon_ME0RecHitBaseAlgo_H + +/** \class ME0RecHitBaseAlgo + * Abstract algorithmic class to compute Rec Hit + * form a ME0 digi + * + * $Date: 2014/02/04 10:16:32 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN Bari + */ + + +#include "DataFormats/GeometryVector/interface/LocalPoint.h" +#include "DataFormats/GeometrySurface/interface/LocalError.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" +#include "DataFormats/Common/interface/OwnVector.h" + +class ME0DetId; + +namespace edm { + class ParameterSet; + class EventSetup; +} + + +class ME0RecHitBaseAlgo { + + public: + + /// Constructor + ME0RecHitBaseAlgo(const edm::ParameterSet& config); + + /// Destructor + virtual ~ME0RecHitBaseAlgo(); + + /// Pass the Event Setup to the algo at each event + virtual void setES(const edm::EventSetup& setup) = 0; + + /// Build all hits in the range associated to the me0Id, at the 1st step. + virtual edm::OwnVector reconstruct(const ME0DetId& me0Id, + const ME0DigiPreRecoCollection::Range& digiRange); + + /// standard local recHit computation + virtual bool compute(const ME0DigiPreReco& digi, + LocalPoint& Point, + LocalError& error) const = 0; + + /// local recHit computation accounting for track direction and + /// absolute position + virtual bool compute(const ME0DigiPreReco& digi, + const float& angle, + const GlobalPoint& globPos, + LocalPoint& Point, + LocalError& error) const = 0; +}; +#endif + diff --git a/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py b/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py new file mode 100644 index 0000000000000..0d5fb51fb5d45 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +from RecoLocalMuon.GEMRecHit.me0RecHits_cfi import * +from RecoLocalMuon.GEMRecHit.me0Segments_cfi import * + +me0LocalReco = cms.Sequence(me0RecHits*me0Segments) diff --git a/RecoLocalMuon/GEMRecHit/python/me0RecHits_cfi.py b/RecoLocalMuon/GEMRecHit/python/me0RecHits_cfi.py new file mode 100644 index 0000000000000..0616b6097afa3 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/python/me0RecHits_cfi.py @@ -0,0 +1,9 @@ +import FWCore.ParameterSet.Config as cms + +me0RecHits = cms.EDProducer("ME0RecHitProducer", + recAlgoConfig = cms.PSet( + + ), + recAlgo = cms.string('ME0RecHitStandardAlgo'), + me0DigiLabel = cms.InputTag("simMuonME0Digis"), +) diff --git a/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py b/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py new file mode 100644 index 0000000000000..fc57fb970bc24 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py @@ -0,0 +1,17 @@ +import FWCore.ParameterSet.Config as cms + +me0Segments = cms.EDProducer("ME0SegmentProducer", + me0RecHitLabel = cms.InputTag("me0RecHits"), + algo_name = cms.string("ME0SegAlgoMM"), + algo_pset = cms.PSet( + ME0Debug = cms.untracked.bool(True), + minHitsPerSegment = cms.uint32(3), + preClustering = cms.bool(True), + dXclusBoxMax = cms.double(1.), + dYclusBoxMax = cms.double(5.), + preClusteringUseChaining = cms.bool(True), + dPhiChainBoxMax = cms.double(.02), + dEtaChainBoxMax = cms.double(.05), + maxRecHitsInCluster = cms.int32(6) + ) +) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitAlgoFactory.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitAlgoFactory.cc new file mode 100644 index 0000000000000..fda6b8af9c6a9 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitAlgoFactory.cc @@ -0,0 +1,14 @@ +/* + * See header file for a description of this class. + * + * $Date: 2014/02/04 10:16:35 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN Bari + */ + +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" + +#include "FWCore/PluginManager/interface/PluginFactory.h" + +EDM_REGISTER_PLUGINFACTORY(ME0RecHitAlgoFactory,"ME0RecHitAlgoFactory"); + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc new file mode 100644 index 0000000000000..cac6c09f2ce3b --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc @@ -0,0 +1,42 @@ +/* +* See header file for a description of this class. +* +* $Date: 2014/02/04 10:16:35 $ +* $Revision: 1.1 $ +* \author M. Maggi -- INFN Bari +*/ + + + +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + + +ME0RecHitBaseAlgo::ME0RecHitBaseAlgo(const edm::ParameterSet& config) { +} + +ME0RecHitBaseAlgo::~ME0RecHitBaseAlgo(){} + + +// Build all hits in the range associated to the layerId, at the 1st step. +edm::OwnVector ME0RecHitBaseAlgo::reconstruct(const ME0DetId& me0Id, +const ME0DigiPreRecoCollection::Range& digiRange){ + edm::OwnVector result; + + for (ME0DigiPreRecoCollection::const_iterator digi = digiRange.first; + digi != digiRange.second;digi++) { + + LocalError tmpErr; + LocalPoint point; + // Call the compute method + bool OK = this->compute(*digi, point, tmpErr); + if (!OK) continue; + + ME0RecHit* recHit = new ME0RecHit(me0Id,digi->tof(),point,tmpErr); + + if (std::abs(digi->pdgid()) == 13) result.push_back(recHit); + } + return result; +} diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc new file mode 100644 index 0000000000000..6207502182bc4 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc @@ -0,0 +1,104 @@ +/** \file + * + * $Date: 2013/04/24 17:16:35 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN Bari +*/ + +#include "ME0RecHitProducer.h" + + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" + +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" + +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" + +#include + + +using namespace edm; +using namespace std; + + +ME0RecHitProducer::ME0RecHitProducer(const ParameterSet& config){ + + produces(); + theME0DigiLabel = config.getParameter("me0DigiLabel"); + + // Get the concrete reconstruction algo from the factory + + string theAlgoName = config.getParameter("recAlgo"); + theAlgo = ME0RecHitAlgoFactory::get()->create(theAlgoName, + config.getParameter("recAlgoConfig")); +} + + +ME0RecHitProducer::~ME0RecHitProducer(){ + delete theAlgo; +} + + + +void ME0RecHitProducer::beginRun(const edm::Run& r, const edm::EventSetup& setup){ +} + + + +void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { + + // Get the ME0 Geometry + ESHandle me0Geom; + setup.get().get(me0Geom); + + // Get the digis from the event + + Handle digis; + event.getByLabel(theME0DigiLabel,digis); + + // Pass the EventSetup to the algo + + theAlgo->setES(setup); + + // Create the pointer to the collection which will store the rechits + + auto_ptr recHitCollection(new ME0RecHitCollection()); + + // Iterate through all digi collections ordered by LayerId + + ME0DigiPreRecoCollection::DigiRangeIterator me0dgIt; + for (me0dgIt = digis->begin(); me0dgIt != digis->end(); + ++me0dgIt){ + + // The layerId + const ME0DetId& me0Id = (*me0dgIt).first; + + // Get the GeomDet from the setup + // const ME0EtaPartition* roll = me0Geom->etaPartition(me0Id); + + // Get the iterators over the digis associated with this LayerId + const ME0DigiPreRecoCollection::Range& range = (*me0dgIt).second; + + // Call the reconstruction algorithm + + OwnVector recHits = + theAlgo->reconstruct(me0Id, range); + + if(recHits.size() > 0) //FIXME: is it really needed? + recHitCollection->put(me0Id, recHits.begin(), recHits.end()); + } + + event.put(recHitCollection); + +} + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h new file mode 100644 index 0000000000000..5116567e05b32 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h @@ -0,0 +1,61 @@ +#ifndef RecoLocalMuon_ME0RecHitProducer_h +#define RecoLocalMuon_ME0RecHitProducer_h + +/** \class ME0RecHitProducer + * Module for ME0RecHit production. + * + * $Date: 2014/02/04 10:53:23 $ + * $Revision: 1.1 $ + * \author M. Maggim -- INFN Bari + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" + + + +namespace edm { + class ParameterSet; + class Event; + class EventSetup; +} + +class ME0RecHitBaseAlgo; + +class ME0RecHitProducer : public edm::EDProducer { + +public: + /// Constructor + ME0RecHitProducer(const edm::ParameterSet& config); + + /// Destructor + virtual ~ME0RecHitProducer(); + + // Method that access the EventSetup for each run + virtual void beginRun(const edm::Run&, const edm::EventSetup& ) override; + + /// The method which produces the rechits + virtual void produce(edm::Event& event, const edm::EventSetup& setup) override; + +private: + + // The label to be used to retrieve ME0 digis from the event + edm::InputTag theME0DigiLabel; + + // The reconstruction algorithm + ME0RecHitBaseAlgo *theAlgo; + // static std::string theAlgoName; +}; + +#endif + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc new file mode 100644 index 0000000000000..98cb31a4d03db --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc @@ -0,0 +1,55 @@ +/* + * See header file for a description of this class. + * + * $Date: 2014/02/04 10:16:35 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN + */ + +#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Utilities/interface/Exception.h" + + +ME0RecHitStandardAlgo::ME0RecHitStandardAlgo(const edm::ParameterSet& config) : + ME0RecHitBaseAlgo(config) +{ +} + +ME0RecHitStandardAlgo::~ME0RecHitStandardAlgo() +{ +} + +void ME0RecHitStandardAlgo::setES(const edm::EventSetup& setup) +{ +} + +// First Step +bool ME0RecHitStandardAlgo::compute(const ME0DigiPreReco& digi, + LocalPoint& Point, + LocalError& error) const +{ + LocalPoint loctemp2(digi.x(),digi.y(),0.); + Point = loctemp2; + LocalError loerr2(digi.ex()*digi.ex(),digi.corr()*digi.ex()*digi.ey(),digi.ey()*digi.ey()); + error = loerr2; + return true; +} + + +bool ME0RecHitStandardAlgo::compute(const ME0DigiPreReco& digi, + const float& angle, + const GlobalPoint& globPos, + LocalPoint& Point, + LocalError& error) const +{ + + // Glob Pos and angle not used so far... + if (globPos.z()<0){ } // Fake use to avoid warnings + if (angle<0.){ } // Fake use to avoid warnings + this->compute(digi,Point,error); + return true; +} + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h new file mode 100644 index 0000000000000..75cb6429f551d --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h @@ -0,0 +1,40 @@ +#ifndef RecoLocalMuon_ME0RecHitStandardAlgo_H +#define RecoLocalMuon_ME0RecHitStandardAlgo_H + +/** \class ME0RecHitStandardAlgo + * Concrete implementation of ME0RecHitBaseAlgo. + * + * $Date: 2014/02/04 10:16:36 $ + * $Revision: 1.1 $ + * \author M. Maggi -- INFN Bari + */ +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" + +class ME0RecHitStandardAlgo : public ME0RecHitBaseAlgo { + public: + /// Constructor + ME0RecHitStandardAlgo(const edm::ParameterSet& config); + + /// Destructor + virtual ~ME0RecHitStandardAlgo(); + + // Operations + + /// Pass the Event Setup to the algo at each event + virtual void setES(const edm::EventSetup& setup); + + + virtual bool compute(const ME0DigiPreReco& digi, + LocalPoint& point, + LocalError& error) const; + + + virtual bool compute(const ME0DigiPreReco& digi, + const float& angle, + const GlobalPoint& globPos, + LocalPoint& point, + LocalError& error) const; +}; +#endif + + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc new file mode 100644 index 0000000000000..1c3d7bc11d38d --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc @@ -0,0 +1,556 @@ +/** + * \file ME0SegAlgoMM.cc + * + * \authors: Marcello Maggi + */ + +#include "ME0SegAlgoMM.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CommonTools/Statistics/interface/ChiSquaredProbability.h" + +#include +#include +#include +#include + +/* Constructor + * + */ +ME0SegAlgoMM::ME0SegAlgoMM(const edm::ParameterSet& ps) : ME0SegmentAlgorithm(ps), myName("ME0SegAlgoMM") { + + debug = ps.getUntrackedParameter("ME0Debug"); + minHitsPerSegment = ps.getParameter("minHitsPerSegment"); + preClustering = ps.getParameter("preClustering"); + dXclusBoxMax = ps.getParameter("dXclusBoxMax"); + dYclusBoxMax = ps.getParameter("dYclusBoxMax"); + preClustering_useChaining = ps.getParameter("preClusteringUseChaining"); + dPhiChainBoxMax = ps.getParameter("dPhiChainBoxMax"); + dEtaChainBoxMax = ps.getParameter("dEtaChainBoxMax"); + maxRecHitsInCluster = ps.getParameter("maxRecHitsInCluster"); +} + +/* Destructor + * + */ +ME0SegAlgoMM::~ME0SegAlgoMM() { +} + + +std::vector ME0SegAlgoMM::run(ME0Ensamble ensamble, const EnsambleHitContainer& rechits) { + + theEnsamble = ensamble; + // ME0DetId enId(ensambleId); + // LogTrace("ME0SegAlgoMM") << "[ME0SegAlgoMM::run] build segments in chamber " << enId; + + // pre-cluster rechits and loop over all sub clusters seperately + std::vector segments_temp; + std::vector segments; + ProtoSegments rechits_clusters; // this is a collection of groups of rechits + + if(preClustering) { + // run a pre-clusterer on the given rechits to split obviously separated segment seeds: + if(preClustering_useChaining){ + // it uses X,Y,Z information; there are no configurable parameters used; + // the X, Y, Z "cuts" are just (much) wider than the LCT readout ones + // (which are actually not step functions); this new code could accomodate + // the clusterHits one below but we leave it for security and backward + // comparison reasons + rechits_clusters = this->chainHits( rechits ); + } + else{ + // it uses X,Y information + configurable parameters + rechits_clusters = this->clusterHits(rechits ); + } + // loop over the found clusters: + for(auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits ) { + // clear the buffer for the subset of segments: + segments_temp.clear(); + // build the subset of segments: + segments_temp = this->buildSegments( (*sub_rechits) ); + // add the found subset of segments to the collection of all segments in this chamber: + segments.insert( segments.end(), segments_temp.begin(), segments_temp.end() ); + } + + + return segments; + } + else { + segments = this->buildSegments(rechits); + return segments; + } +} + + +// ********************************************************************; +ME0SegAlgoMM::ProtoSegments +ME0SegAlgoMM::clusterHits(const EnsambleHitContainer & rechits) { + + ProtoSegments rechits_clusters; // this is a collection of groups of rechits + // const float dXclus_box_cut = 4.; // seems to work reasonably 070116 + // const float dYclus_box_cut = 8.; // seems to work reasonably 070116 + + float dXclus_box = 0.0; + float dYclus_box = 0.0; + + EnsambleHitContainer temp; + ProtoSegments seeds; + + std::vector running_meanX; + std::vector running_meanY; + + std::vector seed_minX; + std::vector seed_maxX; + std::vector seed_minY; + std::vector seed_maxY; + + // split rechits into subvectors and return vector of vectors: + // Loop over rechits + // Create one seed per hit + for(unsigned int i = 0; i < rechits.size(); ++i) { + temp.clear(); + temp.push_back(rechits[i]); + seeds.push_back(temp); + + // First added hit in seed defines the mean to which the next hit is compared + // for this seed. + + running_meanX.push_back( rechits[i]->localPosition().x() ); + running_meanY.push_back( rechits[i]->localPosition().y() ); + + // set min/max X and Y for box containing the hits in the precluster: + seed_minX.push_back( rechits[i]->localPosition().x() ); + seed_maxX.push_back( rechits[i]->localPosition().x() ); + seed_minY.push_back( rechits[i]->localPosition().y() ); + seed_maxY.push_back( rechits[i]->localPosition().y() ); + } + + // merge clusters that are too close + // measure distance between final "running mean" + for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { + for(size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) { + if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) { + LogDebug("ME0Segment|ME0") << "ME0SegAlgoMM::clusterHits: Warning: Skipping used seeds, this should happen - inform developers!"; + // std::cout<<"We should never see this line now!!!"< running_meanX[MMM] ) dXclus_box = seed_minX[NNN] - seed_maxX[MMM]; + else dXclus_box = seed_minX[MMM] - seed_maxX[NNN]; + if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM]; + else dYclus_box = seed_minY[MMM] - seed_maxY[NNN]; + + + if( dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax ) { + // merge clusters! + // merge by adding seed NNN to seed MMM and erasing seed NNN + + // calculate running mean for the merged seed: + running_meanX[MMM] = (running_meanX[NNN]*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].size()+seeds[MMM].size()); + running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].size()+seeds[MMM].size()); + + // update min/max X and Y for box containing the hits in the merged cluster: + if ( seed_minX[NNN] <= seed_minX[MMM] ) seed_minX[MMM] = seed_minX[NNN]; + if ( seed_maxX[NNN] > seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN]; + if ( seed_minY[NNN] <= seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN]; + if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN]; + + // add seed NNN to MMM (lower to larger number) + seeds[MMM].insert(seeds[MMM].end(),seeds[NNN].begin(),seeds[NNN].end()); + + // mark seed NNN as used (at the moment just set running mean to 999999.) + running_meanX[NNN] = 999999.; + running_meanY[NNN] = 999999.; + // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to + // next seed (NNN+1) + break; + } + } + } + + // hand over the final seeds to the output + // would be more elegant if we could do the above step with + // erasing the merged ones, rather than the + for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { + if(running_meanX[NNN] == 999999.) continue; //skip seeds that have been marked as used up in merging + rechits_clusters.push_back(seeds[NNN]); + } + + return rechits_clusters; +} + + +ME0SegAlgoMM::ProtoSegments +ME0SegAlgoMM::chainHits(const EnsambleHitContainer & rechits) { + + ProtoSegments rechits_chains; + EnsambleHitContainer temp; + ProtoSegments seeds; + + std::vector usedCluster; + + // split rechits into subvectors and return vector of vectors: + // Loop over rechits + // Create one seed per hit + for(unsigned int i = 0; i < rechits.size(); ++i) { + temp.clear(); + temp.push_back(rechits[i]); + seeds.push_back(temp); + usedCluster.push_back(false); + } + + // merge chains that are too close ("touch" each other) + for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { + for(size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) { + if(usedCluster[MMM] || usedCluster[NNN]){ + continue; + } + // all is in the way we define "good"; + // try not to "cluster" the hits but to "chain" them; + // it does the clustering but also does a better job + // for inclined tracks (not clustering them together; + // crossed tracks would be still clustered together) + // 22.12.09: In fact it is not much more different + // than the "clustering", we just introduce another + // variable in the game - Z. And it makes sense + // to re-introduce Y (or actually wire group mumber) + // in a similar way as for the strip number - see + // the code below. + bool goodToMerge = isGoodToMerge(seeds[NNN], seeds[MMM]); + if(goodToMerge){ + // merge chains! + // merge by adding seed NNN to seed MMM and erasing seed NNN + + // add seed NNN to MMM (lower to larger number) + seeds[MMM].insert(seeds[MMM].end(),seeds[NNN].begin(),seeds[NNN].end()); + + // mark seed NNN as used + usedCluster[NNN] = true; + // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to + // next seed (NNN+1) + break; + } + + } + } + + // hand over the final seeds to the output + // would be more elegant if we could do the above step with + // erasing the merged ones, rather than the + + for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { + if(usedCluster[NNN]) continue; //skip seeds that have been marked as used up in merging + rechits_chains.push_back(seeds[NNN]); + } + + //*************************************************************** + + return rechits_chains; +} + +bool ME0SegAlgoMM::isGoodToMerge(EnsambleHitContainer & newChain, EnsambleHitContainer & oldChain) { + for(size_t iRH_new = 0;iRH_newme0Id().layer(); + float phi_new = theEnsamble.first->toGlobal(newChain[iRH_new]->localPosition()).phi(); + float eta_new = theEnsamble.first->toGlobal(newChain[iRH_new]->localPosition()).eta(); + for(size_t iRH_old = 0;iRH_oldme0Id().layer(); + float phi_old = theEnsamble.first->toGlobal(oldChain[iRH_old]->localPosition()).phi(); + float eta_old = theEnsamble.first->toGlobal(oldChain[iRH_old]->localPosition()).eta(); + // to be chained, two hits need to be in neighbouring layers... + // or better allow few missing layers (upto 3 to avoid inefficiencies); + // however we'll not make an angle correction because it + // worsen the situation in some of the "regular" cases + // (not making the correction means that the conditions for + // forming a cluster are different if we have missing layers - + // this could affect events at the boundaries ) + //to be chained, two hits need also to be "close" in phi and eta + bool layerRequirementOK = abs(layer_new-layer_old)<5; + bool phiRequirementOK = fabs(phi_old-phi_new) < dPhiChainBoxMax; + bool etaRequirementOK = fabs(eta_old-eta_new) < dEtaChainBoxMax; + + if(layerRequirementOK && phiRequirementOK && etaRequirementOK){ + return true; + } + } + } + return false; +} + + + + + +std::vector ME0SegAlgoMM::buildSegments(const EnsambleHitContainer& rechits) { + std::vector me0segs; + + proto_segment.clear(); + // select hits from the ensemble and sort it + for (auto rh=rechits.begin(); rh!=rechits.end();rh++){ + proto_segment.push_back(*rh); + } + if (proto_segment.size() < minHitsPerSegment){ + return me0segs; + } + // The actual fit on all hit of the protosegments; + this->doSlopesAndChi2(); + this->fillLocalDirection(); + AlgebraicSymMatrix protoErrors = this->calculateError(); + this->flipErrors( protoErrors ); + ME0Segment tmp(proto_segment,protoIntercept, protoDirection, protoErrors,protoChi2); + me0segs.push_back(tmp); + return me0segs; +} + +//Method doSlopesAndChi2 +// fitSlopes() and fillChiSquared() are always called one after the other +// In fact the code is duplicated in the two functions (as we need 2 loops) - +// it is much better to fix that at some point +void ME0SegAlgoMM::doSlopesAndChi2(){ + this->fitSlopes(); + this->fillChiSquared(); +} +/* Method fitSlopes + * + * Perform a Least Square Fit on a segment as per SK algo + * + */ +void ME0SegAlgoMM::fitSlopes() { + + CLHEP::HepMatrix M(4,4,0); + CLHEP::HepVector B(4,0); + // In absence of a geometrical construction of the ME0Ensamble take layer 1 + const ME0EtaPartition* ens = theEnsamble.first; + + for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { + const ME0RecHit& hit = (**ih); + const ME0EtaPartition* roll = theEnsamble.second[hit.me0Id()]; + GlobalPoint gp = roll->toGlobal(hit.localPosition()); + // Locat w,r,t, to the first layer; + LocalPoint lp = ens->toLocal(gp); + // ptc: Local position of hit w.r.t. chamber + double u = lp.x(); + double v = lp.y(); + double z = lp.z(); + // ptc: Covariance matrix of local errors + CLHEP::HepMatrix IC(2,2); + IC(1,1) = hit.localPositionError().xx(); + IC(1,2) = hit.localPositionError().xy(); + IC(2,2) = hit.localPositionError().yy(); + IC(2,1) = IC(1,2); // since Cov is symmetric + // ptc: Invert covariance matrix (and trap if it fails!) + int ierr = 0; + IC.invert(ierr); // inverts in place + if (ierr != 0) { + LogDebug("ME0Segment|ME0") << "ME0Segment::fitSlopes: failed to invert covariance matrix=\n" << IC; + // std::cout<< "ME0Segment::fitSlopes: failed to invert covariance matrix=\n" << IC << "\n"<toGlobal(hit.localPosition()); + // Locat w,r,t, to the first layer; + LocalPoint lp = ens->toLocal(gp); + // ptc: Local position of hit w.r.t. chamber + double u = lp.x(); + double v = lp.y(); + double z = lp.z(); + + double du = protoIntercept.x() + protoSlope_u * z - u; + double dv = protoIntercept.y() + protoSlope_v * z - v; + + CLHEP::HepMatrix IC(2,2); + IC(1,1) = hit.localPositionError().xx(); + // IC(1,1) = hit.localPositionError().xx(); + IC(1,2) = hit.localPositionError().xy(); + IC(2,2) = hit.localPositionError().yy(); + IC(2,1) = IC(1,2); + + + // Invert covariance matrix + int ierr = 0; + IC.invert(ierr); + if (ierr != 0) { + LogDebug("ME0Segment|ME0") << "ME0Segment::fillChiSquared: failed to invert covariance matrix=\n" << IC; + // std::cout << "ME0Segment::fillChiSquared: failed to invert covariance matrix=\n" << IC << "\n"; + + } + + chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2); + } + + protoChi2 = chsq; + protoNDF = 2.*proto_segment.size() - 4; +} +/* fillLocalDirection + * + */ +void ME0SegAlgoMM::fillLocalDirection() { + // Always enforce direction of segment to point from IP outwards + // (Incorrect for particles not coming from IP, of course.) + + double dxdz = protoSlope_u; + double dydz = protoSlope_v; + double dz = 1./sqrt(1. + dxdz*dxdz + dydz*dydz); + double dx = dz*dxdz; + double dy = dz*dydz; + LocalVector localDir(dx,dy,dz); + + // localDir may need sign flip to ensure it points outward from IP + // ptc: Examine its direction and origin in global z: to point outward + // the localDir should always have same sign as global z... + const ME0EtaPartition* ens = theEnsamble.first; + + double globalZpos = ( ens->toGlobal( protoIntercept ) ).z(); + double globalZdir = ( ens->toGlobal( localDir ) ).z(); + double directionSign = globalZpos * globalZdir; + protoDirection = (directionSign * localDir).unit(); +} + +/* weightMatrix + * + */ +AlgebraicSymMatrix ME0SegAlgoMM::weightMatrix() { + + std::vector::const_iterator it; + int nhits = proto_segment.size(); + AlgebraicSymMatrix matrix(2*nhits, 0); + int row = 0; + + for (it = proto_segment.begin(); it != proto_segment.end(); ++it) { + + const ME0RecHit& hit = (**it); + ++row; + matrix(row, row) = protoChiUCorrection*hit.localPositionError().xx(); + matrix(row, row+1) = hit.localPositionError().xy(); + ++row; + matrix(row, row-1) = hit.localPositionError().xy(); + matrix(row, row) = hit.localPositionError().yy(); + } + int ierr; + matrix.invert(ierr); + return matrix; +} + + +/* derivativeMatrix + * + */ +CLHEP::HepMatrix ME0SegAlgoMM::derivativeMatrix(){ + + int nhits = proto_segment.size(); + CLHEP::HepMatrix matrix(2*nhits, 4); + int row = 0; + + const ME0EtaPartition* ens = theEnsamble.first; + + for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { + const ME0RecHit& hit = (**ih); + const ME0EtaPartition* roll = theEnsamble.second[hit.me0Id()]; + GlobalPoint gp = roll->toGlobal(hit.localPosition()); + // Locat w,r,t, to the first layer; + LocalPoint lp = ens->toLocal(gp); + + float z = lp.z(); + ++row; + matrix(row, 1) = 1.; + matrix(row, 3) = z; + ++row; + matrix(row, 2) = 1.; + matrix(row, 4) = z; + } + return matrix; +} + +/* calculateError*/ +AlgebraicSymMatrix ME0SegAlgoMM::calculateError(){ + + AlgebraicSymMatrix weights = this->weightMatrix(); + AlgebraicMatrix A = this->derivativeMatrix(); + + // (AT W A)^-1 + // from http://www.phys.ufl.edu/~avery/fitting.html, part I + int ierr; + AlgebraicSymMatrix result = weights.similarityT(A); + result.invert(ierr); + + // blithely assuming the inverting never fails... + return result; +} + +void ME0SegAlgoMM::flipErrors( AlgebraicSymMatrix& a ) { + + // The ME0Segment needs the error matrix re-arranged to match + // parameters in order (uz, vz, u0, v0) where uz, vz = slopes, u0, v0 = intercepts + + AlgebraicSymMatrix hold( a ); + + // errors on slopes into upper left + a(1,1) = hold(3,3); + a(1,2) = hold(3,4); + a(2,1) = hold(4,3); + a(2,2) = hold(4,4); + + // errors on positions into lower right + a(3,3) = hold(1,1); + a(3,4) = hold(1,2); + a(4,3) = hold(2,1); + a(4,4) = hold(2,2); + + // must also interchange off-diagonal elements of off-diagonal 2x2 submatrices + a(4,1) = hold(2,3); + a(3,2) = hold(1,4); + a(2,3) = hold(4,1); // = hold(1,4) + a(1,4) = hold(3,2); // = hold(2,3) +} + + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h new file mode 100644 index 0000000000000..ec7f4682bf230 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h @@ -0,0 +1,95 @@ +#ifndef GEMRecHit_ME0SegAlgoMM_h +#define GEMRecHit_ME0SegAlgoMM_h + +/** + * \class ME0SegAlgoMM + * + * This algorithm is very basic no attemp to deal with ambiguities , noise etc. + * The ME0 track segments is built out of the rechit's in a the 6 ME0 Layer denoted + * as the ME0 Ensabmle .
+ * + * \authors Marcello Maggi + * + */ + +#include +#include + +#include +#include + +class ME0SegAlgoMM : public ME0SegmentAlgorithm { + + +public: + + /// Typedefs + + typedef std::vector EnsambleHitContainer; + typedef std::vector ProtoSegments; + typedef std::deque BoolContainer; + + /// Constructor + explicit ME0SegAlgoMM(const edm::ParameterSet& ps); + /// Destructor + virtual ~ME0SegAlgoMM(); + + /** + * Build segments for all desired groups of hits + */ + std::vector run(ME0Ensamble ensamble, const EnsambleHitContainer& rechits); + +private: + /// Utility functions + + // Build groups of rechits that are separated in x and y to save time on the segment finding + ProtoSegments clusterHits(const EnsambleHitContainer & rechits); + + // Build groups of rechits that are separated in strip numbers and Z to save time on the segment finding + ProtoSegments chainHits(const EnsambleHitContainer & rechits); + + bool isGoodToMerge(EnsambleHitContainer & newChain, EnsambleHitContainer & oldChain); + + // Build track segments in this chamber (this is where the actual segment-building algorithm hides.) + std::vector buildSegments(const EnsambleHitContainer& rechits); + + void doSlopesAndChi2(); + void fitSlopes(); + void fillChiSquared(); + void fillLocalDirection(); + CLHEP::HepMatrix derivativeMatrix(void); + AlgebraicSymMatrix weightMatrix(void); + AlgebraicSymMatrix calculateError(void); + void flipErrors(AlgebraicSymMatrix& protoErrors); + + // Member variables + private: + const std::string myName; + + // input from .cfi file + private: + bool debug; + unsigned int minHitsPerSegment; + bool preClustering; + double dXclusBoxMax; + double dYclusBoxMax; + bool preClustering_useChaining; + double dPhiChainBoxMax; + double dEtaChainBoxMax; + int maxRecHitsInCluster; + + private: + EnsambleHitContainer proto_segment; + ME0Ensamble theEnsamble; + LocalPoint protoIntercept; + float protoSlope_u; + float protoSlope_v; + double protoChi2; + double protoNDF; + LocalVector protoDirection; + double protoChiUCorrection=1.0; //Hardcoded to 1.0, to fix noninvertibility of errors matrix + + std::vector e_Cxx; +}; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h new file mode 100644 index 0000000000000..a366f356db341 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h @@ -0,0 +1,40 @@ +#ifndef GEMRecHit_ME0SegmentAlgorithm_h +#define GEMRecHit_ME0SegmentAlgorithm_h + +/** \class ME0SegmentAlgo derived from CSC + * An abstract base class for algorithmic classes used to + * build segments in one ensemble of ME0 detector + * + * Implementation notes:
+ * For example, ME0SegmAlgoMM inherits from this class, + * + * $Date: 2014/02/04 15:41:46 $ + * $Revision: 1.1 $ + * \author Marcello Maggi + * + */ + +#include +#include +#include +#include +#include +#include + +class ME0SegmentAlgorithm { +public: + typedef std::pair >ME0Ensamble; + + /// Constructor + explicit ME0SegmentAlgorithm(const edm::ParameterSet&) {}; + /// Destructor + virtual ~ME0SegmentAlgorithm() {}; + + /** Run the algorithm = build the segments in this chamber + */ + virtual std::vector run(ME0Ensamble ensamble, const std::vector& rechits) = 0; + + private: +}; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc new file mode 100644 index 0000000000000..d1edd216f6f82 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +ME0SegmentBuilder::ME0SegmentBuilder(const edm::ParameterSet& ps) : geom_(0) { + + // Algo name + std::string algoName = ps.getParameter("algo_name"); + + LogDebug("ME0Segment|ME0")<< "ME0SegmentBuilder algorithm name: " << algoName; + + // SegAlgo parameter set + edm::ParameterSet segAlgoPSet = ps.getParameter("algo_pset"); + + // Ask factory to build this algorithm, giving it appropriate ParameterSet + algo = ME0SegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet); + +} +ME0SegmentBuilder::~ME0SegmentBuilder() { + delete algo; +} + +void ME0SegmentBuilder::build(const ME0RecHitCollection* recHits, ME0SegmentCollection& oc) { + + LogDebug("ME0Segment|ME0")<< "Total number of rechits in this event: " << recHits->size(); + + // Let's define the ensemble of ME0 devices having the same region, chambers number (phi), and eta partition + // and layer run from 1 to number of layer. This is not the definition of one chamber... and indeed segments + // could in principle run in different way... The concept of the DetLayer would be more appropriate... + + std::map > ensembleRH; + + // Loop on the ME0 rechit and select the different ME0 Ensemble + for(ME0RecHitCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); it2++) { + ME0DetId id(it2->me0Id().region(),1,it2->me0Id().chamber(),it2->me0Id().roll()); + std::vector pp = ensembleRH[id.rawId()]; + pp.push_back(it2->clone()); + ensembleRH[id.rawId()]=pp; + } + + for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) { + + std::vector me0RecHits; + std::map ens; + + const ME0EtaPartition* firstlayer = geom_->etaPartition(enIt->first); + for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); rechit++) { + me0RecHits.push_back(*rechit); + ens[(*rechit)->me0Id()]=geom_->etaPartition((*rechit)->me0Id()); + } + ME0SegmentAlgorithm::ME0Ensamble ensamble(std::pair >(firstlayer,ens)); + + LogDebug("ME0Segment|ME0") << "found " << me0RecHits.size() << " rechits in chamber " << *enIt; + + // given the chamber select the appropriate algo... and run it + std::vector segv = algo->run(ensamble, me0RecHits); + ME0DetId mid(enIt->first); + LogDebug("ME0Segment|ME0") << "found " << segv.size() << " segments in chamber " << mid; + + // Add the segments to master collection + oc.put(mid, segv.begin(), segv.end()); + } +} + +void ME0SegmentBuilder::setGeometry(const ME0Geometry* geom) { + geom_ = geom; +} + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h new file mode 100644 index 0000000000000..736ec22408248 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h @@ -0,0 +1,50 @@ +#ifndef GEMRecHit_ME0SegmentBuilder_h +#define GEMRecHit_ME0SegmentBuilder_h + +/** \class ME0SegmentBuilder derived by CSCSegmentBuilder + * Algorithm to build ME0Segment's from ME0RecHit collection + * by implementing a 'build' function required by ME0SegmentProducer. + * + * Implementation notes:
+ * Configured via the Producer's ParameterSet.
+ * Presume this might become an abstract base class one day.
+ * + * $Date: 2014/02/04 13:45:31 $ + * $Revision: 1.1 $ + * \author Marcello Maggi + * + */ + +#include +#include +#include +#include + +class ME0SegmentAlgorithm; + +class ME0SegmentBuilder { +public: + + /** Configure the algorithm via ctor. + * Receives ParameterSet percolated down from EDProducer + * which owns this Builder. + */ + explicit ME0SegmentBuilder(const edm::ParameterSet&); + /// Destructor + ~ME0SegmentBuilder(); + + /** Find rechits in each ensemble of 6 ME0 layers, build ME0Segment's , + * and fill into output collection. + */ + void build(const ME0RecHitCollection* rechits, ME0SegmentCollection& oc); + + /** Cache pointer to geometry _for current event_ + */ + void setGeometry(const ME0Geometry* g); + + private: + ME0SegmentAlgorithm* algo; + const ME0Geometry* geom_; +}; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc new file mode 100644 index 0000000000000..2558f39214937 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc @@ -0,0 +1,12 @@ +/** \file ME0SegmentBuilderPluginFactory.cc + * + * $Date: 2014/02/04 13:32:56 $ + * $Revision: 1.1 $ + * \author Marcello Maggi + * + */ + +#include + +EDM_REGISTER_PLUGINFACTORY(ME0SegmentBuilderPluginFactory,"ME0SegmentBuilderPluginFactory"); + diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h new file mode 100644 index 0000000000000..fdd433bbe840b --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h @@ -0,0 +1,18 @@ +#ifndef GEMRecHit_ME0SegmentBuilderPluginFactory_h +#define GEMRecHit_ME0SegmentBuilderPluginFactory_h + +/** \class ME0SegmentBuilderPluginFactory derived from CSC + * Plugin factory for concrete ME0SegmentBuilder algorithms + * + * $Date: 2014/02/04 12:01:11 $ + * $Revision: 1.1 $ + * \author Marcello Maggi + * + */ + +#include +#include + +typedef edmplugin::PluginFactory ME0SegmentBuilderPluginFactory; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc new file mode 100644 index 0000000000000..0f49adc1c0e1d --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc @@ -0,0 +1,56 @@ +/** \file ME0SegmentProducer.cc + * + */ + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +ME0SegmentProducer::ME0SegmentProducer(const edm::ParameterSet& pas) : iev(0) { + + inputObjectsTag = pas.getParameter("me0RecHitLabel"); + segmentBuilder_ = new ME0SegmentBuilder(pas); // pass on the PS + + // register what this produces + produces(); +} + +ME0SegmentProducer::~ME0SegmentProducer() { + + LogDebug("ME0Segment|ME0") << "deleting ME0SegmentBuilder after " << iev << " events w/csc data."; + delete segmentBuilder_; +} + +void ME0SegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) { + + LogDebug("ME0Segment|ME0") << "start producing segments for " << ++iev << "th event with csc data"; + + // find the geometry (& conditions?) for this event & cache it in the builder + edm::ESHandle me0g; + setup.get().get(me0g); + const ME0Geometry* mgeom = &*me0g; + segmentBuilder_->setGeometry(mgeom); + + + // get the collection of ME0RecHit + edm::Handle me0RecHits; + ev.getByLabel(inputObjectsTag, me0RecHits); + + // create empty collection of Segments + std::auto_ptr oc( new ME0SegmentCollection ); + + // fill the collection + segmentBuilder_->build(me0RecHits.product(), *oc); //@@ FILL oc + + // put collection in event + ev.put(oc); +} diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h new file mode 100644 index 0000000000000..2c2ebb51206a5 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h @@ -0,0 +1,35 @@ +#ifndef GEMRecHit_ME0SegmentProducer_h +#define GEMRecHit_ME0SegmentProducer_h + +/** \class ME0SegmentProducer derived by CSCSegmentProducer + * Produces a collection of ME0Segment's in endcap muon ME0s. + * + * $Date: 2014/02/03 23:48:11 $ + * $Revision: 1.1 $ + * \author Marcello Maggi + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +class ME0SegmentBuilder; + +class ME0SegmentProducer : public edm::EDProducer { +public: + /// Constructor + explicit ME0SegmentProducer(const edm::ParameterSet&); + /// Destructor + ~ME0SegmentProducer(); + /// Produce the ME0Segment collection + virtual void produce(edm::Event&, const edm::EventSetup&); + +private: + int iev; // events through + edm::InputTag inputObjectsTag; // input tag labelling rechits for input + ME0SegmentBuilder* segmentBuilder_; +}; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/SealModule.cc b/RecoLocalMuon/GEMRecHit/src/SealModule.cc index 86714befb9947..edbf4f177b2cf 100644 --- a/RecoLocalMuon/GEMRecHit/src/SealModule.cc +++ b/RecoLocalMuon/GEMRecHit/src/SealModule.cc @@ -1,16 +1,25 @@ #include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h" +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" #include "RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.h" -// #include "RecoLocalMuon/GEMRecHit/interface/GEMPointProducer.h" -// #include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAli.h" +DEFINE_FWK_MODULE(GEMRecHitProducer); -#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h" #include "RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h" +DEFINE_EDM_PLUGIN (GEMRecHitAlgoFactory, GEMRecHitStandardAlgo, "GEMRecHitStandardAlgo"); -DEFINE_FWK_MODULE(GEMRecHitProducer); -// DEFINE_FWK_MODULE(GEMPointProducer); -// DEFINE_FWK_MODULE(GEMRecHitAli); -DEFINE_EDM_PLUGIN (GEMRecHitAlgoFactory, GEMRecHitStandardAlgo, "GEMRecHitStandardAlgo"); +#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h" +DEFINE_FWK_MODULE(ME0RecHitProducer); + +#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h" +DEFINE_EDM_PLUGIN (ME0RecHitAlgoFactory, ME0RecHitStandardAlgo, "ME0RecHitStandardAlgo"); + +#include +#include + +#include +DEFINE_FWK_MODULE(ME0SegmentProducer); +DEFINE_EDM_PLUGIN(ME0SegmentBuilderPluginFactory, ME0SegAlgoMM, "ME0SegAlgoMM"); From 9bd93c1c2096a6341f8577c1862193e58f8bed35 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Wed, 6 May 2015 19:39:33 +0200 Subject: [PATCH 02/13] addings suggestions from pull request --- DataFormats/GEMRecHit/src/ME0Segment.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/DataFormats/GEMRecHit/src/ME0Segment.cc b/DataFormats/GEMRecHit/src/ME0Segment.cc index 9b5ed4eb10906..2e895148ed559 100644 --- a/DataFormats/GEMRecHit/src/ME0Segment.cc +++ b/DataFormats/GEMRecHit/src/ME0Segment.cc @@ -3,7 +3,7 @@ * $Date: 2014/02/04 12:41:33 $ * \author Marcello Maggi */ - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include #include @@ -60,8 +60,11 @@ AlgebraicVector ME0Segment::parameters() const { AlgebraicVector result(4); + if(theLocalDirection.z() != 0) + { result[0] = theLocalDirection.x()/theLocalDirection.z(); result[1] = theLocalDirection.y()/theLocalDirection.z(); + } result[2] = theOrigin.x(); result[3] = theOrigin.y(); @@ -89,13 +92,14 @@ float ME0Segment::time() const { const ME0RecHit *recHit = &(*itRH); averageTime+=recHit->tof(); } - averageTime=averageTime/(theME0RecHits.size()); + if(theME0RecHits.size() != 0)averageTime=averageTime/(theME0RecHits.size()); return averageTime; } // void ME0Segment::print() const { - std::cout << *this << std::endl; + LogDebug("ME0Segment") << *this; + } std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) { @@ -105,7 +109,7 @@ std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) { " dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx())<<","< Date: Wed, 6 May 2015 19:46:29 +0200 Subject: [PATCH 05/13] addings suggestions from pull request --- .../GEMRecHit/src/ME0RecHitBaseAlgo.cc | 8 +-- .../GEMRecHit/src/ME0RecHitProducer.cc | 2 - RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc | 53 +++++++++---------- RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h | 18 +++---- .../GEMRecHit/src/ME0SegmentAlgorithm.h | 4 +- .../GEMRecHit/src/ME0SegmentBuilder.cc | 4 +- 6 files changed, 42 insertions(+), 47 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc index cac6c09f2ce3b..d064e810c2040 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitBaseAlgo.cc @@ -33,10 +33,12 @@ const ME0DigiPreRecoCollection::Range& digiRange){ // Call the compute method bool OK = this->compute(*digi, point, tmpErr); if (!OK) continue; + + if (std::abs(digi->pdgid()) == 13) { + ME0RecHit* recHit = new ME0RecHit(me0Id,digi->tof(),point,tmpErr); + result.push_back(recHit); + } - ME0RecHit* recHit = new ME0RecHit(me0Id,digi->tof(),point,tmpErr); - - if (std::abs(digi->pdgid()) == 13) result.push_back(recHit); } return result; } diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc index 6207502182bc4..4dc2c7fadd302 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc @@ -83,8 +83,6 @@ void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { // The layerId const ME0DetId& me0Id = (*me0dgIt).first; - // Get the GeomDet from the setup - // const ME0EtaPartition* roll = me0Geom->etaPartition(me0Id); // Get the iterators over the digis associated with this LayerId const ME0DigiPreRecoCollection::Range& range = (*me0dgIt).second; diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc index 1c3d7bc11d38d..0792f774c8b12 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc @@ -40,10 +40,10 @@ ME0SegAlgoMM::~ME0SegAlgoMM() { } -std::vector ME0SegAlgoMM::run(ME0Ensamble ensamble, const EnsambleHitContainer& rechits) { +std::vector ME0SegAlgoMM::run(ME0Ensemble ensemble, const EnsembleHitContainer& rechits) { - theEnsamble = ensamble; - // ME0DetId enId(ensambleId); + theEnsemble = ensemble; + // ME0DetId enId(ensembleId); // LogTrace("ME0SegAlgoMM") << "[ME0SegAlgoMM::run] build segments in chamber " << enId; // pre-cluster rechits and loop over all sub clusters seperately @@ -87,16 +87,14 @@ std::vector ME0SegAlgoMM::run(ME0Ensamble ensamble, const EnsambleHi // ********************************************************************; ME0SegAlgoMM::ProtoSegments -ME0SegAlgoMM::clusterHits(const EnsambleHitContainer & rechits) { +ME0SegAlgoMM::clusterHits(const EnsembleHitContainer & rechits) { ProtoSegments rechits_clusters; // this is a collection of groups of rechits - // const float dXclus_box_cut = 4.; // seems to work reasonably 070116 - // const float dYclus_box_cut = 8.; // seems to work reasonably 070116 float dXclus_box = 0.0; float dYclus_box = 0.0; - EnsambleHitContainer temp; + EnsembleHitContainer temp; ProtoSegments seeds; std::vector running_meanX; @@ -133,8 +131,7 @@ ME0SegAlgoMM::clusterHits(const EnsambleHitContainer & rechits) { for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { for(size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) { if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) { - LogDebug("ME0Segment|ME0") << "ME0SegAlgoMM::clusterHits: Warning: Skipping used seeds, this should happen - inform developers!"; - // std::cout<<"We should never see this line now!!!"< seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN]; - if ( seed_minY[NNN] <= seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN]; + if ( seed_minY[NNN] < seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN]; if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN]; // add seed NNN to MMM (lower to larger number) @@ -188,10 +185,10 @@ ME0SegAlgoMM::clusterHits(const EnsambleHitContainer & rechits) { ME0SegAlgoMM::ProtoSegments -ME0SegAlgoMM::chainHits(const EnsambleHitContainer & rechits) { +ME0SegAlgoMM::chainHits(const EnsembleHitContainer & rechits) { ProtoSegments rechits_chains; - EnsambleHitContainer temp; + EnsembleHitContainer temp; ProtoSegments seeds; std::vector usedCluster; @@ -255,15 +252,15 @@ ME0SegAlgoMM::chainHits(const EnsambleHitContainer & rechits) { return rechits_chains; } -bool ME0SegAlgoMM::isGoodToMerge(EnsambleHitContainer & newChain, EnsambleHitContainer & oldChain) { +bool ME0SegAlgoMM::isGoodToMerge(EnsembleHitContainer & newChain, EnsembleHitContainer & oldChain) { for(size_t iRH_new = 0;iRH_newme0Id().layer(); - float phi_new = theEnsamble.first->toGlobal(newChain[iRH_new]->localPosition()).phi(); - float eta_new = theEnsamble.first->toGlobal(newChain[iRH_new]->localPosition()).eta(); + float phi_new = theEnsemble.first->toGlobal(newChain[iRH_new]->localPosition()).phi(); + float eta_new = theEnsemble.first->toGlobal(newChain[iRH_new]->localPosition()).eta(); for(size_t iRH_old = 0;iRH_oldme0Id().layer(); - float phi_old = theEnsamble.first->toGlobal(oldChain[iRH_old]->localPosition()).phi(); - float eta_old = theEnsamble.first->toGlobal(oldChain[iRH_old]->localPosition()).eta(); + float phi_old = theEnsemble.first->toGlobal(oldChain[iRH_old]->localPosition()).phi(); + float eta_old = theEnsemble.first->toGlobal(oldChain[iRH_old]->localPosition()).eta(); // to be chained, two hits need to be in neighbouring layers... // or better allow few missing layers (upto 3 to avoid inefficiencies); // however we'll not make an angle correction because it @@ -288,7 +285,7 @@ bool ME0SegAlgoMM::isGoodToMerge(EnsambleHitContainer & newChain, EnsambleHitCon -std::vector ME0SegAlgoMM::buildSegments(const EnsambleHitContainer& rechits) { +std::vector ME0SegAlgoMM::buildSegments(const EnsembleHitContainer& rechits) { std::vector me0segs; proto_segment.clear(); @@ -326,12 +323,12 @@ void ME0SegAlgoMM::fitSlopes() { CLHEP::HepMatrix M(4,4,0); CLHEP::HepVector B(4,0); - // In absence of a geometrical construction of the ME0Ensamble take layer 1 - const ME0EtaPartition* ens = theEnsamble.first; + // In absence of a geometrical construction of the ME0Ensemble take layer 1 + const ME0EtaPartition* ens = theEnsemble.first; for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { const ME0RecHit& hit = (**ih); - const ME0EtaPartition* roll = theEnsamble.second[hit.me0Id()]; + const ME0EtaPartition* roll = theEnsemble.second[hit.me0Id()]; GlobalPoint gp = roll->toGlobal(hit.localPosition()); // Locat w,r,t, to the first layer; LocalPoint lp = ens->toLocal(gp); @@ -350,7 +347,6 @@ void ME0SegAlgoMM::fitSlopes() { IC.invert(ierr); // inverts in place if (ierr != 0) { LogDebug("ME0Segment|ME0") << "ME0Segment::fitSlopes: failed to invert covariance matrix=\n" << IC; - // std::cout<< "ME0Segment::fitSlopes: failed to invert covariance matrix=\n" << IC << "\n"<toGlobal(hit.localPosition()); // Locat w,r,t, to the first layer; LocalPoint lp = ens->toLocal(gp); @@ -421,7 +417,6 @@ void ME0SegAlgoMM::fillChiSquared() { IC.invert(ierr); if (ierr != 0) { LogDebug("ME0Segment|ME0") << "ME0Segment::fillChiSquared: failed to invert covariance matrix=\n" << IC; - // std::cout << "ME0Segment::fillChiSquared: failed to invert covariance matrix=\n" << IC << "\n"; } @@ -448,7 +443,7 @@ void ME0SegAlgoMM::fillLocalDirection() { // localDir may need sign flip to ensure it points outward from IP // ptc: Examine its direction and origin in global z: to point outward // the localDir should always have same sign as global z... - const ME0EtaPartition* ens = theEnsamble.first; + const ME0EtaPartition* ens = theEnsemble.first; double globalZpos = ( ens->toGlobal( protoIntercept ) ).z(); double globalZdir = ( ens->toGlobal( localDir ) ).z(); @@ -491,11 +486,11 @@ CLHEP::HepMatrix ME0SegAlgoMM::derivativeMatrix(){ CLHEP::HepMatrix matrix(2*nhits, 4); int row = 0; - const ME0EtaPartition* ens = theEnsamble.first; + const ME0EtaPartition* ens = theEnsemble.first; for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { const ME0RecHit& hit = (**ih); - const ME0EtaPartition* roll = theEnsamble.second[hit.me0Id()]; + const ME0EtaPartition* roll = theEnsemble.second[hit.me0Id()]; GlobalPoint gp = roll->toGlobal(hit.localPosition()); // Locat w,r,t, to the first layer; LocalPoint lp = ens->toLocal(gp); diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h index ec7f4682bf230..9a5fb9569c9f9 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h @@ -25,8 +25,8 @@ class ME0SegAlgoMM : public ME0SegmentAlgorithm { /// Typedefs - typedef std::vector EnsambleHitContainer; - typedef std::vector ProtoSegments; + typedef std::vector EnsembleHitContainer; + typedef std::vector ProtoSegments; typedef std::deque BoolContainer; /// Constructor @@ -37,21 +37,21 @@ class ME0SegAlgoMM : public ME0SegmentAlgorithm { /** * Build segments for all desired groups of hits */ - std::vector run(ME0Ensamble ensamble, const EnsambleHitContainer& rechits); + std::vector run(ME0Ensemble ensemble, const EnsembleHitContainer& rechits); private: /// Utility functions // Build groups of rechits that are separated in x and y to save time on the segment finding - ProtoSegments clusterHits(const EnsambleHitContainer & rechits); + ProtoSegments clusterHits(const EnsembleHitContainer & rechits); // Build groups of rechits that are separated in strip numbers and Z to save time on the segment finding - ProtoSegments chainHits(const EnsambleHitContainer & rechits); + ProtoSegments chainHits(const EnsembleHitContainer & rechits); - bool isGoodToMerge(EnsambleHitContainer & newChain, EnsambleHitContainer & oldChain); + bool isGoodToMerge(EnsembleHitContainer & newChain, EnsembleHitContainer & oldChain); // Build track segments in this chamber (this is where the actual segment-building algorithm hides.) - std::vector buildSegments(const EnsambleHitContainer& rechits); + std::vector buildSegments(const EnsembleHitContainer& rechits); void doSlopesAndChi2(); void fitSlopes(); @@ -79,8 +79,8 @@ class ME0SegAlgoMM : public ME0SegmentAlgorithm { int maxRecHitsInCluster; private: - EnsambleHitContainer proto_segment; - ME0Ensamble theEnsamble; + EnsembleHitContainer proto_segment; + ME0Ensemble theEnsemble; LocalPoint protoIntercept; float protoSlope_u; float protoSlope_v; diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h index a366f356db341..1baf9d3157915 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h @@ -23,7 +23,7 @@ class ME0SegmentAlgorithm { public: - typedef std::pair >ME0Ensamble; + typedef std::pair >ME0Ensemble; /// Constructor explicit ME0SegmentAlgorithm(const edm::ParameterSet&) {}; @@ -32,7 +32,7 @@ class ME0SegmentAlgorithm { /** Run the algorithm = build the segments in this chamber */ - virtual std::vector run(ME0Ensamble ensamble, const std::vector& rechits) = 0; + virtual std::vector run(ME0Ensemble ensemble, const std::vector& rechits) = 0; private: }; diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc index d1edd216f6f82..b80e3e0785b88 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc @@ -55,12 +55,12 @@ void ME0SegmentBuilder::build(const ME0RecHitCollection* recHits, ME0SegmentColl me0RecHits.push_back(*rechit); ens[(*rechit)->me0Id()]=geom_->etaPartition((*rechit)->me0Id()); } - ME0SegmentAlgorithm::ME0Ensamble ensamble(std::pair >(firstlayer,ens)); + ME0SegmentAlgorithm::ME0Ensemble ensemble(std::pair >(firstlayer,ens)); LogDebug("ME0Segment|ME0") << "found " << me0RecHits.size() << " rechits in chamber " << *enIt; // given the chamber select the appropriate algo... and run it - std::vector segv = algo->run(ensamble, me0RecHits); + std::vector segv = algo->run(ensemble, me0RecHits); ME0DetId mid(enIt->first); LogDebug("ME0Segment|ME0") << "found " << segv.size() << " segments in chamber " << mid; From ed7c47e949be782ec782b7d9d05f2449c8bba9c3 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Mon, 11 May 2015 19:54:27 +0200 Subject: [PATCH 06/13] keeping only ME0 recHit files for this pull request --- DataFormats/GEMRecHit/interface/ME0Segment.h | 85 ------------- .../interface/ME0SegmentCollection.h | 24 ---- DataFormats/GEMRecHit/src/ME0Segment.cc | 116 ------------------ DataFormats/GEMRecHit/src/classes.h | 6 - DataFormats/GEMRecHit/src/classes_def.xml | 12 -- 5 files changed, 243 deletions(-) delete mode 100644 DataFormats/GEMRecHit/interface/ME0Segment.h delete mode 100644 DataFormats/GEMRecHit/interface/ME0SegmentCollection.h delete mode 100644 DataFormats/GEMRecHit/src/ME0Segment.cc diff --git a/DataFormats/GEMRecHit/interface/ME0Segment.h b/DataFormats/GEMRecHit/interface/ME0Segment.h deleted file mode 100644 index c0014029131a9..0000000000000 --- a/DataFormats/GEMRecHit/interface/ME0Segment.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef GEMRecHit_ME0Segment_h -#define GEMRecHit_ME0Segment_h - -/** \class ME0Segment derived by the CSC segment - * Describes a reconstructed track segment in the 6 layers of the ME0 system. - * This is 4-dimensional since it has an origin (x,y) and a direction (x,y) - * in the local coordinate system of the chamber. - * - * $Date: 2014/02/04 12:41:32 $ - * \author Marcello Maggi - */ - -#include -#include - -#include - -class ME0DetId; - -class ME0Segment GCC11_FINAL : public RecSegment { - -public: - - /// Default constructor - ME0Segment() : theChi2(0.){} - - /// Constructor - ME0Segment(const std::vector& proto_segment, LocalPoint origin, - LocalVector direction, AlgebraicSymMatrix errors, double chi2); - - /// Destructor - virtual ~ME0Segment(); - - //--- Base class interface - ME0Segment* clone() const { return new ME0Segment(*this); } - - LocalPoint localPosition() const { return theOrigin; } - LocalError localPositionError() const ; - - LocalVector localDirection() const { return theLocalDirection; } - LocalError localDirectionError() const ; - - /// Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y ) - AlgebraicVector parameters() const; - - /// Covariance matrix of parameters() - AlgebraicSymMatrix parametersError() const { return theCovMatrix; } - - /// The projection matrix relates the trajectory state parameters to the segment parameters(). - virtual AlgebraicMatrix projectionMatrix() const; - - virtual std::vector recHits() const; - - virtual std::vector recHits(); - - double chi2() const { return theChi2; }; - - virtual int dimension() const { return 4; } - - virtual int degreesOfFreedom() const { return 2*nRecHits() - 4;} - - //--- Extension of the interface - - const std::vector& specificRecHits() const { return theME0RecHits; } - - int nRecHits() const { return theME0RecHits.size(); } - - ME0DetId me0DetId() const { return geographicalId(); } - - float time() const; - - void print() const; - - private: - - std::vector theME0RecHits; - LocalPoint theOrigin; // in chamber frame - the GeomDet local coordinate system - LocalVector theLocalDirection; // in chamber frame - the GeomDet local coordinate system - AlgebraicSymMatrix theCovMatrix; // the covariance matrix - double theChi2; -}; - -std::ostream& operator<<(std::ostream& os, const ME0Segment& seg); - -#endif diff --git a/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h b/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h deleted file mode 100644 index 67c6db2a95350..0000000000000 --- a/DataFormats/GEMRecHit/interface/ME0SegmentCollection.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DataFormats_ME0SegmentCollection_H -#define DataFormats_ME0SegmentCollection_H - -/** \class ME0SegmentCollection - * - * The collection of ME0Segment's. See \ref CSCSegmentCollection.h for details from which is derived. - * - * $Date: 2014/02/04 10:08:15 $ - * \author Marcello Maggi - */ - -#include -#include - -#include -#include -#include - -typedef edm::RangeMap > ME0SegmentCollection; - -#include -typedef edm::Ref ME0SegmentRef; - -#endif diff --git a/DataFormats/GEMRecHit/src/ME0Segment.cc b/DataFormats/GEMRecHit/src/ME0Segment.cc deleted file mode 100644 index 2e895148ed559..0000000000000 --- a/DataFormats/GEMRecHit/src/ME0Segment.cc +++ /dev/null @@ -1,116 +0,0 @@ -/** \file ME0egment.cc - * - * $Date: 2014/02/04 12:41:33 $ - * \author Marcello Maggi - */ -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include -#include - -namespace { - // define a Super Layer Id from the first layer of the first rechits, and put to first layer - inline - DetId buildDetId(ME0DetId id) { - return ME0DetId(id.region(),1,id.chamber(),id.roll()); - } - -} - -ME0Segment::ME0Segment(const std::vector& proto_segment, LocalPoint origin, - LocalVector direction, AlgebraicSymMatrix errors, double chi2) : - RecSegment(buildDetId(proto_segment.front()->me0Id())), - theOrigin(origin), - theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2){ - - for(unsigned int i=0; i ME0Segment::recHits() const{ - std::vector pointersOfRecHits; - for (std::vector::const_iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) { - pointersOfRecHits.push_back(&(*irh)); - } - return pointersOfRecHits; -} - -std::vector ME0Segment::recHits() { - - std::vector pointersOfRecHits; - for (std::vector::iterator irh = theME0RecHits.begin(); irh!=theME0RecHits.end(); ++irh) { - pointersOfRecHits.push_back(&(*irh)); - } - return pointersOfRecHits; -} - -LocalError ME0Segment::localPositionError() const { - return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); -} - -LocalError ME0Segment::localDirectionError() const { - return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); -} - - -AlgebraicVector ME0Segment::parameters() const { - // For consistency with DT and CSC and what we require for the TrackingRecHit interface, - // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z) - - AlgebraicVector result(4); - - if(theLocalDirection.z() != 0) - { - result[0] = theLocalDirection.x()/theLocalDirection.z(); - result[1] = theLocalDirection.y()/theLocalDirection.z(); - } - result[2] = theOrigin.x(); - result[3] = theOrigin.y(); - - return result; -} - - -AlgebraicMatrix ME0Segment::projectionMatrix() const { - static AlgebraicMatrix theProjectionMatrix( 4, 5, 0); - static bool isInitialized = false; - if (!isInitialized) { - theProjectionMatrix[0][1] = 1; - theProjectionMatrix[1][2] = 1; - theProjectionMatrix[2][3] = 1; - theProjectionMatrix[3][4] = 1; - isInitialized=true; - } - return theProjectionMatrix; -} - -float ME0Segment::time() const { - float averageTime=0; - for (std::vector::const_iterator itRH = theME0RecHits.begin(); - itRH != theME0RecHits.end(); ++itRH) { - const ME0RecHit *recHit = &(*itRH); - averageTime+=recHit->tof(); - } - if(theME0RecHits.size() != 0)averageTime=averageTime/(theME0RecHits.size()); - return averageTime; -} - -// -void ME0Segment::print() const { - LogDebug("ME0Segment") << *this; - -} - -std::ostream& operator<<(std::ostream& os, const ME0Segment& seg) { - os << "ME0Segment: local pos = " << seg.localPosition() << - " posErr = (" << sqrt(seg.localPositionError().xx())<<","< mw; - ME0Segment ms; - ME0SegmentCollection seg; - edm::Wrapper dwc1; - ME0SegmentRef ref; }; } diff --git a/DataFormats/GEMRecHit/src/classes_def.xml b/DataFormats/GEMRecHit/src/classes_def.xml index 149387471fcce..a9786ec7c747c 100644 --- a/DataFormats/GEMRecHit/src/classes_def.xml +++ b/DataFormats/GEMRecHit/src/classes_def.xml @@ -24,15 +24,6 @@ - - - - - - - - - @@ -45,9 +36,6 @@ - - - From a7806f0d9cb31f65c8aedb05d58e189589081363 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Mon, 11 May 2015 20:06:27 +0200 Subject: [PATCH 07/13] keeping only ME0 recHit files for this pull request --- .../GEMRecHit/python/me0Segments_cfi.py | 17 - RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc | 551 ------------------ RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h | 95 --- .../GEMRecHit/src/ME0SegmentAlgorithm.h | 40 -- .../GEMRecHit/src/ME0SegmentBuilder.cc | 75 --- .../GEMRecHit/src/ME0SegmentBuilder.h | 50 -- .../src/ME0SegmentBuilderPluginFactory.cc | 12 - .../src/ME0SegmentBuilderPluginFactory.h | 18 - .../GEMRecHit/src/ME0SegmentProducer.cc | 56 -- .../GEMRecHit/src/ME0SegmentProducer.h | 35 -- RecoLocalMuon/GEMRecHit/src/SealModule.cc | 6 - 11 files changed, 955 deletions(-) delete mode 100644 RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc delete mode 100644 RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h diff --git a/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py b/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py deleted file mode 100644 index fc57fb970bc24..0000000000000 --- a/RecoLocalMuon/GEMRecHit/python/me0Segments_cfi.py +++ /dev/null @@ -1,17 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -me0Segments = cms.EDProducer("ME0SegmentProducer", - me0RecHitLabel = cms.InputTag("me0RecHits"), - algo_name = cms.string("ME0SegAlgoMM"), - algo_pset = cms.PSet( - ME0Debug = cms.untracked.bool(True), - minHitsPerSegment = cms.uint32(3), - preClustering = cms.bool(True), - dXclusBoxMax = cms.double(1.), - dYclusBoxMax = cms.double(5.), - preClusteringUseChaining = cms.bool(True), - dPhiChainBoxMax = cms.double(.02), - dEtaChainBoxMax = cms.double(.05), - maxRecHitsInCluster = cms.int32(6) - ) -) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc deleted file mode 100644 index 0792f774c8b12..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.cc +++ /dev/null @@ -1,551 +0,0 @@ -/** - * \file ME0SegAlgoMM.cc - * - * \authors: Marcello Maggi - */ - -#include "ME0SegAlgoMM.h" -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "CommonTools/Statistics/interface/ChiSquaredProbability.h" - -#include -#include -#include -#include - -/* Constructor - * - */ -ME0SegAlgoMM::ME0SegAlgoMM(const edm::ParameterSet& ps) : ME0SegmentAlgorithm(ps), myName("ME0SegAlgoMM") { - - debug = ps.getUntrackedParameter("ME0Debug"); - minHitsPerSegment = ps.getParameter("minHitsPerSegment"); - preClustering = ps.getParameter("preClustering"); - dXclusBoxMax = ps.getParameter("dXclusBoxMax"); - dYclusBoxMax = ps.getParameter("dYclusBoxMax"); - preClustering_useChaining = ps.getParameter("preClusteringUseChaining"); - dPhiChainBoxMax = ps.getParameter("dPhiChainBoxMax"); - dEtaChainBoxMax = ps.getParameter("dEtaChainBoxMax"); - maxRecHitsInCluster = ps.getParameter("maxRecHitsInCluster"); -} - -/* Destructor - * - */ -ME0SegAlgoMM::~ME0SegAlgoMM() { -} - - -std::vector ME0SegAlgoMM::run(ME0Ensemble ensemble, const EnsembleHitContainer& rechits) { - - theEnsemble = ensemble; - // ME0DetId enId(ensembleId); - // LogTrace("ME0SegAlgoMM") << "[ME0SegAlgoMM::run] build segments in chamber " << enId; - - // pre-cluster rechits and loop over all sub clusters seperately - std::vector segments_temp; - std::vector segments; - ProtoSegments rechits_clusters; // this is a collection of groups of rechits - - if(preClustering) { - // run a pre-clusterer on the given rechits to split obviously separated segment seeds: - if(preClustering_useChaining){ - // it uses X,Y,Z information; there are no configurable parameters used; - // the X, Y, Z "cuts" are just (much) wider than the LCT readout ones - // (which are actually not step functions); this new code could accomodate - // the clusterHits one below but we leave it for security and backward - // comparison reasons - rechits_clusters = this->chainHits( rechits ); - } - else{ - // it uses X,Y information + configurable parameters - rechits_clusters = this->clusterHits(rechits ); - } - // loop over the found clusters: - for(auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits ) { - // clear the buffer for the subset of segments: - segments_temp.clear(); - // build the subset of segments: - segments_temp = this->buildSegments( (*sub_rechits) ); - // add the found subset of segments to the collection of all segments in this chamber: - segments.insert( segments.end(), segments_temp.begin(), segments_temp.end() ); - } - - - return segments; - } - else { - segments = this->buildSegments(rechits); - return segments; - } -} - - -// ********************************************************************; -ME0SegAlgoMM::ProtoSegments -ME0SegAlgoMM::clusterHits(const EnsembleHitContainer & rechits) { - - ProtoSegments rechits_clusters; // this is a collection of groups of rechits - - float dXclus_box = 0.0; - float dYclus_box = 0.0; - - EnsembleHitContainer temp; - ProtoSegments seeds; - - std::vector running_meanX; - std::vector running_meanY; - - std::vector seed_minX; - std::vector seed_maxX; - std::vector seed_minY; - std::vector seed_maxY; - - // split rechits into subvectors and return vector of vectors: - // Loop over rechits - // Create one seed per hit - for(unsigned int i = 0; i < rechits.size(); ++i) { - temp.clear(); - temp.push_back(rechits[i]); - seeds.push_back(temp); - - // First added hit in seed defines the mean to which the next hit is compared - // for this seed. - - running_meanX.push_back( rechits[i]->localPosition().x() ); - running_meanY.push_back( rechits[i]->localPosition().y() ); - - // set min/max X and Y for box containing the hits in the precluster: - seed_minX.push_back( rechits[i]->localPosition().x() ); - seed_maxX.push_back( rechits[i]->localPosition().x() ); - seed_minY.push_back( rechits[i]->localPosition().y() ); - seed_maxY.push_back( rechits[i]->localPosition().y() ); - } - - // merge clusters that are too close - // measure distance between final "running mean" - for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { - for(size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) { - if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) { - LogDebug("ME0Segment|ME0") << "ME0SegAlgoMM::clusterHits: Warning: Skipping used seeds, this should not happen - inform developers!"; - continue; //skip seeds that have been used - } - - // calculate cut criteria for simple running mean distance cut: - //dXclus = fabs(running_meanX[NNN] - running_meanX[MMM]); - //dYclus = fabs(running_meanY[NNN] - running_meanY[MMM]); - // calculate minmal distance between precluster boxes containing the hits: - if ( running_meanX[NNN] > running_meanX[MMM] ) dXclus_box = seed_minX[NNN] - seed_maxX[MMM]; - else dXclus_box = seed_minX[MMM] - seed_maxX[NNN]; - if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM]; - else dYclus_box = seed_minY[MMM] - seed_maxY[NNN]; - - - if( dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax ) { - // merge clusters! - // merge by adding seed NNN to seed MMM and erasing seed NNN - - // calculate running mean for the merged seed: - running_meanX[MMM] = (running_meanX[NNN]*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].size()+seeds[MMM].size()); - running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].size()+seeds[MMM].size()); - - // update min/max X and Y for box containing the hits in the merged cluster: - if ( seed_minX[NNN] < seed_minX[MMM] ) seed_minX[MMM] = seed_minX[NNN]; - if ( seed_maxX[NNN] > seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN]; - if ( seed_minY[NNN] < seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN]; - if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN]; - - // add seed NNN to MMM (lower to larger number) - seeds[MMM].insert(seeds[MMM].end(),seeds[NNN].begin(),seeds[NNN].end()); - - // mark seed NNN as used (at the moment just set running mean to 999999.) - running_meanX[NNN] = 999999.; - running_meanY[NNN] = 999999.; - // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to - // next seed (NNN+1) - break; - } - } - } - - // hand over the final seeds to the output - // would be more elegant if we could do the above step with - // erasing the merged ones, rather than the - for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { - if(running_meanX[NNN] == 999999.) continue; //skip seeds that have been marked as used up in merging - rechits_clusters.push_back(seeds[NNN]); - } - - return rechits_clusters; -} - - -ME0SegAlgoMM::ProtoSegments -ME0SegAlgoMM::chainHits(const EnsembleHitContainer & rechits) { - - ProtoSegments rechits_chains; - EnsembleHitContainer temp; - ProtoSegments seeds; - - std::vector usedCluster; - - // split rechits into subvectors and return vector of vectors: - // Loop over rechits - // Create one seed per hit - for(unsigned int i = 0; i < rechits.size(); ++i) { - temp.clear(); - temp.push_back(rechits[i]); - seeds.push_back(temp); - usedCluster.push_back(false); - } - - // merge chains that are too close ("touch" each other) - for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { - for(size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) { - if(usedCluster[MMM] || usedCluster[NNN]){ - continue; - } - // all is in the way we define "good"; - // try not to "cluster" the hits but to "chain" them; - // it does the clustering but also does a better job - // for inclined tracks (not clustering them together; - // crossed tracks would be still clustered together) - // 22.12.09: In fact it is not much more different - // than the "clustering", we just introduce another - // variable in the game - Z. And it makes sense - // to re-introduce Y (or actually wire group mumber) - // in a similar way as for the strip number - see - // the code below. - bool goodToMerge = isGoodToMerge(seeds[NNN], seeds[MMM]); - if(goodToMerge){ - // merge chains! - // merge by adding seed NNN to seed MMM and erasing seed NNN - - // add seed NNN to MMM (lower to larger number) - seeds[MMM].insert(seeds[MMM].end(),seeds[NNN].begin(),seeds[NNN].end()); - - // mark seed NNN as used - usedCluster[NNN] = true; - // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to - // next seed (NNN+1) - break; - } - - } - } - - // hand over the final seeds to the output - // would be more elegant if we could do the above step with - // erasing the merged ones, rather than the - - for(size_t NNN = 0; NNN < seeds.size(); ++NNN) { - if(usedCluster[NNN]) continue; //skip seeds that have been marked as used up in merging - rechits_chains.push_back(seeds[NNN]); - } - - //*************************************************************** - - return rechits_chains; -} - -bool ME0SegAlgoMM::isGoodToMerge(EnsembleHitContainer & newChain, EnsembleHitContainer & oldChain) { - for(size_t iRH_new = 0;iRH_newme0Id().layer(); - float phi_new = theEnsemble.first->toGlobal(newChain[iRH_new]->localPosition()).phi(); - float eta_new = theEnsemble.first->toGlobal(newChain[iRH_new]->localPosition()).eta(); - for(size_t iRH_old = 0;iRH_oldme0Id().layer(); - float phi_old = theEnsemble.first->toGlobal(oldChain[iRH_old]->localPosition()).phi(); - float eta_old = theEnsemble.first->toGlobal(oldChain[iRH_old]->localPosition()).eta(); - // to be chained, two hits need to be in neighbouring layers... - // or better allow few missing layers (upto 3 to avoid inefficiencies); - // however we'll not make an angle correction because it - // worsen the situation in some of the "regular" cases - // (not making the correction means that the conditions for - // forming a cluster are different if we have missing layers - - // this could affect events at the boundaries ) - //to be chained, two hits need also to be "close" in phi and eta - bool layerRequirementOK = abs(layer_new-layer_old)<5; - bool phiRequirementOK = fabs(phi_old-phi_new) < dPhiChainBoxMax; - bool etaRequirementOK = fabs(eta_old-eta_new) < dEtaChainBoxMax; - - if(layerRequirementOK && phiRequirementOK && etaRequirementOK){ - return true; - } - } - } - return false; -} - - - - - -std::vector ME0SegAlgoMM::buildSegments(const EnsembleHitContainer& rechits) { - std::vector me0segs; - - proto_segment.clear(); - // select hits from the ensemble and sort it - for (auto rh=rechits.begin(); rh!=rechits.end();rh++){ - proto_segment.push_back(*rh); - } - if (proto_segment.size() < minHitsPerSegment){ - return me0segs; - } - // The actual fit on all hit of the protosegments; - this->doSlopesAndChi2(); - this->fillLocalDirection(); - AlgebraicSymMatrix protoErrors = this->calculateError(); - this->flipErrors( protoErrors ); - ME0Segment tmp(proto_segment,protoIntercept, protoDirection, protoErrors,protoChi2); - me0segs.push_back(tmp); - return me0segs; -} - -//Method doSlopesAndChi2 -// fitSlopes() and fillChiSquared() are always called one after the other -// In fact the code is duplicated in the two functions (as we need 2 loops) - -// it is much better to fix that at some point -void ME0SegAlgoMM::doSlopesAndChi2(){ - this->fitSlopes(); - this->fillChiSquared(); -} -/* Method fitSlopes - * - * Perform a Least Square Fit on a segment as per SK algo - * - */ -void ME0SegAlgoMM::fitSlopes() { - - CLHEP::HepMatrix M(4,4,0); - CLHEP::HepVector B(4,0); - // In absence of a geometrical construction of the ME0Ensemble take layer 1 - const ME0EtaPartition* ens = theEnsemble.first; - - for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { - const ME0RecHit& hit = (**ih); - const ME0EtaPartition* roll = theEnsemble.second[hit.me0Id()]; - GlobalPoint gp = roll->toGlobal(hit.localPosition()); - // Locat w,r,t, to the first layer; - LocalPoint lp = ens->toLocal(gp); - // ptc: Local position of hit w.r.t. chamber - double u = lp.x(); - double v = lp.y(); - double z = lp.z(); - // ptc: Covariance matrix of local errors - CLHEP::HepMatrix IC(2,2); - IC(1,1) = hit.localPositionError().xx(); - IC(1,2) = hit.localPositionError().xy(); - IC(2,2) = hit.localPositionError().yy(); - IC(2,1) = IC(1,2); // since Cov is symmetric - // ptc: Invert covariance matrix (and trap if it fails!) - int ierr = 0; - IC.invert(ierr); // inverts in place - if (ierr != 0) { - LogDebug("ME0Segment|ME0") << "ME0Segment::fitSlopes: failed to invert covariance matrix=\n" << IC; - } - - M(1,1) += IC(1,1); - M(1,2) += IC(1,2); - M(1,3) += IC(1,1) * z; - M(1,4) += IC(1,2) * z; - B(1) += u * IC(1,1) + v * IC(1,2); - - M(2,1) += IC(2,1); - M(2,2) += IC(2,2); - M(2,3) += IC(2,1) * z; - M(2,4) += IC(2,2) * z; - B(2) += u * IC(2,1) + v * IC(2,2); - - M(3,1) += IC(1,1) * z; - M(3,2) += IC(1,2) * z; - M(3,3) += IC(1,1) * z * z; - M(3,4) += IC(1,2) * z * z; - B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z; - - M(4,1) += IC(2,1) * z; - M(4,2) += IC(2,2) * z; - M(4,3) += IC(2,1) * z * z; - M(4,4) += IC(2,2) * z * z; - B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z; - } - CLHEP::HepVector p = solve(M, B); - - // Update member variables - // Note that origin has local z = 0 - protoIntercept = LocalPoint(p(1), p(2), 0.); - protoSlope_u = p(3); - protoSlope_v = p(4); -} -/* Method fillChiSquared - * - * Determine Chi^2 for the proto wire segment - * - */ -void ME0SegAlgoMM::fillChiSquared() { - - double chsq = 0.; - const ME0EtaPartition* ens = theEnsemble.first; - for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { - const ME0RecHit& hit = (**ih); - const ME0EtaPartition* roll = theEnsemble.second[hit.me0Id()]; - GlobalPoint gp = roll->toGlobal(hit.localPosition()); - // Locat w,r,t, to the first layer; - LocalPoint lp = ens->toLocal(gp); - // ptc: Local position of hit w.r.t. chamber - double u = lp.x(); - double v = lp.y(); - double z = lp.z(); - - double du = protoIntercept.x() + protoSlope_u * z - u; - double dv = protoIntercept.y() + protoSlope_v * z - v; - - CLHEP::HepMatrix IC(2,2); - IC(1,1) = hit.localPositionError().xx(); - // IC(1,1) = hit.localPositionError().xx(); - IC(1,2) = hit.localPositionError().xy(); - IC(2,2) = hit.localPositionError().yy(); - IC(2,1) = IC(1,2); - - - // Invert covariance matrix - int ierr = 0; - IC.invert(ierr); - if (ierr != 0) { - LogDebug("ME0Segment|ME0") << "ME0Segment::fillChiSquared: failed to invert covariance matrix=\n" << IC; - - } - - chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2); - } - - protoChi2 = chsq; - protoNDF = 2.*proto_segment.size() - 4; -} -/* fillLocalDirection - * - */ -void ME0SegAlgoMM::fillLocalDirection() { - // Always enforce direction of segment to point from IP outwards - // (Incorrect for particles not coming from IP, of course.) - - double dxdz = protoSlope_u; - double dydz = protoSlope_v; - double dz = 1./sqrt(1. + dxdz*dxdz + dydz*dydz); - double dx = dz*dxdz; - double dy = dz*dydz; - LocalVector localDir(dx,dy,dz); - - // localDir may need sign flip to ensure it points outward from IP - // ptc: Examine its direction and origin in global z: to point outward - // the localDir should always have same sign as global z... - const ME0EtaPartition* ens = theEnsemble.first; - - double globalZpos = ( ens->toGlobal( protoIntercept ) ).z(); - double globalZdir = ( ens->toGlobal( localDir ) ).z(); - double directionSign = globalZpos * globalZdir; - protoDirection = (directionSign * localDir).unit(); -} - -/* weightMatrix - * - */ -AlgebraicSymMatrix ME0SegAlgoMM::weightMatrix() { - - std::vector::const_iterator it; - int nhits = proto_segment.size(); - AlgebraicSymMatrix matrix(2*nhits, 0); - int row = 0; - - for (it = proto_segment.begin(); it != proto_segment.end(); ++it) { - - const ME0RecHit& hit = (**it); - ++row; - matrix(row, row) = protoChiUCorrection*hit.localPositionError().xx(); - matrix(row, row+1) = hit.localPositionError().xy(); - ++row; - matrix(row, row-1) = hit.localPositionError().xy(); - matrix(row, row) = hit.localPositionError().yy(); - } - int ierr; - matrix.invert(ierr); - return matrix; -} - - -/* derivativeMatrix - * - */ -CLHEP::HepMatrix ME0SegAlgoMM::derivativeMatrix(){ - - int nhits = proto_segment.size(); - CLHEP::HepMatrix matrix(2*nhits, 4); - int row = 0; - - const ME0EtaPartition* ens = theEnsemble.first; - - for (auto ih = proto_segment.begin(); ih != proto_segment.end(); ++ih) { - const ME0RecHit& hit = (**ih); - const ME0EtaPartition* roll = theEnsemble.second[hit.me0Id()]; - GlobalPoint gp = roll->toGlobal(hit.localPosition()); - // Locat w,r,t, to the first layer; - LocalPoint lp = ens->toLocal(gp); - - float z = lp.z(); - ++row; - matrix(row, 1) = 1.; - matrix(row, 3) = z; - ++row; - matrix(row, 2) = 1.; - matrix(row, 4) = z; - } - return matrix; -} - -/* calculateError*/ -AlgebraicSymMatrix ME0SegAlgoMM::calculateError(){ - - AlgebraicSymMatrix weights = this->weightMatrix(); - AlgebraicMatrix A = this->derivativeMatrix(); - - // (AT W A)^-1 - // from http://www.phys.ufl.edu/~avery/fitting.html, part I - int ierr; - AlgebraicSymMatrix result = weights.similarityT(A); - result.invert(ierr); - - // blithely assuming the inverting never fails... - return result; -} - -void ME0SegAlgoMM::flipErrors( AlgebraicSymMatrix& a ) { - - // The ME0Segment needs the error matrix re-arranged to match - // parameters in order (uz, vz, u0, v0) where uz, vz = slopes, u0, v0 = intercepts - - AlgebraicSymMatrix hold( a ); - - // errors on slopes into upper left - a(1,1) = hold(3,3); - a(1,2) = hold(3,4); - a(2,1) = hold(4,3); - a(2,2) = hold(4,4); - - // errors on positions into lower right - a(3,3) = hold(1,1); - a(3,4) = hold(1,2); - a(4,3) = hold(2,1); - a(4,4) = hold(2,2); - - // must also interchange off-diagonal elements of off-diagonal 2x2 submatrices - a(4,1) = hold(2,3); - a(3,2) = hold(1,4); - a(2,3) = hold(4,1); // = hold(1,4) - a(1,4) = hold(3,2); // = hold(2,3) -} - - diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h b/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h deleted file mode 100644 index 9a5fb9569c9f9..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegAlgoMM.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef GEMRecHit_ME0SegAlgoMM_h -#define GEMRecHit_ME0SegAlgoMM_h - -/** - * \class ME0SegAlgoMM - * - * This algorithm is very basic no attemp to deal with ambiguities , noise etc. - * The ME0 track segments is built out of the rechit's in a the 6 ME0 Layer denoted - * as the ME0 Ensabmle .
- * - * \authors Marcello Maggi - * - */ - -#include -#include - -#include -#include - -class ME0SegAlgoMM : public ME0SegmentAlgorithm { - - -public: - - /// Typedefs - - typedef std::vector EnsembleHitContainer; - typedef std::vector ProtoSegments; - typedef std::deque BoolContainer; - - /// Constructor - explicit ME0SegAlgoMM(const edm::ParameterSet& ps); - /// Destructor - virtual ~ME0SegAlgoMM(); - - /** - * Build segments for all desired groups of hits - */ - std::vector run(ME0Ensemble ensemble, const EnsembleHitContainer& rechits); - -private: - /// Utility functions - - // Build groups of rechits that are separated in x and y to save time on the segment finding - ProtoSegments clusterHits(const EnsembleHitContainer & rechits); - - // Build groups of rechits that are separated in strip numbers and Z to save time on the segment finding - ProtoSegments chainHits(const EnsembleHitContainer & rechits); - - bool isGoodToMerge(EnsembleHitContainer & newChain, EnsembleHitContainer & oldChain); - - // Build track segments in this chamber (this is where the actual segment-building algorithm hides.) - std::vector buildSegments(const EnsembleHitContainer& rechits); - - void doSlopesAndChi2(); - void fitSlopes(); - void fillChiSquared(); - void fillLocalDirection(); - CLHEP::HepMatrix derivativeMatrix(void); - AlgebraicSymMatrix weightMatrix(void); - AlgebraicSymMatrix calculateError(void); - void flipErrors(AlgebraicSymMatrix& protoErrors); - - // Member variables - private: - const std::string myName; - - // input from .cfi file - private: - bool debug; - unsigned int minHitsPerSegment; - bool preClustering; - double dXclusBoxMax; - double dYclusBoxMax; - bool preClustering_useChaining; - double dPhiChainBoxMax; - double dEtaChainBoxMax; - int maxRecHitsInCluster; - - private: - EnsembleHitContainer proto_segment; - ME0Ensemble theEnsemble; - LocalPoint protoIntercept; - float protoSlope_u; - float protoSlope_v; - double protoChi2; - double protoNDF; - LocalVector protoDirection; - double protoChiUCorrection=1.0; //Hardcoded to 1.0, to fix noninvertibility of errors matrix - - std::vector e_Cxx; -}; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h deleted file mode 100644 index 1baf9d3157915..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentAlgorithm.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef GEMRecHit_ME0SegmentAlgorithm_h -#define GEMRecHit_ME0SegmentAlgorithm_h - -/** \class ME0SegmentAlgo derived from CSC - * An abstract base class for algorithmic classes used to - * build segments in one ensemble of ME0 detector - * - * Implementation notes:
- * For example, ME0SegmAlgoMM inherits from this class, - * - * $Date: 2014/02/04 15:41:46 $ - * $Revision: 1.1 $ - * \author Marcello Maggi - * - */ - -#include -#include -#include -#include -#include -#include - -class ME0SegmentAlgorithm { -public: - typedef std::pair >ME0Ensemble; - - /// Constructor - explicit ME0SegmentAlgorithm(const edm::ParameterSet&) {}; - /// Destructor - virtual ~ME0SegmentAlgorithm() {}; - - /** Run the algorithm = build the segments in this chamber - */ - virtual std::vector run(ME0Ensemble ensemble, const std::vector& rechits) = 0; - - private: -}; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc deleted file mode 100644 index b80e3e0785b88..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -ME0SegmentBuilder::ME0SegmentBuilder(const edm::ParameterSet& ps) : geom_(0) { - - // Algo name - std::string algoName = ps.getParameter("algo_name"); - - LogDebug("ME0Segment|ME0")<< "ME0SegmentBuilder algorithm name: " << algoName; - - // SegAlgo parameter set - edm::ParameterSet segAlgoPSet = ps.getParameter("algo_pset"); - - // Ask factory to build this algorithm, giving it appropriate ParameterSet - algo = ME0SegmentBuilderPluginFactory::get()->create(algoName, segAlgoPSet); - -} -ME0SegmentBuilder::~ME0SegmentBuilder() { - delete algo; -} - -void ME0SegmentBuilder::build(const ME0RecHitCollection* recHits, ME0SegmentCollection& oc) { - - LogDebug("ME0Segment|ME0")<< "Total number of rechits in this event: " << recHits->size(); - - // Let's define the ensemble of ME0 devices having the same region, chambers number (phi), and eta partition - // and layer run from 1 to number of layer. This is not the definition of one chamber... and indeed segments - // could in principle run in different way... The concept of the DetLayer would be more appropriate... - - std::map > ensembleRH; - - // Loop on the ME0 rechit and select the different ME0 Ensemble - for(ME0RecHitCollection::const_iterator it2 = recHits->begin(); it2 != recHits->end(); it2++) { - ME0DetId id(it2->me0Id().region(),1,it2->me0Id().chamber(),it2->me0Id().roll()); - std::vector pp = ensembleRH[id.rawId()]; - pp.push_back(it2->clone()); - ensembleRH[id.rawId()]=pp; - } - - for(auto enIt=ensembleRH.begin(); enIt != ensembleRH.end(); ++enIt) { - - std::vector me0RecHits; - std::map ens; - - const ME0EtaPartition* firstlayer = geom_->etaPartition(enIt->first); - for(auto rechit = enIt->second.begin(); rechit != enIt->second.end(); rechit++) { - me0RecHits.push_back(*rechit); - ens[(*rechit)->me0Id()]=geom_->etaPartition((*rechit)->me0Id()); - } - ME0SegmentAlgorithm::ME0Ensemble ensemble(std::pair >(firstlayer,ens)); - - LogDebug("ME0Segment|ME0") << "found " << me0RecHits.size() << " rechits in chamber " << *enIt; - - // given the chamber select the appropriate algo... and run it - std::vector segv = algo->run(ensemble, me0RecHits); - ME0DetId mid(enIt->first); - LogDebug("ME0Segment|ME0") << "found " << segv.size() << " segments in chamber " << mid; - - // Add the segments to master collection - oc.put(mid, segv.begin(), segv.end()); - } -} - -void ME0SegmentBuilder::setGeometry(const ME0Geometry* geom) { - geom_ = geom; -} - diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h deleted file mode 100644 index 736ec22408248..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilder.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef GEMRecHit_ME0SegmentBuilder_h -#define GEMRecHit_ME0SegmentBuilder_h - -/** \class ME0SegmentBuilder derived by CSCSegmentBuilder - * Algorithm to build ME0Segment's from ME0RecHit collection - * by implementing a 'build' function required by ME0SegmentProducer. - * - * Implementation notes:
- * Configured via the Producer's ParameterSet.
- * Presume this might become an abstract base class one day.
- * - * $Date: 2014/02/04 13:45:31 $ - * $Revision: 1.1 $ - * \author Marcello Maggi - * - */ - -#include -#include -#include -#include - -class ME0SegmentAlgorithm; - -class ME0SegmentBuilder { -public: - - /** Configure the algorithm via ctor. - * Receives ParameterSet percolated down from EDProducer - * which owns this Builder. - */ - explicit ME0SegmentBuilder(const edm::ParameterSet&); - /// Destructor - ~ME0SegmentBuilder(); - - /** Find rechits in each ensemble of 6 ME0 layers, build ME0Segment's , - * and fill into output collection. - */ - void build(const ME0RecHitCollection* rechits, ME0SegmentCollection& oc); - - /** Cache pointer to geometry _for current event_ - */ - void setGeometry(const ME0Geometry* g); - - private: - ME0SegmentAlgorithm* algo; - const ME0Geometry* geom_; -}; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc deleted file mode 100644 index 2558f39214937..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.cc +++ /dev/null @@ -1,12 +0,0 @@ -/** \file ME0SegmentBuilderPluginFactory.cc - * - * $Date: 2014/02/04 13:32:56 $ - * $Revision: 1.1 $ - * \author Marcello Maggi - * - */ - -#include - -EDM_REGISTER_PLUGINFACTORY(ME0SegmentBuilderPluginFactory,"ME0SegmentBuilderPluginFactory"); - diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h deleted file mode 100644 index fdd433bbe840b..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentBuilderPluginFactory.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef GEMRecHit_ME0SegmentBuilderPluginFactory_h -#define GEMRecHit_ME0SegmentBuilderPluginFactory_h - -/** \class ME0SegmentBuilderPluginFactory derived from CSC - * Plugin factory for concrete ME0SegmentBuilder algorithms - * - * $Date: 2014/02/04 12:01:11 $ - * $Revision: 1.1 $ - * \author Marcello Maggi - * - */ - -#include -#include - -typedef edmplugin::PluginFactory ME0SegmentBuilderPluginFactory; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc deleted file mode 100644 index 0f49adc1c0e1d..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.cc +++ /dev/null @@ -1,56 +0,0 @@ -/** \file ME0SegmentProducer.cc - * - */ - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -ME0SegmentProducer::ME0SegmentProducer(const edm::ParameterSet& pas) : iev(0) { - - inputObjectsTag = pas.getParameter("me0RecHitLabel"); - segmentBuilder_ = new ME0SegmentBuilder(pas); // pass on the PS - - // register what this produces - produces(); -} - -ME0SegmentProducer::~ME0SegmentProducer() { - - LogDebug("ME0Segment|ME0") << "deleting ME0SegmentBuilder after " << iev << " events w/csc data."; - delete segmentBuilder_; -} - -void ME0SegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) { - - LogDebug("ME0Segment|ME0") << "start producing segments for " << ++iev << "th event with csc data"; - - // find the geometry (& conditions?) for this event & cache it in the builder - edm::ESHandle me0g; - setup.get().get(me0g); - const ME0Geometry* mgeom = &*me0g; - segmentBuilder_->setGeometry(mgeom); - - - // get the collection of ME0RecHit - edm::Handle me0RecHits; - ev.getByLabel(inputObjectsTag, me0RecHits); - - // create empty collection of Segments - std::auto_ptr oc( new ME0SegmentCollection ); - - // fill the collection - segmentBuilder_->build(me0RecHits.product(), *oc); //@@ FILL oc - - // put collection in event - ev.put(oc); -} diff --git a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h deleted file mode 100644 index 2c2ebb51206a5..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/ME0SegmentProducer.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef GEMRecHit_ME0SegmentProducer_h -#define GEMRecHit_ME0SegmentProducer_h - -/** \class ME0SegmentProducer derived by CSCSegmentProducer - * Produces a collection of ME0Segment's in endcap muon ME0s. - * - * $Date: 2014/02/03 23:48:11 $ - * $Revision: 1.1 $ - * \author Marcello Maggi - */ - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" - -class ME0SegmentBuilder; - -class ME0SegmentProducer : public edm::EDProducer { -public: - /// Constructor - explicit ME0SegmentProducer(const edm::ParameterSet&); - /// Destructor - ~ME0SegmentProducer(); - /// Produce the ME0Segment collection - virtual void produce(edm::Event&, const edm::EventSetup&); - -private: - int iev; // events through - edm::InputTag inputObjectsTag; // input tag labelling rechits for input - ME0SegmentBuilder* segmentBuilder_; -}; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/SealModule.cc b/RecoLocalMuon/GEMRecHit/src/SealModule.cc index edbf4f177b2cf..2c2cf0d4d20e8 100644 --- a/RecoLocalMuon/GEMRecHit/src/SealModule.cc +++ b/RecoLocalMuon/GEMRecHit/src/SealModule.cc @@ -17,9 +17,3 @@ DEFINE_FWK_MODULE(ME0RecHitProducer); #include "RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h" DEFINE_EDM_PLUGIN (ME0RecHitAlgoFactory, ME0RecHitStandardAlgo, "ME0RecHitStandardAlgo"); -#include -#include - -#include -DEFINE_FWK_MODULE(ME0SegmentProducer); -DEFINE_EDM_PLUGIN(ME0SegmentBuilderPluginFactory, ME0SegAlgoMM, "ME0SegAlgoMM"); From 93b2c57e355ccee3341209f9280d134c4d8f36a8 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Mon, 11 May 2015 20:16:00 +0200 Subject: [PATCH 08/13] keeping only ME0 recHit files for this pull request --- RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc index 4dc2c7fadd302..d9943989de5ab 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc @@ -92,7 +92,7 @@ void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { OwnVector recHits = theAlgo->reconstruct(me0Id, range); - if(recHits.size() > 0) //FIXME: is it really needed? + if(recHits.size() > 0) recHitCollection->put(me0Id, recHits.begin(), recHits.end()); } From 23813362ab5c9df5755efbcbc522dc03eb1b489b Mon Sep 17 00:00:00 2001 From: archie sharma Date: Tue, 12 May 2015 14:51:20 +0200 Subject: [PATCH 09/13] modernized code for 75X --- .../GEMRecHit/src/ME0RecHitProducer.cc | 35 ++++--------------- .../GEMRecHit/src/ME0RecHitProducer.h | 22 +++++++++++- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc index d9943989de5ab..6819c1cf00bf6 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc @@ -8,34 +8,13 @@ #include "ME0RecHitProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" - -#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" -#include "Geometry/GEMGeometry/interface/ME0Geometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "DataFormats/MuonDetId/interface/ME0DetId.h" -#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" - -#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" -#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" -#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" - -#include - - -using namespace edm; -using namespace std; - - ME0RecHitProducer::ME0RecHitProducer(const ParameterSet& config){ produces(); - theME0DigiLabel = config.getParameter("me0DigiLabel"); - + + m_token = consumes( config.getParameter("me0DigiLabel") ); + + // Get the concrete reconstruction algo from the factory string theAlgoName = config.getParameter("recAlgo"); @@ -58,13 +37,13 @@ void ME0RecHitProducer::beginRun(const edm::Run& r, const edm::EventSetup& setup void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { // Get the ME0 Geometry - ESHandle me0Geom; + edm::ESHandle me0Geom; setup.get().get(me0Geom); // Get the digis from the event - Handle digis; - event.getByLabel(theME0DigiLabel,digis); + edm::Handle digis; + event.getByToken(m_token,digis); // Pass the EventSetup to the algo diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h index 5116567e05b32..37b5504e0c127 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h @@ -21,8 +21,27 @@ #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "DataFormats/GEMDigi/interface/ME0DigiPreRecoCollection.h" +#include "Geometry/GEMGeometry/interface/ME0EtaPartition.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHit.h" + +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h" +#include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" +#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" + +#include +using namespace edm; +using namespace std; + +//using namespace reco; namespace edm { class ParameterSet; @@ -50,7 +69,8 @@ class ME0RecHitProducer : public edm::EDProducer { private: // The label to be used to retrieve ME0 digis from the event - edm::InputTag theME0DigiLabel; + + edm::EDGetTokenT m_token; // The reconstruction algorithm ME0RecHitBaseAlgo *theAlgo; From 7636f8545744b1f0458068d7a29b6fa19f185248 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Tue, 12 May 2015 19:47:54 +0200 Subject: [PATCH 10/13] modernized code for 75X --- RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h index 37b5504e0c127..451d6dfdcdba2 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h @@ -18,7 +18,7 @@ #include #include -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" #include "FWCore/Framework/interface/Event.h" @@ -51,7 +51,7 @@ namespace edm { class ME0RecHitBaseAlgo; -class ME0RecHitProducer : public edm::EDProducer { +class ME0RecHitProducer : public edm::stream::EDProducer<> { public: /// Constructor From 72458a78b74dd46c8acd7c611cabd89cb91c75d6 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Thu, 14 May 2015 05:23:46 +0200 Subject: [PATCH 11/13] removing namespace statements --- RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc | 12 ++++++------ RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h | 10 ---------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc index 6819c1cf00bf6..a792d4c6a80db 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc @@ -8,7 +8,7 @@ #include "ME0RecHitProducer.h" -ME0RecHitProducer::ME0RecHitProducer(const ParameterSet& config){ +ME0RecHitProducer::ME0RecHitProducer(const edm::ParameterSet& config){ produces(); @@ -17,9 +17,9 @@ ME0RecHitProducer::ME0RecHitProducer(const ParameterSet& config){ // Get the concrete reconstruction algo from the factory - string theAlgoName = config.getParameter("recAlgo"); + std::string theAlgoName = config.getParameter("recAlgo"); theAlgo = ME0RecHitAlgoFactory::get()->create(theAlgoName, - config.getParameter("recAlgoConfig")); + config.getParameter("recAlgoConfig")); } @@ -34,7 +34,7 @@ void ME0RecHitProducer::beginRun(const edm::Run& r, const edm::EventSetup& setup -void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { +void ME0RecHitProducer::produce(edm::Event& event, const edm::EventSetup& setup) { // Get the ME0 Geometry edm::ESHandle me0Geom; @@ -51,7 +51,7 @@ void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { // Create the pointer to the collection which will store the rechits - auto_ptr recHitCollection(new ME0RecHitCollection()); + std::auto_ptr recHitCollection(new ME0RecHitCollection()); // Iterate through all digi collections ordered by LayerId @@ -68,7 +68,7 @@ void ME0RecHitProducer::produce(Event& event, const EventSetup& setup) { // Call the reconstruction algorithm - OwnVector recHits = + edm::OwnVector recHits = theAlgo->reconstruct(me0Id, range); if(recHits.size() > 0) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h index 451d6dfdcdba2..5204905369d0b 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h @@ -38,16 +38,6 @@ #include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h" #include -using namespace edm; -using namespace std; - -//using namespace reco; - -namespace edm { - class ParameterSet; - class Event; - class EventSetup; -} class ME0RecHitBaseAlgo; From ed57ad291808c5d0d419acf96ecd605b03d66262 Mon Sep 17 00:00:00 2001 From: archie sharma Date: Mon, 18 May 2015 15:46:18 +0200 Subject: [PATCH 12/13] removing unused function --- .../GEMRecHit/src/ME0RecHitStandardAlgo.cc | 15 --------------- .../GEMRecHit/src/ME0RecHitStandardAlgo.h | 5 ----- 2 files changed, 20 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc index 98cb31a4d03db..b73b193d72dc3 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc @@ -38,18 +38,3 @@ bool ME0RecHitStandardAlgo::compute(const ME0DigiPreReco& digi, return true; } - -bool ME0RecHitStandardAlgo::compute(const ME0DigiPreReco& digi, - const float& angle, - const GlobalPoint& globPos, - LocalPoint& Point, - LocalError& error) const -{ - - // Glob Pos and angle not used so far... - if (globPos.z()<0){ } // Fake use to avoid warnings - if (angle<0.){ } // Fake use to avoid warnings - this->compute(digi,Point,error); - return true; -} - diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h index 75cb6429f551d..8ec740db9f053 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h +++ b/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h @@ -29,11 +29,6 @@ class ME0RecHitStandardAlgo : public ME0RecHitBaseAlgo { LocalError& error) const; - virtual bool compute(const ME0DigiPreReco& digi, - const float& angle, - const GlobalPoint& globPos, - LocalPoint& point, - LocalError& error) const; }; #endif From d9d77f0cc6315385d515e28894c5f15aadc0c24a Mon Sep 17 00:00:00 2001 From: archie sharma Date: Mon, 18 May 2015 15:48:39 +0200 Subject: [PATCH 13/13] removing unused function --- RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h index ca8718a3124c4..daa05df30a02a 100644 --- a/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h +++ b/RecoLocalMuon/GEMRecHit/interface/ME0RecHitBaseAlgo.h @@ -48,13 +48,6 @@ class ME0RecHitBaseAlgo { LocalPoint& Point, LocalError& error) const = 0; - /// local recHit computation accounting for track direction and - /// absolute position - virtual bool compute(const ME0DigiPreReco& digi, - const float& angle, - const GlobalPoint& globPos, - LocalPoint& Point, - LocalError& error) const = 0; }; #endif