Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:43

0001 #include "HcalMonitor.h"
0002 
0003 using namespace TMath;
0004 
0005 int monitor(char* input_file, char* output_file)
0006 {
0007 
0008   TCanvas *c1 = new TCanvas();  
0009   TStyle *mystyle = new TStyle("mystyle","my style");
0010   initStyle(mystyle);
0011   mystyle->cd();
0012 
0013   index_map::index_map get_index;
0014   int true_index[4176];
0015 
0016   TFile* file=TFile::Open(input_file);
0017   if(!file) return 0;
0018 
0019   TTree* tree = (TTree*)file->Get("TPGntuple");
0020   if(!tree) return 0;
0021 
0022   int ieta[4176], iphi[4176], run, event, tpg_index[4176];
0023   float tpg_energy[4176], tpg_uncompressed[4176];
0024   float highest_energy[4176] = {0.0};
0025   float rec_energy[4167];
0026   //int eta, phi;
0027 
0028   //tree->SetBranchAddress("ieta",ieta);
0029   //tree->SetBranchAddress("iphi",iphi);
0030   tree->SetBranchAddress("run",&run);
0031   tree->SetBranchAddress("event",&event);
0032   tree->SetBranchAddress("tpg_energy",tpg_energy);
0033   // tree->SetBranchAddress("hit_energy",hit_energy);
0034   tree->SetBranchAddress("tpg_uncompressed",tpg_uncompressed);
0035   tree->SetBranchAddress("tpg_index",tpg_index);
0036   tree->SetBranchAddress("rec_energy",rec_energy);
0037 
0038   //2-D plots
0039   TH2F *fakes = new TH2F("fakes","Number of Fakes in Tower",65,-32,33,72,1,73);
0040   TH2F *nofire = new TH2F("nofire","Highest Energy with No TPG",65,-32,33,72,1,73);
0041   TH2F *hslope = new TH2F("hslope","Slope of Uncompressed TPG vs. Hit",65,-32,33,72,1,73);
0042   TH2F *res2D_mean = new TH2F("res2D_mean","Mean of (Hit - Uncompressed)/Hit",65,-32,33,72,1,73);
0043   TH2F *res2D_rms = new TH2F("res2D_rms","RMS of (Hit - Uncompressed)/Hit",65,-32,33,72,1,73);
0044   TH2F *slope_eta = new TH2F("slope_eta","Slope vs. iEta",33,0,32,100,0,5);
0045   TH2F *heffic = new TH2F("heffic","Fitted Efficiency",65,-32,33,72,1,73);
0046   TH2F *hthresh = new TH2F("hthresh","Fitted 50% Threshold",65,-32,33,72,1,73);
0047   TH2F *hwidth = new TH2F("hwidth","Fitted Turn-on Width",65,-32,33,72,1,73);
0048   TH2F *hit_tpg_lut1 = new TH2F("hit_tpg_lut1","Uncompressed E vs. Hit E: |ieta| < 21",80,0,100,80,0,100);
0049   TH2F *hit_tpg_lut2 = new TH2F("hit_tpg_lut2","Uncompressed E vs. Hit E: 21 <= |ieta| < 27",80,0,100,80,0,100);
0050   TH2F *hit_tpg_lut3 = new TH2F("hit_tpg_lut3","Uncompressed E vs. Hit E: 27 <= |ieta| < 29",80,0,100,80,0,100);
0051   TH2F *hit_tpg_lut4 = new TH2F("hit_tpg_lut4","Uncompressed E vs. Hit E: 29 <= |ieta|",80,0,100,80,0,100);
0052   TH2F *res_hit_lut1 = new TH2F("res_hit_lut1","(Hit E - Uncompressed E)/Hit E vs. Hit E: |ieta| < 21",80,0,100,12,-3,3);
0053   TH2F *res_hit_lut2 = new TH2F("res_hit_lut2","(Hit E - Uncompressed E)/Hit E vs. Hit E: 21 <= |ieta| < 27",80,0,100,12,-3,3);
0054   TH2F *res_hit_lut3 = new TH2F("res_hit_lut3","(Hit E - Uncompressed E)/Hit E vs. Hit E: 27 <= |ieta| < 29",80,0,100,12,-3,3);
0055   TH2F *res_hit_lut4 = new TH2F("res_hit_lut4","(Hit E - Uncompressed E)/Hit E vs. Hit E: 29 <= |ieta|",80,0,100,12,-3,3);
0056 
0057   //1-D plots
0058   TH1F *slope_sum = new TH1F("slope_sum","Summary of Slopes",100,0,2);
0059   TH1F *res1D_mean_lut1 = new TH1F("res1D_mean_lut1","Summary of Mean (Hit - Uncompressed)/Hit: |ieta| < 21",100,-0.2,0.2);
0060   TH1F *res1D_rms_lut1 = new TH1F("res1D_rms_lut1","Summary of RMS (Hit - Uncompressed)/Hit: |ieta| < 21",100,0,0.2);
0061   TH1F *res1D_mean_lut2 = new TH1F("res1D_mean_lut2","Summary of Mean (Hit - Uncompressed)/Hit: 21 <= |ieta| < 27",250,-0.5,0.5);
0062   TH1F *res1D_rms_lut2 = new TH1F("res1D_rms_lut2","Summary of RMS (Hit - Uncompressed)/Hit: 21 <= |ieta| < 27",100,0,0.2);
0063   TH1F *res1D_mean_lut3 = new TH1F("res1D_mean_lut3","Summary of Mean (Hit - Uncompressed)/Hit: 27 <= |ieta| < 29",250,-0.5,0.5);
0064   TH1F *res1D_rms_lut3 = new TH1F("res1D_rms_lut3","Summary of RMS (Hit - Uncompressed)/Hit: 27 <= |ieta| < 29",150,0,0.3);
0065   TH1F *res1D_mean_lut4 = new TH1F("res1D_mean_lut4","Summary of Mean (Hit - Uncompressed)/Hit: 29 <= |ieta|",300,-0.6,0.6);
0066   TH1F *res1D_rms_lut4 = new TH1F("res1D_rms_lut4","Summary of RMS (Hit - Uncompressed)/Hit: 29 <= |ieta|",150,0,0.3);
0067   TH1F *all_hits_lut1 = new TH1F("all_hits_lut1","all_hits: lut1",50,0,5);
0068   TH1F *all_hits_lut2 = new TH1F("all_hits_lut2","all_hits: lut2",50,0,5);
0069   TH1F *all_hits_lut3 = new TH1F("all_hits_lut3","all_hits: lut3",150,0,15);
0070   TH1F *all_hits_lut4 = new TH1F("all_hits_lut4","all_hits: lut4",300,5,30);
0071   TH1F *good_hits_lut1 = new TH1F("good_hits_lut1","good_hits: lut1",50,0,5);
0072   TH1F *good_hits_lut2 = new TH1F("good_hits_lut2","good_hits: lut2",50,0,5);
0073   TH1F *good_hits_lut3 = new TH1F("good_hits_lut3","good_hits: lut3",150,0,15);
0074   TH1F *good_hits_lut4 = new TH1F("good_hits_lut4","good_hits: lut4",300,5,30);
0075   TH1F *eff_lut1 = new TH1F("eff_lut1","Efficiency: |ieta| < 21 ",50,0,5);
0076   TH1F *eff_lut2 = new TH1F("eff_lut2","Efficiency: 21 <= |ieta| < 27",50,0,5);
0077   TH1F *eff_lut3 = new TH1F("eff_lut3","Efficiency: 27 <= |ieta| < 29",150,0,15);
0078   TH1F *eff_lut4 = new TH1F("eff_lut4","Efficiency: 29 <= |ieta|",300,5,30);
0079   TH1F *effsum_lut1= new TH1F("effsum_lut1","Efficiency Summary: |ieta| < 21",50,0,1.1);
0080   TH1F *effsum_lut2= new TH1F("effsum_lut2","Efficiency Summary: 21 <= |ieta| < 27",50,0,1.1);
0081   TH1F *effsum_lut3= new TH1F("effsum_lut3","Efficiency Summary: 27 <= |ieta| < 29",50,0,1.1);
0082   TH1F *effsum_lut4= new TH1F("effsum_lut4","Efficiency Summary: 29 <= |ieta|",50,0,1.1);
0083   TH1F *threshsum_lut1= new TH1F("threshsum_lut1","Threshold Summary: |ieta| < 21",100,0,2);
0084   TH1F *threshsum_lut2= new TH1F("threshsum_lut2","Threshold Summary: 21 <= |ieta| < 27",100,0,2);
0085   TH1F *threshsum_lut3= new TH1F("threshsum_lut3","Threshold Summary: 27 <= |ieta| < 29",500,0,10);
0086   TH1F *threshsum_lut4= new TH1F("threshsum_lut4","Threshold Summary: 29 <= |ieta|",1000,0,20);
0087   TH1F *widthsum_lut1= new TH1F("widthsum_lut1","Width Summary: |ieta| < 21",100,0,1);
0088   TH1F *widthsum_lut2= new TH1F("widthsum_lut2","Width Summary: 21 <= |ieta| < 27",100,0,1);
0089   TH1F *widthsum_lut3= new TH1F("widthsum_lut3","Width Summary: 27 <= |ieta| < 29",100,0,1);
0090   TH1F *widthsum_lut4= new TH1F("widthsum_lut4","Width Summary: 29 <= |ieta|",150,0,1.5);
0091   TH1F *nofiresum_lut1 = new TH1F("nofiresum_lut1","Highest Energy with No TPG Summary: |ieta| < 21", 90,0,30);
0092   TH1F *nofiresum_lut2 = new TH1F("nofiresum_lut2","Highest Energy with No TPG Summary: 21 <= |ieta| < 27", 90,0,30);
0093   TH1F *nofiresum_lut3 = new TH1F("nofiresum_lut3","Highest Energy with No TPG Summary: 27 <= |ieta| < 29", 90,0,30);
0094   TH1F *nofiresum_lut4 = new TH1F("nofiresum_lut4","Highest Energy with No TPG Summary: 29 <= |ieta|", 90,0,30);
0095   TH1F *fakessum_lut1 = new TH1F("fakessum_lut1","Energy of Fake Hits: |ieta| < 21",90,0,30);
0096   TH1F *fakessum_lut2 = new TH1F("fakessum_lut2","Energy of Fake Hits: 21 <= |ieta| < 27",90,0,30);
0097   TH1F *fakessum_lut3 = new TH1F("fakessum_lut3","Energy of Fake Hits: 27 <= |ieta| < 29",90,0,30);
0098   TH1F *fakessum_lut4 = new TH1F("fakessum_lut4","Energy of Fake Hits: 29 <= |ieta|",90,0,30);
0099 
0100 
0101   TObjArray all_hits(4176);
0102   TObjArray good_hits(4176);
0103   TObjArray efficiency(4176);
0104   TObjArray hit_tpg(4176);
0105   TObjArray resolution(4176);
0106 
0107 
0108   char name[20], title[20];
0109   map<int,float> tpg_energy_map, uncompressed_map, rec_energy_map;
0110   float compressed, uncompressed, rec;
0111 
0112   for(int i=0;i<= (int)(tree->GetEntries() ) - 1;i++) 
0113     {
0114       tree->GetEntry(i);
0115       tpg_energy_map.clear();
0116       uncompressed_map.clear();
0117       rec_energy_map.clear();
0118       //initialize histos and fill maps/arrays
0119       for (int j=0; j<4176; ++j)
0120     {
0121       true_index[j] = get_index.ntpg(j);
0122       ieta[j] = true_index[j]/100;
0123       iphi[j] = TMath::Abs(true_index[j]%100);
0124       if (tpg_index[j] != 0)
0125         {
0126           tpg_energy_map[tpg_index[j]] = tpg_energy[j];
0127           rec_energy_map[tpg_index[j]] = rec_energy[j];
0128           uncompressed_map[tpg_index[j]] = et2e(TMath::Abs(ieta[j]))*tpg_uncompressed[j];
0129           //cout << "channel found: index = " << tpg_index[j] << " tpg counts = " << tpg_energy[j] << "\n";
0130 
0131         }
0132       if (i==0)
0133         {
0134           sprintf(name,"all_%d",true_index[j]);
0135           sprintf(title,"all hits:%d",true_index[j]);
0136           all_hits[j] = new TH1F(name,title,200,0,20);
0137           sprintf(name,"good_%d",true_index[j]);
0138           sprintf(title,"good hits:%d",true_index[j]);
0139           good_hits[j] = new TH1F(name,title,200,0,20);
0140           sprintf(name,"hit_tpg_%d",true_index[j]);
0141               sprintf(title,"hit_tpg:%d",true_index[j]);
0142               hit_tpg[j] = new TProfile(name,title,200,0,100,0,200);
0143           sprintf(name,"resolution_%d",true_index[j]);
0144               sprintf(title,"resolution:%d",true_index[j]);
0145               resolution[j] = new TH1F(name,title,20,-5,5);
0146         }
0147     }
0148       //fill histos with newly filled maps
0149       //use -1 as the default value for a channel w/o an ide
0150       for (int j=0; j<4176; j++)
0151     {
0152       if (tpg_energy_map.count(true_index[j])==0)
0153         {
0154           compressed = -1;
0155         }
0156       else
0157         {
0158           compressed = tpg_energy_map.find(true_index[j])->second;
0159         }
0160       if (uncompressed_map.count(true_index[j])==0)
0161         {
0162           uncompressed = -1;
0163         }
0164       else
0165         {
0166           uncompressed = uncompressed_map.find(true_index[j])->second;
0167         }
0168       if (rec_energy_map.count(true_index[j])==0)
0169         {
0170           rec = -1;
0171         }
0172       else
0173         {
0174           rec = rec_energy_map.find(true_index[j])->second;
0175         }
0176       
0177       if(compressed != -1 && uncompressed != -1 && rec != -1)
0178         {
0179           ((TH1F*)all_hits[j])->Fill(rec);
0180           if (Abs(ieta[j]) <= 20)
0181         {
0182           all_hits_lut1->Fill(rec);
0183           if (compressed > 0)
0184             {
0185               good_hits_lut1->Fill(rec);
0186               hit_tpg_lut1->Fill(rec,uncompressed);
0187               res_hit_lut1->Fill(rec,(rec-uncompressed)/rec);
0188               ((TH1F*)good_hits[j])->Fill(rec);
0189               ((TProfile*)hit_tpg[j])->Fill(rec,uncompressed);
0190               ((TH1F*)resolution[j])->Fill((rec-uncompressed)/rec);
0191               if (rec == 0)
0192             {
0193               fakes->Fill(ieta[j],iphi[j]);
0194               fakessum_lut1->Fill(uncompressed);
0195             }
0196             }
0197         }
0198           else if (Abs(ieta[j]) <= 26)
0199         {              
0200           all_hits_lut2->Fill(rec);
0201           if (compressed > 0)
0202             {
0203               good_hits_lut2->Fill(rec);
0204               hit_tpg_lut2->Fill(rec,uncompressed);
0205               res_hit_lut2->Fill(rec,(rec-uncompressed)/rec);
0206               ((TH1F*)good_hits[j])->Fill(rec);
0207               ((TProfile*)hit_tpg[j])->Fill(rec,uncompressed);
0208               ((TH1F*)resolution[j])->Fill((rec-uncompressed)/rec);
0209               if (rec == 0)
0210             {
0211               fakes->Fill(ieta[j],iphi[j]);
0212               fakessum_lut2->Fill(uncompressed);
0213             }
0214             }
0215         }
0216           else if (Abs(ieta[j]) <= 28)
0217         {
0218           all_hits_lut3->Fill(rec);
0219           if (compressed > 0)
0220             {
0221               good_hits_lut3->Fill(rec);
0222               hit_tpg_lut3->Fill(rec,uncompressed);
0223               res_hit_lut3->Fill(rec,(rec-uncompressed)/rec);
0224               ((TH1F*)good_hits[j])->Fill(rec);
0225               ((TProfile*)hit_tpg[j])->Fill(rec,uncompressed);
0226               ((TH1F*)resolution[j])->Fill((rec-uncompressed)/rec);
0227               if (rec == 0)
0228             {
0229               fakes->Fill(ieta[j],iphi[j]);
0230               fakessum_lut3->Fill(uncompressed);
0231             }
0232             }
0233         }
0234           else
0235         {
0236           all_hits_lut4->Fill(rec);
0237           if (compressed > 0)
0238             {
0239               good_hits_lut4->Fill(rec);
0240               hit_tpg_lut4->Fill(rec,uncompressed);
0241               res_hit_lut4->Fill(rec,(rec-uncompressed)/rec);
0242               ((TH1F*)good_hits[j])->Fill(rec);
0243               ((TProfile*)hit_tpg[j])->Fill(rec,uncompressed);
0244               ((TH1F*)resolution[j])->Fill((rec-uncompressed)/rec);
0245               if (rec == 0)
0246             {
0247               fakes->Fill(ieta[j],iphi[j]);
0248               fakessum_lut4->Fill(uncompressed);
0249             }
0250             }
0251         }
0252           //Fill nofires
0253           if (compressed == 0)
0254         {
0255           if (rec > highest_energy[j])
0256             {
0257               highest_energy[j] = rec;
0258             }
0259         }
0260         }
0261     }
0262     }
0263   
0264   TF1 *fit = new TF1("fit","[0]*x",0,100);
0265   TF1 *turnon = new TF1("turnon","[0]*0.5*(TMath::Erf((x -[1])*0.5/[2])+1.)",0,30);
0266 
0267   eff_lut1->Divide(good_hits_lut1,all_hits_lut1,1,1,"B");
0268   eff_lut2->Divide(good_hits_lut2,all_hits_lut2,1,1,"B");
0269   eff_lut3->Divide(good_hits_lut3,all_hits_lut3,1,1,"B");
0270   eff_lut4->Divide(good_hits_lut4,all_hits_lut4,1,1,"B");
0271 
0272   turnon->SetParameter(0,1);
0273   turnon->SetParameter(1,2.5);
0274   turnon->SetParameter(2,2);
0275   eff_lut1->Fit("turnon");
0276 
0277   turnon->SetParameter(0,1);
0278   turnon->SetParameter(1,2.5);
0279   turnon->SetParameter(2,2);
0280   eff_lut2->Fit("turnon");
0281 
0282   turnon->SetParameter(0,1);
0283   turnon->SetParameter(1,7.5);
0284   turnon->SetParameter(2,3);
0285   eff_lut3->Fit("turnon");
0286 
0287   turnon->SetParameter(0,1);
0288   turnon->SetParameter(1,12.5);
0289   turnon->SetParameter(2,4);
0290   eff_lut4->Fit("turnon");
0291 
0292   double mean;
0293   double sigma;
0294   double thresh;
0295   double width;
0296   double effic;
0297 
0298   for (int j=0; j< 4176; ++j)
0299     {
0300       turnon->SetParameter(0,1);
0301       turnon->SetParameter(1,10);
0302       turnon->SetParameter(2,6);
0303       //no fire plot
0304       nofire->Fill(ieta[j],iphi[j],highest_energy[j]);
0305       
0306       //efficiency plots
0307       sprintf(name,"eff%d",true_index[j]);
0308       sprintf(title,"efficiency:%d",true_index[j]);
0309       efficiency[j] = new TH1F(name,title,200,0,20);
0310       ((TH1F*)efficiency[j])->Divide((TH1F*)good_hits[j],(TH1F*)all_hits[j],1,1,"B");
0311       ((TH1F*)efficiency[j])->Fit("turnon");
0312       effic = turnon->GetParameter(0);
0313       thresh = turnon->GetParameter(1);
0314       width = turnon->GetParameter(2);
0315       heffic->Fill(ieta[j],iphi[j],effic);
0316       hthresh->Fill(ieta[j],iphi[j],thresh);
0317       hwidth->Fill(ieta[j],iphi[j],width);
0318     
0319       //resolution plots
0320       mean = ((TH1F*)resolution[j])->GetMean(1);
0321       sigma = ((TH1F*)resolution[j])->GetRMS(1);
0322       res2D_mean->Fill(ieta[j],iphi[j],mean);
0323       res2D_rms->Fill(ieta[j],iphi[j],sigma);
0324 
0325 
0326       if (Abs(ieta[j]) <= 20)
0327     {
0328       effsum_lut1->Fill(effic);
0329       threshsum_lut1->Fill(thresh);
0330       widthsum_lut1->Fill(width);
0331       res1D_mean_lut1->Fill(mean);
0332       res1D_rms_lut1->Fill(sigma);
0333       nofiresum_lut1->Fill(highest_energy[j]);
0334     }
0335       else if (Abs(ieta[j]) <=26)
0336     {
0337           effsum_lut2->Fill(effic);
0338           threshsum_lut2->Fill(thresh);
0339           widthsum_lut2->Fill(width);
0340       res1D_mean_lut2->Fill(mean);
0341           res1D_rms_lut2->Fill(sigma);
0342           nofiresum_lut2->Fill(highest_energy[j]);
0343     }
0344       else if (Abs(ieta[j]) <= 28)
0345     {
0346           effsum_lut3->Fill(effic);
0347           threshsum_lut3->Fill(thresh);
0348           widthsum_lut3->Fill(width);
0349       res1D_mean_lut3->Fill(mean);
0350           res1D_rms_lut3->Fill(sigma);
0351           nofiresum_lut3->Fill(highest_energy[j]);
0352     }
0353       else
0354     {
0355           effsum_lut4->Fill(effic);
0356           threshsum_lut4->Fill(thresh);
0357           widthsum_lut4->Fill(width);
0358       res1D_mean_lut4->Fill(mean);
0359           res1D_rms_lut4->Fill(sigma);
0360           nofiresum_lut4->Fill(highest_energy[j]);
0361     }
0362       
0363       //lut testing plots
0364       ((TProfile*)hit_tpg[j])->Fit("fit","","",1,100);
0365       Double_t slope = fit->GetParameter(0);
0366       hslope->Fill(ieta[j],iphi[j],slope);
0367       slope_sum->Fill(slope);
0368       slope_eta->Fill(TMath::Abs(ieta[j]),slope);
0369     }
0370   delete c1;
0371   
0372 
0373   //efficiency
0374   //raw efficiencies
0375   TCanvas *c2 = new TCanvas();
0376   gStyle->SetOptStat("e");
0377   c2->Divide(2,2);
0378   c2->cd(1);
0379   eff_lut1->Draw();
0380   SetupTitle(eff_lut1,"Rec Energy (GeV)","Efficiency");
0381   SetStatus(eff_lut1,"UNCHECKED");
0382   c2->cd(2);
0383   eff_lut2->Draw();
0384   SetupTitle(eff_lut2,"Rec Energy (GeV)","Efficiency");
0385   SetStatus(eff_lut2,"UNCHECKED");  
0386   c2->cd(3);
0387   eff_lut3->Draw();
0388   SetupTitle(eff_lut3,"Rec Energy (GeV)","Efficiency");
0389   SetStatus(eff_lut3,"UNCHECKED");
0390   c2->cd(4);
0391   eff_lut4->Draw();
0392   SetupTitle(eff_lut4,"Rec Energy (GeV)","Efficiency");
0393   SetStatus(eff_lut4,"UNCHECKED");
0394   c2->Print("output.ps(");
0395   delete c2;
0396 
0397   //tower by tower efficiencies
0398   TCanvas *c3 = new TCanvas();
0399   heffic->Draw("COLZ");
0400   SetupTowerDisplay(heffic);
0401   c3->Print("output.ps");
0402   delete c3;
0403 
0404   TCanvas *c4 = new TCanvas();
0405   hthresh->Draw("COLZ");
0406   SetupTowerDisplay(hthresh);
0407   c4->Print("output.ps");
0408   delete c4;
0409 
0410   TCanvas *c5 = new TCanvas();
0411   hwidth->Draw("COLZ");
0412   SetupTowerDisplay(hwidth);
0413   c5->Print("output.ps");
0414   delete c5;
0415 
0416   //efficiency summary
0417   TCanvas *c6 = new TCanvas();
0418   gStyle->SetOptStat("emruo");
0419   c6->Divide(2,2);
0420   c6->cd(1);
0421   effsum_lut1->Draw();
0422   SetupTitle(effsum_lut1,"Efficiency","Ntowers");
0423   SetStatus(effsum_lut1,"UNCHECKED");
0424   c6->cd(2);
0425   effsum_lut2->Draw();
0426   SetupTitle(effsum_lut2,"Efficiency","Ntowers");
0427   SetStatus(effsum_lut2,"UNCHECKED");
0428   c6->cd(3);
0429   effsum_lut3->Draw();
0430   SetupTitle(effsum_lut3,"Efficiency","Ntowers");
0431   SetStatus(effsum_lut3,"UNCHECKED");
0432   c6->cd(4);
0433   effsum_lut4->Draw();
0434   SetupTitle(effsum_lut4,"Efficiency","Ntowers");
0435   SetStatus(effsum_lut4,"UNCHECKED");
0436   c6->Print("output.ps");
0437   delete c6;
0438 
0439   TCanvas *c7 = new TCanvas();
0440   gStyle->SetOptStat("emruo");
0441   c7->Divide(2,2);
0442   c7->cd(1);
0443   threshsum_lut1->Draw();
0444   SetupTitle(threshsum_lut1,"Threshold","Ntowers");
0445   SetStatus(threshsum_lut1,"UNCHECKED");
0446   c7->cd(2);
0447   threshsum_lut2->Draw();
0448   SetupTitle(threshsum_lut2,"Threshold","Ntowers");
0449   SetStatus(threshsum_lut2,"UNCHECKED");
0450   c7->cd(3);
0451   threshsum_lut3->Draw();
0452   SetupTitle(threshsum_lut3,"Threshold","Ntowers");
0453   SetStatus(threshsum_lut3,"UNCHECKED");
0454   c7->cd(4);
0455   threshsum_lut4->Draw();
0456   SetupTitle(threshsum_lut4,"Threshold","Ntowers");
0457   SetStatus(threshsum_lut4,"UNCHECKED");
0458   c7->Print("output.ps");
0459   delete c7;
0460 
0461   TCanvas *c8 = new TCanvas();
0462   c8->Divide(2,2);
0463   gStyle->SetOptStat("emruo");
0464   c8->cd(1);
0465   widthsum_lut1->Draw();
0466   SetupTitle(widthsum_lut1,"Width","Ntowers");
0467   SetStatus(widthsum_lut1,"UNCHECKED");
0468   c8->cd(2);
0469   widthsum_lut2->Draw();
0470   SetupTitle(widthsum_lut2,"Width","Ntowers");
0471   SetStatus(widthsum_lut2,"UNCHECKED");
0472   c8->cd(3);
0473   widthsum_lut3->Draw();
0474   SetupTitle(widthsum_lut3,"Width","Ntowers");
0475   SetStatus(widthsum_lut3,"UNCHECKED");
0476   c8->cd(4);
0477   widthsum_lut4->Draw();
0478   SetupTitle(widthsum_lut4,"Width","Ntowers");
0479   SetStatus(widthsum_lut4,"UNCHECKED");
0480   c8->Print("output.ps");
0481   delete c8;
0482 
0483   //slopes
0484   //raw slope
0485   TCanvas *c15 = new TCanvas();
0486   gStyle->SetOptStat("e");
0487   c15->Divide(2,2);
0488   TF1 *line = new TF1("line","x",0,100);
0489   line->SetLineColor(4);
0490   c15->cd(1);
0491   hit_tpg_lut1->Draw("box");
0492   line->Draw("same");
0493   SetupTitle(hit_tpg_lut1,"Rec Energy (Gev)","Uncompressed TPG (GeV)");
0494   c15->cd(2);
0495   hit_tpg_lut2->Draw("box");
0496   line->Draw("same");
0497   SetupTitle(hit_tpg_lut2,"Rec Energy (Gev)","Uncompressed TPG (GeV)");
0498   c15->cd(3);
0499   hit_tpg_lut3->Draw("box");
0500   line->Draw("same");
0501   SetupTitle(hit_tpg_lut3,"Rec Energy (Gev)","Uncompressed TPG (GeV)");
0502   c15->cd(4);
0503   hit_tpg_lut4->Draw("box");
0504   line->Draw("same");
0505   SetupTitle(hit_tpg_lut4,"Rec Energy (Gev)","Uncompressed TPG (GeV)");
0506   c15->Print("output.ps");
0507   delete c15;
0508 
0509   //tower by tower slope
0510   TCanvas *c16 = new TCanvas();
0511   hslope->Draw("COLZ");
0512   SetupTowerDisplay(hslope);
0513   c16->Print("output.ps");
0514   delete c16;
0515 
0516   //slope summary
0517   TCanvas *c17 = new TCanvas();
0518   gStyle->SetOptStat("emruo");
0519   slope_sum->Draw();
0520   SetupTitle(slope_sum,"Slope of Uncompressed TPG vs Rec Energy","Ntowers");
0521   SetStatus(slope_sum,"UNCHECKED");
0522   c17->SetLogy();
0523   c17->Print("output.ps");
0524   delete c17;
0525 
0526   //resolution
0527   //raw resoltions
0528   TCanvas *c9 = new TCanvas();
0529   gStyle->SetOptStat("e");
0530   c9->Divide(2,2);
0531   c9->cd(1);
0532   res_hit_lut1->Draw("box");
0533   SetupTitle(res_hit_lut1,"Rec. Hit Energy (GeV)","(Rec E - Uncompressed TPG)/Rec E");
0534   c9->cd(2);
0535   res_hit_lut2->Draw("box");
0536   SetupTitle(res_hit_lut2,"Rec. Hit Energy (GeV)","(Rec E - Uncompressed TPG)/Rec E");
0537   c9->cd(3);
0538   res_hit_lut3->Draw("box");
0539   SetupTitle(res_hit_lut3,"Rec. Hit Energy (GeV)","(Rec E - Uncompressed TPG)/Rec E");
0540   c9->cd(4);
0541   res_hit_lut4->Draw("box");
0542   SetupTitle(res_hit_lut4,"Rec. Hit Energy (GeV)","(Rec E - Uncompressed TPG)/Rec E");
0543   c9->Print("output.ps");
0544   delete c9;
0545 
0546   //tower by tower resolutions
0547   TCanvas *c10 = new TCanvas();
0548   res2D_mean->Draw("COLZ");
0549   SetupTowerDisplay(res2D_mean);
0550   c10->Print("output.ps");
0551   delete c10;
0552 
0553   TCanvas *c11 = new TCanvas();
0554   res2D_rms->Draw("COLZ");
0555   SetupTowerDisplay(res2D_rms);
0556   c11->Print("output.ps");
0557   delete c11;
0558  
0559   TCanvas *c13 = new TCanvas();
0560   gStyle->SetOptStat("emruo");
0561   c13->Divide(2,2);
0562   c13->cd(1);
0563   res1D_mean_lut1->Draw();
0564   SetupTitle(res1D_mean_lut1,"Mean (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0565   SetStatus(res1D_mean_lut1,"UNCHECKED");
0566   c13->cd(2);
0567   res1D_mean_lut2->Draw();
0568   SetupTitle(res1D_mean_lut2,"Mean (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0569   SetStatus(res1D_mean_lut2,"UNCHECKED");
0570   c13->cd(3);
0571   res1D_mean_lut3->Draw();
0572   SetupTitle(res1D_mean_lut3,"Mean (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0573   SetStatus(res1D_mean_lut3,"UNCHECKED");
0574   c13->cd(4);
0575   res1D_mean_lut4->Draw();
0576   SetupTitle(res1D_mean_lut4,"Mean (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0577   SetStatus(res1D_mean_lut4,"UNCHECKED");
0578   c13->Print("output.ps");
0579   delete c13;
0580 
0581   TCanvas *c14 = new TCanvas();
0582   c14->Divide(2,2);
0583   c14->cd(1);
0584   res1D_rms_lut1->Draw();
0585   SetupTitle(res1D_rms_lut1,"RMS (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0586   SetStatus(res1D_rms_lut1,"UNCHECKED");
0587   c14->cd(2);
0588   res1D_rms_lut2->Draw();
0589   SetupTitle(res1D_rms_lut2,"RMS (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0590   SetStatus(res1D_rms_lut2,"UNCHECKED");
0591   c14->cd(3);
0592   res1D_rms_lut3->Draw();
0593   SetupTitle(res1D_rms_lut3,"RMS (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0594   SetStatus(res1D_rms_lut3,"UNCHECKED");
0595   c14->cd(4);
0596   res1D_rms_lut4->Draw();
0597   SetupTitle(res1D_rms_lut4,"RMS (Rec E - Uncompressed TPG)/Rec E","Ntowers");
0598   SetStatus(res1D_rms_lut4,"UNCHECKED");
0599   c14->Print("output.ps");
0600   delete c14;
0601 
0602   //nofire
0603   TCanvas *c18 = new TCanvas();
0604   nofire->Draw("COLZ");
0605   SetupTowerDisplay(nofire);
0606   c18->Print("output.ps");
0607   delete c18;
0608 
0609   //nofiresum
0610   TCanvas *c20 = new TCanvas();
0611   gStyle->SetOptStat("emruo");
0612   c20->Divide(2,2);
0613   c20->cd(1);
0614   nofiresum_lut1->Draw();
0615   SetupTitle(nofiresum_lut1,"Highest Energy with no TPG (GeV)","Ntowers");
0616   SetStatus(nofiresum_lut1,"UNCHECKED");
0617   c20->cd(2);
0618   SetupTitle(nofiresum_lut2,"Highest Energy with no TPG (GeV)","Ntowers");
0619   SetStatus(nofiresum_lut2,"UNCHECKED");
0620   nofiresum_lut2->Draw();
0621   c20->cd(3);
0622   SetupTitle(nofiresum_lut3,"Highest Energy with no TPG (GeV)","Ntowers");
0623   SetStatus(nofiresum_lut3,"UNCHECKED");
0624   nofiresum_lut3->Draw();
0625   c20->cd(4);
0626   SetupTitle(nofiresum_lut4,"Highest Energy with no TPG (GeV)","Ntowers");
0627   SetStatus(nofiresum_lut4,"UNCHECKED");
0628   nofiresum_lut4->Draw();
0629   c20->Print("output.ps");
0630   delete c20;
0631 
0632   //fakes
0633   TCanvas *c19 = new TCanvas();
0634   fakes->Draw("COLZ");
0635   SetupTowerDisplay(fakes);
0636   c19->Print("output.ps");
0637   delete c19;
0638 
0639   TCanvas *c21 = new TCanvas();
0640   gStyle->SetOptStat("emruo");
0641   c21->Divide(2,2);
0642   c21->cd(1);
0643   fakessum_lut1->Draw();
0644   SetupTitle(fakessum_lut1,"Uncompressed Energy of Fake TP (GeV)","Ntowers");
0645   SetStatus(fakessum_lut1,"UNCHECKED");
0646   c21->cd(2);
0647   fakessum_lut2->Draw();
0648   SetupTitle(fakessum_lut2,"Uncompressed Energy of Fake TP (GeV)","Ntowers");
0649   SetStatus(fakessum_lut2,"UNCHECKED");
0650   c21->cd(3);
0651   fakessum_lut3->Draw();
0652   SetupTitle(fakessum_lut3,"Uncompressed Energy of Fake TP (GeV)","Ntowers");
0653   SetStatus(fakessum_lut3,"UNCHECKED");
0654   c21->cd(4);
0655   fakessum_lut4->Draw();
0656   SetupTitle(fakessum_lut4,"Uncompressed Energy of Fake TP (GeV)","Ntowers");
0657   SetStatus(fakessum_lut4,"UNCHECKED");
0658   c21->Print("output.ps)");
0659   delete c21;
0660 
0661   TFile f(output_file,"recreate");
0662   efficiency.Write();
0663   nofire->Write();
0664   fakes->Write();
0665   resolution.Write();
0666   hit_tpg.Write();
0667   hslope->Write();
0668   slope_sum->Write();
0669   slope_eta->Write();
0670   res2D_mean->Write();
0671   res2D_rms->Write();
0672   res1D_mean_lut1->Write();
0673   res1D_rms_lut1->Write();
0674   res1D_mean_lut2->Write();
0675   res1D_rms_lut2->Write(); 
0676   res1D_mean_lut3->Write();
0677   res1D_rms_lut3->Write(); 
0678   res1D_mean_lut4->Write();
0679   res1D_rms_lut4->Write();
0680   heffic->Write();
0681   hthresh->Write();
0682   hwidth->Write();
0683   eff_lut1->Write();
0684   eff_lut2->Write();
0685   eff_lut3->Write();
0686   eff_lut4->Write();
0687   hit_tpg_lut1->Write();
0688   hit_tpg_lut2->Write();
0689   hit_tpg_lut3->Write();
0690   hit_tpg_lut4->Write();
0691   res_hit_lut1->Write();
0692   res_hit_lut2->Write();
0693   res_hit_lut3->Write();
0694   res_hit_lut4->Write();
0695   effsum_lut1->Write();
0696   effsum_lut2->Write();
0697   effsum_lut3->Write();
0698   effsum_lut4->Write();
0699   threshsum_lut1->Write();
0700   threshsum_lut2->Write();
0701   threshsum_lut3->Write();
0702   threshsum_lut4->Write();
0703   widthsum_lut1->Write();
0704   widthsum_lut2->Write();
0705   widthsum_lut3->Write();
0706   widthsum_lut4->Write();
0707   fakessum_lut1->Write();
0708   fakessum_lut2->Write();
0709   fakessum_lut3->Write();
0710   fakessum_lut4->Write();
0711   nofiresum_lut1->Write();
0712   nofiresum_lut2->Write();
0713   nofiresum_lut3->Write();
0714   nofiresum_lut4->Write();
0715   f.Close();
0716   
0717   file->Close();
0718   return 0;
0719 }
0720 
0721 double et2e(int eta)
0722 {
0723   switch (TMath::Abs(eta))
0724     {
0725     case 1:  
0726       return 1.001;
0727     case 2:
0728       return 1.009;
0729     case 3:
0730       return 1.024;
0731     case 4:
0732       return 1.047;
0733     case 5:
0734       return 1.078;
0735     case 6:
0736       return 1.117;
0737     case 7:
0738       return 1.164;
0739     case 8:
0740       return 1.221;
0741     case 9:
0742       return 1.286;
0743     case 10:
0744       return 1.361;
0745     case 11:    
0746       return 1.447;
0747     case 12:
0748       return 1.544;
0749     case 13:     
0750       return 1.652;
0751     case 14:     
0752       return 1.773;
0753     case 15:
0754       return 1.907;
0755     case 16:
0756       return 2.056;
0757     case 17:
0758       return 2.220;
0759     case 18:
0760       return 2.401;
0761     case 19:     
0762       return 2.600;
0763     case 20:     
0764       return 2.819;
0765     case 21:
0766       return 3.064;
0767     case 22:    
0768       return 3.353;
0769     case 23:     
0770       return 3.714;
0771     case 24:
0772       return 4.175;
0773     case 25:    
0774       return 4.806;
0775     case 26:    
0776       return 5.645;
0777     case 27:     
0778       return 6.604;
0779     case 28:     
0780       return 8.460;
0781     case 29:
0782       return 10.94;
0783     case 30:
0784       return 17.89;
0785     case 31:     
0786       return 30.21;
0787     case 32:
0788       return 59.38;
0789     default: 
0790       return -99999;
0791     }
0792 }