File indexing completed on 2024-04-06 11:57:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 struct AlighnmentTTrees {
0013 TTree* DTWheels;
0014 TTree* DTStations;
0015 TTree* DTChambers;
0016 TTree* DTSuperLayers;
0017 TTree* DTLayers;
0018 TTree* CSCStations;
0019 TTree* CSCChambers;
0020 TTree* CSCLayers;
0021 };
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 void importTreesFromFile(char *filename, TString dirname, AlighnmentTTrees *at, TString namePrf = "")
0039 {
0040 TFile* f = new TFile(filename);
0041
0042 TTree* tmpTree_DTWheels = (TTree*)f->Get((dirname+"/DTWheels").Data());
0043 TTree* tmpTree_DTStations = (TTree*)f->Get((dirname+"/DTStations").Data());
0044 TTree* tmpTree_DTChambers = (TTree*)f->Get((dirname+"/DTChambers").Data());
0045
0046
0047
0048 TTree* tmpTree_CSCStations = (TTree*)f->Get((dirname+"/CSCStations").Data());
0049 TTree* tmpTree_CSCChambers = (TTree*)f->Get((dirname+"/CSCChambers").Data());
0050
0051
0052 gDirectory->Cd("Rint:/");
0053 at->DTWheels = (TTree*) tmpTree_DTWheels->CopyTree("1");
0054 at->DTStations = (TTree*) tmpTree_DTStations->CopyTree("1");
0055 at->DTChambers = (TTree*) tmpTree_DTChambers->CopyTree("1");
0056
0057
0058
0059 at->CSCStations = (TTree*) tmpTree_CSCStations->CopyTree("1");
0060 at->CSCChambers = (TTree*) tmpTree_CSCChambers->CopyTree("1");
0061
0062
0063 at->DTWheels ->SetName((namePrf+"DTWheels" ).Data());
0064 at->DTStations ->SetName((namePrf+"DTStations" ).Data());
0065 at->DTChambers ->SetName((namePrf+"DTChambers" ).Data());
0066
0067
0068 at->CSCStations ->SetName((namePrf+"CSCStations" ).Data());
0069 at->CSCChambers ->SetName((namePrf+"CSCChambers" ).Data());
0070
0071
0072 f->Close();
0073 }
0074
0075
0076
0077 void setupStyle()
0078 {
0079 gStyle->SetStatBorderSize(1);
0080 gStyle->SetStatStyle(3001);
0081 gStyle->SetOptStat(1111110);
0082 gStyle->SetOptFit(1111);
0083 gStyle->SetStatColor(0);
0084 gStyle->SetStatFontSize(0.03);
0085 gStyle->SetStatW(0.28);
0086 gStyle->SetStatH(0.32);
0087 gStyle->SetStatX(.99);
0088 gStyle->SetStatY(.99);
0089
0090 gStyle->SetCanvasBorderMode(0);
0091 gStyle->SetPadTopMargin(0.13);
0092 gStyle->SetPadLeftMargin(0.16);
0093 gStyle->SetPadRightMargin(0.06);
0094 gStyle->SetTitleYOffset(1.2);
0095 gStyle->SetTitleXOffset(.65);
0096 gStyle->SetTitleYSize(0.07);
0097 gStyle->SetTitleXSize(0.07);
0098 gStyle->SetLabelSize(0.05);
0099 gStyle->SetLabelSize(0.05,"Y");
0100
0101 gStyle->SetTitleBorderSize(0);
0102
0103 gStyle->SetTitleColor(1);
0104 gStyle->SetTitleFillColor(0);
0105 gStyle->SetTitleFontSize(0.07);
0106 gStyle->SetTitleStyle(0);
0107
0108 }
0109
0110
0111
0112 void setupHisto(TH1F *h, char title[200], int color=-1, int lcolor=-1)
0113 {
0114 h->SetTitle(title);
0115 if (color>=0) h->SetFillColor(color);
0116 if (lcolor>=0) {
0117 h->SetLineColor(lcolor);
0118 h->SetLineWidth(2);
0119 }
0120 }
0121
0122
0123
0124 void adjustRange(TH1F *h, TH1F *h1)
0125 {
0126 double ymax = (h->GetMaximum() > h1->GetMaximum()) ? h->GetMaximum() : h1->GetMaximum();
0127 h1->SetMaximum(ymax*1.05);
0128
0129 }
0130
0131
0132
0133
0134 void compare2Alignments(
0135 char *filename,
0136 TString alment0="mockAlignment",
0137 TString alment1="ideal")
0138 {
0139 setupStyle();
0140
0141 AlighnmentTTrees alignTrees[2];
0142
0143 importTreesFromFile(filename, alment0, &alignTrees[0], alment0+"_");
0144 importTreesFromFile(filename, alment1, &alignTrees[1], alment1+"_");
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 alignTrees[0].DTWheels->AddFriend(alignTrees[1].DTWheels,"a");
0177 alignTrees[0].DTChambers->AddFriend(alignTrees[1].DTChambers,"a");
0178 alignTrees[0].DTStations->AddFriend(alignTrees[1].DTStations,"a");
0179
0180
0181 alignTrees[0].CSCStations->AddFriend(alignTrees[1].CSCStations,"a");
0182 alignTrees[0].CSCChambers->AddFriend(alignTrees[1].CSCChambers,"a");
0183
0184
0185
0186
0187 char histostr[100], drawstr[300], cutstr[200], hsetupstr[200];
0188
0189 double nbin = 20, low = -0.05, high = 0.05;
0190
0191 TCanvas *c1 = new TCanvas("c_barrel_dz","c_barrel_dz",1500,350);
0192 c1->Divide(5,1,0.001,0.001);
0193 TH1F *h_bz_[5];
0194 for (int i=-2; i<=2; i++) {
0195 c1->cd(i+3);
0196 sprintf(histostr,"h_bz_[%d]",i+2);
0197
0198 sprintf(drawstr,"xhatx*dx+xhaty*dy+xhatz*dz>>%s(%d,%f,%f)",histostr,nbin,low,high);
0199 sprintf(cutstr, "structa==%d",i);
0200
0201 sprintf(hsetupstr,"wheel %d: #Delta x;#Delta x;# chambers", i);
0202 cout<<drawstr<<endl;
0203 alignTrees[0].DTChambers->Draw(drawstr,cutstr);
0204 h_bz_[i+2] = (TH1F*) gROOT->FindObject(histostr);
0205 setupHisto(h_bz_[i+2],hsetupstr, 3);
0206 h_bz_[i+2]->GetXaxis()->SetNdivisions(207);
0207 }
0208 c1->cd();
0209
0210
0211
0212 nbin = 20; low = -.02; high = .02;
0213
0214 TCanvas *c2 = new TCanvas("c_endcap_dz","c_endcap_dz",1200,700);
0215 c2->Divide(4,2,0.001,0.001);
0216 TH1F *h_edz_[9];
0217 int npad=1;
0218 for (int i=-4; i<=4; i++) {
0219 if (i==0) continue;
0220 c2->cd(npad++);
0221 sprintf(histostr,"h_edz_[%d]",i+4);
0222
0223 sprintf(drawstr,"xhatx*dx+xhaty*dy+xhatz*dz>>%s(%d,%f,%f)",histostr,nbin,low,high);
0224
0225 sprintf(cutstr, "structa==%d&&(!(structa==1&&(structb==1||structb==4)))",i);
0226
0227 sprintf(hsetupstr,"disk %d: #Delta x;#Delta x;# chambers", i);
0228 cout<<drawstr<<endl;
0229 alignTrees[0].CSCChambers->Draw(drawstr,cutstr);
0230 h_edz_[i+4] = (TH1F*) gROOT->FindObject(histostr);
0231 setupHisto(h_edz_[i+4],hsetupstr, 3);
0232 h_edz_[i+4]->GetXaxis()->SetNdivisions(207);
0233 }
0234 c2->cd();
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244 return;
0245
0246 if (gROOT->IsBatch()) return;
0247 new TBrowser();
0248 TTreeViewer *treeview = new TTreeViewer();
0249
0250 char tnames[8][50] = {"DTWheels","DTStations","DTChambers","CSCStations" ,"CSCChambers" };
0251 for (int i=0;i<8;i++) {
0252 char nm[200];
0253 sprintf(nm,"%s_%s",alment0.Data(),tnames[i]);
0254 treeview->SetTreeName(nm);
0255 }
0256 for (int i=0;i<8;i++) {
0257 char nm[200];
0258 sprintf(nm,"%s_%s",alment1.Data(),tnames[i]);
0259 treeview->SetTreeName(nm);
0260 }
0261
0262
0263 }
0264
0265
0266
0267
0268
0269 void compare2AlignmentsSame(
0270 char *filename,
0271 TString alment0="fromAlignment",
0272 TString alment1="ideal")
0273 {
0274 setupStyle();
0275
0276 AlighnmentTTrees alignTrees[2];
0277
0278 importTreesFromFile(filename, alment0, &alignTrees[0], alment0+"_");
0279 importTreesFromFile(filename, alment1, &alignTrees[1], alment1+"_");
0280
0281
0282 alignTrees[0].DTWheels->AddFriend(alignTrees[1].DTWheels,"a");
0283 alignTrees[0].DTChambers->AddFriend(alignTrees[1].DTChambers,"a");
0284 alignTrees[0].DTStations->AddFriend(alignTrees[1].DTStations,"a");
0285
0286
0287 alignTrees[0].CSCStations->AddFriend(alignTrees[1].CSCStations,"a");
0288 alignTrees[0].CSCChambers->AddFriend(alignTrees[1].CSCChambers,"a");
0289
0290
0291
0292
0293 char histostr[100], histostr1[100], drawstr[300], cutstr[200], hsetupstr[200];
0294
0295 double nbin = 20, low = -0.05, high = 0.05;
0296
0297 TCanvas *c1 = (TCanvas*)gROOT->FindObject("c_barrel_dz");
0298 if (c1==NULL) return;
0299 TH1F *h_1;
0300 TH1F *h_bz_[5];
0301 for (int i=-2; i<=2; i++) {
0302 c1->cd(i+3);
0303 sprintf(histostr,"h_bz_s[%d]",i+2);
0304 sprintf(histostr1,"h_bz_[%d]",i+2);
0305
0306 sprintf(drawstr,"xhatx*dx+xhaty*dy+xhatz*dz>>%s(%d,%f,%f)",histostr,nbin,low,high);
0307 sprintf(cutstr, "structa==%d",i);
0308
0309 sprintf(hsetupstr,"wheel %d: #Delta x;#Delta x;# chambers", i);
0310 cout<<drawstr<<endl;
0311 alignTrees[0].DTChambers->Draw(drawstr,cutstr,"same");
0312 h_bz_[i+2] = (TH1F*) gROOT->FindObject(histostr);
0313 setupHisto(h_bz_[i+2],hsetupstr, -1, 4);
0314 h_1 = (TH1F*) gROOT->FindObjectAny(histostr1);
0315 adjustRange(h_bz_[i+2],h_1);
0316 }
0317 c1->cd();
0318
0319
0320
0321 nbin = 20; low = -.02; high = .02;
0322
0323 TCanvas *c2 = (TCanvas*)gROOT->FindObject("c_endcap_dz");
0324 if (c2==NULL) return;
0325 TH1F *h_edz_[9];
0326 int npad=1;
0327 for (int i=-4; i<=4; i++) {
0328 if (i==0) continue;
0329 c2->cd(npad++);
0330 sprintf(histostr,"h_edz_s[%d]",i+4);
0331 sprintf(histostr1,"h_edz_[%d]",i+4);
0332
0333 sprintf(drawstr,"xhatx*dx+xhaty*dy+xhatz*dz>>%s(%d,%f,%f)",histostr,nbin,low,high);
0334
0335 sprintf(cutstr, "structa==%d&&(!(abs(structa)==1&&(structb==1||structb==4)))",i);
0336
0337 sprintf(hsetupstr,"disk %d: #Delta x;#Delta x;# chambers", i);
0338 cout<<drawstr<<endl;
0339 alignTrees[0].CSCChambers->Draw(drawstr,cutstr,"same");
0340 h_edz_[i+4] = (TH1F*) gROOT->FindObject(histostr);
0341 setupHisto(h_edz_[i+4],hsetupstr, -1, 4);
0342 h_1 = (TH1F*) gROOT->FindObjectAny(histostr1);
0343 adjustRange(h_edz_[i+4],h_1);
0344 }
0345 c2->cd();
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355 return;
0356
0357 if (gROOT->IsBatch()) return;
0358 new TBrowser();
0359 TTreeViewer *treeview = new TTreeViewer();
0360
0361 char tnames[8][50] = {"DTWheels","DTStations","DTChambers","CSCStations" ,"CSCChambers" };
0362 for (int i=0;i<8;i++) {
0363 char nm[200];
0364 sprintf(nm,"%s_%s",alment0.Data(),tnames[i]);
0365 treeview->SetTreeName(nm);
0366 }
0367 for (int i=0;i<8;i++) {
0368 char nm[200];
0369 sprintf(nm,"%s_%s",alment1.Data(),tnames[i]);
0370 treeview->SetTreeName(nm);
0371 }
0372
0373
0374 }
0375
0376
0377
0378
0379
0380 void compareAlignmentsSeries(
0381 int N,
0382 char files[10][255],
0383 TString alment0,
0384 TString alment)
0385 {
0386
0387
0388 setupStyle();
0389
0390 AlighnmentTTrees alignTrees[10];
0391
0392 char dum[100];
0393 sprintf(dum,"%s_",alment0.Data());
0394 importTreesFromFile(files[0], alment0, &alignTrees[0], alment0+"_");
0395 for (Int_t i=1; i<=N; i++) {
0396 sprintf(dum,"%s_%d_",alment.Data(),i);
0397 importTreesFromFile(files[i-1], alment, &alignTrees[i], dum);
0398
0399 alignTrees[i].DTWheels->AddFriend(alignTrees[0].DTWheels,"a");
0400 alignTrees[i].DTChambers->AddFriend(alignTrees[0].DTChambers,"a");
0401 alignTrees[i].DTStations->AddFriend(alignTrees[0].DTStations,"a");
0402
0403
0404 alignTrees[i].CSCStations->AddFriend(alignTrees[0].CSCStations,"a");
0405 alignTrees[i].CSCChambers->AddFriend(alignTrees[0].CSCChambers,"a");
0406
0407 }
0408
0409
0410
0411 char histostr[100], drawstr[300], cutstr[200], hsetupstr[200];
0412 double nbin = 20, low = -0.15, high = 0.15;
0413
0414 TCanvas *tc = new TCanvas("test","test",500,500);
0415
0416
0417
0418
0419
0420 TCanvas *c1 = new TCanvas("c_barrel_dxloc","c_barrel_dxloc",1500,350);
0421 c1->Divide(5,1,0.001,0.001);
0422 TH1F *h_bdxloc_[6];
0423 h_bdxloc_[5] = new TH1F("hzero","hzero",5,0.5,5.5);
0424 h_bdxloc_[5]->SetStats(0);
0425 h_bdxloc_[5]->SetLineColor(4);
0426 for (int i=-2; i<=2; i++) {
0427 sprintf(histostr,"h_bdxloc_[%d]",i+2);
0428 cout<<histostr<<endl;
0429 h_bdxloc_[i+2] = new TH1F(histostr,histostr,5,0.5,5.5);
0430 sprintf(cutstr, "structa==%d",i);
0431 sprintf(hsetupstr,"wheel %d: #Delta x;alignment #;#Delta x", i);
0432 tc->cd();
0433 for (int f=1; f<=5; f++) {
0434 alignTrees[f].DTChambers->Draw("xhatx*dx+xhaty*dy+xhatz*dz",cutstr );
0435
0436
0437 h_bdxloc_[i+2]->SetBinContent(f,htemp->GetMean());
0438 h_bdxloc_[i+2]->SetBinError(f,htemp->GetRMS());
0439 }
0440 h_bdxloc_[i+2]->SetEntries(5);
0441 setupHisto(h_bdxloc_[i+2],hsetupstr, 8);
0442 c1->cd(i+3);
0443 h_bdxloc_[i+2]->Draw();
0444 h_bdxloc_[5]->Draw("same");
0445 }
0446 c1->cd();
0447
0448
0449
0450 TCanvas *c2 = new TCanvas("c_endcap_dxloc","c_endcap_dxloc",1200,700);
0451 c2->Divide(4,2,0.001,0.001);
0452 TH1F *h_edxloc_[10];
0453 h_edxloc_[9] = new TH1F("hezero","hezero",5,0.5,5.5);
0454 h_edxloc_[9]->SetStats(0);
0455 h_edxloc_[9]->SetLineColor(4);
0456 int npad=1;
0457 for (int i=-4; i<=4; i++) {
0458 if (i==0) continue;
0459 sprintf(histostr,"h_edxloc_[%d]",i+4);
0460 cout<<histostr<<endl;
0461 h_edxloc_[i+4] = new TH1F(histostr,histostr,5,0.5,5.5);
0462
0463 sprintf(cutstr, "structa==%d",i);
0464 sprintf(hsetupstr,"disk %d: #Delta x;alignment #;#Delta x", i);
0465 tc->cd();
0466 for (int f=1; f<=5; f++) {
0467 alignTrees[f].CSCChambers->Draw("xhatx*dx+xhaty*dy+xhatz*dz",cutstr );
0468
0469
0470 h_edxloc_[i+4]->SetBinContent(f,htemp->GetMean());
0471 h_edxloc_[i+4]->SetBinError(f,htemp->GetRMS());
0472 }
0473 h_edxloc_[i+4]->SetEntries(5);
0474 setupHisto(h_edxloc_[i+4],hsetupstr, 8);
0475 c2->cd(npad++);
0476 h_edxloc_[i+4]->Draw();
0477 h_edxloc_[9]->Draw("same");
0478 }
0479 c2->cd();
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491 return;
0492
0493 if (gROOT->IsBatch()) return;
0494 new TBrowser();
0495 TTreeViewer *treeview = new TTreeViewer();
0496
0497 char tnames[8][50] = {"DTWheels","DTStations","DTChambers","CSCStations" ,"CSCChambers" };
0498 for (int i=0;i<8;i++) {
0499 char nm[200];
0500 sprintf(nm,"%s_%s",alment0.Data(),tnames[i]);
0501 treeview->SetTreeName(nm);
0502 }
0503 for (int i=0;i<8;i++) {
0504 char nm[200];
0505 sprintf(nm,"%s_%s",alment.Data(),tnames[i]);
0506 treeview->SetTreeName(nm);
0507 }
0508
0509
0510 }
0511
0512
0513
0514
0515 void muonDBComparison()
0516 {
0517
0518
0519
0520 char files[5][255]={"root/tracker0.root", "root/tracker1.root", "root/tracker2.root", "root/tracker3.root", "root/tracker5.root"};
0521
0522
0523 compareAlignmentsSeries(5, files,"ideal","fromAlignment");
0524
0525
0526
0527 compare2Alignments("root/first_examples.root", "mockAlignment", "ideal");
0528
0529
0530 compare2AlignmentsSame("root/first_examples.root", "fromAlignment","ideal");
0531
0532 }