Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:49

0001 #include "TH2INTT.h"
0002 
0003 struct chan_info{
0004     int pid;
0005     int module;
0006     int chip;
0007     int chan;
0008     int adc;
0009     // int entry;
0010 };
0011 
0012 struct to_ch_str{
0013     int pid;
0014     int module;
0015     int chip;
0016     int chan;
0017 };
0018 
0019 to_ch_str convertToIndices(int input) {
0020     const int dim1 = 8;
0021     const int dim2 = 14;
0022     const int dim3 = 26;
0023     const int dim4 = 128;
0024 
0025     to_ch_str result;
0026     result.chan = input % dim4;
0027     input /= dim4;
0028     result.chip = input % dim3;
0029     input /= dim3;
0030     result.module = input % dim2;
0031     input /= dim2;
0032     result.pid = input % dim1;
0033 
0034     return result;
0035 }
0036 
0037 void hot_chan_finder(string run_ID)
0038 {   
0039     // string run_ID = "20864";
0040     string folder_directory = "/sphenix/user/ChengWei/INTT/INTT_commissioning/Field_ON/" + run_ID;
0041     string file_name = "beam_inttall-000"+ run_ID +"-0000_event_base_ana";
0042     string output_directory = folder_directory + "/PreCheck_" + file_name;
0043     double standard_ch_ratio_typeA = 1. / (8*14*16*128); // note : typeA, 16 sensor cells
0044     double standard_ch_ratio_typeB = 1. / (8*14*10*128); // note : typeB, 10 sensor cells
0045     int criterion = 3;
0046     bool All_event_used = true;
0047     long long defined_event = 200000; // note : only the in the case that the All_event_used is false
0048 
0049     system(Form("mkdir %s",output_directory.c_str()));
0050 
0051     TFile * file_in = TFile::Open(Form("%s/%s.root",folder_directory.c_str(),file_name.c_str()));
0052     TTree * tree = (TTree *)file_in->Get("tree");
0053     long long N_event = (All_event_used == true) ? tree -> GetEntries() : defined_event; 
0054     cout<<Form("N_event in file %s : %lli",file_name.c_str(), N_event)<<endl;
0055     
0056 
0057     int fNhits;
0058     int pid[100000]; // todo : if the fNhits greater than 100000, it may not work
0059     int module[100000];
0060     int chip_id[100000];
0061     int chan_id[100000];
0062     int adc[100000];
0063     // int bco[100000];
0064     // Long64_t bco_full[100000];
0065 
0066     
0067     tree -> SetBranchStatus("*",0);
0068     tree -> SetBranchStatus("fNhits",1);
0069     tree -> SetBranchStatus("fhitArray.pid",1);
0070     tree -> SetBranchStatus("fhitArray.module",1);
0071     tree -> SetBranchStatus("fhitArray.chip_id",1);
0072     tree -> SetBranchStatus("fhitArray.chan_id",1);
0073     tree -> SetBranchStatus("fhitArray.adc",1);
0074     // tree -> SetBranchStatus("fhitArray.bco",1);
0075     // tree -> SetBranchStatus("fhitArray.bco_full",1);
0076 
0077     tree -> SetBranchAddress("fNhits",&fNhits);
0078     tree -> GetEntry(0); // note : actually I really don't know why this line is necessary.
0079     tree -> SetBranchAddress("fhitArray.pid",&pid[0]);
0080     tree -> SetBranchAddress("fhitArray.module",&module[0]);
0081     tree -> SetBranchAddress("fhitArray.chip_id",&chip_id[0]);
0082     tree -> SetBranchAddress("fhitArray.chan_id",&chan_id[0]);
0083     tree -> SetBranchAddress("fhitArray.adc",&adc[0]);
0084     // tree -> SetBranchAddress("fhitArray.bco",&bco[0]);
0085     // tree -> SetBranchAddress("fhitArray.bco_full",&bco_full[0]);
0086 
0087     // note : ch_hit[pid][module][chip][channel]
0088     int ch_adc[8][14][26][128]; memset(ch_adc, -1, sizeof(ch_adc));                              // note : to keep the channel adc, and find the clone hit (single event)
0089     long long ld_clone_all[8][14]; memset(ld_clone_all, 0, sizeof(ld_clone_all));                      // note : N clone hit in that half-ladder in whole file
0090     long long ld_hit_before_all[8][14]; memset(ld_hit_before_all, 0, sizeof(ld_hit_before_all));       // note : N hit in that half-ladder regardless the clone hit or not
0091     long long ld_hit_after_all[8][14]; memset(ld_hit_after_all, 0, sizeof(ld_hit_after_all));          // note : N hit after the clone-hit removal in the whole file
0092     long long ch_hit_after_all[8][14][26][128]; memset(ch_hit_after_all, 0, sizeof(ch_hit_after_all)); // note : N hit of each channel in this file
0093     long long hit_after_all_typeA = 0; // note : U6 to U13 & U19 to U26 
0094     long long hit_after_all_typeB = 0; // note : U1 to U5 & U14 to U18
0095     vector<long long>ch_hit_after_all_seq; ch_hit_after_all_seq.clear();
0096     vector<chan_info> event_hit_info_vec; event_hit_info_vec.clear();
0097     
0098     // int ch_hit[8][14][26][128]; memset(ch_hit, 0, sizeof(ch_hit));  // note : count how many hit the channels have 
0099     int bad_ch[8][14]; memset(bad_ch, 0, sizeof(bad_ch));
0100     
0101     // note : N clone hit in one event, the ratio (N_clone / fNhits) V
0102     // note : N Clone hit as function of ladders (along all the events) V
0103     // note : Nhit histogram comparison, before and after clone-hit removal V
0104     // note : Nhit after, as function of ladder (along all the events) V
0105 
0106     // note : hot channel, as function of ladder 
0107 
0108     TH1F * nHit_before = new TH1F("nHit_before","nHit_before",500,0,40000); // note : # of hit in each event before clone hit removal
0109     nHit_before -> SetLineColor(4);
0110     nHit_before -> GetXaxis() -> SetTitle("N hits");
0111     nHit_before -> GetYaxis() -> SetTitle("Entry");
0112 
0113     TH1F * nHit_after  = new TH1F("nHit_after","nHit_after",500,0,40000); // note : # of hits in each event after the clone hit removal
0114     nHit_after -> SetLineColor(2);
0115     nHit_after -> GetXaxis() -> SetTitle("N hits");
0116     nHit_after -> GetYaxis() -> SetTitle("Entry");
0117     
0118     TH1F * clone_hit_ratio  = new TH1F("clone_hit_ratio","clone_hit_ratio",200,0,1); // note : in each event, N_clone_hit / fNhits (it won't be 100%)
0119     clone_hit_ratio -> GetXaxis() -> SetTitle("Nclone_hit / Ntotal_hit");
0120     clone_hit_ratio -> GetYaxis() -> SetTitle("Entry");
0121     
0122     TH1F * NchHit_after  = new TH1F("NchHit_after","NchHit_after",1000,0,8000); // note : After hit removal, # of hit each channel has in the whole file
0123     NchHit_after -> GetXaxis() -> SetTitle("N channel hit");
0124     NchHit_after -> GetYaxis() -> SetTitle("Entry");
0125 
0126     TH1F * nHotCh_hist  = new TH1F("nHotCh_hist","nHotCh_hist",112,0,112); 
0127     nHotCh_hist -> GetXaxis() -> SetTitle("Half-ladder index");
0128     nHotCh_hist -> GetYaxis() -> SetTitle("Entry");
0129 
0130     TH2F * Nhit_correlation  = new TH2F("Nhit_correlation","Nhit_correlation",1000,0,20000,1000,0,20000); 
0131     Nhit_correlation -> GetXaxis() -> SetTitle("Before (fNhits)");
0132     Nhit_correlation -> GetYaxis() -> SetTitle("Post clone-hit removal");
0133 
0134     TH2F * Nhit_correlation_short  = new TH2F("Nhit_correlation_short","Nhit_correlation_short",1000,0,2000,1000,0,2000); 
0135     Nhit_correlation_short -> GetXaxis() -> SetTitle("Before (fNhits)");
0136     Nhit_correlation_short -> GetYaxis() -> SetTitle("Post clone-hit removal");
0137 
0138     TH2F * CHratio_Nhits_correlation  = new TH2F("CHratio_Nhits_correlation","CHratio_Nhits_correlation",1000,0,20000,100,0,1); 
0139     CHratio_Nhits_correlation -> GetXaxis() -> SetTitle("fNhits");
0140     CHratio_Nhits_correlation -> GetYaxis() -> SetTitle("Clone-hit ratio");
0141 
0142     TH2F * CHratio_index_correlation  = new TH2F("CHratio_index_correlation","CHratio_index_correlation",1000,0,200000,100,0,1); 
0143     CHratio_index_correlation -> GetXaxis() -> SetTitle("eID");
0144     CHratio_index_correlation -> GetYaxis() -> SetTitle("Clone-hit ratio");
0145 
0146     TH2F * post_nhits_index  = new TH2F("post_nhits_index","post_nhits_index",1000,0,200000,1000,0,35000); 
0147     post_nhits_index -> GetXaxis() -> SetTitle("eID");
0148     post_nhits_index -> GetYaxis() -> SetTitle("Clone-hit ratio");
0149 
0150     vector<double> high_ratio_index; high_ratio_index.clear();
0151     vector<double> high_ratio_y; high_ratio_y.clear();
0152 
0153 
0154     for (int i = 0; i < N_event; i++)
0155     {
0156         tree -> GetEntry(i);
0157         if (i % 1000 == 0) cout<<"running : "<<i<<endl;
0158 
0159         for (int i1 = 0; i1 < fNhits; i1++)
0160         {
0161             if (pid[i1] > 3000 && pid[i1] < 3009 && module[i1] > -1 && module[i1] < 14 && chip_id[i1] > 0 && chip_id[i1] < 27 && chan_id[i1] > -1 && chan_id[i1] < 128 && adc[i1] > -1 && adc[i1] < 8) {
0162                 
0163                 if (ch_adc[ pid[i1] - 3001 ][ module[i1] ][ chip_id[i1] - 1 ][ chan_id[i1] ] == -1) // note : not clone
0164                 {
0165                     ch_adc[ pid[i1] - 3001 ][ module[i1] ][ chip_id[i1] - 1 ][ chan_id[i1] ] = adc[i1];
0166                 }
0167                 else 
0168                 {
0169                     ld_clone_all[ pid[i1] - 3001 ][ module[i1] ] += 1; // note : it's clone hit
0170                     ch_adc[ pid[i1] - 3001 ][ module[i1] ][ chip_id[i1] - 1 ][ chan_id[i1] ] = adc[i1]; //  note : the last one is used
0171                 }
0172                 
0173                 ld_hit_before_all[ pid[i1] - 3001 ][ module[i1] ] += 1; 
0174 
0175             }
0176         }
0177 
0178         for (int i0 = 0; i0 < 8; i0++) // note : pid
0179         {
0180             for (int i1 = 0; i1 < 14; i1++) // note : module
0181             {
0182                 for (int i2 = 0; i2 < 26; i2++) // note : chip - 1
0183                 {
0184                     for (int i3 = 0; i3 < 128; i3++) // note : channel
0185                     {
0186                         if ( ch_adc[i0][i1][i2][i3] != -1 ){
0187                             event_hit_info_vec.push_back({i0, i1, i2+1, i3, ch_adc[i0][i1][i2][i3]});
0188                             ld_hit_after_all[i0][i1] += 1;
0189                             ch_hit_after_all[i0][i1][i2][i3] += 1;
0190                             
0191                             // note : type B
0192                             if ((i2 >= 0 && i2 <= 4) || ( i2 >= 13 && i2 <= 17) ) { hit_after_all_typeB += 1; }
0193                             else { hit_after_all_typeA += 1; } // note : type A                           
0194                         }
0195                         
0196                     }
0197                 }
0198             }
0199         }
0200         if (fNhits != 0)
0201         {
0202             nHit_before -> Fill(fNhits);
0203             nHit_after  -> Fill(event_hit_info_vec.size());
0204             clone_hit_ratio -> Fill( (fNhits - event_hit_info_vec.size()) / double(fNhits) );
0205             Nhit_correlation -> Fill(fNhits, event_hit_info_vec.size());
0206             Nhit_correlation_short -> Fill(fNhits, event_hit_info_vec.size());
0207             post_nhits_index -> Fill(i, event_hit_info_vec.size());
0208             CHratio_index_correlation -> Fill(i,(fNhits - event_hit_info_vec.size()) / double(fNhits));
0209 
0210             CHratio_Nhits_correlation -> Fill(fNhits, (fNhits - event_hit_info_vec.size()) / double(fNhits));
0211             if ( (fNhits - event_hit_info_vec.size()) / double(fNhits) > 0.7 ) {
0212                 cout<<"high clone hit ratio, fNhits : "<<fNhits<<" post : "<<event_hit_info_vec.size()<<endl;
0213                 
0214                 high_ratio_index.push_back(high_ratio_index.size() + 1);
0215                 high_ratio_y.push_back(fNhits);
0216             }
0217 
0218             
0219         }
0220         
0221         
0222 
0223         memset(ch_adc, -1, sizeof(ch_adc));
0224         // memset(ld_clone_all, 0, sizeof(ld_clone_all)); // note : N_clone_hit along all the events.
0225         event_hit_info_vec.clear();
0226         
0227     } // note : for loop, end of event
0228 
0229     TFile * out_file = new TFile( Form("%s/hot_ch_map_criterion_%i.root",output_directory.c_str(),criterion), "RECREATE" );
0230     TTree * tree_out =  new TTree ("tree", "hot channel info.");
0231     int pid_out, module_out, chip_id_out, chan_id_out;
0232     int Nhit_out;
0233     double ratio_out;
0234     tree_out -> Branch("pid",&pid_out);
0235     tree_out -> Branch("module",&module_out);
0236     tree_out -> Branch("chip_id",&chip_id_out);
0237     tree_out -> Branch("chan_id",&chan_id_out);
0238     tree_out -> Branch("NchHit",&Nhit_out);
0239     tree_out -> Branch("ratio",&ratio_out);
0240     tree_out -> Branch("typeA_Nhit",&hit_after_all_typeA);
0241     tree_out -> Branch("typeB_Nhit",&hit_after_all_typeB);
0242 
0243     TCanvas * c1 = new TCanvas("","",900,800);
0244     gPad->SetTopMargin(0.07);
0245     gPad->SetBottomMargin(0.12);
0246     gPad->SetLeftMargin(0.14);
0247     gPad->SetRightMargin(0.14);
0248     c1 -> cd();
0249     c1 -> SetLogy(0);
0250 
0251     TCanvas * c3 = new TCanvas("","",800,800);
0252     c3 -> cd();
0253     gPad->SetTopMargin(0.07);
0254     gPad->SetBottomMargin(0.12);
0255     gPad->SetLeftMargin(0.14);
0256     gPad->SetRightMargin(0.14);
0257     c3 -> SetLogy(0);
0258 
0259 
0260     gStyle->SetOptStat(10);
0261     TH2F * HL_hotch_map = new TH2F("","",128,0,128,30,0,30);
0262     // HL_hotch_map -> SetStats(0);
0263 
0264     TH2F * hotch_map = new TH2F("","",128,0,128,30,0,30);
0265     // hotch_map -> SetStats(0);
0266 
0267     TH2F * chhit_map = new TH2F("","",128,0,128,26,1,27);
0268     // hotch_map -> SetStats(0);
0269 
0270     c1 -> cd();
0271     c1 -> Print(Form("%s/bad_ch_distribution_Cut_%i.pdf(",output_directory.c_str(), criterion));
0272     c1 -> Clear();
0273 
0274     c3 -> cd();
0275     c3 -> Print(Form("%s/N_ch_hit_2D.pdf(",output_directory.c_str()));
0276     c3 -> Clear();
0277 
0278     for (int i0 = 0; i0 < 8; i0++) { // note : pid
0279         for (int i1 = 0; i1 < 14; i1++) { // note : module
0280             for (int i2 = 0; i2 < 26; i2++) { // note : chip - 1
0281                 for (int i3 = 0; i3 < 128; i3++) { // note : channel{
0282                     NchHit_after -> Fill(ch_hit_after_all[i0][i1][i2][i3]);
0283                     ch_hit_after_all_seq.push_back( ch_hit_after_all[i0][i1][i2][i3] );
0284 
0285                     chhit_map -> SetBinContent(i3+1,i2+1,ch_hit_after_all[i0][i1][i2][i3]);
0286 
0287                     // note : type B
0288                     if ((i2 >= 0 && i2 <= 4) || ( i2 >= 13 && i2 <= 17) ) { 
0289                         if ( ((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeB)) / standard_ch_ratio_typeB) > criterion ){
0290                             bad_ch[i0][i1] += 1;
0291                             cout<<"type B hot channel, ratio : "<<((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeB)) / standard_ch_ratio_typeB)<<", Nhit : "<<ch_hit_after_all[i0][i1][i2][i3]<<", location : "<<i0<<" "<<i1<<" "<<i2+1<<" "<<i3<<endl;
0292                             
0293                             pid_out = i0 + 3001;
0294                             module_out = i1;
0295                             chip_id_out = i2 + 1;
0296                             chan_id_out = i3;
0297                             Nhit_out = ch_hit_after_all[i0][i1][i2][i3];
0298                             ratio_out = ((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeB)) / standard_ch_ratio_typeB);
0299                             tree_out -> Fill();
0300 
0301                             HL_hotch_map -> Fill(i3,i2+1);
0302                             hotch_map -> Fill(i3,i2+1);
0303 
0304                         }
0305                     }
0306                     else { // note : type A 
0307                         if ( ((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeA)) / standard_ch_ratio_typeA) > criterion ){
0308                             bad_ch[i0][i1] += 1;
0309                             cout<<"type A hot channel, ratio : "<<((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeA)) / standard_ch_ratio_typeA)<<", Nhit : "<<ch_hit_after_all[i0][i1][i2][i3]<<", location : "<<i0<<" "<<i1<<" "<<i2+1<<" "<<i3<<endl;
0310 
0311                             pid_out = i0 + 3001;
0312                             module_out = i1;
0313                             chip_id_out = i2 + 1;
0314                             chan_id_out = i3;
0315                             Nhit_out = ch_hit_after_all[i0][i1][i2][i3];
0316                             ratio_out = ((ch_hit_after_all[i0][i1][i2][i3] / double(hit_after_all_typeA)) / standard_ch_ratio_typeA);
0317                             tree_out -> Fill();
0318 
0319                             HL_hotch_map -> Fill(i3,i2+1);
0320                             hotch_map -> Fill(i3,i2+1);
0321                         }
0322                     } 
0323                 }
0324             }
0325 
0326             c3 -> cd();
0327             chhit_map -> SetTitle(Form("intt%i_%i",i0,i1));
0328             chhit_map -> Draw("colz0");
0329             c3 -> Print(Form("%s/N_ch_hit_2D.pdf",output_directory.c_str()));
0330             c3 -> Clear();
0331 
0332             c1 -> cd();
0333             HL_hotch_map -> SetTitle(Form("intt%i_%i",i0,i1));
0334             HL_hotch_map -> Draw("colz0");
0335             c1 -> Print(Form("%s/bad_ch_distribution_Cut_%i.pdf",output_directory.c_str(), criterion));
0336             c1 -> Clear();        
0337             HL_hotch_map -> Reset("ICESM");
0338             chhit_map -> Reset("ICESM");
0339         }
0340     }
0341 
0342     c3 -> cd();
0343     c3 -> Print(Form("%s/N_ch_hit_2D.pdf)",output_directory.c_str()));
0344     c3 -> Clear();
0345 
0346     c1 -> cd();
0347     c1 -> Print(Form("%s/bad_ch_distribution_Cut_%i.pdf)",output_directory.c_str(), criterion));
0348     c1 -> Clear();
0349     c1 -> cd();
0350 
0351     int n_size = 8 * 14 * 26 * 128;
0352     int sort_hit_index[n_size];
0353     TMath::Sort(n_size, &ch_hit_after_all_seq[0], sort_hit_index);
0354 
0355     // cout<<"test N event : "<<ch_hit_after_all[convertToIndices(sort_hit_index[0]).pid][convertToIndices(sort_hit_index[0]).module][convertToIndices(sort_hit_index[0]).chip][convertToIndices(sort_hit_index[0]).chan]<<endl;
0356     // cout<<"test N event : "<<ch_hit_after_all[convertToIndices(sort_hit_index[1]).pid][convertToIndices(sort_hit_index[1]).module][convertToIndices(sort_hit_index[1]).chip][convertToIndices(sort_hit_index[1]).chan]<<endl;
0357     // cout<<"test N event : "<<ch_hit_after_all[convertToIndices(sort_hit_index[2]).pid][convertToIndices(sort_hit_index[2]).module][convertToIndices(sort_hit_index[2]).chip][convertToIndices(sort_hit_index[2]).chan]<<endl;
0358     // cout<<"test N event : "<<ch_hit_after_all[convertToIndices(sort_hit_index[3]).pid][convertToIndices(sort_hit_index[3]).module][convertToIndices(sort_hit_index[3]).chip][convertToIndices(sort_hit_index[3]).chan]<<endl;
0359 
0360     vector<double> contain_ratio; contain_ratio.clear();
0361     vector<double> X_index; X_index.clear();
0362 
0363     for (int i = 0; i < 100; i++)
0364     {
0365         to_ch_str to_ch = convertToIndices(sort_hit_index[i]);
0366 
0367         cout<<"the channel that has "<<i+1<<"-most hits, location : "<<to_ch.pid<<" "<<to_ch.module<<" "<<to_ch.chip + 1<<" "<<to_ch.chan<<" nhit : "<<ch_hit_after_all[to_ch.pid][to_ch.module][to_ch.chip][to_ch.chan]<<" ratio : "<< ( ch_hit_after_all[to_ch.pid][to_ch.module][to_ch.chip][to_ch.chan] ) / double(hit_after_all_typeA + hit_after_all_typeB)<<endl;
0368         contain_ratio.push_back( ( ch_hit_after_all[to_ch.pid][to_ch.module][to_ch.chip][to_ch.chan] ) / double(hit_after_all_typeA + hit_after_all_typeB) );
0369         X_index.push_back(i + 1);
0370     }
0371 
0372     TGraph * seq_ch_ratio = new TGraph(contain_ratio.size(), &X_index[0], &contain_ratio[0]);
0373     // seq_ch_ratio -> SetMarkerColor();
0374     seq_ch_ratio -> SetMarkerStyle(20);
0375     seq_ch_ratio -> SetMarkerSize(1);
0376     seq_ch_ratio -> SetTitle("Hit ratio of Top 100 channel");
0377     seq_ch_ratio -> GetXaxis() -> SetTitle("Chan ranking");
0378     seq_ch_ratio -> GetYaxis() -> SetTitle("Ratio (ch_hit / total_hit)");
0379 
0380     TH2INTT * N_clone_pos = new TH2INTT();
0381     N_clone_pos -> SetTitle("N clone hit in each ladder");
0382 
0383     TH2INTT * N_hit_before_pos = new TH2INTT();
0384     N_hit_before_pos -> SetTitle("Nhit before clone hit removal");
0385 
0386     TH2INTT * N_hit_after_pos = new TH2INTT();
0387     N_hit_after_pos -> SetTitle("Nhit post clone hit removal");
0388 
0389     TH2INTT * clone_hit_ratio_ladder = new TH2INTT();
0390     clone_hit_ratio_ladder -> SetTitle("Clone hit ratio");
0391 
0392     TH2INTT * N_bad_ch_ladder = new TH2INTT();
0393     N_bad_ch_ladder -> SetTitle("# of hot channels");
0394 
0395     for (int i = 0; i < 8; i++) // note : pid
0396     {
0397         for (int i1 = 0; i1 < 14; i1++) // note : module
0398         {
0399             N_clone_pos    -> SetSerFCIContent(i,i1,ld_clone_all[i][i1]);
0400             N_hit_after_pos -> SetSerFCIContent(i,i1,ld_hit_after_all[i][i1]);
0401             N_hit_before_pos -> SetSerFCIContent(i,i1,ld_hit_before_all[i][i1]);
0402             clone_hit_ratio_ladder -> SetSerFCIContent(i,i1, ld_clone_all[i][i1] / double(ld_hit_before_all[i][i1]) );
0403             N_bad_ch_ladder -> SetSerFCIContent(i,i1, bad_ch[i][i1] );
0404             nHotCh_hist -> SetBinContent((i*14 + i1) + 1,bad_ch[i][i1]);
0405         }
0406     }
0407 
0408     TGraph * high_ratio_grr = new TGraph(high_ratio_index.size(), &high_ratio_index[0], &high_ratio_y[0]);
0409     high_ratio_grr -> SetMarkerStyle(20);
0410     high_ratio_grr -> SetMarkerSize(0.2);
0411     high_ratio_grr -> Draw("ap");
0412     c1 -> Print(Form("%s/high_ratio_grr.pdf",output_directory.c_str()));
0413     c1 -> Clear();
0414 
0415     CHratio_Nhits_correlation -> Draw("colz0");
0416     c1 -> Print(Form("%s/CHratio_Nhits_correlation.pdf",output_directory.c_str()));
0417     c1 -> Clear();
0418 
0419     CHratio_index_correlation -> Draw();
0420     c1 -> Print(Form("%s/CHratio_index_correlation.pdf",output_directory.c_str()));
0421     c1 -> Clear();
0422 
0423     post_nhits_index -> Draw();
0424     c1 -> Print(Form("%s/post_nhits_index.pdf",output_directory.c_str()));
0425     c1 -> Clear();
0426 
0427     nHotCh_hist -> Draw("hist");
0428     c1 -> Print(Form("%s/combined_bad_ch_1D_Cut_%i.pdf",output_directory.c_str(), criterion));
0429     c1 -> Clear();
0430     
0431     hotch_map -> Draw("colz0");
0432     c1 -> Print(Form("%s/combined_bad_ch_distribution_Cut_%i.pdf",output_directory.c_str(), criterion));
0433     c1 -> Clear();
0434 
0435     TF1 * one_one_line = new TF1("one_one_line","pol1",0,30000);
0436     one_one_line -> SetParameters(0,1);
0437     
0438     Nhit_correlation -> Draw("colz0");
0439     one_one_line -> Draw("lsame");
0440     c1 -> Print(Form("%s/Nhit_correlation.pdf",output_directory.c_str()));
0441     c1 -> Clear();
0442 
0443     Nhit_correlation_short -> Draw("colz0");
0444     one_one_line -> Draw("lsame");
0445     c1 -> Print(Form("%s/Nhit_correlation_short.pdf",output_directory.c_str()));
0446     c1 -> Clear();
0447 
0448 
0449 
0450     seq_ch_ratio -> Draw("ap");
0451     c1 -> Print(Form("%s/seq_ch_ratio.pdf",output_directory.c_str()));
0452     c1 -> Clear();
0453 
0454     c1 -> SetLogy(1);
0455 
0456     nHit_after  -> Draw("hist");
0457     nHit_before -> Draw("hist same");
0458     c1 -> Print(Form("%s/Nhit_dist.pdf",output_directory.c_str()));
0459     c1 -> Clear();
0460 
0461     clone_hit_ratio -> Draw("hist");
0462     c1 -> Print(Form("%s/clone_hit_ratio.pdf",output_directory.c_str()));
0463     c1 -> Clear();
0464 
0465     NchHit_after -> Draw("hist");
0466     c1 -> Print(Form("%s/NchHit_after.pdf",output_directory.c_str()));
0467     c1 -> Clear();
0468 
0469     TCanvas * c2 = new TCanvas("","",1780,800);
0470     c2 -> cd();
0471 
0472     N_clone_pos -> Draw("colz0");
0473     c2 -> Print(Form("%s/N_clone_ladder.pdf",output_directory.c_str()));
0474     c2 -> Clear();
0475 
0476     N_hit_before_pos -> Draw("colz0");
0477     c2 -> Print(Form("%s/Nhit_before_ladder.pdf",output_directory.c_str()));
0478     c2 -> Clear();
0479 
0480     N_hit_after_pos -> Draw("colz0");
0481     c2 -> Print(Form("%s/Nhit_after_ladder.pdf",output_directory.c_str()));
0482     c2 -> Clear();
0483 
0484     clone_hit_ratio_ladder -> Draw("colz0");
0485     c2 -> Print(Form("%s/clone_hit_ratio_ladder.pdf",output_directory.c_str()));
0486     c2 -> Clear();
0487 
0488     N_bad_ch_ladder -> Draw("colz0");
0489     c2 -> Print(Form("%s/N_bad_ch_ladder_Cut_%i.pdf",output_directory.c_str(), criterion));
0490     c2 -> Clear();
0491 
0492     tree_out->SetDirectory(out_file);
0493     tree_out -> Write("", TObject::kOverwrite);
0494 
0495     cout<<"hot channel finder done, file : "<<endl;
0496     out_file -> Close();
0497 }