Skip to content

Commit

Permalink
Merge pull request #19670 from popovvp/dqmpix930p3
Browse files Browse the repository at this point in the history
CTPPS pixel DQM histograms update
  • Loading branch information
cmsbuild committed Jul 17, 2017
2 parents db97194 + 55d6429 commit 43a5db8
Showing 1 changed file with 72 additions and 69 deletions.
141 changes: 72 additions & 69 deletions DQM/CTPPS/plugins/CTPPSPixelDQMSource.cc
Expand Up @@ -38,13 +38,11 @@ class CTPPSPixelDQMSource: public DQMEDAnalyzer
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(edm::Event const& e, edm::EventSetup const& eSetup);
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup);
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup);
void endRun(edm::Run const& run, edm::EventSetup const& eSetup);

private:
unsigned int verbosity;

long int nEvents = 0;
edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelDigi>> tokenDigi;
// edm::EDGetTokenT< edm::DetSetVector<CTPPSPixelCluster> > tokenCluster;

Expand All @@ -63,7 +61,6 @@ class CTPPSPixelDQMSource: public DQMEDAnalyzer
int pixColMAX = 156; // defaultDetSizeInY, CMS X-axis
int ROCSizeInX = pixRowMAX/2; // ROC row size in pixels = 80
int ROCSizeInY = pixColMAX/3; // ROC col size in pixels = 52
long int nEvents = 0;

MonitorElement *hBX, *hBXshort;

Expand All @@ -80,13 +77,14 @@ class CTPPSPixelDQMSource: public DQMEDAnalyzer
MonitorElement *hRPotActivBX[RPotsTotalNumber];
MonitorElement *hRPotActivBXroc[RPotsTotalNumber];
MonitorElement *h2HitsMultROC[RPotsTotalNumber];
MonitorElement *hp2HitsMultROC_LS[RPotsTotalNumber];
MonitorElement *hRPotActivROCs[RPotsTotalNumber];
MonitorElement *hRPotActivROCsMax[RPotsTotalNumber];
MonitorElement *hHitsMult[RPotsTotalNumber][NplaneMAX];
MonitorElement *h2xyHits[RPotsTotalNumber][NplaneMAX];
MonitorElement *hp2xyADC[RPotsTotalNumber][NplaneMAX];
MonitorElement *h2xyROCHits[RPotsTotalNumber*NplaneMAX][NROCsMAX];
MonitorElement *h2xyROCadc[RPotsTotalNumber*NplaneMAX][NROCsMAX];
MonitorElement *hRPotActivBXall[RPotsTotalNumber];
int HitsMultROC[RPotsTotalNumber*NplaneMAX][NROCsMAX];
int HitsMultPlane[RPotsTotalNumber][NplaneMAX];

Expand Down Expand Up @@ -122,9 +120,6 @@ class CTPPSPixelDQMSource: public DQMEDAnalyzer

};

constexpr int CTPPSPixelDQMSource::NplaneMAX;
constexpr int CTPPSPixelDQMSource::NROCsMAX;

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

using namespace std;
Expand Down Expand Up @@ -215,9 +210,9 @@ edm::EventSetup const &)
TAxis *yah = h->GetYaxis();

st = "hit average multiplicity in planes";

int PlaneMultCut = 20;
hp2HitsOcc[arm][stn]= ibooker.bookProfile2D(st,st+st2+";Plane #",
NplaneMAX, 0, NplaneMAX, rpnbins, RPn_first,RPn_last,0,20000);
NplaneMAX, 0, NplaneMAX, rpnbins, RPn_first,RPn_last,-1,PlaneMultCut,"");
TProfile2D *h2 = hp2HitsOcc[arm][stn]->getTProfile2D();
h2->SetOption("textcolz");
TAxis *yah2 = h2->GetYaxis();
Expand All @@ -240,7 +235,7 @@ edm::EventSetup const &)
xmax,0,xmax, CluSizeMAX,0,CluSizeMAX);
h2CluSize[arm][stn]->getTH2F()->SetOption("colz");

//--------- Hits ---
//--------- RPots ---
int pixBinW = 4;
for(int rp=RPn_first; rp<RPn_last; rp++) { // only installed pixel pots
ID.setRP(rp);
Expand All @@ -260,25 +255,44 @@ edm::EventSetup const &)

hRPotActivPlanes[indexP] =
ibooker.book1D("number of fired planes per event", rpTitle+";nPlanes",
NplaneMAX, -0.5, NplaneMAX+0.5);
NplaneMAX+1, -0.5, NplaneMAX+0.5);
hRPotActivBX[indexP] =
ibooker.book1D("5 fired planes per BX", rpTitle+";Event.BX", 4002, -1.5, 4000.+0.5);
hRPotActivBXroc[indexP] =
ibooker.book1D("4 fired ROCs per BX", rpTitle+";Event.BX", 4002, -1.5, 4000.+0.5);

h2HitsMultROC[indexP] = ibooker.bookProfile2D("ROCs hits multiplicity per event",
rpTitle+";plane # ;ROC #", NplaneMAX,-0.5,NplaneMAX-0.5, NROCsMAX,-0.5,NROCsMAX-0.5, 100,0,1.e3);

rpTitle+";plane # ;ROC #", NplaneMAX,-0.5,NplaneMAX-0.5, NROCsMAX,-0.5,NROCsMAX-0.5,
0.,ROCSizeInX*ROCSizeInY,"");
h2HitsMultROC[indexP]->getTProfile2D()->SetOption("colztext");
h2HitsMultROC[indexP]->getTProfile2D()->SetMinimum(1.e-10);


hp2HitsMultROC_LS[indexP]=ibooker.bookProfile2D("ROCs_hits_multiplicity_per_event vs LS",
rpTitle+";LumiSection;Plane#___ROC#", 1000,0.,1000.,
NplaneMAX*NROCsMAX,0.,double(NplaneMAX*NROCsMAX),0.,ROCSizeInX*ROCSizeInY,"");
hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetOption("colz");
hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetMinimum(1.0e-10);
hp2HitsMultROC_LS[indexP]->getTProfile2D()->SetCanExtend(TProfile2D::kXaxis);
TAxis *yahp2 = hp2HitsMultROC_LS[indexP]->getTProfile2D()->GetYaxis();
for(int p=0; p<NplaneMAX; p++) {
sprintf(s,"plane%d_0",p);
yahp2->SetBinLabel(p*NplaneMAX+1,s);
for(int r=1; r<NROCsMAX; r++) {
sprintf(s," %d_%d",p,r);
yahp2->SetBinLabel(p*NplaneMAX+r+1,s);
}
}

hRPotActivROCs[indexP] = ibooker.book2D("number of fired aligned_ROCs per event",
rpTitle+";ROC ID;number of fired ROCs", NROCsMAX,-0.5,NROCsMAX-0.5, 7,-0.5,6.5);
hRPotActivROCs[indexP]->getTH2F()->SetOption("colz");

hRPotActivROCsMax[indexP]= ibooker.book2D("max number of fired aligned_ROCs per event",
rpTitle+";ROC ID;number of fired ROCs", NROCsMAX,-0.5,NROCsMAX-0.5, 7,-0.5,6.5);
hRPotActivROCsMax[indexP]->getTH2F()->SetOption("colz");
ibooker.setCurrentFolder(rpd+"/latency");

hRPotActivBXroc[indexP] =
ibooker.book1D("4 fired ROCs per BX", rpTitle+";Event.BX", 4002, -1.5, 4000.+0.5);

hRPotActivBXall[indexP] =
ibooker.book1D("hits per BX", rpTitle+";Event.BX", 4002, -1.5, 4000.+0.5);

int nbins = pixRowMAX/pixBinW;

Expand All @@ -294,28 +308,28 @@ edm::EventSetup const &)

st = "adc average value";
hp2xyADC[indexP][p]=ibooker.bookProfile2D(st,st1+";pix col;pix row",
nbins,0,pixRowMAX,nbins,0,pixRowMAX,100,0,1.e10,"");
nbins,0,pixRowMAX,nbins,0,pixRowMAX, 0.,512.,"");
hp2xyADC[indexP][p]->getTProfile2D()->SetOption("colz");

st = "hits multiplicity";
hHitsMult[indexP][p]=ibooker.book1DD(st,st1+";number of hits;N / 1 hit",
hitMultMAX,0,hitMultMAX);
hitMultMAX,-0.5,hitMultMAX-0.5);

ibooker.setCurrentFolder(pd + "/ROCs");
int index = getPlaneIndex(arm,stn,rp,p);

for(int roc=0; roc<6; roc++) {
for(int roc=0; roc<NROCsMAX; roc++) {
sprintf(s,"ROC_%d",roc);
string st2 = st1 + "_" + string(s);
ibooker.setCurrentFolder(pd + "/ROCs/" + string(s));

h2xyROCHits[index][roc]=ibooker.book2DD("hits",st2+";pix row;pix col",
ROCSizeInX,0,ROCSizeInX,ROCSizeInY,0,ROCSizeInY);
h2xyROCHits[index][roc]=ibooker.book2DD("hits",st2+";pix col;pix row",
ROCSizeInY,0,ROCSizeInY, ROCSizeInX,0,ROCSizeInX);
h2xyROCHits[index][roc]->getTH2D()->SetOption("colz");

string st = "adc average value";
h2xyROCadc[index][roc]=ibooker.bookProfile2D(st,st2+";pix row;pix col",
ROCSizeInX,0,ROCSizeInX,ROCSizeInY,0,ROCSizeInY, 0,512);
h2xyROCadc[index][roc]=ibooker.bookProfile2D(st,st2+";pix col;pix row",
ROCSizeInY,0,ROCSizeInY,ROCSizeInX,0,ROCSizeInX, 0.,512.,"");
h2xyROCadc[index][roc]->getTProfile2D()->SetOption("colz");
}
} // end of for(int p=0; p<NplaneMAX;..
Expand All @@ -328,19 +342,17 @@ edm::EventSetup const &)
}

//-------------------------------------------------------------------------------
void CTPPSPixelDQMSource::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg,
edm::EventSetup const& context)
{
}
//---------------------------------------------------------------------------------

void CTPPSPixelDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup)
{
++nEvents;
int RPactivity[2][NRPotsMAX];
int lumiId = event.getLuminosityBlock().id().luminosityBlock();
if(lumiId<0) lumiId=0;

int RPactivity[NArms][NRPotsMAX], digiSize[NArms][NRPotsMAX];
for(int arm = 0; arm <2; arm++) {
for(int rp=0; rp<NRPotsMAX; rp++) {
RPactivity[arm][rp] = 0;
RPactivity[arm][rp] = digiSize[arm][rp] = 0;
}
}
for(int ind=0; ind<2*3*NRPotsMAX; ind++) {
Expand All @@ -366,56 +378,58 @@ void CTPPSPixelDQMSource::analyze(edm::Event const& event, edm::EventSetup const
if(!valid && verbosity) LogPrint("CTPPSPixelDQMSource") <<"No valid data in Event "<<nEvents;

if(pixDigi.isValid()) {
for(const auto &ds_digi : *pixDigi) {
for(const auto &ds_digi : *pixDigi)
{
int idet = getDet(ds_digi.id);
if(idet != DetId::VeryForward) {
if(verbosity>1) LogPrint("CTPPSPixelDQMSource") <<"not CTPPS: ds_digi.id"<<ds_digi.id;
continue;
}
// int subdet = getSubdet(ds_digi.id);

int plane = getPixPlane(ds_digi.id);

CTPPSDetId theId(ds_digi.id);
int arm = theId.arm()&0x1;
int station = theId.station()&0x3;
int rpot = theId.rp()&0x7;
RPactivity[arm][rpot] = 1;

++digiSize[arm][rpot];

if(StationStatus[station] && RPstatus[station][rpot]) {

hp2HitsOcc[arm][station]->Fill(plane,rpot,(int)ds_digi.data.size());
h2HitsMultipl[arm][station]->Fill(prIndex(rpot,plane),ds_digi.data.size());
h2PlaneActive[arm][station]->Fill(plane,rpot);

int index = getRPindex(arm,station,rpot);
HitsMultPlane[index][plane] += ds_digi.data.size();
if(RPindexValid[index]) {
hHitsMult[index][plane]->Fill(ds_digi.data.size());
}
int rocHistIndex = getPlaneIndex(arm,station,rpot,plane);

for(DetSet<CTPPSPixelDigi>::const_iterator dit = ds_digi.begin();
dit != ds_digi.end(); ++dit) {
int row = dit->row();
int col = dit->column();
int adc = dit->adc();

if(RPindexValid[index]) {
h2xyHits[index][plane]->Fill(col,row);
hp2xyADC[index][plane]->Fill(col,row,adc);
int colROC, rowROC;
int trocId;
if(!thePixIndices.transformToROC(col,row, trocId, colROC, rowROC)) {
if(trocId>=0 && trocId<NROCsMAX) {
h2xyROCHits[rocHistIndex][trocId]->Fill(rowROC,colROC);
h2xyROCadc[rocHistIndex][trocId]->Fill(rowROC,colROC,adc);
h2xyROCHits[rocHistIndex][trocId]->Fill(colROC,rowROC);
h2xyROCadc[rocHistIndex][trocId]->Fill(colROC,rowROC,adc);
++HitsMultROC[rocHistIndex][trocId];
}
}
} //end if(RPindexValid[index]) {
}

if(int(ds_digi.data.size()) > multHits) multHits = ds_digi.data.size();
} // end if(StationStatus[station]) {
} // end for(const auto &ds_digi : *pixDigi)
Expand All @@ -427,49 +441,38 @@ void CTPPSPixelDQMSource::analyze(edm::Event const& event, edm::EventSetup const
int index = getRPindex(arm,stn,rp);
if(RPindexValid[index]==0) continue;
if(RPactivity[arm][rp]==0) continue;

int np = 0;
for(int p=0; p<NplaneMAX; p++) {
if(HitsMultPlane[index][p]>0) np++;
}
for(int p=0; p<NplaneMAX; p++) if(HitsMultPlane[index][p]>0) np++;
hRPotActivPlanes[index]->Fill(np);
if(np>5) { hRPotActivBX[index]->Fill(event.bunchCrossing());}

if(np>5) hRPotActivBX[index]->Fill(event.bunchCrossing());
hRPotActivBXall[index]->Fill(event.bunchCrossing(),float(digiSize[arm][rp]));

int rocf[NplaneMAX];
for(int r=0; r<NROCsMAX; r++) { rocf[r]=0; }
for(int r=0; r<NROCsMAX; r++) rocf[r]=0;
for(int p=0; p<NplaneMAX; p++) {
int indp = getPlaneIndex(arm,stn,rp,p);
for(int r=0; r<NROCsMAX; r++) {
if(HitsMultROC[indp][r] > 0) ++rocf[r];
}
for(int r=0; r<NROCsMAX; r++) if(HitsMultROC[indp][r] > 0) ++rocf[r];
for(int r=0; r<NROCsMAX; r++) {
h2HitsMultROC[index]->Fill(p,r,HitsMultROC[indp][r]);
hp2HitsMultROC_LS[index]->Fill(lumiId,p*NROCsMAX+r,HitsMultROC[indp][r]);
}
}
int max = 0;
for(int r=0; r<NROCsMAX; r++) {
for(int r=0; r<NROCsMAX; r++)
if(max < rocf[r]) { max = rocf[r]; }
}
for(int r=0; r<NROCsMAX; r++) {
hRPotActivROCs[index]->Fill(r,rocf[r]);
}
for(int r=0; r<NROCsMAX; r++) {
if(rocf[r] == max) {hRPotActivROCsMax[index]->Fill(r,max);}
}

for(int r=0; r<NROCsMAX; r++) hRPotActivROCs[index]->Fill(r,rocf[r]);

if(max > 4) hRPotActivBXroc[index]->Fill(event.bunchCrossing());
}
} //end for(int rp=0; rp<NRPotsMAX; rp++) {
}
}
} //end for(int arm=0; arm<2; arm++) {

if((nEvents % 100)) return;
if(verbosity) LogPrint("CTPPSPixelDQMSource")<<"analyze event "<<nEvents;
}

//--------------------------------------------------------------
void CTPPSPixelDQMSource::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup)
{
}

//-----------------------------------------------------------------------------
void CTPPSPixelDQMSource::endRun(edm::Run const& run, edm::EventSetup const& eSetup)
{
Expand Down

0 comments on commit 43a5db8

Please sign in to comment.