Fork me on GitHub

source: git/examples/CaloGrid.cpp@ eb3be06

ImprovedOutputFile Timing dual_readout llp
Last change on this file since eb3be06 was fed00d2, checked in by GitHub <noreply@…>, 8 years ago

removed setLineWidth in Calogrid

  • Property mode set to 100644
File size: 3.8 KB
Line 
1//calorimeter grid
2#include <set>
3#include <map>
4#include <utility>
5#include <vector>
6#include <algorithm>
7#include <sstream>
8#include <iostream>
9#include <cassert>
10
11#include "display/Delphes3DGeometry.h"
12#include "classes/DelphesClasses.h"
13#include "ExRootAnalysis/ExRootConfReader.h"
14
15#include "TCanvas.h"
16#include "TStyle.h"
17#include "TString.h"
18#include "TText.h"
19#include "TH2F.h"
20#include "TLine.h"
21
22using namespace std;
23
24Bool_t debug = false;
25//Bool_t debug = true;
26
27int 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
86 h2.Draw();
87
88 // fake loop just keeping it for convenience right now
89 for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
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 paramEtaBins = param[i*2];
99 paramPhiBins = param[i*2+1];
100 assert(paramEtaBins.GetSize()==1);
101
102 caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
103 }
104 caloBinning_[*calo] = caloBinning;
105
106 TLine *liney;
107 TLine *linex;
108
109 //loop over calo binning
110 std::set<std::pair<Double_t, Int_t> >::iterator it;
111
112 Int_t n = -1;
113 for (it = caloBinning.begin(); it != caloBinning.end(); ++it)
114 {
115 n++;
116
117 if(debug)cout<<"-----------------------"<<endl;
118 if(debug)cout<<it->first<<","<<it->second<<endl;
119 liney = new TLine(it->first,0,it->first,6.28);
120 liney->SetLineColor(kRed+3);
121 liney->Draw();
122
123 set<std::pair<Double_t, Int_t> >::iterator it2 = it;
124 it2--;
125
126 for(int j = 0; j <= it->second; j++)
127 {
128
129 Double_t yval0 = 0 + 6.28 * j / it->second;
130
131 if(debug) cout<<it2->first<<","<<yval0<<","<<it->first<<","<<yval0<<endl;
132
133 linex = new TLine(it->first,yval0,it2->first,yval0);
134 linex->SetLineColor(kRed+3);
135 linex->Draw();
136
137 }
138
139
140 }
141
142
143 }
144
145 TString text = TString(s);
146 TText *th1 = new TText(5.00,6.45,text);
147 th1->SetTextAlign(31);
148 th1->SetTextFont(132);
149 th1->SetTextSize(0.075);
150 th1->Draw();
151
152
153 TString output = TString(s);
154 c.Print(output+".png","png");
155 c.Print(output+".pdf","pdf");
156
157}
Note: See TracBrowser for help on using the repository browser.