Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
173 changes: 173 additions & 0 deletions CalibPPS/ESProducers/plugins/PPSPixelTopologyESSource.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/****************************************************************************
*
* CondFormats/PPSObjects/plugins/PPSPixelTopologyESSource.cc
*
* Description : - Loads PPSPixelTopology from the PPSPixelTopologyESSource_cfi.py
* config file.
*
*
* Author: F.Ferro ferro@ge.infn.it
*
*
****************************************************************************/

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/SourceFactory.h"
#include "FWCore/Framework/interface/ModuleFactory.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/ESProducts.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
#include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h"

#include <memory>

/**
* \brief Loads PPSPixelTopology from a config file.
**/

class PPSPixelTopologyESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
public:
PPSPixelTopologyESSource(const edm::ParameterSet&);
~PPSPixelTopologyESSource() override = default;

std::unique_ptr<PPSPixelTopology> produce(const PPSPixelTopologyRcd&);
static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
/// Set PPS Topology parameters to their values from config
void setPPSPixelTopology(const edm::ParameterSet&);
/// Fill PPSPixelTopology object
std::unique_ptr<PPSPixelTopology> fillPPSPixelTopology();

// Topology parameters
std::string runType_;
double pitch_simY_;
double pitch_simX_;
double thickness_;
unsigned short no_of_pixels_simX_;
unsigned short no_of_pixels_simY_;
unsigned short no_of_pixels_;
double simX_width_;
double simY_width_;
double dead_edge_width_;
double active_edge_sigma_;
double phys_active_edge_dist_;

protected:
/// sets infinite validity of this data
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue&,
edm::ValidityInterval&) override;
};

//----------------------------------------------------------------------------------------------------

PPSPixelTopologyESSource::PPSPixelTopologyESSource(const edm::ParameterSet& iConfig)
: runType_(""),
pitch_simY_(0.),
pitch_simX_(0.),
thickness_(0.),
no_of_pixels_simX_(0.),
no_of_pixels_simY_(0.),
no_of_pixels_(0.),
simX_width_(0.),
simY_width_(0.),
dead_edge_width_(0.),
active_edge_sigma_(0.),
phys_active_edge_dist_(0.) {
setPPSPixelTopology(iConfig);
setWhatProduced(this);
findingRecord<PPSPixelTopologyRcd>();
}

//----------------------------------------------------------------------------------------------------

std::unique_ptr<PPSPixelTopology> PPSPixelTopologyESSource::produce(const PPSPixelTopologyRcd&) {
auto topo = fillPPSPixelTopology();

edm::LogInfo("PPS") << "PixelTopologyESSource::produce \n" << *topo;

return topo;
}

//----------------------------------------------------------------------------------------------------

void PPSPixelTopologyESSource::setPPSPixelTopology(const edm::ParameterSet& iConfig) {
runType_ = iConfig.getParameter<std::string>("RunType");
pitch_simY_ = iConfig.getParameter<double>("PitchSimY");
pitch_simX_ = iConfig.getParameter<double>("PitchSimX");
thickness_ = iConfig.getParameter<double>("thickness");
no_of_pixels_simX_ = iConfig.getParameter<int>("noOfPixelSimX");
no_of_pixels_simY_ = iConfig.getParameter<int>("noOfPixelSimY");
no_of_pixels_ = iConfig.getParameter<int>("noOfPixels");
simX_width_ = iConfig.getParameter<double>("simXWidth");
simY_width_ = iConfig.getParameter<double>("simYWidth");
dead_edge_width_ = iConfig.getParameter<double>("deadEdgeWidth");
active_edge_sigma_ = iConfig.getParameter<double>("activeEdgeSigma");
phys_active_edge_dist_ = iConfig.getParameter<double>("physActiveEdgeDist");
}

//----------------------------------------------------------------------------------------------------

std::unique_ptr<PPSPixelTopology> PPSPixelTopologyESSource::fillPPSPixelTopology() {
auto p = std::make_unique<PPSPixelTopology>();

p->setRunType(runType_);
p->setPitchSimY(pitch_simY_);
p->setPitchSimX(pitch_simX_);
p->setThickness(thickness_);
p->setNoPixelsSimX(no_of_pixels_simX_);
p->setNoPixelsSimY(no_of_pixels_simY_);
p->setNoPixels(no_of_pixels_);
p->setSimXWidth(simX_width_);
p->setSimYWidth(simY_width_);
p->setDeadEdgeWidth(dead_edge_width_);
p->setActiveEdgeSigma(active_edge_sigma_);
p->setPhysActiveEdgeDist(phys_active_edge_dist_);
p->setActiveEdgeX(simX_width_ / 2. - phys_active_edge_dist_);
p->setActiveEdgeY(simY_width_ / 2. - phys_active_edge_dist_);

return p;
}

//----------------------------------------------------------------------------------------------------

void PPSPixelTopologyESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& key,
const edm::IOVSyncValue& iosv,
edm::ValidityInterval& oValidity) {
edm::LogInfo("PPS") << ">> PPSPixelTopologyESSource::setIntervalFor(" << key.name() << ")\n"
<< " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();

edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
oValidity = infinity;
}

//----------------------------------------------------------------------------------------------------

void PPSPixelTopologyESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("RunType", "Run3");
desc.add<double>("PitchSimY", 150e-3);
desc.add<double>("PitchSimX", 100e-3);
desc.add<double>("thickness", 0.23);
desc.add<int>("noOfPixelSimX", 160);
desc.add<int>("noOfPixelSimY", 156);
desc.add<int>("noOfPixels", 160 * 156);
desc.add<double>("simXWidth", 16.6);
desc.add<double>("simYWidth", 16.2);
desc.add<double>("deadEdgeWidth", 200e-3);
desc.add<double>("activeEdgeSigma", 0.02);
desc.add<double>("physActiveEdgeDist", 0.150);

descriptions.add("ppsPixelTopologyESSource", desc);
}

//----------------------------------------------------------------------------------------------------

DEFINE_FWK_EVENTSETUP_SOURCE(PPSPixelTopologyESSource);
17 changes: 17 additions & 0 deletions CalibPPS/ESProducers/python/ppsPixelTopologyESSourceRun2_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import FWCore.ParameterSet.Config as cms

ppsPixelTopologyESSource = cms.ESSource('PPSPixelTopologyESSource',
RunType = cms.string('Run2'),
PitchSimY = cms.double(0.15),
PitchSimX = cms.double(0.1),
thickness = cms.double(0.23),
noOfPixelSimX = cms.int32(160),
noOfPixelSimY = cms.int32(156),
noOfPixels = cms.int32(24960),
simXWidth = cms.double(16.6),
simYWidth = cms.double(24.4),
deadEdgeWidth = cms.double(0.2),
activeEdgeSigma = cms.double(0.02),
physActiveEdgeDist = cms.double(0.15),
appendToDataLabel = cms.string('')
)
9 changes: 9 additions & 0 deletions CalibPPS/ESProducers/python/ppsTopology_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import FWCore.ParameterSet.Config as cms

from CalibPPS.ESProducers.ppsPixelTopologyESSource_cfi import ppsPixelTopologyESSource

from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016
from Configuration.Eras.Modifier_ctpps_2017_cff import ctpps_2017
from Configuration.Eras.Modifier_ctpps_2018_cff import ctpps_2018

(ctpps_2016 | ctpps_2017 | ctpps_2018).toModify(ppsPixelTopologyESSource, RunType = cms.string('Run2'), simYWidth = cms.double(24.4) )
3 changes: 3 additions & 0 deletions CondCore/CTPPSPlugins/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h"
#include "CondFormats/PPSObjects/interface/PPSDirectSimulationData.h"
#include "CondFormats/DataRecord/interface/PPSDirectSimulationDataRcd.h"
#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
#include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h"

REGISTER_PLUGIN(CTPPSBeamParametersRcd, CTPPSBeamParameters);
REGISTER_PLUGIN(CTPPSPixelDAQMappingRcd, CTPPSPixelDAQMapping);
Expand All @@ -28,3 +30,4 @@ REGISTER_PLUGIN(RPMisalignedAlignmentRecord, CTPPSRPAlignmentCorrectionsData);
REGISTER_PLUGIN(PPSTimingCalibrationRcd, PPSTimingCalibration);
REGISTER_PLUGIN(CTPPSOpticsRcd, LHCOpticalFunctionsSetCollection);
REGISTER_PLUGIN(PPSDirectSimulationDataRcd, PPSDirectSimulationData);
REGISTER_PLUGIN(PPSPixelTopologyRcd, PPSPixelTopology);
10 changes: 10 additions & 0 deletions CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Author: F.Ferro

#ifndef CondFormats_DataRecord_PPSPixelTopologyRcd_h
#define CondFormats_DataRecord_PPSPixelTopologyRcd_h

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class PPSPixelTopologyRcd : public edm::eventsetup::EventSetupRecordImplementation<PPSPixelTopologyRcd> {};

#endif
14 changes: 14 additions & 0 deletions CondFormats/DataRecord/src/PPSPixelTopologyRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : PPSPixelTopologyRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: F.Ferro

#include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(PPSPixelTopologyRcd);
150 changes: 150 additions & 0 deletions CondFormats/PPSObjects/interface/PPSPixelTopology.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#ifndef CondFormats_PPSObjects_PPSPixelTopology_h
#define CondFormats_PPSObjects_PPSPixelTopology_h
// -*- C++ -*-
//
// Package: PPSObjects
// Class: PPSPixelTopology
//
/**\class PPSPixelTopology PPSPixelTopology.h CondFormats/PPSObjects/src/PPSPixelTopology.cc

Description: Internal topology of PPS detectors

Implementation:
<Notes on implementation>
*/
//

#include "CondFormats/Serialization/interface/Serializable.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CondFormats/PPSObjects/interface/CTPPSPixelIndices.h"
#include <cmath>

class PPSPixelTopology {
public:
// Constructor
PPSPixelTopology();
// Destructor
~PPSPixelTopology();

class PixelInfo {
public:
PixelInfo(double lower_simX_border,
double higher_simX_border,
double lower_simY_border,
double higher_simY_border,
double eff_factor,
unsigned short pixel_row_no,
unsigned short pixel_col_no)
: lower_simX_border_(lower_simX_border),
higher_simX_border_(higher_simX_border),
lower_simY_border_(lower_simY_border),
higher_simY_border_(higher_simY_border),
eff_factor_(eff_factor),
pixel_row_no_(pixel_row_no),
pixel_col_no_(pixel_col_no)
//,
// pixel_index_(pixel_col_no * PPSPixelTopology::no_of_pixels_simX_ + pixel_row_no)
{}

inline double higherSimXBorder() const { return higher_simX_border_; }
inline double lowerSimXBorder() const { return lower_simX_border_; }
inline double higherSimYBorder() const { return higher_simY_border_; }
inline double lowerSimYBorder() const { return lower_simY_border_; }
inline double effFactor() const { return eff_factor_; }
inline unsigned short pixelRowNo() const { return pixel_row_no_; }
inline unsigned short pixelColNo() const { return pixel_col_no_; }
// inline unsigned short pixelIndex() const { return pixel_index_; }

private:
double lower_simX_border_;
double higher_simX_border_;
double lower_simY_border_;
double higher_simY_border_;
double eff_factor_;
unsigned short pixel_row_no_;
unsigned short pixel_col_no_;
// unsigned short pixel_index_;
COND_SERIALIZABLE;
};

unsigned short pixelIndex(PixelInfo pI) const;
bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2) const;
PixelInfo getPixelsInvolved(double x, double y, double sigma, double& hit_pos_x, double& hit_pos_y) const;

void pixelRange(
unsigned int arow, unsigned int acol, double& lower_x, double& higher_x, double& lower_y, double& higher_y) const;

// Getters

std::string getRunType() const;
double getPitchSimY() const;
double getPitchSimX() const;
double getThickness() const;
unsigned short getNoPixelsSimX() const;
unsigned short getNoPixelsSimY() const;
unsigned short getNoPixels() const;
double getSimXWidth() const;
double getSimYWidth() const;
double getDeadEdgeWidth() const;
double getActiveEdgeSigma() const;
double getPhysActiveEdgeDist() const;
double getActiveEdgeX() const;
double getActiveEdgeY() const;

// Setters

void setRunType(std::string rt);
void setPitchSimY(double psy);
void setPitchSimX(double psx);
void setThickness(double tss);
void setNoPixelsSimX(unsigned short npx);
void setNoPixelsSimY(unsigned short npy);
void setNoPixels(unsigned short np);
void setSimXWidth(double sxw);
void setSimYWidth(double syw);
void setDeadEdgeWidth(double dew);
void setActiveEdgeSigma(double aes);
void setPhysActiveEdgeDist(double pae);
void setActiveEdgeX(double aex);
void setActiveEdgeY(double aey);

void printInfo(std::stringstream& s);

private:
/*
Geometrical and topological information on RPix silicon detector.
Uses coordinate a frame with origin in the center of the wafer.
*/

double activeEdgeFactor(double x, double y) const;
double distanceFromTopActiveEdge(double x, double y) const;
double distanceFromBottomActiveEdge(double x, double y) const;
double distanceFromRightActiveEdge(double x, double y) const;
double distanceFromLeftActiveEdge(double x, double y) const;
unsigned int row(double x) const;
unsigned int col(double y) const;
void rowCol2Index(unsigned int arow, unsigned int acol, unsigned int& index) const;
void index2RowCol(unsigned int& arow, unsigned int& acol, unsigned int index) const;

std::string runType_;
double pitch_simY_;
double pitch_simX_;
double thickness_;
unsigned short no_of_pixels_simX_;
unsigned short no_of_pixels_simY_;
unsigned short no_of_pixels_;
double simX_width_;
double simY_width_;
double dead_edge_width_;
double active_edge_sigma_;
double phys_active_edge_dist_;

double active_edge_x_;
double active_edge_y_;

COND_SERIALIZABLE;
};

std::ostream& operator<<(std::ostream&, PPSPixelTopology);

#endif
Loading