Changes in examples/CaloGrid.cpp [77e9ae1:fed00d2] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/CaloGrid.cpp
r77e9ae1 rfed00d2 1 1 //calorimeter grid 2 #include <algorithm> 3 #include <cassert> 4 #include <iostream> 2 #include <set> 5 3 #include <map> 6 #include <set>7 #include <sstream>8 4 #include <utility> 9 5 #include <vector> 6 #include <algorithm> 7 #include <sstream> 8 #include <iostream> 9 #include <cassert> 10 10 11 #include "display/Delphes3DGeometry.h" 12 #include "classes/DelphesClasses.h" 11 13 #include "ExRootAnalysis/ExRootConfReader.h" 12 #include "classes/DelphesClasses.h"13 #include "display/Delphes3DGeometry.h"14 14 15 15 #include "TCanvas.h" 16 #include "TStyle.h" 17 #include "TString.h" 18 #include "TText.h" 16 19 #include "TH2F.h" 17 20 #include "TLine.h" 18 #include "TString.h"19 #include "TStyle.h"20 #include "TText.h"21 21 22 22 using namespace std; … … 28 28 { 29 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 35 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 36 37 37 TString card(argv[1]); … … 39 39 ExRootConfReader *confReader = new ExRootConfReader; 40 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); 41 50 42 std::vector<std::string> calorimeters_; 43 std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_; 51 caloBinning_.clear(); // calo binning 44 52 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); 53 TCanvas c("","",1600,838); 54 55 gPad->SetLeftMargin(0.16) ; 56 gPad->SetTopMargin(0.16) ; 57 gPad->SetBottomMargin(0.20) ; 58 58 gStyle->SetOptStat(0000000); 59 59 60 60 gStyle->SetTextFont(132); 61 61 62 62 TH2F h2("h2", "", 1, -6, 6, 1, 0, 6.28); 63 63 … … 71 71 h2.GetYaxis()->SetLabelFont(132); 72 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); 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) ; 81 84 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 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 91 //first entry is eta bin, second is number of phi bins 92 set< pair<Double_t, Int_t> > caloBinning;92 set< pair<Double_t, Int_t> > caloBinning; 93 93 ExRootConfParam paramEtaBins, paramPhiBins; 94 ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", 94 ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str())); 95 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)); 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)); 104 103 } 105 104 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) 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++) 115 127 { 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 } 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 139 143 } 140 144 141 145 TString text = TString(s); 142 TText *th1 = new TText(5.00, 6.45,text);143 th1->SetTextAlign(31); 144 th1->SetTextFont(132); 146 TText *th1 = new TText(5.00,6.45,text); 147 th1->SetTextAlign(31); 148 th1->SetTextFont(132); 145 149 th1->SetTextSize(0.075); 146 150 th1->Draw(); 147 151 152 148 153 TString output = TString(s); 149 c.Print(output + ".png", "png"); 150 c.Print(output + ".pdf", "pdf"); 154 c.Print(output+".png","png"); 155 c.Print(output+".pdf","pdf"); 156 151 157 }
Note:
See TracChangeset
for help on using the changeset viewer.