From b29bed837ad14a97ec7b527c2fa129f79e8caf5d Mon Sep 17 00:00:00 2001 From: Joze Zobec Date: Tue, 28 Jul 2015 21:00:51 +0200 Subject: [PATCH 1/5] fixed Merge_cfg.py so it can handle more than 255 files at once --- .../HSCP/test/MakeEDMtuples/Sample_Data/Merge_cfg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUSYBSMAnalysis/HSCP/test/MakeEDMtuples/Sample_Data/Merge_cfg.py b/SUSYBSMAnalysis/HSCP/test/MakeEDMtuples/Sample_Data/Merge_cfg.py index 5427cc244936f..05c307e0b7ca2 100644 --- a/SUSYBSMAnalysis/HSCP/test/MakeEDMtuples/Sample_Data/Merge_cfg.py +++ b/SUSYBSMAnalysis/HSCP/test/MakeEDMtuples/Sample_Data/Merge_cfg.py @@ -7,9 +7,9 @@ process.MessageLogger.cerr.FwkReport.reportEvery = 5000 process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( + fileNames = cms.untracked.vstring( *( XXX_INPUT_XXX - ) + ) ) ) process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) From 28e27613c6564d1f67561144fd81253c42cd15e1 Mon Sep 17 00:00:00 2001 From: Joze Zobec Date: Tue, 28 Jul 2015 21:34:39 +0200 Subject: [PATCH 2/5] fix which saves the histograms in the file --- .../test/UsefulScripts/DeDxStudy/DeDxStudy.C | 323 +++++++++++------- 1 file changed, 202 insertions(+), 121 deletions(-) diff --git a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C index 45a128d90a202..7e3b4b39265e4 100644 --- a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C +++ b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C @@ -50,6 +50,94 @@ using namespace trigger; #endif +const double P_Min = 1; +const double P_Max = 15; +const int P_NBins = 14 ; +const double Path_Min = 0.2 ; +const double Path_Max = 1.6 ; +const int Path_NBins = 42 ; +const double Charge_Min = 0 ; +const double Charge_Max = 5000; +const int Charge_NBins = 500 ; + +struct dEdxStudyObj +{ + string Name; + TH3D* Charge_Vs_Path; + TH1D* HdedxMIP; + TH2D* HdedxVsPHSCP; + TH2D* HdedxVsP; + TH2D* HdedxVsPM; + TH2D* HdedxVsQP; + TProfile* HdedxVsPProfile; + TProfile* HdedxVsEtaProfile; + TH2D* HdedxVsEta; + TProfile* HNOSVsEtaProfile; + TProfile* HNOMVsEtaProfile; + TProfile* HNOMSVsEtaProfile; + TH1D* HMass; + TH1D* HP; + TH1D* HHit; + TH2D* HIasVsP; + TH2D* HIasVsPM; + TH1D* HIasMIP; + TH2D* IasVsEta_Split; + TH2D* IasVsEta_Unsplit; + TProfile* IasVsEta_ProfileS; + TProfile* IasVsEta_ProfileU; + + dEdxStudyObj(string saveName){ + Name = saveName; + + bool isDiscrim = false; if(saveName.find("Ias")!=std::string::npos)isDiscrim = true; + + + string HistoName; + HistoName = saveName + "_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); + HistoName = saveName + "_MIP"; HdedxMIP = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, isDiscrim?1.0:20); + HistoName = saveName + "_dedxVsPHSCP"; HdedxVsPHSCP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 2000,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsP"; HdedxVsP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsPM"; HdedxVsPM = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsQP"; HdedxVsQP = new TH2D( HistoName.c_str(), HistoName.c_str(), 6000, -30, 30,1500,0, isDiscrim?1.0:25); + HistoName = saveName + "_Profile"; HdedxVsPProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100, 0,100); + HistoName = saveName + "_Eta"; HdedxVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Eta2D"; HdedxVsEta = new TH2D (HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 1000,0, isDiscrim?1.0:5); + HistoName = saveName + "_NOS"; HNOSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOM"; HNOMVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOMS"; HNOMSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Mass"; HMass = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 10); + HistoName = saveName + "_P"; HP = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 100); + HistoName = saveName + "_Hit"; HHit = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, 20); + HistoName = saveName + "_IasVsEta_Split"; IasVsEta_Split = new TH2D( HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 50, 0, 1.0); + HistoName = saveName + "_IasVsEta_Unsplit"; IasVsEta_Unsplit = new TH2D( HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 50, 0, 1.0); + HistoName = saveName + "_IasVsEta_ProfileS"; IasVsEta_ProfileS = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_IasVsEta_ProfileU"; IasVsEta_ProfileU = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + } +}; + +void Write_dEdxStudyObj (dEdxStudyObj* Obj){ + Obj->Charge_Vs_Path ->Write(); + Obj->HdedxMIP ->Write(); + Obj->HdedxVsPHSCP ->Write(); + Obj->HdedxVsP ->Write(); + Obj->HdedxVsPM ->Write(); + Obj->HdedxVsQP ->Write(); + Obj->HdedxVsPProfile ->Write(); + Obj->HdedxVsEtaProfile ->Write(); + Obj->HdedxVsEta ->Write(); + Obj->HNOSVsEtaProfile ->Write(); + Obj->HNOMVsEtaProfile ->Write(); + Obj->HNOMSVsEtaProfile ->Write(); + Obj->HMass ->Write(); + Obj->HP ->Write(); + Obj->HHit ->Write(); + Obj->IasVsEta_Split ->Write(); + Obj->IasVsEta_Unsplit ->Write(); + Obj->IasVsEta_ProfileS ->Write(); + Obj->IasVsEta_ProfileU ->Write(); +} + + void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT="out.root") @@ -73,7 +161,12 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT std::vector FileName; bool isData = true; if(INPUT.find(".root")10)break; - ev.to(e); - if(e%TreeStep==0){printf(".");fflush(stdout);} - - fwlite::Handle dedxCollH; - dedxCollH.getByLabel(ev, "dedxHitInfo"); - if(!dedxCollH.isValid()){printf("Invalid dedxCollH\n");continue;} - - fwlite::Handle< std::vector > trackCollHandle; - trackCollHandle.getByLabel(ev,"RefitterForDeDx"); - if(!trackCollHandle.isValid()){ - trackCollHandle.getByLabel(ev,"generalTracks"); - if (!trackCollHandle.isValid()){ - printf("Invalid trackCollHandle\n"); - continue; - } - } - - - for(unsigned int c=0;csize();c++){ - reco::TrackRef track = reco::TrackRef( trackCollHandle.product(), c ); - - if(track->chi2()/track->ndof()>5 )continue; //WAS >1 - if(track->found()<8)continue; - - - const DeDxHitInfo* dedxHits = NULL; - if(TypeMode!=3 && !track.isNull()) { - DeDxHitInfoRef dedxHitsRef = dedxCollH->get(track.key()); - if(!dedxHitsRef.isNull())dedxHits = &(*dedxHitsRef); - } - if(!dedxHits)continue; + std::unordered_map TrackerGains; + LoadDeDxCalibration(TrackerGains, DIRNAME+"/Gains.root"); + printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n"); + printf("Looping on Tree :"); + int TreeStep = ev.size()/50;if(TreeStep==0)TreeStep=1; + for(Long64_t e=0;esize();h++){ - DetId detid(dedxHits->detId(h)); - if(detid.subdetId()<3)continue; // skip pixels - - double scaleFactor = 1.0; - double Norm = (detid.subdetId()<3)?3.61e-06:3.61e-06*265; - double ChargeOverPathlength = scaleFactor*Norm*dedxHits->charge(h)/dedxHits->pathlength(h); - - SiStripDetId SSdetId(detid); - if (track->p() > 5) Charge_Vs_Path->Fill (SSdetId.moduleGeometry(), - dedxHits->pathlength(h)*10, - dedxHits->charge(h)/(dedxHits->pathlength(h)*10)); - HHit->Fill(ChargeOverPathlength); - } + fwlite::Handle dedxCollH; + dedxCollH.getByLabel(ev, "dedxHitInfo"); + if(!dedxCollH.isValid()){printf("Invalid dedxCollH\n");continue;} - DeDxData* dedxSObj = computedEdx(dedxHits, dEdxSF, dEdxTemplates, false, useClusterCleaning, false, false ); - DeDxData* dedxMObj = computedEdx(dedxHits, dEdxSF, NULL, false, useClusterCleaning, false, LOOP==0?false:true ); + fwlite::Handle< std::vector > trackCollHandle; + trackCollHandle.getByLabel(ev,"RefitterForDeDx"); + if(!trackCollHandle.isValid()){ + trackCollHandle.getByLabel(ev,"generalTracks"); + if (!trackCollHandle.isValid()){ + printf("Invalid trackCollHandle\n"); + continue; + } + } - HdedxVsPHSCP->Fill(track->pt(), dedxMObj->dEdx()); + for(unsigned int c=0;csize();c++){ + reco::TrackRef track = reco::TrackRef( trackCollHandle.product(), c ); - if(track->pt()>20 && track->pt()<40 && dedxMObj->numberOfMeasurements()>6 ){ - HdedxVsEtaProfile->Fill(track->eta(), dedxMObj->dEdx() ); - HdedxVsEta->Fill(track->eta(), dedxMObj->dEdx() ); - HNOMVsEtaProfile->Fill(track->eta(),dedxMObj->numberOfMeasurements() ); - HNOSVsEtaProfile->Fill(track->eta(),dedxMObj->numberOfSaturatedMeasurements() ); - HNOMSVsEtaProfile->Fill(track->eta(),dedxMObj->numberOfMeasurements() - dedxMObj->numberOfSaturatedMeasurements() ); - } + if(track->chi2()/track->ndof()>5 )continue; //WAS >1 + if(track->found()<8)continue; - if(fabs(track->eta())>2.1)continue; - if((int)dedxMObj->numberOfMeasurements()<10)continue; - if(track->p()>5 && track->p()<40){ - HdedxMIP->Fill(dedxMObj->dEdx()); - HP->Fill(track->p()); - HIasMIP->Fill(dedxSObj->dEdx()); + const DeDxHitInfo* dedxHits = NULL; + if(TypeMode!=3 && !track.isNull()) { + DeDxHitInfoRef dedxHitsRef = dedxCollH->get(track.key()); + if(!dedxHitsRef.isNull())dedxHits = &(*dedxHitsRef); + } + if(!dedxHits)continue; + + + for(unsigned int h=0;hsize();h++){ + DetId detid(dedxHits->detId(h)); + if(detid.subdetId()<3)continue; // skip pixels + + double scaleFactor = 1.0; + double Norm = (detid.subdetId()<3)?3.61e-06:3.61e-06*265; + double ChargeOverPathlength = scaleFactor*Norm*dedxHits->charge(h)/dedxHits->pathlength(h); + + SiStripDetId SSdetId(detid); + + + if (track->p() > 5){ + for(unsigned int R=0;RCharge_Vs_Path->Fill (SSdetId.moduleGeometry(), dedxHits->pathlength(h)*10, dedxHits->charge(h)/(dedxHits->pathlength(h)*10)); } } - HdedxVsP ->Fill(track->p(), dedxMObj->dEdx() ); - HdedxVsQP->Fill(track->p()*track->charge(), dedxMObj->dEdx() ); - HIasVsP ->Fill(track->p(), dedxSObj->dEdx() ); - - if(fabs(track->eta())<0.4)HdedxVsPProfile->Fill(track->p(), dedxMObj->dEdx() ); - double Mass = GetMass(track->p(),dedxMObj->dEdx(), false); - if(dedxMObj->dEdx()>4.0 && track->p()<3.0){ - HMass->Fill(Mass); - if(isnan((float)Mass) || Mass<0.94-0.3 || Mass>0.94+0.3)continue; - HdedxVsPM ->Fill(track->p(), dedxMObj->dEdx() ); - HIasVsPM ->Fill(track->p(), dedxSObj->dEdx() ); + for(unsigned int R=0;RHHit->Fill(ChargeOverPathlength); } + } + + + for(unsigned int R=0;RHdedxVsPHSCP->Fill(track->pt(), dedxObj->dEdx()); + if(track->pt()>20 && track->pt()<40 && dedxObj->numberOfMeasurements()>6 ){ + results[R]->HdedxVsEtaProfile->Fill(track->eta(), dedxObj->dEdx() ); + results[R]->HdedxVsEta->Fill(track->eta(), dedxObj->dEdx() ); + results[R]->HNOMVsEtaProfile->Fill(track->eta(),dedxObj->numberOfMeasurements() ); + results[R]->HNOSVsEtaProfile->Fill(track->eta(),dedxObj->numberOfSaturatedMeasurements() ); + results[R]->HNOMSVsEtaProfile->Fill(track->eta(),dedxObj->numberOfMeasurements() - dedxObj->numberOfSaturatedMeasurements() ); + } - } - }printf("\n"); + if (track->p() > 5 && dEdxNewTemplatesSplit && dEdxNewTemplatesUnsplit){ + bool useraw = studies[R].find("raw") !=std::string::npos ? true : false, + truncate = studies[R].find("trunc")!=std::string::npos ? true : false; + DeDxData* dedxNewObjS = computedEdx(dedxHits, dEdxSF, dEdxNewTemplatesSplit, false, useClusterCleaning, truncate, false, useraw ? &TrackerGains : NULL); + DeDxData* dedxNewObjU = computedEdx(dedxHits, dEdxSF, dEdxNewTemplatesUnsplit, false, useClusterCleaning, truncate, false, useraw ? &TrackerGains : NULL); - HdedxMIP->Scale(1.0/HdedxMIP->Integral() ); - HHit->Scale(1.0/HHit->Integral() ); + results[R]->IasVsEta_Split ->Fill(track->eta(), dedxNewObjS->dEdx()); + results[R]->IasVsEta_ProfileS->Fill(track->eta(), dedxNewObjS->dEdx()); + results[R]->IasVsEta_Unsplit ->Fill(track->eta(), dedxNewObjU->dEdx()); + results[R]->IasVsEta_ProfileU->Fill(track->eta(), dedxNewObjU->dEdx()); + } - } + if(fabs(track->eta())>2.1)continue; + if((int)dedxObj->numberOfMeasurements()<10)continue; + if(track->p()>5 && track->p()<40){ + results[R]->HdedxMIP->Fill(dedxObj->dEdx()); + results[R]->HP->Fill(track->p()); + } + results[R]->HdedxVsP ->Fill(track->p(), dedxObj->dEdx() ); + results[R]->HdedxVsQP->Fill(track->p()*track->charge(), dedxObj->dEdx() ); - Charge_Vs_Path->SaveAs(("ChargeVsPath"+OUTPUT).c_str()); + if(fabs(track->eta())<0.4)results[R]->HdedxVsPProfile->Fill(track->p(), dedxObj->dEdx() ); + double Mass = GetMass(track->p(),dedxObj->dEdx(), false); + if(dedxObj->dEdx()>4.0 && track->p()<3.0){ + results[R]->HMass->Fill(Mass); + if(isnan((float)Mass) || Mass<0.94-0.3 || Mass>0.94+0.3)continue; + results[R]->HdedxVsPM ->Fill(track->p(), dedxObj->dEdx() ); + } + } + } + }printf("\n"); + for (int study_i = 0; study_i < Nstudies; study_i++) + Write_dEdxStudyObj (results[study_i]); OutputHisto->Write(); OutputHisto->Close(); } From b61ef726a3e57d2ca519cc302cfdac88181e5191 Mon Sep 17 00:00:00 2001 From: Joze Zobec Date: Tue, 28 Jul 2015 21:55:52 +0200 Subject: [PATCH 3/5] merged with changes from Loic --- .../test/UsefulScripts/DeDxStudy/DeDxStudy.C | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C index dd5d30b2039ef..b58db4aad48dc 100644 --- a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C +++ b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C @@ -96,6 +96,20 @@ struct dEdxStudyObj HistoName = saveName + "_dedxVsPM"; HdedxVsPM = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); HistoName = saveName + "_dedxVsQP"; HdedxVsQP = new TH2D( HistoName.c_str(), HistoName.c_str(), 6000, -30, 30,1500,0, isDiscrim?1.0:25); HistoName = saveName + "_Profile"; HdedxVsPProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100, 0,100); + HistoName = saveName + "_Eta"; HdedxVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Eta2D"; HdedxVsEta = new TH2D (HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 1000,0, isDiscrim?1.0:5); + HistoName = saveName + "_NOS"; HNOSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOM"; HNOMVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOMS"; HNOMSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Mass"; HMass = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 10); + HistoName = saveName + "_P"; HP = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 100); + HistoName = saveName + "_Hit"; HHit = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, 20); + } +}; + + + + void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT="out.root") @@ -141,15 +155,6 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT } - string studies[] = {"harm2", "trunc40", "harm2_raw", "trunc40_raw", "Ias"}; - unsigned int Nstudies = sizeof(studies)/sizeof(string); - dEdxStudyObj** results = new dEdxStudyObj*[Nstudies]; - for(unsigned int R=0;Rsize();h++){ - DetId detid(dedxHits->detId(h)); - if(detid.subdetId()<3)continue; // skip pixels - - double scaleFactor = 1.0; - double Norm = (detid.subdetId()<3)?3.61e-06:3.61e-06*265; - double ChargeOverPathlength = scaleFactor*Norm*dedxHits->charge(h)/dedxHits->pathlength(h); - - SiStripDetId SSdetId(detid); - - - if (track->p() > 5){ - for(unsigned int R=0;RCharge_Vs_Path->Fill (SSdetId.moduleGeometry(), dedxHits->pathlength(h)*10, dedxHits->charge(h)/(dedxHits->pathlength(h)*10)); } - } - for(unsigned int R=0;RHHit->Fill(ChargeOverPathlength); } - } - - for(unsigned int R=0;Reta())<0.4)results[R]->HdedxVsPProfile->Fill(track->p(), dedxObj->dEdx() ); double Mass = GetMass(track->p(),dedxObj->dEdx(), false); if(dedxObj->dEdx()>4.0 && track->p()<3.0){ + results[R]->HMass->Fill(Mass); + if(isnan((float)Mass) || Mass<0.94-0.3 || Mass>0.94+0.3)continue; + results[R]->HdedxVsPM ->Fill(track->p(), dedxObj->dEdx() ); + } + } + } + }printf("\n"); OutputHisto->Write(); OutputHisto->Close(); } From 3abf73303f1bea63fba803f03eaff808ec12019d Mon Sep 17 00:00:00 2001 From: Joze Zobec Date: Tue, 28 Jul 2015 21:57:53 +0200 Subject: [PATCH 4/5] properly applied patch to save the histograms --- .../test/UsefulScripts/DeDxStudy/DeDxStudy.C | 84 +++++++++++++++---- 1 file changed, 68 insertions(+), 16 deletions(-) diff --git a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C index b58db4aad48dc..7e3b4b39265e4 100644 --- a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C +++ b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/DeDxStudy.C @@ -81,6 +81,10 @@ struct dEdxStudyObj TH2D* HIasVsP; TH2D* HIasVsPM; TH1D* HIasMIP; + TH2D* IasVsEta_Split; + TH2D* IasVsEta_Unsplit; + TProfile* IasVsEta_ProfileS; + TProfile* IasVsEta_ProfileU; dEdxStudyObj(string saveName){ Name = saveName; @@ -89,25 +93,49 @@ struct dEdxStudyObj string HistoName; - HistoName = saveName + "_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); - HistoName = saveName + "_MIP"; HdedxMIP = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, isDiscrim?1.0:20); - HistoName = saveName + "_dedxVsPHSCP"; HdedxVsPHSCP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 2000,1500,0, isDiscrim?1.0:15); - HistoName = saveName + "_dedxVsP"; HdedxVsP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); - HistoName = saveName + "_dedxVsPM"; HdedxVsPM = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); - HistoName = saveName + "_dedxVsQP"; HdedxVsQP = new TH2D( HistoName.c_str(), HistoName.c_str(), 6000, -30, 30,1500,0, isDiscrim?1.0:25); - HistoName = saveName + "_Profile"; HdedxVsPProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100, 0,100); - HistoName = saveName + "_Eta"; HdedxVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); - HistoName = saveName + "_Eta2D"; HdedxVsEta = new TH2D (HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 1000,0, isDiscrim?1.0:5); - HistoName = saveName + "_NOS"; HNOSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); - HistoName = saveName + "_NOM"; HNOMVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); - HistoName = saveName + "_NOMS"; HNOMSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); - HistoName = saveName + "_Mass"; HMass = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 10); - HistoName = saveName + "_P"; HP = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 100); - HistoName = saveName + "_Hit"; HHit = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, 20); + HistoName = saveName + "_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); + HistoName = saveName + "_MIP"; HdedxMIP = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, isDiscrim?1.0:20); + HistoName = saveName + "_dedxVsPHSCP"; HdedxVsPHSCP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 2000,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsP"; HdedxVsP = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsPM"; HdedxVsPM = new TH2D( HistoName.c_str(), HistoName.c_str(), 3000, 0, 30,1500,0, isDiscrim?1.0:15); + HistoName = saveName + "_dedxVsQP"; HdedxVsQP = new TH2D( HistoName.c_str(), HistoName.c_str(), 6000, -30, 30,1500,0, isDiscrim?1.0:25); + HistoName = saveName + "_Profile"; HdedxVsPProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100, 0,100); + HistoName = saveName + "_Eta"; HdedxVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Eta2D"; HdedxVsEta = new TH2D (HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 1000,0, isDiscrim?1.0:5); + HistoName = saveName + "_NOS"; HNOSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOM"; HNOMVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_NOMS"; HNOMSVsEtaProfile = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_Mass"; HMass = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 10); + HistoName = saveName + "_P"; HP = new TH1D( HistoName.c_str(), HistoName.c_str(), 500, 0, 100); + HistoName = saveName + "_Hit"; HHit = new TH1D( HistoName.c_str(), HistoName.c_str(), 200, 0, 20); + HistoName = saveName + "_IasVsEta_Split"; IasVsEta_Split = new TH2D( HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 50, 0, 1.0); + HistoName = saveName + "_IasVsEta_Unsplit"; IasVsEta_Unsplit = new TH2D( HistoName.c_str(), HistoName.c_str(), 100,-3, 3, 50, 0, 1.0); + HistoName = saveName + "_IasVsEta_ProfileS"; IasVsEta_ProfileS = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); + HistoName = saveName + "_IasVsEta_ProfileU"; IasVsEta_ProfileU = new TProfile(HistoName.c_str(), HistoName.c_str(), 100,-3, 3); } }; - +void Write_dEdxStudyObj (dEdxStudyObj* Obj){ + Obj->Charge_Vs_Path ->Write(); + Obj->HdedxMIP ->Write(); + Obj->HdedxVsPHSCP ->Write(); + Obj->HdedxVsP ->Write(); + Obj->HdedxVsPM ->Write(); + Obj->HdedxVsQP ->Write(); + Obj->HdedxVsPProfile ->Write(); + Obj->HdedxVsEtaProfile ->Write(); + Obj->HdedxVsEta ->Write(); + Obj->HNOSVsEtaProfile ->Write(); + Obj->HNOMVsEtaProfile ->Write(); + Obj->HNOMSVsEtaProfile ->Write(); + Obj->HMass ->Write(); + Obj->HP ->Write(); + Obj->HHit ->Write(); + Obj->IasVsEta_Split ->Write(); + Obj->IasVsEta_Unsplit ->Write(); + Obj->IasVsEta_ProfileS ->Write(); + Obj->IasVsEta_ProfileU ->Write(); +} @@ -153,6 +181,15 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT if(isData){ dEdxTemplates = loadDeDxTemplate(DIRNAME + "/../../../data/Data7TeV_Deco_SiStripDeDxMip_3D_Rcd.root"); }else{ dEdxTemplates = loadDeDxTemplate(DIRNAME + "/../../../data/MC7TeV_Deco_SiStripDeDxMip_3D_Rcd.root"); } + TH3F* dEdxNewTemplatesSplit = NULL; + TH3F* dEdxNewTemplatesUnsplit = NULL; + if(isData){ + dEdxNewTemplatesSplit = loadDeDxTemplate(DIRNAME + "/dEdxVsPath_Data.root", true); + dEdxNewTemplatesUnsplit = loadDeDxTemplate(DIRNAME + "/dEdxVsPath_Data.root", false); + }else{ + dEdxNewTemplatesSplit = loadDeDxTemplate(DIRNAME + "/dEdxVsPath_MC.root", true); + dEdxNewTemplatesUnsplit = loadDeDxTemplate(DIRNAME + "/dEdxVsPath_MC.root", false); + } string studies[] = {"harm2", "trunc40", "harm2_raw", "trunc40_raw", "Ias"}; @@ -239,6 +276,19 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT results[R]->HNOMSVsEtaProfile->Fill(track->eta(),dedxObj->numberOfMeasurements() - dedxObj->numberOfSaturatedMeasurements() ); } + if (track->p() > 5 && dEdxNewTemplatesSplit && dEdxNewTemplatesUnsplit){ + bool useraw = studies[R].find("raw") !=std::string::npos ? true : false, + truncate = studies[R].find("trunc")!=std::string::npos ? true : false; + + DeDxData* dedxNewObjS = computedEdx(dedxHits, dEdxSF, dEdxNewTemplatesSplit, false, useClusterCleaning, truncate, false, useraw ? &TrackerGains : NULL); + DeDxData* dedxNewObjU = computedEdx(dedxHits, dEdxSF, dEdxNewTemplatesUnsplit, false, useClusterCleaning, truncate, false, useraw ? &TrackerGains : NULL); + + results[R]->IasVsEta_Split ->Fill(track->eta(), dedxNewObjS->dEdx()); + results[R]->IasVsEta_ProfileS->Fill(track->eta(), dedxNewObjS->dEdx()); + results[R]->IasVsEta_Unsplit ->Fill(track->eta(), dedxNewObjU->dEdx()); + results[R]->IasVsEta_ProfileU->Fill(track->eta(), dedxNewObjU->dEdx()); + } + if(fabs(track->eta())>2.1)continue; if((int)dedxObj->numberOfMeasurements()<10)continue; if(track->p()>5 && track->p()<40){ @@ -258,6 +308,8 @@ void DeDxStudy(string DIRNAME="COMPILE", string INPUT="dEdx.root", string OUTPUT } } }printf("\n"); + for (int study_i = 0; study_i < Nstudies; study_i++) + Write_dEdxStudyObj (results[study_i]); OutputHisto->Write(); OutputHisto->Close(); } From a5503d6fb3ddfe3d884efa4c5a3d27dc423db44e Mon Sep 17 00:00:00 2001 From: Joze Zobec Date: Tue, 28 Jul 2015 23:58:14 +0200 Subject: [PATCH 5/5] MakePlot.C now plots the IasVsEta graphs and saves them with the rest --- .../test/UsefulScripts/DeDxStudy/MakePlot.C | 77 +++++++++++++++---- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/MakePlot.C b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/MakePlot.C index aaeb567e658a2..9cda12fc1eccf 100644 --- a/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/MakePlot.C +++ b/SUSYBSMAnalysis/HSCP/test/UsefulScripts/DeDxStudy/MakePlot.C @@ -135,27 +135,35 @@ void MakePlot() TritonLineLeft->SetLineColor(1); TritonLineLeft->SetLineWidth(2); - TFile* InputFile = new TFile("dEdxHistos_251252.root"); + TFile* InputFile = new TFile("dEdxHistosNew.root"); std::vector ObjName; - ObjName.push_back("harm2"); +// ObjName.push_back("harm2"); + ObjName.push_back("harm2_raw"); +// ObjName.push_back("trunc40"); +// ObjName.push_back("trunc40_raw"); +// ObjName.push_back("Ias"); for(unsigned int i=0;iSetTextFont(43); //give the font size in pixel (instead of fraction) - T->SetTextSize(21); //font size - T->SetBorderSize(0); - T->SetFillColor(0); - T->SetFillStyle(0); - T->SetTextAlign(22); - T->AddText("#bf{CMS} Preliminary - 2.74 pb^{-1} - #sqrt{s} = 13 TeV"); + TPaveText* T = new TPaveText(0.05, 0.995, 0.95, 0.945, "NDC"); + T->SetTextFont(43); //give the font size in pixel (instead of fraction) + T->SetTextSize(21); //font size + T->SetBorderSize(0); + T->SetFillColor(0); + T->SetFillStyle(0); + T->SetTextAlign(22); + T->AddText("#bf{CMS} Preliminary - 2.74 pb^{-1} - #sqrt{s} = 13 TeV"); std::cout << "TESTA\n"; TCanvas* c1 = new TCanvas("c1", "c1", 600,600); @@ -221,6 +229,45 @@ void MakePlot() SaveCanvas(c1, "pictures/", ObjName[i] + "_Profile"); delete c1; + c1 = new TCanvas("c1", "c1", 600,600); + c1->SetLogz(true); + IasVsEta_Split->SetStats(kFALSE); + IasVsEta_Split->GetXaxis()->SetTitle("Eta"); + IasVsEta_Split->GetYaxis()->SetTitle("I_{as}"); + IasVsEta_Split->SetAxisRange(-2.1,2.1,"X"); + IasVsEta_Split->Draw("COLZ"); + SaveCanvas(c1, "pictures/", ObjName[i] + "_IasVsEta_Split"); + delete c1; + + c1 = new TCanvas("c1", "c1", 600,600); + c1->SetLogz(true); + IasVsEta_Unsplit->SetStats(kFALSE); + IasVsEta_Unsplit->GetXaxis()->SetTitle("Eta"); + IasVsEta_Unsplit->GetYaxis()->SetTitle("I_{as}"); + IasVsEta_Unsplit->SetAxisRange(-2.1,2.1,"X"); + IasVsEta_Unsplit->Draw("COLZ"); + SaveCanvas(c1, "pictures/", ObjName[i] + "_IasVsEta_Unsplit"); + delete c1; + + c1 = new TCanvas("c1", "c1", 600,600); + TLegend* leg = new TLegend(0.50, 0.80, 0.80, 0.90); + leg->SetFillColor(0); + leg->SetFillStyle(0); + leg->SetBorderSize(0); + leg->AddEntry (IasVsEta_ProfileU, "Unsplit", "P"); + leg->AddEntry (IasVsEta_ProfileS, "Split per module", "P"); + IasVsEta_ProfileU->SetStats(kFALSE); + IasVsEta_ProfileS->SetMarkerStyle(23); + IasVsEta_ProfileS->SetMarkerColor(kBlue); + IasVsEta_ProfileU->GetXaxis()->SetTitle("pseudo-rapidity, #eta"); + IasVsEta_ProfileU->GetYaxis()->SetTitle("I_{as}"); + IasVsEta_ProfileU->Draw(""); + IasVsEta_ProfileS->Draw("same"); + leg->Draw(); + SaveCanvas(c1, "pictures/", ObjName[i] + "_IasVsEta_Profile"); + delete leg; + delete c1; + c1 = new TCanvas("c1", "c1", 600,600); c1->SetLogy(true); c1->SetGridx(true);