20 int inum =
static_cast<int>(num);
21 return inum - inum % 8;
25 const char *
run =
"../9613-0000.root";
26 const char * runNum =
"EMCal run 9613";
30 TFile *
f =
new TFile(run,
"READ");
34 TTree *
t = (TTree*) f->Get(
"towerntup");
35 const int entries = t->GetEntries();
40 std::vector<float> *emcTowE = 0;
41 std::vector<float> *emciEta = 0;
42 std::vector<float> *emciPhi = 0;
44 t->SetBranchAddress(
"energy",&emcTowE);
45 t->SetBranchAddress(
"etabin",&emciEta);
46 t->SetBranchAddress(
"phibin",&emciPhi);
48 TH2D *EDist =
new TH2D(
"EDist",
";EMCal tower phi;EMCal tower eta",256,-.5,255.5,96,-.5,95.5);
49 TH2D *EDist_gap =
new TH2D(
"EDist_gap",
";EMCal tower phi;EMCal tower eta",256,-.5,255.5,96,-.5,95.5);
50 TH2D* packet_corrs[128][128];
51 for (
int i = 0;
i < 128;
i++) {
52 for (
int j = 0;
j < 128;
j++) {
54 const char * ccorrIndex = corrIndex.c_str();
55 packet_corrs[
i][
j] =
new TH2D(ccorrIndex,
";Energy;Energy",256,0,20000,256,0,20000);
59 auto packetE =
new float[entries][128];
60 TH2D *correlations =
new TH2D(
"correlations",
";packets",128,0,128,128,0,128);
62 float tower_E[256 * 96] = { 0 };
63 float tower_ET[256 * 96] = { 0 };
65 TCanvas *
tc =
new TCanvas();
66 gStyle->SetOptStat(0);
73 std::cout <<
"I see " << entries <<
" events!" << std::endl;
75 for (
int e = 0 ;
e < entries;
e++ ) {
78 for (
unsigned i = 0;
i < emcTowE->size();
i++) {
79 tower_E[
i] += emcTowE->at(
i);
82 if (
e % 1000 == 0 ) {
83 std::cout <<
"\r" <<
static_cast<int>(
static_cast<float>(
e) / entries * 100) <<
"%" <<
std::flush;
89 std::cout << endl <<
"Finding hot/cold spots..." << endl;
91 TH1D *h_tower_E =
new TH1D(
"h_tower_E",
";Tower energy;counts",200,0,200000);
92 TH1D *h_tower_E_top =
new TH1D(
"h_tower_E_top",
";Tower energy;counts",200,0,200000);
96 for (
int i = 0;
i < 256 * 96;
i++) {
97 if (emciEta->at(
i) >= 80) {
98 h_tower_E_top->Fill(tower_E[
i]);
100 h_tower_E->Fill(tower_E[
i]);
102 if (tower_E[i] > hottest) {
103 hottest = tower_E[
i];
106 float aveE = sumE / (256 * 96);
107 float stdDev = h_tower_E->GetStdDev();
109 std::vector<int> hot_spots;
110 std::vector<int> warm_spots;
111 std::vector<int> cold_spots;
112 std::vector<int> cool_spots;
113 std::vector<int> normal_spots;
115 float cool_tol = 0.65;
117 for (
int i = 0;
i < 256 * 96;
i++) {
119 if (tower_E[
i] > (aveE+stdDev*3) && tower_E[
i + 1] < (aveE+stdDev*3) && tower_E[
i - 1] < (aveE+stdDev*3)) {
120 hot_spots.push_back(
i);
122 else if (tower_E[
i] > (aveE + stdDev*3)) {
123 warm_spots.push_back(
i);
125 else if (tower_E[
i] < aveE * cool_tol && tower_E[
i + 1] > aveE * cool_tol && tower_E[
i - 1] > aveE * cool_tol) {
126 cold_spots.push_back(
i);
128 else if (tower_E[
i] < aveE * cool_tol) {
129 cool_spots.push_back(
i);
132 normal_spots.push_back(
i);
138 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
139 l.DrawLatex(0.15,0.91,runNum);
140 tc->Print(
"tower_E_1D.pdf");
142 h_tower_E_top->Draw();
143 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
144 l.DrawLatex(0.15,0.91,runNum);
145 tc->Print(
"tower_E_top_1D.pdf");
151 std::cout <<
"hot spots" << endl;
152 for (
unsigned i = 0;
i < hot_spots.size();
i++) {
153 std::cout <<
"(ieta, iphi) = (";
154 std::cout << emciEta->at(hot_spots.at(
i)) <<
", " << emciPhi->at(hot_spots.at(
i)) <<
") " << endl;
156 std::cout << endl <<
"warm spots" << endl;
157 for (
unsigned i = 0;
i < warm_spots.size();
i++ ) {
158 std::cout <<
"(ieta, iphi) = (";
159 std::cout << emciEta->at(warm_spots.at(
i)) <<
", " << emciPhi->at(warm_spots.at(
i)) <<
") " << endl;
161 std::cout << endl <<
"cold spots" << endl;
162 for (
unsigned i = 0;
i < cold_spots.size();
i++) {
163 std::cout <<
"(ieta, iphi) = (";
164 std::cout << emciEta->at(cold_spots.at(
i)) <<
", " << emciPhi->at(cold_spots.at(
i)) <<
") " << endl;
166 std::cout << endl <<
"cool spots" << endl;
167 std::vector<std::tuple<int,int>> cool_points;
169 for (
unsigned i = 0;
i < cool_spots.size();
i++) {
170 int rEta =
round8(emciEta->at(cool_spots.at(
i)));
171 int rPhi =
round8(emciPhi->at(cool_spots.at(
i)));
174 std::find(cool_points.begin(), cool_points.end(),
std::make_tuple(rEta,rPhi)) == cool_points.end()) {
176 std::cout <<
"(ieta, iphi) = (" << rEta <<
", " << rPhi <<
")" << endl;
181 for (
unsigned i = 0;
i < emcTowE->size();
i++ ) {
183 EDist->Fill( emciPhi->at(
i), emciEta->at(
i), tower_E[
i] );
185 for (
unsigned j = 0;
j < hot_spots.size();
j++ ) {
186 if (
i == static_cast<unsigned>(hot_spots.at(
j))) {
190 for (
unsigned j = 0;
j < warm_spots.size();
j++ ) {
191 if (
i == static_cast<unsigned>(warm_spots.at(
j))) {
197 EDist_gap->Fill(emciPhi->at(
i), emciEta->at(
i), tower_E[
i]);
204 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
205 l.DrawLatex(0.15,0.91,runNum);
206 l.SetTextSize(0.035);
207 l.DrawLatex(0.65,0.92,
"#Sigma_{evt} ADC");
209 tc->Print(
"EDist.pdf");
212 EDist_gap->Draw(
"colz");
213 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
214 l.DrawLatex(0.15,0.91,runNum);
215 l.SetTextSize(0.035);
216 l.DrawLatex(0.65,0.92,
"#Sigma_{evt} ADC");
218 tc->Print(
"EDistGap.pdf");
223 std::cout << endl <<
"Finding packet energies..." << endl;
228 for (
int e = 0;
e < entries;
e++) {
232 for (
unsigned i = 0;
i < emcTowE->size();
i++) {
233 ieta = emciEta->at(
i);
234 iphi = emciPhi->at(
i);
235 for (
unsigned j = 0;
j < hot_spots.size();
j++ ){
236 if (ieta == emciEta->at(hot_spots.at(
j)) && iphi == emciPhi->at(hot_spots.at(
j))) {
240 for (
unsigned j = 0;
j < warm_spots.size();
j++ ) {
241 if (ieta == emciEta->at(warm_spots.at(
j)) && iphi == emciPhi->at(warm_spots.at(
j))) {
246 packet += iphi / 8 * 4;
247 if (ieta / 24 == 0) { packet += ieta / 24 + 1; }
248 else if (ieta / 24 == 1) { packet += ieta / 24 - 1; }
249 else { packet += ieta / 24; }
251 if (!hot) { packetE[
e][packet] += emcTowE->at(
i); }
255 if (
e % 1000 == 0 ) {
256 std::cout <<
"\r" <<
static_cast<int>(
static_cast<float>(
e) / entries * 100) <<
"%" <<
std::flush;
261 std::cout << endl <<
"Finding correlations..." << endl;
263 for (
int e = 0;
e < entries;
e++ ) {
264 for (
int i = 0;
i < 128;
i++) {
265 for (
int j = 0;
j < 128;
j++) {
266 packet_corrs[
i][
j]->Fill(packetE[
e][
i],packetE[
e][
j]);
267 correlations->Fill(i,j,packet_corrs[i][j]->GetCorrelationFactor() / entries);
270 if (
e % 1000 == 0 ) {
271 std::cout <<
"\r" <<
static_cast<int>(
static_cast<float>(
e) / entries * 100) <<
"%" <<
std::flush;
277 correlations->SetMinimum(.7);
278 correlations->Draw(
"colz");
279 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
280 l.DrawLatex(0.15,0.91,runNum);
281 l.SetTextSize(0.035);
282 l.DrawLatex(0.65,0.92,
"Packet Correlations");
284 tc->Print(
"packet_correlations.pdf");
288 std::cout <<
"Would you like to see a specific correlation? (yes/no)" << endl;
290 if (quit ==
"no") { stop =
true; }
292 std::cout <<
"Which correlation would you like to see? (i j)" << endl;
295 std::cin >> ans1 >> ans2;
298 std::cout << title << endl;
299 const char * ctitle = title.c_str();
301 packet_corrs[ans1][ans2]->Draw(
"colz");
302 l.DrawLatex(0.15,0.95,
"sPHENIX Internal");
303 l.DrawLatex(0.15,0.91,runNum);
304 l.SetTextSize(0.035);
305 l.DrawLatex(0.65,0.92,ctitle);
307 tc->Print(
"specific_correlation.pdf");
309 std::cout <<
"Would you like to keep going? (yes/no) " << endl;