Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:04

0001 TFile *OpenFiles(std::string path) {
0002   TFile *f;
0003   f = new TFile(path.c_str(), "READ");
0004   return f;
0005 }
0006 
0007 void printEmptyChambers(std::string histoname, std::string oname, TFile *f) {
0008   TH2I *plot = (TH2I *)f->Get(histoname.c_str());
0009   std::string endcap, chamber;
0010   int limitr, limitc;
0011   std::vector<string> deadchambers;
0012 
0013   for (int e = 0; e < 2; e++) {
0014     for (int s = 0; s < 4; s++) {
0015       if (s == 0)
0016         limitr = 4;
0017       if (s == 1 || s == 2)
0018         limitr = 2;
0019       if (s == 3)
0020         limitr = 1;
0021       for (int r = 0; r < limitr; r++) {
0022         if (s == 0)
0023           limitc = 36;
0024         if (s != 0 && r == 0)
0025           limitc = 18;
0026         if (s != 0 && r == 1)
0027           limitc = 36;
0028         for (int c = 0; c < limitc; c++) {
0029           int type = 0;
0030           if (s == 0 && r == 0)
0031             type = 2;
0032           else if (s == 0 && r == 1)
0033             type = 3;
0034           else if (s == 0 && r == 2)
0035             type = 4;
0036           else if (s == 0 && r == 3)
0037             type = 1;
0038           else
0039             type = (s + 1) * 2 + (r + 1);
0040           if (e == 0)
0041             type = type + 10;
0042           if (e == 1)
0043             type = 11 - type;
0044           int bin = plot->GetBin((c + 1), type);
0045           float content = plot->GetBinContent(bin);
0046           std::ostringstream oss;
0047           if (e == 0)
0048             endcap = "+";
0049           if (e == 1)
0050             endcap = "-";
0051           oss << "ME " << endcap << (s + 1) << "/" << (r + 1) << "/" << (c + 1);
0052           chamber = oss.str();
0053           if (content == 0) {
0054             if (oname == "wire digis" && (s == 0 && r == 3))
0055               continue;
0056             else
0057               deadchambers.push_back(chamber);
0058           }
0059         }
0060       }
0061     }
0062   }
0063 
0064   int n_dc = deadchambers.size();
0065   ofstream file;
0066   file.open("deadchamberlist.txt", ios::app);
0067   file << "Chambers with missing " << oname << "...\n" << endl;
0068   if (n_dc > 0) {
0069     for (int n = 0; n < n_dc; n++) {
0070       file << deadchambers[n] << endl;
0071     }
0072   }
0073   file << "\n\n\n\n";
0074   file.close();
0075 }
0076 
0077 void make1DPlot(std::string histoname, TFile *f1, std::string histotitle, int statoption, std::string savename) {
0078   TH1F *h1 = (TH1F *)f1->Get(histoname.c_str());
0079 
0080   TCanvas *c = new TCanvas("c", "my canvas", 1);
0081 
0082   if (h1) {
0083     if (statoption == 0)
0084       gStyle->SetOptStat(kFALSE);
0085     else
0086       gStyle->SetOptStat(statoption);
0087     gStyle->SetHistFillColor(92);
0088     gStyle->SetFrameFillColor(4000);
0089     gStyle->SetTitleW(0.7);
0090     gStyle->SetTitleH(0.07);
0091     gPad->SetFillColor(4000);
0092     c->SetFillStyle(4000);
0093     gStyle->SetStatColor(0);
0094     gStyle->SetTitleFillColor(0);
0095     h1->UseCurrentStyle();
0096 
0097     h1->SetTitle(histotitle.c_str());
0098     h1->GetXaxis()->SetLabelSize(0.04);
0099     h1->GetYaxis()->SetLabelSize(0.04);
0100     h1->GetXaxis()->SetTitleOffset(0.7);
0101     h1->GetXaxis()->SetTitleSize(0.06);
0102     h1->GetXaxis()->SetNdivisions(208, kTRUE);
0103 
0104     h1->Draw();
0105 
0106     c->Update();
0107     c->Print(savename.c_str(), "png");
0108   }
0109   delete c;
0110 }
0111 
0112 void makeCSCOccupancy(std::string histoname, TFile *f1, std::string histotitle, std::string savename) {
0113   TH1F *h1 = (TH1F *)f1->Get(histoname.c_str());
0114 
0115   TCanvas *c = new TCanvas("c", "my canvas", 1);
0116 
0117   if (h1) {
0118     gStyle->SetOptStat(kFALSE);
0119     gStyle->SetHistFillColor(92);
0120     gStyle->SetFrameFillColor(4000);
0121     gStyle->SetTitleW(0.7);
0122     gStyle->SetTitleH(0.07);
0123     gPad->SetFillColor(4000);
0124     c->SetFillStyle(4000);
0125     gStyle->SetStatColor(0);
0126     gStyle->SetTitleFillColor(0);
0127     h1->UseCurrentStyle();
0128 
0129     h1->SetTitle(histotitle.c_str());
0130     h1->GetXaxis()->SetLabelSize(0.04);
0131     h1->GetYaxis()->SetLabelSize(0.04);
0132     h1->GetXaxis()->SetTitleOffset(0.7);
0133     h1->GetXaxis()->SetTitleSize(0.06);
0134     h1->GetXaxis()->SetNdivisions(208, kTRUE);
0135 
0136     h1->GetXaxis()->SetBinLabel(2, "Total Events");
0137     h1->GetXaxis()->SetBinLabel(4, "# Events with Wires");
0138     h1->GetXaxis()->SetBinLabel(6, "# Events with Strips");
0139     h1->GetXaxis()->SetBinLabel(8, "# Events with Wires&Strips");
0140     h1->GetXaxis()->SetBinLabel(10, "# Events with Rechits");
0141     h1->GetXaxis()->SetBinLabel(12, "# Events with Segments");
0142     h1->GetXaxis()->SetBinLabel(14, "Events Rejected");
0143 
0144     h1->Draw();
0145 
0146     c->Update();
0147     c->Print(savename.c_str(), "png");
0148   }
0149 
0150   delete c;
0151 }
0152 
0153 void make1DPlot2(std::string histoname1,
0154                  std::string histoname2,
0155                  int statoption,
0156                  TFile *f1,
0157                  std::string t1,
0158                  std::string t2,
0159                  std::string savename) {
0160   // use this if you want two plots on one canvas
0161 
0162   TH1F *a1 = (TH1F *)f1->Get(histoname1.c_str());
0163   TH1F *b1 = (TH1F *)f1->Get(histoname2.c_str());
0164 
0165   TCanvas *c = new TCanvas("c", "my canvas", 1);
0166   c->Divide(1, 2);
0167 
0168   if (a1) {
0169     c->cd(1);
0170     if (statoption == 0)
0171       gStyle->SetOptStat(kFALSE);
0172     else
0173       gStyle->SetOptStat(statoption);
0174     gStyle->SetHistFillColor(92);
0175     gStyle->SetFrameFillColor(4000);
0176     gStyle->SetTitleW(0.4);
0177     gStyle->SetTitleH(0.09);
0178     gStyle->SetStatColor(0);
0179     gStyle->SetTitleFillColor(0);
0180     gPad->SetFillColor(4000);
0181     c->SetFillStyle(4000);
0182     a1->UseCurrentStyle();
0183     a1->SetTitle(t1.c_str());
0184     a1->GetXaxis()->SetLabelSize(0.06);
0185     a1->GetYaxis()->SetLabelSize(0.06);
0186     a1->GetXaxis()->SetTitleOffset(0.7);
0187     a1->GetXaxis()->SetTitleSize(0.06);
0188     a1->GetXaxis()->SetNdivisions(208, kTRUE);
0189     a1->Draw();
0190   }
0191 
0192   if (b1) {
0193     gStyle->SetHistFillColor(72);
0194     b1->UseCurrentStyle();
0195 
0196     t2 = t2 + " (run " + run + ")";
0197     b1->SetTitle(t2.c_str());
0198     b1->GetXaxis()->SetLabelSize(0.06);
0199     b1->GetYaxis()->SetLabelSize(0.06);
0200     b1->GetXaxis()->SetTitleOffset(0.7);
0201     b1->GetXaxis()->SetTitleSize(0.06);
0202     b1->GetXaxis()->SetNdivisions(508, kTRUE);
0203     c->cd(2);
0204     b1->Draw();
0205   }
0206 
0207   c->Update();
0208   c->Print(savename.c_str(), "png");
0209   delete c;
0210 }
0211 
0212 void makeEffGif(std::string histoname, TFile *f1, std::string histotitle, std::string savename) {
0213   TH1F *ho = (TH1F *)f1->Get(histoname.c_str());
0214 
0215   TCanvas *c = new TCanvas("c", "my canvas", 1);
0216 
0217   TH1F *hn = new TH1F("tmp", histotitle.c_str(), 20, 0.5, 20.5);
0218 
0219   if (ho) {
0220     float Num = 1;
0221     float Den = 1;
0222     for (int i = 0; i < 20; i++) {
0223       Num = ho->GetBinContent(i + 1);
0224       Den = ho->GetBinContent(i + 21);
0225       //getEfficiency(Num, Den, eff);
0226       float Eff = 0.;
0227       float EffE = 0.;
0228       if (fabs(Den) > 0.000000001) {
0229         Eff = Num / Den;
0230         if (Num < Den) {
0231           EffE = sqrt((1. - Eff) * Eff / Den);
0232         }
0233       }
0234       hn->SetBinContent(i + 1, Eff);
0235       hn->SetBinError(i + 1, EffE);
0236     }
0237 
0238     gStyle->SetOptStat(kFALSE);
0239     gStyle->SetHistFillColor(92);
0240     gStyle->SetFrameFillColor(4000);
0241     gStyle->SetTitleW(0.7);
0242     gStyle->SetTitleH(0.07);
0243     gPad->SetFillColor(4000);
0244     gStyle->SetStatColor(0);
0245     gStyle->SetTitleFillColor(0);
0246     c->SetFillStyle(4000);
0247     hn->UseCurrentStyle();
0248 
0249     hn->SetTitle(histotitle.c_str());
0250     hn->GetXaxis()->SetLabelSize(0.04);
0251     hn->GetYaxis()->SetLabelSize(0.04);
0252     hn->GetXaxis()->SetTitleOffset(0.7);
0253     hn->GetXaxis()->SetTitleSize(0.06);
0254     hn->GetXaxis()->SetNdivisions(208, kTRUE);
0255     hn->GetYaxis()->SetRangeUser(0.5, 1.1);
0256     hn->SetMarkerStyle(6);
0257     hn->GetXaxis()->SetBinLabel(1, "ME +1/1b");
0258     hn->GetXaxis()->SetBinLabel(2, "ME +1/2");
0259     hn->GetXaxis()->SetBinLabel(3, "ME +1/3");
0260     hn->GetXaxis()->SetBinLabel(4, "ME +1/1a");
0261     hn->GetXaxis()->SetBinLabel(5, "ME +2/1");
0262     hn->GetXaxis()->SetBinLabel(6, "ME +2/2");
0263     hn->GetXaxis()->SetBinLabel(7, "ME +3/1");
0264     hn->GetXaxis()->SetBinLabel(8, "ME +3/2");
0265     hn->GetXaxis()->SetBinLabel(9, "ME +4/1");
0266     hn->GetXaxis()->SetBinLabel(10, "ME +4/2");
0267     hn->GetXaxis()->SetBinLabel(11, "ME -1/1b");
0268     hn->GetXaxis()->SetBinLabel(12, "ME -1/2");
0269     hn->GetXaxis()->SetBinLabel(13, "ME -1/3");
0270     hn->GetXaxis()->SetBinLabel(14, "ME -1/1a");
0271     hn->GetXaxis()->SetBinLabel(15, "ME -2/1");
0272     hn->GetXaxis()->SetBinLabel(16, "ME -2/2");
0273     hn->GetXaxis()->SetBinLabel(17, "ME -3/1");
0274     hn->GetXaxis()->SetBinLabel(18, "ME -3/2");
0275     hn->GetXaxis()->SetBinLabel(19, "ME -4/1");
0276     hn->GetXaxis()->SetBinLabel(20, "ME -4/2");
0277     hn->Draw();
0278     c->Update();
0279     c->Print(savename.c_str(), "png");
0280   }
0281   delete c;
0282   delete hn;
0283 }
0284 
0285 void Draw2DProfile(std::string histoname, TFile *f1, std::string title, std::string option, std::string savename) {
0286   TProfile2D *test = f1->Get(histoname.c_str());
0287   TH2D *plot = test->ProjectionXY("test2", option.c_str());
0288 
0289   if (plot) {
0290     TCanvas *c = new TCanvas("c", "my canvas", 1);
0291     gStyle->SetPalette(1, 0);
0292     gPad->SetFillColor(4000);
0293     c->SetFillStyle(4000);
0294     gStyle->SetStatColor(0);
0295     gStyle->SetTitleFillColor(0);
0296     plot->SetStats(kFALSE);
0297     plot->GetYaxis()->SetBinLabel(1, "ME- 4/1");
0298     plot->GetYaxis()->SetBinLabel(2, "ME- 3/2");
0299     plot->GetYaxis()->SetBinLabel(3, "ME- 3/1");
0300     plot->GetYaxis()->SetBinLabel(4, "ME- 2/2");
0301     plot->GetYaxis()->SetBinLabel(5, "ME- 2/1");
0302     plot->GetYaxis()->SetBinLabel(6, "ME- 1/3");
0303     plot->GetYaxis()->SetBinLabel(7, "ME- 1/2");
0304     plot->GetYaxis()->SetBinLabel(8, "ME- 1/1b");
0305     plot->GetYaxis()->SetBinLabel(9, "ME- 1/1a");
0306     plot->GetYaxis()->SetBinLabel(10, "ME+ 1/1a");
0307     plot->GetYaxis()->SetBinLabel(11, "ME+ 1/1b");
0308     plot->GetYaxis()->SetBinLabel(12, "ME+ 1/2");
0309     plot->GetYaxis()->SetBinLabel(13, "ME+ 1/3");
0310     plot->GetYaxis()->SetBinLabel(14, "ME+ 2/1");
0311     plot->GetYaxis()->SetBinLabel(15, "ME+ 2/2");
0312     plot->GetYaxis()->SetBinLabel(16, "ME+ 3/1");
0313     plot->GetYaxis()->SetBinLabel(17, "ME+ 3/2");
0314     plot->GetYaxis()->SetBinLabel(18, "ME+ 4/1");
0315 
0316     plot->SetTitle(title.c_str());
0317 
0318     for (int i = 1; i < 37; i++) {
0319       ostringstream oss1;
0320       oss1 << i;
0321       string ch = oss1.str();
0322       plot->GetXaxis()->SetBinLabel(i, ch.c_str());
0323     }
0324 
0325     c->SetRightMargin(0.12);
0326     plot->GetYaxis()->SetNdivisions(20, kFALSE);
0327     plot->GetXaxis()->SetNdivisions(36, kFALSE);
0328     plot->GetXaxis()->SetTitle("Chamber #");
0329     c->SetGrid();
0330 
0331     plot->Draw("colz");
0332     c->Update();
0333     c->Print(savename.c_str(), "png");
0334     delete c;
0335   }
0336 }
0337 
0338 void Draw2DEfficiency(std::string histo, TFile *f1, std::string title, std::string savename) {
0339   TCanvas *c = new TCanvas("c", "my canvas", 1);
0340   gStyle->SetPalette(1, 0);
0341   gPad->SetFillColor(4000);
0342   c->SetFillStyle(4000);
0343   gStyle->SetStatColor(0);
0344   gStyle->SetTitleFillColor(0);
0345 
0346   TH2F *num = (TH2F *)f1->Get(histo.c_str());
0347   TH2F *denom = (TH2F *)f1->Get("Efficiency/hEffDenominator");
0348 
0349   TH2F *plot = new TH2F("plot", title.c_str(), 36, 0.5, 36.5, 18, 0.5, 18.5);
0350 
0351   plot->Divide(num, denom, 1., 1., "B");
0352 
0353   plot->SetStats(kFALSE);
0354 
0355   plot->GetYaxis()->SetBinLabel(1, "ME- 4/1");
0356   plot->GetYaxis()->SetBinLabel(2, "ME- 3/2");
0357   plot->GetYaxis()->SetBinLabel(3, "ME- 3/1");
0358   plot->GetYaxis()->SetBinLabel(4, "ME- 2/2");
0359   plot->GetYaxis()->SetBinLabel(5, "ME- 2/1");
0360   plot->GetYaxis()->SetBinLabel(9, "ME- 1/1a");
0361   plot->GetYaxis()->SetBinLabel(6, "ME- 1/3");
0362   plot->GetYaxis()->SetBinLabel(7, "ME- 1/2");
0363   plot->GetYaxis()->SetBinLabel(8, "ME- 1/1b");
0364   plot->GetYaxis()->SetBinLabel(11, "ME+ 1/1b");
0365   plot->GetYaxis()->SetBinLabel(12, "ME+ 1/2");
0366   plot->GetYaxis()->SetBinLabel(13, "ME+ 1/3");
0367   plot->GetYaxis()->SetBinLabel(10, "ME+ 1/1a");
0368   plot->GetYaxis()->SetBinLabel(14, "ME+ 2/1");
0369   plot->GetYaxis()->SetBinLabel(15, "ME+ 2/2");
0370   plot->GetYaxis()->SetBinLabel(16, "ME+ 3/1");
0371   plot->GetYaxis()->SetBinLabel(17, "ME+ 3/2");
0372   plot->GetYaxis()->SetBinLabel(18, "ME+ 4/1");
0373 
0374   for (int i = 1; i < 37; i++) {
0375     ostringstream oss1;
0376     oss1 << i;
0377     string ch = oss1.str();
0378     plot->GetXaxis()->SetBinLabel(i, ch.c_str());
0379   }
0380 
0381   c->SetRightMargin(0.12);
0382 
0383   plot->GetYaxis()->SetNdivisions(20, kFALSE);
0384   plot->GetXaxis()->SetNdivisions(36, kFALSE);
0385 
0386   plot->GetXaxis()->SetTitle("Chamber #");
0387 
0388   c->SetGrid();
0389 
0390   plot->Draw("COLZ");
0391 
0392   c->Update();
0393   c->Print(savename.c_str(), "png");
0394   delete c;
0395   delete plot;
0396 }
0397 
0398 void Draw2DTempPlot(std::string histo, TFile *f1, bool includeME11, std::string savename) {
0399   TCanvas *c = new TCanvas("c", "my canvas", 1);
0400   gStyle->SetPalette(1, 0);
0401   gPad->SetFillColor(4000);
0402   c->SetFillStyle(4000);
0403   gStyle->SetStatColor(0);
0404   gStyle->SetTitleFillColor(0);
0405 
0406   TH2I *plot = (TH2I *)f1->Get(histo.c_str());
0407 
0408   plot->SetStats(kFALSE);
0409 
0410   if (includeME11) {
0411     plot->GetYaxis()->SetBinLabel(1, "ME- 4/2");
0412     plot->GetYaxis()->SetBinLabel(2, "ME- 4/1");
0413     plot->GetYaxis()->SetBinLabel(3, "ME- 3/2");
0414     plot->GetYaxis()->SetBinLabel(4, "ME- 3/1");
0415     plot->GetYaxis()->SetBinLabel(5, "ME- 2/2");
0416     plot->GetYaxis()->SetBinLabel(6, "ME- 2/1");
0417     plot->GetYaxis()->SetBinLabel(10, "ME- 1/1a");
0418     plot->GetYaxis()->SetBinLabel(7, "ME- 1/3");
0419     plot->GetYaxis()->SetBinLabel(8, "ME- 1/2");
0420     plot->GetYaxis()->SetBinLabel(9, "ME- 1/1b");
0421     plot->GetYaxis()->SetBinLabel(12, "ME+ 1/1b");
0422     plot->GetYaxis()->SetBinLabel(13, "ME+ 1/2");
0423     plot->GetYaxis()->SetBinLabel(14, "ME+ 1/3");
0424     plot->GetYaxis()->SetBinLabel(11, "ME+ 1/1a");
0425     plot->GetYaxis()->SetBinLabel(15, "ME+ 2/1");
0426     plot->GetYaxis()->SetBinLabel(16, "ME+ 2/2");
0427     plot->GetYaxis()->SetBinLabel(17, "ME+ 3/1");
0428     plot->GetYaxis()->SetBinLabel(18, "ME+ 3/2");
0429     plot->GetYaxis()->SetBinLabel(19, "ME+ 4/1");
0430     plot->GetYaxis()->SetBinLabel(20, "ME+ 4/2");
0431   } else {
0432     plot->GetYaxis()->SetBinLabel(1, "ME- 4/1");
0433     plot->GetYaxis()->SetBinLabel(2, "ME- 3/2");
0434     plot->GetYaxis()->SetBinLabel(3, "ME- 3/1");
0435     plot->GetYaxis()->SetBinLabel(4, "ME- 2/2");
0436     plot->GetYaxis()->SetBinLabel(5, "ME- 2/1");
0437     plot->GetYaxis()->SetBinLabel(6, "ME- 1/3");
0438     plot->GetYaxis()->SetBinLabel(7, "ME- 1/2");
0439     plot->GetYaxis()->SetBinLabel(8, "ME- 1/1b");
0440     plot->GetYaxis()->SetBinLabel(9, "ME- 1/1a");
0441     plot->GetYaxis()->SetBinLabel(10, "ME+ 1/1a");
0442     plot->GetYaxis()->SetBinLabel(11, "ME+ 1/1b");
0443     plot->GetYaxis()->SetBinLabel(12, "ME+ 1/2");
0444     plot->GetYaxis()->SetBinLabel(13, "ME+ 1/3");
0445     plot->GetYaxis()->SetBinLabel(14, "ME+ 2/1");
0446     plot->GetYaxis()->SetBinLabel(15, "ME+ 2/2");
0447     plot->GetYaxis()->SetBinLabel(16, "ME+ 3/1");
0448     plot->GetYaxis()->SetBinLabel(17, "ME+ 3/2");
0449     plot->GetYaxis()->SetBinLabel(18, "ME+ 4/1");
0450   }
0451 
0452   for (int i = 1; i < 37; i++) {
0453     ostringstream oss1;
0454     oss1 << i;
0455     string ch = oss1.str();
0456     plot->GetXaxis()->SetBinLabel(i, ch.c_str());
0457   }
0458 
0459   c->SetRightMargin(0.12);
0460 
0461   plot->GetYaxis()->SetNdivisions(20, kFALSE);
0462   plot->GetXaxis()->SetNdivisions(36, kFALSE);
0463 
0464   plot->GetXaxis()->SetTitle("Chamber #");
0465 
0466   c->SetGrid();
0467 
0468   plot->Draw("COLZ");
0469 
0470   c->Update();
0471   c->Print(savename.c_str(), "png");
0472   delete c;
0473 }
0474 
0475 void GlobalPosfromTree(
0476     std::string graphname, TFile *f1, int endcap, int station, std::string type, std::string savename) {
0477   TTree *t1;
0478   TBranch *b1;
0479   struct posRecord {
0480     int endcap;
0481     int station;
0482     int ring;
0483     int chamber;
0484     int layer;
0485     float localx;
0486     float localy;
0487     float globalx;
0488     float globaly;
0489   } points;
0490 
0491   if (type == "rechit") {
0492     t1 = (TTree *)f1->Get("recHits/rHPositions");
0493     b1 = t1->GetBranch("rHpos");
0494     b1->SetAddress(&points);
0495   }
0496 
0497   if (type == "segment") {
0498     t1 = (TTree *)f1->Get("Segments/segPositions");
0499     b1 = t1->GetBranch("segpos");
0500     b1->SetAddress(&points);
0501   }
0502 
0503   int n1 = (int)t1->GetEntries();
0504   const int nevents1 = n1;
0505   float globx1[nevents1];
0506   float globy1[nevents1];
0507   int nstation1 = 0;
0508   const int num_of_rings = 4;
0509   const int num_of_chambers = 36;
0510   int nchamber1[num_of_rings][num_of_chambers];
0511   for (int i = 0; i < num_of_rings; i++) {
0512     for (int j = 0; j < num_of_chambers; j++) {
0513       nchamber1[i][j] = 0;
0514     }
0515   }
0516 
0517   for (int i = 0; i < nevents1; i++) {
0518     b1->GetEntry(i);
0519     if (points.station == station && points.endcap == endcap) {
0520       globx1[nstation1] = points.globalx;
0521       globy1[nstation1] = points.globaly;
0522       nstation1++;
0523       nchamber1[points.ring - 1][points.chamber - 1]++;
0524     }
0525   }
0526 
0527   TCanvas *c = new TCanvas("c", "my canvas", 1);
0528   c->SetCanvasSize(700, 700);
0529   TGraph *graph1 = new TGraph(nstation1, globx1, globy1);
0530 
0531   std::string name1 = graphname;
0532 
0533   gStyle->SetPalette(1, 0);
0534   gStyle->SetTitleW(0.9);
0535   gStyle->SetTitleH(0.1);
0536   gStyle->SetStatColor(0);
0537   gStyle->SetTitleFillColor(0);
0538   gPad->SetFillColor(4000);
0539   c->SetFillStyle(4000);
0540   gStyle->SetOptStat(10);
0541 
0542   graph1->GetXaxis()->SetLimits(-720, 720);
0543   graph1->GetYaxis()->SetLimits(-720, 720);
0544   graph1->GetXaxis()->SetRangeUser(-720, 720);
0545   graph1->GetYaxis()->SetRangeUser(-720, 720);
0546 
0547   graph1->SetTitle(name1.c_str());
0548   graph1->UseCurrentStyle();
0549   graph1->Draw("AP");
0550 
0551   //  drawChamberLines(station);
0552   drawColoredChamberLines(station, nchamber1);
0553 
0554   c->Print(savename.c_str(), "png");
0555   delete c;
0556 
0557 }  // end GlobalPosfromTree
0558 
0559 drawChamberLines(int station) {
0560   gStyle->SetLineWidth(2);
0561   float pi = 3.14159;
0562   TVector3 x(0, 0, 1);
0563   int linecolor = 1;
0564   //for alternating colors, set 2 diff colors here
0565   int lc1 = 1;
0566   int lc2 = 1;
0567 
0568   if (station == 1) {
0569     TVector3 p1(101, 9.361, 0);
0570     TVector3 p2(101, -9.361, 0);
0571     TVector3 p3(260, -22.353, 0);
0572     TVector3 p4(260, 22.353, 0);
0573 
0574     TLine *line1;
0575     TLine *line2;
0576     TLine *line3;
0577     TLine *line4;
0578 
0579     for (int i = 0; i < 36; i++) {
0580       if (linecolor == lc1)
0581         linecolor = lc2;
0582       else
0583         linecolor = lc1;
0584 
0585       line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
0586       line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
0587       line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
0588       line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
0589       line1->SetLineColor(linecolor);
0590       line2->SetLineColor(linecolor);
0591       line3->SetLineColor(linecolor);
0592       line4->SetLineColor(linecolor);
0593 
0594       line1->Draw();
0595       line2->Draw();
0596       line3->Draw();
0597       line4->Draw();
0598 
0599       p1.Rotate(pi / 18, x);
0600       p2.Rotate(pi / 18, x);
0601       p3.Rotate(pi / 18, x);
0602       p4.Rotate(pi / 18, x);
0603     }
0604 
0605     TVector3 q1(281.49, 25.5, 0);
0606     TVector3 q2(281.49, -25.5, 0);
0607     TVector3 q3(455.99, -41.87, 0);
0608     TVector3 q4(455.99, 41.87, 0);
0609 
0610     for (int i = 0; i < 36; i++) {
0611       if (linecolor == lc2)
0612         linecolor = lc1;
0613       else
0614         linecolor = lc2;
0615 
0616       line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
0617       line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
0618       line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
0619       line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
0620 
0621       line1->SetLineColor(linecolor);
0622       line2->SetLineColor(linecolor);
0623       line3->SetLineColor(linecolor);
0624       line4->SetLineColor(linecolor);
0625 
0626       line1->Draw();
0627       line2->Draw();
0628       line3->Draw();
0629       line4->Draw();
0630 
0631       q1.Rotate(pi / 18, x);
0632       q2.Rotate(pi / 18, x);
0633       q3.Rotate(pi / 18, x);
0634       q4.Rotate(pi / 18, x);
0635     }
0636 
0637     TVector3 r1(511.99, 31.7, 0);
0638     TVector3 r2(511.99, -31.7, 0);
0639     TVector3 r3(676.15, -46.05, 0);
0640     TVector3 r4(676.15, 46.05.6, 0);
0641 
0642     for (int i = 0; i < 36; i++) {
0643       if (linecolor == lc1)
0644         linecolor = lc2;
0645       else
0646         linecolor = lc1;
0647 
0648       line1 = new TLine(r1(0), r1(1), r2(0), r2(1));
0649       line2 = new TLine(r2(0), r2(1), r3(0), r3(1));
0650       line3 = new TLine(r3(0), r3(1), r4(0), r4(1));
0651       line4 = new TLine(r4(0), r4(1), r1(0), r1(1));
0652       line1->SetLineColor(linecolor);
0653       line2->SetLineColor(linecolor);
0654       line3->SetLineColor(linecolor);
0655       line4->SetLineColor(linecolor);
0656 
0657       line1->Draw();
0658       line2->Draw();
0659       line3->Draw();
0660       line4->Draw();
0661 
0662       r1.Rotate(pi / 18, x);
0663       r2.Rotate(pi / 18, x);
0664       r3.Rotate(pi / 18, x);
0665       r4.Rotate(pi / 18, x);
0666     }
0667   }
0668 
0669   if (station == 2) {
0670     TVector3 p1(146.9, 27.0, 0);
0671     TVector3 p2(146.9, -27.0, 0);
0672     TVector3 p3(336.56, -62.855, 0);
0673     TVector3 p4(336.56, 62.855, 0);
0674 
0675     p1.Rotate(pi / 36, x);
0676     p2.Rotate(pi / 36, x);
0677     p3.Rotate(pi / 36, x);
0678     p4.Rotate(pi / 36, x);
0679 
0680     TLine *line1;
0681     TLine *line2;
0682     TLine *line3;
0683     TLine *line4;
0684 
0685     for (int i = 0; i < 36; i++) {
0686       if (linecolor == lc1)
0687         linecolor = lc2;
0688       else
0689         linecolor = lc1;
0690 
0691       line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
0692       line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
0693       line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
0694       line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
0695       line1->SetLineColor(linecolor);
0696       line2->SetLineColor(linecolor);
0697       line3->SetLineColor(linecolor);
0698       line4->SetLineColor(linecolor);
0699 
0700       line1->Draw();
0701       line2->Draw();
0702       line3->Draw();
0703       line4->Draw();
0704 
0705       p1.Rotate(pi / 9, x);
0706       p2.Rotate(pi / 9, x);
0707       p3.Rotate(pi / 9, x);
0708       p4.Rotate(pi / 9, x);
0709     }
0710 
0711     TVector3 q1(364.02, 33.23, 0);
0712     TVector3 q2(364.02, -33.23, 0);
0713     TVector3 q3(687.08, -63.575, 0);
0714     TVector3 q4(687.08, 63.575, 0);
0715 
0716     for (int i = 0; i < 36; i++) {
0717       if (linecolor == lc2)
0718         linecolor = lc1;
0719       else
0720         linecolor = lc2;
0721 
0722       line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
0723       line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
0724       line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
0725       line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
0726       line1->SetLineColor(linecolor);
0727       line2->SetLineColor(linecolor);
0728       line3->SetLineColor(linecolor);
0729       line4->SetLineColor(linecolor);
0730 
0731       line1->Draw();
0732       line2->Draw();
0733       line3->Draw();
0734       line4->Draw();
0735 
0736       q1.Rotate(pi / 18, x);
0737       q2.Rotate(pi / 18, x);
0738       q3.Rotate(pi / 18, x);
0739       q4.Rotate(pi / 18, x);
0740     }
0741   }
0742 
0743   if (station == 3) {
0744     TVector3 p1(166.89, 30.7, 0);
0745     TVector3 p2(166.89, -30.7, 0);
0746     TVector3 p3(336.59, -62.855, 0);
0747     TVector3 p4(336.59, 62.855, 0);
0748 
0749     p1.Rotate(pi / 36, x);
0750     p2.Rotate(pi / 36, x);
0751     p3.Rotate(pi / 36, x);
0752     p4.Rotate(pi / 36, x);
0753 
0754     TLine *line1;
0755     TLine *line2;
0756     TLine *line3;
0757     TLine *line4;
0758 
0759     for (int i = 0; i < 36; i++) {
0760       if (linecolor == lc1)
0761         linecolor = lc2;
0762       else
0763         linecolor = lc1;
0764 
0765       line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
0766       line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
0767       line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
0768       line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
0769       line1->SetLineColor(linecolor);
0770       line2->SetLineColor(linecolor);
0771       line3->SetLineColor(linecolor);
0772       line4->SetLineColor(linecolor);
0773 
0774       line1->Draw();
0775       line2->Draw();
0776       line3->Draw();
0777       line4->Draw();
0778 
0779       p1.Rotate(pi / 9, x);
0780       p2.Rotate(pi / 9, x);
0781       p3.Rotate(pi / 9, x);
0782       p4.Rotate(pi / 9, x);
0783     }
0784 
0785     TVector3 q1(364.02, 33.23, 0);
0786     TVector3 q2(364.02, -33.23, 0);
0787     TVector3 q3(687.08, -63.575, 0);
0788     TVector3 q4(687.08, 63.575, 0);
0789 
0790     for (int i = 0; i < 36; i++) {
0791       if (linecolor == lc2)
0792         linecolor = lc1;
0793       else
0794         linecolor = lc2;
0795 
0796       line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
0797       line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
0798       line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
0799       line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
0800       line1->SetLineColor(linecolor);
0801       line2->SetLineColor(linecolor);
0802       line3->SetLineColor(linecolor);
0803       line4->SetLineColor(linecolor);
0804 
0805       line1->Draw();
0806       line2->Draw();
0807       line3->Draw();
0808       line4->Draw();
0809 
0810       q1.Rotate(pi / 18, x);
0811       q2.Rotate(pi / 18, x);
0812       q3.Rotate(pi / 18, x);
0813       q4.Rotate(pi / 18, x);
0814     }
0815   }
0816 
0817   if (station == 4) {
0818     TVector3 p1(186.99, 34.505.15, 0);
0819     TVector3 p2(186.99, -34.505, 0);
0820     TVector3 p3(336.41, -62.825, 0);
0821     TVector3 p4(336.41, 62.825, 0);
0822 
0823     p1.Rotate(pi / 36, x);
0824     p2.Rotate(pi / 36, x);
0825     p3.Rotate(pi / 36, x);
0826     p4.Rotate(pi / 36, x);
0827 
0828     TLine *line1;
0829     TLine *line2;
0830     TLine *line3;
0831     TLine *line4;
0832 
0833     for (int i = 0; i < 36; i++) {
0834       if (linecolor == lc1)
0835         linecolor = lc2;
0836       else
0837         linecolor = lc1;
0838 
0839       line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
0840       line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
0841       line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
0842       line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
0843       line1->SetLineColor(linecolor);
0844       line2->SetLineColor(linecolor);
0845       line3->SetLineColor(linecolor);
0846       line4->SetLineColor(linecolor);
0847 
0848       line1->Draw();
0849       line2->Draw();
0850       line3->Draw();
0851       line4->Draw();
0852 
0853       p1.Rotate(pi / 9, x);
0854       p2.Rotate(pi / 9, x);
0855       p3.Rotate(pi / 9, x);
0856       p4.Rotate(pi / 9, x);
0857     }
0858   }
0859 }
0860 
0861 void compare1DPlot(
0862     std::string histoname, TFile *f1, TFile *f2, std::string histotitle, int statoption, std::string savename) {
0863   // used to compare two of the same histogram from different releases/runs/etc
0864 
0865   TH1F *h2 = (TH1F *)f1->Get(histoname.c_str());
0866   TH1F *h1 = (TH1F *)f2->Get(histoname.c_str());
0867 
0868   TCanvas *c = new TCanvas("c", "my canvas", 1);
0869 
0870   if (h1 && h2) {
0871     gStyle->SetHistFillColor(92);
0872     gStyle->SetFrameFillColor(4000);
0873     gStyle->SetTitleW(0.5);
0874     gStyle->SetTitleH(0.07);
0875     gStyle->SetStatColor(0);
0876     gStyle->SetTitleFillColor(0);
0877     gPad->SetFillColor(4000);
0878     c->SetFillStyle(4000);
0879     gStyle->SetOptStat(statoption);
0880     h1->UseCurrentStyle();
0881     h2->UseCurrentStyle();
0882     h2->SetFillColor(52);
0883 
0884     h1->SetTitle(histotitle.c_str());
0885     h1->GetXaxis()->SetLabelSize(0.04);
0886     h1->GetYaxis()->SetLabelSize(0.04);
0887     h1->GetXaxis()->SetTitleOffset(0.7);
0888     h1->GetXaxis()->SetTitleSize(0.06);
0889     h1->GetXaxis()->SetNdivisions(208, kTRUE);
0890 
0891     TLegend *leg = new TLegend(0.79, 0.74, 0.89, 0.84);
0892     leg->AddEntry(h1, "ref", "f");
0893     leg->AddEntry(h2, "new", "l");
0894 
0895     h1->Draw();
0896     h2->Draw("same e");
0897     leg->Draw();
0898   }
0899 
0900   c->Update();
0901   c->Print(savename.c_str(), "png");
0902   delete c;
0903 }
0904 
0905 void compareEffGif(std::string histoname, TFile *f1, TFile *f2, std::string histotitle, std::string savename) {
0906   TH1F *h1 = (TH1F *)f1->Get(histoname.c_str());
0907   TH1F *h2 = (TH1F *)f2->Get(histoname.c_str());
0908 
0909   TCanvas *c = new TCanvas("c", "my canvas", 1);
0910 
0911   TH1F *hn1 = new TH1F("tmp1", histotitle.c_str(), 20, 0.5, 20.5);
0912   TH1F *hn2 = new TH1F("tmp2", histotitle.c_str(), 20, 0.5, 20.5);
0913 
0914   if (h1 && h2) {
0915     float Num = 1;
0916     float Den = 1;
0917     for (int i = 0; i < 20; i++) {
0918       Num = h1->GetBinContent(i + 1);
0919       Den = h1->GetBinContent(i + 21);
0920       //getEfficiency(Num, Den, eff);
0921       float Eff = 0.;
0922       float EffE = 0.;
0923       if (fabs(Den) > 0.000000001) {
0924         Eff = Num / Den;
0925         if (Num < Den) {
0926           EffE = sqrt((1. - Eff) * Eff / Den);
0927         }
0928       }
0929       hn1->SetBinContent(i + 1, Eff);
0930       hn1->SetBinError(i + 1, EffE);
0931     }
0932 
0933     float Num = 1;
0934     float Den = 1;
0935     for (int i = 0; i < 20; i++) {
0936       Num = h2->GetBinContent(i + 1);
0937       Den = h2->GetBinContent(i + 21);
0938       //getEfficiency(Num, Den, eff);
0939       float Eff = 0.;
0940       float EffE = 0.;
0941       if (fabs(Den) > 0.000000001) {
0942         Eff = Num / Den;
0943         if (Num < Den) {
0944           EffE = sqrt((1. - Eff) * Eff / Den);
0945         }
0946       }
0947       hn2->SetBinContent(i + 1, Eff);
0948       hn2->SetBinError(i + 1, EffE);
0949     }
0950 
0951     gStyle->SetOptStat(kFALSE);
0952     gStyle->SetHistFillColor(92);
0953     gStyle->SetFrameFillColor(4000);
0954     gStyle->SetTitleW(0.7);
0955     gStyle->SetTitleH(0.07);
0956     gPad->SetFillColor(4000);
0957     gStyle->SetStatColor(0);
0958     gStyle->SetTitleFillColor(0);
0959     c->SetFillStyle(4000);
0960     hn1->UseCurrentStyle();
0961 
0962     hn1->SetTitle(histotitle.c_str());
0963     hn1->GetXaxis()->SetLabelSize(0.04);
0964     hn1->GetYaxis()->SetLabelSize(0.04);
0965     hn1->GetXaxis()->SetTitleOffset(0.7);
0966     hn1->GetXaxis()->SetTitleSize(0.06);
0967     hn1->GetXaxis()->SetNdivisions(208, kTRUE);
0968     hn1->GetYaxis()->SetRangeUser(0.5, 1.1);
0969     hn1->SetMarkerStyle(6);
0970     hn1->SetMarkerColor(kBlue);
0971     hn2->SetMarkerStyle(6);
0972     hn2->SetMarkerColor(kRed);
0973     hn1->GetXaxis()->SetBinLabel(1, "ME +1/1b");
0974     hn1->GetXaxis()->SetBinLabel(2, "ME +1/2");
0975     hn1->GetXaxis()->SetBinLabel(3, "ME +1/3");
0976     hn1->GetXaxis()->SetBinLabel(4, "ME +1/1a");
0977     hn1->GetXaxis()->SetBinLabel(5, "ME +2/1");
0978     hn1->GetXaxis()->SetBinLabel(6, "ME +2/2");
0979     hn1->GetXaxis()->SetBinLabel(7, "ME +3/1");
0980     hn1->GetXaxis()->SetBinLabel(8, "ME +3/2");
0981     hn1->GetXaxis()->SetBinLabel(9, "ME +4/1");
0982     hn1->GetXaxis()->SetBinLabel(10, "ME +4/2");
0983     hn1->GetXaxis()->SetBinLabel(11, "ME -1/1b");
0984     hn1->GetXaxis()->SetBinLabel(12, "ME -1/2");
0985     hn1->GetXaxis()->SetBinLabel(13, "ME -1/3");
0986     hn1->GetXaxis()->SetBinLabel(14, "ME -1/1a");
0987     hn1->GetXaxis()->SetBinLabel(15, "ME -2/1");
0988     hn1->GetXaxis()->SetBinLabel(16, "ME -2/2");
0989     hn1->GetXaxis()->SetBinLabel(17, "ME -3/1");
0990     hn1->GetXaxis()->SetBinLabel(18, "ME -3/2");
0991     hn1->GetXaxis()->SetBinLabel(19, "ME -4/1");
0992     hn1->GetXaxis()->SetBinLabel(20, "ME -4/2");
0993 
0994     TLegend *leg = new TLegend(0.79, 0.79, 0.89, 0.89);
0995     leg->AddEntry(hn1, "new", "p");
0996     leg->AddEntry(hn2, "ref", "p");
0997 
0998     hn1->Draw();
0999     hn2->Draw("same");
1000     leg->Draw();
1001     c->Update();
1002     c->Print(savename.c_str(), "png");
1003   }
1004   delete c;
1005   delete hn1;
1006   delete hn2;
1007 }
1008 
1009 void GlobalPosfromTreeCompare(
1010     std::string graphname, TFile *f1, TFile *f2, int endcap, int station, std::string type, std::string savename) {
1011   struct posRecord {
1012     int endcap;
1013     int station;
1014     int ring;
1015     int chamber;
1016     int layer;
1017     float localx;
1018     float localy;
1019     float globalx;
1020     float globaly;
1021   } points1, points2;
1022 
1023   TTree *t1;
1024   TTree *t2;
1025   TBranch *b1;
1026   TBranch *b2;
1027 
1028   if (type == "rechit") {
1029     t1 = (TTree *)f1->Get("recHits/rHPositions");
1030     t2 = (TTree *)f2->Get("recHits/rHPositions");
1031     b1 = t1->GetBranch("rHpos");
1032     b2 = t2->GetBranch("rHpos");
1033     b1->SetAddress(&points1);
1034     b2->SetAddress(&points2);
1035   }
1036 
1037   if (type == "segment") {
1038     t1 = (TTree *)f1->Get("Segments/segPositions");
1039     t2 = (TTree *)f2->Get("Segments/segPositions");
1040     b1 = t1->GetBranch("segpos");
1041     b2 = t2->GetBranch("segpos");
1042     b1->SetAddress(&points1);
1043     b2->SetAddress(&points2);
1044   }
1045 
1046   int n1 = (int)t1->GetEntries();
1047   int n2 = (int)t2->GetEntries();
1048 
1049   const int nevents1 = n1;
1050   const int nevents2 = n2;
1051 
1052   float globx1[nevents1];
1053   float globy1[nevents1];
1054   float globx2[nevents2];
1055   float globy2[nevents2];
1056   int nstation1 = 0;
1057   int nstation2 = 0;
1058 
1059   for (int i = 0; i < nevents1; i++) {
1060     b1->GetEntry(i);
1061     if (points1.station == station && points1.endcap == endcap) {
1062       globx1[nstation1] = points1.globalx;
1063       globy1[nstation1] = points1.globaly;
1064       nstation1++;
1065     }
1066   }
1067   for (int i = 0; i < nevents2; i++) {
1068     b2->GetEntry(i);
1069     if (points2.station == station && points2.endcap == endcap) {
1070       globx2[nstation2] = points2.globalx;
1071       globy2[nstation2] = points2.globaly;
1072       nstation2++;
1073     }
1074   }
1075 
1076   std::string name1 = graphname + " (New)";
1077   std::string name2 = graphname + " (Ref)";
1078   TCanvas *c = new TCanvas("c", "my canvas", 1);
1079   c->SetCanvasSize(1300, 700);
1080   c->Divide(2, 1);
1081   TGraph *graph1 = new TGraph(nstation1, globx1, globy1);
1082   TGraph *graph2 = new TGraph(nstation2, globx2, globy2);
1083 
1084   gStyle->SetTitleW(0.6);
1085   gStyle->SetTitleH(0.1);
1086   gStyle->SetStatColor(0);
1087   gStyle->SetTitleFillColor(0);
1088   gStyle->SetOptStat(10);
1089 
1090   c->cd(1);
1091   graph1->SetTitle(name1.c_str());
1092   graph1->UseCurrentStyle();
1093   drawChamberLines(station);
1094   graph1->Draw("AP");
1095   c->cd(2);
1096   graph2->SetTitle(name2.c_str());
1097   graph2->UseCurrentStyle();
1098   drawChamberLines(station);
1099   graph2->Draw("AP");
1100 
1101   //c->Update();
1102   c->Print(savename.c_str(), "png");
1103   delete c;
1104 }
1105 
1106 void NikolaiPlots(TFile *f_in, int flag) {
1107   gROOT->SetStyle("Plain");  // to get rid of gray color of pad and have it white
1108   gStyle->SetPalette(1, 0);  //
1109 
1110   std::ostringstream ss, ss1;
1111 
1112   if (flag == 1) {  // gas gain results
1113     std::string folder = "GasGain/";
1114 
1115     std::string input_histName = "gas_gain_rechit_adc_3_3_sum_location_ME_";
1116     std::string input_title_X = "Location=(layer-1)*nsegm+segm";
1117     std::string input_title_Y = "3X3 ADC Sum";
1118 
1119     std::string slice_title_X = "3X3 ADC Sum Location";
1120 
1121     Int_t ny = 30;
1122     Float_t ylow = 1.0, yhigh = 31.0;
1123     std::string result_histName = "mean_gas_gain_vs_location_csc_ME_";
1124     std::string result_histTitle = "Mean 3X3 ADC Sum";
1125     std::string result_title_Y = "Location=(layer-1)*nsegm+segm";
1126 
1127     std::string result_histNameEntries = "entries_gas_gain_vs_location_csc_ME_";
1128     std::string result_histTitleEntries = "Entries 3X3 ADC Sum";
1129   }
1130 
1131   if (flag == 2) {  // AFEB timing results
1132     std::string folder = "AFEBTiming/";
1133 
1134     std::string input_histName = "afeb_time_bin_vs_afeb_occupancy_ME_";
1135     std::string input_title_X = "AFEB";
1136     std::string input_title_Y = "Time Bin";
1137 
1138     std::string slice_title_X = "AFEB";
1139 
1140     Int_t ny = 42;
1141     Float_t ylow = 1.0, yhigh = 42.0;
1142     std::string result_histName = "mean_afeb_time_bin_vs_afeb_csc_ME_";
1143     std::string result_histTitle = "AFEB Mean Time Bin";
1144     std::string result_title_Y = "AFEB";
1145 
1146     std::string result_histNameEntries = "entries_afeb_time_bin_vs_afeb_csc_ME_";
1147     std::string result_histTitleEntries = "Entries AFEB Time Bin";
1148   }
1149 
1150   if (flag == 3) {  // Comparator timing results
1151     std::string folder = "CompTiming/";
1152 
1153     std::string input_histName = "comp_time_bin_vs_cfeb_occupancy_ME_";
1154     std::string input_title_X = "CFEB";
1155     std::string input_title_Y = "Time Bin";
1156 
1157     std::string slice_title_X = "CFEB";
1158 
1159     Int_t ny = 5;
1160     Float_t ylow = 1.0, yhigh = 6.0;
1161     std::string result_histName = "mean_comp_time_bin_vs_cfeb_csc_ME_";
1162     std::string result_histTitle = "Comparator Mean Time Bin";
1163     std::string result_title_Y = "CFEB";
1164 
1165     std::string result_histNameEntries = "entries_comp_time_bin_vs_cfeb_csc_ME_";
1166     std::string result_histTitleEntries = "Entries Comparator Time Bin";
1167   }
1168 
1169   if (flag == 4) {  // Strip ADC timing results
1170     std::string folder = "ADCTiming/";
1171 
1172     std::string input_histName = "adc_3_3_weight_time_bin_vs_cfeb_occupancy_ME_";
1173     std::string input_title_X = "CFEB";
1174     std::string input_title_Y = "Time Bin";
1175 
1176     std::string slice_title_X = "CFEB";
1177 
1178     Int_t ny = 5;
1179     Float_t ylow = 1.0, yhigh = 6.0;
1180     std::string result_histName = "mean_adc_time_bin_vs_cfeb_csc_ME_";
1181     std::string result_histTitle = "ADC 3X3 Mean Time Bin";
1182     std::string result_title_Y = "CFEB";
1183 
1184     std::string result_histNameEntries = "entries_adc_time_bin_vs_cfeb_csc_ME_";
1185     std::string result_histTitleEntries = "Entries ADC 3X3 Time Bin";
1186   }
1187 
1188   std::vector<std::string> xTitle;
1189   xTitle.push_back("ME+1/1 CSC");
1190   xTitle.push_back("ME+1/2 CSC");
1191   xTitle.push_back("ME+1/3 CSC");
1192   xTitle.push_back("ME+2/1 CSC");
1193   xTitle.push_back("ME+2/2 CSC");
1194   xTitle.push_back("ME+3/1 CSC");
1195   xTitle.push_back("ME+3/2 CSC");
1196   xTitle.push_back("ME+4/1 CSC");
1197   xTitle.push_back("ME+4/2 CSC");
1198   xTitle.push_back("ME-1/1 CSC");
1199   xTitle.push_back("ME-1/2 CSC");
1200   xTitle.push_back("ME-1/3 CSC");
1201   xTitle.push_back("ME-2/1 CSC");
1202   xTitle.push_back("ME-2/2 CSC");
1203   xTitle.push_back("ME-3/1 CSC");
1204   xTitle.push_back("ME-3/2 CSC");
1205   xTitle.push_back("ME-4/1 CSC");
1206   xTitle.push_back("ME-4/2 CSC");
1207 
1208   TH2F *h2[500];
1209   TH2F *h;
1210   Int_t esr[18] = {111, 112, 113, 121, 122, 131, 132, 141, 142, 211, 212, 213, 221, 222, 231, 232, 241, 242};
1211   Int_t entries[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1212   Int_t k = 0;
1213   TCanvas *c1 = new TCanvas("c1", "canvas");
1214   c1->cd();
1215 
1216   //if(flag==2) { // adding special case for AFEB timing
1217   ss.str("");
1218   ss << "mean_afeb_time_bin_vs_csc_ME";
1219   ss1.str("");
1220   ss1 << "Mean AFEB time bin vs CSC and ME";
1221   gStyle->SetOptStat(0);
1222   TH2F *hb = new TH2F(ss.str().c_str(), ss1.str().c_str(), 36, 1.0, 37.0, 18, 1.0, 19.0);
1223   hb->SetStats(kFALSE);
1224   hb->GetXaxis()->SetTitle("CSC #");
1225   hb->GetZaxis()->SetLabelSize(0.03);
1226   hb->SetOption("COLZ");
1227 
1228   hb->GetYaxis()->SetBinLabel(1, "ME- 4/2");
1229   hb->GetYaxis()->SetBinLabel(2, "ME- 4/1");
1230   hb->GetYaxis()->SetBinLabel(3, "ME- 3/2");
1231   hb->GetYaxis()->SetBinLabel(4, "ME- 3/1");
1232   hb->GetYaxis()->SetBinLabel(5, "ME- 2/2");
1233   hb->GetYaxis()->SetBinLabel(6, "ME- 2/1");
1234   hb->GetYaxis()->SetBinLabel(7, "ME- 1/3");
1235   hb->GetYaxis()->SetBinLabel(8, "ME- 1/2");
1236   hb->GetYaxis()->SetBinLabel(9, "ME- 1/1");
1237   hb->GetYaxis()->SetBinLabel(10, "ME+ 1/1");
1238   hb->GetYaxis()->SetBinLabel(11, "ME+ 1/2");
1239   hb->GetYaxis()->SetBinLabel(12, "ME+ 1/3");
1240   hb->GetYaxis()->SetBinLabel(13, "ME+ 2/1");
1241   hb->GetYaxis()->SetBinLabel(14, "ME+ 2/2");
1242   hb->GetYaxis()->SetBinLabel(15, "ME+ 3/1");
1243   hb->GetYaxis()->SetBinLabel(16, "ME+ 3/2");
1244   hb->GetYaxis()->SetBinLabel(17, "ME+ 4/1");
1245   hb->GetYaxis()->SetBinLabel(18, "ME+ 4/2");
1246   //}
1247 
1248   for (Int_t jesr = 0; jesr < 18; jesr++) {
1249     ss.str("");
1250     ss << result_histName.c_str() << esr[jesr];
1251     ss1.str("");
1252     ss1 << result_histTitle;
1253     TH2F *h = new TH2F(ss.str().c_str(), ss1.str().c_str(), 40, 0.0, 40.0, ny, ylow, yhigh);
1254     h->SetStats(kFALSE);
1255     h->GetXaxis()->SetTitle(xTitle[jesr].c_str());
1256     h->GetYaxis()->SetTitle(result_title_Y.c_str());
1257     h->GetZaxis()->SetLabelSize(0.03);
1258     h->SetOption("COLZ");
1259 
1260     ss.str("");
1261     ss << result_histNameEntries.c_str() << esr[jesr];
1262     ss1.str("");
1263     ss1 << result_histTitleEntries;
1264     TH2F *hentr = new TH2F(ss.str().c_str(), ss1.str().c_str(), 40, 0.0, 40.0, ny, ylow, yhigh);
1265     hentr->SetStats(kFALSE);
1266     hentr->GetXaxis()->SetTitle(xTitle[jesr].c_str());
1267     hentr->GetYaxis()->SetTitle(result_title_Y.c_str());
1268     hentr->GetZaxis()->SetLabelSize(0.03);
1269     hentr->SetOption("COLZ");
1270 
1271     if (flag == 2) {  // adding special cases for AFEB timing
1272       ss.str("");
1273       ss << "normal_afeb_time_bin_vs_csc_ME_" << esr[jesr];
1274       ss1.str("");
1275       ss1 << "Normalized AFEB time bin, %";
1276       TH2F *ha = new TH2F(ss.str().c_str(), ss1.str().c_str(), 40, 0.0, 40.0, 16, 0.0, 16.0);
1277       ha->SetStats(kFALSE);
1278       ha->GetXaxis()->SetTitle(xTitle[jesr].c_str());
1279       ha->GetYaxis()->SetTitle("Time Bin");
1280       ha->GetZaxis()->SetLabelSize(0.03);
1281       ha->SetOption("COLZ");
1282     }
1283 
1284     for (Int_t csc = 1; csc < 37; csc++) {
1285       Int_t idchamber = esr[jesr] * 100 + csc;
1286       ss.str("");
1287       ss << folder.c_str() << input_histName.c_str() << idchamber;
1288       f_in->cd();
1289       TH2F *h2[1];
1290       h2[k] = (TH2F *)f_in->Get(ss.str().c_str());
1291       if (h2[k] != NULL) {
1292         // saving original, adding X,Y titles, color and "BOX" option
1293         h2[k]->GetXaxis()->SetTitle(input_title_X.c_str());
1294         h2[k]->GetYaxis()->SetTitle(input_title_Y.c_str());
1295         h2[k]->GetYaxis()->SetTitleOffset(1.2);
1296         h2[k]->SetFillColor(4);
1297         h2[k]->SetOption("BOX");
1298         gStyle->SetOptStat(1001111);
1299 
1300         // saving Y projection of the whole 2D hist for given chamber
1301         ss.str("");
1302         ss << input_histName.c_str() << idchamber << "_Y_all";
1303         TH1D *h1d = h2[k]->ProjectionY(ss.str().c_str(), 1, h2[k]->GetNbinsX(), "");
1304         h1d->GetYaxis()->SetTitle("Entries");
1305         h1d->GetYaxis()->SetTitleOffset(1.2);
1306         gStyle->SetOptStat(1001111);
1307 
1308         if (flag == 2 && h1d->GetEntries() > 0) {  // adding spec. case for afeb timing
1309           Float_t entr = h1d->GetEntries();
1310           for (Int_t m = 1; m < h1d->GetNbinsX(); m++) {
1311             Float_t w = h1d->GetBinContent(m);
1312             w = 100.0 * w / entr;
1313             ha->SetBinContent(csc + 1, m, w);
1314           }
1315           Float_t mean = h1d->GetMean();
1316           Int_t me;
1317           if (jesr < 9)
1318             me = 10 + jesr;
1319           if (jesr > 8)
1320             me = 18 - jesr;
1321           hb->SetBinContent(csc, me, mean);
1322         }
1323         delete h1d;
1324 
1325         // saving slices, finding MEAN in each slice, fill 2D hist
1326         for (Int_t j = 1; j <= h2[k]->GetNbinsX(); j++) {
1327           Int_t n = j;
1328           ss.str("");
1329           ss << input_histName.c_str() << idchamber << "_Y_" << n;
1330           TH1D *h1d = h2[k]->ProjectionY(ss.str().c_str(), j, j, "");
1331           if (h1d->GetEntries() > 0) {
1332             Float_t mean = h1d->GetMean();
1333             Float_t entr = h1d->GetEntries();
1334             entries[jesr] = entries[jesr] + 1;
1335             h->SetBinContent(csc + 1, j, mean);
1336             hentr->SetBinContent(csc + 1, j, entr);
1337             ss.str("");
1338             ss << slice_title_X << " " << n;
1339             h1d->GetXaxis()->SetTitle(ss.str().c_str());
1340             h1d->GetYaxis()->SetTitle("Entries");
1341             h1d->GetYaxis()->SetTitleOffset(1.2);
1342             gStyle->SetOptStat(1001111);
1343           }
1344           delete h1d;
1345         }
1346       }
1347     }
1348     if (entries[jesr] > 0) {
1349       h->SetStats(kFALSE);
1350       hentr->SetStats(kFALSE);
1351       c1->Update();
1352 
1353       // printing
1354 
1355       h->Draw();
1356       ss.str("");
1357       ss << result_histName.c_str() << esr[jesr] << ".png";
1358       c1->Print(ss.str().c_str(), "png");
1359 
1360       hentr->Draw();
1361       ss.str("");
1362       ss << result_histNameEntries.c_str() << esr[jesr] << ".png";
1363       c1->Print(ss.str().c_str(), "png");
1364     }
1365     delete h;
1366     delete hentr;
1367     if (flag == 2)
1368       delete ha;
1369   }
1370   if (flag == 2) {
1371     hb->Draw();
1372     ss.str("");
1373     ss << "mean_afeb_time_bin_vs_csc_ME"
1374        << ".png";
1375     c1->Print(ss.str().c_str(), "png");
1376 
1377     c1->Update();
1378     //delete hb;
1379   }
1380   delete hb;
1381   delete c1;
1382 }
1383 
1384 drawColoredChamberLines(int station, int nchamber1[4][36]) {
1385   // thanks to Luca Sabbatini for this coe
1386   const int maxRingIdxOfRelevance = 2;
1387   const int maxChamberIdxOfRelevance = 35;
1388   const int totalNumberOfChambersOfRelevance = 540;
1389 
1390   Int_t thisRingIdx = 0;
1391   Int_t numChambersInRing = 0;
1392 
1393   float nchamber1Avg = 0.;
1394   float thisRingNchamber1Avg = 0;
1395   float thisRingNchamber1Max = 0;
1396   // Note that thisRingNchamber1Min is only the minumum *non-zero*
1397   // occupancy among all the cmabers for the given ring
1398   float thisRingNchamber1Min = 0;
1399   Int_t thisRingNchamber1Base = 0;
1400 
1401   // rFloatRGB, gFloatRGB, bFloatRGB, are from the RGB color space;
1402   // all three range between [0,1]
1403   // hFloatHLS, lFloatHLS, sFloatHLS, are from the HLS color space;
1404   // lFloatHLS and sFloatHLS range between [0,1], while hFloatHLS
1405   // ranges between [0,360]
1406   Float_t rFloatRGB = 0.;
1407   Float_t gFloatRGB = 0.;
1408   Float_t bFloatRGB = 0.;
1409   Float_t hFloatHLS = 0.;
1410   Float_t lFloatHLS = 0.5;
1411   Float_t sFloatHLS = 1.0;
1412   TColor tempColor;
1413 
1414   // compute average chamber occupancy over all CSCs
1415   for (int i = 0; i < maxRingIdxOfRelevance + 1; i++) {
1416     for (int j = 0; j < maxChamberIdxOfRelevance + 1; j++) {
1417       nchamber1Avg += nchamber1[i][j];
1418     }
1419   }
1420   nchamber1Avg = nchamber1Avg / totalNumberOfChambersOfRelevance;
1421 
1422   Float_t myFavoriteLineWidth = 2.0;
1423   gStyle->SetLineWidth(myFavoriteLineWidth);
1424   float pi = 3.14159;
1425   TVector3 x(0, 0, 1);
1426   int linecolor = 1;
1427 
1428   // emptyLineColor is the color of the outline of empty chambers.
1429   // if emptyLineColor is negative, no outline is drawn at all for
1430   // that chamber.
1431   Int_t emptyLineColor = kYellow;
1432 
1433   // note that these can be greater than 360 because I have included
1434   // a line down below that performs a modulus operation: %360, which
1435   // ensures that the resulting hue will indeed be with [0,360]
1436   //
1437   // Hue:    0   30      60      120     180     240 270 300     360
1438   //         |   |       |       |       |       |   |   |       |
1439   // Color: Red Orange Yellow   Green   Cyan  Blue Vilet Magenta Red
1440   Float_t lineHueMin = 240;
1441   Float_t lineHueMax = 360;
1442 
1443   TLine *line1;
1444   TLine *line2;
1445   TLine *line3;
1446   TLine *line4;
1447 
1448   if (station == 1) {
1449     // station 1, ring 1 (inner-most ring)
1450     thisRingIdx = 0;
1451     numChambersInRing = 36;
1452     TVector3 p1(101, 9.361, 0);
1453     TVector3 p2(101, -9.361, 0);
1454     TVector3 p3(260, -22.353, 0);
1455     TVector3 p4(260, 22.353, 0);
1456 
1457     // compute thisRingNchamber1Min, thisRingNchamber1Max,
1458     //  thisRingNchamber1Avg and thisRingNchamber1Base
1459     thisRingNchamber1Avg = 0.;
1460     thisRingNchamber1Max = 0.;
1461     for (int j = 0; j < numChambersInRing; j++) {
1462       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1463       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1464         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1465       }
1466     }
1467     thisRingNchamber1Min = thisRingNchamber1Max;
1468     for (int j = 0; j < numChambersInRing; j++) {
1469       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1470           nchamber1[thisRingIdx][j] != 0) {
1471         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1472       }
1473     }
1474     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1475     thisRingNchamber1Base = thisRingNchamber1Min;
1476 
1477     for (int i = 0; i < numChambersInRing; i++) {
1478       // set the line color
1479       if (nchamber1[thisRingIdx][i] != 0) {
1480         hFloatHLS = int((nchamber1[0][i] - thisRingNchamber1Base) / (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1481                             (lineHueMax - lineHueMin) +
1482                         lineHueMin) %
1483                     360;
1484         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1485         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1486       } else if (emptyLineColor >= 0) {
1487         linecolor = emptyLineColor;
1488       }
1489 
1490       // draw the chamber outline using the line color (so long
1491       // as the the chamber isn't empty *and* the user did not
1492       // set a negative line color for empty chambers)
1493       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1494           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1495         line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
1496         line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
1497         line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
1498         line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
1499         line1->SetLineColor(linecolor);
1500         line2->SetLineColor(linecolor);
1501         line3->SetLineColor(linecolor);
1502         line4->SetLineColor(linecolor);
1503 
1504         line1->Draw();
1505         line2->Draw();
1506         line3->Draw();
1507         line4->Draw();
1508       }
1509 
1510       // Rotate coordinate by 1 chamber
1511       p1.Rotate(2 * pi / numChambersInRing, x);
1512       p2.Rotate(2 * pi / numChambersInRing, x);
1513       p3.Rotate(2 * pi / numChambersInRing, x);
1514       p4.Rotate(2 * pi / numChambersInRing, x);
1515     }
1516 
1517     // station 1, ring 2 (middle-ring)
1518     thisRingIdx = 1;
1519     numChambersInRing = 36;
1520     TVector3 q1(281.49, 25.5, 0);
1521     TVector3 q2(281.49, -25.5, 0);
1522     TVector3 q3(455.99, -41.87, 0);
1523     TVector3 q4(455.99, 41.87, 0);
1524 
1525     thisRingNchamber1Avg = 0.;
1526     thisRingNchamber1Max = 0.;
1527     for (int j = 0; j < numChambersInRing; j++) {
1528       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1529       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1530         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1531       }
1532     }
1533     thisRingNchamber1Min = thisRingNchamber1Max;
1534     for (int j = 0; j < numChambersInRing; j++) {
1535       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1536           nchamber1[thisRingIdx][j] != 0) {
1537         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1538       }
1539     }
1540     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1541     thisRingNchamber1Base = thisRingNchamber1Min;
1542 
1543     for (int i = 0; i < numChambersInRing; i++) {
1544       if (nchamber1[thisRingIdx][i] != 0) {
1545         hFloatHLS = int((nchamber1[thisRingIdx][i] - thisRingNchamber1Base) /
1546                             (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1547                             (lineHueMax - lineHueMin) +
1548                         lineHueMin) %
1549                     360;
1550         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1551         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1552       } else if (emptyLineColor >= 0) {
1553         linecolor = emptyLineColor;
1554       }
1555 
1556       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1557           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1558         line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
1559         line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
1560         line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
1561         line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
1562         line1->SetLineColor(linecolor);
1563         line2->SetLineColor(linecolor);
1564         line3->SetLineColor(linecolor);
1565         line4->SetLineColor(linecolor);
1566 
1567         line1->Draw();
1568         line2->Draw();
1569         line3->Draw();
1570         line4->Draw();
1571       }
1572       q1.Rotate(2 * pi / numChambersInRing, x);
1573       q2.Rotate(2 * pi / numChambersInRing, x);
1574       q3.Rotate(2 * pi / numChambersInRing, x);
1575       q4.Rotate(2 * pi / numChambersInRing, x);
1576     }
1577 
1578     // station 1, ring 3 (outer-most ring)
1579     thisRingIdx = 2;
1580     numChambersInRing = 36;
1581     TVector3 r1(511.99, 31.7, 0);
1582     TVector3 r2(511.99, -31.7, 0);
1583     TVector3 r3(676.15, -46.05, 0);
1584     TVector3 r4(676.15, 46.05.6, 0);
1585 
1586     thisRingNchamber1Avg = 0.;
1587     thisRingNchamber1Max = 0.;
1588     for (int j = 0; j < numChambersInRing; j++) {
1589       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1590       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1591         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1592       }
1593     }
1594     thisRingNchamber1Min = thisRingNchamber1Max;
1595     for (int j = 0; j < numChambersInRing; j++) {
1596       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1597           nchamber1[thisRingIdx][j] != 0) {
1598         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1599       }
1600     }
1601     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1602     thisRingNchamber1Base = thisRingNchamber1Min;
1603 
1604     for (int i = 0; i < numChambersInRing; i++) {
1605       if (nchamber1[thisRingIdx][i] != 0) {
1606         hFloatHLS = int((nchamber1[thisRingIdx][i] - thisRingNchamber1Base) /
1607                             (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1608                             (lineHueMax - lineHueMin) +
1609                         lineHueMin) %
1610                     360;
1611         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1612         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1613       } else if (emptyLineColor >= 0) {
1614         linecolor = emptyLineColor;
1615       }
1616 
1617       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1618           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1619         line1 = new TLine(r1(0), r1(1), r2(0), r2(1));
1620         line2 = new TLine(r2(0), r2(1), r3(0), r3(1));
1621         line3 = new TLine(r3(0), r3(1), r4(0), r4(1));
1622         line4 = new TLine(r4(0), r4(1), r1(0), r1(1));
1623         line1->SetLineColor(linecolor);
1624         line2->SetLineColor(linecolor);
1625         line3->SetLineColor(linecolor);
1626         line4->SetLineColor(linecolor);
1627 
1628         line1->Draw();
1629         line2->Draw();
1630         line3->Draw();
1631         line4->Draw();
1632       }
1633       r1.Rotate(2 * pi / numChambersInRing, x);
1634       r2.Rotate(2 * pi / numChambersInRing, x);
1635       r3.Rotate(2 * pi / numChambersInRing, x);
1636       r4.Rotate(2 * pi / numChambersInRing, x);
1637     }
1638   }
1639 
1640   if (station == 2) {
1641     // station 2, ring 1 (inner ring)
1642     thisRingIdx = 0;
1643     numChambersInRing = 18;
1644     TVector3 p1(146.9, 27.0, 0);
1645     TVector3 p2(146.9, -27.0, 0);
1646     TVector3 p3(336.56, -62.855, 0);
1647     TVector3 p4(336.56, 62.855, 0);
1648 
1649     // must "pre-rotate" by one-fourth of a chamber
1650     p1.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1651     p2.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1652     p3.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1653     p4.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1654 
1655     thisRingNchamber1Avg = 0.;
1656     thisRingNchamber1Max = 0.;
1657     for (int j = 0; j < numChambersInRing; j++) {
1658       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1659       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1660         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1661       }
1662     }
1663     thisRingNchamber1Min = thisRingNchamber1Max;
1664     for (int j = 0; j < numChambersInRing; j++) {
1665       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1666           nchamber1[thisRingIdx][j] != 0) {
1667         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1668       }
1669     }
1670     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1671     thisRingNchamber1Base = thisRingNchamber1Min;
1672 
1673     for (int i = 0; i < numChambersInRing; i++) {
1674       if (nchamber1[thisRingIdx][i] != 0) {
1675         hFloatHLS = int((nchamber1[0][i] - thisRingNchamber1Base) / (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1676                             (lineHueMax - lineHueMin) +
1677                         lineHueMin) %
1678                     360;
1679         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1680         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1681       } else if (emptyLineColor >= 0) {
1682         linecolor = emptyLineColor;
1683       }
1684 
1685       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1686           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1687         line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
1688         line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
1689         line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
1690         line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
1691         line1->SetLineColor(linecolor);
1692         line2->SetLineColor(linecolor);
1693         line3->SetLineColor(linecolor);
1694         line4->SetLineColor(linecolor);
1695 
1696         line1->Draw();
1697         line2->Draw();
1698         line3->Draw();
1699         line4->Draw();
1700       }
1701       p1.Rotate(2 * pi / numChambersInRing, x);
1702       p2.Rotate(2 * pi / numChambersInRing, x);
1703       p3.Rotate(2 * pi / numChambersInRing, x);
1704       p4.Rotate(2 * pi / numChambersInRing, x);
1705     }
1706 
1707     // station 2, ring 2 (outer ring)
1708     thisRingIdx = 1;
1709     numChambersInRing = 36;
1710     TVector3 q1(364.02, 33.23, 0);
1711     TVector3 q2(364.02, -33.23, 0);
1712     TVector3 q3(687.08, -63.575, 0);
1713     TVector3 q4(687.08, 63.575, 0);
1714 
1715     thisRingNchamber1Avg = 0.;
1716     thisRingNchamber1Max = 0.;
1717     for (int j = 0; j < numChambersInRing; j++) {
1718       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1719       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1720         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1721       }
1722     }
1723     thisRingNchamber1Min = thisRingNchamber1Max;
1724     for (int j = 0; j < numChambersInRing; j++) {
1725       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1726           nchamber1[thisRingIdx][j] != 0) {
1727         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1728       }
1729     }
1730     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1731     thisRingNchamber1Base = thisRingNchamber1Min;
1732 
1733     for (int i = 0; i < numChambersInRing; i++) {
1734       if (nchamber1[thisRingIdx][i] != 0) {
1735         hFloatHLS = int((nchamber1[thisRingIdx][i] - thisRingNchamber1Base) /
1736                             (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1737                             (lineHueMax - lineHueMin) +
1738                         lineHueMin) %
1739                     360;
1740         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1741         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1742       } else if (emptyLineColor >= 0) {
1743         linecolor = emptyLineColor;
1744       }
1745 
1746       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1747           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1748         line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
1749         line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
1750         line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
1751         line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
1752         line1->SetLineColor(linecolor);
1753         line2->SetLineColor(linecolor);
1754         line3->SetLineColor(linecolor);
1755         line4->SetLineColor(linecolor);
1756 
1757         line1->Draw();
1758         line2->Draw();
1759         line3->Draw();
1760         line4->Draw();
1761       }
1762       q1.Rotate(2 * pi / numChambersInRing, x);
1763       q2.Rotate(2 * pi / numChambersInRing, x);
1764       q3.Rotate(2 * pi / numChambersInRing, x);
1765       q4.Rotate(2 * pi / numChambersInRing, x);
1766     }
1767   }
1768 
1769   if (station == 3) {
1770     // station 3, ring 1 (inner ring)
1771     thisRingIdx = 0;
1772     numChambersInRing = 18;
1773     TVector3 p1(166.89, 30.7, 0);
1774     TVector3 p2(166.89, -30.7, 0);
1775     TVector3 p3(336.59, -62.855, 0);
1776     TVector3 p4(336.59, 62.855, 0);
1777 
1778     // must "pre-rotate" by one-fourth of a chamber
1779     p1.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1780     p2.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1781     p3.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1782     p4.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1783 
1784     TLine *line1;
1785     TLine *line2;
1786     TLine *line3;
1787     TLine *line4;
1788 
1789     thisRingNchamber1Avg = 0.;
1790     thisRingNchamber1Max = 0.;
1791     for (int j = 0; j < numChambersInRing; j++) {
1792       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1793       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1794         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1795       }
1796     }
1797     thisRingNchamber1Min = thisRingNchamber1Max;
1798     for (int j = 0; j < numChambersInRing; j++) {
1799       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1800           nchamber1[thisRingIdx][j] != 0) {
1801         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1802       }
1803     }
1804     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1805     thisRingNchamber1Base = thisRingNchamber1Min;
1806 
1807     for (int i = 0; i < numChambersInRing; i++) {
1808       if (nchamber1[thisRingIdx][i] != 0) {
1809         hFloatHLS = int((nchamber1[0][i] - thisRingNchamber1Base) / (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1810                             (lineHueMax - lineHueMin) +
1811                         lineHueMin) %
1812                     360;
1813         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1814         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1815       } else if (emptyLineColor >= 0) {
1816         linecolor = emptyLineColor;
1817       }
1818 
1819       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1820           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1821         line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
1822         line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
1823         line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
1824         line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
1825         line1->SetLineColor(linecolor);
1826         line2->SetLineColor(linecolor);
1827         line3->SetLineColor(linecolor);
1828         line4->SetLineColor(linecolor);
1829 
1830         line1->Draw();
1831         line2->Draw();
1832         line3->Draw();
1833         line4->Draw();
1834       }
1835       p1.Rotate(2 * pi / numChambersInRing, x);
1836       p2.Rotate(2 * pi / numChambersInRing, x);
1837       p3.Rotate(2 * pi / numChambersInRing, x);
1838       p4.Rotate(2 * pi / numChambersInRing, x);
1839     }
1840 
1841     // station 3, ring 2 (outer ring)
1842     thisRingIdx = 1;
1843     numChambersInRing = 36;
1844     TVector3 q1(364.02, 33.23, 0);
1845     TVector3 q2(364.02, -33.23, 0);
1846     TVector3 q3(687.08, -63.575, 0);
1847     TVector3 q4(687.08, 63.575, 0);
1848 
1849     thisRingNchamber1Avg = 0.;
1850     thisRingNchamber1Max = 0.;
1851     for (int j = 0; j < numChambersInRing; j++) {
1852       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1853       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1854         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1855       }
1856     }
1857     thisRingNchamber1Min = thisRingNchamber1Max;
1858     for (int j = 0; j < numChambersInRing; j++) {
1859       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1860           nchamber1[thisRingIdx][j] != 0) {
1861         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1862       }
1863     }
1864     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1865     thisRingNchamber1Base = thisRingNchamber1Min;
1866 
1867     for (int i = 0; i < numChambersInRing; i++) {
1868       if (nchamber1[thisRingIdx][i] != 0) {
1869         hFloatHLS = int((nchamber1[thisRingIdx][i] - thisRingNchamber1Base) /
1870                             (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1871                             (lineHueMax - lineHueMin) +
1872                         lineHueMin) %
1873                     360;
1874         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1875         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1876       } else if (emptyLineColor >= 0) {
1877         linecolor = emptyLineColor;
1878       }
1879 
1880       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1881           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1882         line1 = new TLine(q1(0), q1(1), q2(0), q2(1));
1883         line2 = new TLine(q2(0), q2(1), q3(0), q3(1));
1884         line3 = new TLine(q3(0), q3(1), q4(0), q4(1));
1885         line4 = new TLine(q4(0), q4(1), q1(0), q1(1));
1886         line1->SetLineColor(linecolor);
1887         line2->SetLineColor(linecolor);
1888         line3->SetLineColor(linecolor);
1889         line4->SetLineColor(linecolor);
1890 
1891         line1->Draw();
1892         line2->Draw();
1893         line3->Draw();
1894         line4->Draw();
1895       }
1896       q1.Rotate(2 * pi / numChambersInRing, x);
1897       q2.Rotate(2 * pi / numChambersInRing, x);
1898       q3.Rotate(2 * pi / numChambersInRing, x);
1899       q4.Rotate(2 * pi / numChambersInRing, x);
1900     }
1901   }
1902 
1903   if (station == 4) {
1904     // station 4, ring 1 (the only ring on station 4... so far)
1905     thisRingIdx = 0;
1906     numChambersInRing = 18;
1907     TVector3 p1(186.99, 34.505.15, 0);
1908     TVector3 p2(186.99, -34.505, 0);
1909     TVector3 p3(336.41, -62.825, 0);
1910     TVector3 p4(336.41, 62.825, 0);
1911 
1912     // must "pre-rotate" by one-fourth of a chamber
1913     p1.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1914     p2.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1915     p3.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1916     p4.Rotate((1 / 4.) * 2 * pi / numChambersInRing, x);
1917 
1918     TLine *line1;
1919     TLine *line2;
1920     TLine *line3;
1921     TLine *line4;
1922 
1923     thisRingNchamber1Avg = 0.;
1924     thisRingNchamber1Max = 0.;
1925     for (int j = 0; j < numChambersInRing; j++) {
1926       thisRingNchamber1Avg += nchamber1[thisRingIdx][j];
1927       if (thisRingNchamber1Max < nchamber1[thisRingIdx][j]) {
1928         thisRingNchamber1Max = nchamber1[thisRingIdx][j];
1929       }
1930     }
1931     thisRingNchamber1Min = thisRingNchamber1Max;
1932     for (int j = 0; j < numChambersInRing; j++) {
1933       if (thisRingNchamber1Min > nchamber1[thisRingIdx][j] &&  //
1934           nchamber1[thisRingIdx][j] != 0) {
1935         thisRingNchamber1Min = nchamber1[thisRingIdx][j];
1936       }
1937     }
1938     thisRingNchamber1Avg = thisRingNchamber1Avg / numChambersInRing;
1939     thisRingNchamber1Base = thisRingNchamber1Min;
1940 
1941     for (int i = 0; i < numChambersInRing; i++) {
1942       if (nchamber1[thisRingIdx][i] != 0) {
1943         hFloatHLS = int((nchamber1[0][i] - thisRingNchamber1Base) / (thisRingNchamber1Max - thisRingNchamber1Base) *  //
1944                             (lineHueMax - lineHueMin) +
1945                         lineHueMin) %
1946                     360;
1947         tempColor.HLS2RGB(hFloatHLS, lFloatHLS, sFloatHLS, rFloatRGB, gFloatRGB, bFloatRGB);
1948         linecolor = tempColor.GetColor(rFloatRGB, gFloatRGB, bFloatRGB);
1949       } else if (emptyLineColor >= 0) {
1950         linecolor = emptyLineColor;
1951       }
1952 
1953       if ((nchamber1[thisRingIdx][i] != 0) ||  //
1954           (nchamber1[thisRingIdx][i] == 0 && emptyLineColor >= 0)) {
1955         line1 = new TLine(p1(0), p1(1), p2(0), p2(1));
1956         line2 = new TLine(p2(0), p2(1), p3(0), p3(1));
1957         line3 = new TLine(p3(0), p3(1), p4(0), p4(1));
1958         line4 = new TLine(p4(0), p4(1), p1(0), p1(1));
1959         line1->SetLineColor(linecolor);
1960         line2->SetLineColor(linecolor);
1961         line3->SetLineColor(linecolor);
1962         line4->SetLineColor(linecolor);
1963 
1964         line1->Draw();
1965         line2->Draw();
1966         line3->Draw();
1967         line4->Draw();
1968       }
1969       p1.Rotate(2 * pi / numChambersInRing, x);
1970       p2.Rotate(2 * pi / numChambersInRing, x);
1971       p3.Rotate(2 * pi / numChambersInRing, x);
1972       p4.Rotate(2 * pi / numChambersInRing, x);
1973     }
1974   }
1975 }