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

include pilot blade stuff to pixel rawdigi, 2nd attempt #5961

Merged
merged 2 commits into from Oct 27, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h
Expand Up @@ -30,7 +30,9 @@
* The PixelDataFormatter interpret/format ONLY detector data words
* (not FED headers or trailer, which are treated elsewhere).
*/

//
// Add the phase1 format
//
#include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/Common/interface/DetSetVector.h"
Expand Down Expand Up @@ -66,7 +68,7 @@ class PixelDataFormatter {
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

PixelDataFormatter(const SiPixelFedCabling* map);
PixelDataFormatter(const SiPixelFedCabling* map, bool phase1=false);

void setErrorStatus(bool ErrorStatus);
void setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo);
Expand All @@ -84,7 +86,6 @@ class PixelDataFormatter {
mutable int theDigiCounter;
mutable int theWordCounter;


SiPixelFedCabling const * theCablingTree;
const SiPixelFrameReverter* theFrameReverter;
const SiPixelQuality* badPixelInfo;
Expand All @@ -97,6 +98,11 @@ class PixelDataFormatter {
int hasDetDigis;
ErrorChecker errorcheck;

// For the 32bit data format (moved from *.cc namespace, keep uppercase for compatibility)
int ADC_shift, PXID_shift, DCOL_shift, ROC_shift, LINK_shift;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMS style is to have all class members to start from a lower case;
upper case is reserved for type names

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALL Tracker code in EventFilter use this type of notation. It is historical. Make no sense to change it 20 year after.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's OK for constants (and they were for 20 years and we are changing them)
They are not constants anymore here.
I would not insist though.

Word32 LINK_mask, ROC_mask, DCOL_mask, PXID_mask, ADC_mask;
int maxROCIndex;

int checkError(const Word32& data) const;

int digi2word( cms_uint32_t detId, const PixelDigi& digi,
Expand Down
16 changes: 14 additions & 2 deletions EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.cc
Expand Up @@ -28,7 +28,8 @@ SiPixelDigiToRaw::SiPixelDigiToRaw( const edm::ParameterSet& pset ) :
{

tPixelDigi = consumes<edm::DetSetVector<PixelDigi> >(config_.getParameter<edm::InputTag>("InputLabel"));
// Define EDProduct type

// Define EDProduct type
produces<FEDRawDataCollection>();

// start the counters
Expand All @@ -43,6 +44,15 @@ SiPixelDigiToRaw::SiPixelDigiToRaw( const edm::ParameterSet& pset ) :
hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050);
hDigi = new TH1D("hDigi","hDigi",50,0.,15000.);
}

// Control the usage of phase1
usePhase1 = false;
if (config_.exists("UsePhase1")) {
usePhase1 = config_.getParameter<bool> ("UsePhase1");
if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
}

usePilotBlade=false; // I am not yet sure we need it here?
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -93,7 +103,9 @@ void SiPixelDigiToRaw::produce( edm::Event& ev,
debug = edm::MessageDrop::instance()->debugEnabled;
if (debug) LogDebug("SiPixelDigiToRaw") << cablingTree_->version();

PixelDataFormatter formatter(cablingTree_.get());
//PixelDataFormatter formatter(cablingTree_.get());
PixelDataFormatter formatter(cablingTree_.get(), usePhase1);

formatter.passFrameReverter(frameReverter_);
if (theTimer) theTimer->start();

Expand Down
2 changes: 2 additions & 0 deletions EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.h
Expand Up @@ -51,5 +51,7 @@ class SiPixelDigiToRaw final : public edm::EDProducer {
edm::ESWatcher<SiPixelFedCablingMapRcd> recordWatcher;
bool debug;
edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> tPixelDigi;
bool usePilotBlade;
bool usePhase1;
};
#endif
25 changes: 22 additions & 3 deletions EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc
@@ -1,6 +1,7 @@
// Skip FED40 pilot-blade
// Include parameter driven interface to SiPixelQuality for study purposes
// exclude ROC(raw) based on bad ROC list in SiPixelQuality
// enabled by: process.siPixelDigis.UseQualityInfo = True
// enabled by: process.siPixelDigis.UseQualityInfo = True (BY DEFAULT NOT USED)
// 20-10-2010 Andrew York (Tennessee)

#include "SiPixelRawToDigi.h"
Expand Down Expand Up @@ -80,6 +81,21 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf )
hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050);
hDigi = new TH1D("hDigi","hDigi",50,0.,15000.);
}

// Control the usage of pilot-blade data, FED=40
usePilotBlade = false;
if (config_.exists("UsePilotBlade")) {
usePilotBlade = config_.getParameter<bool> ("UsePilotBlade");
if(usePilotBlade) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
}

// Control the usage of phase1
usePhase1 = false;
if (config_.exists("UsePhase1")) {
usePhase1 = config_.getParameter<bool> ("UsePhase1");
if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
}

}


Expand Down Expand Up @@ -129,7 +145,6 @@ void SiPixelRawToDigi::produce( edm::Event& ev,
}

edm::Handle<FEDRawDataCollection> buffers;
label = config_.getParameter<edm::InputTag>("InputLabel");
ev.getByToken(tFEDRawDataCollection, buffers);

// create product (digis & errors)
Expand All @@ -139,7 +154,9 @@ void SiPixelRawToDigi::produce( edm::Event& ev,
std::auto_ptr< DetIdCollection > tkerror_detidcollection(new DetIdCollection());
std::auto_ptr< DetIdCollection > usererror_detidcollection(new DetIdCollection());

PixelDataFormatter formatter(cabling_.get());
//PixelDataFormatter formatter(cabling_.get()); // phase 0 only
PixelDataFormatter formatter(cabling_.get(), usePhase1); // for phase 1 & 0

formatter.setErrorStatus(includeErrors);

if (useQuality) formatter.setQualityStatus(useQuality, badPixelInfo_);
Expand All @@ -158,6 +175,8 @@ void SiPixelRawToDigi::produce( edm::Event& ev,
for (auto aFed = fedIds.begin(); aFed != fedIds.end(); ++aFed) {
int fedId = *aFed;

if(!usePilotBlade && (fedId==40) ) continue; // skip pilot blade data

if (regions_ && !regions_->mayUnpackFED(fedId)) continue;

if(debug) LogDebug("SiPixelRawToDigi")<< " PRODUCE DIGI FOR FED: " << fedId << endl;
Expand Down
3 changes: 2 additions & 1 deletion EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h
Expand Up @@ -56,6 +56,7 @@ class SiPixelRawToDigi : public edm::stream::EDProducer<> {
edm::InputTag label;
int ndigis;
int nwords;

bool usePilotBlade;
bool usePhase1;
};
#endif
4 changes: 3 additions & 1 deletion EventFilter/SiPixelRawToDigi/python/SiPixelDigiToRaw_cfi.py
Expand Up @@ -2,7 +2,9 @@

siPixelRawData = cms.EDProducer("SiPixelDigiToRaw",
Timing = cms.untracked.bool(False),
InputLabel = cms.InputTag("simSiPixelDigis")
InputLabel = cms.InputTag("simSiPixelDigis"),
## Use phase1
UsePhase1 = cms.bool(False),
)


Expand Down
4 changes: 4 additions & 0 deletions EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py
Expand Up @@ -10,6 +10,10 @@
ErrorList = cms.vint32(29),
## UserErrorList: list of error codes used by Pixel experts for investigation
UserErrorList = cms.vint32(40),
## Use pilot blades
UsePilotBlade = cms.bool(False),
## Use phase1
UsePhase1 = cms.bool(False),
## Empty Regions PSet means complete unpacking
Regions = cms.PSet( )
)
Expand Down
81 changes: 55 additions & 26 deletions EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc
Expand Up @@ -28,22 +28,26 @@ namespace {
constexpr int DCOL_bits = 5;
constexpr int PXID_bits = 8;
constexpr int ADC_bits = 8;

constexpr int ADC_shift = 0;
constexpr int PXID_shift = ADC_shift + ADC_bits;
constexpr int DCOL_shift = PXID_shift + PXID_bits;
constexpr int ROC_shift = DCOL_shift + DCOL_bits;
constexpr int LINK_shift = ROC_shift + ROC_bits;

constexpr PixelDataFormatter::Word32 LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits);
constexpr PixelDataFormatter::Word32 ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits);
constexpr PixelDataFormatter::Word32 DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits);
constexpr PixelDataFormatter::Word32 PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits);
constexpr PixelDataFormatter::Word32 ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits);

// For phase1
constexpr int LINK_bits1 = 7;
constexpr int ROC_bits1 = 4;

// Moved to the header file, keep commented out unti the final version is done/
// constexpr int ADC_shift = 0;
// constexpr int PXID_shift = ADC_shift + ADC_bits;
// constexpr int DCOL_shift = PXID_shift + PXID_bits;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this commented out code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not.
This is just a workaround.
Later on I will have to review this code and make sure it is still optimal, in particular for HLT use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough

// constexpr int ROC_shift = DCOL_shift + DCOL_bits;
// constexpr int LINK_shift = ROC_shift + ROC_bits;
// constexpr PixelDataFormatter::Word32 LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits);
// constexpr PixelDataFormatter::Word32 ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits);
// constexpr PixelDataFormatter::Word32 DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits);
// constexpr PixelDataFormatter::Word32 PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits);
// constexpr PixelDataFormatter::Word32 ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits);

}

PixelDataFormatter::PixelDataFormatter( const SiPixelFedCabling* map)
PixelDataFormatter::PixelDataFormatter( const SiPixelFedCabling* map, bool phase1)
: theDigiCounter(0), theWordCounter(0), theCablingTree(map), badPixelInfo(0), modulesToUnpack(0)
{
int s32 = sizeof(Word32);
Expand All @@ -61,6 +65,29 @@ PixelDataFormatter::PixelDataFormatter( const SiPixelFedCabling* map)
useQualityInfo = false;
allDetDigis = 0;
hasDetDigis = 0;

ADC_shift = 0;
PXID_shift = ADC_shift + ADC_bits;
DCOL_shift = PXID_shift + PXID_bits;
ROC_shift = DCOL_shift + DCOL_bits;

if(phase1) { // for phase 1
LINK_shift = ROC_shift + ROC_bits1;
LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits1);
ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits1);
maxROCIndex=8;
} else { // for phase 0
LINK_shift = ROC_shift + ROC_bits;
LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits);
ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits);
maxROCIndex=25;
}


DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits);
PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits);
ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits);

}

void PixelDataFormatter::setErrorStatus(bool ErrorStatus)
Expand Down Expand Up @@ -142,7 +169,7 @@ void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const

if ( (nlink!=link) | (nroc!=roc) ) { // new roc
link = nlink; roc=nroc;
skipROC = likely(roc<25) ? false : !errorcheck.checkROC(errorsInEvent, fedId, &converter, ww, errors);
skipROC = likely(roc<maxROCIndex) ? false : !errorcheck.checkROC(errorsInEvent, fedId, &converter, ww, errors);
if (skipROC) continue;
rocp = converter.toRoc(link,roc);
if unlikely(!rocp) {
Expand Down Expand Up @@ -188,21 +215,23 @@ void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const

}

void doVectorize(int const * __restrict__ w, int * __restrict__ row, int * __restrict__ col, int * __restrict__ valid, int N, PixelROC const * rocp) {
for (int i=0; i<N; ++i) {
auto ww = w[i];
int dcol = (ww >> DCOL_shift) & DCOL_mask;
int pxid = (ww >> PXID_shift) & PXID_mask;
// int adc = (ww >> ADC_shift) & ADC_mask;
// I do not know what this was for or if it is needed? d.k. 10.14
// Keep it commented out until we are sure that it is not needed.
// void doVectorize(int const * __restrict__ w, int * __restrict__ row, int * __restrict__ col, int * __restrict__ valid, int N, PixelROC const * rocp) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented out code, please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave this code where it is!

// for (int i=0; i<N; ++i) {
// auto ww = w[i];
// int dcol = (ww >> DCOL_shift) & DCOL_mask;
// int pxid = (ww >> PXID_shift) & PXID_mask;
// // int adc = (ww >> ADC_shift) & ADC_mask;

LocalPixel::DcolPxid local = { dcol, pxid };
valid[i] = local.valid();
GlobalPixel global = rocp->toGlobal( LocalPixel(local) );
row[i]=global.row; col[i]=global.col;
// LocalPixel::DcolPxid local = { dcol, pxid };
// valid[i] = local.valid();
// GlobalPixel global = rocp->toGlobal( LocalPixel(local) );
// row[i]=global.row; col[i]=global.col;

}
// }

}
// }


void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis)
Expand Down
10 changes: 7 additions & 3 deletions EventFilter/SiPixelRawToDigi/test/SiPixelRawDumper.cc
Expand Up @@ -1014,19 +1014,21 @@ void SiPixelRawDumper::analyze(const edm::Event& ev, const edm::EventSetup& es)

// Loop over FEDs
for (int fedId = fedIds.first; fedId <= fedIds.second; fedId++) {
//LogDebug("SiPixelRawDumper")<< " GET DATA FOR FED: " << fedId ;
if(printHeaders) cout<<"Get data For FED = "<<fedId<<endl;

//edm::DetSetVector<PixelDigi> collection;
PixelDataFormatter::Errors errors;

//get event data for this fed
const FEDRawData& rawData = buffers->FEDData( fedId );

if(printHeaders) cout<<"Get data For FED = "<<fedId<<" size in bytes "<<rawData.size()<<endl;
if(rawData.size()==0) continue; // skip if not data for this fed

for(int i=0;i<36;++i) fedchannelsize[i]=0;

int nWords = rawData.size()/sizeof(Word64);
//cout<<" size "<<nWords<<endl;

sumFedSize += float(nWords);
if(fedId<32) aveFedSize += double(2.*nWords);

Expand All @@ -1042,15 +1044,16 @@ void SiPixelRawDumper::analyze(const edm::Event& ev, const edm::EventSetup& es)
hsizep->Fill(float(fedId),float(2*nWords)); // profile
if(fedId<32) hsizels->Fill(float(lumiBlock),float(2*nWords)); // bpix versu sls


// check headers
const Word64* header = reinterpret_cast<const Word64* >(rawData.data());
//cout<<hex<<*header<<dec<<endl;

unsigned int bxid = 0;
eventId = MyDecode::header(*header, fedId, printHeaders, bxid);
//if(fedId = fedIds.first)
if(bx != int(bxid) ) cout<<" Inconsistent BX: from event "<<bx<<" from FED "<<bxid<<endl;


const Word64* trailer = reinterpret_cast<const Word64* >(rawData.data())+(nWords-1);
//cout<<hex<<*trailer<<dec<<endl;
status = MyDecode::trailer(*trailer,fedId, printHeaders);
Expand All @@ -1061,6 +1064,7 @@ void SiPixelRawDumper::analyze(const edm::Event& ev, const edm::EventSetup& es)
int countErrorsInFed2=0;
int fedChannel = 0;
int num=0;

// Loop over payload words
for (const Word64* word = header+1; word != trailer; word++) {
static const Word64 WORD32_mask = 0xffffffff;
Expand Down
16 changes: 9 additions & 7 deletions EventFilter/SiPixelRawToDigi/test/runRawDumper_cfg.py
Expand Up @@ -45,7 +45,7 @@
#process.MessageLogger.cerr.threshold = 'Debug'

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
input = cms.untracked.int32(-1)
)

process.TFileService = cms.Service("TFileService",
Expand All @@ -54,8 +54,9 @@

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(

## "/store/data/Run2012A/AlCaLumiPixels/RAW/v1/000/191/271/00016516-0587-E111-9884-003048D2BBF0.root",
# "file:../../../../../CMSSW_7_1_3/src/DPGAnalysis-SiPixelTools/HitAnalyzer/test/raw.root"
# "file:/afs/cern.ch/work/d/dkotlins/public/MC/mu/pt100_71_pre7/raw/raw2.root"
"/store/data/Run2012A/AlCaLumiPixels/RAW/v1/000/191/271/00016516-0587-E111-9884-003048D2BBF0.root",
## "/store/data/Run2012A/AlCaLumiPixels/RAW/v1/000/191/271/022D9994-1087-E111-8772-001D09F28D4A.root",
## "/store/data/Run2012A/AlCaLumiPixels/RAW/v1/000/191/271/044649F6-0B87-E111-AE83-0025B32036D2.root",
## "/store/data/Run2012A/AlCaLumiPixels/RAW/v1/000/191/271/081DAD76-0B87-E111-90EB-0030486730C6.root",
Expand Down Expand Up @@ -253,9 +254,8 @@
# "rfio:/castor/cern.ch/cms/store/data/Run2012D/MinimumBias/RAW/v1/000/205/718/1285A278-E41B-E211-BD9A-0019B9F72F97.root",
# "rfio:/castor/cern.ch/cms/store/data/Run2012D/MinimumBias/RAW/v1/000/205/718/1289B6A0-F91B-E211-BC25-001D09F24682.root",

"rfio:/castor/cern.ch/cms/store/data/Run2012D/MinimumBias/RAW/v1/000/208/686/A88F66A0-393F-E211-9287-002481E0D524.root",


# "rfio:/castor/cern.ch/cms/store/data/Run2012D/MinimumBias/RAW/v1/000/208/686/A88F66A0-393F-E211-9287-002481E0D524.root",

)

)
Expand All @@ -277,7 +277,9 @@
Timing = cms.untracked.bool(False),
IncludeErrors = cms.untracked.bool(True),
# In 2012, label = rawDataCollector, extension = _LHC
InputLabel = cms.untracked.string('rawDataCollector'),
# InputLabel = cms.untracked.string('rawDataCollector'),
# for MC
InputLabel = cms.untracked.string('siPixelRawData'),
# For PixelLumi stream
# InputLabel = cms.untracked.string('hltFEDSelectorLumiPixels'),
# old
Expand Down