#if 1 #include #include #include #include #include #include #include #include #include #include "RootHeader.h" #include "TTree.h" #include "TProfile.h" #include "TH1F.h" #include "TFile.h" #include "TPolyLine.h" #include "TImage.h" using namespace std; #endif void translate(int crate, int slot, int channel, int &hit_mod, int &hit_lay, int &hit_col, int &hit_side){ // int mod_cr[4] = {13, 25, 19, 31}; int mod_cr[8] = {1, 37, 7, 43, 13, 25, 19, 31}; int up = -1; switch(slot){ case 3: hit_mod = mod_cr[crate]; up = 1; break; case 4: hit_mod = mod_cr[crate]; break; case 5: hit_mod = mod_cr[crate] + 1; up = 1; break; case 6: hit_mod = mod_cr[crate] + 1; break; case 7: hit_mod = mod_cr[crate] + 2; up = 1; break; case 8: hit_mod = mod_cr[crate] + 2; break; case 9: hit_mod = mod_cr[crate] + 3; up = 1; break; case 10: hit_mod = mod_cr[crate] + 3; break; case 13: hit_mod = mod_cr[crate] + 4; up = 1; break; case 14: hit_mod = mod_cr[crate] + 4; break; case 15: hit_mod = mod_cr[crate] + 5; up = 1; break; case 16: hit_mod = mod_cr[crate] + 5; break; default: break; } if(up == 1){ if(channel >= 0 && channel < 4){ hit_lay = 1; hit_col = channel + 1; hit_side = 1; } if(channel >= 4 && channel < 8){ hit_lay = 2; hit_col = channel - 3; hit_side = 1; } if(channel >= 8 && channel < 12){ hit_lay = 1; hit_col = channel - 7; hit_side = 2; } if(channel >= 12 && channel < 16){ hit_lay = 2; hit_col = channel - 11; hit_side = 2; } } else { if(channel >= 0 && channel < 4){ hit_lay = 3; hit_col = channel + 1; hit_side = 1; } if(channel >= 4 && channel < 8){ hit_lay = 4; hit_col = channel - 3; hit_side = 1; } if(channel >= 8 && channel < 12){ hit_lay = 3; hit_col = channel - 7; hit_side = 2; } if(channel >= 12 && channel < 16){ hit_lay = 4; hit_col = channel - 11; hit_side = 2; } } } void bcal_check() { int c; Int_t bd1 = 5; Int_t bd2 = 6; // Int_t bd1 = 15; // Int_t bd2 = 16; gStyle->SetOptStat(0); gStyle->SetOptFit(0); #if 0 TCanvas *c1 = new TCanvas("Upstream","Upstream",600.,700.); TCanvas *c2 = new TCanvas("Downstream","Downstream",600.,700.); TCanvas *c11 = new TCanvas("Test","Test",300,300); TCanvas *c12 = new TCanvas("Test 1","Test 1",300.,300.); c1->Divide(4,4); c2->Divide(4,4); c11->Divide(4,4); c12->Divide(4,4); #endif #if 1 TCanvas *cc[25]; Int_t y_pos = 0; for(Int_t can = 1; can < 25; can++){ char title[30]; sprintf(title,"can%d",can); if(can == 1) y_pos = 250; else if(can == 7) y_pos = 750; else if(can == 13) y_pos = 0; else if(can == 19) y_pos = 500; Int_t x_pos = ((can - 1)%6)*200; cc[can] = new TCanvas(title,title,x_pos,y_pos,200,200); cc[can]->Divide(4,4); } #endif TProfile *fadc_raw[12][20][16]; TH1F *hen = new TH1F("en","en",1000,-100,900); // TFile *f1=new TFile ("fcal_test.root","R"); // Playback // TFile *f1=new TFile ("bcal_s4_296.root","R"); // TFile *f1=new TFile ("bcal_s4_337.root","R"); // Playback // TFile *f1=new TFile ("bcal_s4_296.root","R"); // TFile *f1=new TFile ("bcal_s4_338.root","R"); // Good cosmics // TFile *f1=new TFile ("bcal_s4_341.root","R"); // Pulser downstream good // TFile *f1=new TFile ("bcal_s4_349.root","R"); // TFile *f1=new TFile ("bcal_s4_cosmic_368.root","R"); // TFile *f1=new TFile ("bcal_s4_cosmic_370.root","R"); // Cosmic good one // TFile *f1=new TFile ("bcal_s4_cosmic_405.root","R"); // TFile *f1=new TFile ("bcal_s4_cosmic_409.root","R"); // Cosmic North Side - > Good data, rate 3 Hz // TFile *f1=new TFile ("bcal_n4_691.root","R"); // Cosmic All BCAL South Side // TFile *f1=new TFile ("bcal_cosmic_693.root","R"); // Cosmic All BCAL ( North and South) 1128 events, rate 1 Hz // TFile *f1=new TFile ("bcal_cosmic_694.root","R"); TFile *f1=new TFile ("bcal_cosmic_3.root","R"); // BCAL Float_t pi = 3.1415926; TPolyLine *cell_cont[49]; TPolyLine *cell[49][5][5]; TCanvas *c3 = new TCanvas("BCAL Upstream","BCAL Upstream",700,700); gPad->Range(-120,-120,120,120); Float_t rad_min = 65; Float_t rad_max = 90; Float_t dphi = 7.5*pi/180; Float_t x_cell[5]; Float_t y_cell[5]; for(Int_t module = 1; module <= 48; module++){ // Float_t phi_min = pi - (module - 1)*dphi + dphi/2.; // Float_t phi_max = phi_min - dphi; Float_t phi_min = pi - (module - 1)*dphi ; Float_t phi_max = phi_min - dphi; x_cell[0] = rad_min*cos(phi_min); y_cell[0] = rad_min*sin(phi_min); x_cell[1] = rad_max*cos(phi_min); y_cell[1] = rad_max*sin(phi_min); x_cell[3] = rad_min*cos(phi_max); y_cell[3] = rad_min*sin(phi_max); x_cell[2] = rad_max*cos(phi_max); y_cell[2] = rad_max*sin(phi_max); x_cell[4] = rad_min*cos(phi_min); y_cell[4] = rad_min*sin(phi_min); cout << " phi_min = " << phi_min << " phi_max = " << phi_max << endl; cell_cont[module] = new TPolyLine(5, x_cell, y_cell); cell_cont[module]->SetLineColor(2); cell_cont[module]->SetLineWidth(3); cell_cont[module]->Draw(); } Float_t dr = (rad_max - rad_min)/10.; Float_t dr_step[5]; dr_step[0] = 0; dr_step[1] = dr; dr_step[2] = 3*dr; dr_step[3] = 6*dr; dr_step[4] = 10*dr; Float_t X_IN1, Y_IN1, X_IN2, Y_IN2, X_OUT1, Y_OUT1, X_OUT2, Y_OUT2; for(Int_t module = 1; module <= 48; module++){ // Float_t phi_min = pi - (module - 1)*dphi + dphi/2.; // Float_t phi_max = phi_min - dphi; Float_t phi_min = pi - (module - 1)*dphi ; Float_t phi_max = phi_min - dphi; for(Int_t layer = 1; layer <= 4; layer++){ X_IN1 = (rad_min + dr_step[layer-1])*cos(phi_min); Y_IN1 = (rad_min + dr_step[layer-1])*sin(phi_min); X_IN2 = (rad_min + dr_step[layer-1])*cos(phi_max); Y_IN2 = (rad_min + dr_step[layer-1])*sin(phi_max); X_OUT1 = (rad_min + dr_step[layer])*cos(phi_min); Y_OUT1 = (rad_min + dr_step[layer])*sin(phi_min); X_OUT2 = (rad_min + dr_step[layer])*cos(phi_max); Y_OUT2 = (rad_min + dr_step[layer])*sin(phi_max); Float_t L_IN = sqrt( pow(X_IN2 - X_IN1,2) + pow(Y_IN2 - Y_IN1,2)); Float_t L_OUT = sqrt( pow(X_OUT2 - X_OUT1,2) + pow(Y_OUT2 - Y_OUT1,2)); // cout << L_IN << " " << L_OUT << endl; Float_t sin1 = (Y_IN2 - Y_IN1)/L_IN; Float_t cos1 = (X_IN2 - X_IN1)/L_IN; for(Int_t column = 1; column <= 4; column++){ x_cell[0] = X_IN1 + (column - 1)*L_IN*cos1/4; y_cell[0] = Y_IN1 + (column - 1)*L_IN*sin1/4; x_cell[1] = X_OUT1 + (column - 1)*L_OUT*cos1/4; y_cell[1] = Y_OUT1 + (column - 1)*L_OUT*sin1/4; x_cell[2] = X_OUT1 + column*L_OUT*cos1/4; y_cell[2] = Y_OUT1 + column*L_OUT*sin1/4; x_cell[3] = X_IN1 + column*L_IN*cos1/4; y_cell[3] = Y_IN1 + column*L_IN*sin1/4; x_cell[4] = X_IN1 + (column - 1)*L_IN*cos1/4; y_cell[4] = Y_IN1 + (column - 1)*L_IN*sin1/4; cell[module][layer][column] = new TPolyLine(5, x_cell, y_cell); cell[module][layer][column]->SetLineColor(1); cell[module][layer][column]->SetLineWidth(0.1); cell[module][layer][column]->Draw(); } } } cout << " SASCHA SASCHA SASCHA " << endl; TTree *t1= (TTree*)f1->Get("tree1"); TBranch *br_nhit =t1->GetBranch("nhit"); TBranch *br_hcrate =t1->GetBranch("hcrate"); TBranch *br_hslot =t1->GetBranch("hslot"); TBranch *br_hch =t1->GetBranch("hch"); TBranch *br_nsamp =t1->GetBranch("nsamp"); TBranch *br_samp =t1->GetBranch("samp"); cout << "I am here " << endl; Int_t nhit; // Int_t hcrate[1600], hslot[1600], hch[1600], nsamp[1600]; // Int_t samp[1600][100]; Int_t hcrate[1600], hslot[1600], hch[1600], nsamp[1600]; Int_t samp[1600][130]; br_nhit->SetAddress(&nhit); cout << "I am here 1 " << endl; br_samp->SetAddress(&samp); br_hcrate->SetAddress(&hcrate); br_hslot->SetAddress(&hslot); br_hch->SetAddress(&hch); br_nsamp->SetAddress(&nsamp); br_samp->SetAddress(&samp); cout << "I am here 2 " << endl; Int_t nevent = t1->GetEntries(); cout << " Number of events = " << nevent << endl; for(Int_t crate = 0; crate < 8; crate++){ for(Int_t slot = 0; slot < 17; slot++){ for(Int_t channel = 0; channel < 16; channel++){ char title[30]; sprintf(title,"raw_cr%d_sl%d_ch%d",crate,slot,channel); // fadc_raw[crate][slot][channel] = new TProfile(title,title,100,-0.5,99.5,-10.,4096); fadc_raw[crate][slot][channel] = new TProfile(title,title,130,-0.5,129.5,-10.,4096); // For play back mode // fadc_raw[crate][slot][channel] = new TProfile(title,title,200,-0.5,199.5,-10.,4096); // fadc_raw[crate][slot][channel]->SetMinimum(190); // fadc_raw[crate][slot][channel]->SetMaximum(260); // Playback // fadc_raw[crate][slot][channel]->SetMinimum(0); // fadc_raw[crate][slot][channel]->SetMaximum(1500); // LED // fadc_raw[crate][slot][channel]->SetMinimum(0); // fadc_raw[crate][slot][channel]->SetMaximum(1800); // Cosmics fadc_raw[crate][slot][channel]->SetMinimum(50); // fadc_raw[crate][slot][channel]->SetMaximum(450); fadc_raw[crate][slot][channel]->SetMaximum(250); } } } cout << " Before analyses" << endl; for(Int_t i = 0; i < nevent; i++){ br_nhit->GetEntry(i); br_hcrate->GetEntry(i); br_hslot->GetEntry(i); br_hch->GetEntry(i); br_nsamp->GetEntry(i); br_samp->GetEntry(i); cout << " Read " << nhit << endl; if(nhit > 0){ for(Int_t hit = 0; hit < nhit; hit++){ Int_t crate = -1; Int_t slot = -1; Int_t channel = -1; crate = hcrate[hit]; slot = hslot[hit]; channel = hch[hit]; int hit_mod = -1; int hit_lay = -1; int hit_col = -1; int hit_side = -1; // cout << " Crate = " << crate << " Slot = " << slot << " Channel = " << channel << endl; translate(crate, slot, channel, hit_mod, hit_lay, hit_col, hit_side); // cout << " Before analyses 1 " << endl; // if(crate == 0){ // cout << " Crate = " << crate << " Slot = " << slot << " Channel = " << channel << endl; // cout << " BCAL mod = " << hit_mod << " layer = " << hit_lay << " column = " << hit_col << // " side = " << hit_side << endl; // cout << endl; // } // if(slot != bd1 && slot != bd2) continue; // cout << nhit << " Slot = " << slot << endl; Int_t sig_int = 0; Int_t base_int = 0; if(nsamp[hit] > 0){ // cout << " CRATE = " << crate << " SLOT = " << slot << " CHANNEL = " << channel << " NSAMP = " << nsamp[hit] << " hit = " << hit << endl; // cout << " " << samp[hit][0] << " " << samp[hit][1] << " " << samp[hit][2] << " " << samp[hit][3] << endl; base_int = 0; for (Int_t sample = 0; sample < nsamp[hit]; sample++){ // if(crate == 0 || slot == 12) // cout << " CRATE = " << crate << " SLOT = " << slot << " CHANNEL = " << channel << " " << samp[hit][sample] << endl; fadc_raw[crate][slot][channel]->Fill(float(sample),float(samp[hit][sample])); // Play back // fadc_raw[crate][slot][channel]->GetXaxis()->SetRangeUser(0,100); // if(channel == 1){ // cout << samp[hit][sample] << " "; // } // if(sample > 25 && sample <= 75) sig_int += samp[hit][sample]; // if(sample > 5 && sample <= 15) base_int += samp[hit][sample]; // if(sample > 35 && sample <= 90) sig_int += samp[hit][sample]; // if(sample > 25 && sample <= 80) sig_int += samp[hit][sample]; // Run 405 // if(sample > 40 && sample <= 80) sig_int += samp[hit][sample]; // Crate 3 bds 9 and 10 // if(sample > 30 && sample <= 70) sig_int += samp[hit][sample]; // if(sample > 85 && sample <= 95) base_int += samp[hit][sample]; sig_int += samp[hit][sample]; if(sample > 5 && sample <= 15) base_int += samp[hit][sample]; } hen->Fill(float(sig_int)-200.*40); // Float_t en = float(sig_int)-float(base_int)*5; // Float_t en = float(sig_int)-200.*40; Float_t en = float(sig_int)-float(base_int)*13; // Float_t en = float(sig_int)-13000.; // if(en > 100){ // if(en > 90){ if(en > 240){ if(hit_side == 1){ cout << " hit_mod " << hit_mod << " hit_lay = " << hit_lay << " hit en = " << en << endl; cell[hit_mod][hit_lay][hit_col]->SetFillColor(4); cell[hit_mod][hit_lay][hit_col]->Draw("f"); } } // cout << endl; } } } #if 1 #if 0 for(Int_t ch = 0; ch < 4; ch++){ c1->cd(ch + 1); fadc_raw[0][bd2][4 + ch ]->Draw(); c1->cd(ch + 5); fadc_raw[0][bd2][ch]->Draw(); c1->cd(ch + 9); fadc_raw[0][bd1][4 + ch]->Draw(); c1->cd(ch + 13); fadc_raw[0][bd1][ch]->Draw(); c2->cd(ch + 1); fadc_raw[0][bd2][12 + ch ]->Draw(); c2->cd(ch + 5); fadc_raw[0][bd2][8 + ch]->Draw(); c2->cd(ch + 9); fadc_raw[0][bd1][12 + ch]->Draw(); c2->cd(ch + 13); fadc_raw[0][bd1][8 + ch]->Draw(); } #endif #if 1 for(Int_t cr = 0; cr < 4; cr++){ for(Int_t ch = 0; ch < 4; ch++){ Int_t can = 6*cr; cc[can+1]->cd(ch + 1); fadc_raw[cr][4][4 + ch ]->Draw(); fadc_raw[cr][4][12 + ch ]->SetLineColor(2); fadc_raw[cr][4][12 + ch ]->Draw("same"); cc[can+1]->cd(ch + 5); fadc_raw[cr][4][ch]->Draw(); fadc_raw[cr][4][8 + ch]->SetLineColor(2); fadc_raw[cr][4][8 + ch]->Draw("same"); cc[can+1]->cd(ch + 9); fadc_raw[cr][3][4 + ch]->Draw(); fadc_raw[cr][3][12 + ch]->SetLineColor(2); fadc_raw[cr][3][12 + ch]->Draw("same"); cc[can+1]->cd(ch + 13); fadc_raw[cr][3][ch]->Draw(); fadc_raw[cr][3][8 + ch]->SetLineColor(2); fadc_raw[cr][3][8 + ch]->Draw("same"); cc[can+2]->cd(ch + 1); fadc_raw[cr][6][4 + ch ]->Draw(); fadc_raw[cr][6][12 + ch ]->SetLineColor(2); fadc_raw[cr][6][12 + ch ]->Draw("same"); cc[can+2]->cd(ch + 5); fadc_raw[cr][6][ch]->Draw(); fadc_raw[cr][6][8 + ch]->SetLineColor(2); fadc_raw[cr][6][8 + ch]->Draw("same"); cc[can+2]->cd(ch + 9); fadc_raw[cr][5][4 + ch]->Draw(); fadc_raw[cr][5][12 + ch]->SetLineColor(2); fadc_raw[cr][5][12 + ch]->Draw("same"); cc[can+2]->cd(ch + 13); fadc_raw[cr][5][ch]->Draw(); fadc_raw[cr][5][8 + ch]->SetLineColor(2); fadc_raw[cr][5][8 + ch]->Draw("same"); cc[can+3]->cd(ch + 1); fadc_raw[cr][8][4 + ch ]->Draw(); fadc_raw[cr][8][12 + ch ]->SetLineColor(2); fadc_raw[cr][8][12 + ch ]->Draw("same"); cc[can+3]->cd(ch + 5); fadc_raw[cr][8][ch]->Draw(); fadc_raw[cr][8][8 + ch]->SetLineColor(2); fadc_raw[cr][8][8 + ch]->Draw("same"); cc[can+3]->cd(ch + 9); fadc_raw[cr][7][4 + ch]->Draw(); fadc_raw[cr][7][12 + ch]->SetLineColor(2); fadc_raw[cr][7][12 + ch]->Draw(); cc[can+3]->cd(ch + 13); fadc_raw[cr][7][ch]->Draw(); fadc_raw[cr][7][8 + ch]->SetLineColor(2); fadc_raw[cr][7][8 + ch]->Draw("same"); cc[can+4]->cd(ch + 1); fadc_raw[cr][10][4 + ch ]->Draw(); fadc_raw[cr][10][12 + ch ]->SetLineColor(2); fadc_raw[cr][10][12 + ch ]->Draw("same"); cc[can+4]->cd(ch + 5); fadc_raw[cr][10][ch]->Draw(); fadc_raw[cr][10][8 + ch]->SetLineColor(2); fadc_raw[cr][10][8 + ch]->Draw("same"); cc[can+4]->cd(ch + 9); fadc_raw[cr][9][4 + ch]->Draw(); fadc_raw[cr][9][12 + ch]->SetLineColor(2); fadc_raw[cr][9][12 + ch]->Draw("same"); cc[can+4]->cd(ch + 13); fadc_raw[cr][9][ch]->Draw(); fadc_raw[cr][9][8 + ch]->SetLineColor(2); fadc_raw[cr][9][8 + ch]->Draw("same"); cc[can+5]->cd(ch + 1); fadc_raw[cr][14][4 + ch ]->Draw(); fadc_raw[cr][14][12 + ch ]->SetLineColor(2); fadc_raw[cr][14][12 + ch ]->Draw("same"); cc[can+5]->cd(ch + 5); fadc_raw[cr][14][ch]->Draw(); fadc_raw[cr][14][8 + ch]->SetLineColor(2); fadc_raw[cr][14][8 + ch]->Draw("same"); cc[can+5]->cd(ch + 9); fadc_raw[cr][13][4 + ch]->Draw(); fadc_raw[cr][13][12 + ch]->SetLineColor(2); fadc_raw[cr][13][12 + ch]->Draw("same"); cc[can+5]->cd(ch + 13); fadc_raw[cr][13][ch]->Draw(); fadc_raw[cr][13][8 + ch]->SetLineColor(2); fadc_raw[cr][13][8 + ch]->Draw("same"); cc[can+6]->cd(ch + 1); fadc_raw[cr][16][4 + ch ]->Draw(); fadc_raw[cr][16][12 + ch ]->SetLineColor(2); fadc_raw[cr][16][12 + ch ]->Draw("same"); cc[can+6]->cd(ch + 5); fadc_raw[cr][16][ch]->Draw(); fadc_raw[cr][16][8 + ch]->SetLineColor(2); fadc_raw[cr][16][8 + ch]->Draw("same"); cc[can+6]->cd(ch + 9); fadc_raw[cr][15][4 + ch]->Draw(); fadc_raw[cr][15][12 + ch]->SetLineColor(2); fadc_raw[cr][15][12 + ch]->Draw("same"); cc[can+6]->cd(ch + 13); fadc_raw[cr][15][ch]->Draw(); fadc_raw[cr][15][8 + ch]->SetLineColor(2); fadc_raw[cr][15][8 + ch]->Draw("same"); } } #endif // cout << " Before " << endl; // c1->Update(); // cout << " Mid 1 " << endl; // c2->Update(); // cout << " Mid 2 " << endl; c3->cd(); // cell[28][1][1]->SetFillColor(4); // cell[28][1][1]->Draw("f"); // gPad->Update(); c3->Update(); // c11->Update(); // c12->Update(); for(Int_t can = 1; can < 25; can++){ cc[can]->Update(); } #if 0 TImage *img1 = TImage::Create(); img1->FromPad(c1); // img1->WriteImage("c1_cosm_14_evt8.png"); TImage *img2 = TImage::Create(); img2->FromPad(c1); // img2->WriteImage("c2_cosm_14_evt8.png"); #endif #if 0 TImage *img3 = TImage::Create(); img3->FromPad(c3); // img3->WriteImage("c3_cosm_evt6.png"); img3->WriteImage("c3_cosm_examp.png"); #endif cout << " After " << endl; // c3->Update(); cout << " Read Event " << i + 1 << endl; c = getchar(); if(c == 'E'){ cout << " I am here " << endl; return; } for(Int_t ch = 0; ch < 16; ch++){ fadc_raw[0][bd1][ch]->Reset(); fadc_raw[0][bd2][ch]->Reset(); } #if 1 for(Int_t cr = 0; cr < 4; cr++){ for(Int_t bd = 0; bd < 17; bd++){ for(Int_t ch = 0; ch < 16; ch++){ fadc_raw[cr][bd][ch]->Reset(); fadc_raw[cr][bd][ch]->Reset(); } } } #endif for(Int_t mod = 1; mod < 49; mod++){ cell_cont[mod]->Draw(); for(Int_t lay = 1; lay < 5; lay++) for(Int_t col = 1; col < 5; col++){ cell[mod][lay][col]->SetFillColor(0); cell[mod][lay][col]->SetLineColor(1); cell[mod][lay][col]->SetLineWidth(1); cell[mod][lay][col]->Draw(); c3->cd(); gPad->Modified(); } } #endif } // hen->Draw(); return; }