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

apply necessary changes to test the phase-2 AlCaReco workflow #40542

Merged
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
108 changes: 61 additions & 47 deletions Alignment/OfflineValidation/plugins/GeneralPurposeTrackAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// user include files
#include "CommonTools/TrackerMap/interface/TrackerMap.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CondCore/SiPixelPlugins/interface/SiPixelPayloadInspectorHelper.h"
#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h"
#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
#include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
Expand Down Expand Up @@ -90,10 +91,14 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
GeneralPurposeTrackAnalyzer(const edm::ParameterSet &pset)
: geomToken_(esConsumes()),
magFieldToken_(esConsumes<edm::Transition::BeginRun>()),
latencyToken_(esConsumes<edm::Transition::BeginRun>()),
geomTokenBR_(esConsumes<edm::Transition::BeginRun>()),
trackerTopologyTokenBR_(esConsumes<edm::Transition::BeginRun>()),
siPixelFedCablingMapTokenBR_(esConsumes<edm::Transition::BeginRun>()) {
doLatencyAnalysis_ = pset.getParameter<bool>("doLatencyAnalysis");
if (doLatencyAnalysis_) {
latencyToken_ = esConsumes<edm::Transition::BeginRun>();
}

usesResource(TFileService::kSharedResource);

TkTag_ = pset.getParameter<edm::InputTag>("TkTag");
Expand Down Expand Up @@ -152,7 +157,7 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
// tokens for the event setup
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> latencyToken_;
edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> latencyToken_;

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomTokenBR_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyTokenBR_;
Expand Down Expand Up @@ -282,9 +287,8 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
int ievt;
int itrks;
int mode;
bool firstEvent_;
bool isPhase1_;
float etaMax_;
SiPixelPI::phase phase_;

const TrackerGeometry *trackerGeometry_;

Expand All @@ -294,6 +298,7 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
edm::InputTag VerticesTag_;

bool isCosmics_;
bool doLatencyAnalysis_;

edm::EDGetTokenT<reco::TrackCollection> theTrackCollectionToken_;
edm::EDGetTokenT<edm::TriggerResults> hltresultsToken_;
Expand All @@ -310,18 +315,10 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
{
ievt++;

edm::Handle<reco::TrackCollection> trackCollection = event.getHandle(theTrackCollectionToken_);

// geometry setup
const TrackerGeometry *theGeometry = &setup.getData(geomToken_);

// switch on the phase1
if ((theGeometry->isThere(GeomDetEnumerators::P1PXB)) || (theGeometry->isThere(GeomDetEnumerators::P1PXEC))) {
isPhase1_ = true;
} else {
isPhase1_ = false;
}

edm::Handle<reco::TrackCollection> trackCollection = event.getHandle(theTrackCollectionToken_);
const reco::TrackCollection tC = *(trackCollection.product());
itrks += tC.size();

Expand Down Expand Up @@ -387,12 +384,12 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
int row = cluster.x() - 0.5, col = cluster.y() - 0.5;
int rocId = coord_.roc(detId, std::make_pair(row, col));

rocsToMask.set(rocId);
pixelrocsmap_->fillSelectedRocs(detid_db, rocsToMask, 1);

if (!isPhase1_) {
if (phase_ == SiPixelPI::phase::zero) {
pmap->fill(detid_db, 1);
} else {
} else if (phase_ == SiPixelPI::phase::one) {
rocsToMask.set(rocId);
pixelrocsmap_->fillSelectedRocs(detid_db, rocsToMask, 1);

if (subid == PixelSubdetector::PixelBarrel) {
pixelmap->fillBarrelBin("entriesBarrel", detid_db, 1);
} else {
Expand Down Expand Up @@ -426,7 +423,7 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
}
}
} else {
if ((*iHit)->isValid()) {
if ((*iHit)->isValid() && phase_ != SiPixelPI::phase::two) {
tmap->fill(detId.rawId(), 1);
}
}
Expand Down Expand Up @@ -720,19 +717,37 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
<< "run number:" << run.run() << " magnetic field: " << B_ << " [T]" << std::endl;
}

//SiStrip Latency
const SiStripLatency *apvlat = &setup.getData(latencyToken_);
if (apvlat->singleReadOutMode() == 1) {
mode = 1; // peak mode
} else if (apvlat->singleReadOutMode() == 0) {
mode = -1; // deco mode
const TrackerGeometry *trackerGeometry = &setup.getData(geomTokenBR_);
if (trackerGeometry->isThere(GeomDetEnumerators::P2PXB) || trackerGeometry->isThere(GeomDetEnumerators::P2PXEC)) {
phase_ = SiPixelPI::phase::two;
} else if (trackerGeometry->isThere(GeomDetEnumerators::P1PXB) ||
trackerGeometry->isThere(GeomDetEnumerators::P1PXEC)) {
phase_ = SiPixelPI::phase::one;
} else {
phase_ = SiPixelPI::phase::zero;
}

// if it's a phase-2 geometry there are no phase-1 conditions
if (phase_ == SiPixelPI::phase::two) {
mode = 0;
} else {
if (doLatencyAnalysis_) {
//SiStrip Latency
const SiStripLatency *apvlat = &setup.getData(latencyToken_);
if (apvlat->singleReadOutMode() == 1) {
mode = 1; // peak mode
} else if (apvlat->singleReadOutMode() == 0) {
mode = -1; // deco mode
}
} else {
mode = 0;
}
}

conditionsMap_[run.run()].first = mode;
conditionsMap_[run.run()].second = B_;

// init the sipixel coordinates
const TrackerGeometry *trackerGeometry = &setup.getData(geomTokenBR_);
const TrackerTopology *trackerTopology = &setup.getData(trackerTopologyTokenBR_);
const SiPixelFedCablingMap *siPixelFedCablingMap = &setup.getData(siPixelFedCablingMapTokenBR_);

Expand All @@ -753,8 +768,6 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
}

TH1D::SetDefaultSumw2(kTRUE);

isPhase1_ = true;
etaMax_ = 3.0;

ievt = 0;
Expand Down Expand Up @@ -971,8 +984,6 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR

// clang-format on

firstEvent_ = true;

} //beginJob

//*************************************************************
Expand Down Expand Up @@ -1059,28 +1070,30 @@ class GeneralPurposeTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchR
fieldByRun_->GetXaxis()->SetBinLabel((the_r - theRuns_.front()) + 1, std::to_string(the_r).c_str());
}

if (!isPhase1_) {
pmap->save(true, 0, 0, "PixelHitMap.pdf", 600, 800);
pmap->save(true, 0, 0, "PixelHitMap.png", 500, 750);
}
if (phase_ < SiPixelPI::phase::two) {
if (phase_ == SiPixelPI::phase::zero) {
pmap->save(true, 0, 0, "PixelHitMap.pdf", 600, 800);
pmap->save(true, 0, 0, "PixelHitMap.png", 500, 750);
}

tmap->save(true, 0, 0, "StripHitMap.pdf");
tmap->save(true, 0, 0, "StripHitMap.png");
tmap->save(true, 0, 0, "StripHitMap.pdf");
tmap->save(true, 0, 0, "StripHitMap.png");

gStyle->SetPalette(kRainBow);
pixelmap->beautifyAllHistograms();
gStyle->SetPalette(kRainBow);
pixelmap->beautifyAllHistograms();

TCanvas cB("CanvBarrel", "CanvBarrel", 1200, 1000);
pixelmap->drawBarrelMaps("entriesBarrel", cB);
cB.SaveAs("pixelBarrelEntries.png");
TCanvas cB("CanvBarrel", "CanvBarrel", 1200, 1000);
pixelmap->drawBarrelMaps("entriesBarrel", cB);
cB.SaveAs("pixelBarrelEntries.png");

TCanvas cF("CanvForward", "CanvForward", 1600, 1000);
pixelmap->drawForwardMaps("entriesForward", cF);
cF.SaveAs("pixelForwardEntries.png");
TCanvas cF("CanvForward", "CanvForward", 1600, 1000);
pixelmap->drawForwardMaps("entriesForward", cF);
cF.SaveAs("pixelForwardEntries.png");

TCanvas cRocs = TCanvas("cRocs", "cRocs", 1200, 1600);
pixelrocsmap_->drawMaps(cRocs, "Pixel on-track clusters occupancy");
cRocs.SaveAs("Phase1PixelROCMaps_fullROCs.png");
TCanvas cRocs = TCanvas("cRocs", "cRocs", 1200, 1600);
pixelrocsmap_->drawMaps(cRocs, "Pixel on-track clusters occupancy");
cRocs.SaveAs("Phase1PixelROCMaps_fullROCs.png");
}
}

//*************************************************************
Expand Down Expand Up @@ -1138,6 +1151,7 @@ void GeneralPurposeTrackAnalyzer::fillDescriptions(edm::ConfigurationDescription
desc.add<edm::InputTag>("BeamSpotTag", edm::InputTag("offlineBeamSpot"));
desc.add<edm::InputTag>("VerticesTag", edm::InputTag("offlinePrimaryVertices"));
desc.add<bool>("isCosmics", false);
desc.add<bool>("doLatencyAnalysis", true);
descriptions.addWithDefaultLabel(desc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
'/store/relval/CMSSW_12_5_0_pre5/RelValTTbar_14TeV/GEN-SIM-RECO/PU_125X_mcRun3_2022_realistic_v3-v1/10000/0136c33f-3ff9-4602-8578-906ae6e0160b.root'
)

filesDefaultMC_TTBarPUPhase2 = cms.untracked.vstring(
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/ALCARECO/TkAlMinBias-125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/27b7ab93-1d2b-4f4a-a98e-68386c314b5e.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/ALCARECO/TkAlMinBias-125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/45b3c086-a3ac-429e-845f-4796ba8f2d3f.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/ALCARECO/TkAlMinBias-125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/b82f7b2d-1e7f-43ce-a7bc-dc44ce3b2358.root'
)

filesDefaultMC_TTBarPUPhase2RECO = cms.untracked.vstring(
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/22e22ae6-a353-4f2e-815e-cc5efee37af9.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/87ea36b3-b17a-4f5a-ab5a-0973e684db1b.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/e9de823f-35f7-4493-ba4a-c1d9671d2d70.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/9c5055d6-5f74-4e26-8166-1f65cc7e6e5c.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/678538ab-9e17-4880-b27a-b7b5b045124d.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/7f9af44d-aff5-41be-9d0d-3cbbd35b19dd.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/d8d6b261-4897-4ee4-9210-d68041b3dd67.root',
'/store/relval/CMSSW_12_5_3/RelValMinBias_14TeV/GEN-SIM-RECO/125X_mcRun4_realistic_v5_2026D88PU-v1/2590000/04fa3331-7c8a-420d-b07a-d677e2caf992.root'
)

filesDefaultData_JetHTRun2018D = cms.untracked.vstring(
'/store/data/Run2018D/JetHT/ALCARECO/TkAlMinBias-12Nov2019_UL2018-v3/270000/AF80DFBE-C277-1142-AE8F-71FE4444370A.root'
)
Expand Down
Loading