61 void endJob()
override;
118 produceHFhits_ = iConfig.
getParameter<
bool>(
"produceHFhits");
119 produceHFtowers_ = iConfig.
getParameter<
bool>(
"produceHFtowers");
120 produceEcalhits_ = iConfig.
getParameter<
bool>(
"produceEcalhits");
121 produceZDChits_ = iConfig.
getParameter<
bool>(
"produceZDChits");
122 produceETmidRap_ = iConfig.
getParameter<
bool>(
"produceETmidRapidity");
123 producePixelhits_ = iConfig.
getParameter<
bool>(
"producePixelhits");
124 produceTracks_ = iConfig.
getParameter<
bool>(
"produceTracks");
125 producePixelTracks_ = iConfig.
getParameter<
bool>(
"producePixelTracks");
127 midRapidityRange_ = iConfig.
getParameter<
double>(
"midRapidityRange");
128 trackPtCut_ = iConfig.
getParameter<
double>(
"trackPtCut");
129 trackEtaCut_ = iConfig.
getParameter<
double>(
"trackEtaCut");
135 if (produceHFtowers_ || produceETmidRap_)
138 if (produceEcalhits_) {
142 if (produceZDChits_) {
146 if (producePixelhits_) {
151 if (produceTracks_) {
155 if (producePixelTracks_)
158 reuseAny_ = iConfig.
getParameter<
bool>(
"reUseCentrality");
165 produces<Centrality>();
168 CentralityProducer::~CentralityProducer() {
179 if (producePixelhits_)
181 if (produceEcalhits_)
183 if (producePixelhits_)
186 auto creco = std::make_unique<Centrality>();
190 iEvent.
getByToken(reuseTag_, inputCentrality);
192 if (produceHFhits_) {
193 creco->etHFhitSumPlus_ = 0;
194 creco->etHFhitSumMinus_ = 0;
198 for (
size_t ihit = 0; ihit < hits->
size(); ++ihit) {
199 const HFRecHit& rechit = (*hits)[ihit];
200 if (rechit.
id().
ieta() > 0)
201 creco->etHFhitSumPlus_ += rechit.
energy();
202 if (rechit.
id().
ieta() < 0)
203 creco->etHFhitSumMinus_ += rechit.
energy();
207 creco->etHFhitSumMinus_ = inputCentrality->EtHFhitSumMinus();
208 creco->etHFhitSumPlus_ = inputCentrality->EtHFhitSumPlus();
212 if (produceHFtowers_ || produceETmidRap_) {
213 creco->etHFtowerSumPlus_ = 0;
214 creco->etHFtowerSumMinus_ = 0;
215 creco->etHFtowerSumECutPlus_ = 0;
216 creco->etHFtowerSumECutMinus_ = 0;
217 creco->etMidRapiditySum_ = 0;
223 for (
size_t i = 0;
i < towers->
size(); ++
i) {
227 if (produceHFtowers_) {
228 if (isHF && eta > 0) {
229 creco->etHFtowerSumPlus_ += tower.
pt();
231 creco->etHFtowerSumECutPlus_ += tower.
pt();
233 creco->etHFtruncatedPlus_ += tower.
pt();
235 if (isHF && eta < 0) {
236 creco->etHFtowerSumMinus_ += tower.
pt();
238 creco->etHFtowerSumECutMinus_ += tower.
pt();
239 if (eta < -hfEtaCut_)
240 creco->etHFtruncatedMinus_ += tower.
pt();
244 creco->etHFtowerSumMinus_ = inputCentrality->EtHFtowerSumMinus();
245 creco->etHFtowerSumPlus_ = inputCentrality->EtHFtowerSumPlus();
246 creco->etHFtowerSumECutMinus_ = inputCentrality->EtHFtowerSumECutMinus();
247 creco->etHFtowerSumECutPlus_ = inputCentrality->EtHFtowerSumECutPlus();
248 creco->etHFtruncatedMinus_ = inputCentrality->EtHFtruncatedMinus();
249 creco->etHFtruncatedPlus_ = inputCentrality->EtHFtruncatedPlus();
252 if (produceETmidRap_) {
253 if (
std::abs(eta) < midRapidityRange_)
254 creco->etMidRapiditySum_ += tower.
pt() / (midRapidityRange_ * 2.);
255 }
else if (reuseAny_)
256 creco->etMidRapiditySum_ = inputCentrality->EtMidRapiditySum();
260 creco->etHFtowerSumMinus_ = inputCentrality->EtHFtowerSumMinus();
261 creco->etHFtowerSumPlus_ = inputCentrality->EtHFtowerSumPlus();
262 creco->etHFtowerSumECutMinus_ = inputCentrality->EtHFtowerSumECutMinus();
263 creco->etHFtowerSumECutPlus_ = inputCentrality->EtHFtowerSumECutPlus();
264 creco->etMidRapiditySum_ = inputCentrality->EtMidRapiditySum();
268 if (produceEcalhits_) {
269 creco->etEESumPlus_ = 0;
270 creco->etEESumMinus_ = 0;
279 for (
unsigned int i = 0;
i < ebHits->
size(); ++
i) {
282 double et = hit.
energy() * (pos.perp() / pos.mag());
283 creco->etEBSum_ +=
et;
286 for (
unsigned int i = 0;
i < eeHits->
size(); ++
i) {
289 double et = hit.
energy() * (pos.perp() / pos.mag());
291 creco->etEESumPlus_ +=
et;
293 creco->etEESumMinus_ +=
et;
298 creco->etEESumMinus_ = inputCentrality->EtEESumMinus();
299 creco->etEESumPlus_ = inputCentrality->EtEESumPlus();
300 creco->etEBSum_ = inputCentrality->EtEBSum();
304 if (producePixelhits_) {
305 creco->pixelMultiplicity_ = 0;
312 int nPixel_minus = 0;
319 recHitIterator != recHitRange.
end();
327 double eta = rechitPos.eta();
328 double abeta =
std::abs(rechitPos.eta());
329 int clusterSize = recHit->
cluster()->size();
330 unsigned layer = topo_->layer(detId);
333 if (layer == 1 && 18 * abeta - 40 > clusterSize)
335 if (layer == 2 && 6 * abeta - 7.2 > clusterSize)
337 if ((layer == 3 || layer == 4) && 4 * abeta - 2.4 > clusterSize)
348 creco->pixelMultiplicity_ = nPixel;
349 creco->pixelMultiplicityPlus_ = nPixel_plus;
350 creco->pixelMultiplicityMinus_ = nPixel_minus;
353 creco->pixelMultiplicity_ = inputCentrality->multiplicityPixel();
354 creco->pixelMultiplicityPlus_ = inputCentrality->multiplicityPixelPlus();
355 creco->pixelMultiplicityMinus_ = inputCentrality->multiplicityPixelMinus();
359 if (produceTracks_) {
363 double vxError = -999.;
364 double vyError = -999.;
365 double vzError = -999.;
370 unsigned int daughter = 0;
373 for (
unsigned int i = 0;
i < recoVertices->size(); ++
i) {
374 daughter = (*recoVertices)[
i].tracksSize();
375 if (daughter > (*recoVertices)[greatestvtx].tracksSize())
379 if (!recoVertices->empty()) {
380 vx = (*recoVertices)[greatestvtx].position().x();
381 vy = (*recoVertices)[greatestvtx].position().y();
382 vz = (*recoVertices)[greatestvtx].position().z();
383 vxError = (*recoVertices)[greatestvtx].xError();
384 vyError = (*recoVertices)[greatestvtx].yError();
385 vzError = (*recoVertices)[greatestvtx].zError();
394 double trackCounter = 0;
395 double trackCounterEta = 0;
396 double trackCounterEtaPt = 0;
398 for (
unsigned int i = 0;
i < tracks->size(); ++
i) {
400 if (useQuality_ && !track.
quality(trackQuality_))
403 if (track.
pt() > trackPtCut_)
407 if (track.
pt() > trackPtCut_)
412 double dz = track.
dz(v1);
413 double dzsigma2 = track.
dzError() * track.
dzError() + vzError * vzError;
414 double dxy = track.
dxy(v1);
417 const double pterrcut = 0.1;
418 const double dzrelcut = 3.0;
419 const double dxyrelcut = 3.0;
422 track.
ptError() / track.
pt() < pterrcut && dz * dz < dzrelcut * dzrelcut * dzsigma2 &&
423 dxy * dxy < dxyrelcut * dxyrelcut * dxysigma2) {
428 creco->trackMultiplicity_ =
nTracks;
429 creco->ntracksPtCut_ = trackCounter;
430 creco->ntracksEtaCut_ = trackCounterEta;
431 creco->ntracksEtaPtCut_ = trackCounterEtaPt;
435 creco->trackMultiplicity_ = inputCentrality->Ntracks();
436 creco->ntracksPtCut_ = inputCentrality->NtracksPtCut();
437 creco->ntracksEtaCut_ = inputCentrality->NtracksEtaCut();
438 creco->ntracksEtaPtCut_ = inputCentrality->NtracksEtaPtCut();
442 if (producePixelTracks_) {
444 iEvent.
getByToken(srcPixelTracks_, pixeltracks);
445 int nPixelTracks = pixeltracks->size();
446 int nPixelTracksPlus = 0;
447 int nPixelTracksMinus = 0;
449 for (
auto const&
track : *pixeltracks) {
455 creco->nPixelTracks_ = nPixelTracks;
456 creco->nPixelTracksPlus_ = nPixelTracksPlus;
457 creco->nPixelTracksMinus_ = nPixelTracksMinus;
460 creco->nPixelTracks_ = inputCentrality->NpixelTracks();
461 creco->nPixelTracksPlus_ = inputCentrality->NpixelTracksPlus();
462 creco->nPixelTracksMinus_ = inputCentrality->NpixelTracksMinus();
466 if (produceZDChits_) {
467 creco->zdcSumPlus_ = 0;
468 creco->zdcSumMinus_ = 0;
471 bool zdcAvailable = iEvent.
getByToken(srcZDChits_, hits);
473 for (
size_t ihit = 0; ihit < hits->
size(); ++ihit) {
479 creco->zdcSumPlus_ += rechit.
energy();
486 creco->zdcSumMinus_ += rechit.
energy();
491 creco->zdcSumPlus_ = -9;
492 creco->zdcSumMinus_ = -9;
496 creco->zdcSumMinus_ = inputCentrality->zdcSumMinus();
497 creco->zdcSumPlus_ = inputCentrality->zdcSumPlus();
508 void CentralityProducer::endJob() {}
constexpr float energy() const
reco::TrackBase::TrackQuality trackQuality_
T getParameter(std::string const &) const
const unsigned int nTracks(const reco::Vertex &sv)
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double eta() const final
momentum pseudorapidity
edm::EDGetTokenT< EcalRecHitCollection > srcEBhits_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< Centrality > reuseTag_
TrackQuality
track quality
double dxyError() const
error on dxy
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
int zside() const
get the z-side of the cell (1/-1)
double pt() const final
transverse momentum
edm::EDGetTokenT< VertexCollection > srcVertex_
edm::EDGetTokenT< CaloTowerCollection > srcTowers_
#define DEFINE_FWK_MODULE(type)
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
int ieta() const
get the cell ieta
double energy() const final
energy
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::EDGetTokenT< HFRecHitCollection > srcHFhits_
Abs< T >::type abs(const T &t)
float lowGainEnergy() const
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dzError() const
error on dz
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
DetId id() const
get the id
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::EDGetTokenT< ZDCRecHitCollection > srcZDChits_
ClusterRef cluster() const
bool isHF(int etabin, int depth)
edm::ESHandle< CaloGeometry > cGeo
bool quality(const TrackQuality) const
Track quality.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
const_iterator find(id_type i, bool update=false) const
edm::EDGetTokenT< SiPixelRecHitCollection > srcPixelhits_
edm::ESHandle< TrackerTopology > topo_
edm::EDGetTokenT< TrackCollection > srcPixelTracks_
edm::EDGetTokenT< TrackCollection > srcTracks_
HcalZDCDetId id() const
get the id
LocalPoint localPosition() const final
edm::ESHandle< TrackerGeometry > tGeo
DetId geographicalId() const
edm::EDGetTokenT< EcalRecHitCollection > srcEEhits_
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
const_iterator begin(bool update=false) const
constexpr Detector det() const
get the detector field from this detid