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
backport of CASTOR updates on rechitcorrector and noise simulation #23894
Changes from all commits
0a1daca
96cc6ae
49ca4f1
33c5a78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
// Class: RecHitCorrector | ||
// | ||
/**\class RecHitCorrector RecHitCorrector.cc RecoLocalCalo/Castor/src/RecHitCorrector.cc | ||
|
||
Description: [one line class summary] | ||
|
||
Implementation: | ||
[Notes on implementation] | ||
*/ | ||
|
@@ -22,7 +22,7 @@ | |
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDProducer.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
@@ -44,15 +44,13 @@ | |
// class declaration | ||
// | ||
|
||
class RecHitCorrector : public edm::EDProducer { | ||
class RecHitCorrector : public edm::stream::EDProducer<> { | ||
public: | ||
explicit RecHitCorrector(const edm::ParameterSet&); | ||
~RecHitCorrector(); | ||
~RecHitCorrector() override; | ||
|
||
private: | ||
virtual void beginJob() override ; | ||
virtual void produce(edm::Event&, const edm::EventSetup&) override; | ||
virtual void endJob() override ; | ||
void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
||
// ----------member data --------------------------- | ||
edm::EDGetTokenT<CastorRecHitCollection> tok_input_; | ||
|
@@ -114,72 +112,49 @@ RecHitCorrector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) | |
iSetup.get<CastorChannelQualityRcd>().get(p); | ||
CastorChannelQuality* myqual = new CastorChannelQuality(*p.product()); | ||
|
||
if (!rechits.isValid()) std::cout << "No valid CastorRecHitCollection found, please check the InputLabel..." << std::endl; | ||
if (!rechits.isValid()) edm::LogWarning("CastorRecHitCorrector") << "No valid CastorRecHitCollection found, please check the InputLabel..."; | ||
|
||
CastorCalibrations calibrations; | ||
|
||
std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection); | ||
auto rec = std::make_unique<CastorRecHitCollection>(); | ||
|
||
for (unsigned int i=0;i<rechits->size();i++) { | ||
CastorRecHit rechit = (*rechits)[i]; | ||
//std::cout << "rechit energy = " << rechit.energy() << std::endl; | ||
double fC = factor_*rechit.energy(); | ||
double time = rechit.time(); | ||
//std::cout << "rechit energy(fC) = " << fC << " time = " << time << std::endl; | ||
|
||
// do proper gain calibration reading the latest entries in the condDB | ||
const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id()); | ||
int capid = 0; // take some capid, gains are the same for all capid's | ||
double correctedenergy = factor_*rechit.energy(); | ||
|
||
double correctedenergy = 0; | ||
if (doInterCalib_) { | ||
if (rechit.id().module() <= 2) { | ||
correctedenergy = 0.5*fC*calibrations.gain(capid); | ||
//std::cout << " correctedenergy = " << correctedenergy << " gain = " << calibrations.gain(capid) << std::endl; | ||
} else { | ||
correctedenergy = fC*calibrations.gain(capid); | ||
} | ||
} else { | ||
if (rechit.id().module() <= 2) { | ||
correctedenergy = 0.5*fC; | ||
} else { | ||
correctedenergy = fC; | ||
} | ||
// do proper gain calibration reading the latest entries in the condDB | ||
const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id()); | ||
int capid = 0; // take some capid, gains are the same for all capid's | ||
correctedenergy *= calibrations.gain(capid); | ||
} | ||
|
||
// now check the channelquality of this rechit | ||
bool ok = true; | ||
DetId detcell=(DetId)rechit.id(); | ||
std::vector<DetId> channels = myqual->getAllChannels(); | ||
//std::cout << "number of specified quality flags = " << channels.size() << std::endl; | ||
for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();channel++) { | ||
if (channel->rawId() == detcell.rawId()) { | ||
const CastorChannelStatus* mydigistatus=myqual->getValues(*channel); | ||
//std::cout << "CastorChannelStatus = " << mydigistatus->getValue() << std::endl; | ||
if (mydigistatus->getValue() == 2989) ok = false; // 2989 = BAD | ||
for (auto channel : channels) { | ||
if (channel.rawId() == detcell.rawId()) { | ||
const CastorChannelStatus* mydigistatus=myqual->getValues(channel); | ||
if (mydigistatus->getValue() == 2989) { | ||
ok = false; // 2989 = BAD | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (ok) { | ||
CastorRecHit *correctedhit = new CastorRecHit(rechit.id(),correctedenergy,time); | ||
rec->push_back(*correctedhit); | ||
rec->emplace_back(rechit.id(),correctedenergy,time); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hvanhaev , is it correct? I would think about "rec->emplace_back(new CastorRecHit(....))" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need for new. One could think of explicitly calling a constructor the old implementation collected copies of the hits (type CastorRecHit). The updated version does exactly the same. and also avoids a memory leak that was there before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, using |
||
} | ||
} | ||
|
||
iEvent.put(rec); | ||
iEvent.put(std::move(rec)); | ||
|
||
delete myqual; | ||
|
||
} | ||
|
||
// ------------ method called once each job just before starting event loop ------------ | ||
void | ||
RecHitCorrector::beginJob() | ||
{ | ||
} | ||
|
||
// ------------ method called once each job just after ending the event loop ------------ | ||
void | ||
RecHitCorrector::endJob() { | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(RecHitCorrector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvanhaev
please remind me the reason for hits with the
id().module() <= 2
to be not handled in a special way anymore.Are hits with these module values present only for some period of data taking. If so, when?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvanhaev
In case you missed the question, please clarify on the hits with
id().module() <= 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvanhaev: (maybe I missed some part of the discussion about it, sorry for that) shouldn't this 0.5 factor for
id().module() <= 2
be restored to fully reproduce the previous 80X behaviour?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#23894 (comment)
this code is not used in the standard reco workflows.
So, there is no requirement for unchanged default behavior.