Skip to content

Commit

Permalink
Merge pull request #15566 from suchandradutta/Phase2Digitizer_81X_160727
Browse files Browse the repository at this point in the history
introduction of  Over-Threshold bit in outer tracker Digis
  • Loading branch information
davidlange6 committed Aug 29, 2016
2 parents c5db1f8 + 60d413b commit f4a7623
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 21 deletions.
12 changes: 10 additions & 2 deletions DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Phase2TrackerDigi {
theChannel = pixelToChannel(row,col);
}

Phase2TrackerDigi( unsigned int row, unsigned int col, bool ot_flag) {
theChannel = pixelToChannel(row,col);
if (ot_flag) theChannel |= (1<< 15);
}

Phase2TrackerDigi() : theChannel(0) {}

// Access to digi information - pixel sensors
Expand All @@ -30,6 +35,8 @@ class Phase2TrackerDigi {
unsigned int edge() const { return column(); } // CD: any better name for that?
// Access to the (raw) channel number
unsigned int channel() const { return theChannel; }
// Access Overthreshold bit
bool overThreshold() const { return (otBit(theChannel) ? true : false); }

static std::pair<unsigned int,unsigned int> channelToPixel( unsigned int ch) {
return std::pair<unsigned int, unsigned int>(channelToRow(ch),channelToColumn(ch));
Expand All @@ -43,8 +50,9 @@ class Phase2TrackerDigi {

private:
PackedDigiType theChannel;
static unsigned int channelToRow( unsigned int ch) { return ch & 0x03FF; } // (theChannel & 0x03FF)>>0
static unsigned int channelToColumn( unsigned int ch) { return ch >> 10; } // (theChannel & 0xFC00)>>10
static unsigned int channelToRow( unsigned int ch) { return ch & 0x03FF; }
static unsigned int channelToColumn( unsigned int ch) { return ((ch >> 10) & 0x1F); }
static unsigned int otBit( unsigned int ch) { return ((ch >> 15) & 0x1) ; }
};

// Comparison operators
Expand Down
4 changes: 3 additions & 1 deletion SimTracker/SiPhase2Digitizer/plugins/DigitizerUtility.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#ifndef __SimTracker_SiPhase2Digitizer_DigitizerUtility_h
#define __SimTracker_SiPhase2Digitizer_DigitizerUtility_h

Expand Down Expand Up @@ -46,7 +47,7 @@ namespace DigitizerUtility {

// in case of contribution of noise to the digi
// the MC information are removed
if (other._frac.size() > 0 && other._frac[0] >- 0.5) {
if (other._frac.size() > 0 && other._frac[0] > -0.5) {
if (other._hitInfo) {
const std::vector<unsigned int>& otherTrackIds = other._hitInfo->trackIds();
if (_hitInfo) {
Expand Down Expand Up @@ -140,6 +141,7 @@ namespace DigitizerUtility {
};
struct DigiSimInfo {
int sig_tot;
bool ot_bit;
std::map<unsigned int, float> track_map;
unsigned int hit_counter;
unsigned int tof_bin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ namespace cms
for (auto const & digi_p : digi_map) {
DigitizerUtility::DigiSimInfo info = digi_p.second;
std::pair<int,int> ip = Phase2TrackerDigi::channelToPixel(digi_p.first);
collector.data.emplace_back(ip.first, ip.second);
collector.data.emplace_back(ip.first, ip.second, info.ot_bit);
for (auto const & track_p : info.track_map) {
linkcollector.data.emplace_back(digi_p.first, track_p.first, info.hit_counter, info.tof_bin, info.event_id, track_p.second);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,10 @@ void Phase2TrackerDigitizerAlgorithm::digitize(const Phase2TrackerGeomDetUnit* p

if (doDigitalReadout) adc = theAdcFullScale;
else adc = std::min( int(signalInElectrons / theElectronPerADC), theAdcFullScale );

DigitizerUtility::DigiSimInfo info;
info.sig_tot = adc;
info.ot_bit = ( int(signalInElectrons / theElectronPerADC) > theAdcFullScale ? true : false);
if (makeDigiSimLinks_ && sig_data.hitInfo() != 0) {
info.hit_counter = sig_data.hitIndex();
info.tof_bin = sig_data.tofBin();
Expand Down
93 changes: 81 additions & 12 deletions SimTracker/SiPhase2Digitizer/test/Phase2TrackerMonitorDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,20 @@ void Phase2TrackerMonitorDigi::analyze(const edm::Event& iEvent, const edm::Even
edm::ESHandle<TrackerGeometry> geomHandle;
iSetup.get<TrackerDigiGeometryRecord>().get(geomType_, geomHandle);

if (pixelFlag_) fillDigiHistos(pixDigiHandle, geomHandle);
else fillDigiHistos(otDigiHandle, geomHandle);
if (pixelFlag_) fillITPixelDigiHistos(pixDigiHandle, geomHandle);
else fillOTDigiHistos(otDigiHandle, geomHandle);
}
}
template <class T>
void Phase2TrackerMonitorDigi::fillDigiHistos(const edm::Handle<edm::DetSetVector<T>> handle, const edm::ESHandle<TrackerGeometry> gHandle) {
const edm::DetSetVector<T>* digis = handle.product();
void Phase2TrackerMonitorDigi::fillITPixelDigiHistos(const edm::Handle<edm::DetSetVector<PixelDigi>> handle, const edm::ESHandle<TrackerGeometry> gHandle) {
const edm::DetSetVector<PixelDigi>* digis = handle.product();

const TrackerTopology* tTopo = tTopoHandle_.product();

for (typename edm::DetSetVector<T>::const_iterator DSViter = digis->begin(); DSViter != digis->end(); DSViter++) {
for (typename edm::DetSetVector<PixelDigi>::const_iterator DSViter = digis->begin(); DSViter != digis->end(); DSViter++) {
unsigned int rawid = DSViter->id;
DetId detId(rawid);
edm::LogInfo("Phase2TrackerMonitorDigi")<< " Det Id = " << rawid;
int layer;
if (pixelFlag_) layer = tTopo->getITPixelLayerNumber(rawid);
else layer = tTopo->getOTLayerNumber(rawid);
int layer = tTopo->getITPixelLayerNumber(rawid);
if (layer < 0) continue;
std::map<uint32_t, DigiMEs >::iterator pos = layerMEs.find(layer);
if (pos == layerMEs.end()) continue;
Expand All @@ -115,9 +112,9 @@ void Phase2TrackerMonitorDigi::fillDigiHistos(const edm::Handle<edm::DetSetVecto
int row_last = -1;
int col_last = -1;
int nclus = 0;
int width = 0;
int width = 1;
int position = 0;
for (typename edm::DetSet< T >::const_iterator di = DSViter->begin(); di != DSViter->end(); di++) {
for (typename edm::DetSet< PixelDigi >::const_iterator di = DSViter->begin(); di != DSViter->end(); di++) {
int col = di->column(); // column
int row = di->row(); // row
const DetId detId(rawid);
Expand All @@ -134,9 +131,71 @@ void Phase2TrackerMonitorDigi::fillDigiHistos(const edm::Handle<edm::DetSetVecto
std::dec << std::endl;
local_mes.PositionOfDigis->Fill(row+1, col+1);

if (row_last == -1 ) {
position = row+1;
nclus++;
} else {
if (abs(row - row_last) == 1 && col == col_last) {
position += row+1;
width++;
} else {
position /= width;
local_mes.ClusterWidth->Fill(width);
local_mes.ClusterPosition->Fill(position);
width = 1;
position = row+1;
nclus++;
}
}
edm::LogInfo("Phase2TrackerMonitorDigi")<< " row " << row << " col " << col << " row_last " << row_last << " col_last " << col_last << " width " << width;
row_last = row;
col_last = col;
}
local_mes.NumberOfClusters->Fill(nclus);
local_mes.NumberOfDigis->Fill(nDigi);
}
}
void Phase2TrackerMonitorDigi::fillOTDigiHistos(const edm::Handle<edm::DetSetVector<Phase2TrackerDigi>> handle, const edm::ESHandle<TrackerGeometry> gHandle) {
const edm::DetSetVector<Phase2TrackerDigi>* digis = handle.product();

const TrackerTopology* tTopo = tTopoHandle_.product();

for (typename edm::DetSetVector<Phase2TrackerDigi>::const_iterator DSViter = digis->begin(); DSViter != digis->end(); DSViter++) {
unsigned int rawid = DSViter->id;
DetId detId(rawid);
edm::LogInfo("Phase2TrackerMonitorDigi")<< " Det Id = " << rawid;
int layer = tTopo->getOTLayerNumber(rawid);
if (layer < 0) continue;
std::map<uint32_t, DigiMEs >::iterator pos = layerMEs.find(layer);
if (pos == layerMEs.end()) continue;
DigiMEs local_mes = pos->second;
int nDigi = 0;
int row_last = -1;
int col_last = -1;
int nclus = 0;
int width = 1;
int position = 0;
float frac_ot = 0.;
for (typename edm::DetSet< Phase2TrackerDigi >::const_iterator di = DSViter->begin(); di != DSViter->end(); di++) {
int col = di->column(); // column
int row = di->row(); // row
const DetId detId(rawid);

const GeomDetUnit* gDetUnit = gHandle->idToDetUnit(detId);
if (gDetUnit) {
MeasurementPoint mp( row + 0.5, col + 0.5 );
GlobalPoint pdPos = gDetUnit->surface().toGlobal( gDetUnit->topology().localPosition( mp ) ) ;
XYPositionMap->Fill(pdPos.x()*10.0, pdPos.y()*10.0);
RZPositionMap->Fill(pdPos.z()*10.0, std::sqrt(pdPos.x()*pdPos.x() + pdPos.y()*pdPos.y())*10.0);
}
nDigi++;
if (di->overThreshold()) frac_ot++;
edm::LogInfo("Phase2TrackerMonitorDigi")<< " column " << col << " row " << row <<
std::dec << std::endl;
local_mes.PositionOfDigis->Fill(row+1, col+1);


if (row_last == -1 ) {
width = 1;
position = row+1;
nclus++;
} else {
Expand All @@ -158,6 +217,9 @@ void Phase2TrackerMonitorDigi::fillDigiHistos(const edm::Handle<edm::DetSetVecto
}
local_mes.NumberOfClusters->Fill(nclus);
local_mes.NumberOfDigis->Fill(nDigi);

if (nDigi) frac_ot /= nDigi;
if (local_mes.FractionOfOTBits) local_mes.FractionOfOTBits->Fill(frac_ot);
}
}
//
Expand Down Expand Up @@ -280,6 +342,13 @@ void Phase2TrackerMonitorDigi::bookLayerHistos(DQMStore::IBooker & ibooker, unsi
Parameters.getParameter<int32_t>("Nbins"),
Parameters.getParameter<double>("xmin"),
Parameters.getParameter<double>("xmax"));

if (!pixelFlag_) {
HistoName.str("");
HistoName << "FractionOfOverThresholdDigis_" << fname2.str();
local_mes.FractionOfOTBits= ibooker.book1D(HistoName.str(), HistoName.str(),11, -0.05, 1.05);
}

layerMEs.insert(std::make_pair(layer, local_mes));
}
}
Expand Down
7 changes: 4 additions & 3 deletions SimTracker/SiPhase2Digitizer/test/Phase2TrackerMonitorDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ class Phase2TrackerMonitorDigi : public DQMEDAnalyzer{
MonitorElement* NumberOfClusters;
MonitorElement* ClusterWidth;
MonitorElement* ClusterPosition;
MonitorElement* FractionOfOTBits;
};

MonitorElement* XYPositionMap;
MonitorElement* RZPositionMap;

private:
void bookLayerHistos(DQMStore::IBooker & ibooker, unsigned int det_id, const TrackerTopology* tTopo, bool iflag);
template <class T>
void fillDigiHistos(const edm::Handle<edm::DetSetVector<T>> handle, const edm::ESHandle<TrackerGeometry> gHandle);
void fillITPixelDigiHistos(const edm::Handle<edm::DetSetVector<PixelDigi>> handle, const edm::ESHandle<TrackerGeometry> gHandle);
void fillOTDigiHistos(const edm::Handle<edm::DetSetVector<Phase2TrackerDigi>> handle, const edm::ESHandle<TrackerGeometry> gHandle);

edm::ParameterSet config_;
std::map<unsigned int, DigiMEs> layerMEs;
bool pixelFlag_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ bool Phase2TrackerValidateDigi::findOTDigi(unsigned int detid, unsigned int id)
for (edm::DetSet<Phase2TrackerDigi>::const_iterator di = DSVIter->begin(); di != DSVIter->end(); di++) {
int col = di->column(); // column
int row = di->row(); // row

unsigned int channel = Phase2TrackerDigi::pixelToChannel(row,col);
unsigned int simTkId = getSimTrackId(otSimLinkHandle_, detid, channel);
if (simTkId == id) {
Expand All @@ -246,7 +245,6 @@ bool Phase2TrackerValidateDigi::findITPixelDigi(unsigned int detid, unsigned int
for (edm::DetSet<PixelDigi>::const_iterator di = DSVIter->begin(); di != DSVIter->end(); di++) {
int col = di->column(); // column
int row = di->row(); // row

unsigned int channel = PixelDigi::pixelToChannel(row,col);
unsigned int simTkId = getSimTrackId(itPixelSimLinkHandle_, detid, channel);
if (simTkId == id) {
Expand Down

0 comments on commit f4a7623

Please sign in to comment.