Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:46

0001 #include "SimFastTiming/FastTimingCommon/interface/BTLPulseShape.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <string>
0006 
0007 #include "TROOT.h"
0008 #include "TStyle.h"
0009 #include "TH1F.h"
0010 #include "TCanvas.h"
0011 #include "TF1.h"
0012 
0013 int main() {
0014   edm::MessageDrop::instance()->debugEnabled = false;
0015 
0016   const unsigned int histsiz(BTLPulseShape::k1NSecBinsTotal);
0017 
0018   // shape constants and input amplitude
0019 
0020   const double ReferencePulseNpe_ = 100.;
0021   const double TimeThreshold1_ = 20.;
0022   const double TimeThreshold2_ = 50.;
0023   const double Npe_to_V_ = 0.0064;
0024 
0025   const BTLPulseShape theShape;
0026 
0027   const size_t nampli(5);
0028   const std::array<float, nampli> npe{{8000., 4000., 3500., 1000., 100.}};
0029   std::vector<TH1F*> histVect;
0030 
0031   // standard display of the implemented shape function
0032   const int csize = 500;
0033   TCanvas* showShape = new TCanvas("showShape", "showShape", csize, 2 * csize);
0034 
0035   for (size_t index = 0; index < nampli; index++) {
0036     const double scale = npe[index] / ReferencePulseNpe_;
0037     const std::array<float, 3> tATt(
0038         theShape.timeAtThr(scale, TimeThreshold1_ * Npe_to_V_, TimeThreshold2_ * Npe_to_V_));
0039 
0040     TString name = "BTLShape_" + std::to_string(index);
0041     histVect.emplace_back(new TH1F(name, "Tabulated BTL shape", histsiz, 0., (float)(histsiz)));
0042 
0043     std::cout << "Tabulated BTL shape, scale vs reference = " << std::fixed << std::setw(6) << std::setprecision(2)
0044               << scale << " maximum at [" << std::fixed << std::setw(6) << std::setprecision(2) << theShape.indexOfMax()
0045               << " ] = " << std::fixed << std::setw(6) << std::setprecision(2) << theShape.timeOfMax() << std::endl;
0046     std::cout << "Time at thresholds:\n"
0047               << std::fixed << std::setw(8) << std::setprecision(3) << TimeThreshold1_ * Npe_to_V_ << " --> " << tATt[0]
0048               << "\n"
0049               << std::fixed << std::setw(8) << std::setprecision(3) << TimeThreshold2_ * Npe_to_V_ << " --> " << tATt[1]
0050               << "\n"
0051               << std::fixed << std::setw(8) << std::setprecision(3) << TimeThreshold1_ * Npe_to_V_ << " --> " << tATt[2]
0052               << "\n"
0053               << std::endl;
0054 
0055     for (unsigned int i = 0; i <= histsiz; ++i) {
0056       const double time((i + 0.5) / BTLPulseShape::kNBinsPerNSec);
0057       const double myShape(theShape(time));
0058       histVect[index]->SetBinContent(i, myShape * scale);
0059       histVect[index]->SetBinError(i, 0.001);
0060       std::cout << " bin = " << std::fixed << std::setw(4) << i << " time (ns) = " << std::fixed << std::setw(6)
0061                 << std::setprecision(3) << time << " shape = " << std::setw(11) << std::setprecision(8)
0062                 << myShape * scale << std::endl;
0063     }
0064 
0065     showShape->cd();
0066     histVect[index]->SetStats(kFALSE);
0067     histVect[index]->Draw("SAME");
0068   }
0069 
0070   showShape->SaveAs("BTLShape.pdf");
0071 
0072   return 0;
0073 }