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

[10.6.X] Fix simulation of the pixel bad components on the FED channel basis for PreMixing #27916

Merged
merged 1 commit into from
Sep 19, 2019
Merged
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
19 changes: 15 additions & 4 deletions SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ PreMixingSiPixelWorker::PreMixingSiPixelWorker(const edm::ParameterSet& ps, edm:
PixelDigiToken_ = iC.consumes<edm::DetSetVector<PixelDigi> >(pixeldigi_collectionSig_);
PixelDigiPToken_ = iC.consumes<edm::DetSetVector<PixelDigi> >(pixeldigi_collectionPile_);


producer.produces< edm::DetSetVector<PixelDigi> > (PixelDigiCollectionDM_);
producer.produces<PixelFEDChannelCollection>(PixelDigiCollectionDM_);

// clear local storage for this event
SiHitStorage_.clear();
Expand Down Expand Up @@ -290,10 +292,19 @@ void PreMixingSiPixelWorker::put(edm::Event &e, edm::EventSetup const& iSetup, s

edm::ESHandle<TrackerTopology> tTopoHand;
iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology *tTopo=tTopoHand.product();

for(const auto& iu : pDD->detUnits()) {
if(iu->type().isTrackerPixel()) {

const TrackerTopology* tTopo = tTopoHand.product();

if (digitizer_.killBadFEDChannels()) {
std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ = digitizer_.chooseScenario(ps, engine);
if (PixelFEDChannelCollection_ == nullptr) {
throw cms::Exception("NullPointerError") << "PixelFEDChannelCollection not set in chooseScenario function.\n";
}
e.put(std::move(PixelFEDChannelCollection_), PixelDigiCollectionDM_);
}

for (const auto& iu : pDD->detUnits()) {
if (iu->type().isTrackerPixel()) {
edm::DetSet<PixelDigi> collector(iu->geographicalId().rawId());
edm::DetSet<PixelDigiSimLink> linkcollector(iu->geographicalId().rawId()); // ignored as DigiSimLinks are combined separately

Expand Down
51 changes: 49 additions & 2 deletions SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,55 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector<Pileup

bool SiPixelDigitizerAlgorithm::killBadFEDChannels() const {return KillBadFEDChannels;}

std::unique_ptr<PixelFEDChannelCollection> SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *engine){

std::unique_ptr<PixelFEDChannelCollection> SiPixelDigitizerAlgorithm::chooseScenario(
const std::vector<PileupSummaryInfo>& ps, CLHEP::HepRandomEngine* engine) {
std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ = nullptr;
pixelEfficiencies_.PixelFEDChannelCollection_ = nullptr;

std::vector<int> bunchCrossing;
std::vector<float> TrueInteractionList;

for (unsigned int i = 0; i < ps.size(); i++) {
bunchCrossing.push_back(ps[i].getBunchCrossing());
TrueInteractionList.push_back(ps[i].getTrueNumInteractions());
}

int pui = 0, p = 0;
std::vector<int>::const_iterator pu;
std::vector<int>::const_iterator pu0 = bunchCrossing.end();

for (pu = bunchCrossing.begin(); pu != bunchCrossing.end(); ++pu) {
if (*pu == 0) {
pu0 = pu;
p = pui;
}
pui++;
}

if (pu0 != bunchCrossing.end()) {
unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me
const auto& theProbabilitiesPerScenario = scenarioProbabilityHandle->getProbabilities(PUBin);
std::vector<double> probabilities;
probabilities.reserve(theProbabilitiesPerScenario.size());
for (auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++) {
probabilities.push_back(it->second);
}

CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size());
double x = randGeneral.shoot();
unsigned int index = x * probabilities.size() - 1;
const std::string& scenario = theProbabilitiesPerScenario.at(index).first;

PixelFEDChannelCollection_ = std::make_unique<PixelFEDChannelCollection>(quality_map->at(scenario));
pixelEfficiencies_.PixelFEDChannelCollection_ =
std::make_unique<PixelFEDChannelCollection>(quality_map->at(scenario));
}

return PixelFEDChannelCollection_;
}

std::unique_ptr<PixelFEDChannelCollection> SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo,
CLHEP::HepRandomEngine* engine) {
//Determine scenario to use for the current event based on pileup information

std::unique_ptr<PixelFEDChannelCollection> PixelFEDChannelCollection_ = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ class SiPixelDigitizerAlgorithm {
CLHEP::HepRandomEngine*);
void calculateInstlumiFactor(PileupMixingContent* puInfo);
void init_DynIneffDB(const edm::EventSetup&, const unsigned int&);
std::unique_ptr<PixelFEDChannelCollection> chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine*);

// for premixing
void calculateInstlumiFactor(const std::vector<PileupSummaryInfo> &ps, int bunchSpacing); // TODO: try to remove the duplication of logic...
void setSimAccumulator(const std::map<uint32_t, std::map<int, int> >& signalMap);

std::unique_ptr<PixelFEDChannelCollection> chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *);

std::unique_ptr<PixelFEDChannelCollection> chooseScenario(const std::vector<PileupSummaryInfo>& ps,
CLHEP::HepRandomEngine* engine);

bool killBadFEDChannels() const;
typedef std::unordered_map<std::string,PixelFEDChannelCollection> PixelFEDChannelCollectionMap;
const PixelFEDChannelCollectionMap* quality_map;
Expand Down