1 | //calorimeter grid
|
---|
2 | #include <algorithm>
|
---|
3 | #include <cassert>
|
---|
4 | #include <iostream>
|
---|
5 | #include <map>
|
---|
6 | #include <set>
|
---|
7 | #include <sstream>
|
---|
8 | #include <utility>
|
---|
9 | #include <vector>
|
---|
10 |
|
---|
11 | #include "ExRootAnalysis/ExRootConfReader.h"
|
---|
12 | #include "classes/DelphesClasses.h"
|
---|
13 | #include "display/Delphes3DGeometry.h"
|
---|
14 |
|
---|
15 | #include "TCanvas.h"
|
---|
16 | #include "TH2F.h"
|
---|
17 | #include "TLine.h"
|
---|
18 | #include "TString.h"
|
---|
19 | #include "TStyle.h"
|
---|
20 | #include "TText.h"
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 | Bool_t debug = false;
|
---|
25 | //Bool_t debug = true;
|
---|
26 |
|
---|
27 | int main(int argc, char *argv[])
|
---|
28 | {
|
---|
29 |
|
---|
30 | if(argc != 3)
|
---|
31 | {
|
---|
32 | cout << " Usage: ./CaloGrid [detector card] [calo name]" << endl;
|
---|
33 | cout << "Example: ./CaloGrid cards/delphes_card_CMS.tcl ECal" << endl;
|
---|
34 | return 0;
|
---|
35 | }
|
---|
36 |
|
---|
37 | TString card(argv[1]);
|
---|
38 |
|
---|
39 | ExRootConfReader *confReader = new ExRootConfReader;
|
---|
40 | confReader->ReadFile(card);
|
---|
41 |
|
---|
42 | std::vector<std::string> calorimeters_;
|
---|
43 | std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_;
|
---|
44 |
|
---|
45 | std::string s(argv[2]);
|
---|
46 | std::replace(s.begin(), s.end(), ',', ' ');
|
---|
47 | std::istringstream stream(s);
|
---|
48 | std::string word;
|
---|
49 | while(stream >> word) calorimeters_.push_back(word);
|
---|
50 |
|
---|
51 | caloBinning_.clear(); // calo binning
|
---|
52 |
|
---|
53 | TCanvas c("", "", 1600, 838);
|
---|
54 |
|
---|
55 | gPad->SetLeftMargin(0.16);
|
---|
56 | gPad->SetTopMargin(0.16);
|
---|
57 | gPad->SetBottomMargin(0.20);
|
---|
58 | gStyle->SetOptStat(0000000);
|
---|
59 |
|
---|
60 | gStyle->SetTextFont(132);
|
---|
61 |
|
---|
62 | TH2F h2("h2", "", 1, -6, 6, 1, 0, 6.28);
|
---|
63 |
|
---|
64 | h2.GetXaxis()->SetTitle("#eta");
|
---|
65 | h2.GetYaxis()->SetTitle("#phi");
|
---|
66 |
|
---|
67 | h2.GetXaxis()->SetTitleFont(132);
|
---|
68 | h2.GetYaxis()->SetTitleFont(132);
|
---|
69 | h2.GetZaxis()->SetTitleFont(132);
|
---|
70 | h2.GetXaxis()->SetLabelFont(132);
|
---|
71 | h2.GetYaxis()->SetLabelFont(132);
|
---|
72 |
|
---|
73 | h2.GetXaxis()->SetTitleOffset(1.4);
|
---|
74 | h2.GetYaxis()->SetTitleOffset(1.1);
|
---|
75 | h2.GetXaxis()->SetLabelOffset(0.02);
|
---|
76 | h2.GetYaxis()->SetLabelOffset(0.02);
|
---|
77 | h2.GetXaxis()->SetTitleSize(0.06);
|
---|
78 | h2.GetYaxis()->SetTitleSize(0.06);
|
---|
79 | h2.GetXaxis()->SetLabelSize(0.06);
|
---|
80 | h2.GetYaxis()->SetLabelSize(0.06);
|
---|
81 |
|
---|
82 | h2.GetXaxis()->SetTickLength(0.0);
|
---|
83 | h2.GetYaxis()->SetTickLength(0.0);
|
---|
84 |
|
---|
85 | h2.Draw();
|
---|
86 |
|
---|
87 | // fake loop just keeping it for convenience right now
|
---|
88 | for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
|
---|
89 | {
|
---|
90 |
|
---|
91 | //first entry is eta bin, second is number of phi bins
|
---|
92 | set<pair<Double_t, Int_t> > caloBinning;
|
---|
93 | ExRootConfParam paramEtaBins, paramPhiBins;
|
---|
94 | ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", calo->c_str()));
|
---|
95 | Int_t size = param.GetSize();
|
---|
96 |
|
---|
97 | for(int i = 0; i < size / 2; ++i)
|
---|
98 | {
|
---|
99 | paramEtaBins = param[i * 2];
|
---|
100 | paramPhiBins = param[i * 2 + 1];
|
---|
101 | assert(paramEtaBins.GetSize() == 1);
|
---|
102 |
|
---|
103 | caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(), paramPhiBins.GetSize() - 1));
|
---|
104 | }
|
---|
105 | caloBinning_[*calo] = caloBinning;
|
---|
106 |
|
---|
107 | TLine *liney;
|
---|
108 | TLine *linex;
|
---|
109 |
|
---|
110 | //loop over calo binning
|
---|
111 | std::set<std::pair<Double_t, Int_t> >::iterator it;
|
---|
112 |
|
---|
113 | Int_t n = -1;
|
---|
114 | for(it = caloBinning.begin(); it != caloBinning.end(); ++it)
|
---|
115 | {
|
---|
116 | n++;
|
---|
117 |
|
---|
118 | if(debug) cout << "-----------------------" << endl;
|
---|
119 | if(debug) cout << it->first << "," << it->second << endl;
|
---|
120 | liney = new TLine(it->first, 0, it->first, 6.28);
|
---|
121 | liney->SetLineColor(kRed + 3);
|
---|
122 | liney->Draw();
|
---|
123 |
|
---|
124 | set<std::pair<Double_t, Int_t> >::iterator it2 = it;
|
---|
125 | it2--;
|
---|
126 |
|
---|
127 | for(int j = 0; j <= it->second; j++)
|
---|
128 | {
|
---|
129 |
|
---|
130 | Double_t yval0 = 0 + 6.28 * j / it->second;
|
---|
131 |
|
---|
132 | if(debug) cout << it2->first << "," << yval0 << "," << it->first << "," << yval0 << endl;
|
---|
133 |
|
---|
134 | linex = new TLine(it->first, yval0, it2->first, yval0);
|
---|
135 | linex->SetLineColor(kRed + 3);
|
---|
136 | linex->Draw();
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | TString text = TString(s);
|
---|
142 | TText *th1 = new TText(5.00, 6.45, text);
|
---|
143 | th1->SetTextAlign(31);
|
---|
144 | th1->SetTextFont(132);
|
---|
145 | th1->SetTextSize(0.075);
|
---|
146 | th1->Draw();
|
---|
147 |
|
---|
148 | TString output = TString(s);
|
---|
149 | c.Print(output + ".png", "png");
|
---|
150 | c.Print(output + ".pdf", "pdf");
|
---|
151 | }
|
---|