Skip to content

Commit

Permalink
remove unmerged modules
Browse files Browse the repository at this point in the history
  • Loading branch information
wweiphy authored and mmusich committed Mar 14, 2022
1 parent d22b199 commit 61a6ba2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,9 @@ void SiPixelLorentzAnglePCLHarvester::beginRun(const edm::Run& iRun, const edm::

if (std::find(treatedIndices.begin(), treatedIndices.end(), i_index) != treatedIndices.end()) {
hists.detIdsList.at(i_index).push_back(rawId);
if (module >= 3 && module <= 6 && (layer == 3 || layer == 4)) {
int i_index_merge = (module - 1) / 2 + (layer - 3) * 2 + hists.nlay * hists.nModules_[hists.nlay - 1] +
(int)hists.BPixnewDetIds_.size();
hists.detIdsList.at(i_index_merge).push_back(rawId);
}
} else {
hists.detIdsList.insert(std::pair<uint32_t, std::vector<uint32_t>>(i_index, {rawId}));
treatedIndices.push_back(i_index);

if (module >= 3 && module <= 6 && (layer == 3 || layer == 4)) {
int i_index_merge = (module - 1) / 2 + (layer - 3) * 2 + hists.nlay * hists.nModules_[hists.nlay - 1] +
(int)hists.BPixnewDetIds_.size();
hists.detIdsList.insert(std::pair<uint32_t, std::vector<uint32_t>>(i_index_merge, {rawId}));
treatedIndices.push_back(i_index_merge);
}
}
}

Expand Down Expand Up @@ -266,29 +254,6 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS

hists.h_drift_depth_[i_index]->divide(
hists.h_drift_depth_adc_[i_index], hists.h_drift_depth_noadc_[i_index], 1., 1., "");

if ((i_module == 3 || i_module == 5) && (i_layer == 3 || i_layer == 4)) {
int i_index_merge = (i_module - 1) / 2 + (i_layer - 3) * 2 + hists.nlay * hists.nModules_[hists.nlay - 1] +
(int)hists.BPixnewDetIds_.size();

hists.h_drift_depth_[i_index_merge] = iGetter.get(
fmt::format("{}/h_drift_depth_layer{}_module{}_and_module{}", prefix_, i_layer, i_module, i_module + 1));

hists.h_drift_depth_adc_[i_index_merge] = iGetter.get(fmt::format(
"{}/h_drift_depth_adc_layer{}_module{}_and_module{}", prefix_, i_layer, i_module, i_module + 1));

hists.h_drift_depth_adc2_[i_index_merge] = iGetter.get(fmt::format(
"{}/h_drift_depth_adc2_layer{}_module{}_and_module{}", prefix_, i_layer, i_module, i_module + 1));

hists.h_drift_depth_noadc_[i_index_merge] = iGetter.get(fmt::format(
"{}/h_drift_depth_noadc_layer{}_module{}_and_module{}", prefix_, i_layer, i_module, i_module + 1));

hists.h_mean_[i_index_merge] = iGetter.get(
fmt::format("{}/h_mean_layer{}_module{}_and_module{}", dqmDir_, i_layer, i_module, i_module + 1));

hists.h_drift_depth_[i_index_merge]->divide(
hists.h_drift_depth_adc_[i_index_merge], hists.h_drift_depth_noadc_[i_index_merge], 1., 1., "");
}
}
}

Expand Down Expand Up @@ -354,7 +319,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS
// retrieve the number of bins from the other monitoring histogram
const auto& maxSect = hists.h_bySectOccupancy_->getNbinsX();
const double lo = -0.5;
const double hi = maxSect + 0.5;
const double hi = maxSect - 0.5;

// this will be booked in the Harvesting folder
iBooker.setCurrentFolder(fmt::format("{}Harvesting/SectorMonitoring", dqmDir_));
Expand Down Expand Up @@ -477,7 +442,6 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS
for (int i_layer = 1; i_layer <= hists.nlay; i_layer++) {
for (int i_module = 1; i_module <= hists.nModules_[i_layer - 1]; i_module++) {
int i_index = i_module + (i_layer - 1) * hists.nModules_[i_layer - 1];

if (hists.h_drift_depth_adc_[i_index] == nullptr)
continue;
//loop over bins in depth (z-local-coordinate) (in order to fit slices)
Expand All @@ -496,15 +460,6 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS
<< res.chi2 << "\t" << res.prob << "\t"
<< "null"
<< "\t" << res.tan_LA << "\t" << res.error_LA;

if ((i_module == 3 || i_module == 5) && (i_layer == 3 || i_layer == 4)) {
int i_index_merge = (i_module - 1) / 2 + (i_layer - 3) * 2 + hists.nlay * hists.nModules_[hists.nlay - 1] +
(int)hists.BPixnewDetIds_.size();
for (int i = 1; i <= hist_depth_; i++) {
findMean(h_drift_depth_adc_slice_, i, i_index_merge);
}
const auto& res_combine = fitAndStore(LorentzAngle, i_index_merge, i_layer, i_module);
}
}
} // end loop over modules and layers

Expand Down Expand Up @@ -681,8 +636,7 @@ SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore(

int nentries = hists.h_bySectOccupancy_->getBinContent(i_index); // number of on track hits in that sector

bool isNew = ((i_index > hists.nlay * hists.nModules_[hists.nlay - 1]) &&
(i_index <= (hists.nlay * hists.nModules_[hists.nlay - 1] + (int)hists.BPixnewDetIds_.size())));
bool isNew = (i_index > hists.nlay * hists.nModules_[hists.nlay - 1]);
int shiftIdx = i_index - hists.nlay * hists.nModules_[hists.nlay - 1] - 1;

LogDebug("SiPixelLorentzAnglePCLHarvester")
Expand All @@ -691,13 +645,8 @@ SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore(
const auto& detIdsToFill =
isNew ? std::vector<unsigned int>({hists.BPixnewDetIds_[shiftIdx]}) : hists.detIdsList.at(i_index);

if (i_index <= (hists.nlay * hists.nModules_[hists.nlay - 1] + (int)hists.BPixnewDetIds_.size())) {
LogDebug("SiPixelLorentzAnglePCLHarvester")
<< "index: " << i_index << " i_module: " << i_module << " i_layer: " << i_layer;
} else {
LogDebug("SiPixelLorentzAnglePCLHarvester") << "index: " << i_index << "combine i_module: " << i_module
<< "and i_module+1" << i_module + 1 << " i_layer: " << i_layer;
}
LogDebug("SiPixelLorentzAnglePCLHarvester")
<< "index: " << i_index << " i_module: " << i_module << " i_layer: " << i_layer;
for (const auto& id : detIdsToFill) {
LogDebug("SiPixelLorentzAnglePCLHarvester") << id << ",";
}
Expand All @@ -716,8 +665,6 @@ SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore(
hists.h_bySectDeltaLA_->setBinContent(i_index, deltaLA);

for (const auto& id : detIdsToFill) {
if (i_index > (hists.nlay * hists.nModules_[hists.nlay - 1] + (int)hists.BPixnewDetIds_.size()))
continue;
if (!theLAPayload->putLorentzAngle(id, LorentzAnglePerTesla_)) {
edm::LogError("SiPixelLorentzAnglePCLHarvester") << "[SiPixelLorentzAnglePCLHarvester::fitAndStore]: detid ("
<< i_layer << "," << i_module << ") already exists";
Expand All @@ -732,8 +679,6 @@ SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore(
hists.h_bySectDeltaLA_->setBinContent(i_index, 0.);

for (const auto& id : detIdsToFill) {
if (i_index > (hists.nlay * hists.nModules_[hists.nlay - 1] + (int)hists.BPixnewDetIds_.size()))
continue;
LorentzAnglePerTesla_ = currentLorentzAngle->getLorentzAngle(id);
if (!theLAPayload->putLorentzAngle(id, LorentzAnglePerTesla_)) {
edm::LogError("SiPixelLorentzAnglePCLHarvester") << "[SiPixelLorentzAnglePCLHarvester::fitAndStore]: detid ("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,21 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS
iHists.h_drift_depth_noadc_.at(i_index)->Fill(drift, depth, 1.);
iHists.h_bySectOccupancy_->Fill(i_index - 1); // histogram starts at 0

if (module_ >= 3 && module_ <= 6 && (layer_ == 3 || layer_ == 4)) {
int i_index_merge = (module_ - 1) / 2 + (layer_ - 3) * 2 +
iHists.nlay * iHists.nModules_[iHists.nlay - 1] +
(int)iHists.BPixnewDetIds_.size();

iHists.h_drift_depth_adc_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j]);
iHists.h_drift_depth_adc2_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
iHists.h_drift_depth_noadc_.at(i_index_merge)->Fill(drift, depth, 1.);
iHists.h_bySectOccupancy_->Fill(i_index_merge - 1);
if (tracker->getDetectorType(subDetID) == TrackerGeometry::ModuleType::Ph1PXB) {
if ((module_ == 3 || module_ == 5) && (layer_ == 3 || layer_ == 4)) {
int i_index_merge = i_index + 1;
iHists.h_drift_depth_adc_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j]);
iHists.h_drift_depth_adc2_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
iHists.h_drift_depth_noadc_.at(i_index_merge)->Fill(drift, depth, 1.);
iHists.h_bySectOccupancy_->Fill(i_index_merge - 1);
}
if ((module_ == 4 || module_ == 6) && (layer_ == 3 || layer_ == 4)) {
int i_index_merge = i_index - 1;
iHists.h_drift_depth_adc_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j]);
iHists.h_drift_depth_adc2_.at(i_index_merge)->Fill(drift, depth, pixinfo_.adc[j] * pixinfo_.adc[j]);
iHists.h_drift_depth_noadc_.at(i_index_merge)->Fill(drift, depth, 1.);
iHists.h_bySectOccupancy_->Fill(i_index_merge - 1);
}
}

} else {
Expand Down Expand Up @@ -705,12 +711,11 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
edm::Run const& run,
edm::EventSetup const& iSetup) {
// book the by partition monitoring
const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size() +
4; // add 4 more for combined modules
const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size();

iBooker.setCurrentFolder(fmt::sprintf("%s/SectorMonitoring", folder_.data()));
iHists.h_bySectOccupancy_ = iBooker.book1D(
"h_bySectorOccupancy", "hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect + 0.5);
"h_bySectorOccupancy", "hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect - 0.5);

iBooker.setCurrentFolder(folder_);
static constexpr double min_depth_ = -100.;
Expand All @@ -736,26 +741,6 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
i_layer,
i_module);
iHists.h_mean_[i_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);

if ((i_module == 3 || i_module == 5) && (i_layer == 3 || i_layer == 4)) {
int i_index_merge = (i_module - 1) / 2 + (i_layer - 3) * 2 + iHists.nlay * iHists.nModules_[iHists.nlay - 1] +
(int)iHists.BPixnewDetIds_.size();

std::string binName = fmt::sprintf("BPix Layer%i Module %i and Module %i", i_layer, i_module, i_module + 1);
LogDebug("SiPixelLorentzAnglePCLWorker") << " i_index_merge: " << i_index_merge << " bin name: " << binName
<< " (i_layer: " << i_layer << " i_module:" << i_module << " and "
<< " i_module:" << i_module + 1 << ")";

iHists.h_bySectOccupancy_->setBinLabel(i_index_merge, binName);

sprintf(name, "h_mean_layer%i_module%i_and_module%i", i_layer, i_module, i_module + 1);
sprintf(title,
"average drift vs depth layer%i module%i_and_module%i; production depth [#mum]; #LTdrift#GT [#mum]",
i_layer,
i_module,
i_module + 1);
iHists.h_mean_[i_index_merge] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);
}
}
}
for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) {
Expand Down Expand Up @@ -798,50 +783,6 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
sprintf(title, "depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
iHists.h_drift_depth_[i_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

// merge modules 3 and 4 at L3 & L4, merge modules 5 and 6 at L3 & L4
if ((i_module == 3 || i_module == 5) && (i_layer == 3 || i_layer == 4)) {
unsigned int i_index_merge = (i_module - 1) / 2 + (i_layer - 3) * 2 +
iHists.nlay * iHists.nModules_[iHists.nlay - 1] +
(int)iHists.BPixnewDetIds_.size();

sprintf(name, "h_drift_depth_adc_layer%i_module%i_and_module%i", i_layer, i_module, i_module + 1);
sprintf(title,
"depth vs drift (ADC) layer%i module%i_and_module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module,
i_module + 1);
iHists.h_drift_depth_adc_[i_index_merge] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_adc2_layer%i_module%i_and_module%i", i_layer, i_module, i_module + 1);
sprintf(title,
"depth vs drift (ADC^{2}) layer%i module%i_and_module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module,
i_module + 1);
iHists.h_drift_depth_adc2_[i_index_merge] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_noadc_layer%i_module%i_and_module%i", i_layer, i_module, i_module + 1);
sprintf(title,
"depth vs drift (no ADC) layer%i module%i_and_module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module,
i_module + 1);
iHists.h_drift_depth_noadc_[i_index_merge] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_layer%i_module%i_and_module%i", i_layer, i_module, i_module + 1);
sprintf(title,
"depth vs drift layer%i module%i_and_module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module,
i_module + 1);

iHists.h_drift_depth_[i_index_merge] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
}
}
}

Expand Down

0 comments on commit 61a6ba2

Please sign in to comment.