From e5328bddbd32d156b5dd12386b2e2ba8fd389f58 Mon Sep 17 00:00:00 2001 From: ssaumya Date: Wed, 25 Nov 2020 12:53:15 +0530 Subject: [PATCH 1/3] MagField & Hits, deleted latency --- .../plugins/CosmicRateAnalyzer.cc | 52 ++++++++++++++----- .../test/cosmicRateAnalyzer_cfg.py | 4 +- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc index 76dcab07851d9..25b8d63dedda1 100644 --- a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc +++ b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc @@ -6,9 +6,9 @@ /**\class CosmicRateAnalyzer CosmicRateAnalyzer.cc CosmicTrackTool/CosmicRateAnalyzer/plugins/CosmicRateAnalyzer.cc Description : - This Analyzer creates tuple, having necessary infromation for cosmic track and event rate calculations. -Tuple created by this analyzer also have some kinematical information. This tuple is input of some offline -macros that make rate plots and kinematical plots. + This Analyzer creates tuple, having necessary infromation for Cosmic Track Rate and Event Rate calculations. + Tuples created by this analyzer also have some kinematic information. This tuple is input to some offline + macros that make Rate plots and Kinematical plots. Implementation : Documentation for running this tool is described in twiki : https://twiki.cern.ch/twiki/bin/view/CMS/TkAlCosmicsRateMonitoring @@ -16,7 +16,7 @@ Implementation : Documentation for running this tool is described in twiki : */ // Originally created: Justyna Magdalena Tomaszewska,,, // Revisited by: Ashutosh Bhardwaj and Kirti Ranjan -// Further Developed by: Sumit Keshri (sumit.keshri@cern.ch) +// Further Developed by: Sumit Keshri (sumit.keshri@cern.ch) & Saumya (saumya.saumya@cern.ch) // // Created: Sat, 30 May 2015 20:14:35 GMT // @@ -55,10 +55,11 @@ Implementation : Documentation for running this tool is described in twiki : #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" -#include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" +#include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" +#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSetVector.h" @@ -96,7 +97,7 @@ class CosmicRateAnalyzer : public edm::one::EDAnalyzer > clustercollectionToken_; edm::EDGetTokenT muonTags_; edm::RunNumber_t lastrunnum; - double lastruntime; + double lastruntime, magField; edm::Service fs; unsigned int DetectorID; @@ -148,6 +149,13 @@ class CosmicRateAnalyzer : public edm::one::EDAnalyzer dz; std::vector nvh; std::vector DTtime; + std::vector nh_BPIX; + std::vector nh_FPIX; + std::vector nh_TIB; + std::vector nh_TOB; + std::vector nh_TID; + std::vector nh_TEC; + }; // @@ -195,6 +203,12 @@ void CosmicRateAnalyzer::ClearInEventLoop() { dz.clear(); nvh.clear(); DTtime.clear(); + nh_BPIX.clear(); + nh_FPIX.clear(); + nh_TIB.clear(); + nh_TOB.clear(); + nh_TID.clear(); + nh_TEC.clear(); } // ------------ method called for each event ------------ @@ -205,8 +219,10 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup edm::Handle tracks; iEvent.getByToken(trackTags_, tracks); - edm::ESHandle magfield; - iSetup.get().get(magfield); + edm::ESHandle magFieldHandle_; + iSetup.get().get(magFieldHandle_); + magField=-9999; + magField = magFieldHandle_.product()->inTesla(GlobalPoint(0,0,0)).mag(); edm::ESHandle tTopo; iSetup.get().get(tTopo); @@ -219,9 +235,6 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup lastruntime = t_end - t_begin; lastrunnum = iEvent.getRun().run(); - edm::ESHandle apvlat; - iSetup.get().get(apvlat); - if (!tracks->empty()) v_ntrk.push_back(tracks->size()); @@ -238,7 +251,13 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup d0.push_back(itTrack1->d0()); dz.push_back(itTrack1->dz()); nvh.push_back(itTrack1->numberOfValidHits()); - + nh_BPIX.push_back(itTrack1->hitPattern().numberOfValidPixelBarrelHits()); + nh_FPIX.push_back(itTrack1->hitPattern().numberOfValidPixelEndcapHits()); + nh_TIB.push_back(itTrack1->hitPattern().numberOfValidStripTIBHits()); + nh_TOB.push_back(itTrack1->hitPattern().numberOfValidStripTOBHits()); + nh_TID.push_back(itTrack1->hitPattern().numberOfValidStripTIDHits()); + nh_TEC.push_back(itTrack1->hitPattern().numberOfValidStripTECHits()); + int nhitinBPIX = 0; int nhitinFPIX = 0; int nhitinPIXEL = 0; @@ -389,7 +408,14 @@ void CosmicRateAnalyzer::beginJob() { treeEvent->Branch("dz", &dz); treeEvent->Branch("nvh", &nvh); treeEvent->Branch("ntrk", &ntrk); + treeEvent->Branch("nHitsBPIX", &nh_BPIX); + treeEvent->Branch("nHitsFPIX", &nh_FPIX); + treeEvent->Branch("nHitsTIB", &nh_TIB); + treeEvent->Branch("nHitsTOB", &nh_TOB); + treeEvent->Branch("nHitsTID", &nh_TID); + treeEvent->Branch("nHitsTEC", &nh_TEC); treeEvent->Branch("DTtime", &DTtime); + treeEvent->Branch("magField",&magField); treeRun->Branch("run_time", &run_time); treeRun->Branch("runnum", &runnum); treeRun->Branch("number_of_events", &number_of_events); diff --git a/Alignment/TrackerAlignment/test/cosmicRateAnalyzer_cfg.py b/Alignment/TrackerAlignment/test/cosmicRateAnalyzer_cfg.py index e414114deca39..96beb3fb0dedd 100644 --- a/Alignment/TrackerAlignment/test/cosmicRateAnalyzer_cfg.py +++ b/Alignment/TrackerAlignment/test/cosmicRateAnalyzer_cfg.py @@ -24,13 +24,13 @@ readFiles = cms.untracked.vstring() -readFiles = cms.untracked.vstring( FileUtils.loadListFromFile (os.environ['CMSSW_BASE']+'/src/CosmicRateTool/TrackAnalyzer/test/'+'fileList.txt') ) +readFiles = cms.untracked.vstring( FileUtils.loadListFromFile (os.environ['CMSSW_BASE']+'/src/Alignment/TrackerAlignment/test/'+'fileList.txt') ) process.source = cms.Source("PoolSource", fileNames = readFiles, ) process.TFileService = cms.Service("TFileService", fileName = cms.string("Cosmic_rate_tuple.root") ) -process.load("CosmicRateTool.TrackAnalyzer.cosmicRateAnalyzer_cfi") +process.load("Alignment.TrackerAlignment.cosmicRateAnalyzer_cfi") process.p = cms.Path(process.cosmicRateAnalyzer) From d882ee246cba1a8dee74ba04bd081fa7362d82c3 Mon Sep 17 00:00:00 2001 From: ssaumya Date: Wed, 25 Nov 2020 14:31:12 +0530 Subject: [PATCH 2/3] Removed extraneous header file, not being used --- Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc index 25b8d63dedda1..aeaccc9fe42c0 100644 --- a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc +++ b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc @@ -55,8 +55,6 @@ Implementation : Documentation for running this tool is described in twiki : #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" -#include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" -#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" @@ -283,7 +281,6 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup if (PixelSubdetector::PixelBarrel == subdetId1) { ++nhitinBPIX; ++nhitinPIXEL; - PixelBarrelName pxbId1(detId1); } /////////////////////////////////////////////////////////////////////////////////////////////////// // Hit information in PixelEndcap // From 42d3496b8d56403dc26e51b7e701d06474e859bd Mon Sep 17 00:00:00 2001 From: ssaumya Date: Wed, 25 Nov 2020 14:58:43 +0530 Subject: [PATCH 3/3] Corrected Formatting --- Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc index aeaccc9fe42c0..58be7798077ae 100644 --- a/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc +++ b/Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc @@ -153,7 +153,6 @@ class CosmicRateAnalyzer : public edm::one::EDAnalyzer nh_TOB; std::vector nh_TID; std::vector nh_TEC; - }; // @@ -219,8 +218,8 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup edm::ESHandle magFieldHandle_; iSetup.get().get(magFieldHandle_); - magField=-9999; - magField = magFieldHandle_.product()->inTesla(GlobalPoint(0,0,0)).mag(); + magField = -9999; + magField = magFieldHandle_.product()->inTesla(GlobalPoint(0, 0, 0)).mag(); edm::ESHandle tTopo; iSetup.get().get(tTopo); @@ -255,7 +254,7 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup nh_TOB.push_back(itTrack1->hitPattern().numberOfValidStripTOBHits()); nh_TID.push_back(itTrack1->hitPattern().numberOfValidStripTIDHits()); nh_TEC.push_back(itTrack1->hitPattern().numberOfValidStripTECHits()); - + int nhitinBPIX = 0; int nhitinFPIX = 0; int nhitinPIXEL = 0; @@ -412,7 +411,7 @@ void CosmicRateAnalyzer::beginJob() { treeEvent->Branch("nHitsTID", &nh_TID); treeEvent->Branch("nHitsTEC", &nh_TEC); treeEvent->Branch("DTtime", &DTtime); - treeEvent->Branch("magField",&magField); + treeEvent->Branch("magField", &magField); treeRun->Branch("run_time", &run_time); treeRun->Branch("runnum", &runnum); treeRun->Branch("number_of_events", &number_of_events);