ATLAS Offline Software
Functions
L1CaloPprPhos4ShapeCollection.cxx File Reference
#include "TrigT1CaloCalibTools/L1CaloPprPhos4ShapeCollection.h"
#include "TrigT1CaloCalibConditions/ChanCalibErrorCode.h"
#include "TrigT1CaloCalibConditions/L1CaloCoolChannelId.h"
#include <sstream>
#include <unistd.h>
#include "TTree.h"
#include "TFile.h"
#include "TProfile.h"
#include "TH1.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TSystem.h"
#include "TPaveText.h"
#include "LWHists/TH2F_LW.h"

Go to the source code of this file.

Functions

StatusCode L1CaloPprPhos4ShapeCollection::Finalize ATLAS_NOT_REENTRANT (void)
 

Function Documentation

◆ ATLAS_NOT_REENTRANT()

StatusCode L1CaloPprPhos4ShapeCollection::Finalize ATLAS_NOT_REENTRANT ( void  )

Definition at line 226 of file L1CaloPprPhos4ShapeCollection.cxx.

226  {
227 
228  // want to store the profiles and histograms for each cool id into
229  // a TTree, which will be output to a file.
230 
231  ATH_MSG_INFO("[Finalize] In Finalize()");
232 
233  // open the output file
234  std::string filename;
235  if (m_runNumberStr.empty()) {
236  filename = (m_outputFileDirName + '/' + m_outputFileName + '.' + m_outputFileNamePostfix);
237  }
238  else {
239  filename = (m_outputFileDirName + '/' + m_outputFileName + '_' + m_runNumberStr + '.' + m_outputFileNamePostfix);
240  }
241 
242  ATH_MSG_INFO("[Finalize] Opening output file: " << filename);
243  TFile* outputFile = new TFile(filename.c_str(), "RECREATE");
244  if (!outputFile->IsOpen()) {
245  ATH_MSG_ERROR("[Finalize]: Could not open file for TTree output: " << filename);
246 
247  delete outputFile; outputFile = 0;
248  return StatusCode::FAILURE;
249  }
250 
251 
252  ATH_MSG_INFO("[Finalize] Create TTree");
253 
254  TTree* tree = new TTree("phos4signalShapes", "phos4signalShapes");
255 
256  tree->Branch(m_coolIdName.c_str(), &m_coolId, std::string(m_coolIdName + "/i").c_str());
257 
258  tree->Branch(m_isEnabledName.c_str(), &m_isEnabled, std::string(m_isEnabledName + "/O").c_str());
259  tree->Branch(m_isValidName.c_str(), &m_isValid, std::string(m_isValidName + "/O").c_str());
260  tree->Branch(m_isProcessedName.c_str(), &m_isProcessed, std::string(m_isProcessedName + "/O").c_str());
261 
262  tree->Branch(m_rawSignalShapeName.c_str(), &m_rawSignalShape);
263  tree->Branch(m_rawMaxPeakBinName.c_str(), &m_rawMaxPeakBin, std::string(m_rawMaxPeakBinName + "/i").c_str());
264  tree->Branch(m_rawMaxPeakValueName.c_str(), &m_rawMaxPeakValue, std::string(m_rawMaxPeakValueName + "/F").c_str());
265  tree->Branch(m_rawMaxFullDelayDataName.c_str(), &m_rawMaxFullDelayData, std::string(m_rawMaxFullDelayDataName + "/i").c_str());
266  tree->Branch(m_rawFitPeakBinName.c_str(), &m_rawFitPeakBin, std::string(m_rawFitPeakBinName + "/i").c_str());
267  tree->Branch(m_rawFitPeakValueName.c_str(), &m_rawFitPeakValue, std::string(m_rawFitPeakValueName + "/F").c_str());
268  tree->Branch(m_rawFitFullDelayDataName.c_str(), &m_rawFitFullDelayData, std::string(m_rawFitFullDelayDataName + "/i").c_str());
269  tree->Branch(m_rawFitPerformedName.c_str(), &m_rawFitPerformed, std::string(m_rawFitPerformedName + "/O").c_str());
270 
271  tree->Branch(m_rawFitName.c_str(), &m_rawFit);
272 
273  tree->Branch(m_pedestalMeanName.c_str(), &m_pedestalMean, std::string(m_pedestalMeanName + "/F").c_str());
274  tree->Branch(m_pedestalSigmaName.c_str(), &m_pedestalSigma, std::string(m_pedestalSigmaName + "/F").c_str());
275 
276  tree->Branch(m_processedSignalShapeName.c_str(), &m_processedSignalShape);
277  tree->Branch(m_processedMaxPeakBinName.c_str(), &m_processedMaxPeakBin, std::string(m_processedMaxPeakBinName + "/i").c_str());
278  tree->Branch(m_processedMaxPeakValueName.c_str(), &m_processedMaxPeakValue, std::string(m_processedMaxPeakValueName + "/F").c_str());
279  tree->Branch(m_processedMaxFullDelayDataName.c_str(), &m_processedMaxFullDelayData, std::string(m_processedMaxFullDelayDataName + "/i").c_str());
280  tree->Branch(m_processedFitPeakBinName.c_str(), &m_processedFitPeakBin, std::string(m_processedFitPeakBinName + "/i").c_str());
281  tree->Branch(m_processedFitPeakValueName.c_str(), &m_processedFitPeakValue, std::string(m_processedFitPeakValueName + "/F").c_str());
282  tree->Branch(m_processedFitFullDelayDataName.c_str(), &m_processedFitFullDelayData, std::string(m_processedFitFullDelayDataName + "/i").c_str());
283  tree->Branch(m_processedFitPerformedName.c_str(), &m_processedFitPerformed, std::string(m_processedFitPerformedName + "/O").c_str());
284 
285  tree->Branch(m_processedFitName.c_str(), &m_processedFit);
286 
287  tree->Branch(m_risingSlopeMeanName.c_str(), &m_risingSlopeMean, std::string(m_risingSlopeMeanName + "/F").c_str());
288  tree->Branch(m_risingSlopeSigmaName.c_str(), &m_risingSlopeSigma, std::string(m_risingSlopeSigmaName + "/F").c_str());
289 
290  tree->Branch(m_errorCodeName.c_str(), &m_errorCode, std::string(m_errorCodeName + "/i").c_str());
291 
292  tree->Branch(m_currentFullDelayDataName.c_str(), &m_currentFullDelayData, std::string(m_currentFullDelayDataName + "/i").c_str());
293 
294  ATH_MSG_INFO("[Finalize] Looping over shapes for processing.");
295 
296  // open a file to output each of the new FullDelayData values for the database
297  std::string dbFilename_rawMax;
298  std::string dbFilename_rawFit;
299  std::string dbFilename_processedMax;
300  std::string dbFilename_processedFit;
301  if (m_runNumberStr.empty()) {
302  dbFilename_rawMax = (m_outputFileDirName + '/' + m_dbFileName_rawMax + '.' + m_outDBFileNamePostfix);
303  dbFilename_rawFit = (m_outputFileDirName + '/' + m_dbFileName_rawFit + '.' + m_outDBFileNamePostfix);
304  dbFilename_processedMax = (m_outputFileDirName + '/' + m_dbFileName_processedMax + '.' + m_outDBFileNamePostfix);
305  dbFilename_processedFit = (m_outputFileDirName + '/' + m_dbFileName_processedFit + '.' + m_outDBFileNamePostfix);
306  }
307  else {
308  dbFilename_rawMax = (m_outputFileDirName + '/' + m_dbFileName_rawMax + '_' + m_runNumberStr + '.' + m_outDBFileNamePostfix);
309  dbFilename_rawFit = (m_outputFileDirName + '/' + m_dbFileName_rawFit + '_' + m_runNumberStr + '.' + m_outDBFileNamePostfix);
310  dbFilename_processedMax = (m_outputFileDirName + '/' + m_dbFileName_processedMax + '_' + m_runNumberStr + '.' + m_outDBFileNamePostfix);
311  dbFilename_processedFit = (m_outputFileDirName + '/' + m_dbFileName_processedFit + '_' + m_runNumberStr + '.' + m_outDBFileNamePostfix);
312  }
313  std::ofstream dbFile_rawMax(dbFilename_rawMax.c_str());
314  if (!dbFile_rawMax.is_open()) {
315  ATH_MSG_ERROR("[Finalize]: Failed to open file for database output, " << dbFilename_rawMax);
316  }
317  std::ofstream dbFile_rawFit(dbFilename_rawFit.c_str());
318  if (!dbFile_rawFit.is_open()) {
319  ATH_MSG_ERROR("[Finalize]: Failed to open file for database output, " << dbFilename_rawFit);
320  }
321  std::ofstream dbFile_processedMax(dbFilename_processedMax.c_str());
322  if (!dbFile_processedMax.is_open()) {
323  ATH_MSG_ERROR("[Finalize]: Failed to open file for database output, " << dbFilename_processedMax);
324  }
325  std::ofstream dbFile_processedFit(dbFilename_processedFit.c_str());
326  if (!dbFile_processedFit.is_open()) {
327  ATH_MSG_ERROR("[Finalize]: Failed to open file for database output, " << dbFilename_processedFit);
328  }
329 
331  // need a canvas to putput the postscript file containing
332  // the raw and processed histograms
333  // Adding two more canvases to output the channels
334  // with errors which will be saved to a different file
335  // and then concatentated to the top of the full list
336 
337  TCanvas rawCanvas("rawCanvas", "Raw Signal Shapes", 0, 0, 1024, 768);
338  rawCanvas.SetBatch(true);
339  // remove any pading space
340  rawCanvas.SetMargin(0, 0, 0, 0);
341  // divide into two pads (1 for page titles and 1 for plots)
342  rawCanvas.Divide(1, 2, 0, 0);
343  TVirtualPad *rawTitlePad = rawCanvas.cd(1);
344  TVirtualPad *rawPlotPad = rawCanvas.cd(2);
345  // remove any pading space from pads
346  rawTitlePad->SetMargin(0, 0, 0, 0);
347  rawPlotPad->SetMargin(0, 0, 0, 0);
348  // resize the pads so that title is at the top
349  const float titleBottom = 0.97;
350  rawTitlePad->SetPad(0, titleBottom, 1, 1);
351  rawPlotPad->SetPad(0, 0, 1, titleBottom);
352  // divide bottom pad into 64 pads for plots
353  const unsigned short int maxPlotsPerPage = 64;
354  const unsigned short int maxPlotsPerPageX = 8;
355  const unsigned short int maxPlotsPerPageY = 8;
356  rawPlotPad->Divide(maxPlotsPerPageX, maxPlotsPerPageY, 0, 0);
357  // Create text label for top pad
358  TPaveText *rawPageTitle = new TPaveText(0, 0, 1, 1);
359  rawPageTitle->SetFillColor(kWhite);
360  rawPageTitle->SetBorderSize(0);
361 
362  TCanvas rawErrorCanvas("rawErrorCanvas", "Raw Signal Shapes with Errors", 0, 0, 1024, 768);
363  rawErrorCanvas.SetBatch(true);
364  // remove any pading space
365  rawErrorCanvas.SetMargin(0, 0, 0, 0);
366  // divide into two pads (1 for page titles and 1 for plots)
367  rawErrorCanvas.Divide(1, 2, 0, 0);
368  TVirtualPad *rawErrorTitlePad = rawErrorCanvas.cd(1);
369  TVirtualPad *rawErrorPlotPad = rawErrorCanvas.cd(2);
370  // remove any pading space from pads
371  rawErrorTitlePad->SetMargin(0, 0, 0, 0);
372  rawErrorPlotPad->SetMargin(0, 0, 0, 0);
373  // resize the pads so that title is at the top
374  rawErrorTitlePad->SetPad(0, titleBottom, 1, 1);
375  rawErrorPlotPad->SetPad(0, 0, 1, titleBottom);
376  // divide bottom pad into 64 pads for plots
377  const unsigned short int maxErrorPlotsPerPage = 16;
378  const unsigned short int maxErrorPlotsPerPageX = 4;
379  const unsigned short int maxErrorPlotsPerPageY = 4;
380  rawErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageY, 0, 0);
381  // Create text label for top pad
382  TPaveText *rawErrorPageTitle = new TPaveText(0, 0, 1, 1);
383  rawErrorPageTitle->SetFillColor(kWhite);
384  rawErrorPageTitle->SetBorderSize(0);
385 
386  // Counter for the number of plots in the error canvas
387  // this is used to figure out how many plots are being
388  // included and when to go to the next page
389  unsigned short int nErrorPlots = 0;
390  unsigned short int nErrorPlotPages = 0;
391 
392  TCanvas processedCanvas("processedCanvas", "Processed Signal Shapes", 0, 0, 1024, 768);
393  // remove any pading space
394  processedCanvas.SetMargin(0, 0, 0, 0);
395  // divide into two pads (1 for page titles and 1 for plots)
396  processedCanvas.Divide(1, 2, 0, 0);
397  TVirtualPad *processedTitlePad = processedCanvas.cd(1);
398  TVirtualPad *processedPlotPad = processedCanvas.cd(2);
399  // remove any pading space from pads
400  processedTitlePad->SetMargin(0, 0, 0, 0);
401  processedPlotPad->SetMargin(0, 0, 0, 0);
402  // resize the pads so that title is at the top
403  processedTitlePad->SetPad(0, titleBottom, 1, 1);
404  processedPlotPad->SetPad(0, 0, 1, titleBottom);
405  // divide bottom pad into 64 pads for plots
406  processedPlotPad->Divide(maxPlotsPerPageX, maxPlotsPerPageY, 0, 0);
407  // Create text label for top pad
408  TPaveText *processedPageTitle = new TPaveText(0, 0, 1, 1);
409  processedPageTitle->SetFillColor(kWhite);
410  processedPageTitle->SetBorderSize(0);
411 
412  TCanvas processedErrorCanvas("processedErrorCanvas", "Processed Signal Shapes with Errors", 0, 0, 1024, 768);
413  // remove any pading space
414  processedErrorCanvas.SetMargin(0, 0, 0, 0);
415  // divide into two pads (1 for page titles and 1 for plots)
416  processedErrorCanvas.Divide(1, 2, 0, 0);
417  TVirtualPad *processedErrorTitlePad = processedErrorCanvas.cd(1);
418  TVirtualPad *processedErrorPlotPad = processedErrorCanvas.cd(2);
419  // remove any pading space from pads
420  processedErrorTitlePad->SetMargin(0, 0, 0, 0);
421  processedErrorPlotPad->SetMargin(0, 0, 0, 0);
422  // resize the pads so that title is at the top
423  processedErrorTitlePad->SetPad(0, titleBottom, 1, 1);
424  processedErrorPlotPad->SetPad(0, 0, 1, titleBottom);
425  // divide bottom pad into 64 pads for plots
426  processedErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageY, 0, 0);
427  // Create text label for top pad
428  TPaveText *processedErrorPageTitle = new TPaveText(0, 0, 1, 1);
429  processedErrorPageTitle->SetFillColor(kWhite);
430  processedErrorPageTitle->SetBorderSize(0);
431 
432  // also want files to store the canvases in
433  std::string filenameRawShapes, filenameRawErrorShapes;
434  std::string filenameProcessedShapes, filenameProcessedErrorShapes;
435  if (m_runNumberStr.empty()) {
436  filenameRawShapes = (m_outputFileDirName + '/' + m_outRawCanvasName + '.' + m_outRawCanvasNamePostfix);
437  filenameRawErrorShapes = (m_outputFileDirName + '/' + m_outRawCanvasName + "Error." + m_outRawCanvasNamePostfix);
438  filenameProcessedShapes = (m_outputFileDirName + '/' + m_outProcessedCanvasName + '.' + m_outProcessedCanvasNamePostfix);
439  filenameProcessedErrorShapes = (m_outputFileDirName + '/' + m_outProcessedCanvasName + "Error." + m_outProcessedCanvasNamePostfix);
440  }
441  else {
442  filenameRawShapes = (m_outputFileDirName + '/' + m_outRawCanvasName + '_' + m_runNumberStr + '.' + m_outRawCanvasNamePostfix);
443  filenameRawErrorShapes = (m_outputFileDirName + '/' + m_outRawCanvasName + "Error_" + m_runNumberStr + '.' + m_outRawCanvasNamePostfix);
444  filenameProcessedShapes = (m_outputFileDirName + '/' + m_outProcessedCanvasName + '_' + m_runNumberStr + '.' + m_outProcessedCanvasNamePostfix);
445  filenameProcessedErrorShapes = (m_outputFileDirName + '/' + m_outProcessedCanvasName + "Error_" + m_runNumberStr + '.' + m_outProcessedCanvasNamePostfix);
446  }
447 
449  // setup summary plots for this run
451 
452  // 1D difference between currentFullDelayData and derived
453  TH1I *h1f_diff_fullDelayData_rawMax = new TH1I("h1f_diff_fullDelayData_rawMax", "FullDelayData: RawMax - database;#Delta FullDelayData (ns)", 100, -50, 50);
454  TH1I *h1f_diff_fullDelayData_rawFit = new TH1I("h1f_diff_fullDelayData_rawFit", "FullDelayData: RawFit - database;#Delta FullDelayData (ns)", 100, -50, 50);
455  TH1I *h1f_diff_fullDelayData_processedMax = new TH1I("h1f_diff_fullDelayData_processedMax", "FullDelayData: ProcessedMax - database;#Delta FullDelayData (ns)", 100, -50, 50);
456  TH1I *h1f_diff_fullDelayData_processedFit = new TH1I("h1f_diff_fullDelayData_processedFit", "FullDelayData: ProcessedFit - database;#Delta FullDelayData (ns)", 100, -50, 50);
457 
458  // 2D difference between currentFullDelayData and derived
459  // EM
460  TH2F_LW *h2f_diff_fullDelayData_rawMax_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_diff_fullDelayData_rawMax_em", "EM FullDelayData: RawMax - database");
461  TH2F_LW *h2f_diff_fullDelayData_rawFit_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_diff_fullDelayData_rawFit_em", "EM FullDelayData: RawFit - database");
462  TH2F_LW *h2f_diff_fullDelayData_processedMax_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_diff_fullDelayData_processedMax_em", "EM FullDelayData: ProcessedMax - database");
463  TH2F_LW *h2f_diff_fullDelayData_processedFit_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_diff_fullDelayData_processedFit_em", "EM FullDelayData: ProcessedFit - database");
464  // HAD
465  TH2F_LW *h2f_diff_fullDelayData_rawMax_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_diff_fullDelayData_rawMax_had", "HAD FullDelayData: RawMax - database");
466  TH2F_LW *h2f_diff_fullDelayData_rawFit_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_diff_fullDelayData_rawFit_had", "HAD FullDelayData: RawFit - database");
467  TH2F_LW *h2f_diff_fullDelayData_processedMax_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_diff_fullDelayData_processedMax_had", "HAD FullDelayData: ProcessedMax - database");
468  TH2F_LW *h2f_diff_fullDelayData_processedFit_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_diff_fullDelayData_processedFit_had", "HAD FullDelayData: ProcessedFit - database");
469 
470  // 2D Error Plots (just a place holder to help presentation in the summary plots
471  // EM
472  TH2F_LW *h2f_errorCode_dummy_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_errorCode_dummy_em", "EM Error Code Dummy");
473  // HAD
474  TH2F_LW *h2f_errorCode_dummy_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_errorCode_dummy_had", "HAD Error Code Dummy");
475 
476  // 2D ErrorCode
477  TH2F_LW *h2f_errorCode_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_errorCode_em", "EM Error Code");
478  TH2F_LW *h2f_errorCode_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_errorCode_had", "HAD Error Code");
479 
480  // 2D derived FullDelayData
481  // EM
482  TH2F_LW *h2f_fullDelayData_rawMax_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_fullDelayData_rawMax_em", "EM FullDelayData: RawMax");
483  TH2F_LW *h2f_fullDelayData_rawFit_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_fullDelayData_rawFit_em", "EM FullDelayData: RawFit");
484  TH2F_LW *h2f_fullDelayData_processedMax_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_fullDelayData_processedMax_em", "EM FullDelayData: ProcessedMax");
485  TH2F_LW *h2f_fullDelayData_processedFit_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_fullDelayData_processedFit_em", "EM FullDelayData: ProcessedFit");
486  // HAD
487  TH2F_LW *h2f_fullDelayData_rawMax_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_fullDelayData_rawMax_had", "HAD FullDelayData: RawMax");
488  TH2F_LW *h2f_fullDelayData_rawFit_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_fullDelayData_rawFit_had", "HAD FullDelayData: RawFit");
489  TH2F_LW *h2f_fullDelayData_processedMax_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_fullDelayData_processedMax_had", "HAD FullDelayData: ProcessedMax");
490  TH2F_LW *h2f_fullDelayData_processedFit_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_fullDelayData_processedFit_had", "HAD FullDelayData: ProcessedFit");
491 
492  // 2D current Delays
493  TH2F_LW *h2f_fullDelayData_em = (*m_histTool)->bookPPMEmEtaVsPhi("h2f_fullDelayData_em", "EM FullDelayData from database");
494  TH2F_LW *h2f_fullDelayData_had = (*m_histTool)->bookPPMHadEtaVsPhi("h2f_fullDelayData_had", "HAD FullDelayData from database");
495 
496 
497  // get iterators to loop over cool ids
498  ShapesMap_itr itr = this->begin();
499  ShapesMap_itr itrEnd = this->end();
500 
501  StatusCode overallSc;
502  for (; itr != itrEnd; ++itr) {
503 
504  L1CaloPprPhos4Shape* shape = itr->second;
505 
506  // call the finalize function for this cool id
507  // so the raw signal is processed.
508  StatusCode sc = shape->Finalize();
509  if (sc.isFailure()) {
510  overallSc = StatusCode::FAILURE;
511  }
512 
513  // now fill the TTree items
514  m_coolId = shape->GetCoolId();
515 
516  m_isEnabled = shape->IsEnabled();
517  m_isValid = shape->IsValidChannel();
518  m_isProcessed = shape->IsProcessed();
519 
520  m_rawSignalShape = shape->GetRawSignalShape();
521  m_rawMaxPeakBin = shape->GetRawMaxPeakBin();
522  m_rawMaxPeakValue = shape->GetRawMaxPeakValue();
523  m_rawMaxFullDelayData = shape->GetRawMaxFullDelayData();
524  m_rawFitPeakBin = shape->GetRawFitPeakBin();
525  m_rawFitPeakValue = shape->GetRawFitPeakValue();
526  m_rawFitFullDelayData = shape->GetRawFitFullDelayData();
527  m_rawFitPerformed = shape->GetRawFitPerformed();
528 
529  m_rawFit = shape->GetRawFit();
530 
531  m_pedestalMean = shape->GetPedestalMean();
532  m_pedestalSigma = shape->GetPedestalSigma();
533 
534  m_processedSignalShape = shape->GetProcessedSignalShape();
535  m_processedMaxPeakBin = shape->GetProcessedMaxPeakBin();
536  m_processedMaxPeakValue = shape->GetProcessedMaxPeakValue();
537  m_processedMaxFullDelayData = shape->GetProcessedMaxFullDelayData();
538  m_processedFitPeakBin = shape->GetProcessedFitPeakBin();
539  m_processedFitPeakValue = shape->GetProcessedFitPeakValue();
540  m_processedFitFullDelayData = shape->GetProcessedFitFullDelayData();
541  m_processedFitPerformed = shape->GetProcessedFitPerformed();
542 
543  m_processedFit = shape->GetProcessedFit();
544 
545  m_risingSlopeMean = shape->GetRisingSlopeMean();
546  m_risingSlopeSigma = shape->GetRisingSlopeSigma();
547 
548  m_errorCode = shape->GetErrorCode();
549 
550  m_currentFullDelayData = shape->GetCurrentFullDelayData();
551 
552  tree->Fill();
553 
554  // output to database text file
555  if (dbFile_rawMax.is_open()) {
556  dbFile_rawMax << m_timingRegime << ".PprPhos4ScanResults,0x";
557  dbFile_rawMax.width(8);
558  dbFile_rawMax.fill('0');
559  dbFile_rawMax << std::hex << itr->first << std::dec << ",";
560  dbFile_rawMax << "ModuleId:unsigned:0,";
561  dbFile_rawMax << "ErrorCode:unsigned:" << shape->GetErrorCode() << ",";
562  dbFile_rawMax << "Histograms:string:Not yet set,";
563  dbFile_rawMax << "FullDelayData:unsigned:" << shape->GetRawMaxFullDelayData() << std::endl;
564  }
565  if (dbFile_rawFit.is_open()) {
566  dbFile_rawFit << m_timingRegime << ".PprPhos4ScanResults,0x";
567  dbFile_rawFit.width(8);
568  dbFile_rawFit.fill('0');
569  dbFile_rawFit << std::hex << itr->first << std::dec << ",";
570  dbFile_rawFit << "ModuleId:unsigned:0,";
571  dbFile_rawFit << "ErrorCode:unsigned:" << shape->GetErrorCode() << ",";
572  dbFile_rawFit << "Histograms:string:Not yet set,";
573  dbFile_rawFit << "FullDelayData:unsigned:" << shape->GetRawFitFullDelayData() << std::endl;
574  }
575  if (dbFile_processedMax.is_open()) {
576  dbFile_processedMax << m_timingRegime << ".PprPhos4ScanResults,0x";
577  dbFile_processedMax.width(8);
578  dbFile_processedMax.fill('0');
579  dbFile_processedMax << std::hex << itr->first << std::dec << ",";
580  dbFile_processedMax << "ModuleId:unsigned:0,";
581  dbFile_processedMax << "ErrorCode:unsigned:" << shape->GetErrorCode() << ",";
582  dbFile_processedMax << "Histograms:string:Not yet set,";
583  dbFile_processedMax << "FullDelayData:unsigned:" << shape->GetProcessedMaxFullDelayData() << std::endl;
584  }
585  if (dbFile_processedFit.is_open()) {
586  dbFile_processedFit << m_timingRegime << ".PprPhos4ScanResults,0x";
587  dbFile_processedFit.width(8);
588  dbFile_processedFit.fill('0');
589  dbFile_processedFit << std::hex << itr->first << std::dec << ",";
590  dbFile_processedFit << "ModuleId:unsigned:0,";
591  dbFile_processedFit << "ErrorCode:unsigned:" << shape->GetErrorCode() << ",";
592  dbFile_processedFit << "Histograms:string:Not yet set,";
593  dbFile_processedFit << "FullDelayData:unsigned:" << shape->GetProcessedFitFullDelayData() << std::endl;
594  }
595 
598  // put plots in canvas
599 
600  const unsigned int digiChanNum = ((m_coolId >> 8) & 0xf) * 4 + (m_coolId & 0xf);
601  // customize how the pads are presented
602  TVirtualPad* rawPad = rawPlotPad->GetPad(digiChanNum + 1);
603  rawPad->SetRightMargin(0.);
604  rawPad->SetTopMargin(0.);
605  rawPad->SetBottomMargin(0.);
606  rawPad->SetLeftMargin(0.);
607  if (!(digiChanNum % 8))
608  rawPad->SetLeftMargin(0.1);
609  if (digiChanNum >= 56)
610  rawPad->SetBottomMargin(0.1);
611 
612  m_rawSignalShape->SetMinimum(0);
613  m_rawSignalShape->SetMaximum(1030);
614 
615  TVirtualPad* procPad = processedPlotPad->GetPad(digiChanNum + 1);
616  procPad->SetRightMargin(0.);
617  procPad->SetLeftMargin(0.);
618  procPad->SetBottomMargin(0.);
619  procPad->SetTopMargin(0.);
620  if (!(digiChanNum % 8))
621  procPad->SetLeftMargin(0.1);
622  if (digiChanNum >= 56)
623  procPad->SetBottomMargin(0.1);
624 
625  m_processedSignalShape->SetMinimum(-30);
626  m_processedSignalShape->SetMaximum(1000);
627 
628  rawPad->SetFillColor(kWhite);
629  procPad->SetFillColor(kWhite);
630  // color disabled (but used) channels cyan
631  if (!shape->IsEnabled() && shape->IsValidChannel()) {
632  rawPad->SetFillColor(kCyan);
633  procPad->SetFillColor(kCyan);
634  }
635  // color enabled but unused channels green
636  else if (!shape->IsValidChannel()) {
637  rawPad->SetFillColor(kGreen);
638  procPad->SetFillColor(kGreen);
639  }
640  // color channels with error codes red
641  else if (shape->GetErrorCode() != 0) {
642  rawPad->SetFillColor(kRed);
643  procPad->SetFillColor(kRed);
644 
645  // if there is no signal, zoom in on the pedestal
646  ChanCalibErrorCode raw_errorCode = shape->GetErrorCode();
647  if (raw_errorCode.phos4ScanNoSignal()) {
648  m_rawSignalShape->SetMaximum(100);
649  m_rawSignalShape->SetMinimum(0);
650  m_processedSignalShape->SetMaximum(70);
651  m_processedSignalShape->SetMinimum(-30);
652  }
653  }
654 
655  rawPlotPad->cd(digiChanNum + 1);
656  m_rawSignalShape->GetXaxis()->SetLabelSize(0.07);
657  m_rawSignalShape->GetXaxis()->SetLabelOffset(0.01);
658  m_rawSignalShape->Draw();
659  processedPlotPad->cd(digiChanNum + 1);
660  m_processedSignalShape->GetXaxis()->SetLabelSize(0.07);
661  m_processedSignalShape->GetXaxis()->SetLabelOffset(0.01);
662  m_processedSignalShape->Draw();
663 
664  // save canses to file
665  if (digiChanNum == maxPlotsPerPage - 1) {
666  ATH_MSG_INFO("[Finalize] Saving Channel Shapes to file. ");
667  // set title for the page
668  std::string rawTitle = GetPadTitle(m_coolId) + " (raw)";
669  std::string processedTitle = GetPadTitle(m_coolId) + " (processed)";
670 
671  // draw title on page
672  rawTitlePad->cd();
673  rawPageTitle->Clear();
674  rawPageTitle->AddText(rawTitle.c_str());
675  rawPageTitle->Draw();
676 
677  // update canvas
678  rawCanvas.Update();
679 
680  // draw title on page
681  processedTitlePad->cd();
682  processedPageTitle->Clear();
683  processedPageTitle->AddText(processedTitle.c_str());
684  processedPageTitle->Draw();
685 
686  processedCanvas.Update();
687 
688  // if this is the first module in the first crate we open the files.
689  if ( ((m_coolId >> 24) & 0xf) == 0 && ((m_coolId >> 16) & 0xf) == 0) {
690  rawCanvas.SaveAs( std::string(filenameRawShapes + "(").c_str() );
691  processedCanvas.SaveAs( std::string(filenameProcessedShapes + "(").c_str() );
692 
693  rawPlotPad->Clear();
694  rawPlotPad->SetMargin(0, 0, 0, 0);
695  rawPlotPad->Divide(8, 8, 0, 0);
696  processedPlotPad->Clear();
697  processedPlotPad->SetMargin(0, 0, 0, 0);
698  processedPlotPad->Divide(8, 8, 0, 0);
699 
700  }
701  // if this is the last module in the last crate the we close the files.
702  else if (((m_coolId >> 24) & 0xf) == 7 && ((m_coolId >> 16) & 0xf) == 15) {
703  rawCanvas.SaveAs( std::string(filenameRawShapes + ")").c_str() );
704  processedCanvas.SaveAs( std::string(filenameProcessedShapes + ")").c_str() );
705  }
706  // all others just add
707  else {
708  rawCanvas.SaveAs( filenameRawShapes.c_str() );
709  processedCanvas.SaveAs( filenameProcessedShapes.c_str() );
710 
711  rawPlotPad->Clear();
712  rawPlotPad->SetMargin(0, 0, 0, 0);
713  rawPlotPad->Divide(8, 8, 0, 0);
714  processedPlotPad->Clear();
715  processedPlotPad->SetMargin(0, 0, 0, 0);
716  processedPlotPad->Divide(8, 8, 0, 0);
717 
718  }
719 
720  }// end if(digiChanNum)
721 
722  // fill the error plot canvases
723 
724  // add shapes with errors to the error summary canvases
725  if (m_errorCode != 0) {
726 
727  ChanCalibErrorCode tempErrorCode(m_errorCode);
728 
729  // don't plot saturated signals
730  if (!tempErrorCode.phos4ScanSignalSaturated()) {
731 
732  // if it's a Tile run and this is a Tile Channel
733  if (m_isTileRun && !m_isLArRun && IsTileChannel(shape)) {
734 
735  const unsigned short int padIndex = nErrorPlots + 1;
736 
737  TVirtualPad *rawErrorPad = rawErrorPlotPad->cd(padIndex);
738  TVirtualPad *procErrorPad = processedErrorPlotPad->cd(padIndex);
739  rawErrorPad->SetFillColor(kWhite);
740  procErrorPad->SetFillColor(kWhite);
741  // color disabled (but used) channels cyan
742  if (!shape->IsEnabled() && shape->IsValidChannel()) {
743  rawErrorPad->SetFillColor(kCyan);
744  procErrorPad->SetFillColor(kCyan);
745  }
746  // color enabled but unused channels green
747  else if (!shape->IsValidChannel()) {
748  rawErrorPad->SetFillColor(kGreen);
749  procErrorPad->SetFillColor(kGreen);
750  }
751  // color channels with error codes red
752  else {
753  rawErrorPad->SetFillColor(kRed);
754  procErrorPad->SetFillColor(kRed);
755  }
756 
757  rawErrorPad->cd();
758  m_rawSignalShape->Draw();
759 
760  procErrorPad->cd();
761  m_processedSignalShape->Draw();
762 
763  nErrorPlots++;
764  }
765  // if it's a LAr run and this is a LAr Channel
766  else if ( m_isLArRun && !m_isTileRun && IsLArChannel(shape)) {
767 
768  const unsigned short int padIndex = nErrorPlots + 1;
769 
770  TVirtualPad *rawErrorPad = rawErrorPlotPad->cd(padIndex);
771  TVirtualPad *procErrorPad = processedErrorPlotPad->cd(padIndex);
772  rawErrorPad->SetFillColor(kWhite);
773  procErrorPad->SetFillColor(kWhite);
774  // color disabled (but used) channels cyan
775  if (!shape->IsEnabled() && shape->IsValidChannel()) {
776  rawErrorPad->SetFillColor(kCyan);
777  procErrorPad->SetFillColor(kCyan);
778  }
779  // color enabled but unused channels green
780  else if (!shape->IsValidChannel()) {
781  rawErrorPad->SetFillColor(kGreen);
782  procErrorPad->SetFillColor(kGreen);
783  }
784  // color channels with error codes red
785  else {
786  rawErrorPad->SetFillColor(kRed);
787  procErrorPad->SetFillColor(kRed);
788  }
789 
790  rawErrorPad->cd();
791  m_rawSignalShape->Draw();
792 
793  procErrorPad->cd();
794  m_processedSignalShape->Draw();
795 
796  nErrorPlots++;
797  }
798  }
799  }// end if(errorCode)
800 
801  // Save the output file if the number of plots has reached
802  // the maximum
803  if (nErrorPlots == maxErrorPlotsPerPage) {
804 
805  ATH_MSG_INFO("[Finalize] Saving Error Shapes to file. ");
806 
807  // set title for the page
808  std::string rawTitle = "Failed Channels (raw)";
809  std::string processedTitle = "Failed Channels (processed)";
810 
811  // draw title on page
812  rawErrorTitlePad->cd();
813  rawErrorPageTitle->Clear();
814  rawErrorPageTitle->AddText(rawTitle.c_str());
815  rawErrorPageTitle->Draw();
816 
817  // update canvas
818  rawErrorCanvas.Update();
819 
820  // draw title on page
821  processedErrorTitlePad->cd();
822  processedErrorPageTitle->Clear();
823  processedErrorPageTitle->AddText(processedTitle.c_str());
824  processedErrorPageTitle->Draw();
825 
826  processedErrorCanvas.Update();
827 
828  // if this is the first page open a new file
829  if ( nErrorPlotPages == 0 ) {
830  rawErrorCanvas.SaveAs( std::string(filenameRawErrorShapes + "(").c_str() );
831  processedErrorCanvas.SaveAs( std::string(filenameProcessedErrorShapes + "(").c_str() );
832 
833  rawErrorPlotPad->Clear();
834  rawErrorPlotPad->SetMargin(0, 0, 0, 0);
835  rawErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageX, 0, 0);
836  processedErrorPlotPad->Clear();
837  processedErrorPlotPad->SetMargin(0, 0, 0, 0);
838  processedErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageX, 0, 0);
839 
840  }
841  // all others just add
842  else {
843  rawErrorCanvas.SaveAs( filenameRawErrorShapes.c_str() );
844  processedErrorCanvas.SaveAs( filenameProcessedErrorShapes.c_str() );
845 
846  rawErrorPlotPad->Clear();
847  rawErrorPlotPad->SetMargin(0, 0, 0, 0);
848  rawErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageX, 0, 0);
849  processedErrorPlotPad->Clear();
850  processedErrorPlotPad->SetMargin(0, 0, 0, 0);
851  processedErrorPlotPad->Divide(maxErrorPlotsPerPageX, maxErrorPlotsPerPageX, 0, 0);
852  }
853  // Note: These files will be closed after the LOOP over the iterators ends
854  nErrorPlots = 0;
855  nErrorPlotPages++;
856  }// end if(nErrorPlots)
857 
858 
860  // Fill Summary Plots
862 
863  // 1D plots
864  const int diffRawMax = (int)m_rawMaxFullDelayData - (int)m_currentFullDelayData;
865  const int diffRawFit = (int)m_rawFitFullDelayData - (int)m_currentFullDelayData;
866  const int diffProcessedMax = (int)m_processedMaxFullDelayData - (int)m_currentFullDelayData;
867  const int diffProcessedFit = (int)m_processedFitFullDelayData - (int)m_currentFullDelayData;
868  // only fill if there was no error
869  if (m_errorCode == 0) {
870  h1f_diff_fullDelayData_rawMax->Fill(diffRawMax);
871  h1f_diff_fullDelayData_rawFit->Fill(diffRawFit);
872  h1f_diff_fullDelayData_processedMax->Fill(diffProcessedMax);
873  h1f_diff_fullDelayData_processedFit->Fill(diffProcessedFit);
874  }
875 
876  float eta = shape->GetEta();
877  float phi = shape->GetPhi();
878 
879  // 2D plots
880  if (shape->GetLayer() == L1CaloPprPhos4Shape::EM) {
881 
882  // error code
883  int error = 0;
884  if (m_errorCode == 0x12) // no signal
885  error = 1;
886  else if (m_errorCode == 0x402) // saturated signal
887  error = 2;
888  else if (m_errorCode == 0x22) // bad signal shape
889  error = 3;
890  if (error > 0)
891  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_errorCode_em, eta, phi, error);
892 
893  // skip filling if there is an error
894  if (error == 0) {
895  // diff delay
896  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_rawMax_em, eta, phi, diffRawMax);
897  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_rawFit_em, eta, phi, diffRawFit);
898  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_processedMax_em, eta, phi, diffProcessedMax);
899  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_processedFit_em, eta, phi, diffProcessedFit);
900 
901  // derived delays
902  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_fullDelayData_rawMax_em, eta, phi, m_rawMaxFullDelayData);
903  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_fullDelayData_rawFit_em, eta, phi, m_rawFitFullDelayData);
904  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_fullDelayData_processedMax_em, eta, phi, m_processedMaxFullDelayData);
905  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_fullDelayData_processedFit_em, eta, phi, m_processedFitFullDelayData);
906 
907  // current delay
908  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_fullDelayData_em, eta, phi, m_currentFullDelayData);
909  }// end if(error)
910  // for the diff plots, I want the bins with errors to appear white
911  // to do this I falsely fill them with large negative values
912  else {
913  int artificialDelay = -999;
914  // diff delay
915  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_rawMax_em, eta, phi, artificialDelay);
916  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_rawFit_em, eta, phi, artificialDelay);
917  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_processedMax_em, eta, phi, artificialDelay);
918  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_diff_fullDelayData_processedFit_em, eta, phi, artificialDelay);
919 
920  // error plot
921  int artificialError = 10;
922  (*m_histTool)->fillPPMEmEtaVsPhi(h2f_errorCode_dummy_em, eta, phi, artificialError);
923  }
924  }
925  else if (shape->GetLayer() == L1CaloPprPhos4Shape::HAD) {
926 
927  // error code
928  int error = 0;
929  if (m_errorCode == 0x12) // no signal
930  error = 1;
931  else if (m_errorCode == 0x402) // saturated signal
932  error = 2;
933  else if (m_errorCode == 0x22) // bad signal shape
934  error = 3;
935  if (error > 0)
936  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_errorCode_had, eta, phi, error);
937 
938  // skip filling if there is an error
939  if (error == 0) {
940  // diff delays
941  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_rawMax_had, eta, phi, diffRawMax);
942  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_rawFit_had, eta, phi, diffRawFit);
943  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_processedMax_had, eta, phi, diffProcessedMax);
944  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_processedFit_had, eta, phi, diffProcessedFit);
945 
946  // derived delays
947  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_fullDelayData_rawMax_had, eta, phi, m_rawMaxFullDelayData);
948  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_fullDelayData_rawFit_had, eta, phi, m_rawFitFullDelayData);
949  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_fullDelayData_processedMax_had, eta, phi, m_processedMaxFullDelayData);
950  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_fullDelayData_processedFit_had, eta, phi, m_processedFitFullDelayData);
951 
952  // current delay
953  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_fullDelayData_had, eta, phi, m_currentFullDelayData);
954  }// end if(error)
955  // for the diff plots, I want the bins with errors to appear white
956  // to do this I falsely fill them with large negative values
957  else {
958  int artificialDelay = -999;
959 
960  // diff delays
961  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_rawMax_had, eta, phi, artificialDelay);
962  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_rawFit_had, eta, phi, artificialDelay);
963  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_processedMax_had, eta, phi, artificialDelay);
964  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_diff_fullDelayData_processedFit_had, eta, phi, artificialDelay);
965 
966  // error plot
967  int artificialError = 10;
968  (*m_histTool)->fillPPMHadEtaVsPhi(h2f_errorCode_dummy_had, eta, phi, artificialError);
969  }
970  }
971 
972  }// end for(itr)
973 
974 
975  // Close error plots
976  // if there are earlier pages, end the file
977  if (nErrorPlotPages > 0) {
978 
979  ATH_MSG_INFO("[Finalize] Saving Last Error Shapes to file. ");
980 
981  // set title for the page
982  std::string rawTitle = "Failed Channels (raw)";
983  std::string processedTitle = "Failed Channels (processed)";
984 
985  // draw title on page
986  rawErrorTitlePad->cd();
987  rawErrorPageTitle->Clear();
988  rawErrorPageTitle->AddText(rawTitle.c_str());
989  rawErrorPageTitle->Draw();
990 
991  // update canvas
992  rawErrorCanvas.Update();
993 
994  // draw title on page
995  processedErrorTitlePad->cd();
996  processedErrorPageTitle->Clear();
997  processedErrorPageTitle->AddText(processedTitle.c_str());
998  processedErrorPageTitle->Draw();
999 
1000  processedErrorCanvas.Update();
1001 
1002  rawErrorCanvas.SaveAs( std::string(filenameRawErrorShapes + ")").c_str() );
1003  processedErrorCanvas.SaveAs( std::string(filenameProcessedErrorShapes + ")").c_str() );
1004 
1005 
1006  // append Error histograms to the top of the signal shape files
1007  MergeErrorAndShapes(filenameRawErrorShapes, filenameRawShapes);
1008  MergeErrorAndShapes(filenameProcessedErrorShapes, filenameProcessedShapes);
1009 
1010  }
1011  // if there is only one page just save it
1012  else if (nErrorPlots != 0 ) {
1013 
1014  ATH_MSG_INFO("[Finalize] Saving Single Page of Error Shapes to file. ");
1015 
1016  // set title for the page
1017  std::string rawTitle = "Failed Channels (raw)";
1018  std::string processedTitle = "Failed Channels (processed)";
1019 
1020  // draw title on page
1021  rawErrorTitlePad->cd();
1022  rawErrorPageTitle->Clear();
1023  rawErrorPageTitle->AddText(rawTitle.c_str());
1024  rawErrorPageTitle->Draw();
1025 
1026  // update canvas
1027  rawErrorCanvas.Update();
1028 
1029  // draw title on page
1030  processedErrorTitlePad->cd();
1031  processedErrorPageTitle->Clear();
1032  processedErrorPageTitle->AddText(processedTitle.c_str());
1033  processedErrorPageTitle->Draw();
1034 
1035  processedErrorCanvas.Update();
1036 
1037  rawErrorCanvas.SaveAs( filenameRawErrorShapes.c_str() );
1038  processedErrorCanvas.SaveAs( filenameProcessedErrorShapes.c_str() );
1039 
1040  // append Error histograms to the top of the signal shape files
1041  MergeErrorAndShapes(filenameRawErrorShapes, filenameRawShapes);
1042  MergeErrorAndShapes(filenameProcessedErrorShapes, filenameProcessedShapes);
1043  }
1044 
1045  //gZip the postscript files
1046  gzipFile(filenameRawShapes);
1047  gzipFile(filenameProcessedShapes);
1048 
1049  // close text file
1050  if (dbFile_rawMax.is_open()) dbFile_rawMax.close();
1051  if (dbFile_rawFit.is_open()) dbFile_rawFit.close();
1052  if (dbFile_processedMax.is_open()) dbFile_processedMax.close();
1053  if (dbFile_processedFit.is_open()) dbFile_processedFit.close();
1054 
1055  ATH_MSG_INFO("[Finalize] Writing TTree.");
1056 
1057  tree->Write();
1058 
1059  // Also want to store the Run Number
1060  TTree* runTree = new TTree("runInfo", "runInfo");
1061 
1062  runTree->Branch(m_runNumberName.c_str(), &m_runNumber, std::string(m_runNumberName + "/i").c_str());
1063 
1064  // m_runNumber was set during the run so we can go ahead and fill it.
1065  runTree->Fill();
1066 
1067  runTree->Write();
1068 
1069  outputFile->Close();
1070 
1071 // delete rawPageTitle;
1072 // rawPageTitle = 0;
1073 //
1074 // delete processedPageTitle;
1075 // processedPageTitle = 0;
1076 
1078  // Save and Draw summary plots
1080  ATH_MSG_INFO("Recording Summary Plots.");
1081 
1082  std::string summaryRootFile, summaryPsFile;
1083  if (m_runNumberStr.empty()) {
1084  summaryRootFile = (m_outputFileDirName + '/' + m_outputSummaryPlotsFileName + '.' + m_outputSummaryPlotsPostfix);
1085  summaryPsFile = (m_outputFileDirName + '/' + m_outputSummaryPlotsFileName + '.' + m_outputSummaryCanvasPostfix);
1086  }
1087  else {
1088  summaryRootFile = (m_outputFileDirName + '/' + m_outputSummaryPlotsFileName + '_' + m_runNumberStr + '.' + m_outputSummaryPlotsPostfix);
1089  summaryPsFile = (m_outputFileDirName + '/' + m_outputSummaryPlotsFileName + '_' + m_runNumberStr + '.' + m_outputSummaryCanvasPostfix);
1090  }
1091 
1092  // Open ROOT file
1093  TFile *summaryFile = new TFile(summaryRootFile.c_str(), "RECREATE");
1094  summaryFile->cd();
1095 
1096  // turn off plot titles for summary plots
1097  gStyle->SetOptTitle(0);
1098 
1099  // Create canvas for postscript file
1100  TCanvas *summaryCanvas = new TCanvas("summaryCanvas", "Summary Plots", 0, 0, 800, 600);
1101  summaryCanvas->SetBatch(true);
1102  summaryCanvas->cd(1)->SetMargin(0, 0, 0, 0);
1103  // divide into Title pad and content pad
1104  summaryCanvas->Divide(1, 2, 0, 0);
1105  TVirtualPad *titlePad = summaryCanvas->cd(1);
1106  titlePad->SetPad(0, titleBottom, 1, 1);
1107  TVirtualPad *contentPad = summaryCanvas->cd(2);
1108  contentPad->SetPad(0, 0, 1, titleBottom);
1109 
1110  TPaveText *titlePave = new TPaveText(0, 0, 1, 1);
1111  titlePave->SetFillColor(kWhite);
1112  titlePave->SetBorderSize(kWhite);
1113  titlePad->cd();
1114  titlePave->Draw();
1115 
1116  // error code
1117 
1118  contentPad->Clear();
1119  contentPad->Divide(1, 2, 0, 0);
1120  contentPad->cd(1)->SetMargin(0.1, 0., 0. , 0.);
1121  contentPad->cd(2)->SetMargin(0.1, 0., 0.1, 0.);
1122 
1123  contentPad->cd(1);
1124  SaveEtaPhiHisto(h2f_errorCode_em, 1, 4, 3)->Draw("col");
1125  contentPad->cd(2);
1126  SaveEtaPhiHisto(h2f_errorCode_had, 1, 4, 3)->Draw("col");
1127 
1128  titlePave->Clear();
1129  titlePave->AddText("ErrorCode: EM(top) HAD(bottom) Color Code: no signal(blue), sat signal(green), bad signal(red) ");
1130 
1131  summaryCanvas->Update();
1132  summaryCanvas->SaveAs( std::string(summaryPsFile + "(").c_str() );
1133 
1134  // current delays
1135 
1136  // EM
1137  contentPad->Clear();
1138  contentPad->Divide(2, 2, 0, 0);
1139  contentPad->cd(1)->SetMargin(0.1, 0. , 0. , 0. );
1140  contentPad->cd(2)->SetMargin(0. , 0.1, 0. , 0. );
1141  contentPad->cd(3)->SetMargin(0.1, 0. , 0.1, 0. );
1142  contentPad->cd(4)->SetMargin(0. , 0.1, 0.1, 0. );
1143 
1144  contentPad->cd(1);
1145  SaveEtaPhiHisto(h2f_fullDelayData_rawMax_em, 0, 300, 60)->Draw("col");
1146  contentPad->cd(2);
1147  SaveEtaPhiHisto(h2f_fullDelayData_rawFit_em, 0, 300, 60)->Draw("colz");
1148  contentPad->cd(3);
1149  SaveEtaPhiHisto(h2f_fullDelayData_processedMax_em, 0, 300, 60)->Draw("col");
1150  contentPad->cd(4);
1151  SaveEtaPhiHisto(h2f_fullDelayData_processedFit_em, 0, 300, 60)->Draw("colz");
1152 
1153  titlePave->Clear();
1154  titlePave->AddText("EM Derived FullDelayData: RawMax(top-left) RawFit(top-right) ProcessedMax(bottom-left) ProcessedFit(bottom-right)");
1155 
1156  summaryCanvas->Update();
1157  summaryCanvas->SaveAs( summaryPsFile.c_str() );
1158 
1159  // HAD
1160  contentPad->Clear();
1161  contentPad->Divide(2, 2, 0, 0);
1162  contentPad->cd(1)->SetMargin(0.1, 0. , 0. , 0. );
1163  contentPad->cd(2)->SetMargin(0. , 0.1, 0. , 0. );
1164  contentPad->cd(3)->SetMargin(0.1, 0. , 0.1, 0. );
1165  contentPad->cd(4)->SetMargin(0. , 0.1, 0.1, 0. );
1166 
1167  contentPad->cd(1);
1168  SaveEtaPhiHisto(h2f_fullDelayData_rawMax_had, 0, 300, 60)->Draw("col");
1169  contentPad->cd(2);
1170  SaveEtaPhiHisto(h2f_fullDelayData_rawFit_had, 0, 300, 60)->Draw("colz");
1171  contentPad->cd(3);
1172  SaveEtaPhiHisto(h2f_fullDelayData_processedMax_had, 0, 300, 60)->Draw("col");
1173  contentPad->cd(4);
1174  SaveEtaPhiHisto(h2f_fullDelayData_processedFit_had, 0, 300, 60)->Draw("colz");
1175 
1176  titlePave->Clear();
1177  titlePave->AddText("HAD Derived FullDelayData: RawMax(top-left) RawFit(top-right) ProcessedMax(bottom-left) ProcessedFit(bottom-right)");
1178 
1179  summaryCanvas->Update();
1180  summaryCanvas->SaveAs( summaryPsFile.c_str() );
1181 
1182  // current delays EM & HAD
1183  contentPad->Clear();
1184  contentPad->Divide(1, 2, 0, 0);
1185  contentPad->cd(1)->SetMargin(0.1, 0.1, 0. , 0.);
1186  contentPad->cd(2)->SetMargin(0.1, 0.1, 0.1, 0.);
1187 
1188  contentPad->cd(1);
1189  SaveEtaPhiHisto(h2f_fullDelayData_em, 0, 300, 60)->Draw("colz");
1190  contentPad->cd(2);
1191  SaveEtaPhiHisto(h2f_fullDelayData_had, 0, 300, 60)->Draw("colz");
1192 
1193  titlePave->Clear();
1194  titlePave->AddText("FullDelayData From Database: EM(top) HAD(bottom)");
1195 
1196  summaryCanvas->Update();
1197  summaryCanvas->SaveAs( summaryPsFile.c_str() );
1198 
1199  // difference of delays
1200 
1201  // EM
1202  contentPad->Clear();
1203  contentPad->Divide(2, 2, 0, 0);
1204  contentPad->cd(1)->SetMargin(0.1, 0. , 0.01, 0. );
1205  contentPad->cd(2)->SetMargin(0. , 0.1, 0.01, 0. );
1206  contentPad->cd(3)->SetMargin(0.1, 0. , 0.1, 0. );
1207  contentPad->cd(4)->SetMargin(0. , 0.1, 0.1, 0. );
1208 
1209  contentPad->cd(1);
1210  SaveEtaPhiHisto(h2f_errorCode_dummy_em)->Draw("box");
1211  SaveEtaPhiHisto(h2f_diff_fullDelayData_rawMax_em)->Draw("col same");
1212  contentPad->cd(2);
1213  SaveEtaPhiHisto(h2f_errorCode_dummy_em)->Draw("box");
1214  SaveEtaPhiHisto(h2f_diff_fullDelayData_rawFit_em)->Draw("colz same");
1215  contentPad->cd(3);
1216  SaveEtaPhiHisto(h2f_errorCode_dummy_em)->Draw("box");
1217  SaveEtaPhiHisto(h2f_diff_fullDelayData_processedMax_em)->Draw("col same");
1218  contentPad->cd(4);
1219  SaveEtaPhiHisto(h2f_errorCode_dummy_em)->Draw("box");
1220  SaveEtaPhiHisto(h2f_diff_fullDelayData_processedFit_em)->Draw("colz same");
1221 
1222  titlePave->Clear();
1223  titlePave->AddText("EM FullDelayData (derived-database): RawMax(top-left) RawFit(top-right) ProcessedMax(bottom-left) ProcessedFit(bottom-right)");
1224 
1225  summaryCanvas->Update();
1226  summaryCanvas->SaveAs( summaryPsFile.c_str() );
1227 
1228  // HAD
1229  contentPad->Clear();
1230  contentPad->Divide(2, 2, 0, 0);
1231  contentPad->cd(1)->SetMargin(0.1, 0. , 0.01, 0. );
1232  contentPad->cd(2)->SetMargin(0. , 0.1, 0.01, 0. );
1233  contentPad->cd(3)->SetMargin(0.1, 0. , 0.1, 0. );
1234  contentPad->cd(4)->SetMargin(0. , 0.1, 0.1, 0. );
1235 
1236  contentPad->cd(1);
1237  SaveEtaPhiHisto(h2f_errorCode_dummy_had)->Draw("box");
1238  SaveEtaPhiHisto(h2f_diff_fullDelayData_rawMax_had)->Draw("col same");
1239  contentPad->cd(2);
1240  SaveEtaPhiHisto(h2f_errorCode_dummy_had)->Draw("box");
1241  SaveEtaPhiHisto(h2f_diff_fullDelayData_rawFit_had)->Draw("colz same");
1242  contentPad->cd(3);
1243  SaveEtaPhiHisto(h2f_errorCode_dummy_had)->Draw("box");
1244  SaveEtaPhiHisto(h2f_diff_fullDelayData_processedMax_had)->Draw("col same");
1245  contentPad->cd(4);
1246  SaveEtaPhiHisto(h2f_errorCode_dummy_had)->Draw("box");
1247  SaveEtaPhiHisto(h2f_diff_fullDelayData_processedFit_had)->Draw("colz same");
1248 
1249  titlePave->Clear();
1250  titlePave->AddText("HAD FullDelayData (derived-database): RawMax(top-left) RawFit(top-right) ProcessedMax(bottom-left) ProcessedFit(bottom-right)");
1251 
1252  summaryCanvas->Update();
1253  summaryCanvas->SaveAs( summaryPsFile.c_str() );
1254 
1255  // Save and Draw 1D diff delay histograms
1256  contentPad->Clear();
1257  contentPad->Divide(2, 2, 0, 0);
1258  contentPad->cd(1)->SetMargin(0.1, 0. , 0. , 0. );
1259  contentPad->cd(2)->SetMargin(0.1, 0. , 0. , 0. );
1260  contentPad->cd(3)->SetMargin(0.1, 0. , 0.1, 0. );
1261  contentPad->cd(4)->SetMargin(0.1, 0. , 0.1, 0. );
1262 
1263  // write to ROOT file
1264  h1f_diff_fullDelayData_rawMax->Write();
1265  h1f_diff_fullDelayData_rawFit->Write();
1266  h1f_diff_fullDelayData_processedMax->Write();
1267  h1f_diff_fullDelayData_processedFit->Write();
1268 
1269  // draw in canvas
1270  contentPad->cd(1);
1271  contentPad->cd(1)->SetLogy(1);
1272  h1f_diff_fullDelayData_rawMax->Draw();
1273  contentPad->cd(2);
1274  contentPad->cd(2)->SetLogy(1);
1275  h1f_diff_fullDelayData_rawFit->Draw();
1276  contentPad->cd(3);
1277  contentPad->cd(3)->SetLogy(1);
1278  h1f_diff_fullDelayData_processedMax->Draw();
1279  contentPad->cd(4);
1280  contentPad->cd(4)->SetLogy(1);
1281  h1f_diff_fullDelayData_processedFit->Draw();
1282 
1283  titlePave->Clear();
1284  titlePave->AddText("FullDelayData (derived-database): RawMax(top-left) RawFit(top-right) ProcessedMax(bottom-left) ProcessedFit(bottom-right)");
1285 
1286  summaryCanvas->Update();
1287  summaryCanvas->SaveAs( std::string(summaryPsFile + ")").c_str() );
1288 
1289  // close ROOT file
1290  summaryFile->Close();
1291 
1292 
1293  // copy ps to pdf
1294  ps2pdf(summaryPsFile);
1295  sleep(5);
1296  // gzip ps
1297  gzipFile(summaryPsFile);
1298 
1299 
1300 // delete summaryFile;
1301 // summaryFile = 0;
1302 //
1303 // delete h1f_diff_fullDelayData_rawMax;
1304 // h1f_diff_fullDelayData_rawMax = 0;
1305 // delete h1f_diff_fullDelayData_rawFit;
1306 // h1f_diff_fullDelayData_rawFit = 0;
1307 // delete h1f_diff_fullDelayData_processedMax;
1308 // h1f_diff_fullDelayData_processedMax = 0;
1309 // delete h1f_diff_fullDelayData_processedFit;
1310 // h1f_diff_fullDelayData_processedFit = 0;
1311 //
1312  // commented out since LW histo deconstructor is private(!!)
1313 // delete h2f_diff_fullDelayData_rawMax_em;
1314 // h2f_diff_fullDelayData_rawMax_em = 0;
1315 // delete h2f_diff_fullDelayData_rawFit_em;
1316 // h2f_diff_fullDelayData_rawFit_em = 0;
1317 // delete h2f_diff_fullDelayData_processedMax_em;
1318 // h2f_diff_fullDelayData_processedMax_em = 0;
1319 // delete h2f_diff_fullDelayData_processedFit_em;
1320 // h2f_diff_fullDelayData_processedFit_em = 0;
1321 //
1322 // delete h2f_diff_fullDelayData_rawMax_had;
1323 // h2f_diff_fullDelayData_rawMax_had = 0;
1324 // delete h2f_diff_fullDelayData_rawFit_had;
1325 // h2f_diff_fullDelayData_rawFit_had = 0;
1326 // delete h2f_diff_fullDelayData_processedMax_had;
1327 // h2f_diff_fullDelayData_processedMax_had = 0;
1328 // delete h2f_diff_fullDelayData_processedFit_had;
1329 // h2f_diff_fullDelayData_processedFit_had = 0;
1330 
1331 
1332 
1333  return overallSc;
1334 }
L1CaloPprPhos4Shape::GetRawFit
TF1 * GetRawFit(void)
Definition: L1CaloPprPhos4Shape.h:125
L1CaloPprPhos4Shape::GetProcessedMaxPeakBin
unsigned int GetProcessedMaxPeakBin(void)
Definition: L1CaloPprPhos4Shape.h:128
L1CaloPprPhos4Shape::GetProcessedFitPeakBin
unsigned int GetProcessedFitPeakBin(void)
Definition: L1CaloPprPhos4Shape.h:131
L1CaloPprPhos4Shape::GetRawFitPeakValue
float GetRawFitPeakValue(void)
Definition: L1CaloPprPhos4Shape.h:121
ChanCalibErrorCode::phos4ScanNoSignal
bool phos4ScanNoSignal() const
Definition: ChanCalibErrorCode.h:138
L1CaloPprPhos4Shape::IsValidChannel
bool IsValidChannel(void)
Definition: L1CaloPprPhos4Shape.h:159
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
L1CaloPprPhos4Shape::GetProcessedFitFullDelayData
unsigned int GetProcessedFitFullDelayData(void)
Definition: L1CaloPprPhos4Shape.h:133
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TH1I
Definition: rootspy.cxx:332
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
tree
TChain * tree
Definition: tile_monitor.h:30
L1CaloPprPhos4Shape::GetPhi
float GetPhi(void) const
Definition: L1CaloPprPhos4Shape.h:105
L1CaloPprPhos4Shape::IsProcessed
bool IsProcessed(void)
Definition: L1CaloPprPhos4Shape.h:165
L1CaloPprPhos4Shape::GetLayer
CaloLayer GetLayer(void) const
Definition: L1CaloPprPhos4Shape.h:108
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
ChanCalibErrorCode
ChanCalibErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanE...
Definition: ChanCalibErrorCode.h:20
L1CaloPprPhos4Shape::GetCoolId
unsigned int GetCoolId(void)
Definition: L1CaloPprPhos4Shape.h:140
L1CaloPprPhos4Shape::GetProcessedFit
TF1 * GetProcessedFit(void)
Definition: L1CaloPprPhos4Shape.h:136
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
L1CaloPprPhos4Shape::HAD
@ HAD
Definition: L1CaloPprPhos4Shape.h:95
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
L1CaloPprPhos4Shape::GetRawSignalShape
TProfile * GetRawSignalShape(void)
Definition: L1CaloPprPhos4Shape.h:116
L1CaloPprPhos4Shape::GetProcessedFitPerformed
bool GetProcessedFitPerformed(void)
Definition: L1CaloPprPhos4Shape.h:134
L1CaloPprPhos4Shape
Definition: L1CaloPprPhos4Shape.h:86
lumiFormat.summaryFile
summaryFile
Definition: lumiFormat.py:122
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
L1CaloPprPhos4Shape::GetRawFitPeakBin
unsigned int GetRawFitPeakBin(void)
Definition: L1CaloPprPhos4Shape.h:120
L1CaloPprPhos4Shape::GetProcessedSignalShape
TH1F * GetProcessedSignalShape(void)
Definition: L1CaloPprPhos4Shape.h:127
L1CaloPprPhos4Shape::GetRawFitFullDelayData
unsigned int GetRawFitFullDelayData(void)
Definition: L1CaloPprPhos4Shape.h:122
L1CaloPprPhos4Shape::GetRawMaxPeakBin
unsigned int GetRawMaxPeakBin(void)
Definition: L1CaloPprPhos4Shape.h:117
L1CaloPprPhos4Shape::GetProcessedFitPeakValue
float GetProcessedFitPeakValue(void)
Definition: L1CaloPprPhos4Shape.h:132
L1CaloPprPhos4Shape::GetProcessedMaxFullDelayData
unsigned int GetProcessedMaxFullDelayData(void)
Definition: L1CaloPprPhos4Shape.h:130
L1CaloPprPhos4Shape::EM
@ EM
Definition: L1CaloPprPhos4Shape.h:94
L1CaloPprPhos4Shape::GetPedestalMean
float GetPedestalMean(void)
Definition: L1CaloPprPhos4Shape.h:153
L1CaloPprPhos4Shape::Finalize
StatusCode Finalize(void)
In finalize I want the profile to be processed and extract some useful characteristics like the peak ...
Definition: L1CaloPprPhos4Shape.cxx:135
L1CaloPprPhos4Shape::GetRawFitPerformed
bool GetRawFitPerformed(void)
Definition: L1CaloPprPhos4Shape.h:123
L1CaloPprPhos4Shape::GetRisingSlopeMean
float GetRisingSlopeMean(void)
Definition: L1CaloPprPhos4Shape.h:148
L1CaloPprPhos4Shape::GetProcessedMaxPeakValue
float GetProcessedMaxPeakValue(void)
Definition: L1CaloPprPhos4Shape.h:129
L1CaloPprPhos4Shape::GetRisingSlopeSigma
float GetRisingSlopeSigma(void)
Definition: L1CaloPprPhos4Shape.h:149
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
L1CaloPprPhos4Shape::GetRawMaxPeakValue
float GetRawMaxPeakValue(void)
Definition: L1CaloPprPhos4Shape.h:118
TH2F_LW
Definition: TH2F_LW.h:23
L1CaloPprPhos4Shape::GetEta
float GetEta(void) const
Definition: L1CaloPprPhos4Shape.h:102
L1CaloPprPhos4Shape::GetCurrentFullDelayData
unsigned int GetCurrentFullDelayData(void)
Definition: L1CaloPprPhos4Shape.h:157
error
Definition: IImpactPoint3dEstimator.h:70
L1CaloPprPhos4Shape::IsEnabled
bool IsEnabled(void)
Definition: L1CaloPprPhos4Shape.h:162
L1CaloPprPhos4Shape::GetPedestalSigma
float GetPedestalSigma(void)
Definition: L1CaloPprPhos4Shape.h:154
L1CaloPprPhos4Shape::GetRawMaxFullDelayData
unsigned int GetRawMaxFullDelayData(void)
Definition: L1CaloPprPhos4Shape.h:119
L1CaloPprPhos4Shape::GetErrorCode
unsigned int GetErrorCode(void)
Definition: L1CaloPprPhos4Shape.h:151