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

Memory reduction of the Cluster Charge Histogram used in SiStrip gain calibration #20010

Merged
merged 3 commits into from Sep 15, 2017
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
55 changes: 44 additions & 11 deletions CalibTracker/SiStripChannelGain/plugins/SiStripGainFromCalibTree.cc
Expand Up @@ -82,6 +82,7 @@
#include "CalibTracker/SiStripChannelGain/interface/APVGainHelpers.h"

#include <unordered_map>
#include <array>



Expand Down Expand Up @@ -208,7 +209,8 @@ class SiStripGainFromCalibTree : public ConditionDBWriter<SiStripApvGain> {
MonitorElement* MPV_Vs_PhiTECthin; /*!< MPV vs Phi for TEC thin planes */
MonitorElement* MPV_Vs_PhiTECthick; /*!< MPV vs Phi for TID tick planes */

MonitorElement* NoMPV; /*!< R,Z map of missing APV calibration */
MonitorElement* NoMPVmasked; /*!< R,Z map of missing APV calibration (masked modules)*/
MonitorElement* NoMPVfit; /*!< R,Z map of missing APV calibration (no fit) */

MonitorElement* Gains; /*!< distribution of gain factors */
MonitorElement* MPVs; /*!< distribution of MPVs */
Expand Down Expand Up @@ -479,7 +481,33 @@ void SiStripGainFromCalibTree::bookDQMHistos(const char* dqm_dir, const char* ta

int elepos = (m_harvestingMode && AlgoMode=="PCL")? Harvest : statCollectionFromMode(tag);

Charge_Vs_Index[elepos] = dbe->book2S(cvi.c_str() , cvi.c_str() , 88625, 0 , 88624,2000,0,4000);
// The cluster charge is stored by exploiting a non uniform binning in order
// reduce the histogram memory size. The bin width is relaxed with a falling
// exponential function and the bin boundaries are stored in the binYarray.
// The binXarray is used to provide as many bins as the APVs.
//
// More details about this implementations are here:
// https://indico.cern.ch/event/649344/contributions/2672267/attachments/1498323/2332518/OptimizeChHisto.pdf

std::vector<float> binXarray;
binXarray.reserve( NStripAPVs+1 );
for(int a=0;a<=NStripAPVs;a++){
binXarray.push_back( (float)a );
}

std::array<float,688> binYarray;
double p0 = 5.445;
double p1 = 0.002113;
double p2 = 69.01576;
double y = 0.;
for(int b=0;b<687;b++) {
binYarray[b] = y;
if(y<=902.) y = y + 2.;
else y = ( p0 - log(exp(p0-p1*y) - p2*p1)) / p1;
}
binYarray[687] = 4000.;

Charge_Vs_Index[elepos] = dbe->book2S(cvi.c_str() , cvi.c_str() , NStripAPVs, &binXarray[0], 687, binYarray.data());
//Charge_Vs_Index_Absolute[elepos] = dbe->book2S(cviA.c_str() , cviA.c_str() , 88625, 0 , 88624,1000,0,4000);
Charge_Vs_PathlengthTIB[elepos] = dbe->book2S(cvpTIB.c_str() , cvpTIB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
Charge_Vs_PathlengthTOB[elepos] = dbe->book2S(cvpTOB.c_str() , cvpTOB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
Expand Down Expand Up @@ -551,7 +579,8 @@ void SiStripGainFromCalibTree::bookDQMHistos(const char* dqm_dir, const char* ta
MPV_Vs_PhiTECthin = dbe->book2DD("MPV_vs_PhiTEC1","MPV vs Phi TEC-thin" , 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
MPV_Vs_PhiTECthick = dbe->book2DD("MPV_vs_PhiTEC2","MPV vs Phi TEC-thick", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);

NoMPV = dbe->book2DD("NoMPV" ,"NoMPV" ,350, -350, 350, 240, 0, 120);
NoMPVfit = dbe->book2DD("NoMPVfit" ,"Modules with bad Landau Fit",350, -350, 350, 240, 0, 120);
NoMPVmasked = dbe->book2DD("NoMPVmasked" ,"Masked Modules" ,350, -350, 350, 240, 0, 120);

Gains = dbe->book1DD("Gains" ,"Gains" , 300, 0, 2);
MPVs = dbe->book1DD("MPVs" ,"MPVs" , MPVbin, MPVmin, MPVmax);
Expand Down Expand Up @@ -969,7 +998,7 @@ SiStripGainFromCalibTree::algoEndJob() {
algoAnalyzeTheTree();
}else if(m_harvestingMode){
NClusterStrip = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 );
NClusterPixel = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(NStripAPVs+2, NStripAPVs+NPixelDets+2, 0, 99999 );
//NClusterPixel = (Charge_Vs_Index[Harvest])->getTH2S()->Integral(NStripAPVs+2, NStripAPVs+NPixelDets+2, 0, 99999 );
}

// Now that we have the full statistics we can extract the information of the 2D histograms
Expand Down Expand Up @@ -1121,7 +1150,10 @@ void SiStripGainFromCalibTree::processEvent() {
if(Validation) {ClusterChargeOverPath/=(*gainused)[i];}
if(OldGainRemoving){ClusterChargeOverPath*=(*gainused)[i];}
}
//(Charge_Vs_Index_Absolute[elepos])->Fill(APV->Index,Charge);

// keep pixel cluster charge processing until here
if(APV->SubDet<=2) continue;

(Charge_Vs_Index[elepos]) ->Fill(APV->Index,ClusterChargeOverPath);


Expand Down Expand Up @@ -1358,8 +1390,9 @@ void SiStripGainFromCalibTree::qualityMonitor() {
}


if (FitMPV<0.) { // No fit of MPV
NoMPV->Fill(z,R);
if (FitMPV<=0.) { // No fit of MPV
if (APV->isMasked) NoMPVmasked->Fill(z,R);
else NoMPVfit->Fill(z,R);

} else { // Fit of MPV
if(FitMPV>0.) Gains->Fill(Gain);
Expand Down Expand Up @@ -1482,19 +1515,19 @@ void SiStripGainFromCalibTree::storeOnTree(TFileService* tfs)
FILE* Gains = stdout;
fprintf(Gains,"NEvents = %i\n",NEvent);
fprintf(Gains,"NTracks = %i\n",NTrack);
fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
//fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
//fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);

Gains=fopen(OutputGains.c_str(),"w");
fprintf(Gains,"NEvents = %i\n",NEvent);
fprintf(Gains,"NTracks = %i\n",NTrack);
fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
//fprintf(Gains,"NClustersPixel = %i\n",NClusterPixel);
fprintf(Gains,"NClustersStrip = %i\n",NClusterStrip);
fprintf(Gains,"Number of Strip APVs = %lu\n",static_cast<unsigned long>(NStripAPVs));
fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
//fprintf(Gains,"Number of Pixel Dets = %lu\n",static_cast<unsigned long>(NPixelDets));
fprintf(Gains,"GoodFits = %i BadFits = %i ratio = %f%% (MASKED=%i)\n",GOOD,BAD,(100.0*GOOD)/(GOOD+BAD), MASKED);

int elepos = statCollectionFromMode(m_calibrationMode.c_str());
Expand Down
Expand Up @@ -186,7 +186,8 @@ SiStripGainsPCLHarvester::gainQualityMonitor(DQMStore::IBooker& ibooker_, const
MonitorElement* MPV_Vs_PhiTECthin = ibooker_.book2DD("MPVvsPhiTEC1","MPV vs Phi TEC-thin ",50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
MonitorElement* MPV_Vs_PhiTECthick = ibooker_.book2DD("MPVvsPhiTEC2","MPV vs Phi TEC-thick",50,-3.4,3.4,MPVbin,MPVmin,MPVmax);

MonitorElement* NoMPV = ibooker_.book2DD("NoMPV" ,"NoMPV" ,350, -350, 350, 240, 0, 120);
MonitorElement* NoMPVfit = ibooker_.book2DD("NoMPVfit" ,"Modules with bad Landau Fit",350, -350, 350, 240, 0, 120);
MonitorElement* NoMPVmasked = ibooker_.book2DD("NoMPVmasked" ,"Masked Modules" ,350, -350, 350, 240, 0, 120);

MonitorElement* Gains = ibooker_.book1DD("Gains" ,"Gains" , 300, 0, 2);
MonitorElement* MPVs = ibooker_.book1DD("MPVs" ,"MPVs" , MPVbin,MPVmin,MPVmax);
Expand Down Expand Up @@ -262,8 +263,9 @@ SiStripGainsPCLHarvester::gainQualityMonitor(DQMStore::IBooker& ibooker_, const
}


if (FitMPV<0.) { // No fit of MPV
NoMPV->Fill(z,R);
if (FitMPV<=0.) { // No fit of MPV
if (APV->isMasked) NoMPVmasked->Fill(z,R);
else NoMPVfit->Fill(z,R);

} else { // Fit of MPV
if(FitMPV>0.) Gains->Fill(Gain);
Expand Down
33 changes: 31 additions & 2 deletions CalibTracker/SiStripChannelGain/src/SiStripGainsPCLWorker.cc
Expand Up @@ -267,6 +267,9 @@ void SiStripGainsPCLWorker::processEvent(const TrackerTopology* topo) {
if(Validation) {ClusterChargeOverPath/=(*gainused)[i];}
if(OldGainRemoving){ClusterChargeOverPath*=(*gainused)[i];}
}

// keep processing of pixel cluster charge until here
if(APV->SubDet<=2) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

hi @dimattia , Question : can't we get rid completely of the pixel part ? there are have checks and computation for the pixel above this line like here
https://github.com/dimattia/cmssw/blob/8bdcb4372e22de2ac5112b37575b3bead83546a5/CalibTracker/SiStripChannelGain/src/SiStripGainsPCLWorker.cc#L262
or here :
https://github.com/dimattia/cmssw/blob/8bdcb4372e22de2ac5112b37575b3bead83546a5/CalibTracker/SiStripChannelGain/src/SiStripGainsPCLWorker.cc#L238
which are eventually not used - Same comments for SiStripGainFromCalibTree.cc .
What do you think ? thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ciao @boudoul in principle yes because the pixel cluster charge is neither collected in the AlCARECO histograms nor used. Anyway, I would like to keep the Pixel hit processing for a while because we may discover that, with the new Pixel detector readout, filtering the statistic according to the quality of the pixel hits in the track helps the quality of the dE/dx estimation for the Strip.


// real histogram for calibration
(Charge_Vs_Index[elepos])->Fill(APV->Index,ClusterChargeOverPath);
Expand Down Expand Up @@ -512,8 +515,35 @@ SiStripGainsPCLWorker::bookHistograms(DQMStore::IBooker & ibooker, edm::Run cons
std::string cvpTECM2 = std::string("Charge_Vs_PathlengthTECM2") + stag;

int elepos = statCollectionFromMode(tag);

// The cluster charge is stored by exploiting a non uniform binning in order
// reduce the histogram memory size. The bin width is relaxed with a falling
// exponential function and the bin boundaries are stored in the binYarray.
// The binXarray is used to provide as many bins as the APVs.
//
// More details about this implementations are here:
// https://indico.cern.ch/event/649344/contributions/2672267/attachments/1498323/2332518/OptimizeChHisto.pdf

std::vector<float> binXarray;
binXarray.reserve( NStripAPVs+1 );
for(int a=0;a<=NStripAPVs;a++){
binXarray.push_back( (float)a );
}


std::array<float,688> binYarray;
double p0 = 5.445;
double p1 = 0.002113;
double p2 = 69.01576;
double y = 0.;
for(int b=0;b<687;b++) {
binYarray[b] = y;
if(y<=902.) y = y + 2.;
else y = ( p0 - log(exp(p0-p1*y) - p2*p1)) / p1;
}
binYarray[687] = 4000.;

Charge_Vs_Index[elepos] = ibooker.book2S(cvi.c_str() , cvi.c_str() , 88625, 0 , 88624,2000,0,4000);
Charge_Vs_Index[elepos] = ibooker.book2S(cvi.c_str() , cvi.c_str() , NStripAPVs, &binXarray[0], 687, binYarray.data());
Charge_Vs_PathlengthTIB[elepos] = ibooker.book2S(cvpTIB.c_str() , cvpTIB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
Charge_Vs_PathlengthTOB[elepos] = ibooker.book2S(cvpTOB.c_str() , cvpTOB.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
Charge_Vs_PathlengthTIDP[elepos] = ibooker.book2S(cvpTIDP.c_str() , cvpTIDP.c_str() , 20 , 0.3 , 1.3 , 250,0,2000);
Expand Down Expand Up @@ -562,5 +592,4 @@ SiStripGainsPCLWorker::bookHistograms(DQMStore::IBooker & ibooker, edm::Run cons
int plane = APVGain::subdetectorPlane((hnames[i]).first);
Charge_4[elepos].push_back( APVGain::APVmon(id,side,plane,monitor) );
}

}
18 changes: 18 additions & 0 deletions DQMServices/Core/src/DQMStore.cc
Expand Up @@ -1242,6 +1242,24 @@ DQMStore::book2D(const std::string &name, const std::string &title,
nchX, xbinsize, nchY, ybinsize));
}

/// Book 2S variable bin histogram.
MonitorElement *
DQMStore::book2S(const char *name, const char *title,
int nchX, const float *xbinsize, int nchY, const float *ybinsize)
{
return book2S(pwd_, name, new TH2S(name, title,
nchX, xbinsize, nchY, ybinsize));
}

/// Book 2S variable bin histogram.
MonitorElement *
DQMStore::book2S(const std::string &name, const std::string &title,
int nchX, const float *xbinsize, int nchY, const float *ybinsize)
{
return book2S(pwd_, name, new TH2S(name.c_str(), title.c_str(),
nchX, xbinsize, nchY, ybinsize));
}

/// Book 2D histogram by cloning an existing histogram.
MonitorElement *
DQMStore::book2D(const char *name, TH2F *source)
Expand Down