File indexing completed on 2024-04-06 11:56:58
0001
0002 #include <string>
0003 #include <sstream>
0004
0005 #include "TProfile.h"
0006 #include "TList.h"
0007 #include "TNtuple.h"
0008 #include "TString.h"
0009 #include "TArrow.h"
0010 #include "TFrame.h"
0011 #include "TString.h"
0012
0013 double arrowSize = 0.0095;
0014 float y_, x_, z_, phi_, r_, dphi_, dr_, dx_, dz_, dy_;
0015 int level_, sublevel_;
0016 char outputDir_[292];
0017
0018 void Plot10Mu(const char* text, float X, float Y, float size) {
0019 TPaveText* atext = new TPaveText(X, Y, X + size, Y + size);
0020 atext->AddText(text);
0021 atext->SetLineColor(0);
0022 atext->SetFillColor(0);
0023 atext->SetTextFont(42);
0024 atext->SetTextSize(0.04);
0025 atext->Draw();
0026 delete atext;
0027 }
0028
0029 void normArrow(float x, float y, float norm) {
0030
0031 TArrow* normArrow = new TArrow(x, y, x + norm, y, arrowSize, ">");
0032 normArrow->Draw();
0033 }
0034
0035 void DrawRPhiLegend(double xLim, double yLim, double barrelRPhiRescale) {
0036 float xTest = 0.9 * xLim;
0037 float yTest = yLim / 2;
0038 float testBlockSize = 0.2 * xLim;
0039 float disty = 0;
0040 float dYTest = 0.1 * xLim;
0041
0042 Plot10Mu("#Delta r:", xTest, yTest, testBlockSize);
0043 Plot10Mu("500 #mum", xTest, yTest - 3 * dYTest, testBlockSize);
0044 normArrow(xTest + dYTest, yTest - 4 * dYTest - disty, 500. / 10000 * barrelRPhiRescale);
0045 }
0046
0047 int makeRPhiArrowPlot(TTree* data,
0048 const char* name,
0049 double xLim,
0050 double yLim,
0051 double level,
0052 double sublevel,
0053 double zMin,
0054 double zMax,
0055 double rMin,
0056 double rMax,
0057 double barrelRPhiRescale) {
0058 TCanvas* OBPCanvas = new TCanvas(name, name, 1050, 875);
0059 OBPCanvas->DrawFrame(-xLim, -yLim, 1.2 * xLim, yLim, ";module position x [cm];module position y [cm]");
0060 OBPCanvas->SetFillColor(0);
0061 OBPCanvas->SetFrameBorderMode(0);
0062
0063 TFrame* aFrame = OBPCanvas->GetFrame();
0064 aFrame->SetFillColor(0);
0065
0066 int passcut = 0;
0067 for (int entry = 0; entry < data->GetEntries(); entry++) {
0068 data->GetEntry(entry);
0069 if ((level_ == level) && (((sublevel_ == sublevel) && (sublevel != 0)) || (sublevel == 0))) {
0070 if ((z_ <= zMax) && (z_ > zMin) && (r_ <= rMax) && (r_ > rMin)) {
0071 TArrow* aArraw = new TArrow(x_, y_, x_ + barrelRPhiRescale * dx_, y_ + barrelRPhiRescale * dy_, 0.0075, ">");
0072 aArraw->Draw();
0073 passcut++;
0074 }
0075 }
0076 }
0077 DrawRPhiLegend(xLim, yLim, barrelRPhiRescale);
0078
0079 std::ostringstream sliceLeg_s;
0080 sliceLeg_s << name << ": " << zMin << " < z <= " << zMax;
0081 TString sliceLeg(sliceLeg_s.str());
0082 TPaveText* atext = new TPaveText(0.2 * xLim, 0.85 * yLim, 0.66 * xLim, 0.99 * yLim);
0083 atext->AddText(sliceLeg);
0084 atext->SetLineColor(0);
0085 atext->SetFillColor(0);
0086 atext->SetTextFont(42);
0087 atext->SetTextSize(0.04);
0088 atext->Draw();
0089
0090 std::ostringstream outfile_s;
0091 outfile_s << outputDir_ << "/" << name << ".png";
0092 TString outfile(outfile_s.str());
0093 OBPCanvas->Print(outfile);
0094 std::ostringstream outfile2_s;
0095 outfile2_s << outputDir_ << "/" << name << ".pdf";
0096 TString outfile2(outfile2_s.str());
0097 OBPCanvas->SaveAs(outfile2);
0098
0099 delete atext;
0100 delete OBPCanvas;
0101
0102 return passcut;
0103 }
0104
0105 int makeZPhiArrowPlot(TTree* data,
0106 const char* name,
0107 double zLim,
0108 double phiLim,
0109 double level,
0110 double sublevel,
0111 double zMin,
0112 double zMax,
0113 double rMin,
0114 double rMax,
0115 double barrelRPhiRescale) {
0116 TCanvas* OBPCanvas = new TCanvas(name, name, 1050, 875);
0117 OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2 * zLim, phiLim, ";module position z [cm];module position r*phi [cm]");
0118 OBPCanvas->SetFillColor(0);
0119 OBPCanvas->SetFrameBorderMode(0);
0120
0121 TFrame* aFrame = OBPCanvas->GetFrame();
0122 aFrame->SetFillColor(0);
0123
0124 int passcut = 0;
0125 for (int entry = 0; entry < data->GetEntries(); entry++) {
0126 data->GetEntry(entry);
0127 if ((level_ == level) && (((sublevel_ == sublevel) && (sublevel != 0)) || (sublevel == 0))) {
0128 if ((z_ <= zMax) && (z_ > zMin) && (r_ <= rMax) && (r_ > rMin)) {
0129 TArrow* aArraw = new TArrow(
0130 z_, r_ * phi_, z_ + barrelRPhiRescale * dz_, r_ * phi_ + barrelRPhiRescale * r_ * dphi_, 0.0075, ">");
0131 aArraw->Draw();
0132 passcut++;
0133 }
0134 }
0135 }
0136 DrawRPhiLegend(zLim, phiLim, barrelRPhiRescale);
0137
0138 std::ostringstream sliceLeg_s;
0139 sliceLeg_s << name << ": " << rMin << " < r <= " << rMax;
0140 TString sliceLeg(sliceLeg_s.str());
0141 TPaveText* atext = new TPaveText(0.2 * zLim, 0.85 * phiLim, 0.66 * zLim, 0.99 * phiLim);
0142 atext->AddText(sliceLeg);
0143 atext->SetLineColor(0);
0144 atext->SetFillColor(0);
0145 atext->SetTextFont(42);
0146 atext->SetTextSize(0.04);
0147 atext->Draw();
0148
0149 std::ostringstream outfile_s;
0150 outfile_s << outputDir_ << "/" << name << ".png";
0151 TString outfile(outfile_s.str());
0152 OBPCanvas->Print(outfile);
0153 std::ostringstream outfile2_s;
0154 outfile2_s << outputDir_ << "/" << name << ".pdf";
0155 TString outfile2(outfile2_s.str());
0156 OBPCanvas->SaveAs(outfile2);
0157
0158 delete atext;
0159 delete OBPCanvas;
0160
0161 return passcut;
0162 }
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 void makeArrowPlots(const char* filename, const char* outputDir) {
0219 TFile fin(filename);
0220 fin.cd();
0221
0222 bool plotPXB = true;
0223 bool plotTIB = true;
0224 bool plotTOB = true;
0225 bool plotPXF = true;
0226 bool plotTID = true;
0227 bool plotTEC = true;
0228
0229 sprintf(outputDir_, "%s", outputDir);
0230 gSystem->mkdir(outputDir_, true);
0231
0232 TTree* data = static_cast<TTree*>(fin.Get("alignTree"));
0233 data->SetBranchAddress("sublevel", &sublevel_);
0234 data->SetBranchAddress("level", &level_);
0235 data->SetBranchAddress("x", &x_);
0236 data->SetBranchAddress("y", &y_);
0237 data->SetBranchAddress("z", &z_);
0238 data->SetBranchAddress("dx", &dx_);
0239 data->SetBranchAddress("dy", &dy_);
0240 data->SetBranchAddress("dz", &dz_);
0241 data->SetBranchAddress("dphi", &dphi_);
0242 data->SetBranchAddress("dr", &dr_);
0243 data->SetBranchAddress("phi", &phi_);
0244 data->SetBranchAddress("r", &r_);
0245
0246
0247
0248
0249 int totalPXB_modules = 0;
0250 int totalPXB_modules_zphi = 0;
0251
0252 if (plotPXB) {
0253 double pxbScale = 30.0;
0254 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY-4", 20, 20, 1, 1, -26, -20, 0, 19, pxbScale);
0255 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY-3", 20, 20, 1, 1, -19, -14, 0, 19, pxbScale);
0256 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY-2", 20, 20, 1, 1, -14, -6.5, 0, 19, pxbScale);
0257 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY-1", 20, 20, 1, 1, -6.5, 0, 0, 19, pxbScale);
0258 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY+1", 20, 20, 1, 1, 0, 6.5, 0, 19, pxbScale);
0259 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY+2", 20, 20, 1, 1, 6.5, 14, 0, 19, pxbScale);
0260 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY+3", 20, 20, 1, 1, 14, 19, 0, 19, pxbScale);
0261 totalPXB_modules += makeRPhiArrowPlot(data, "PXB_BarrelXY+4", 20, 20, 1, 1, 19, 26, 0, 19, pxbScale);
0262 double pxbScale_zphi = 40.0;
0263 totalPXB_modules_zphi += makeZPhiArrowPlot(data, "PXB_BarrelZPhi_1", 35, 15, 1, 1, -300, 300, 0, 5, pxbScale_zphi);
0264 totalPXB_modules_zphi += makeZPhiArrowPlot(data, "PXB_BarrelZPhi_2", 35, 30, 1, 1, -300, 300, 5, 9, pxbScale_zphi);
0265 totalPXB_modules_zphi += makeZPhiArrowPlot(data, "PXB_BarrelZPhi_3", 35, 45, 1, 1, -300, 300, 9, 14, pxbScale_zphi);
0266 totalPXB_modules_zphi +=
0267 makeZPhiArrowPlot(data, "PXB_BarrelZPhi_4", 35, 65, 1, 1, -300, 300, 14, 19, pxbScale_zphi);
0268 }
0269
0270
0271 int totalTIB_modules = 0;
0272 int totalTIB_modules_zphi = 0;
0273 if (plotTIB) {
0274 double tibScale = 30.0;
0275 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-6", 80, 80, 1, 3, -70, -56, 0, 120, tibScale);
0276 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-5", 80, 80, 1, 3, -56, -42, 0, 120, tibScale);
0277 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-4", 80, 80, 1, 3, -42, -32, 0, 120, tibScale);
0278 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-3", 80, 80, 1, 3, -32, -20, 0, 120, tibScale);
0279 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-2", 80, 80, 1, 3, -20, -10, 0, 120, tibScale);
0280 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY-1", 80, 80, 1, 3, -10, 0, 0, 120, tibScale);
0281 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+1", 80, 80, 1, 3, 0, 10, 0, 120, tibScale);
0282 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+2", 80, 80, 1, 3, 10, 20, 0, 120, tibScale);
0283 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+3", 80, 80, 1, 3, 20, 32, 0, 120, tibScale);
0284 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+4", 80, 80, 1, 3, 32, 42, 0, 120, tibScale);
0285 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+5", 80, 80, 1, 3, 42, 56, 0, 120, tibScale);
0286 totalTIB_modules += makeRPhiArrowPlot(data, "TIB_BarrelXY+6", 80, 80, 1, 3, 56, 70, 0, 120, tibScale);
0287 double tibScale_zphi = 40.0;
0288 totalTIB_modules_zphi +=
0289 makeZPhiArrowPlot(data, "TIB_BarrelZPhi_1", 80, 120, 1, 3, -300, 300, 20.0, 29.0, tibScale_zphi);
0290 totalTIB_modules_zphi +=
0291 makeZPhiArrowPlot(data, "TIB_BarrelZPhi_2", 80, 140, 1, 3, -300, 300, 29.0, 37.5, tibScale_zphi);
0292 totalTIB_modules_zphi +=
0293 makeZPhiArrowPlot(data, "TIB_BarrelZPhi_3", 80, 170, 1, 3, -300, 300, 37.5, 47.5, tibScale_zphi);
0294 totalTIB_modules_zphi +=
0295 makeZPhiArrowPlot(data, "TIB_BarrelZPhi_4", 80, 200, 1, 3, -300, 300, 47.5, 60.0, tibScale_zphi);
0296 }
0297
0298
0299 int totalTOB_modules = 0;
0300 int totalTOB_modules_zphi = 0;
0301 if (plotTOB) {
0302 double tobScale = 100.0;
0303 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-6", 150, 150, 1, 5, -108, -90, 0, 120, tobScale);
0304 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-5", 150, 150, 1, 5, -90, -72, 0, 120, tobScale);
0305 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-4", 150, 150, 1, 5, -72, -54, 0, 120, tobScale);
0306 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-3", 150, 150, 1, 5, -54, -36, 0, 120, tobScale);
0307 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-2", 150, 150, 1, 5, -36, -18, 0, 120, tobScale);
0308 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY-1", 150, 150, 1, 5, -18, 0, 0, 120, tobScale);
0309 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+1", 150, 150, 1, 5, 0, 18, 0, 120, tobScale);
0310 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+2", 150, 150, 1, 5, 18, 36, 0, 120, tobScale);
0311 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+3", 150, 150, 1, 5, 36, 54, 0, 120, tobScale);
0312 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+4", 150, 150, 1, 5, 54, 72, 0, 120, tobScale);
0313 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+5", 150, 150, 1, 5, 72, 90, 0, 120, tobScale);
0314 totalTOB_modules += makeRPhiArrowPlot(data, "TOB_BarrelXY+6", 150, 150, 1, 5, 90, 108, 0, 120, tobScale);
0315 double tobScale_zphi = 40.0;
0316 totalTOB_modules_zphi +=
0317 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_1", 130, 250, 1, 5, -300, 300, 55.0, 65.0, tobScale_zphi);
0318 totalTOB_modules_zphi +=
0319 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_2", 130, 280, 1, 5, -300, 300, 65.0, 75.0, tobScale_zphi);
0320 totalTOB_modules_zphi +=
0321 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_3", 130, 320, 1, 5, -300, 300, 75.0, 85.0, tobScale_zphi);
0322 totalTOB_modules_zphi +=
0323 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_4", 130, 350, 1, 5, -300, 300, 85.0, 93.0, tobScale_zphi);
0324 totalTOB_modules_zphi +=
0325 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_5", 130, 380, 1, 5, -300, 300, 93.0, 101.0, tobScale_zphi);
0326 totalTOB_modules_zphi +=
0327 makeZPhiArrowPlot(data, "TOB_BarrelZPhi_6", 130, 410, 1, 5, -300, 300, 101.0, 110.0, tobScale_zphi);
0328 }
0329
0330
0331 int totalPXF_modules = 0;
0332
0333 if (plotPXF) {
0334 double pxfScale = 30.0;
0335 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY+1", 20, 20, 1, 2, 25, 36, 0, 120, pxfScale);
0336 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY+2", 20, 20, 1, 2, 36, 44, 0, 120, pxfScale);
0337 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY+3", 20, 20, 1, 2, 44, 55, 0, 120, pxfScale);
0338 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY-1", 20, 20, 1, 2, -36, -25, 0, 120, pxfScale);
0339 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY-2", 20, 20, 1, 2, -44, -36, 0, 120, pxfScale);
0340 totalPXF_modules += makeRPhiArrowPlot(data, "PXF_DiskXY-3", 20, 20, 1, 2, -55, -44, 0, 120, pxfScale);
0341
0342
0343
0344
0345
0346
0347
0348 }
0349
0350
0351 int totalTID_modules = 0;
0352
0353 if (plotTID) {
0354 double tidScale = 50.0;
0355 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY+1", 70, 70, 1, 4, 70, 80, 0, 120, tidScale);
0356 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY+2", 70, 70, 1, 4, 80, 95, 0, 120, tidScale);
0357 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY+3", 70, 70, 1, 4, 95, 110, 0, 120, tidScale);
0358 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY-1", 70, 70, 1, 4, -80, -70, 0, 120, tidScale);
0359 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY-2", 70, 70, 1, 4, -95, -80, 0, 120, tidScale);
0360 totalTID_modules += makeRPhiArrowPlot(data, "TID_DiskXY-3", 70, 70, 1, 4, -110, -95, 0, 120, tidScale);
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370 }
0371
0372
0373 int totalTEC_modules = 0;
0374 if (plotTEC) {
0375 double tecScale = 100.0;
0376 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+1", 150, 150, 1, 6, 120, 130, 0, 120, tecScale);
0377 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+2", 150, 150, 1, 6, 130, 145, 0, 120, tecScale);
0378 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+3", 150, 150, 1, 6, 145, 160, 0, 120, tecScale);
0379 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+4", 150, 150, 1, 6, 160, 175, 0, 120, tecScale);
0380 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+5", 150, 150, 1, 6, 175, 190, 0, 120, tecScale);
0381 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+6", 150, 150, 1, 6, 190, 215, 0, 120, tecScale);
0382 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+7", 150, 150, 1, 6, 215, 235, 0, 120, tecScale);
0383 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+8", 150, 150, 1, 6, 235, 260, 0, 120, tecScale);
0384 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY+9", 150, 150, 1, 6, 260, 280, 0, 120, tecScale);
0385 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-1", 150, 150, 1, 6, -130, -120, 0, 120, tecScale);
0386 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-2", 150, 150, 1, 6, -145, -130, 0, 120, tecScale);
0387 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-3", 150, 150, 1, 6, -160, -145, 0, 120, tecScale);
0388 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-4", 150, 150, 1, 6, -175, -160, 0, 120, tecScale);
0389 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-5", 150, 150, 1, 6, -190, -175, 0, 120, tecScale);
0390 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-6", 150, 150, 1, 6, -215, -190, 0, 120, tecScale);
0391 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-7", 150, 150, 1, 6, -235, -215, 0, 120, tecScale);
0392 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-8", 150, 150, 1, 6, -260, -235, 0, 120, tecScale);
0393 totalTEC_modules += makeRPhiArrowPlot(data, "TEC_DiskXY-9", 150, 150, 1, 6, -280, -260, 0, 120, tecScale);
0394 }
0395
0396 std::cout << "Plotted PXB modules: " << totalPXB_modules << std::endl;
0397 std::cout << "Plotted PXB modules (zphi): " << totalPXB_modules_zphi << std::endl;
0398 std::cout << "Plotted TIB modules: " << totalTIB_modules << std::endl;
0399 std::cout << "Plotted TIB modules (zphi): " << totalTIB_modules_zphi << std::endl;
0400 std::cout << "Plotted TOB modules: " << totalTOB_modules << std::endl;
0401 std::cout << "Plotted TOB modules (zphi): " << totalTOB_modules_zphi << std::endl;
0402 std::cout << "Plotted PXF modules: " << totalPXF_modules << std::endl;
0403
0404 std::cout << "Plotted TID modules: " << totalTID_modules << std::endl;
0405
0406 std::cout << "Plotted TEC modules: " << totalTEC_modules << std::endl;
0407
0408 delete data;
0409 }