Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format for clustering CSC rechits with jet algorithms #35543

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions DataFormats/CSCRecHit/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/TrackingRecHit"/>
<use name="DataFormats/Common"/>
Comment on lines -3 to +1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert to the old indentation

<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/TrackingRecHit"/>
<export>
<lib name="1"/>
</export>
79 changes: 79 additions & 0 deletions DataFormats/CSCRecHit/interface/CSCJetCandidate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#ifndef DataFormats_CSCJetCandidate_h
#define DataFormats_CSCJetCandidate_h

#include <vector>
#include <memory>
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Common/interface/SortedCollection.h"

#include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used.

Suggested change
#include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>

#include "DataFormats/Candidate/interface/LeafCandidate.h"

namespace reco {

class CSCJetCandidate : public LeafCandidate {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have (so far just minor) preference for such class to be in DataFormats/MuonReco.
Also, the purpose seems to be rather generic and we should probably consider making a more generic type that can handle transparently other muon detectors (DT/RPC/GEM).

public:
//default constructor
CSCJetCandidate()
: x_(0.),
y_(0.),
z_(0.),
tPeak_(-999.),
tWire_(-999.),
quality_(0),
chamber_(0),
station_(0),
nStrips_(0),
hitWire_(0),
wgroupsBX_(0),
nWireGroups_(0) {}

CSCJetCandidate(const double phi,
const double eta,
const float x,
const float y,
const float z,
const float tPeak,
const float tWire,
const int quality,
const int chamber,
const int station,
const int nStrips,
const int hitWire,
const int wgroupsBX,
const int nWireGroups);

//destructor
~CSCJetCandidate() override;

float xPos() const { return x_; }
float yPos() const { return y_; }
float zPos() const { return z_; }
float tPeak() const { return tPeak_; }
float tWire() const { return tWire_; }
int quality() const { return quality_; }
int chamber() const { return chamber_; }
int station() const { return station_; }
int nStrips() const { return nStrips_; }
int hitWire() const { return hitWire_; }
int wgroupsBX() const { return wgroupsBX_; }
int nWireGroups() const { return nWireGroups_; }

private:
float x_;
float y_;
float z_;
float tPeak_;
float tWire_;
int quality_;
int chamber_;
int station_;
int nStrips_;
int hitWire_;
int wgroupsBX_;
int nWireGroups_;
};

typedef std::vector<CSCJetCandidate> CSCJetCandidateCollection;
} // namespace reco
#endif
38 changes: 38 additions & 0 deletions DataFormats/CSCRecHit/src/CSCJetCandidate.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "DataFormats/CSCRecHit/interface/CSCJetCandidate.h"

/*
* Create LeafCandidate with (eta,phi) only as CSC rechits has no energy/momentum measurement
* Pt is set to 1.0 as a place holder, mass is set at 0.
* Vertex associated with the CSC rechit is set to the origin.
*
*/
reco::CSCJetCandidate::CSCJetCandidate(double phi,
double eta,
float x,
float y,
float z,
float tPeak,
float tWire,
int quality,
int chamber,
int station,
int nStrips,
int hitWire,
int wgroupsBX,
int nWireGroups)
: LeafCandidate(0, LorentzVector(math::PtEtaPhiMLorentzVector(1.0, eta, phi, 0)), Point(0, 0, 0)) {
x_ = x;
Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: LeafCandidate(0, LorentzVector(math::PtEtaPhiMLorentzVector(1.0, eta, phi, 0)), Point(0, 0, 0)) {
x_ = x;
: LeafCandidate(0, LorentzVector(math::PtEtaPhiMLorentzVector(1.0, eta, phi, 0)), Point(0, 0, 0)), x_(x) {

initializer list (before { is preferred to the use of the constructor body)

[the comment applies to the rest of the members]

y_ = y;
z_ = z;
tPeak_ = tPeak;
tWire_ = tWire;
quality_ = quality;
chamber_ = chamber;
station_ = station;
nStrips_ = nStrips;
hitWire_ = hitWire;
wgroupsBX_ = wgroupsBX;
nWireGroups_ = nWireGroups;
}

reco::CSCJetCandidate::~CSCJetCandidate() {}
2 changes: 2 additions & 0 deletions DataFormats/CSCRecHit/src/classes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
#include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>

#include <DataFormats/CSCRecHit/interface/CSCJetCandidate.h>

#include <DataFormats/CSCRecHit/interface/CSCSegment.h>
#include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>

Expand Down
8 changes: 6 additions & 2 deletions DataFormats/CSCRecHit/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
<class name="edm::ClonePolicy<CSCRecHit2D>"/> <!-- Root6 -->
<class name="edm::RangeMap<CSCDetId,edm::OwnVector<CSCRecHit2D,edm::ClonePolicy<CSCRecHit2D> >,edm::ClonePolicy<CSCRecHit2D> >"/>
<class name="edm::Wrapper<edm::RangeMap<CSCDetId,edm::OwnVector<CSCRecHit2D,edm::ClonePolicy<CSCRecHit2D> >,edm::ClonePolicy<CSCRecHit2D> > >"/>

<class name="std::vector<CSCSegment>"/>
<class name="reco::CSCJetCandidate" ClassVersion="4">
<version ClassVersion="3" checksum="1185432696"/>
<version ClassVersion="4" checksum="882507185"/>
Comment on lines +20 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<class name="reco::CSCJetCandidate" ClassVersion="4">
<version ClassVersion="3" checksum="1185432696"/>
<version ClassVersion="4" checksum="882507185"/>
<class name="reco::CSCJetCandidate" ClassVersion="3">
<version ClassVersion="3" checksum="882507185"/>

remove intermediate/unused class versions

</class>
<class name="std::vector<reco::CSCJetCandidate>"/>
<class name="edm::Wrapper<std::vector<reco::CSCJetCandidate>>"/>
<class name="std::vector<CSCSegment*>"/>
<class name="CSCSegment" ClassVersion="11">
<version ClassVersion="11" checksum="160361831"/>
Expand Down
72 changes: 72 additions & 0 deletions RecoLocalMuon/CSCRecHitD/src/CSCJetCandidateProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <RecoLocalMuon/CSCRecHitD/src/CSCJetCandidateProducer.h>

#include <FWCore/Framework/interface/Frameworkfwd.h>
#include <FWCore/Framework/interface/EDProducer.h>
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/Framework/interface/MakerMacros.h>
#include <DataFormats/Common/interface/Handle.h>
#include <FWCore/Framework/interface/ESHandle.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Utilities/interface/Exception.h>
#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>
#include "Geometry/Records/interface/MuonGeometryRecord.h"

CSCJetCandidateProducer::CSCJetCandidateProducer(const edm::ParameterSet& ps) {
cscRechitInputToken_ = consumes<CSCRecHit2DCollection>(edm::InputTag("csc2DRecHits")),

// register what this produces
produces<CSCJetCandidateCollection>();
}

CSCJetCandidateProducer::~CSCJetCandidateProducer() {}

void CSCJetCandidateProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
LogTrace("CSCRecHit") << "[CSCJetCandidateProducer] starting event ";

edm::ESHandle<CSCGeometry> cscG;
edm::Handle<CSCRecHit2DCollection> cscRechits;

setup.get<MuonGeometryRecord>().get(cscG);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ev.getByToken(cscRechitInputToken_, cscRechits);

// Create empty collection of rechits
auto oc = std::make_unique<CSCJetCandidateCollection>();

// Put collection in event
LogTrace("CSCRecHit") << "[CSCJetCandidateProducer] putting collection of " << oc->size() << " rechits into event.";

for (const CSCRecHit2D& cscRechit : *cscRechits) {
LocalPoint cscRecHitLocalPosition = cscRechit.localPosition();
CSCDetId cscdetid = cscRechit.cscDetId();
int endcap = CSCDetId::endcap(cscdetid) == 1 ? 1 : -1;
const CSCChamber* cscchamber = cscG->chamber(cscdetid);
if (cscchamber) {
GlobalPoint globalPosition = cscchamber->toGlobal(cscRecHitLocalPosition);

float x = globalPosition.x();
float y = globalPosition.y();
float z = globalPosition.z();
double phi = globalPosition.phi();
double eta = globalPosition.eta();
float tpeak = cscRechit.tpeak();
float wireTime = cscRechit.wireTime();
int quality = cscRechit.quality();
int chamber = endcap * (CSCDetId::station(cscdetid) * 10 + CSCDetId::ring(cscdetid));
int station = endcap * CSCDetId::station(cscdetid);
int nStrips = cscRechit.nStrips();
int hitWire = cscRechit.hitWire();
int wgroupsBX = cscRechit.wgroupsBX();
int nWireGroups = cscRechit.nWireGroups();

reco::CSCJetCandidate rh(
phi, eta, x, y, z, tpeak, wireTime, quality, chamber, station, nStrips, hitWire, wgroupsBX, nWireGroups);
oc->push_back(rh);
}
}
ev.put(std::move(oc));
}

//define this as a plug-in
DEFINE_FWK_MODULE(CSCJetCandidateProducer);
36 changes: 36 additions & 0 deletions RecoLocalMuon/CSCRecHitD/src/CSCJetCandidateProducer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef CSCRecHitD_CSCJetCandidateProducer_h
#define CSCRecHitD_CSCJetCandidateProducer_h

/** \class CSCJetCandidateProducer
*
* Produces a collection of CSCJetCandidate's (2D CSC RecHits as JetCandidates)
* \author Martin Kwok
*
*/

#include <FWCore/Framework/interface/ConsumesCollector.h>
#include <FWCore/Framework/interface/Frameworkfwd.h>
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Utilities/interface/InputTag.h>
#include <FWCore/Utilities/interface/ESGetToken.h>

#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCJetCandidate.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"

class CSCJetCandidateProducer : public edm::stream::EDProducer<> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header files are not needed for plugins; please merge this .h file contents into the CSCJetCandidateProducer.cc

all new modules should have a fillDescriptions method defined to provide a default configuration
https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideConfigurationValidationAndHelp

public:
explicit CSCJetCandidateProducer(const edm::ParameterSet& ps);
~CSCJetCandidateProducer() override;

void produce(edm::Event&, const edm::EventSetup&) override;

private:
edm::EDGetTokenT<CSCRecHit2DCollection> cscRechitInputToken_;
typedef std::vector<reco::CSCJetCandidate> CSCJetCandidateCollection;
};

#endif