Skip to content

Commit

Permalink
cleanup and use fill description
Browse files Browse the repository at this point in the history
  • Loading branch information
sroychow committed Nov 17, 2021
1 parent 2e55608 commit 99d0671
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,28 @@
//
// Author: Suvankar Roy Chowdhury
//
#include <memory>
#include<math.h>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
// DQM Histograming
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "CUDADataFormats/Track/interface/PixelTrackHeterogeneous.h"
#include "CUDADataFormats/Common/interface/HostProduct.h"
#include "CUDADataFormats/SiPixelCluster/interface/gpuClusteringConstants.h"
#include "CUDADataFormats/Common/interface/HostProduct.h"

class SiPixelPhase1MonitorTrackSoA : public DQMEDAnalyzer {
public:
explicit SiPixelPhase1MonitorTrackSoA(const edm::ParameterSet&);
~SiPixelPhase1MonitorTrackSoA() override;
void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
//static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
edm::EDGetTokenT<PixelTrackHeterogeneous> tokenSoATrack_;
Expand All @@ -55,7 +49,7 @@ class SiPixelPhase1MonitorTrackSoA : public DQMEDAnalyzer {

SiPixelPhase1MonitorTrackSoA::SiPixelPhase1MonitorTrackSoA(const edm::ParameterSet& iConfig) {
tokenSoATrack_ = consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelTrackSrc"));
topFolderName_ = iConfig.getParameter<std::string>("TopFolderName");//"SiPixelHeterogeneous/PixelTrackSoA";
topFolderName_ = iConfig.getParameter<std::string>("TopFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA";
}

SiPixelPhase1MonitorTrackSoA::~SiPixelPhase1MonitorTrackSoA() {
Expand All @@ -69,29 +63,19 @@ SiPixelPhase1MonitorTrackSoA::~SiPixelPhase1MonitorTrackSoA() {
void SiPixelPhase1MonitorTrackSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
auto const& tsoa = *iEvent.get(tokenSoATrack_);
auto maxTracks = tsoa.stride();
//for future if we need to cut on quality
//auto const *quality = tsoa.qualityData();
//auto const &fit = tsoa.stateAtBS;
//auto const &hitIndices = tsoa.hitIndices;

int32_t nTracks=0;
int32_t nTracks = 0;
for (int32_t it = 0; it < maxTracks; ++it) {
auto nHits = tsoa.nHits(it);
if (nHits == 0)
break; // this is a guard
float pt = tsoa.pt(it);
if(!(pt > 0.)) continue;
float pt = tsoa.pt(it);
if (!(pt > 0.))
continue;
float chi2 = tsoa.chi2(it);
float phi = tsoa.phi(it);
float zip = tsoa.zip(it);
float eta = tsoa.eta(it);
std::cout << "Track chi2, pt, phi, z, eta:"
<< chi2 << "\t"
<< pt << "\t"
<< phi << "\t"
<< zip << "\t"
<< eta << "\t"
<< std::endl;
hchi2->Fill(chi2);
hnHits->Fill(nHits);
hpt->Fill(pt);
Expand All @@ -100,29 +84,34 @@ void SiPixelPhase1MonitorTrackSoA::analyze(const edm::Event& iEvent, const edm::
hz->Fill(zip);
nTracks++;
}
std::cout << "Number of SoA tracks>>>" << nTracks << std::endl;
hnTracks->Fill(nTracks);
}


//
// -- Book Histograms
//
void SiPixelPhase1MonitorTrackSoA::bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
//std::string top_folder = ""//
ibooker.cd();
ibooker.setCurrentFolder(topFolderName_);
hnTracks = ibooker.book1D("nTracks", ";Number of tracks per event;#entries", 1001, -0.5, 1000.5);
hnHits = ibooker.book1D("nRecHits", ";Number of all RecHits per track;#entries", 41, -0.5, 40.5);
hnHits = ibooker.book1D("nRecHits", ";Number of all RecHits per track;#entries", 15, -0.5, 14.5);
hchi2 = ibooker.book1D("nChi2ndof", ";Track chi-squared over ndof;#entries", 40, 0., 20.);
hpt = ibooker.book1D("pt", ";Track p_T;#entries", 200, 0., 200.);
heta = ibooker.book1D("eta", ";Track #eta;#entries", 30, -3., 3.);
hphi = ibooker.book1D("phi", ";Track #phi;#entries", 30, -M_PI, M_PI);
hz = ibooker.book1D("z", ";Track z;#entries", 30, -30., 30);
hz = ibooker.book1D("z", ";Track z;#entries", 30, -30., 30.);
}

//void SiPixelPhase1MonitorTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//}
void SiPixelPhase1MonitorTrackSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// monitorpixelTrackSoA
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelTrackSrc", edm::InputTag("pixelTracksSoA"));
desc.add<std::string>("TopFolderName", "SiPixelHeterogeneous/PixelTrackSoA");
descriptions.add("monitorpixelTrackSoA", desc);
// or use the following to generate the label from the module's C++ type
//descriptions.addWithDefaultLabel(desc);
}
DEFINE_FWK_MODULE(SiPixelPhase1MonitorTrackSoA);
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
//
// Author: Suvankar Roy Chowdhury
//
#include <memory>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -24,8 +22,6 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "CUDADataFormats/Vertex/interface/ZVertexHeterogeneous.h"
#include "CUDADataFormats/Common/interface/HostProduct.h"
#include "CUDADataFormats/Common/interface/HostProduct.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

class SiPixelPhase1MonitorVertexSoA : public DQMEDAnalyzer {
Expand All @@ -34,7 +30,7 @@ class SiPixelPhase1MonitorVertexSoA : public DQMEDAnalyzer {
~SiPixelPhase1MonitorVertexSoA() override;
void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
//static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
edm::EDGetTokenT<ZVertexHeterogeneous> tokenSoAVertex_;
Expand Down Expand Up @@ -67,54 +63,60 @@ SiPixelPhase1MonitorVertexSoA::~SiPixelPhase1MonitorVertexSoA() {
// -- Analyze
//
void SiPixelPhase1MonitorVertexSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
auto const &vsoa = *(iEvent.get(tokenSoAVertex_).get());
auto const& vsoa = *(iEvent.get(tokenSoAVertex_).get());
int nVertices = vsoa.nvFinal;
std::cout << "nVertices>>>>" << nVertices << std::endl;
auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
float x0 = 0, y0 = 0, z0 = 0, dxdz = 0, dydz = 0;
float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.;
if (!bsHandle.isValid()) {
edm::LogWarning("PixelVertexProducer") << "No beamspot found. returning vertexes with (0,0,Z) ";
} else {
const reco::BeamSpot &bs = *bsHandle;
const reco::BeamSpot& bs = *bsHandle;
x0 = bs.x0();
y0 = bs.y0();
z0 = bs.z0();
dxdz = bs.dxdz();
dydz = bs.dydz();
}
for(int iv = 0; iv < nVertices; iv++) {
for (int iv = 0; iv < nVertices; iv++) {
auto z = vsoa.zv[iv];
auto x = x0 + dxdz * z;
auto y = y0 + dydz * z;
z+=z0;
z += z0;
hx->Fill(x);
hy->Fill(y);
hz->Fill(z);
if(vsoa.ndof[iv] != 0)
hchi2->Fill(vsoa.chi2[iv]/vsoa.ndof[iv]);
if (vsoa.ndof[iv] != 0)
hchi2->Fill(vsoa.chi2[iv] / vsoa.ndof[iv]);
hptv2->Fill(vsoa.ptv2[iv]);
}
hnVertex->Fill(nVertices);
}


//
// -- Book Histograms
//
void SiPixelPhase1MonitorVertexSoA::bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
edm::Run const& iRun,
edm::EventSetup const& iSetup) {
//std::string top_folder = ""//
ibooker.cd();
ibooker.setCurrentFolder(topFolderName_);
hnVertex = ibooker.book1D("nVertex", ";# of Vertex;#entries", 201, -0.5, 200.5);
hnVertex = ibooker.book1D("nVertex", ";# of Vertex;#entries", 101, -0.5, 100.5);
hx = ibooker.book1D("vx", ";Vertez x;#entries", 30, -30., 30);
hy = ibooker.book1D("vy", ";Vertez y;#entries", 30, -30., 30);
hz = ibooker.book1D("vz", ";Vertez z;#entries", 30, -30., 30);
hchi2 = ibooker.book1D("chi2", ";Vertex chi-squared over ndof;#entries", 40, 0., 20.);
hptv2 = ibooker.book1D("ptsq", ";Vertex p_T squared;#entries", 200, 0., 200.);
}

//void SiPixelPhase1MonitorVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//}
void SiPixelPhase1MonitorVertexSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// monitorpixelVertexSoA
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelVertexSrc", edm::InputTag("pixelVerticesSoA"));
desc.add<edm::InputTag>("beamSpotSrc", edm::InputTag("offlineBeamSpot"));
desc.add<std::string>("TopFolderName", "SiPixelHeterogeneous/PixelVertexSoA");
descriptions.add("monitorpixelVertexSoA", desc);
// or use the following to generate the label from the module's C++ type
//descriptions.addWithDefaultLabel(desc);
}
DEFINE_FWK_MODULE(SiPixelPhase1MonitorVertexSoA);
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import FWCore.ParameterSet.Config as cms
from DQM.SiPixelPhase1Heterogeneous.SiPixelPhase1MonitorTrackSoA_cfi import *
from DQM.SiPixelPhase1Heterogeneous.SiPixelPhase1MonitorVertexSoA_cfi import *
#from DQM.SiPixelPhase1Heterogeneous.SiPixelPhase1MonitorDigiSoA_cfi import *
from DQM.SiPixelPhase1Heterogeneous.monitorpixelTrackSoA_cfi import *
from DQM.SiPixelPhase1Heterogeneous.monitorpixelVertexSoA_cfi import *

monitorpixelsoa = cms.Task(monitorpixelDigi,
monitorpixelTrackSoA)
#,
# monitorpixelVertexSoA,
# )
monitorpixelSoASource = cms.Sequence(monitorpixelTrackSoA * monitorpixelVertexSoA)

This file was deleted.

This file was deleted.

0 comments on commit 99d0671

Please sign in to comment.