From 2f5d80a5f96bc7e8a0a428fba1b2f0a1fc324a0f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 24 Aug 2022 14:58:26 +0200 Subject: [PATCH] Replace getbylabel using token in CalibCalorimetry/CastorCalib Code check --- .../plugins/CastorPedestalsAnalysis.cc | 73 +++++-------------- 1 file changed, 19 insertions(+), 54 deletions(-) diff --git a/CalibCalorimetry/CastorCalib/plugins/CastorPedestalsAnalysis.cc b/CalibCalorimetry/CastorCalib/plugins/CastorPedestalsAnalysis.cc index 9494e7af17f4e..794e516652a83 100644 --- a/CalibCalorimetry/CastorCalib/plugins/CastorPedestalsAnalysis.cc +++ b/CalibCalorimetry/CastorCalib/plugins/CastorPedestalsAnalysis.cc @@ -83,13 +83,17 @@ class CastorPedestalsAnalysis : public edm::one::EDAnalyzer Bunches; + const edm::EDGetTokenT castorDigiCollectionToken_; + const edm::ESGetToken tok_cond_; + const edm::ESGetToken tok_map_; //Flag for saving histos - bool hiSaveFlag; - bool dumpXML; - bool verboseflag; + const bool hiSaveFlag; + const bool dumpXML; + const bool verboseflag; + const int firstTS; + const int lastTS; + bool firsttime; int runnum; - int firstTS; - int lastTS; std::string ROOTfilename; std::string pedsADCfilename; std::string pedsfCfilename; @@ -99,33 +103,26 @@ class CastorPedestalsAnalysis : public edm::one::EDAnalyzer tok_cond_; - edm::ESGetToken tok_map_; - TH1F* CASTORMeans; TH1F* CASTORWidths; // TH2F *dephist[4]; TH2F* dephist; - - bool firsttime; - - edm::InputTag castorDigiCollectionTag; }; CastorPedestalsAnalysis::CastorPedestalsAnalysis(const edm::ParameterSet& ps) - : castorDigiCollectionTag(ps.getParameter("castorDigiCollectionTag")) { + : castorDigiCollectionToken_( + consumes(ps.getParameter("castorDigiCollectionTag"))), + tok_cond_(esConsumes()), + tok_map_(esConsumes()), + hiSaveFlag(ps.getUntrackedParameter("hiSaveFlag", false)), + dumpXML(ps.getUntrackedParameter("dumpXML", false)), + verboseflag(ps.getUntrackedParameter("verbose", false)), + firstTS(ps.getUntrackedParameter("firstTS", 0)), + lastTS(ps.getUntrackedParameter("lastTS", 9)) { usesResource(TFileService::kSharedResource); - hiSaveFlag = ps.getUntrackedParameter("hiSaveFlag", false); - dumpXML = ps.getUntrackedParameter("dumpXML", false); - verboseflag = ps.getUntrackedParameter("verbose", false); - firstTS = ps.getUntrackedParameter("firstTS", 0); - lastTS = ps.getUntrackedParameter("lastTS", 9); firsttime = true; - - tok_cond_ = esConsumes(); - tok_map_ = esConsumes(); } CastorPedestalsAnalysis::~CastorPedestalsAnalysis() { @@ -294,30 +291,10 @@ CastorPedestalsAnalysis::~CastorPedestalsAnalysis() { // CastorCondXML::dumpObject (outStream5, runnum, runnum, runnum, XMLtag, 1, (*rawPedsItem), (*rawWidthsItem)); } - /* - if (hiSaveFlag) { - theFile->Write(); - } else { - theFile->cd(); - theFile->cd("CASTOR"); - CASTORMeans->Write(); - CASTORWidths->Write(); - } - theFile->cd(); - dephist->Write(); - */ dephist->SetDrawOption("colz"); dephist->GetXaxis()->SetTitle("module"); dephist->GetYaxis()->SetTitle("sector"); - //for (int n=0; n!= 4; n++) - //{ - //dephist[n]->Write(); - //dephist[n]->SetDrawOption("colz"); - //dephist[n]->GetXaxis()->SetTitle("i#eta"); - //dephist[n]->GetYaxis()->SetTitle("i#phi"); - //} - std::stringstream tempstringout; tempstringout << runnum; std::string name1 = tempstringout.str() + "_pedplots_1d.png"; @@ -364,8 +341,7 @@ CastorPedestalsAnalysis::~CastorPedestalsAnalysis() { // ------------ method called to for each event ------------ void CastorPedestalsAnalysis::analyze(const edm::Event& e, const edm::EventSetup& iSetup) { - edm::Handle castor; - e.getByLabel(castorDigiCollectionTag, castor); + const edm::Handle& castor = e.getHandle(castorDigiCollectionToken_); auto conditions = &iSetup.getData(tok_cond_); const CastorQIEShape* shape = conditions->getCastorShape(); @@ -386,21 +362,10 @@ void CastorPedestalsAnalysis::analyze(const edm::Event& e, const edm::EventSetup edm::Service fs; fs->mkdir("CASTOR"); - /* - theFile = new TFile(ROOTfilename.c_str(), "RECREATE"); - theFile->cd(); - // Create sub-directories - theFile->mkdir("CASTOR"); - theFile->cd(); - */ CASTORMeans = fs->make("All Ped Means CASTOR", "All Ped Means CASTOR", 100, 0, 9); CASTORWidths = fs->make("All Ped Widths CASTOR", "All Ped Widths CASTOR", 100, 0, 3); dephist = fs->make("Pedestals (ADC)", "All Castor", 14, 0., 14.5, 16, .5, 16.5); - // dephist[0] = fs->make("Pedestals (ADC)","Depth 1",89, -44, 44, 72, .5, 72.5); - // dephist[1] = fs->make("Pedestals (ADC)","Depth 2",89, -44, 44, 72, .5, 72.5); - // dephist[2] = fs->make("Pedestals (ADC)","Depth 3",89, -44, 44, 72, .5, 72.5); - // dephist[3] = fs->make("Pedestals (ADC)","Depth 4",89, -44, 44, 72, .5, 72.5); const CastorElectronicsMap* myRefEMap = &iSetup.getData(tok_map_); std::vector listEMap = myRefEMap->allPrecisionId();