Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:33:05

0001 #include <TH2.h>
0002 #include <TStyle.h>
0003 #include <TCanvas.h>
0004 #include <TMath.h>
0005 #include <cmath>
0006 #include <TString.h>
0007 
0008 void CosmicRateTool_CosmicRates(const char *fileName, unsigned int runLow = 0, unsigned int runUp = 0) {
0009   TString InputFile = Form("%s", fileName);
0010   TFile *file = new TFile(InputFile);
0011 
0012   bool IsFileExist;
0013   IsFileExist = file->IsZombie();
0014   if (IsFileExist) {
0015     cout << endl
0016          << "====================================================================================================="
0017          << endl;
0018     cout << fileName << " is not found. Check the file!" << endl;
0019     cout << "====================================================================================================="
0020          << endl
0021          << endl;
0022     exit(EXIT_FAILURE);
0023   }
0024 
0025   TTree *tree;
0026   tree = (TTree *)file->Get("cosmicRateAnalyzer/Run");
0027 
0028   FILE *pFile;
0029   pFile = fopen("tracksInfo.txt", "w");
0030 
0031   double run_time;
0032   unsigned int runnum;
0033   int number_of_events;
0034   int number_of_tracks;
0035   int number_of_tracks_PIX;
0036   int number_of_tracks_FPIX;
0037   int number_of_tracks_BPIX;
0038   int number_of_tracks_TID;
0039   int number_of_tracks_TIDM;
0040   int number_of_tracks_TIDP;
0041   int number_of_tracks_TIB;
0042   int number_of_tracks_TEC;
0043   int number_of_tracks_TECP;
0044   int number_of_tracks_TECM;
0045   int number_of_tracks_TOB;
0046 
0047   tree->SetBranchAddress("run_time", &run_time);
0048   tree->SetBranchAddress("runnum", &runnum);
0049   tree->SetBranchAddress("number_of_events", &number_of_events);
0050   tree->SetBranchAddress("number_of_tracks", &number_of_tracks);
0051   tree->SetBranchAddress("number_of_tracks_PIX", &number_of_tracks_PIX);
0052   tree->SetBranchAddress("number_of_tracks_FPIX", &number_of_tracks_FPIX);
0053   tree->SetBranchAddress("number_of_tracks_BPIX", &number_of_tracks_BPIX);
0054   tree->SetBranchAddress("number_of_tracks_TID", &number_of_tracks_TID);
0055   tree->SetBranchAddress("number_of_tracks_TIDM", &number_of_tracks_TIDM);
0056   tree->SetBranchAddress("number_of_tracks_TIDP", &number_of_tracks_TIDP);
0057   tree->SetBranchAddress("number_of_tracks_TIB", &number_of_tracks_TIB);
0058   tree->SetBranchAddress("number_of_tracks_TEC", &number_of_tracks_TEC);
0059   tree->SetBranchAddress("number_of_tracks_TECP", &number_of_tracks_TECP);
0060   tree->SetBranchAddress("number_of_tracks_TECM", &number_of_tracks_TECM);
0061   tree->SetBranchAddress("number_of_tracks_TOB", &number_of_tracks_TOB);
0062 
0063   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0064   //        Various Rates Declerations
0065   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0066 
0067   vector<double> event_rate;
0068   vector<double> event_rate_err;
0069   vector<double> track_rate;
0070   vector<double> track_rate_err;
0071   vector<double> runNumber;
0072   vector<double> runNumber_err;
0073   vector<double> track_rate_PIX;
0074   vector<double> track_rate_PIX_err;
0075   vector<double> track_rate_FPIX;
0076   vector<double> track_rate_FPIX_err;
0077   vector<double> track_rate_BPIX;
0078   vector<double> track_rate_BPIX_err;
0079   vector<double> track_rate_TOB;
0080   vector<double> track_rate_TOB_err;
0081   vector<double> track_rate_TIB;
0082   vector<double> track_rate_TIB_err;
0083   vector<double> track_rate_TID;
0084   vector<double> track_rate_TID_err;
0085   vector<double> track_rate_TEC;
0086   vector<double> track_rate_TEC_err;
0087   vector<double> track_rate_TECP;
0088   vector<double> track_rate_TECP_err;
0089   vector<double> track_rate_TECM;
0090   vector<double> track_rate_TECM_err;
0091   vector<double> tracks;
0092   vector<double> tracks_err;
0093   vector<double> tracks_bpix;
0094   vector<double> tracks_fpix;
0095   vector<double> tracks_pix;
0096   vector<double> tracks_tec;
0097   vector<double> weight;
0098 
0099   string Bar_Xtitle[8] = {"Event", "Track", "FPIX", "BPIX", "TIB", "TID", "TOB", "TEC"};
0100   double Bar_Ytitle[8] = {0};
0101 
0102   int j = 0;
0103   double total_tracks = 0;
0104   double bpix_tracks = 0;
0105   double fpix_tracks = 0;
0106   double pix_tracks = 0;
0107   double tracks_TECoff = 0;
0108   int nTotalEvents = 0, nTotalTracks = 0;
0109 
0110   fprintf(pFile, "##################################################\n");
0111   fprintf(pFile, "         Track rate for each run number           \n");
0112   fprintf(pFile, "##################################################\n");
0113 
0114   Long64_t n = tree->GetEntriesFast();
0115   std::cout << "Total Runs in this file: " << n << endl;
0116   for (Long64_t jentry = 0; jentry < n; jentry++)  // Loop over Runs
0117   {
0118     tree->GetEntry(jentry);
0119     if (run_time == 0 || run_time < 0)
0120       continue;
0121 
0122     if (runLow != 0 && runUp != 0) {
0123       if (runnum < runLow)
0124         continue;
0125       if (runnum > runUp)
0126         break;
0127     }
0128 
0129     event_rate.push_back(number_of_events / run_time);
0130     runNumber.push_back(runnum);
0131     track_rate.push_back(number_of_tracks / run_time);
0132     track_rate_PIX.push_back(number_of_tracks_PIX / run_time);
0133     track_rate_FPIX.push_back(number_of_tracks_FPIX / run_time);
0134     track_rate_BPIX.push_back(number_of_tracks_BPIX / run_time);
0135     track_rate_TOB.push_back(number_of_tracks_TOB / run_time);
0136     track_rate_TIB.push_back(number_of_tracks_TIB / run_time);
0137     track_rate_TID.push_back(number_of_tracks_TID / run_time);
0138     track_rate_TEC.push_back(number_of_tracks_TEC / run_time);
0139     track_rate_TECP.push_back(number_of_tracks_TECP / run_time);
0140     track_rate_TECM.push_back(number_of_tracks_TECM / run_time);
0141     tracks.push_back(number_of_tracks);
0142     tracks_bpix.push_back(number_of_tracks_BPIX);
0143     tracks_fpix.push_back(number_of_tracks_FPIX);
0144     tracks_pix.push_back(number_of_tracks_PIX);
0145     tracks_tec.push_back(number_of_tracks_TECM);
0146     total_tracks += tracks[j];
0147     bpix_tracks += tracks_bpix[j];
0148     fpix_tracks += tracks_fpix[j];
0149     pix_tracks += tracks_pix[j];
0150     nTotalEvents += number_of_events;
0151     nTotalTracks += number_of_tracks;
0152 
0153     fprintf(pFile,
0154             "runnum :%-7.0lf, # of tracks :%-10.0lf, track rates :%-10.2lf\n",
0155             runNumber.at(j),
0156             tracks.at(j),
0157             track_rate.at(j));
0158     track_rate_err.push_back(sqrt(float(number_of_tracks)) / run_time);
0159     event_rate_err.push_back(sqrt(float(number_of_events)) / run_time);
0160     track_rate_PIX_err.push_back(sqrt(float(number_of_tracks_PIX)) / run_time);
0161     track_rate_FPIX_err.push_back(sqrt(float(number_of_tracks_FPIX)) / run_time);
0162     track_rate_BPIX_err.push_back(sqrt(float(number_of_tracks_BPIX)) / run_time);
0163     track_rate_TOB_err.push_back(sqrt(float(number_of_tracks_TOB)) / run_time);
0164     track_rate_TIB_err.push_back(sqrt(float(number_of_tracks_TIB)) / run_time);
0165     track_rate_TID_err.push_back(sqrt(float(number_of_tracks_TID)) / run_time);
0166     track_rate_TEC_err.push_back(sqrt(float(number_of_tracks_TEC)) / run_time);
0167     track_rate_TECP_err.push_back(sqrt(float(number_of_tracks_TECP)) / run_time);
0168     track_rate_TECM_err.push_back(sqrt(float(number_of_tracks_TECM)) / run_time);
0169 
0170     runNumber_err.push_back(0);
0171     if (number_of_tracks_TECM == 0) {
0172       tracks_TECoff += tracks.at(j);
0173     }
0174 
0175     j++;
0176   }  //Loop over runs closed
0177   std::cout << "Total Events: " << nTotalEvents << std::endl;
0178   std::cout << "Total Tracks: " << nTotalTracks << std::endl;
0179 
0180   fprintf(pFile, "\n\n");
0181   fprintf(pFile, "##################################################\n");
0182   fprintf(pFile, "    Some information on total number of tracks    \n");
0183   fprintf(pFile, "##################################################\n");
0184   fprintf(pFile, "Total # of tracks   : %-10.0lf\n", total_tracks);
0185   fprintf(pFile, "# of tracks in BPIX : %-10.0lf\n", bpix_tracks);
0186   fprintf(pFile, "# of tracks in FPIX : %-10.0lf\n", fpix_tracks);
0187   fprintf(pFile, "# of tracks in PIX  : %-10.0lf\n", pix_tracks);
0188   fprintf(pFile, "\n\n");
0189 
0190   fclose(pFile);
0191 
0192   //+++++++++++++++++++++++++++++       Make Directories     +++++++++++++++++++++++++++++++++++++
0193 
0194   gSystem->Exec("mkdir -p Rate_Plots");
0195 
0196   //----------------------------------------------------------------------------------------------
0197 
0198   TCanvas c("c1", "c1", 604, 82, 856, 836);  // Declare canvas
0199   gStyle->SetOptStat(0);
0200   c.Range(298434.4, -0.2989256, 299381.3, 2.010954);
0201   c.SetFillColor(0);
0202   c.SetBorderMode(0);
0203   c.SetBorderSize(2);
0204   c.SetTickx(1);
0205   c.SetTicky(1);
0206   c.SetGrid();
0207   c.SetLeftMargin(0.1883886);
0208   c.SetRightMargin(0.03909953);
0209   c.SetTopMargin(0.0875817);
0210   c.SetBottomMargin(0.1294118);
0211   c.SetFrameLineWidth(3);
0212   c.SetFrameBorderMode(0);
0213 
0214   //============  Text  =============//
0215   TLatex top_right_Title = TLatex();
0216   top_right_Title.SetTextFont(42);
0217   top_right_Title.SetTextSize(0.03717);
0218 
0219   TLatex detector = TLatex();
0220   detector.SetTextFont(62);
0221   detector.SetTextSize(0.047);
0222 
0223   //============  Declaring TVectors for TGraphs  =============//
0224   TVectorD event_rate_VecD;
0225   TVectorD event_rate_err_VecD;
0226   TVectorD track_rate_VecD;
0227   TVectorD track_rate_err_VecD;
0228   TVectorD runNumber_VecD;
0229   TVectorD runNumber_err_VecD;
0230   TVectorD track_rate_PIX_VecD;
0231   TVectorD track_rate_PIX_err_VecD;
0232   TVectorD track_rate_FPIX_VecD;
0233   TVectorD track_rate_FPIX_err_VecD;
0234   TVectorD track_rate_BPIX_VecD;
0235   TVectorD track_rate_BPIX_err_VecD;
0236   TVectorD track_rate_TOB_VecD;
0237   TVectorD track_rate_TOB_err_VecD;
0238   TVectorD track_rate_TIB_VecD;
0239   TVectorD track_rate_TIB_err_VecD;
0240   TVectorD track_rate_TID_VecD;
0241   TVectorD track_rate_TID_err_VecD;
0242   TVectorD track_rate_TEC_VecD;
0243   TVectorD track_rate_TEC_err_VecD;
0244   TVectorD track_rate_TECP_VecD;
0245   TVectorD track_rate_TECP_err_VecD;
0246   TVectorD track_rate_TECM_VecD;
0247   TVectorD track_rate_TECM_err_VecD;
0248 
0249   runNumber_VecD.Use(runNumber.size(), &(runNumber[0]));
0250   runNumber_err_VecD.Use(runNumber_err.size(), &(runNumber_err[0]));
0251   event_rate_VecD.Use(event_rate.size(), &(event_rate[0]));
0252   event_rate_err_VecD.Use(event_rate_err.size(), &(event_rate_err[0]));
0253 
0254   track_rate_VecD.Use(track_rate.size(), &(track_rate[0]));
0255   track_rate_err_VecD.Use(track_rate_err.size(), &(track_rate_err[0]));
0256 
0257   track_rate_PIX_VecD.Use(track_rate_PIX.size(), &(track_rate_PIX[0]));
0258   track_rate_PIX_err_VecD.Use(track_rate_PIX_err.size(), &(track_rate_PIX_err[0]));
0259   track_rate_FPIX_VecD.Use(track_rate_FPIX.size(), &(track_rate_FPIX[0]));
0260   track_rate_FPIX_err_VecD.Use(track_rate_FPIX_err.size(), &(track_rate_FPIX_err[0]));
0261   track_rate_BPIX_VecD.Use(track_rate_BPIX.size(), &(track_rate_BPIX[0]));
0262   track_rate_BPIX_err_VecD.Use(track_rate_BPIX_err.size(), &(track_rate_BPIX_err[0]));
0263   track_rate_TOB_VecD.Use(track_rate_TOB.size(), &(track_rate_TOB[0]));
0264   track_rate_TOB_err_VecD.Use(track_rate_TOB_err.size(), &(track_rate_TOB_err[0]));
0265   track_rate_TIB_VecD.Use(track_rate_TIB.size(), &(track_rate_TIB[0]));
0266   track_rate_TIB_err_VecD.Use(track_rate_TIB_err.size(), &(track_rate_TIB_err[0]));
0267   track_rate_TID_VecD.Use(track_rate_TID.size(), &(track_rate_TID[0]));
0268   track_rate_TID_err_VecD.Use(track_rate_TID_err.size(), &(track_rate_TID_err[0]));
0269   track_rate_TEC_VecD.Use(track_rate_TEC.size(), &(track_rate_TEC[0]));
0270   track_rate_TEC_err_VecD.Use(track_rate_TEC_err.size(), &(track_rate_TEC_err[0]));
0271   track_rate_TECP_VecD.Use(track_rate_TECP.size(), &(track_rate_TECP[0]));
0272   track_rate_TECP_err_VecD.Use(track_rate_TECP_err.size(), &(track_rate_TECP_err[0]));
0273   track_rate_TECM_VecD.Use(track_rate_TECM.size(), &(track_rate_TECM[0]));
0274   track_rate_TECM_err_VecD.Use(track_rate_TECM_err.size(), &(track_rate_TECM_err[0]));
0275 
0276   //+++++++++++++++++++++++++++++  Overall event event rate  +++++++++++++++++++++++++++++++++++++
0277 
0278   TGraphErrors gr_event_rate(runNumber_VecD, event_rate_VecD, runNumber_err_VecD, event_rate_err_VecD);
0279   gr_event_rate.GetXaxis()->SetTitle("Run Number");
0280   gr_event_rate.GetXaxis()->SetLabelSize(0.04);
0281   gr_event_rate.GetXaxis()->SetNoExponent();
0282   gr_event_rate.GetXaxis()->SetNdivisions(5);
0283   gr_event_rate.GetYaxis()->SetTitle("Event Rate (Hz)");
0284   gr_event_rate.GetXaxis()->SetTitleSize(0.05);
0285   gr_event_rate.GetYaxis()->SetLabelSize(0.05);
0286   gr_event_rate.GetYaxis()->SetTitleSize(0.05);
0287   gr_event_rate.SetMarkerStyle(20);
0288   gr_event_rate.SetMarkerSize(1.4);
0289   gr_event_rate.SetMarkerColor(kRed);
0290   gr_event_rate.SetTitle("");
0291   //gr_event_rate.GetYaxis()->SetRangeUser(0,7);
0292   gr_event_rate.Draw("AP");
0293   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0294   detector.DrawLatexNDC(0.23, 0.83, "Event Rate");
0295   c.SetGrid();
0296   c.SaveAs("event_rate.png");
0297   c.SaveAs("event_rate.pdf");
0298   c.SaveAs("event_rate.C");
0299   c.Clear();
0300   gSystem->Exec("mv event_rate.png Rate_Plots");
0301   gSystem->Exec("mv event_rate.pdf Rate_Plots");
0302   gSystem->Exec("mv event_rate.C Rate_Plots");
0303 
0304   //-----------------------------------------------------------------------------------------------
0305 
0306   //++++++++++++++++++++++++++++++  Overall track rate  +++++++++++++++++++++++++++++++++++++++++++
0307 
0308   TGraphErrors gr_track_rate(runNumber_VecD, track_rate_VecD, runNumber_err_VecD, track_rate_err_VecD);
0309   gr_track_rate.GetXaxis()->SetTitle("Run Number");
0310   gr_track_rate.GetXaxis()->SetLabelSize(0.04);
0311   gr_track_rate.GetXaxis()->SetNoExponent();
0312   gr_track_rate.GetXaxis()->SetNdivisions(5);
0313   gr_track_rate.GetYaxis()->SetTitle("Track Rate (Hz)");
0314   gr_track_rate.GetXaxis()->SetTitleSize(0.05);
0315   gr_track_rate.GetYaxis()->SetLabelSize(0.05);
0316   gr_track_rate.GetYaxis()->SetTitleSize(0.05);
0317   gr_track_rate.SetMarkerStyle(20);
0318   gr_track_rate.SetMarkerSize(1.4);
0319   gr_track_rate.SetMarkerColor(kRed);
0320   gr_track_rate.SetTitle("");
0321   gr_track_rate.Draw("AP");
0322   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0323   detector.DrawLatexNDC(0.23, 0.83, "Track Rate");
0324   c.SetGrid();
0325   c.SaveAs("track_rate.png");
0326   c.SaveAs("track_rate.pdf");
0327   c.SaveAs("track_rate.C");
0328   c.Clear();
0329   gSystem->Exec("mv track_rate.png Rate_Plots");
0330   gSystem->Exec("mv track_rate.pdf Rate_Plots");
0331   gSystem->Exec("mv track_rate.C Rate_Plots");
0332 
0333   //-----------------------------------------------------------------------------------------------
0334 
0335   //+++++++++++++++++++++++++++++++  Total Pixel track rate +++++++++++++++++++++++++++++++++++++++
0336 
0337   TGraphErrors gr_track_rate_PIX(runNumber_VecD, track_rate_PIX_VecD, runNumber_err_VecD, track_rate_PIX_err_VecD);
0338   gr_track_rate_PIX.GetXaxis()->SetTitle("Run Number");
0339   gr_track_rate_PIX.GetXaxis()->SetLabelSize(0.04);
0340   gr_track_rate_PIX.GetXaxis()->SetNoExponent();
0341   gr_track_rate_PIX.GetXaxis()->SetNdivisions(5);
0342   gr_track_rate_PIX.GetYaxis()->SetTitle("Track Rate (Hz)");
0343   gr_track_rate_PIX.GetXaxis()->SetTitleSize(0.05);
0344   gr_track_rate_PIX.GetYaxis()->SetLabelSize(0.05);
0345   gr_track_rate_PIX.GetYaxis()->SetTitleSize(0.05);
0346   gr_track_rate_PIX.SetMarkerStyle(20);
0347   gr_track_rate_PIX.SetMarkerSize(1.4);
0348   gr_track_rate_PIX.SetMarkerColor(2);
0349   gr_track_rate_PIX.SetTitle("");
0350   gr_track_rate_PIX.Draw("AP");
0351   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0352   detector.DrawLatexNDC(0.23, 0.83, "PIXEL");
0353   c.SetGrid();
0354   c.SaveAs("pixel_track_rate.png");
0355   c.SaveAs("pixel_track_rate.pdf");
0356   c.SaveAs("pixel_track_rate.C");
0357   c.Clear();
0358   gSystem->Exec("mv pixel_track_rate.png Rate_Plots");
0359   gSystem->Exec("mv pixel_track_rate.pdf Rate_Plots");
0360   gSystem->Exec("mv pixel_track_rate.C Rate_Plots");
0361 
0362   //-----------------------------------------------------------------------------------------------
0363 
0364   //++++++++++++++++++++++++++++++++  FPIX track rate  ++++++++++++++++++++++++++++++++++++++++++++
0365 
0366   TGraphErrors gr_track_rate_FPIX(runNumber_VecD, track_rate_FPIX_VecD, runNumber_err_VecD, track_rate_FPIX_err_VecD);
0367   gr_track_rate_FPIX.GetXaxis()->SetTitle("Run Number");
0368   gr_track_rate_FPIX.GetXaxis()->SetLabelSize(0.04);
0369   gr_track_rate_FPIX.GetXaxis()->SetNoExponent();
0370   gr_track_rate_FPIX.GetXaxis()->SetNdivisions(5);
0371   gr_track_rate_FPIX.GetYaxis()->SetTitle("Track Rate (Hz)");
0372   gr_track_rate_FPIX.GetXaxis()->SetTitleSize(0.05);
0373   gr_track_rate_FPIX.GetYaxis()->SetLabelSize(0.05);
0374   gr_track_rate_FPIX.GetYaxis()->SetTitleSize(0.05);
0375   gr_track_rate_FPIX.SetMarkerStyle(20);
0376   gr_track_rate_FPIX.SetMarkerSize(1.4);
0377   gr_track_rate_FPIX.SetMarkerColor(kRed);
0378   gr_track_rate_FPIX.SetTitle("");
0379   gr_track_rate_FPIX.Draw("AP");
0380   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0381   detector.DrawLatexNDC(0.23, 0.83, "FPIX");
0382   c.SetGrid();
0383   c.SaveAs("fpix_track_rate.png");
0384   c.SaveAs("fpix_track_rate.pdf");
0385   c.SaveAs("fpix_track_rate.C");
0386   c.Clear();
0387   gSystem->Exec("mv fpix_track_rate.png Rate_Plots");
0388   gSystem->Exec("mv fpix_track_rate.pdf Rate_Plots");
0389   gSystem->Exec("mv fpix_track_rate.C Rate_Plots");
0390 
0391   //-----------------------------------------------------------------------------------------------
0392 
0393   //++++++++++++++++++++++++++++++++  BPIX track rate  ++++++++++++++++++++++++++++++++++++++++++++
0394 
0395   TGraphErrors gr_track_rate_BPIX(runNumber_VecD, track_rate_BPIX_VecD, runNumber_err_VecD, track_rate_BPIX_err_VecD);
0396   gr_track_rate_BPIX.GetXaxis()->SetTitle("Run Number");
0397   gr_track_rate_BPIX.GetXaxis()->SetLabelSize(0.04);
0398   gr_track_rate_BPIX.GetXaxis()->SetNoExponent();
0399   gr_track_rate_BPIX.GetXaxis()->SetNdivisions(5);
0400   gr_track_rate_BPIX.GetYaxis()->SetTitle("Track Rate (Hz)");
0401   gr_track_rate_BPIX.GetXaxis()->SetTitleSize(0.05);
0402   gr_track_rate_BPIX.GetYaxis()->SetLabelSize(0.05);
0403   gr_track_rate_BPIX.GetYaxis()->SetTitleSize(0.05);
0404   gr_track_rate_BPIX.SetMarkerStyle(20);
0405   gr_track_rate_BPIX.SetMarkerSize(1.4);
0406   gr_track_rate_BPIX.SetMarkerColor(2);
0407   gr_track_rate_BPIX.SetTitle("");
0408   gr_track_rate_BPIX.Draw("AP");
0409   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0410   detector.DrawLatexNDC(0.23, 0.83, "BPIX");
0411   c.SetGrid();
0412   c.SaveAs("bpix_track_rate.png");
0413   c.SaveAs("bpix_track_rate.pdf");
0414   c.SaveAs("bpix_track_rate.C");
0415   c.Clear();
0416   gSystem->Exec("mv bpix_track_rate.png Rate_Plots");
0417   gSystem->Exec("mv bpix_track_rate.pdf Rate_Plots");
0418   gSystem->Exec("mv bpix_track_rate.C Rate_Plots");
0419 
0420   //-----------------------------------------------------------------------------------------------
0421 
0422   //++++++++++++++++++++++++++++++++  TOB track rate  ++++++++++++++++++++++++++++++++++++++++++++
0423 
0424   TGraphErrors gr_track_rate_TOB(runNumber_VecD, track_rate_TOB_VecD, runNumber_err_VecD, track_rate_TOB_err_VecD);
0425   gr_track_rate_TOB.GetXaxis()->SetTitle("Run Number");
0426   gr_track_rate_TOB.GetXaxis()->SetLabelSize(0.04);
0427   gr_track_rate_TOB.GetXaxis()->SetNoExponent();
0428   gr_track_rate_TOB.GetXaxis()->SetNdivisions(5);
0429   gr_track_rate_TOB.GetYaxis()->SetTitle("Track Rate (Hz)");
0430   gr_track_rate_TOB.GetXaxis()->SetTitleSize(0.05);
0431   gr_track_rate_TOB.GetYaxis()->SetLabelSize(0.05);
0432   gr_track_rate_TOB.GetYaxis()->SetTitleSize(0.05);
0433   gr_track_rate_TOB.SetMarkerStyle(20);
0434   gr_track_rate_TOB.SetMarkerSize(1.4);
0435   gr_track_rate_TOB.SetMarkerColor(2);
0436   gr_track_rate_TOB.SetTitle("");
0437   gr_track_rate_TOB.Draw("AP");
0438   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0439   detector.DrawLatexNDC(0.23, 0.83, "TOB");
0440   c.SetGrid();
0441   c.SaveAs("tob_track_rate.png");
0442   c.SaveAs("tob_track_rate.pdf");
0443   c.SaveAs("tob_track_rate.C");
0444   c.Clear();
0445   gSystem->Exec("mv tob_track_rate.png Rate_Plots");
0446   gSystem->Exec("mv tob_track_rate.C Rate_Plots");
0447   gSystem->Exec("mv tob_track_rate.pdf Rate_Plots");
0448 
0449   //-----------------------------------------------------------------------------------------------
0450 
0451   //++++++++++++++++++++++++++++++++  TIB track rate  ++++++++++++++++++++++++++++++++++++++++++++
0452 
0453   TGraphErrors gr_track_rate_TIB(runNumber_VecD, track_rate_TIB_VecD, runNumber_err_VecD, track_rate_TIB_err_VecD);
0454   gr_track_rate_TIB.GetXaxis()->SetTitle("Run Number");
0455   gr_track_rate_TIB.GetXaxis()->SetLabelSize(0.04);
0456   gr_track_rate_TIB.GetXaxis()->SetNoExponent();
0457   gr_track_rate_TIB.GetXaxis()->SetNdivisions(5);
0458   gr_track_rate_TIB.GetYaxis()->SetTitle("Track Rate (Hz)");
0459   gr_track_rate_TIB.GetXaxis()->SetTitleSize(0.05);
0460   gr_track_rate_TIB.GetYaxis()->SetLabelSize(0.05);
0461   gr_track_rate_TIB.GetYaxis()->SetTitleSize(0.05);
0462   gr_track_rate_TIB.SetMarkerStyle(20);
0463   gr_track_rate_TIB.SetMarkerSize(1.4);
0464   gr_track_rate_TIB.SetMarkerColor(2);
0465   gr_track_rate_TIB.SetTitle("");
0466   gr_track_rate_TIB.Draw("AP");
0467   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0468   detector.DrawLatexNDC(0.23, 0.83, "TIB");
0469   c.SetGrid();
0470   c.SaveAs("tib_track_rate.png");
0471   c.SaveAs("tib_track_rate.pdf");
0472   c.SaveAs("tib_track_rate.C");
0473   c.Clear();
0474   gSystem->Exec("mv tib_track_rate.png Rate_Plots");
0475   gSystem->Exec("mv tib_track_rate.pdf Rate_Plots");
0476   gSystem->Exec("mv tib_track_rate.C Rate_Plots");
0477 
0478   //-----------------------------------------------------------------------------------------------
0479 
0480   //++++++++++++++++++++++++++++++++  TID track rate  ++++++++++++++++++++++++++++++++++++++++++++
0481 
0482   TGraphErrors gr_track_rate_TID(runNumber_VecD, track_rate_TID_VecD, runNumber_err_VecD, track_rate_TID_err_VecD);
0483   gr_track_rate_TID.GetXaxis()->SetTitle("Run Number");
0484   gr_track_rate_TID.GetXaxis()->SetLabelSize(0.04);
0485   gr_track_rate_TID.GetXaxis()->SetNoExponent();
0486   gr_track_rate_TID.GetXaxis()->SetNdivisions(5);
0487   gr_track_rate_TID.GetYaxis()->SetTitle("Track Rate (Hz)");
0488   gr_track_rate_TID.GetXaxis()->SetTitleSize(0.05);
0489   gr_track_rate_TID.GetYaxis()->SetLabelSize(0.05);
0490   gr_track_rate_TID.GetYaxis()->SetTitleSize(0.05);
0491   gr_track_rate_TID.SetMarkerStyle(20);
0492   gr_track_rate_TID.SetMarkerSize(1.4);
0493   gr_track_rate_TID.SetMarkerColor(2);
0494   gr_track_rate_TID.SetTitle("");
0495   gr_track_rate_TID.Draw("AP");
0496   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0497   detector.DrawLatexNDC(0.23, 0.83, "TID");
0498   c.SetGrid();
0499   c.SaveAs("tid_track_rate.png");
0500   c.SaveAs("tid_track_rate.pdf");
0501   c.SaveAs("tid_track_rate.C");
0502   c.Clear();
0503   gSystem->Exec("mv tid_track_rate.png Rate_Plots");
0504   gSystem->Exec("mv tid_track_rate.pdf Rate_Plots");
0505   gSystem->Exec("mv tid_track_rate.C Rate_Plots");
0506 
0507   //-----------------------------------------------------------------------------------------------
0508 
0509   //++++++++++++++++++++++++++++++++  Total TEC track rate  ++++++++++++++++++++++++++++++++++++++++++++
0510 
0511   TGraphErrors gr_track_rate_TEC(runNumber_VecD, track_rate_TEC_VecD, runNumber_err_VecD, track_rate_TEC_err_VecD);
0512   gr_track_rate_TEC.GetXaxis()->SetTitle("Run Number");
0513   gr_track_rate_TEC.GetXaxis()->SetLabelSize(0.04);
0514   gr_track_rate_TEC.GetXaxis()->SetNoExponent();
0515   gr_track_rate_TEC.GetXaxis()->SetNdivisions(5);
0516   gr_track_rate_TEC.GetYaxis()->SetTitle("Track Rate (Hz)");
0517   gr_track_rate_TEC.GetXaxis()->SetTitleSize(0.05);
0518   gr_track_rate_TEC.GetYaxis()->SetLabelSize(0.05);
0519   gr_track_rate_TEC.GetYaxis()->SetTitleSize(0.05);
0520   gr_track_rate_TEC.SetMarkerStyle(20);
0521   gr_track_rate_TEC.SetMarkerSize(1.4);
0522   gr_track_rate_TEC.SetMarkerColor(kRed);
0523   gr_track_rate_TEC.SetTitle("");
0524   gr_track_rate_TEC.Draw("AP");
0525   top_right_Title.DrawLatexNDC(0.79, 0.94, "cosmic rays");
0526   detector.DrawLatexNDC(0.23, 0.83, "TEC");
0527   c.SetGrid();
0528   c.SaveAs("tec_track_rate.png");
0529   c.SaveAs("tec_track_rate.pdf");
0530   c.SaveAs("tec_track_rate.C");
0531   c.Clear();
0532   gSystem->Exec("mv tec_track_rate.png Rate_Plots");
0533   gSystem->Exec("mv tec_track_rate.pdf Rate_Plots");
0534   gSystem->Exec("mv tec_track_rate.C Rate_Plots");
0535 
0536   //-----------------------------------------------------------------------------------------------
0537 
0538   //++++++++++++++++++++++++++++++++  TEC+/- track rate  ++++++++++++++++++++++++++++++++++++++++++++
0539   TMultiGraph mg("track rate", "Track Rate TEC+/-");  // Multigraph decleration
0540 
0541   TGraphErrors *gr_track_rate_TECP =
0542       new TGraphErrors(runNumber_VecD, track_rate_TECP_VecD, runNumber_err_VecD, track_rate_TECP_err_VecD);
0543   gr_track_rate_TECP->SetMarkerStyle(20);
0544   gr_track_rate_TECP->SetMarkerSize(1.4);
0545   gr_track_rate_TECP->SetMarkerColor(kBlack);
0546 
0547   TGraphErrors *gr_track_rate_TECM =
0548       new TGraphErrors(runNumber_VecD, track_rate_TECM_VecD, runNumber_err_VecD, track_rate_TECM_err_VecD);
0549   gr_track_rate_TECM->SetMarkerStyle(20);
0550   gr_track_rate_TECM->SetMarkerSize(1.4);
0551   gr_track_rate_TECM->SetMarkerColor(kGreen);
0552 
0553   mg.Add(gr_track_rate_TECP);
0554   mg.Add(gr_track_rate_TECM);
0555   mg.Draw("AP");
0556   mg.GetXaxis()->SetTitle("Run Number");
0557   mg.GetXaxis()->SetNoExponent();
0558   mg.GetXaxis()->SetNdivisions(5);
0559   mg.GetXaxis()->SetLabelSize(0.04);
0560   mg.GetXaxis()->SetTitleSize(0.05);
0561   mg.GetYaxis()->SetLabelSize(0.05);
0562   mg.GetYaxis()->SetTitleSize(0.05);
0563   mg.GetYaxis()->SetTitle("Track Rate (Hz)");
0564 
0565   TLegend leg(0.76, 0.76, 0.92, 0.90);  // Legend for TEC+/-
0566   leg.AddEntry(gr_track_rate_TECP, "TEC+", "p");
0567   leg.AddEntry(gr_track_rate_TECM, "TEC-", "p");
0568   leg.SetBorderSize(1);
0569   leg.SetShadowColor(0);
0570   leg.SetFillColor(0);
0571   leg.Draw();
0572   c.SetGrid();
0573   c.SaveAs("tec_track_ratePM.png");
0574   c.Clear();
0575   gSystem->Exec("mv tec_track_ratePM.png Rate_Plots");
0576 
0577   //-----------------------------------------------------------------------------------------------
0578 
0579   c.Close();
0580 
0581   //-----------------------------------------------------------------------------------------------
0582   //                    Weighted Mean calculation
0583   //-----------------------------------------------------------------------------------------------
0584 
0585   double total_weight = 0;
0586   double weighted_mean_track_rate;
0587   double weighted_mean_track_rate_TEC;
0588   double weighted_mean_track_rate_TOB;
0589   double weighted_mean_track_rate_TIB;
0590   double weighted_mean_track_rate_TID;
0591   double weighted_mean_track_rate_FPIX;
0592   double weighted_mean_track_rate_BPIX;
0593   double weighted_mean_event_rate;
0594 
0595   for (int k = 0; k < j; k++)  // Loop over all runs used(j) to allot weight to each run number
0596   {
0597     weight.push_back(tracks.at(k) / total_tracks);
0598   }
0599 
0600   for (int a = 0; a < j; a++)  // Loop over all runs used(j) to evaluate weighted mean for each subdetector
0601   {
0602     weighted_mean_track_rate += track_rate.at(a) * weight.at(a);
0603     weighted_mean_track_rate_TEC += track_rate_TEC.at(a) * weight.at(a);
0604     weighted_mean_track_rate_TOB += track_rate_TOB.at(a) * weight.at(a);
0605     weighted_mean_track_rate_TIB += track_rate_TIB.at(a) * weight.at(a);
0606     weighted_mean_track_rate_TID += track_rate_TID.at(a) * weight.at(a);
0607     weighted_mean_track_rate_FPIX += track_rate_FPIX.at(a) * weight.at(a);
0608     weighted_mean_track_rate_BPIX += track_rate_BPIX.at(a) * weight.at(a);
0609     weighted_mean_event_rate += event_rate.at(a) * weight.at(a);
0610     total_weight += weight.at(a);
0611   }
0612 
0613   std::cout << " Weighted mean Event Rate : " << weighted_mean_event_rate << std::endl;
0614   std::cout << " Weighted mean Total Track Rate : " << weighted_mean_track_rate << std::endl;
0615   std::cout << " Weighted mean Track Rate BPIX: " << weighted_mean_track_rate_BPIX << std::endl;
0616   std::cout << " Weighted mean Track Rate FPIX : " << weighted_mean_track_rate_FPIX << std::endl;
0617   std::cout << " Weighted mean Track Rate TIB: " << weighted_mean_track_rate_TIB << std::endl;
0618   std::cout << " Weighted mean Track Rate TOB: " << weighted_mean_track_rate_TOB << std::endl;
0619   std::cout << " Weighted mean Track Rate TID: " << weighted_mean_track_rate_TID << std::endl;
0620   std::cout << " Weighted mean Track Rate TEC: " << weighted_mean_track_rate_TEC << std::endl;
0621 
0622   //-----------------------------------------------------------------------------------------------
0623   //            Summary Plot for track rate in each Subdetector
0624   //-----------------------------------------------------------------------------------------------
0625 
0626   TCanvas *canvas = new TCanvas("canvas", "canvas", 324, 57, 953, 866);
0627   canvas->SetFillColor(0);
0628   canvas->SetBorderMode(0);
0629   canvas->SetBorderSize(2);
0630   canvas->SetGridx();
0631   canvas->SetGridy();
0632   canvas->SetTickx(1);
0633   canvas->SetTicky(1);
0634   canvas->SetLeftMargin(0.1608833);
0635   canvas->SetRightMargin(0.05152471);
0636   canvas->SetFrameLineWidth(3);
0637   canvas->SetFrameBorderMode(0);
0638   canvas->SetFrameLineWidth(3);
0639   canvas->SetFrameBorderMode(0);
0640 
0641   TH1F h1b("h1b", "Track Rate Summary", 8, 0, 8);
0642   h1b.SetFillColor(kRed);
0643   h1b.SetBarWidth(0.6);
0644   h1b.SetBarOffset(0.25);
0645   h1b.SetStats(0);
0646   h1b.GetXaxis()->SetLabelFont(42);
0647   h1b.GetXaxis()->SetLabelOffset(0.012);
0648   h1b.GetXaxis()->SetLabelSize(0.06);
0649   h1b.GetXaxis()->SetTitleSize(0.05);
0650   h1b.GetXaxis()->SetTitleFont(42);
0651   h1b.GetYaxis()->SetTitle("Average Track Rate (Hz)");
0652   h1b.GetYaxis()->SetLabelFont(42);
0653   h1b.GetYaxis()->SetLabelSize(0.05);
0654   h1b.GetYaxis()->SetTitleSize(0.05);
0655   h1b.GetYaxis()->SetTitleOffset(0);
0656 
0657   Bar_Ytitle[0] = weighted_mean_event_rate;
0658   Bar_Ytitle[1] = weighted_mean_track_rate;
0659   Bar_Ytitle[2] = weighted_mean_track_rate_FPIX;
0660   Bar_Ytitle[3] = weighted_mean_track_rate_BPIX;
0661   Bar_Ytitle[4] = weighted_mean_track_rate_TIB;
0662   Bar_Ytitle[5] = weighted_mean_track_rate_TID;
0663   Bar_Ytitle[6] = weighted_mean_track_rate_TOB;
0664   Bar_Ytitle[7] = weighted_mean_track_rate_TEC;
0665 
0666   for (int i = 1; i <= 8; i++) {
0667     h1b.SetBinContent(i, Bar_Ytitle[i - 1]);
0668     h1b.GetXaxis()->SetBinLabel(i, Bar_Xtitle[i - 1].c_str());
0669   }
0670 
0671   gStyle->SetPaintTextFormat("1.3f");
0672   h1b.LabelsOption("d");
0673   h1b.Draw("bTEXT");
0674 
0675   // --------- Saving Summary Chart in pdf,png & C formats ------- //
0676   TString summary_chart_title = "SummaryChart";
0677   TString Format[3] = {"png", "pdf", "C"};
0678 
0679   for (int i = 0; i < 3; i++) {
0680     TString filename = summary_chart_title + "." + Format[i];
0681     canvas->SaveAs(filename.Data());
0682     TString mv_cmd = "mv " + filename + " Rate_Plots";
0683     gSystem->Exec(mv_cmd.Data());
0684   }
0685   canvas->Clear();
0686   canvas->Close();
0687 }