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

Pixel raw2 digi #2297

Merged
merged 10 commits into from
Feb 4, 2014
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
5 changes: 4 additions & 1 deletion CondCore/SiPixelPlugins/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
#include "CondFormats/DataRecord/interface/SiPixelGainCalibrationForHLTSimRcd.h"
#include "CondFormats/DataRecord/interface/SiPixelLorentzAngleSimRcd.h"

namespace {
struct InitRocs {void operator()(SiPixelFedCablingMap& m){ m.initializeRocs();}};
}

REGISTER_PLUGIN(SiPixelFedCablingMapRcd,SiPixelFedCablingMap);
REGISTER_PLUGIN_INIT(SiPixelFedCablingMapRcd,SiPixelFedCablingMap, InitRocs);
REGISTER_PLUGIN(SiPixelGainCalibrationRcd,SiPixelGainCalibration);
REGISTER_PLUGIN(SiPixelGainCalibrationForHLTRcd,SiPixelGainCalibrationForHLT);
REGISTER_PLUGIN(SiPixelGainCalibrationOfflineRcd,SiPixelGainCalibrationOffline);
Expand Down
3 changes: 1 addition & 2 deletions CondFormats/SiPixelObjects/interface/FrameConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ namespace sipixelobjects {

class FrameConversion {
public:
FrameConversion(){}
FrameConversion( const PixelEndcapName & name, int rocIdInDetUnit);
FrameConversion( const PixelBarrelName & name, int rocIdInDetUnit);
FrameConversion( int rowOffset, int rowSlopeSign, int colOffset, int colSlopeSign)
: theRowConversion( LinearConversion(rowOffset,rowSlopeSign) ),
theCollumnConversion( LinearConversion(colOffset, colSlopeSign) ) {}

FrameConversion * clone() const { return new FrameConversion(*this); }

const sipixelobjects::LinearConversion & row() const { return theRowConversion; }
const sipixelobjects::LinearConversion & collumn() const { return theCollumnConversion;}

Expand Down
8 changes: 4 additions & 4 deletions CondFormats/SiPixelObjects/interface/LocalPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ namespace sipixelobjects {
/// row and collumn in ROC representation
struct RocRowCol {
int rocRow, rocCol;
bool valid() const { return 0 <= rocRow && rocRow < numRowsInRoc
&& 0 <= rocCol && rocCol < numColsInRoc; }
bool valid() const { return (0 <= rocRow) & (rocRow < numRowsInRoc)
& (0 <= rocCol) & (rocCol < numColsInRoc); }
};

/// double collumn and pixel ID in double collumn representation
struct DcolPxid {
int dcol, pxid;
bool valid() const { return (0 <= dcol && dcol < 26 && 2 <= pxid && pxid < 162 ); }
bool valid() const { return ( (0 <= dcol) & (dcol < 26) & (2 <= pxid) & (pxid < 162) ); }
};

LocalPixel( const DcolPxid & pixel) {
thePixel.rocCol = pixel.dcol*2 + pixel.pxid%2;
thePixel.rocRow = numRowsInRoc - pixel.pxid/2;
thePixel.rocCol = pixel.dcol*2 + pixel.pxid%2;
}

LocalPixel( const RocRowCol & pixel) : thePixel(pixel) {}
Expand Down
29 changes: 17 additions & 12 deletions CondFormats/SiPixelObjects/interface/PixelROC.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ class PixelROC {
public:

/// dummy
PixelROC() : theDetUnit(0), theIdDU(0), theIdLk(0), theFrameConverter(0) {}
PixelROC() : theDetUnit(0), theIdDU(0), theIdLk(0) {}

~PixelROC();

PixelROC(const PixelROC & o);
const PixelROC& operator=(const PixelROC&);

void swap(PixelROC&);

/// ctor with DetUnit id,
/// ROC number in DU (given by token passage),
Expand All @@ -48,22 +42,33 @@ class PixelROC {
/// converts DU position to local.
/// If GlobalPixel is outside ROC the resulting LocalPixel is not inside ROC.
/// (call to inside(..) recommended)
LocalPixel toLocal(const GlobalPixel & gp) const;
LocalPixel toLocal(const GlobalPixel & glo) const {
int rocRow = theFrameConverter.row().inverse(glo.row);
int rocCol = theFrameConverter.collumn().inverse(glo.col);

LocalPixel::RocRowCol rocRowCol = {rocRow, rocCol};
return LocalPixel(rocRowCol);

}

/// converts LocalPixel in ROC to DU coordinates.
/// LocalPixel must be inside ROC. Otherwise result is meaningless
GlobalPixel toGlobal(const LocalPixel & loc) const;
GlobalPixel toGlobal(const LocalPixel & loc) const {
GlobalPixel result;
result.col = theFrameConverter.collumn().convert(loc.rocCol());
result.row = theFrameConverter.row().convert(loc.rocRow());
return result;
}

/// printout for debug
std::string print(int depth = 0) const;

private:
void initFrameConversion() const;
void initFrameConversion();

private:
uint32_t theDetUnit;
unsigned int theIdDU, theIdLk;
mutable const FrameConversion * theFrameConverter;
FrameConversion theFrameConverter;

};

Expand Down
2 changes: 2 additions & 0 deletions CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class SiPixelFedCablingMap : public SiPixelFedCabling {

SiPixelFedCablingMap(const std::string & version="") : theVersion(version) {}

void initializeRocs();

virtual ~SiPixelFedCablingMap() {}

SiPixelFedCablingTree * cablingTree() const;
Expand Down
12 changes: 7 additions & 5 deletions CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define SiPixelFedCablingTree_H

#include <vector>
#include <map>
#include <unordered_map>
#include <string>

#include "CondFormats/SiPixelObjects/interface/SiPixelFedCabling.h"
#include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h"

class SiPixelFedCablingTree : public SiPixelFedCabling {
class SiPixelFedCablingTree final : public SiPixelFedCabling {

public:
typedef sipixelobjects::PixelFEDCabling PixelFEDCabling;
Expand All @@ -34,13 +34,15 @@ class SiPixelFedCablingTree : public SiPixelFedCabling {

virtual std::vector<sipixelobjects::CablingPathToDetUnit> pathToDetUnit(uint32_t rawDetId) const;

virtual const sipixelobjects::PixelROC* findItem(
const sipixelobjects::CablingPathToDetUnit & path) const;
virtual const sipixelobjects::PixelROC* findItem(const sipixelobjects::CablingPathToDetUnit & path) const;

const sipixelobjects::PixelROC* findItemInFed(const sipixelobjects::CablingPathToDetUnit & path,
const PixelFEDCabling * aFed) const;

int checkNumbering() const;

private:
std::string theVersion;
std::map<int, PixelFEDCabling> theFedCablings;
std::unordered_map<int, PixelFEDCabling> theFedCablings;
};
#endif
32 changes: 30 additions & 2 deletions CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,54 @@
#include "CondFormats/SiPixelObjects/interface/ElectronicIndex.h"
#include "CondFormats/SiPixelObjects/interface/DetectorIndex.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCabling.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
#include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h"
#include "CondFormats/SiPixelObjects/interface/PixelROC.h"

#include "FWCore/Utilities/interface/GCC11Compatibility.h"

#include <boost/cstdint.hpp>

class SiPixelFrameConverter {
public:

typedef sipixelobjects::PixelFEDCabling PixelFEDCabling;

// using PixelFEDCabling = sipixelobjects::PixelFEDCabling;

SiPixelFrameConverter(const SiPixelFedCabling* map, int fedId);

bool hasDetUnit(uint32_t radId) const;

sipixelobjects::PixelROC const * toRoc(int link, int roc) const;


int toDetector(const sipixelobjects::ElectronicIndex & cabling,
sipixelobjects::DetectorIndex & detector) const;
sipixelobjects::DetectorIndex & detector) const {
using namespace sipixelobjects;
auto roc = toRoc(cabling.link, cabling.roc);
if (!roc) return 2;
LocalPixel::DcolPxid local = { cabling.dcol, cabling.pxid };
if (!local.valid()) return 3;

GlobalPixel global = roc->toGlobal( LocalPixel(local) );
detector.rawId = roc->rawId();
detector.row = global.row;
detector.col = global.col;

return 0;

}


int toCabling( sipixelobjects::ElectronicIndex & cabling,
const sipixelobjects::DetectorIndex & detector) const;

private:

int theFedId;
const SiPixelFedCabling* theMap;
SiPixelFedCablingTree const * theTree;
const PixelFEDCabling * theFed;

};
#endif
59 changes: 5 additions & 54 deletions CondFormats/SiPixelObjects/src/PixelROC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,22 @@ using namespace std;
using namespace sipixelobjects;

PixelROC::PixelROC(uint32_t du, int idDU, int idLk)
: theDetUnit(du), theIdDU(idDU), theIdLk(idLk), theFrameConverter(0)
{}
: theDetUnit(du), theIdDU(idDU), theIdLk(idLk)
{initFrameConversion();}

PixelROC::PixelROC(const PixelROC & o)
: theDetUnit(o.theDetUnit), theIdDU(o.theIdDU), theIdLk(o.theIdLk),theFrameConverter(0)
{
if(o.theFrameConverter) theFrameConverter = o.theFrameConverter->clone();
}

PixelROC::~PixelROC()
{
delete theFrameConverter;
}

const PixelROC&
PixelROC::operator=(const PixelROC& iRHS)
{
PixelROC temp(iRHS);
this->swap(temp);
return *this;
}

void
PixelROC::swap(PixelROC& iOther)
{
std::swap(theDetUnit,iOther.theDetUnit);
std::swap(theIdDU,iOther.theIdDU);
std::swap(theIdLk,iOther.theIdLk);
std::swap(theFrameConverter,iOther.theFrameConverter);
}

GlobalPixel PixelROC::toGlobal(const LocalPixel & loc) const
{
GlobalPixel result;
if (!theFrameConverter) initFrameConversion();
result.col = theFrameConverter->collumn().convert(loc.rocCol());
result.row = theFrameConverter->row().convert(loc.rocRow());
return result;
}


LocalPixel PixelROC::toLocal( const GlobalPixel& glo) const
{
if (!theFrameConverter) initFrameConversion();
int rocRow = theFrameConverter->row().inverse(glo.row);
int rocCol = theFrameConverter->collumn().inverse(glo.col);

LocalPixel::RocRowCol rocRowCol = {rocRow, rocCol};
return LocalPixel(rocRowCol);
}

void PixelROC::initFrameConversion() const
void PixelROC::initFrameConversion()
{
if ( PixelModuleName::isBarrel(theDetUnit) ) {
PixelBarrelName barrelName(theDetUnit);
theFrameConverter = new FrameConversion(barrelName, theIdDU);
theFrameConverter = FrameConversion(barrelName, theIdDU);
} else {
PixelEndcapName endcapName(theDetUnit);
theFrameConverter = new FrameConversion(endcapName, theIdDU);
theFrameConverter = FrameConversion(endcapName, theIdDU);
}
}

string PixelROC::print(int depth) const
{
if (!theFrameConverter) initFrameConversion();

ostringstream out;
bool barrel = PixelModuleName::isBarrel(theDetUnit);
Expand Down
10 changes: 10 additions & 0 deletions CondFormats/SiPixelObjects/src/SiPixelFedCablingMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
#include <iostream>
#include <algorithm>

#include <iostream>

using namespace sipixelobjects;


void SiPixelFedCablingMap::initializeRocs() {
// std::cout << "initialize PixelRocs" << std::endl;
for (auto & v : theMap) v.second.initFrameConversion();

}


bool SiPixelFedCablingMap::Key::operator < (const Key & other) const
{
if (fed < other.fed) return true;
Expand Down
26 changes: 19 additions & 7 deletions CondFormats/SiPixelObjects/src/SiPixelFedCablingTree.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
#include <algorithm>
#include <sstream>
#include <iostream>

using namespace std;
using namespace sipixelobjects;

typedef std::map<int, SiPixelFedCablingTree::PixelFEDCabling>::const_iterator IMAP;
typedef std::unordered_map<int, SiPixelFedCablingTree::PixelFEDCabling>::const_iterator IMAP;

std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingTree::pathToDetUnit(
uint32_t rawDetId) const
{
std::vector<sipixelobjects::CablingPathToDetUnit> result;
typedef std::map<int, PixelFEDCabling>::const_iterator IM;
for (IM im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
for (auto im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
const PixelFEDCabling & aFed = im->second;
for (unsigned int idxLink = 1; idxLink <= aFed.numberOfLinks(); idxLink++) {
const PixelFEDLink * link = aFed.link(idxLink);
Expand All @@ -38,7 +38,7 @@ void SiPixelFedCablingTree::addFed(const PixelFEDCabling & f)

const PixelFEDCabling * SiPixelFedCablingTree::fed(unsigned int id) const
{
IMAP it = theFedCablings.find(id);
auto it = theFedCablings.find(id);
return ( it == theFedCablings.end() ) ? 0 : & (*it).second;
}

Expand All @@ -61,6 +61,7 @@ std::vector<const PixelFEDCabling *> SiPixelFedCablingTree::fedList() const
for (IMAP im = theFedCablings.begin(); im != theFedCablings.end(); im++) {
result.push_back( &(im->second) );
}
std::sort(result.begin(),result.end(),[](const PixelFEDCabling * a,const PixelFEDCabling * b){return a->id()<b->id();});
return result;

}
Expand All @@ -73,7 +74,7 @@ void SiPixelFedCablingTree::addItem(unsigned int fedId, unsigned int linkId, con
}

const sipixelobjects::PixelROC* SiPixelFedCablingTree::findItem(
const CablingPathToDetUnit & path) const
const CablingPathToDetUnit & path) const
{
const PixelROC* roc = 0;
const PixelFEDCabling * aFed = fed(path.fed);
Expand All @@ -84,11 +85,22 @@ const sipixelobjects::PixelROC* SiPixelFedCablingTree::findItem(
return roc;
}


const sipixelobjects::PixelROC* SiPixelFedCablingTree::findItemInFed(
const CablingPathToDetUnit & path,
const PixelFEDCabling * aFed) const
{
const PixelROC* roc = 0;
const PixelFEDLink * aLink = aFed->link(path.link);
if (aLink) roc = aLink->roc(path.roc);
return roc;
}


int SiPixelFedCablingTree::checkNumbering() const
{
int status = 0;
for (std::map<int, PixelFEDCabling>::const_iterator im = theFedCablings.begin();
im != theFedCablings.end(); ++im) {
for (auto im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
if (im->first != static_cast<int>( im->second.id())) {
status = 1;
std::cout << "PROBLEM WITH FED ID!!" << im->first <<" vs: "<< im->second.id() << std::endl;
Expand Down
Loading