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

Updated CosmicRateAnalyzer: MagField & Hits added, deleted latency #32278

Merged
merged 3 commits into from
Dec 1, 2020
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
48 changes: 35 additions & 13 deletions Alignment/TrackerAlignment/plugins/CosmicRateAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
/**\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

*/
// Originally created: Justyna Magdalena Tomaszewska,,,
// Revisited by: Ashutosh Bhardwaj and Kirti Ranjan
// Further Developed by: Sumit Keshri ([email protected])
// Further Developed by: Sumit Keshri ([email protected]) & Saumya ([email protected])
//
// Created: Sat, 30 May 2015 20:14:35 GMT
//
Expand Down Expand Up @@ -55,10 +55,9 @@ 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 "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"
Expand Down Expand Up @@ -96,7 +95,7 @@ class CosmicRateAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clustercollectionToken_;
edm::EDGetTokenT<reco::MuonCollection> muonTags_;
edm::RunNumber_t lastrunnum;
double lastruntime;
double lastruntime, magField;
edm::Service<TFileService> fs;

unsigned int DetectorID;
Expand Down Expand Up @@ -148,6 +147,12 @@ class CosmicRateAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm:
std::vector<double> dz;
std::vector<double> nvh;
std::vector<double> DTtime;
std::vector<int> nh_BPIX;
std::vector<int> nh_FPIX;
std::vector<int> nh_TIB;
std::vector<int> nh_TOB;
std::vector<int> nh_TID;
std::vector<int> nh_TEC;
};

//
Expand Down Expand Up @@ -195,6 +200,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 ------------
Expand All @@ -205,8 +216,10 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
edm::Handle<reco::TrackCollection> tracks;
iEvent.getByToken(trackTags_, tracks);

edm::ESHandle<MagneticField> magfield;
iSetup.get<IdealMagneticFieldRecord>().get(magfield);
edm::ESHandle<MagneticField> magFieldHandle_;
iSetup.get<IdealMagneticFieldRecord>().get(magFieldHandle_);
magField = -9999;
magField = magFieldHandle_.product()->inTesla(GlobalPoint(0, 0, 0)).mag();

edm::ESHandle<TrackerTopology> tTopo;
iSetup.get<TrackerTopologyRcd>().get(tTopo);
Expand All @@ -219,9 +232,6 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
lastruntime = t_end - t_begin;
lastrunnum = iEvent.getRun().run();

edm::ESHandle<SiStripLatency> apvlat;
iSetup.get<SiStripLatencyRcd>().get(apvlat);

if (!tracks->empty())
v_ntrk.push_back(tracks->size());

Expand All @@ -238,6 +248,12 @@ 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;
Expand All @@ -264,7 +280,6 @@ void CosmicRateAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
if (PixelSubdetector::PixelBarrel == subdetId1) {
++nhitinBPIX;
++nhitinPIXEL;
PixelBarrelName pxbId1(detId1);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Hit information in PixelEndcap //
Expand Down Expand Up @@ -389,7 +404,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);
Expand Down
4 changes: 2 additions & 2 deletions Alignment/TrackerAlignment/test/cosmicRateAnalyzer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)