Skip to content

Commit

Permalink
Merge pull request #27912 from mmusich/fixPremixingForStuckTBM
Browse files Browse the repository at this point in the history
Fix simulation of the pixel bad components on the FED channel basis for PreMixing
  • Loading branch information
cmsbuild authored Sep 3, 2019
2 parents da319d1 + d1a7e77 commit a329cef
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
9 changes: 9 additions & 0 deletions SimTracker/SiPixelDigitizer/plugins/PreMixingSiPixelWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ PreMixingSiPixelWorker::PreMixingSiPixelWorker(const edm::ParameterSet& ps,
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 @@ -280,6 +281,14 @@ void PreMixingSiPixelWorker::put(edm::Event& e,
iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
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());
Expand Down
47 changes: 47 additions & 0 deletions SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,53 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector<Pileup

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

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,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(const std::vector<PileupSummaryInfo>& ps,
CLHEP::HepRandomEngine* engine);

std::unique_ptr<PixelFEDChannelCollection> chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine*);
bool killBadFEDChannels() const;
typedef std::unordered_map<std::string, PixelFEDChannelCollection> PixelFEDChannelCollectionMap;
const PixelFEDChannelCollectionMap* quality_map;
Expand Down

0 comments on commit a329cef

Please sign in to comment.