Skip to content

Commit

Permalink
Merge pull request cms-sw#15 from jozzez1/Run2HSCP_Jozze
Browse files Browse the repository at this point in the history
Run2 hscp jozze
  • Loading branch information
quertenmont committed Aug 5, 2015
2 parents bf9c0df + c23cefa commit 59e4468
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 175 deletions.
34 changes: 23 additions & 11 deletions SUSYBSMAnalysis/HSCP/test/AnalysisCode/Analysis_CommonFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class DuplicatesClass{


TH3F* loadDeDxTemplate(string path, bool splitByModuleType=false);
reco::DeDxData* computedEdx(const DeDxHitInfo* dedxHits, double scaleFactor=1.0, TH3* templateHisto=NULL, bool usePixel=false, bool useClusterCleaning=true, bool reverseProb=false, bool useTruncated=false, std::unordered_map<unsigned int,double>* TrackerGains=NULL, bool useStrip=true, bool mustBeInside=false);
reco::DeDxData* computedEdx(const DeDxHitInfo* dedxHits, double* scaleFactors, TH3* templateHisto=NULL, bool usePixel=false, bool useClusterCleaning=true, bool reverseProb=false, bool useTruncated=false, std::unordered_map<unsigned int,double>* TrackerGains=NULL, bool useStrip=true, bool mustBeInside=false);
bool clusterCleaning(const SiStripCluster* cluster, bool crosstalkInv=false );
void printStripCluster(FILE* pFile, const SiStripCluster* cluster, const DetId& DetId);

Expand Down Expand Up @@ -554,23 +554,32 @@ bool isHitInsideTkModule(const LocalPoint hitPos, const DetId& detid){
if(fabs(nx)>1.0)return false;
if(fabs(ny)>1.0)return false;

//Remove hits close to the border //FIXME to be activated in this code
//double absDistEdgeXNorm = 1-fabs(hscpHitsInfo.localx[h])/(hscpHitsInfo.modwidth [h]/2.0);
//double absDistEdgeYNorm = 1-fabs(hscpHitsInfo.localy[h])/(hscpHitsInfo.modlength[h]/2.0);
//if(detid.subdetId()==1 && (absDistEdgeXNorm<0.05 || absDistEdgeYNorm<0.01)) continue;
//if(detid.subdetId()==2 && (absDistEdgeXNorm<0.05 || absDistEdgeYNorm<0.01)) continue;
//if(detid.subdetId()==3 && (absDistEdgeXNorm<0.005 || absDistEdgeYNorm<0.04)) continue;
//if(detid.subdetId()==4 && (absDistEdgeXNorm<0.005 || absDistEdgeYNorm<0.02)) continue;
//if(detid.subdetId()==5 && (absDistEdgeXNorm<0.005 || absDistEdgeYNorm<0.02 || absDistEdgeYNorm>0.97)) continue;
//if(detid.subdetId()==6 && (absDistEdgeXNorm<0.005 || absDistEdgeYNorm<0.03 || absDistEdgeYNorm>0.8)) continue;
// "blacklists" for the gaps and edges
// FIXME APVs are missing for now!!!
switch (detid.subdetId()){
case 1: if (ny > 0.96 || ny < -0.96 || nx < -0.98 || 0.98 > nx) return false; break;
case 2: if (ny > 0.97 || ny < -0.97 || nx < -0.99 || 0.99 > nx) return false; break;
case 5: if (ny > 0.98 || ny < -0.98 || nx < -0.98 || 0.98 > nx) return false; break;
case 6: if (ny > 0.98 || ny < -0.98 || nx < -0.99 || 0.99 > nx) return false; break;
case 7: if (ny > 0.97 || ny < -0.99 || nx < -0.98 || 0.98 > nx) return false; break;
case 8: if (ny > 0.98 || ny < -0.98 || nx < -0.99 || 0.99 > nx) return false; break;
case 9: if (ny > 0.98 || ny < -0.98 || nx < -0.99 || 0.99 > nx) return false; break;
case 10: if (ny > 0.97 || ny < -0.97 || nx < -0.99 || 0.99 > nx) return false; break;
case 11: if (ny > 0.97 || ny < -0.97 || nx < -0.99 || 0.99 > nx) return false; break;
case 3: if (ny > 0.98 || ny < -0.98 || nx < -0.98 || 0.98 > nx || (ny < 0.04 && ny > -0.04)) return false; break;
case 4: if (ny > 0.98 || ny < -0.98 || nx < -0.98 || 0.98 > nx || (ny < 0.04 && ny > -0.04)) return false; break;
case 12: if (ny > 0.98 || ny < -0.98 || nx < -0.99 || 0.99 > nx || (ny < -0.07 && ny > -0.17)) return false; break;
case 13: if (ny > 0.97 || ny < -0.97 || nx < -0.99 || 0.99 > nx || (ny < -0.01 && ny > -0.10)) return false; break;
case 14: if (ny > 0.95 || ny < -0.97 || nx < -0.99 || 0.98 > nx || (ny < 0.12 && ny > 0.01)) return false; break;
}

return true;
}




DeDxData* computedEdx(const DeDxHitInfo* dedxHits, double scaleFactor, TH3* templateHisto, bool usePixel, bool useClusterCleaning, bool reverseProb, bool useTruncated, std::unordered_map<unsigned int,double>* TrackerGains, bool useStrip, bool mustBeInside){
DeDxData* computedEdx(const DeDxHitInfo* dedxHits, double* scaleFactors, TH3* templateHisto, bool usePixel, bool useClusterCleaning, bool reverseProb, bool useTruncated, std::unordered_map<unsigned int,double>* TrackerGains, bool useStrip, bool mustBeInside){
if(!dedxHits) return NULL;
if(templateHisto)usePixel=false; //never use pixel for discriminator

Expand Down Expand Up @@ -616,6 +625,9 @@ DeDxData* computedEdx(const DeDxHitInfo* dedxHits, double scaleFactor, TH3* temp
if(isSatCluster)NSat++;
}

double scaleFactor = scaleFactors[0];
if (detid.subdetId()<3) scaleFactor *= scaleFactors[1];

if(templateHisto){ //save discriminator probability
double ChargeOverPathlength = scaleFactor*ClusterCharge/(dedxHits->pathlength(h)*10.0);
SiStripDetId SSdetId(detid); //we sure it's strip since template force the use of usePixel=false
Expand Down
16 changes: 13 additions & 3 deletions SUSYBSMAnalysis/HSCP/test/AnalysisCode/Analysis_Step1_EventLoop.C
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ edm::LumiReWeighting LumiWeightsMCSyst;

TH3F* dEdxTemplates = NULL;
std::unordered_map<unsigned int,double> TrackerGains;
double dEdxSF = 1.0;
double dEdxSF [2] = {
1.00000, // [0] unchanged
1.14958 // [1] Pixel data to SiStrip data
};

//dEdxSF [0] = 1.09708; // [1] Monte Carlo SiStrip to data SiStrip
//dEdxSF [1] = 1.01875; // [3] Monte Carlo Pixel to Monte Carlo SiStrip !!! MC Pixel to Data SiStrip = [3] * [1] ~ 11


bool useClusterCleaning = true;
/////////////////////////// CODE PARAMETERS /////////////////////////////

Expand Down Expand Up @@ -958,10 +966,12 @@ void Analysis_Step1_EventLoop(char* SavePath)
bool isSignal = (samples[s].Type>=2);

if(isData){
dEdxSF = 1.00000;
dEdxSF [0] = 1.00000;
dEdxSF [1] = 1.14985;
dEdxTemplates = loadDeDxTemplate("../../data/Data13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", true);
}else{
dEdxSF = 1.09708;
dEdxSF [0] = 1.09708;
dEdxSF [1] = 1.01875;
dEdxTemplates = loadDeDxTemplate("../../data/MC13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", true);
}

Expand Down
27 changes: 18 additions & 9 deletions SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct dEdxStudyObj
TProfile2D* Charge_Vs_XY[15];
TH2D* Charge_Vs_XYH[15];
TProfile2D* Charge_Vs_XYN[15];
TProfile2D* Charge_Vs_XYCSize[15];
TH2D* Charge_Vs_XYHN[15];
TH2D* Charge_Vs_XYLN[15];

Expand Down Expand Up @@ -126,12 +127,13 @@ struct dEdxStudyObj
HistoName = Name + "_ChargeVsPath"; Charge_Vs_Path = new TH3D( HistoName.c_str(), HistoName.c_str(), P_NBins, P_Min, P_Max, Path_NBins, Path_Min, Path_Max, Charge_NBins, Charge_Min, Charge_Max);
for(unsigned int g=0;g<15;g++){
char Id[255]; sprintf(Id, "%02i", g);
HistoName = Name + "_ChargeVsFS"+Id; Charge_Vs_FS[g] = new TProfile( HistoName.c_str(), HistoName.c_str(), 769, 0, 769);
HistoName = Name + "_ChargeVsXY"+Id; Charge_Vs_XY[g] = new TProfile2D( HistoName.c_str(), HistoName.c_str(), 250, -15, 15, 250, -15, 15);
HistoName = Name + "_ChargeVsXYH"+Id; Charge_Vs_XYH[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -15, 15, 250, -15, 15);
HistoName = Name + "_ChargeVsXYN"+Id; Charge_Vs_XYN[g] = new TProfile2D( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsXYHN"+Id; Charge_Vs_XYHN[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsXYLN"+Id; Charge_Vs_XYLN[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsFS"+Id; Charge_Vs_FS[g] = new TProfile ( HistoName.c_str(), HistoName.c_str(), 769, 0, 769);
HistoName = Name + "_ChargeVsXY"+Id; Charge_Vs_XY[g] = new TProfile2D( HistoName.c_str(), HistoName.c_str(), 250, -15, 15, 250, -15, 15);
HistoName = Name + "_ChargeVsXYH"+Id; Charge_Vs_XYH[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -15, 15, 250, -15, 15);
HistoName = Name + "_ChargeVsXYN"+Id; Charge_Vs_XYN[g] = new TProfile2D( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsXYHN"+Id; Charge_Vs_XYHN[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsXYLN"+Id; Charge_Vs_XYLN[g] = new TH2D ( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
HistoName = Name + "_ChargeVsXYCSize"+Id; Charge_Vs_XYCSize[g] = new TProfile2D( HistoName.c_str(), HistoName.c_str(), 250, -1.5, 1.5, 250, -1.5, 1.5);
}
}
}
Expand Down Expand Up @@ -197,11 +199,13 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT
TH3F* dEdxTemplates = NULL;
TH3F* dEdxTemplatesInc = NULL;
if(isData){ //FIXME update template on data directory
dEdxSF = 1.0;
dEdxSF [0] = 1.00000;
dEdxSF [1] = 1.14985;
dEdxTemplates = loadDeDxTemplate(DIRNAME + "/../../../data/Data13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", true);
dEdxTemplatesInc = loadDeDxTemplate(DIRNAME + "/../../../data/Data13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", false);
}else{
dEdxSF = 1.09708;
dEdxSF [0] = 1.09708;
dEdxSF [1] = 1.01875;
dEdxTemplates = loadDeDxTemplate(DIRNAME + "/../../../data/MC13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", true);
dEdxTemplatesInc = loadDeDxTemplate(DIRNAME + "/../../../data/MC13TeV_Deco_SiStripDeDxMip_3D_Rcd.root", false);
}
Expand Down Expand Up @@ -266,7 +270,8 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT
if(track->p() > 5){
for(unsigned int h=0;h<dedxHits->size();h++){
DetId detid(dedxHits->detId(h));
double scaleFactor = dEdxSF;
double scaleFactor = dEdxSF[0];
if (detid.subdetId()<3) scaleFactor *= dEdxSF[1];
double Norm = (detid.subdetId()<3)?3.61e-06:3.61e-06*265;
double ChargeOverPathlength = scaleFactor*Norm*dedxHits->charge(h)/dedxHits->pathlength(h);

Expand All @@ -285,6 +290,10 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT
if(detid.subdetId()>=3)results[R]->Charge_Vs_FS[moduleGeometry]->Fill(dedxHits->stripCluster(h)->firstStrip(), dedxHits->charge(h));
results[R]->Charge_Vs_XY[moduleGeometry]->Fill(dedxHits->pos(h).x(), dedxHits->pos(h).y(), dedxHits->charge(h));
results[R]->Charge_Vs_XYH[moduleGeometry]->Fill(dedxHits->pos(h).x(), dedxHits->pos(h).y());

results[R]->Charge_Vs_XYCSize[moduleGeometry]->Fill(dedxHits->pos(h).x(), dedxHits->pos(h).y(), detid.subdetId() >= 3
? dedxHits->stripCluster(h)->amplitudes().size()
: dedxHits->pixelCluster(h)->size());

if(moduleGeometry>=1){
double nx, ny;
Expand Down
Loading

0 comments on commit 59e4468

Please sign in to comment.