From 3e24a01783e17208e565479a4a0f898371d14909 Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Wed, 1 Nov 2017 17:03:03 +0100 Subject: [PATCH 1/8] Applied 'dos2unix Alignment/OfflineValidation/scripts/makeArrowPlots.C'. --- .../scripts/makeArrowPlots.C | 764 +++++++++--------- 1 file changed, 382 insertions(+), 382 deletions(-) diff --git a/Alignment/OfflineValidation/scripts/makeArrowPlots.C b/Alignment/OfflineValidation/scripts/makeArrowPlots.C index cf678daa5fdca..4658ee612dd4f 100644 --- a/Alignment/OfflineValidation/scripts/makeArrowPlots.C +++ b/Alignment/OfflineValidation/scripts/makeArrowPlots.C @@ -1,382 +1,382 @@ -//#include "compareGeometries.h" -#include -#include - -#include "TProfile.h" -#include "TList.h" -#include "TNtuple.h" -#include "TString.h" - -double arrowSize = 0.0095; -float y_,x_,z_,phi_,r_,dphi_,dr_,dx_,dz_,dy_; -int level_,sublevel_; -char outputDir_[192]; - -void Plot10Mu(const char* text,float X, float Y, float size) -{ - TPaveText* atext = new TPaveText(X,Y,X+size,Y+size); - atext->AddText(text); - atext->SetLineColor(0); - atext->SetFillColor(0); - atext->SetTextFont(42); - atext->SetTextSize(0.04); - atext->Draw(); -} - - -void normArrow(float x, float y, float norm) -{ - // draw 100 mu m arrow if norm = 1 - TArrow* normArrow = new TArrow(x,y,x+norm,y,arrowSize,">"); - // normArrow->SetLineWidth(2); - normArrow->Draw(); -} - -void DrawRPhiLegend(double xLim, double yLim, double barrelRPhiRescale) -{ - float xTest = 0.9*xLim; - float yTest = yLim/2; - float testBlockSize = 0.2*xLim; //5cm in axis unit - float disty = 0; - float dYTest =0.1*xLim; - float dZTest =2; - float xLegObj = 20; - float yLegObj = 18; - - Plot10Mu("#Delta r:",xTest,yTest,testBlockSize); - Plot10Mu("500 #mum",xTest,yTest-3*dYTest,testBlockSize); - normArrow(xTest+dYTest,yTest-4*dYTest-disty,500./10000*barrelRPhiRescale); -} - - -int makeRPhiArrowPlot( TTree* data, const char* name, double xLim, double yLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ - - - TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); - OBPCanvas->DrawFrame(-xLim, -yLim, 1.2*xLim, yLim, ";module position x [cm];module position y [cm]"); - OBPCanvas->SetFillColor(0); - OBPCanvas->SetFrameBorderMode(0); - - TFrame* aFrame = OBPCanvas->GetFrame(); - aFrame->SetFillColor(0); - - int passcut = 0; - for(int entry = 0;entryGetEntries(); entry++) - { - data->GetEntry(entry); - if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){ - if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ - TArrow* aArraw = new TArrow( x_, y_ , x_ + barrelRPhiRescale*dx_, y_+barrelRPhiRescale*dy_,0.0075,">"); - aArraw->Draw(); - passcut++; - } - } - } - DrawRPhiLegend( xLim, yLim, barrelRPhiRescale ); - - char sliceLeg[192]; - sprintf( sliceLeg, "%s: %f < z <= %f", name, zMin, zMax ); - //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); - TPaveText* atext = new TPaveText(0.2*xLim,0.85*yLim,0.66*xLim,0.99*yLim); - atext->AddText(sliceLeg); - atext->SetLineColor(0); - atext->SetFillColor(0); - atext->SetTextFont(42); - atext->SetTextSize(0.04); - atext->Draw(); - - - - char outfile[192]; - sprintf( outfile, "%s/%s.png", outputDir_, name ); - OBPCanvas->Print( outfile ); - - return passcut; -} - -int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ - - - TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); - OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]"); - OBPCanvas->SetFillColor(0); - OBPCanvas->SetFrameBorderMode(0); - - TFrame* aFrame = OBPCanvas->GetFrame(); - aFrame->SetFillColor(0); - - int passcut = 0; - for(int entry = 0;entryGetEntries(); entry++) - { - data->GetEntry(entry); - if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){ - if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ - TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">"); - aArraw->Draw(); - passcut++; - } - } - } - DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale ); - - char sliceLeg[192]; - sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax ); - //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); - TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim); - atext->AddText(sliceLeg); - atext->SetLineColor(0); - atext->SetFillColor(0); - atext->SetTextFont(42); - atext->SetTextSize(0.04); - atext->Draw(); - - - - char outfile[192]; - sprintf( outfile, "%s/%s.png", outputDir_, name ); - OBPCanvas->Print( outfile ); - - return passcut; -} - -/* -int makeRZArrowPlot( TTree* data, char* name, double zLim, double zLimMax, double rLim, double rLimMax, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ - - - TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); - OBPCanvas->DrawFrame(zLim, rLim, zLimMax, rLimMax, ";module position z [cm];module position r [cm]"); - OBPCanvas->SetFillColor(0); - OBPCanvas->SetFrameBorderMode(0); - - TFrame* aFrame = OBPCanvas->GetFrame(); - aFrame->SetFillColor(0); - - int passcut = 0; - for(int entry = 0;entryGetEntries(); entry++) - { - data->GetEntry(entry); - if ((level_ == level)&&(sublevel_ == sublevel)){ - if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ - TArrow* aArraw = new TArrow( z_, r_ , z_ + barrelRPhiRescale*dz_, r_+barrelRPhiRescale*dr_,0.0075,">"); - aArraw->Draw(); - passcut++; - } - } - } - // legend - double xpos = 0.8*(zLimMax-zLim) + zLim; - double ypos = 0.7*(rLimMax-rLim) + rLim; - double sizer = 0.05*(zLimMax-zLim); - Plot10Mu("#Delta r:",xpos,ypos,sizer); - Plot10Mu("500 #mum",xpos,ypos-1.5*sizer,sizer); - normArrow(xpos,ypos-2*sizer,500./10000*barrelRPhiRescale); - - - char sliceLeg[192]; - sprintf( sliceLeg, "%s: %d < z <= %d", name, zMin, zMax ); - //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); - TPaveText* atext = new TPaveText(0.4*(zLimMax-zLim) + zLim,0.85*(rLimMax-rLim)+rLim,0.86*(zLimMax-zLim) + zLim,0.99*(rLimMax-rLim)+rLim); - atext->AddText(sliceLeg); - atext->SetLineColor(0); - atext->SetFillColor(0); - atext->SetTextFont(42); - atext->SetTextSize(0.04); - atext->Draw(); - - - - char outfile[192]; - sprintf( outfile, "%s/%s.png", outputDir_, name ); - OBPCanvas->Print( outfile ); - - return passcut; -} -*/ - -void makeArrowPlots(const char* filename, const char* outputDir) -{ - - fin = new TFile(filename); - fin->cd(); - - bool plotPXB = true; - bool plotTIB = true; - bool plotTOB = true; - bool plotPXF = true; - bool plotTID = true; - bool plotTEC = true; - - TString outputfile("OUTPUT_"); - outputfile.Append(filename); - TFile* output = new TFile(outputfile,"recreate"); - - sprintf( outputDir_, "%s", outputDir ); - - TTree* data = (TTree*)fin->Get("alignTree"); - data->SetBranchAddress("sublevel",&sublevel_); - data->SetBranchAddress("level",&level_); - data->SetBranchAddress("x",&x_); - data->SetBranchAddress("y",&y_); - data->SetBranchAddress("z",&z_); - data->SetBranchAddress("dx",&dx_); - data->SetBranchAddress("dy",&dy_); - data->SetBranchAddress("dz",&dz_); - data->SetBranchAddress("dphi",&dphi_); - data->SetBranchAddress("dr",&dr_); - data->SetBranchAddress("phi",&phi_); - data->SetBranchAddress("r",&r_); - - // args are: tree, title, xLim, yLim - // cuts are: level, sublevel, zMin, zMax, rMin, rMax, scaleFactor - // PXB slices - int totalPXB_modules = 0; - int totalPXB_modules_zphi = 0; - int dummy = 0; - if (plotPXB){ - double pxbScale = 30.0; - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-4", 20, 20, 1, 1, -26, -20, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-3", 20, 20, 1, 1, -19, -14, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-2", 20, 20, 1, 1, -14, -6.5, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-1", 20, 20, 1, 1, -6.5, 0, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+1", 20, 20, 1, 1, 0, 6.5, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+2", 20, 20, 1, 1, 6.5, 14, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+3", 20, 20, 1, 1, 14, 19, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+4", 20, 20, 1, 1, 19, 26, 0, 15, pxbScale); - double pxbScale_zphi = 40.0; - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_1", 35, 20, 1, 1, -300, 300, 0, 5, pxbScale_zphi); - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_2", 35, 30, 1, 1, -300, 300, 5, 8, pxbScale_zphi); - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_3", 35, 40, 1, 1, -300, 300, 8, 14, pxbScale_zphi); - } - - // TIB slices - int totalTIB_modules = 0; - int totalTIB_modules_zphi = 0; - if (plotTIB){ - double tibScale = 30.0; - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-6", 80, 80, 1, 3, -70, -56, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-5", 80, 80, 1, 3, -56, -42, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-4", 80, 80, 1, 3, -42, -32, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-3", 80, 80, 1, 3, -32, -20, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-2", 80, 80, 1, 3, -20, -10, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-1", 80, 80, 1, 3, -10, 0, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+1", 80, 80, 1, 3, 0, 10, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+2", 80, 80, 1, 3, 10, 20, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+3", 80, 80, 1, 3, 20, 32, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+4", 80, 80, 1, 3, 32, 42, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+5", 80, 80, 1, 3, 42, 56, 0, 120, tibScale); - totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+6", 80, 80, 1, 3, 56, 70, 0, 120, tibScale); - double tibScale_zphi = 40.0; - totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_1", 80, 120, 1, 3, -300, 300, 20.0, 29.0, tibScale_zphi); - totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_2", 80, 140, 1, 3, -300, 300, 29.0, 37.5, tibScale_zphi); - totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_3", 80, 170, 1, 3, -300, 300, 37.5, 47.5, tibScale_zphi); - totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_4", 80, 200, 1, 3, -300, 300, 47.5, 60.0, tibScale_zphi); - - } - - // TOB slices - int totalTOB_modules = 0; - int totalTOB_modules_zphi = 0; - if (plotTOB){ - double tobScale = 100.0; - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-6", 150, 150, 1, 5, -108, -90, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-5", 150, 150, 1, 5, -90, -72, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-4", 150, 150, 1, 5, -72, -54, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-3", 150, 150, 1, 5, -54, -36, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-2", 150, 150, 1, 5, -36, -18, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-1", 150, 150, 1, 5, -18, 0, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+1", 150, 150, 1, 5, 0, 18, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+2", 150, 150, 1, 5, 18, 36, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+3", 150, 150, 1, 5, 36, 54, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+4", 150, 150, 1, 5, 54, 72, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+5", 150, 150, 1, 5, 72, 90, 0, 120, tobScale); - totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+6", 150, 150, 1, 5, 90, 108, 0, 120, tobScale); - double tobScale_zphi = 40.0; - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_1", 130, 250, 1, 5, -300, 300, 55.0, 65.0, tobScale_zphi); - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_2", 130, 280, 1, 5, -300, 300, 65.0, 75.0, tobScale_zphi); - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_3", 130, 320, 1, 5, -300, 300, 75.0, 85.0, tobScale_zphi); - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_4", 130, 350, 1, 5, -300, 300, 85.0, 93.0, tobScale_zphi); - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_5", 130, 380, 1, 5, -300, 300, 93.0, 101.0, tobScale_zphi); - totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_6", 130, 410, 1, 5, -300, 300, 101.0, 110.0, tobScale_zphi); - } - - // PXF slices - int totalPXF_modules = 0; - int totalPXF_modules_rz = 0; - if (plotPXF){ - double pxfScale = 30.0; - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+1", 20, 20, 1, 2, 25, 40, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+2", 20, 20, 1, 2, 40, 55, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-1", 20, 20, 1, 2, -40, -25, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-2", 20, 20, 1, 2, -55, -40, 0, 120, pxfScale); - /* - double pxfScale_zphi = 10.0; - totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ-1", -38, -30, 5, 17, 1, 2, -40, -25, 0, 120.0, pxfScale_zphi); - totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ-2", -52, -44, 5, 17, 1, 2, -55, -40, 0, 120.0, pxfScale_zphi); - totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ+1", 32, 40, 5, 17, 1, 2, 25, 40, 0, 120.0, pxfScale_zphi); - totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ+2", 46, 54, 5, 17, 1, 2, 40, 55, 0, 120.0, pxfScale_zphi); - */ - } - - // TID slices - int totalTID_modules = 0; - int totalTID_modules_rz = 0; - if (plotTID){ - double tidScale = 50.0; - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+1", 70, 70, 1, 4, 70, 80, 0, 120, tidScale); - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+2", 70, 70, 1, 4, 80, 95, 0, 120, tidScale); - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+3", 70, 70, 1, 4, 95, 110, 0, 120, tidScale); - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-1", 70, 70, 1, 4, -80, -70, 0, 120, tidScale); - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-2", 70, 70, 1, 4, -95, -80, 0, 120, tidScale); - totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-3", 70, 70, 1, 4, -110, -95, 0, 120, tidScale); - /* - double tidScale_zphi = 10.0; - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-1", -80, -70, -3, 55, 1, 4, -80, -70, 0, 120.0, tidScale_zphi); - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-2", -95, -80, 20, 55, 1, 4, -95, -80, 0, 120.0, tidScale_zphi); - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-3", -110, -95, 20, 55, 1, 4, -110, -95, 0, 120.0, tidScale_zphi); - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+1", 70, 80, 20, 55, 1, 4, 70, 80, 0, 120.0, tidScale_zphi); - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+2", 80, 95, 20, 55, 1, 4, 80, 95, 0, 120.0, tidScale_zphi); - totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+3", 95, 110, 20, 55, 1, 4, 95, 110, 0, 120.0, tidScale_zphi); - */ - } - - - // TEC slices - int totalTEC_modules = 0; - if (plotTEC){ - double tecScale = 100.0; - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+1", 150, 150, 1, 6, 120, 130, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+2", 150, 150, 1, 6, 130, 145, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+3", 150, 150, 1, 6, 145, 160, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+4", 150, 150, 1, 6, 160, 175, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+5", 150, 150, 1, 6, 175, 190, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+6", 150, 150, 1, 6, 190, 215, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+7", 150, 150, 1, 6, 215, 235, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+8", 150, 150, 1, 6, 235, 260, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+9", 150, 150, 1, 6, 260, 280, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-1", 150, 150, 1, 6, -130, -120, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-2", 150, 150, 1, 6, -145, -130, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-3", 150, 150, 1, 6, -160, -145, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-4", 150, 150, 1, 6, -175, -160, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-5", 150, 150, 1, 6, -190, -175, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-6", 150, 150, 1, 6, -215, -190, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-7", 150, 150, 1, 6, -235, -215, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-8", 150, 150, 1, 6, -260, -235, 0, 120, tecScale); - totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-9", 150, 150, 1, 6, -280, -260, 0, 120, tecScale); - } - - std::cout << "Plotted PXB modules: " << totalPXB_modules << std::endl; - std::cout << "Plotted PXB modules (zphi): " << totalPXB_modules_zphi << std::endl; - std::cout << "Plotted TIB modules: " << totalTIB_modules << std::endl; - std::cout << "Plotted TIB modules (zphi): " << totalTIB_modules_zphi << std::endl; - std::cout << "Plotted TOB modules: " << totalTOB_modules << std::endl; - std::cout << "Plotted TOB modules (zphi): " << totalTOB_modules_zphi << std::endl; - std::cout << "Plotted PXF modules: " << totalPXF_modules << std::endl; - //std::cout << "Plotted PXF modules (rz): " << totalPXF_modules_rz << std::endl; - std::cout << "Plotted TID modules: " << totalTID_modules << std::endl; - //std::cout << "Plotted TID modules (rz): " << totalTID_modules_rz << std::endl; - std::cout << "Plotted TEC modules: " << totalTEC_modules << std::endl; - - - - -} +//#include "compareGeometries.h" +#include +#include + +#include "TProfile.h" +#include "TList.h" +#include "TNtuple.h" +#include "TString.h" + +double arrowSize = 0.0095; +float y_,x_,z_,phi_,r_,dphi_,dr_,dx_,dz_,dy_; +int level_,sublevel_; +char outputDir_[192]; + +void Plot10Mu(const char* text,float X, float Y, float size) +{ + TPaveText* atext = new TPaveText(X,Y,X+size,Y+size); + atext->AddText(text); + atext->SetLineColor(0); + atext->SetFillColor(0); + atext->SetTextFont(42); + atext->SetTextSize(0.04); + atext->Draw(); +} + + +void normArrow(float x, float y, float norm) +{ + // draw 100 mu m arrow if norm = 1 + TArrow* normArrow = new TArrow(x,y,x+norm,y,arrowSize,">"); + // normArrow->SetLineWidth(2); + normArrow->Draw(); +} + +void DrawRPhiLegend(double xLim, double yLim, double barrelRPhiRescale) +{ + float xTest = 0.9*xLim; + float yTest = yLim/2; + float testBlockSize = 0.2*xLim; //5cm in axis unit + float disty = 0; + float dYTest =0.1*xLim; + float dZTest =2; + float xLegObj = 20; + float yLegObj = 18; + + Plot10Mu("#Delta r:",xTest,yTest,testBlockSize); + Plot10Mu("500 #mum",xTest,yTest-3*dYTest,testBlockSize); + normArrow(xTest+dYTest,yTest-4*dYTest-disty,500./10000*barrelRPhiRescale); +} + + +int makeRPhiArrowPlot( TTree* data, const char* name, double xLim, double yLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ + + + TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); + OBPCanvas->DrawFrame(-xLim, -yLim, 1.2*xLim, yLim, ";module position x [cm];module position y [cm]"); + OBPCanvas->SetFillColor(0); + OBPCanvas->SetFrameBorderMode(0); + + TFrame* aFrame = OBPCanvas->GetFrame(); + aFrame->SetFillColor(0); + + int passcut = 0; + for(int entry = 0;entryGetEntries(); entry++) + { + data->GetEntry(entry); + if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){ + if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ + TArrow* aArraw = new TArrow( x_, y_ , x_ + barrelRPhiRescale*dx_, y_+barrelRPhiRescale*dy_,0.0075,">"); + aArraw->Draw(); + passcut++; + } + } + } + DrawRPhiLegend( xLim, yLim, barrelRPhiRescale ); + + char sliceLeg[192]; + sprintf( sliceLeg, "%s: %f < z <= %f", name, zMin, zMax ); + //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); + TPaveText* atext = new TPaveText(0.2*xLim,0.85*yLim,0.66*xLim,0.99*yLim); + atext->AddText(sliceLeg); + atext->SetLineColor(0); + atext->SetFillColor(0); + atext->SetTextFont(42); + atext->SetTextSize(0.04); + atext->Draw(); + + + + char outfile[192]; + sprintf( outfile, "%s/%s.png", outputDir_, name ); + OBPCanvas->Print( outfile ); + + return passcut; +} + +int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ + + + TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); + OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]"); + OBPCanvas->SetFillColor(0); + OBPCanvas->SetFrameBorderMode(0); + + TFrame* aFrame = OBPCanvas->GetFrame(); + aFrame->SetFillColor(0); + + int passcut = 0; + for(int entry = 0;entryGetEntries(); entry++) + { + data->GetEntry(entry); + if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){ + if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ + TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">"); + aArraw->Draw(); + passcut++; + } + } + } + DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale ); + + char sliceLeg[192]; + sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax ); + //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); + TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim); + atext->AddText(sliceLeg); + atext->SetLineColor(0); + atext->SetFillColor(0); + atext->SetTextFont(42); + atext->SetTextSize(0.04); + atext->Draw(); + + + + char outfile[192]; + sprintf( outfile, "%s/%s.png", outputDir_, name ); + OBPCanvas->Print( outfile ); + + return passcut; +} + +/* + int makeRZArrowPlot( TTree* data, char* name, double zLim, double zLimMax, double rLim, double rLimMax, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ + + + TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); + OBPCanvas->DrawFrame(zLim, rLim, zLimMax, rLimMax, ";module position z [cm];module position r [cm]"); + OBPCanvas->SetFillColor(0); + OBPCanvas->SetFrameBorderMode(0); + + TFrame* aFrame = OBPCanvas->GetFrame(); + aFrame->SetFillColor(0); + + int passcut = 0; + for(int entry = 0;entryGetEntries(); entry++) + { + data->GetEntry(entry); + if ((level_ == level)&&(sublevel_ == sublevel)){ + if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ + TArrow* aArraw = new TArrow( z_, r_ , z_ + barrelRPhiRescale*dz_, r_+barrelRPhiRescale*dr_,0.0075,">"); + aArraw->Draw(); + passcut++; + } + } + } + // legend + double xpos = 0.8*(zLimMax-zLim) + zLim; + double ypos = 0.7*(rLimMax-rLim) + rLim; + double sizer = 0.05*(zLimMax-zLim); + Plot10Mu("#Delta r:",xpos,ypos,sizer); + Plot10Mu("500 #mum",xpos,ypos-1.5*sizer,sizer); + normArrow(xpos,ypos-2*sizer,500./10000*barrelRPhiRescale); + + + char sliceLeg[192]; + sprintf( sliceLeg, "%s: %d < z <= %d", name, zMin, zMax ); + //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); + TPaveText* atext = new TPaveText(0.4*(zLimMax-zLim) + zLim,0.85*(rLimMax-rLim)+rLim,0.86*(zLimMax-zLim) + zLim,0.99*(rLimMax-rLim)+rLim); + atext->AddText(sliceLeg); + atext->SetLineColor(0); + atext->SetFillColor(0); + atext->SetTextFont(42); + atext->SetTextSize(0.04); + atext->Draw(); + + + + char outfile[192]; + sprintf( outfile, "%s/%s.png", outputDir_, name ); + OBPCanvas->Print( outfile ); + + return passcut; + } +*/ + +void makeArrowPlots(const char* filename, const char* outputDir) +{ + + fin = new TFile(filename); + fin->cd(); + + bool plotPXB = true; + bool plotTIB = true; + bool plotTOB = true; + bool plotPXF = true; + bool plotTID = true; + bool plotTEC = true; + + TString outputfile("OUTPUT_"); + outputfile.Append(filename); + TFile* output = new TFile(outputfile,"recreate"); + + sprintf( outputDir_, "%s", outputDir ); + + TTree* data = (TTree*)fin->Get("alignTree"); + data->SetBranchAddress("sublevel",&sublevel_); + data->SetBranchAddress("level",&level_); + data->SetBranchAddress("x",&x_); + data->SetBranchAddress("y",&y_); + data->SetBranchAddress("z",&z_); + data->SetBranchAddress("dx",&dx_); + data->SetBranchAddress("dy",&dy_); + data->SetBranchAddress("dz",&dz_); + data->SetBranchAddress("dphi",&dphi_); + data->SetBranchAddress("dr",&dr_); + data->SetBranchAddress("phi",&phi_); + data->SetBranchAddress("r",&r_); + + // args are: tree, title, xLim, yLim + // cuts are: level, sublevel, zMin, zMax, rMin, rMax, scaleFactor + // PXB slices + int totalPXB_modules = 0; + int totalPXB_modules_zphi = 0; + int dummy = 0; + if (plotPXB){ + double pxbScale = 30.0; + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-4", 20, 20, 1, 1, -26, -20, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-3", 20, 20, 1, 1, -19, -14, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-2", 20, 20, 1, 1, -14, -6.5, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-1", 20, 20, 1, 1, -6.5, 0, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+1", 20, 20, 1, 1, 0, 6.5, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+2", 20, 20, 1, 1, 6.5, 14, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+3", 20, 20, 1, 1, 14, 19, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+4", 20, 20, 1, 1, 19, 26, 0, 15, pxbScale); + double pxbScale_zphi = 40.0; + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_1", 35, 20, 1, 1, -300, 300, 0, 5, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_2", 35, 30, 1, 1, -300, 300, 5, 8, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_3", 35, 40, 1, 1, -300, 300, 8, 14, pxbScale_zphi); + } + + // TIB slices + int totalTIB_modules = 0; + int totalTIB_modules_zphi = 0; + if (plotTIB){ + double tibScale = 30.0; + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-6", 80, 80, 1, 3, -70, -56, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-5", 80, 80, 1, 3, -56, -42, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-4", 80, 80, 1, 3, -42, -32, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-3", 80, 80, 1, 3, -32, -20, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-2", 80, 80, 1, 3, -20, -10, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY-1", 80, 80, 1, 3, -10, 0, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+1", 80, 80, 1, 3, 0, 10, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+2", 80, 80, 1, 3, 10, 20, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+3", 80, 80, 1, 3, 20, 32, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+4", 80, 80, 1, 3, 32, 42, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+5", 80, 80, 1, 3, 42, 56, 0, 120, tibScale); + totalTIB_modules += makeRPhiArrowPlot( data, "TIB_BarrelXY+6", 80, 80, 1, 3, 56, 70, 0, 120, tibScale); + double tibScale_zphi = 40.0; + totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_1", 80, 120, 1, 3, -300, 300, 20.0, 29.0, tibScale_zphi); + totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_2", 80, 140, 1, 3, -300, 300, 29.0, 37.5, tibScale_zphi); + totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_3", 80, 170, 1, 3, -300, 300, 37.5, 47.5, tibScale_zphi); + totalTIB_modules_zphi += makeZPhiArrowPlot( data, "TIB_BarrelZPhi_4", 80, 200, 1, 3, -300, 300, 47.5, 60.0, tibScale_zphi); + + } + + // TOB slices + int totalTOB_modules = 0; + int totalTOB_modules_zphi = 0; + if (plotTOB){ + double tobScale = 100.0; + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-6", 150, 150, 1, 5, -108, -90, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-5", 150, 150, 1, 5, -90, -72, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-4", 150, 150, 1, 5, -72, -54, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-3", 150, 150, 1, 5, -54, -36, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-2", 150, 150, 1, 5, -36, -18, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY-1", 150, 150, 1, 5, -18, 0, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+1", 150, 150, 1, 5, 0, 18, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+2", 150, 150, 1, 5, 18, 36, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+3", 150, 150, 1, 5, 36, 54, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+4", 150, 150, 1, 5, 54, 72, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+5", 150, 150, 1, 5, 72, 90, 0, 120, tobScale); + totalTOB_modules += makeRPhiArrowPlot( data, "TOB_BarrelXY+6", 150, 150, 1, 5, 90, 108, 0, 120, tobScale); + double tobScale_zphi = 40.0; + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_1", 130, 250, 1, 5, -300, 300, 55.0, 65.0, tobScale_zphi); + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_2", 130, 280, 1, 5, -300, 300, 65.0, 75.0, tobScale_zphi); + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_3", 130, 320, 1, 5, -300, 300, 75.0, 85.0, tobScale_zphi); + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_4", 130, 350, 1, 5, -300, 300, 85.0, 93.0, tobScale_zphi); + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_5", 130, 380, 1, 5, -300, 300, 93.0, 101.0, tobScale_zphi); + totalTOB_modules_zphi += makeZPhiArrowPlot( data, "TOB_BarrelZPhi_6", 130, 410, 1, 5, -300, 300, 101.0, 110.0, tobScale_zphi); + } + + // PXF slices + int totalPXF_modules = 0; + int totalPXF_modules_rz = 0; + if (plotPXF){ + double pxfScale = 30.0; + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+1", 20, 20, 1, 2, 25, 40, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+2", 20, 20, 1, 2, 40, 55, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-1", 20, 20, 1, 2, -40, -25, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-2", 20, 20, 1, 2, -55, -40, 0, 120, pxfScale); + /* + double pxfScale_zphi = 10.0; + totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ-1", -38, -30, 5, 17, 1, 2, -40, -25, 0, 120.0, pxfScale_zphi); + totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ-2", -52, -44, 5, 17, 1, 2, -55, -40, 0, 120.0, pxfScale_zphi); + totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ+1", 32, 40, 5, 17, 1, 2, 25, 40, 0, 120.0, pxfScale_zphi); + totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ+2", 46, 54, 5, 17, 1, 2, 40, 55, 0, 120.0, pxfScale_zphi); + */ + } + + // TID slices + int totalTID_modules = 0; + int totalTID_modules_rz = 0; + if (plotTID){ + double tidScale = 50.0; + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+1", 70, 70, 1, 4, 70, 80, 0, 120, tidScale); + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+2", 70, 70, 1, 4, 80, 95, 0, 120, tidScale); + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY+3", 70, 70, 1, 4, 95, 110, 0, 120, tidScale); + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-1", 70, 70, 1, 4, -80, -70, 0, 120, tidScale); + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-2", 70, 70, 1, 4, -95, -80, 0, 120, tidScale); + totalTID_modules += makeRPhiArrowPlot( data, "TID_DiskXY-3", 70, 70, 1, 4, -110, -95, 0, 120, tidScale); + /* + double tidScale_zphi = 10.0; + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-1", -80, -70, -3, 55, 1, 4, -80, -70, 0, 120.0, tidScale_zphi); + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-2", -95, -80, 20, 55, 1, 4, -95, -80, 0, 120.0, tidScale_zphi); + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ-3", -110, -95, 20, 55, 1, 4, -110, -95, 0, 120.0, tidScale_zphi); + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+1", 70, 80, 20, 55, 1, 4, 70, 80, 0, 120.0, tidScale_zphi); + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+2", 80, 95, 20, 55, 1, 4, 80, 95, 0, 120.0, tidScale_zphi); + totalTID_modules_rz += makeRZArrowPlot( data, "TID_DiskRZ+3", 95, 110, 20, 55, 1, 4, 95, 110, 0, 120.0, tidScale_zphi); + */ + } + + + // TEC slices + int totalTEC_modules = 0; + if (plotTEC){ + double tecScale = 100.0; + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+1", 150, 150, 1, 6, 120, 130, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+2", 150, 150, 1, 6, 130, 145, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+3", 150, 150, 1, 6, 145, 160, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+4", 150, 150, 1, 6, 160, 175, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+5", 150, 150, 1, 6, 175, 190, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+6", 150, 150, 1, 6, 190, 215, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+7", 150, 150, 1, 6, 215, 235, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+8", 150, 150, 1, 6, 235, 260, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY+9", 150, 150, 1, 6, 260, 280, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-1", 150, 150, 1, 6, -130, -120, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-2", 150, 150, 1, 6, -145, -130, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-3", 150, 150, 1, 6, -160, -145, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-4", 150, 150, 1, 6, -175, -160, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-5", 150, 150, 1, 6, -190, -175, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-6", 150, 150, 1, 6, -215, -190, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-7", 150, 150, 1, 6, -235, -215, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-8", 150, 150, 1, 6, -260, -235, 0, 120, tecScale); + totalTEC_modules += makeRPhiArrowPlot( data, "TEC_DiskXY-9", 150, 150, 1, 6, -280, -260, 0, 120, tecScale); + } + + std::cout << "Plotted PXB modules: " << totalPXB_modules << std::endl; + std::cout << "Plotted PXB modules (zphi): " << totalPXB_modules_zphi << std::endl; + std::cout << "Plotted TIB modules: " << totalTIB_modules << std::endl; + std::cout << "Plotted TIB modules (zphi): " << totalTIB_modules_zphi << std::endl; + std::cout << "Plotted TOB modules: " << totalTOB_modules << std::endl; + std::cout << "Plotted TOB modules (zphi): " << totalTOB_modules_zphi << std::endl; + std::cout << "Plotted PXF modules: " << totalPXF_modules << std::endl; + //std::cout << "Plotted PXF modules (rz): " << totalPXF_modules_rz << std::endl; + std::cout << "Plotted TID modules: " << totalTID_modules << std::endl; + //std::cout << "Plotted TID modules (rz): " << totalTID_modules_rz << std::endl; + std::cout << "Plotted TEC modules: " << totalTEC_modules << std::endl; + + + + +} From 380ef24ab163d1478cc42ef7035d7a89dcab0cee Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Wed, 1 Nov 2017 17:08:19 +0100 Subject: [PATCH 2/8] Fix arrow plots in geometry comparison tool. --- .../python/TkAlAllInOneTool/geometryComparison.py | 9 --------- Alignment/OfflineValidation/scripts/makeArrowPlots.C | 9 +++++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index 4dd425606d150..f3afc43273edc 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -230,15 +230,6 @@ def createScript(self, path): "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c" " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." ".Comparison_common"+name+"_Images/\" \n") - repMap["runComparisonScripts"] += \ - ("if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]]\n" - "then\n" - " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name - +"_ArrowPlots\n" - "else\n" - " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name - +"_ArrowPlots\n" - "fi\n") repMap["runComparisonScripts"] += \ ("rfcp .oO[Alignment/OfflineValidation]Oo." "/scripts/makeArrowPlots.C " diff --git a/Alignment/OfflineValidation/scripts/makeArrowPlots.C b/Alignment/OfflineValidation/scripts/makeArrowPlots.C index 4658ee612dd4f..58bda4b04056c 100644 --- a/Alignment/OfflineValidation/scripts/makeArrowPlots.C +++ b/Alignment/OfflineValidation/scripts/makeArrowPlots.C @@ -196,8 +196,8 @@ int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim void makeArrowPlots(const char* filename, const char* outputDir) { - fin = new TFile(filename); - fin->cd(); + TFile fin(filename); + fin.cd(); bool plotPXB = true; bool plotTIB = true; @@ -208,11 +208,12 @@ void makeArrowPlots(const char* filename, const char* outputDir) TString outputfile("OUTPUT_"); outputfile.Append(filename); - TFile* output = new TFile(outputfile,"recreate"); + TFile output(outputfile, "recreate"); sprintf( outputDir_, "%s", outputDir ); + gSystem->mkdir(outputDir_, true); - TTree* data = (TTree*)fin->Get("alignTree"); + TTree* data = static_cast(fin.Get("alignTree")); data->SetBranchAddress("sublevel",&sublevel_); data->SetBranchAddress("level",&level_); data->SetBranchAddress("x",&x_); From 85001f3d5aea1a306ed3a1279cb330cf7a2a2e1e Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Wed, 1 Nov 2017 17:54:26 +0100 Subject: [PATCH 3/8] Get rid of remaining usage of 'eos' command. --- .../python/TkAlAllInOneTool/configTemplates.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/configTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/configTemplates.py index b7056c190b9d2..3ea8d8a76424d 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/configTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/configTemplates.py @@ -59,10 +59,10 @@ #rfmkdir -p .oO[datadir]Oo. &>! /dev/null #remove possible result file from previous runs -previous_results=$(eos ls /store/caf/user/$USER/.oO[eosdir]Oo.) +previous_results=$(ls /eos/cms/store/caf/user/$USER/.oO[eosdir]Oo.) for file in ${previous_results} do - if [ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ] + if [ ${file} = /eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ] then xrdcp -f root://eoscms//eos/cms${file} root://eoscms//eos/cms${file}.bak fi @@ -98,7 +98,7 @@ find . -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo." #copy root files to eos -eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo. +mkdir -p /eos/cms/store/caf/user/$USER/.oO[eosdir]Oo. if [ .oO[parallelJobs]Oo. -eq 1 ] then root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root) @@ -236,7 +236,7 @@ ############################################################################### # download root files from eos -root_files=$(eos ls /store/caf/user/$USER/.oO[eosdir]Oo. \ +root_files=$(ls /eos/cms/store/caf/user/$USER/.oO[eosdir]Oo. \ | grep ".root$" | grep -v "result.root$") #for file in ${root_files} #do @@ -267,7 +267,6 @@ ###################################################################### mergeParallelOfflineTemplate=""" #!/bin/bash -eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select' CWD=`pwd -P` cd .oO[CMSSW_BASE]Oo./src export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo. @@ -326,7 +325,7 @@ compareAlignmentsExecution=""" #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date echo -e "\n\nComparing validations" -eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo./ +mkdir -p /eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./ cp .oO[Alignment/OfflineValidation]Oo./scripts/compareFileAges.C . root -x -q -b -l "compareFileAges.C(\\\"root://eoscms.cern.ch//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root\\\", \\\".oO[compareStringsPlain]Oo.\\\")" comparisonNeeded=${?} From 34f61bcdfe0fce58744232870f8f937131b0a17c Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Thu, 2 Nov 2017 10:30:54 +0100 Subject: [PATCH 4/8] Migrate arrow-plots macro to phase-1 geometry. --- .../scripts/makeArrowPlots.C | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Alignment/OfflineValidation/scripts/makeArrowPlots.C b/Alignment/OfflineValidation/scripts/makeArrowPlots.C index 58bda4b04056c..032865d46e83e 100644 --- a/Alignment/OfflineValidation/scripts/makeArrowPlots.C +++ b/Alignment/OfflineValidation/scripts/makeArrowPlots.C @@ -235,18 +235,19 @@ void makeArrowPlots(const char* filename, const char* outputDir) int dummy = 0; if (plotPXB){ double pxbScale = 30.0; - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-4", 20, 20, 1, 1, -26, -20, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-3", 20, 20, 1, 1, -19, -14, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-2", 20, 20, 1, 1, -14, -6.5, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-1", 20, 20, 1, 1, -6.5, 0, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+1", 20, 20, 1, 1, 0, 6.5, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+2", 20, 20, 1, 1, 6.5, 14, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+3", 20, 20, 1, 1, 14, 19, 0, 15, pxbScale); - totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+4", 20, 20, 1, 1, 19, 26, 0, 15, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-4", 20, 20, 1, 1, -26, -20, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-3", 20, 20, 1, 1, -19, -14, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-2", 20, 20, 1, 1, -14, -6.5, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY-1", 20, 20, 1, 1, -6.5, 0, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+1", 20, 20, 1, 1, 0, 6.5, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+2", 20, 20, 1, 1, 6.5, 14, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+3", 20, 20, 1, 1, 14, 19, 0, 19, pxbScale); + totalPXB_modules += makeRPhiArrowPlot( data, "PXB_BarrelXY+4", 20, 20, 1, 1, 19, 26, 0, 19, pxbScale); double pxbScale_zphi = 40.0; - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_1", 35, 20, 1, 1, -300, 300, 0, 5, pxbScale_zphi); - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_2", 35, 30, 1, 1, -300, 300, 5, 8, pxbScale_zphi); - totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_3", 35, 40, 1, 1, -300, 300, 8, 14, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_1", 35, 15, 1, 1, -300, 300, 0, 5, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_2", 35, 30, 1, 1, -300, 300, 5, 9, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_3", 35, 45, 1, 1, -300, 300, 9, 14, pxbScale_zphi); + totalPXB_modules_zphi += makeZPhiArrowPlot( data, "PXB_BarrelZPhi_4", 35, 65, 1, 1, -300, 300, 14, 19, pxbScale_zphi); } // TIB slices @@ -305,10 +306,12 @@ void makeArrowPlots(const char* filename, const char* outputDir) int totalPXF_modules_rz = 0; if (plotPXF){ double pxfScale = 30.0; - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+1", 20, 20, 1, 2, 25, 40, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+2", 20, 20, 1, 2, 40, 55, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-1", 20, 20, 1, 2, -40, -25, 0, 120, pxfScale); - totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-2", 20, 20, 1, 2, -55, -40, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+1", 20, 20, 1, 2, 25, 36, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+2", 20, 20, 1, 2, 36, 44, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY+3", 20, 20, 1, 2, 44, 55, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-1", 20, 20, 1, 2, -36, -25, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-2", 20, 20, 1, 2, -44, -36, 0, 120, pxfScale); + totalPXF_modules += makeRPhiArrowPlot( data, "PXF_DiskXY-3", 20, 20, 1, 2, -55, -44, 0, 120, pxfScale); /* double pxfScale_zphi = 10.0; totalPXF_modules_rz += makeRZArrowPlot( data, "PXF_DiskRZ-1", -38, -30, 5, 17, 1, 2, -40, -25, 0, 120.0, pxfScale_zphi); From c5431219e7f687202aedab8bbb45743c45316257 Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Thu, 2 Nov 2017 11:51:59 +0100 Subject: [PATCH 5/8] Move 'makeArrowPlots.C' to macros directory, as it is not a script. --- .../OfflineValidation/{scripts => macros}/makeArrowPlots.C | 0 .../python/TkAlAllInOneTool/geometryComparison.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Alignment/OfflineValidation/{scripts => macros}/makeArrowPlots.C (100%) diff --git a/Alignment/OfflineValidation/scripts/makeArrowPlots.C b/Alignment/OfflineValidation/macros/makeArrowPlots.C similarity index 100% rename from Alignment/OfflineValidation/scripts/makeArrowPlots.C rename to Alignment/OfflineValidation/macros/makeArrowPlots.C diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index f3afc43273edc..d7fbc3861ae41 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -232,7 +232,7 @@ def createScript(self, path): ".Comparison_common"+name+"_Images/\" \n") repMap["runComparisonScripts"] += \ ("rfcp .oO[Alignment/OfflineValidation]Oo." - "/scripts/makeArrowPlots.C " + "/macros/makeArrowPlots.C " ".\n" "root -b -q 'makeArrowPlots.C(\"" ".oO[name]Oo..Comparison_common"+name From 8c37a97b66d28c18008ae20186cdc3b1ae084ab3 Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Fri, 3 Nov 2017 09:53:53 +0100 Subject: [PATCH 6/8] Create also pdf version of arrow plots. --- Alignment/OfflineValidation/macros/makeArrowPlots.C | 4 ++++ .../python/TkAlAllInOneTool/geometryComparison.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Alignment/OfflineValidation/macros/makeArrowPlots.C b/Alignment/OfflineValidation/macros/makeArrowPlots.C index 032865d46e83e..468babeb2002b 100644 --- a/Alignment/OfflineValidation/macros/makeArrowPlots.C +++ b/Alignment/OfflineValidation/macros/makeArrowPlots.C @@ -90,6 +90,8 @@ int makeRPhiArrowPlot( TTree* data, const char* name, double xLim, double yLim, char outfile[192]; sprintf( outfile, "%s/%s.png", outputDir_, name ); OBPCanvas->Print( outfile ); + sprintf(outfile, "%s/%s.pdf", outputDir_, name); + OBPCanvas->SaveAs(outfile); return passcut; } @@ -135,6 +137,8 @@ int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim char outfile[192]; sprintf( outfile, "%s/%s.png", outputDir_, name ); OBPCanvas->Print( outfile ); + sprintf(outfile, "%s/%s.pdf", outputDir_, name); + OBPCanvas->SaveAs(outfile); return passcut; } diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index d7fbc3861ae41..3aef54a6cd35d 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -246,6 +246,11 @@ def createScript(self, path): "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash " "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." ".Comparison_common"+name+"_Images/ArrowPlots\"\n") + repMap["runComparisonScripts"] += \ + ("find .oO[name]Oo.."+name+"_ArrowPlots " + "-maxdepth 1 -name \"*.pdf\" -print | xargs -I {} bash " + "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." + ".Comparison_common"+name+"_Images/ArrowPlots\"\n") repMap["runComparisonScripts"] += \ ("find . " "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash " From 41e6ab37334dbc9ea94da89606f6629c33294f12 Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Fri, 3 Nov 2017 09:55:46 +0100 Subject: [PATCH 7/8] Plot only global geometry comparison plots by default to save disk space. --- .../python/TkAlAllInOneTool/geometryComparison.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index 3aef54a6cd35d..cfb923133e2c3 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -17,7 +17,7 @@ class GeometryComparison(GenericValidation): "modulesToPlot":"all", "moduleList": "/store/caf/user/cschomak/emptyModuleList.txt", "useDefaultRange":"false", - "plotOnlyGlobal":"false", + "plotOnlyGlobal":"true", "plotPng":"true", "makeProfilePlots":"true", "dx_min":"-99999", From 3e1724eaef0f915496bf5c2d6c727884d42aff81 Mon Sep 17 00:00:00 2001 From: Gregor Mittag Date: Fri, 3 Nov 2017 10:27:52 +0100 Subject: [PATCH 8/8] Allow special characters in alignment names. --- .../python/TkAlAllInOneTool/alignment.py | 4 ++-- .../TkAlAllInOneTool/betterConfigParser.py | 10 ++++++++++ .../TkAlAllInOneTool/geometryComparison.py | 6 +++--- .../python/TkAlAllInOneTool/helperFunctions.py | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/alignment.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/alignment.py index 989d014366222..f1865542eeb04 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/alignment.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/alignment.py @@ -3,7 +3,7 @@ import re import configTemplates -from helperFunctions import conddb, parsecolor, parsestyle, replaceByMap +from helperFunctions import conddb, parsecolor, parsestyle, replaceByMap, clean_name from TkAlExceptions import AllInOneError class Alignment(object): @@ -39,7 +39,7 @@ def __init__(self, name, config, runGeomComp = "1"): config.checkInput(section, knownSimpleOptions = ['globaltag', 'style', 'color', 'title', 'mp', 'mp_alignments', 'mp_deformations', 'hp', 'hp_alignments', 'hp_deformations', 'sm', 'sm_alignments', 'sm_deformations'], knownKeywords = ['condition']) - self.name = name + self.name = clean_name(name) if config.exists(section,"title"): self.title = config.get(section,"title") else: diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/betterConfigParser.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/betterConfigParser.py index 967418cbac24e..514c9cd20c0fb 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/betterConfigParser.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/betterConfigParser.py @@ -125,6 +125,16 @@ def getAlignments( self ): if "alignment:" in section: alignments.append( Alignment( section.split( "alignment:" )[1], self ) ) + names_after_cleaning = [alignment.name for alignment in alignments] + duplicates = [name + for name, count + in collections.Counter(names_after_cleaning).items() + if count > 1] + if len(duplicates) > 0: + msg = "Duplicate alignment names after removing invalid characters: " + msg += ", ".join(duplicates) +"\n" + msg += "Please rename the alignments to avoid name clashes." + raise AllInOneError(msg) return alignments def getCompares( self ): diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py index cfb923133e2c3..3c9a991551f44 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/geometryComparison.py @@ -2,7 +2,7 @@ import ConfigParser # needed for exceptions in this module import configTemplates from genericValidation import GenericValidation -from helperFunctions import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring +from helperFunctions import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring, clean_name from TkAlExceptions import AllInOneError @@ -89,12 +89,12 @@ def getRepMap(self, alignment = None): common = self.__compares.keys()[0] repMap.update({ - "common": common, + "common": clean_name(common), "comparedGeometry": (".oO[alignmentName]Oo." "ROOTGeometry.root"), "referenceGeometry": "IDEAL", # will be replaced later # if not compared to IDEAL - "reference": referenceName, + "reference": clean_name(referenceName), "referenceTitle": referenceTitle, "alignmentTitle": self.alignmentToValidate.title, "moduleListBase": os.path.basename(repMap["moduleList"]), diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py index 7ab95632f52df..cad93a334641c 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py @@ -1,4 +1,5 @@ import os +import re import ROOT import sys from TkAlExceptions import AllInOneError @@ -226,3 +227,19 @@ def sysexit(number): sys.stdout = bkpstdout return result + + +def clean_name(s): + """Transforms a string into a valid variable or method name. + + Arguments: + - `s`: input string + """ + + # Remove invalid characters + s = re.sub(r"[^0-9a-zA-Z_]", "", s) + + # Remove leading characters until we find a letter or underscore + s = re.sub(r"^[^a-zA-Z_]+", "", s) + + return s