Belle II Software development
top modules

Classes

class  TOPAlignmentCollectorModule
 Collector for geometrical alignment of a TOP module with dimuons or Bhabhas. More...
 
class  TOPAsicShiftsBS13dCollectorModule
 Collector for carrier shifts of BS13d. More...
 
class  TOPChannelMaskCollectorModule
 Collector for preparing masks of hot and dead channels. More...
 
class  TOPCommonT0BFCollectorModule
 Collector for common T0 calibration with a fit of bunch finder residuals (method BF) More...
 
class  TOPCommonT0LLCollectorModule
 Collector for common T0 calibration with neg. More...
 
class  TOPModuleT0DeltaTCollectorModule
 Collector for module T0 calibration with chi2 minimization of time differences between slots (method DeltaT). More...
 
class  TOPModuleT0LLCollectorModule
 Collector for module T0 calibration with neg. More...
 
class  TOPOffsetCollectorModule
 Collector for eventT0 and fill pattern offset calibrations. More...
 
class  TOPPhotonYieldsCollectorModule
 Collector for photon pixel yields aimed for PMT ageing studies and for finding optically decoupled PMT's. More...
 
class  TOPPulseHeightCollectorModule
 Collector for channel pulse-height distributions. More...
 
class  TOPValidationCollectorModule
 Collector for automatic validation of calibration with dimuon events. More...
 
class  OpticalGunModule
 Source of optical photons for the simulation of the TOP laser system. More...
 
class  TOPAlignerModule
 Alignment of TOP. More...
 
class  TOPBackgroundModule
 TOP backgound module. More...
 
class  TOPBunchFinderModule
 Bunch finder: searches for the bunch crossing where the interaction happened using track-based TOP likelihood. More...
 
class  TOPChannelMaskerModule
 Masks dead PMs from the reconstruction. More...
 
class  TOPChannelT0CalibratorModule
 A module for alternative channel T0 calibration with collision data Note: after this kind of calibration one cannot do the geometrical alignment This module can also be used to check the calibration. More...
 
class  TOPChannelT0MCModule
 TOP Channel T0 MC Extraction module (under development) More...
 
class  TOPCommonT0CalibratorModule
 A module for common T0 calibration with collision data (dimuons or bhabhas) More...
 
class  TOPCosmicT0FinderModule
 Event T0 finder for global cosmic runs. More...
 
class  TOPDigitizerModule
 TOP digitizer. More...
 
class  TOPTriggerDigitizerModule
 Digitizer that provides time stamps for TOP trigger. More...
 
class  TOPCalPulseGeneratorModule
 Generator of calibration pulses Output to TOPSimCalPulses. More...
 
class  TOPDoublePulseGeneratorModule
 Generator of double calibration pulses Output to TOPDigits. More...
 
class  TOPDQMModule
 TOP DQM histogrammer. More...
 
class  TOPGainEfficiencyCalculatorModule
 Module for channel-by-channel gain/efficiency analysis. More...
 
class  TOPLaserHitSelectorModule
 Module for pixel-by-pixel gain/efficiency analysis. More...
 
class  TOPGeometryParInitializerModule
 Class for initializing TOPGeometryPar. More...
 
class  TOPInterimFENtupleModule
 Module to produce ntuple from TOPDigits and TOPRawDigits. More...
 
class  TOPLaserCalibratorModule
 T0 Laser calibration module (under development) More...
 
class  TOPLaserCalibratorCollectorModule
 Collector module for the TOP channelT0 calibration and, more in general, for the time resolution studies using the laser and pulser data. More...
 
class  TOPLLScannerModule
 A module to perform the TOP PID likelihood scan and find the actual minimum as function of the mass. More...
 
class  TOPMCTrackMakerModule
 Constructs Tracks and ExtHits from MCParticles and TOPBarHits Utility needed for testing and debugging of TOP reconstruction. More...
 
class  TOPModuleT0CalibratorModule
 A module for module T0 calibration with collision data (dimuons or bhabhas) Useful when the geometrical alignment need not to be repeated. More...
 
class  TOPNtupleModule
 Module to write out a ntuple summarizing TOP reconstruction output. More...
 
class  TOPPackerModule
 Raw data packer. More...
 
class  TOPPDFCheckerModule
 Module for checking analytic PDF used in likelihood calculation. More...
 
class  TOPPDFDebuggerModule
 TOP reconstruction module. More...
 
class  TOPRawDigitConverterModule
 TOPRawDigits to TOPDigits converter. More...
 
class  TOPReconstructorModule
 TOP reconstruction module. More...
 
class  TOPRingPlotterModule
 A module to plot the x-t images from TOP, and in general study the distribution of the digits associated to the particles in a particleList. More...
 
class  TOPTBCComparatorModule
 Module for the comparison of different sets of time base correction (TBC) constants and to produce monitoring plots out of a given set. More...
 
struct  Hit
 Structure to hold some of the calpulse data. More...
 
struct  TwoTimes
 Structure to hold calpulse raw times expressed in samples since sample 0 of window 0. More...
 
class  TOPTimeBaseCalibratorModule
 Time base calibrator. More...
 
class  TOPTimeRecalibratorModule
 Utility module for re-calibrating time of TOPDigits pulseWidth and timeError are not changed although they may depend no calibration! More...
 
class  TOPUnpackerModule
 Raw data unpacker. More...
 
class  TOPWaveformFeatureExtractorModule
 Waveform feature extractor: module adds rawDigits that are found in waveforms by feature extraction but are not already present in RawDigits. More...
 
class  TOPWaveformQualityPlotterModule
 Plots and histograms of waveforms and feature extracted parameters. More...
 
class  TOPXTalkChargeShareSetterModule
 Crosstalk & chargeshare flag setter. More...
 

Enumerations

enum  {
  c_NChannelPerAsic = 8 ,
  c_NModule = 16 ,
  c_NChannelPerPMT = 16 ,
  c_NChannelPerPMTRow = 4 ,
  c_NPMTPerRow = 16 ,
  c_NPMTPerModule = 32 ,
  c_NPixelPerRow = 64 ,
  c_NPixelPerModule = 512
}
 enum for maximum number of array elements (# of hits per event) More...
 

Functions

 REG_MODULE (TOPAlignmentCollector)
 Register module.
 
 REG_MODULE (TOPAsicShiftsBS13dCollector)
 Register module.
 
 REG_MODULE (TOPChannelMaskCollector)
 Register module.
 
 REG_MODULE (TOPCommonT0BFCollector)
 Register module.
 
 REG_MODULE (TOPCommonT0LLCollector)
 Register module.
 
 REG_MODULE (TOPModuleT0DeltaTCollector)
 Register module.
 
 REG_MODULE (TOPModuleT0LLCollector)
 Register module.
 
 REG_MODULE (TOPOffsetCollector)
 Register module.
 
 REG_MODULE (TOPPhotonYieldsCollector)
 Register module.
 
 REG_MODULE (TOPPulseHeightCollector)
 Register module.
 
 REG_MODULE (TOPValidationCollector)
 Register module.
 
 REG_MODULE (OpticalGun)
 Register module.
 
 REG_MODULE (TOPAligner)
 Register module.
 
 REG_MODULE (TOPBackground)
 Register the Module.
 
 REG_MODULE (TOPBunchFinder)
 Register module.
 
 REG_MODULE (TOPChannelMasker)
 Register the Module.
 
 REG_MODULE (TOPChannelT0Calibrator)
 Register module.
 
 REG_MODULE (TOPChannelT0MC)
 Register module.
 
 REG_MODULE (TOPCommonT0Calibrator)
 Register module.
 
 REG_MODULE (TOPCosmicT0Finder)
 Register module.
 
 REG_MODULE (TOPDigitizer)
 Register the Module.
 
 REG_MODULE (TOPTriggerDigitizer)
 Register the Module.
 
 REG_MODULE (TOPCalPulseGenerator)
 Register module.
 
 REG_MODULE (TOPDoublePulseGenerator)
 Register module.
 
 REG_MODULE (TOPDQM)
 Register module.
 
 REG_MODULE (TOPGainEfficiencyCalculator)
 Register the Module.
 
 REG_MODULE (TOPLaserHitSelector)
 Register the Module.
 
 REG_MODULE (TOPGeometryParInitializer)
 Register module.
 
 REG_MODULE (TOPInterimFENtuple)
 Register module.
 
 REG_MODULE (TOPLaserCalibrator)
 Register module.
 
 REG_MODULE (TOPMCTrackMaker)
 Register module.
 
 REG_MODULE (TOPModuleT0Calibrator)
 Register module.
 
 REG_MODULE (TOPNtuple)
 Register module.
 
 REG_MODULE (TOPPacker)
 Register module.
 
 REG_MODULE (TOPPDFChecker)
 Register module.
 
 REG_MODULE (TOPPDFDebugger)
 Register the Module.
 
 REG_MODULE (TOPRawDigitConverter)
 Register module.
 
 REG_MODULE (TOPReconstructor)
 Register the Module.
 
 REG_MODULE (TOPTBCComparator)
 Register module.
 
 REG_MODULE (TOPTimeBaseCalibrator)
 Register module.
 
 REG_MODULE (TOPTimeRecalibrator)
 Register module.
 
 REG_MODULE (TOPUnpacker)
 Register module.
 
 REG_MODULE (TOPWaveformFeatureExtractor)
 Register module.
 
 REG_MODULE (TOPWaveformQualityPlotter)
 Register module.
 
 TOPAlignmentCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPAsicShiftsBS13dCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPChannelMaskCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPCommonT0BFCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPCommonT0LLCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPModuleT0DeltaTCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPModuleT0LLCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPOffsetCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void startRun () final
 Replacement for beginRun().
 
virtual void collect () final
 Replacement for event().
 
 TOPPhotonYieldsCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPPulseHeightCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void collect () final
 Replacement for event().
 
 TOPValidationCollectorModule ()
 Constructor.
 
virtual void prepare () final
 Replacement for initialize().
 
virtual void startRun () final
 Replacement for beginRun().
 
virtual void collect () final
 Replacement for event().
 
virtual void closeRun () final
 Replacement for endRun().
 
 OpticalGunModule ()
 Constructor.
 
virtual ~OpticalGunModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
bool isInsideSlit (const ROOT::Math::XYZPoint &point, const ROOT::Math::XYZVector &direction) const
 Checks if photon passes the slit.
 
ROOT::Math::XYZVector getDirectionGaussian () const
 Return photon direction according to a projected 2D gaussian distribution based on numerical aperture NA.
 
ROOT::Math::XYZVector getDirectionUniform () const
 Return photon direction according to a projected uniform distribution with opening angle alpha.
 
ROOT::Math::XYZVector getDirectionLambertian () const
 Return photon direction according to a lambertian distribution with opening angle alpha.
 
ROOT::Math::XYZVector getDirectionCustom () const
 Return photon direction according to a custom angular distribution given by TFormula.
 
 TOPAlignerModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
 TOPBackgroundModule ()
 Constructor.
 
virtual ~TOPBackgroundModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
void myprint (TH1F *histo, const char *path, const char *xtit, const char *ytit, double tresh)
 Print histogram 1D, helper function.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
void printModuleParams () const
 Prints module parameters.
 
 TOPBunchFinderModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
Const::ChargedStable getMostProbable (const Track &track)
 Returns most probable charged stable particle according to dEdx and predefined prior probabilities.
 
int setFinder (TOP::Chi2MinimumFinder1D &finder, const TOP::PDFConstructor &reco, double timeMin, double timeMax)
 Sets finder object with chi2 values.
 
TimeSeed getTimeSeed ()
 Returns a time seed.
 
bool isBucketFilled (int bunchNo)
 Does reconstructed bunch number correspond to filled bucket.
 
 TOPChannelMaskerModule ()
 Constructor: Sets the description of the module.
 
virtual void initialize () override
 initialize method: registers datastore objects (the TOP hits)
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 event method: removes channels from the reconstruction pdf, flags hits from noisy channels as junk
 
 TOPChannelT0CalibratorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
 TOPChannelT0MCModule ()
 Constructor.
 
virtual ~TOPChannelT0MCModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPCommonT0CalibratorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
bool isRunningOffsetSubtracted ()
 Checks if running offset is subtracted in TOPDigits.
 
 TOPCosmicT0FinderModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
 TOPDigitizerModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
TimeOffset getTimeOffset (double trgOffset, int moduleID, int pixelID)
 Returns a complete time offset by adding time mis-calibration to trgOffset.
 
double generatePulseHeight (int moduleID, int pixelID) const
 Generates and returns pulse height.
 
 TOPTriggerDigitizerModule ()
 Constructor.
 
virtual ~TOPTriggerDigitizerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPCalPulseGeneratorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
 TOPDoublePulseGeneratorModule ()
 Constructor.
 
virtual ~TOPDoublePulseGeneratorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
void storeSampleTimes (std::string fileName)
 Optionally store sample times used by the generator as root histograms fileName root output file name.
 
void saveAsHistogram (const std::vector< double > &vec, const std::string &name, const std::string &title, const std::string &xTitle="", const std::string &yTitle="") const
 Save vector to histogram and write it out.
 
 TOPDQMModule ()
 Constructor.
 
virtual ~TOPDQMModule ()
 Destructor.
 
virtual void defineHisto () override
 Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
int getModuleID (const Track &track) const
 Returns slot ID of the module that is hit by the track.
 
 TOPGainEfficiencyCalculatorModule ()
 Constructor.
 
virtual ~TOPGainEfficiencyCalculatorModule ()
 Destructor.
 
virtual void initialize () override
 Load time vs charge 2D histogram from a given input file (paramter "inputFile") and prepare hit timing and pulse charge distribution for each channel.
 
virtual void defineHisto () override
 Define TTree branches to store fit results for each channel This TTree is saved in an output file given by "histoFileName" parameter of "HistoManager" module.
 
virtual void beginRun () override
 The main processes, fitting charge distribution and calculating gain/efficiency, are done in this function.
 
virtual void event () override
 This will be empty as the all the processes are done in beginRun() function thus input file can be a dummy file.
 
virtual void endRun () override
 Draw plots to show fitting results for each channel and save them into a given PDF file (outputPDFFile).
 
virtual void terminate () override
 Termination action.
 
void LoadHistograms (const std::string &histotype)
 Load 2D histograms from a given input file (output of TOPLaserHitSelector) and create timing and charge distribution as projection histograms for the x- and y-axis, respectively.
 
void FitHistograms (EHistogramType LoadHisto)
 Fit charge (or integrated charged) distribution to calculate gain and efficiency for each channel.
 
void DummyFillBranch (EHistogramType LoadHisto)
 Fill Dummy for Branch.
 
void DrawResult (const std::string &histotype, EHistogramType LoadHisto)
 Draw results of gain/efficiency calculation for each channel to a given output file.
 
static double TOPGainFunc (double *var, double *par)
 Fit function of pulse charge (or charnge) distribution for channel(pixel)-by-channel gain extraction, given by "[0]*pow(x-[4],[1])*exp(-pow(x-[4],[2])/[3])" smeared by Gaussian with a constant sigma to consider baseline fluctuation.
 
static double FindPeakForSmallerXThan (TH1 *histo, double xmax=0)
 Find peak and return its position for a limited range of x (x smaller than the given value (xmax))
 
 TOPLaserHitSelectorModule ()
 Constructor.
 
virtual ~TOPLaserHitSelectorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void defineHisto () override
 create timing-height 2D histograms for all 8192 pixels
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPGeometryParInitializerModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
 TOPInterimFENtupleModule ()
 Constructor.
 
virtual ~TOPInterimFENtupleModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void defineHisto () override
 Module funcions to define histograms.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
void getReferenceTiming ()
 Find reference timing.
 
 TOPLaserCalibratorModule ()
 Constructor.
 
virtual ~TOPLaserCalibratorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPMCTrackMakerModule ()
 Constructor.
 
virtual ~TOPMCTrackMakerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPModuleT0CalibratorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
bool isRunningOffsetSubtracted ()
 Checks if running offset is subtracted in TOPDigits.
 
 TOPNtupleModule ()
 Constructor.
 
virtual ~TOPNtupleModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPPackerModule ()
 Constructor.
 
virtual ~TOPPackerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
void packProductionDraft ()
 Pack in format: c_Draft (tentative production format) this format was never implemented in firmware!
 
void packType0Ver16 ()
 Pack in format: c_Type0Ver16 (Feature-extracted data) this format was never implemented in firmware!
 
void packProductionDebug ()
 Pack in format: Production Debugging Data Format 01.
 
 TOPPDFCheckerModule ()
 Constructor.
 
virtual void defineHisto () override
 Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
bool isFromThisParticle (const TOPDigit &digit, const MCParticle *particle)
 Checks if digit comes from given MC particle.
 
 TOPPDFDebuggerModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
void associatePDFPeaks (const TOP::PDFConstructor &pdfConstructor)
 Associate PDF peaks with photons using S-plot technique.
 
 TOPRawDigitConverterModule ()
 Constructor.
 
virtual ~TOPRawDigitConverterModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPReconstructorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
 TOPTBCComparatorModule ()
 Constructor.
 
void defineHisto () override
 Defining the histograms.
 
int analyzeCalFile ()
 Analyzes the calibrations stored in the file m_calSetFile.
 
int makeComparisons ()
 Last function to be called, compared the histograms of different datasets filled by analyzeCalFile() Every new comparison histogram added to the module has to be filled here.
 
void initialize () override
 Initialize the module.
 
void beginRun () override
 Called when entering a new run.
 
void event () override
 Event processor.
 
void endRun () override
 End-of-run action.
 
void terminate () override
 Termination action.
 
int parseInputDirectoryLine (std::string)
 Utility function to get the directory name and the label from a line of the m_inputDirectoryList file Sets the values of m_calSetDirectory and m_calSetLabel.
 
int parseSlotAndScrodIDfromFileName (std::string)
 Utility function to parse the slot and BS id from the calibration file names.
 
TH1F * calculateHistoRatio (TH1F *, TH1F *, TH1F *)
 Utility function to take the ratio of two histograms using TH1::Divide(), without overwriting the output name and title initialized in defineHisto().
 
TH2F * calculateHistoRatio (TH2F *, TH2F *, TH2F *)
 Utility function to take the ratio of two histograms using TH2::Divide(), without overwriting the output name and title initialized in defineHisto().
 
 TOPTimeBaseCalibratorModule ()
 Constructor.
 
virtual ~TOPTimeBaseCalibratorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
bool calibrateChannel (std::vector< TwoTimes > &ntuple, unsigned scrodID, unsigned scrodChannel, TH1F &Hchi2, TH1F &Hndf, TH1F &HDeltaT)
 calibrate single channel
 
bool matrixInversion (const std::vector< TwoTimes > &ntuple, unsigned scrodID, unsigned scrodChannel, double meanTimeDifference, TH1F &Hchi2, TH1F &Hndf, TH1F &HDeltaT)
 Method by matrix inversion.
 
bool iterativeTBC (const std::vector< TwoTimes > &ntuple, unsigned scrodID, unsigned scrodChannel, double meanTimeDifference, TH1F &Hchi2, TH1F &Hndf, TH1F &HDeltaT)
 Method by iteration of chi2 minimization.
 
void Iteration (const std::vector< TwoTimes > &ntuple, std::vector< double > &xval)
 Iteration function called by iterativeTBC()
 
double Chisq (const std::vector< TwoTimes > &ntuple, const std::vector< double > &xxval)
 Return the chisqure of one set of TBC constants (xval) in iTBC calculaton.
 
void saveAsHistogram (const std::vector< double > &vec, const std::string &name, const std::string &title, const std::string &xTitle="", const std::string &yTitle="") const
 Save vector to histogram and write it out.
 
void saveAsHistogram (const std::vector< double > &vec, const std::vector< double > &err, const std::string &name, const std::string &title, const std::string &xTitle="", const std::string &yTitle="") const
 Save vector and errors to histogram and write it out.
 
void saveAsHistogram (const TMatrixDSym &M, const std::string &name, const std::string &title) const
 Save matrix to histogram and write it out.
 
 TOPTimeRecalibratorModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
 TOPUnpackerModule ()
 Constructor.
 
virtual ~TOPUnpackerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
std::string getFrontEndName (RawTOP &raw, int finesse) const
 Returns the name of the front-end.
 
bool printTheError ()
 Error messages suppression logic.
 
void unpackProductionDraft (const int *buffer, int bufferSize)
 Unpack raw data given in a tentative production format (will vanish in future)
 
void unpackType0Ver16 (const int *buffer, int bufferSize)
 Unpack raw data given in feature-extraction production format.
 
bool unpackHeadersInterimFEVer01 (const int *buffer, int bufferSize, bool swapBytes)
 Tries to unpack raw data assuming it is in feature-extraction interim format.
 
int unpackInterimFEVer01 (const int *buffer, int bufferSize, bool pedestalSubtracted)
 Unpack raw data given in feature-extraction interim format.
 
int unpackProdDebug (const int *buffer, int bufferSize, TOP::RawDataType dataFormat, bool pedestalSubtracted)
 Unpack raw data given in production debugging format.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPWaveformFeatureExtractorModule ()
 Constructor.
 
virtual ~TOPWaveformFeatureExtractorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
virtual void terminate () override
 Termination action.
 
 TOPWaveformQualityPlotterModule ()
 Constructor.
 
void defineHisto () override
 Books the empty histograms.
 
void initialize () override
 Module initialization, calls defineHisto and gets waveform.
 
void basicDebuggingPlots (const TOPRawWaveform &rawwave)
 Fills the debugging 1D histograms and hitmaps.
 
void drawWaveforms (const TOPRawWaveform &rawwave)
 Draws the full waveforms onto the TProfiles.
 
void event () override
 Event processor.
 
void endRun () override
 End-of-run action.
 

Detailed Description

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

enum for maximum number of array elements (# of hits per event)

Definition at line 24 of file TOPLaserHitSelectorModule.h.

24 { c_NChannelPerAsic = 8, c_NModule = 16, c_NChannelPerPMT = 16,
25 c_NChannelPerPMTRow = 4, c_NPMTPerRow = 16,
26 c_NPMTPerModule = 32, c_NPixelPerRow = 64, c_NPixelPerModule = 512
27 };

Function Documentation

◆ analyzeCalFile()

int analyzeCalFile ( )

Analyzes the calibrations stored in the file m_calSetFile.

This is the main function in which the analysis and the hisogram filling takes place. Every new monitoring histogram added to the module has to be filled here.

Definition at line 207 of file TOPTBCComparatorModule.cc.

208 {
209 // Here the histograms are filled
210 // WARNING! What root calls "RMS" is actually a standard deviation
211
212 // Sanity check on the parsed parameters
213 if (m_slotID < 0 || m_boardstackID < 0 || m_scrodID < 0) {
214 B2WARNING("Negative slot, BS or scrod ID found while calling analyzeCalFile(). Looks like they have not been initialized, or that a function re-initialized them");
215 return 0;
216 }
217
218 // Loop over all the histograms that should be found in the file
219 for (short iChannel = 0; iChannel < 128; iChannel++) {
220
221 // Pics up one histogram just to check that the channel iChannel was actually used to calculate the calibrations
222 if (!m_calSetFile->Get(str(format("timeDiff_ch%1%") % (iChannel)).c_str())) {
223 continue;
224 }
225
226
227 // ---------
228 // 1) Define some channel numbering quantities
229 // Watchout: m_slotID is in [1..16] so slot m_slotID is on the element m_slotID-1 of the array
230 // ---------
231
232 short hardwareChannel = iChannel + 128 * m_boardstackID; // 0-511 across the whole module, BS by BS
233 auto& chMapper = TOP::TOPGeometryPar::Instance()->getChannelMapper();
234 short pixelID = chMapper.getPixelID(hardwareChannel); // 1-512 across the whole module, in rows
235 short colNum = (pixelID - 1) % 64 + 1; // 1- 64 column ID (right to left looking from the quartz to the PMTs)
236 short rowNum = (pixelID - 1) / 64 + 1 ; // 1- 8 row ID (bottom to top looking from the quartz to the PMTs)
237 short globalChannel = hardwareChannel + 512 * (m_slotID -
238 1); // channel number across the whole detector, 0-8191. Used for cal monitorin only
239
240
241 // ---------
242 // 2) Channel-by-channel DeltaT summaries (average on the 256 samples of each set)
243 // ---------
244
245 // Checks that the histogram needed here is not corrupted before using it
246 if (!m_calSetFile->Get(str(format("timeDiffcal_ch%1%") % (iChannel)).c_str())) {
247 B2WARNING("Error opening " << str(format("timeDiffcal_ch%1%") % (iChannel)));
248 } else {
249 TH2F* h_timeDiffcal = (TH2F*)m_calSetFile->Get(str(format("timeDiffcal_ch%1%") % (iChannel)).c_str());
250 TH1D* h_projection = h_timeDiffcal->ProjectionY("h_projection", 1, m_numSamples); // full projection
251
252 m_slotAverageDeltaT[m_slotID - 1][m_calSetID]->SetBinContent(hardwareChannel + 1, h_projection->GetMean());
253 m_slotAverageDeltaT[m_slotID - 1][m_calSetID]->SetBinError(hardwareChannel + 1,
254 h_projection->GetMeanError()); // Do we trust root on this?
255 m_slotSigmaDeltaT[m_slotID - 1][m_calSetID]->SetBinContent(hardwareChannel + 1,
256 h_projection->GetRMS()); // WARNING! What root calls "RMS" is actually a standard deviation
257 m_slotSigmaDeltaT[m_slotID - 1][m_calSetID]->SetBinError(hardwareChannel + 1,
258 h_projection->GetRMSError()); // WARNING! What root calls "RMS" is actually a standard deviation
259
260 m_slotAverageDeltaTMap[m_slotID - 1][m_calSetID]->SetBinContent(colNum, rowNum, h_projection->GetMean());
261 m_slotSigmaDeltaTMap[m_slotID - 1][m_calSetID]->SetBinContent(colNum, rowNum,
262 h_projection->GetRMS());
263
264 m_topAverageDeltaT[m_calSetID]->SetBinContent(globalChannel + 1, h_projection->GetMean());
265 m_topSigmaDeltaT[m_calSetID]->SetBinContent(globalChannel + 1, h_projection->GetRMS());
266 }
267
268 // ---------
269 // 3) Channel-by-channel average occupancy
270 // ---------
271
272 // Checks that the histogram needed here is not corrupted before using it
273 if (!m_calSetFile->Get(str(format("sampleOccup_ch%1%") % (iChannel)).c_str())) {
274 B2WARNING("Error opening " << str(format("sampleOccup_ch%1%") % (iChannel)));
275 } else {
276 TH1F* h_sampleOccup = (TH1F*)m_calSetFile->Get(str(format("sampleOccup_ch%1%") % (iChannel)).c_str());
277
278 // reads the occupancy histogram bin-by-by to look for (almost) empty samples
279 int nEmpty = 0;
280 for (int iSample = 1; iSample < m_numSamples + 1 ; iSample++) {
281 if (h_sampleOccup->GetBinContent(iSample) < m_minCalPulses) nEmpty++;
282 }
283
284 m_slotSampleOccupancy[m_slotID - 1][m_calSetID]->SetBinContent(hardwareChannel + 1, h_sampleOccup->Integral() / m_numSamples);
285 m_slotEmptySamples[m_slotID - 1][m_calSetID]->SetBinContent(hardwareChannel + 1, nEmpty);
286
287 m_slotSampleOccupancyMap[m_slotID - 1][m_calSetID]->SetBinContent(colNum, rowNum, h_sampleOccup->Integral() / m_numSamples);
288 m_slotEmptySamplesMap[m_slotID - 1][m_calSetID]->SetBinContent(colNum, rowNum, nEmpty);
289
290 m_topSampleOccupancy[m_calSetID]->SetBinContent(globalChannel + 1, h_sampleOccup->Integral() / m_numSamples);
291
292 }
293
294
295
296 }
297 return 1;
298 }

◆ associatePDFPeaks()

void associatePDFPeaks ( const TOP::PDFConstructor & pdfConstructor)
private

Associate PDF peaks with photons using S-plot technique.

Parameters
pdfConstructorreconstruction object for given track and hypothesis

Definition at line 192 of file TOPPDFDebuggerModule.cc.

193 {
194
195 const auto& signalPDFs = pdfConstructor.getSignalPDF();
196 auto signalPhotons = pdfConstructor.getExpectedSignalPhotons();
197 auto bkgPhotons = pdfConstructor.getExpectedBkgPhotons();
198 auto deltaPhotons = pdfConstructor.getExpectedDeltaPhotons();
199 int PDGCode = pdfConstructor.getHypothesis().getPDGCode();
200
201 for (const auto& digit : m_digits) {
202 if (digit.getModuleID() != pdfConstructor.getModuleID()) continue;
203 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
204 int pixelID = digit.getPixelID();
205 unsigned index = pixelID - 1;
206 if (index >= signalPDFs.size()) continue;
207 const auto& signalPDF = signalPDFs[index];
208 const auto* tts = signalPDF.getTTS();
209 const auto& pdfPeaks = signalPDF.getPDFPeaks();
210 const auto& extraInfos = signalPDF.getPDFExtraInfo();
211 if (extraInfos.size() != pdfPeaks.size()) {
212 B2ERROR("associatePDFPeaks: sizes of PDFPeaks and ExtraInfo's differ");
213 continue;
214 }
215
216 auto* associatedPDF = m_associatedPDFs.appendNew(PDGCode);
217 digit.addRelationTo(associatedPDF);
218
219 double bkgLevel = pdfConstructor.getBackgroundPDF()->getPDFValue(pixelID) * bkgPhotons;
220 associatedPDF->setBackgroundWeight(bkgLevel);
221 double deltaLevel = pdfConstructor.getDeltaRayPDF().getPDFValue(pixelID, digit.getTime()) * deltaPhotons;
222 associatedPDF->setDeltaRayWeight(deltaLevel);
223
224 float time = digit.getTime();
225 float timeErr = digit.getTimeError();
226
227 for (size_t k = 0; k < pdfPeaks.size(); k++) {
228 const auto& pdfPeak = pdfPeaks[k];
229 const auto& pdfExtra = extraInfos[k];
230 TOPAssociatedPDF::PDFPeak peak;
231 peak.position = pdfPeak.t0;
232 peak.width = sqrt(pdfPeak.wid);
233 peak.numPhotons = pdfPeak.nph * signalPhotons;
234 float wt = 0;
235 for (const auto& gaus : tts->getTTS()) {
236 float sig2 = peak.width * peak.width + gaus.sigma * gaus.sigma + timeErr * timeErr;
237 float x = pow(time - peak.position - gaus.position, 2) / sig2;
238 if (x > 20) continue;
239 wt += peak.numPhotons * gaus.fraction / sqrt(2 * M_PI * sig2) * exp(-x / 2);
240 }
241 if (wt > 0) {
242 peak.fic = pdfPeak.fic;
243 peak.e = pdfExtra.e;
244 peak.sige = pdfExtra.sige;
245 peak.nx = abs(pdfExtra.Nxm) + abs(pdfExtra.Nxb) + abs(pdfExtra.Nxe);
246 peak.ny = abs(pdfExtra.Nym) + abs(pdfExtra.Nyb) + abs(pdfExtra.Nye);
247 peak.nxm = abs(pdfExtra.Nxm);
248 peak.nym = abs(pdfExtra.Nym);
249 peak.nxe = abs(pdfExtra.Nxe);
250 peak.nye = abs(pdfExtra.Nye);
251 peak.xd = pdfExtra.xD;
252 peak.yd = pdfExtra.yD;
253 peak.type = pdfExtra.type;
254 peak.kxe = pdfExtra.kxE;
255 peak.kye = pdfExtra.kyE;
256 peak.kze = pdfExtra.kzE;
257 peak.kxd = pdfExtra.kxD;
258 peak.kyd = pdfExtra.kyD;
259 peak.kzd = pdfExtra.kzD;
260 associatedPDF->appendPeak(peak, wt);
261 }
262 }
263 }
264
265 }
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

◆ basicDebuggingPlots()

void basicDebuggingPlots ( const TOPRawWaveform & rawwave)

Fills the debugging 1D histograms and hitmaps.

Parameters
rawwavethe raw waveform

Definition at line 81 of file TOPWaveformQualityPlotterModule.cc.

82 {
83 int scrodid = v.getScrodID();
84 int asicid = v.getASICNumber();
85 int channelid = v.getASICChannel();
86 int carrierid = v.getCarrierNumber();
87 m_scrod_id->Fill(scrodid);
88 m_asic_ch->Fill(channelid);
89 m_asic->Fill(asicid);
90 m_carrier->Fill(carrierid);
91 m_asic_win->Fill(v.getStorageWindow());
92 m_entries->Fill(v.getWaveform().size());
93 m_moduleID->Fill(v.getModuleID());
94 m_pixelID->Fill(v.getPixelID());
95
96 if (m_hitmap.find(scrodid) == m_hitmap.end()) {
97 m_hitmap[scrodid] = new TH2F((string("scrod ") + to_string(scrodid) + string("Hitmap")).c_str(),
98 (string("scrod ") + to_string(scrodid) + string("carrier vs. asic;asic;carrier")).c_str(), 4, 0, 4, 4, 0, 4);
99 }
100 m_hitmap[scrodid]->Fill(asicid, carrierid);
101 const vector<short>& waveform = v.getWaveform();
102 if (waveform.empty()) {
103 return;
104 }
105 for (short adc : waveform) {
106 m_samples->Fill(adc);
107 }
108 }

◆ beginRun() [1/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 194 of file TOPBackgroundModule.cc.

195 {
196 // Print run number
197 B2INFO("TOPBackground: Processing:");
198
199 }

◆ beginRun() [2/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 202 of file TOPBunchFinderModule.cc.

203 {
204 StoreObjPtr<EventMetaData> evtMetaData;
205
206 if (not m_commonT0.isValid()) {
207 B2FATAL("Common T0 calibration payload requested but not available for run "
208 << evtMetaData->getRun()
209 << " of experiment " << evtMetaData->getExperiment());
210 }
211
212 if (m_HLTmode) return;
213
214 if (m_useTimeSeed and not m_eventT0Offset.isValid()) {
215 B2WARNING("EventT0Offset not available for run "
216 << evtMetaData->getRun()
217 << " of experiment " << evtMetaData->getExperiment()
218 << ": seeding with SVD or CDC eventT0 will not be done.");
219 }
220 if (m_useFillPattern) {
221 if (not m_bunchStructure->isSet()) {
222 B2WARNING("BunchStructure not available for run "
223 << evtMetaData->getRun()
224 << " of experiment " << evtMetaData->getExperiment()
225 << ": fill pattern will not be used.");
226 }
227 if (not m_fillPatternOffset.isValid()) {
228 B2WARNING("FillPatternOffset not available for run "
229 << evtMetaData->getRun()
230 << " of experiment " << evtMetaData->getExperiment()
231 << ": fill pattern will not be used.");
232 }
233 }
234
235 }

◆ beginRun() [3/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 54 of file TOPChannelMaskerModule.cc.

55 {
56
57 if (not m_channelMask.isValid()) {
58 B2FATAL("channel mask not available");
59 }
60 if (not m_channelT0.isValid()) {
61 B2FATAL("channel T0 calibration not available");
62 }
63 if (not m_timebase.isValid()) {
64 B2FATAL("timebase calibration not available");
65 }
66
67 }

◆ beginRun() [4/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 63 of file TOPChannelT0MCModule.cc.

64 {
65 }

◆ beginRun() [5/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 142 of file TOPDigitizerModule.cc.

143 {
144 StoreObjPtr<EventMetaData> evtMetaData;
145
146 // check availability of mappers
147 const auto& channelMapper = TOPGeometryPar::Instance()->getChannelMapper();
148 if (not channelMapper.isValid()) {
149 B2FATAL("No valid channel mapper found for run "
150 << evtMetaData->getRun()
151 << " of experiment " << evtMetaData->getExperiment());
152 }
153 const auto& frontEndMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
154 if (not frontEndMapper.isValid()) {
155 B2FATAL("No valid front-end mapper found for run "
156 << evtMetaData->getRun()
157 << " of experiment " << evtMetaData->getExperiment());
158 }
159
160 // check availability of constants in database
161 if (m_useDatabase) {
162 if (not m_timebases.isValid()) {
163 B2FATAL("Sample time calibration constants requested but not available for run "
164 << evtMetaData->getRun()
165 << " of experiment " << evtMetaData->getExperiment());
166 }
167 if (not m_channelT0.isValid()) {
168 B2FATAL("Channel T0 calibration constants requested but not available for run "
169 << evtMetaData->getRun()
170 << " of experiment " << evtMetaData->getExperiment());
171 }
172 if (not m_asicShift.isValid()) {
173 B2FATAL("ASIC shifts calibration requested but not available for run "
174 << evtMetaData->getRun()
175 << " of experiment " << evtMetaData->getExperiment());
176 }
177 if (not m_moduleT0.isValid()) {
178 B2FATAL("Module T0 calibration constants requested but not available for run "
179 << evtMetaData->getRun()
180 << " of experiment " << evtMetaData->getExperiment());
181 }
182 if (not m_commonT0.isValid()) {
183 B2FATAL("Common T0 calibration constants requested but not available for run "
184 << evtMetaData->getRun()
185 << " of experiment " << evtMetaData->getExperiment());
186 }
187 if (not m_pulseHeights.isValid()) {
188 B2FATAL("Pulse height calibration constants requested but not available for run "
189 << evtMetaData->getRun()
190 << " of experiment " << evtMetaData->getExperiment());
191 }
192 if (not m_thresholds.isValid()) {
193 B2FATAL("Channel thresholds requested but not available for run "
194 << evtMetaData->getRun()
195 << " of experiment " << evtMetaData->getExperiment());
196 }
197 if (not m_noises.isValid()) {
198 B2FATAL("Channel noise levels requested but not available for run "
199 << evtMetaData->getRun()
200 << " of experiment " << evtMetaData->getExperiment());
201 }
202 if (m_timeWalk.isValid()) {
203 TimeDigitizer::setTimeWalk(&m_timeWalk);
204 } else {
205 TimeDigitizer::setTimeWalk(0);
206 // B2FATAL("Time-walk parameters requested but not available for run "
207 B2WARNING("Time-walk parameters not available for run "
208 << evtMetaData->getRun()
209 << " of experiment " << evtMetaData->getExperiment());
210 }
211 } else if (m_useSampleTimeCalibration) {
212 if (not m_timebases.isValid()) {
213 B2FATAL("Sample time calibration constants requested but not available for run "
214 << evtMetaData->getRun()
215 << " of experiment " << evtMetaData->getExperiment());
216 }
217 }
218
219 // check availability of front-end settings
220 if (not m_feSetting.isValid()) {
221 B2FATAL("Front-end settings are not available for run "
222 << evtMetaData->getRun()
223 << " of experiment " << evtMetaData->getExperiment());
224 }
225
226 // pass a parameter to TimeDigitizer
227 TimeDigitizer::setReadoutWindows(m_feSetting->getReadoutWindows());
228 if ((evtMetaData->getExperiment() > 0 and evtMetaData->getExperiment() < 5) or
229 evtMetaData->getExperiment() == 1002) {
230 TimeDigitizer::maskSamples(true); // phase-2: mask samples at window boundaries
231 } else {
232 TimeDigitizer::maskSamples(false); // phase-3: no masking
233 }
234
235 }

◆ beginRun() [6/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 148 of file TOPDoublePulseGeneratorModule.cc.

149 {
150 StoreObjPtr<EventMetaData> evtMetaData;
151 if (m_useDatabase) {
152 if (!(*m_timebase).isValid()) {
153 B2FATAL("Sample time calibration requested but not available for run "
154 << evtMetaData->getRun()
155 << " of experiment " << evtMetaData->getExperiment());
156 }
157 }
158
159 }

◆ beginRun() [7/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from HistoModule.

Definition at line 307 of file TOPDQMModule.cc.

308 {
309 m_BoolEvtMonitor->Reset();
310 m_window_vs_slot->Reset();
311 m_eventT0->Reset();
312 m_bunchOffset->Reset();
313 m_time->Reset();
314 m_timeBG->Reset();
315 m_signalHits->Reset();
316 m_backgroundHits->Reset();
317 m_trackHits->Reset();
318 m_goodTDCAll->Reset();
319 m_badTDCAll->Reset();
320 m_goodHitsPerEventAll->Reset();
321 m_badHitsPerEventAll->Reset();
322 m_TOPOccAfterInjLER->Reset();
323 m_TOPOccAfterInjHER->Reset();
324 m_TOPEOccAfterInjLER->Reset();
325 m_TOPEOccAfterInjHER->Reset();
326 m_nhitInjLER->Reset();
327 m_nhitInjHER->Reset();
328 m_nhitInjLERcut->Reset();
329 m_nhitInjHERcut->Reset();
330 m_eventInjLER->Reset();
331 m_eventInjHER->Reset();
332 m_eventInjLERcut->Reset();
333 m_eventInjHERcut->Reset();
334
335 for (int i = 0; i < m_numModules; i++) {
336 m_window_vs_asic[i]->Reset();
337 m_goodHitsXY[i]->Reset();
338 m_badHitsXY[i]->Reset();
339 m_goodHitsAsics[i]->Reset();
340 m_badHitsAsics[i]->Reset();
341 m_goodTDC[i]->Reset();
342 m_badTDC[i]->Reset();
343 m_goodTiming[i]->Reset();
344 m_goodTimingBG[i]->Reset();
345 m_goodChannelHits[i]->Reset();
346 m_badChannelHits[i]->Reset();
347 m_pulseHeights[i]->Reset();
348 }
349 }

◆ beginRun() [8/22]

void beginRun ( void )
overridevirtual

The main processes, fitting charge distribution and calculating gain/efficiency, are done in this function.

Reimplemented from HistoModule.

Definition at line 160 of file TOPGainEfficiencyCalculatorModule.cc.

161 {
162 }

◆ beginRun() [9/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from HistoModule.

Definition at line 159 of file TOPInterimFENtupleModule.cc.

160 {
161 }

◆ beginRun() [10/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 81 of file TOPLaserCalibratorModule.cc.

82 {
83 }

◆ beginRun() [11/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from HistoModule.

Definition at line 150 of file TOPLaserHitSelectorModule.cc.

151 {
152 }

◆ beginRun() [12/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 88 of file TOPMCTrackMakerModule.cc.

89 {
90 }

◆ beginRun() [13/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 160 of file TOPModuleT0CalibratorModule.cc.

161 {
162 if (m_moduleT0.hasChanged()) {
163 StoreObjPtr<EventMetaData> evtMetaData;
164 B2WARNING("ModuleT0 payload has changed. Calibration results may not be correct."
165 << LogVar("run", evtMetaData->getRun()));
166 }
167 }

◆ beginRun() [14/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 127 of file TOPNtupleModule.cc.

128 {
129 }

◆ beginRun() [15/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 99 of file TOPPackerModule.cc.

100 {
101 }

◆ beginRun() [16/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 132 of file TOPRawDigitConverterModule.cc.

133 {
134
135 StoreObjPtr<EventMetaData> evtMetaData;
136
137 // check if calibrations are available when needed - if not, terminate
138
139 if (m_useSampleTimeCalibration) {
140 if (not m_timebase.isValid()) {
141 B2FATAL("Sample time calibration requested but not available for run "
142 << evtMetaData->getRun()
143 << " of experiment " << evtMetaData->getExperiment());
144 }
145 }
146 if (m_useChannelT0Calibration) {
147 if (not m_channelT0.isValid()) {
148 B2FATAL("Channel T0 calibration requested but not available for run "
149 << evtMetaData->getRun()
150 << " of experiment " << evtMetaData->getExperiment());
151 }
152 }
153 if (m_useAsicShiftCalibration) {
154 if (not m_asicShift.isValid()) {
155 B2FATAL("ASIC shifts calibration requested but not available for run "
156 << evtMetaData->getRun()
157 << " of experiment " << evtMetaData->getExperiment());
158 }
159 }
160 if (m_useModuleT0Calibration) {
161 if (not m_moduleT0.isValid()) {
162 B2FATAL("Module T0 calibration requested but not available for run "
163 << evtMetaData->getRun()
164 << " of experiment " << evtMetaData->getExperiment());
165 }
166 }
167 if (m_useCommonT0Calibration) {
168 if (not m_commonT0.isValid()) {
169 B2FATAL("Common T0 calibration requested but not available for run "
170 << evtMetaData->getRun()
171 << " of experiment " << evtMetaData->getExperiment());
172 }
173 }
174 if (not m_timeWalk.isValid()) {
175 // B2FATAL("Time-walk calibration is not available for run "
176 B2WARNING("Time-walk calibration is not available for run "
177 << evtMetaData->getRun()
178 << " of experiment " << evtMetaData->getExperiment());
179 }
180 if (m_pedestalRMS > 0 and not m_noises.isValid()) {
181 B2FATAL("Channel noise levels are not available for run "
182 << evtMetaData->getRun()
183 << " of experiment " << evtMetaData->getExperiment());
184 }
185
186 if (not m_feSetting.isValid()) {
187 B2FATAL("Front-end settings are not available for run "
188 << evtMetaData->getRun()
189 << " of experiment " << evtMetaData->getExperiment());
190 }
191
192 }

◆ beginRun() [17/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Reimplemented from HistoModule.

Definition at line 341 of file TOPTBCComparatorModule.cc.

342 {
343 return;
344 }

◆ beginRun() [18/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 143 of file TOPTimeBaseCalibratorModule.cc.

144 {
145 }

◆ beginRun() [19/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 85 of file TOPTimeRecalibratorModule.cc.

86 {
87 StoreObjPtr<EventMetaData> evtMetaData;
88
89 // check if calibrations are available when needed - if not, terminate
90
91 if (m_useSampleTimeCalibration) {
92 if (not m_timebase.isValid()) {
93 B2FATAL("Sample time calibration requested but not available for run "
94 << evtMetaData->getRun()
95 << " of experiment " << evtMetaData->getExperiment());
96 }
97 }
98 if (m_useChannelT0Calibration) {
99 if (not m_channelT0.isValid()) {
100 B2FATAL("Channel T0 calibration requested but not available for run "
101 << evtMetaData->getRun()
102 << " of experiment " << evtMetaData->getExperiment());
103 }
104 }
105 if (m_useAsicShiftCalibration) {
106 if (not m_asicShift.isValid()) {
107 B2FATAL("ASIC shifts calibration requested but not available for run "
108 << evtMetaData->getRun()
109 << " of experiment " << evtMetaData->getExperiment());
110 }
111 }
112 if (m_useModuleT0Calibration) {
113 if (not m_moduleT0.isValid()) {
114 B2FATAL("Module T0 calibration requested but not available for run "
115 << evtMetaData->getRun()
116 << " of experiment " << evtMetaData->getExperiment());
117 }
118 }
119 if (m_useCommonT0Calibration) {
120 if (not m_commonT0.isValid()) {
121 B2FATAL("Common T0 calibration requested but not available for run "
122 << evtMetaData->getRun()
123 << " of experiment " << evtMetaData->getExperiment());
124 }
125 }
126 if (m_useTimeWalkCalibration) {
127 if (not m_timeWalk.isValid()) {
128 // B2FATAL("Time-walk calibration requested but not available for run "
129 B2WARNING("Time-walk calibration is not available for run "
130 << evtMetaData->getRun()
131 << " of experiment " << evtMetaData->getExperiment());
132 }
133 }
134
135 if (not m_feSetting.isValid()) {
136 B2FATAL("Front-end settings are not available for run "
137 << evtMetaData->getRun()
138 << " of experiment " << evtMetaData->getExperiment());
139 }
140
141 }

◆ beginRun() [20/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 86 of file TOPTriggerDigitizerModule.cc.

87 {
88 }

◆ beginRun() [21/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 113 of file TOPUnpackerModule.cc.

114 {
115 m_channelStatistics.clear();
116 }

◆ beginRun() [22/22]

void beginRun ( void )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 78 of file TOPWaveformFeatureExtractorModule.cc.

79 {
80 }

◆ calculateHistoRatio() [1/2]

TH1F * calculateHistoRatio ( TH1F * hRatio,
TH1F * hNum,
TH1F * hDen )

Utility function to take the ratio of two histograms using TH1::Divide(), without overwriting the output name and title initialized in defineHisto().

Definition at line 591 of file TOPTBCComparatorModule.cc.

592 {
593 // Saves the name and titple of the output histogram, as defined in defineHisto
594 const char* name = hRatio->GetName();
595 const char* title = hRatio->GetTitle();
596
597 const char* xAxisTitle = hRatio->GetXaxis()->GetTitle();
598 const char* yAxisTitle = hRatio->GetYaxis()->GetTitle();
599
600 // clone the numerator histogram into the output one
601 hRatio = (TH1F*)hNum->Clone();
602
603
604 // makes the ratio
605 hRatio->Divide(hDen);
606
607 //ri-sets name, title and axis labels
608 hRatio->SetName(name);
609 hRatio->SetTitle(title);
610 hRatio->GetXaxis()->SetTitle(xAxisTitle);
611 hRatio->GetYaxis()->SetTitle(yAxisTitle);
612 return hRatio;
613 }

◆ calculateHistoRatio() [2/2]

TH2F * calculateHistoRatio ( TH2F * hRatio,
TH2F * hNum,
TH2F * hDen )

Utility function to take the ratio of two histograms using TH2::Divide(), without overwriting the output name and title initialized in defineHisto().

Definition at line 615 of file TOPTBCComparatorModule.cc.

616 {
617 // Saves the name and titple of the output histogram, as defined in defineHisto
618 const char* name = hRatio->GetName();
619 const char* title = hRatio->GetTitle();
620
621 const char* xAxisTitle = hRatio->GetXaxis()->GetTitle();
622 const char* yAxisTitle = hRatio->GetYaxis()->GetTitle();
623
624 // clone the numerator histogram into the output one
625 hRatio = (TH2F*)hNum->Clone();
626
627
628 // makes the ratio
629 hRatio->Divide(hDen);
630
631 //ri-sets name, title and axis labels
632 hRatio->SetName(name);
633 hRatio->SetTitle(title);
634 hRatio->GetXaxis()->SetTitle(xAxisTitle);
635 hRatio->GetYaxis()->SetTitle(yAxisTitle);
636 return hRatio;
637 }

◆ calibrateChannel()

bool calibrateChannel ( std::vector< TwoTimes > & ntuple,
unsigned scrodID,
unsigned scrodChannel,
TH1F & Hchi2,
TH1F & Hndf,
TH1F & HDeltaT )
private

calibrate single channel

Parameters
ntuplentuple data
scrodIDSCROD ID
scrodChannelchannel number within SCROD (0 - 127)
Hchi2histogram to store normalized chi^2
Hndfhistogram to store degrees of freedom
HDeltaThistogram to store fittet double pulse delay
Returns
true on success

Definition at line 311 of file TOPTimeBaseCalibratorModule.cc.

315 {
316
317 // determine outlayer removal cuts
318
319 string name = "timeDiff_ch" + to_string(chan);
320 string forWhat = "scrod " + to_string(scrodID) + " channel " + to_string(chan);
321 string title = "Cal pulse time difference vs. sample for " + forWhat;
322 TProfile prof(name.c_str(), title.c_str(), c_TimeAxisSize, 0, c_TimeAxisSize,
323 m_minTimeDiff, m_maxTimeDiff, "S");
324 prof.SetXTitle("sample number");
325 prof.SetYTitle("time difference [samples]");
326
327 name = "sampleOccup_ch" + to_string(chan);
328 title = "Occupancy for " + forWhat;
329 TH1F hist(name.c_str(), title.c_str(), c_TimeAxisSize, 0, c_TimeAxisSize);
330 hist.SetXTitle("sample number");
331 hist.SetYTitle("entries per sample");
332
333 vector<double> profMeans(c_TimeAxisSize, (m_maxTimeDiff + m_minTimeDiff) / 2);
334 double sigma = (m_maxTimeDiff - m_minTimeDiff) / 6;
335
336 for (int iter = 0; iter < 5; iter++) {
337 prof.Reset();
338 double x = 0;
339 double x2 = 0;
340 int n = 0;
341 for (auto& twoTimes : ntuple) {
342 int sample = int(twoTimes.t1) % c_TimeAxisSize;
343 double diff = twoTimes.t2 - twoTimes.t1;
344 double Ddiff = diff - profMeans[sample];
345 if (fabs(Ddiff) < 3 * sigma) {
346 prof.Fill(sample, diff);
347 hist.Fill(sample);
348 x += Ddiff;
349 x2 += Ddiff * Ddiff;
350 n++;
351 twoTimes.good = true;
352 } else {
353 twoTimes.good = false;
354 }
355 }
356 for (int i = 0; i < c_TimeAxisSize; i++) {
357 profMeans[i] = prof.GetBinContent(i + 1);
358 }
359 if (n == 0) return false;
360 x2 /= n;
361 x /= n;
362 sigma = sqrt(x2 - x * x);
363 }
364 prof.Write();
365 hist.Write();
366
367 // calculate average time difference
368
369 double meanTimeDifference = 0;
370 for (auto& x : profMeans) meanTimeDifference += x;
371 meanTimeDifference /= profMeans.size();
372 meanTimeDifference -= int(meanTimeDifference / static_cast<double>(c_TimeAxisSize)) * c_TimeAxisSize;
373
374 // perform the fit
375
376 switch (m_method) {
377 case 0:
378 B2INFO("... channel " << chan << ": "
379 << ntuple.size() << " double cal pulses)");
380 return false;
381 case 1:
382 return matrixInversion(ntuple, scrodID, chan, meanTimeDifference,
383 Hchi2, Hndf, HDeltaT);
384 case 2:
385 return iterativeTBC(ntuple, scrodID, chan, meanTimeDifference,
386 Hchi2, Hndf, HDeltaT);
387 case 3:
388 B2ERROR("Singuler value decomposition not implemented yet");
389 return false;
390 default:
391 B2ERROR("Unknown method " << m_method);
392 return false;
393 }
394
395 }

◆ Chisq()

double Chisq ( const std::vector< TwoTimes > & ntuple,
const std::vector< double > & xxval )
private

Return the chisqure of one set of TBC constants (xval) in iTBC calculaton.

Parameters
ntuplentuple data
xxvalTBC constants of 256 samples, and xxval[0]=0, xxval[256]=2*FTSW

Definition at line 669 of file TOPTimeBaseCalibratorModule.cc.

670 {
671 double sum1 = 0.0;
672 double sum2 = 0.0; //sum od dt and dt**2
673
674 m_good = 0;
675
676 for (const auto& twoTimes : ntuple) {
677 if (!twoTimes.good) continue;
678
679 std::vector<double> m(c_TimeAxisSize, 0.0);
680
681 int i1 = int(twoTimes.t1);
682 double fr = twoTimes.t1 - i1;
683 double samp0 = i1 % 256;
684 double ctdc1 = xxval[samp0] + fr * (xxval[samp0 + 1] - xxval[samp0]);
685 int i2 = int(twoTimes.t2);
686 fr = twoTimes.t2 - i2;
687 double samp1 = i2 % 256;
688 double ctdc2 = xxval[samp1] + fr * (xxval[samp1 + 1] - xxval[samp1]);
689 double cdt = 0.0;
690 if (samp1 > samp0) cdt = ctdc2 - ctdc1;
691 else cdt = ctdc2 - ctdc1 + m_syncTimeBase * 2;
692
693 if (cdt < m_dt_max && cdt > m_dt_min) {
694 sum1 += cdt;
695 sum2 += cdt * cdt;
696 m_good++;
697 }
698 }
699
700 double chi2 = -1.0;
701
702 if (m_good > 10) {
703 double mean = sum1 / m_good;
704 chi2 = (sum2 - m_good * mean * mean) / m_good / m_sigm2_exp;
705 }
706 return chi2;
707 }

◆ closeRun()

void closeRun ( )
finalprivatevirtual

Replacement for endRun().

Do anything you would normally do in endRun here.

Reimplemented from CalibrationCollectorModule.

Definition at line 288 of file TOPValidationCollectorModule.cc.

289 {
290
291 // module T0 pulls
292
293 for (int module = 0; module < c_numModules; module++) {
294 std::vector<double> pos, err;
295 for (int set = 0; set < c_numSets; set++) {
296 const auto& minimum = m_finders[set][module].getMinimum();
297 if (minimum.valid) {
298 pos.push_back(minimum.position);
299 err.push_back(minimum.error);
300 }
301 }
302 auto h_pulls = getObjectPtr<TH1F>("moduleT0_pulls");
303 for (unsigned i = 0; i < pos.size(); i++) {
304 for (unsigned j = i + 1; j < pos.size(); j++) {
305 double pull = (pos[i] - pos[j]) / sqrt(err[i] * err[i] + err[j] * err[j]);
306 h_pulls->Fill(pull);
307 }
308 }
309 }
310
311 // module T0 residuals
312
313 for (int module = 0; module < c_numModules; module++) {
314 auto& finder = m_finders[0][module];
315 for (int set = 1; set < c_numSets; set++) {
316 finder.add(m_finders[set][module]);
317 }
318 const auto& minimum = finder.getMinimum();
319 if (minimum.valid) {
320 m_treeEntry.moduleT0[module] = minimum.position;
321 m_treeEntry.moduleT0Err[module] = minimum.error;
322 }
323 }
324
325 // common T0 residual
326
327 auto& finder = m_finders[0][0];
328 for (int module = 1; module < c_numModules; module++) {
329 finder.add(m_finders[0][module]);
330 }
331 const auto& minimum = finder.getMinimum();
332 if (minimum.valid) {
333 m_treeEntry.commonT0 = minimum.position;
334 m_treeEntry.commonT0Err = minimum.error;
335 }
336
337 // fill the tree
338
339 auto tree = getObjectPtr<TTree>("tree");
340 tree->Fill();
341 }

◆ collect() [1/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 216 of file TOPAlignmentCollectorModule.cc.

217 {
218 // bunch must be reconstructed
219
220 if (not m_recBunch.isValid()) return;
221 if (not m_recBunch->isReconstructed()) return;
222
223 // track-by-track iterations
224
225 for (const auto& track : m_tracks) {
226
227 // construct TOPTrack from mdst track
228 TOPTrack trk(track);
229 if (not trk.isValid()) continue;
230
231 // skip if track not hitting target module
232 if (trk.getModuleID() != m_targetMid) continue;
233
234 // track selection
235 if (not m_selector.isSelected(trk)) continue;
236
237 // generate sub-sample number
238 int sub = gRandom->Integer(c_numSets);
239 auto& align = m_align[sub];
240 auto& countFails = m_countFails[sub];
241 const auto& name = m_treeNames[sub];
242 auto h1 = getObjectPtr<TH2F>("tracks_per_slot");
243 h1->Fill(trk.getModuleID(), sub);
244
245 // do an iteration
246 int err = align.iterate(trk, m_selector.getChargedStable());
247 m_iter++;
248
249 // check number of consecutive failures, and in case reset
250 if (err == 0) {
251 countFails = 0;
252 } else if (countFails <= m_maxFails) {
253 countFails++;
254 } else {
255 B2INFO("Reached maximum allowed number of failed iterations. "
256 "Resetting TOPalign object of set = " << sub << " at iter = " << m_iter);
257 align.reset();
258 countFails = 0;
259 }
260
261 // get new parameter values and estimated errors
262 m_vAlignPars = align.getParameters();
263 m_vAlignParsErr = align.getErrors();
264 m_ntrk = align.getNumUsedTracks();
265 m_errorCode = err;
266 m_valid = align.isValid();
267 m_numPhot = align.getNumOfPhotons();
268
269 // set other ntuple variables
270 const auto& localPosition = m_selector.getLocalPosition();
271 m_x = localPosition.X();
272 m_y = localPosition.Y();
273 m_z = localPosition.Z();
274 const auto& localMomentum = m_selector.getLocalMomentum();
275 m_p = localMomentum.R();
276 m_theta = localMomentum.Theta();
277 m_phi = localMomentum.Phi();
278 const auto& pocaPosition = m_selector.getPOCAPosition();
279 m_pocaR = pocaPosition.Rho();
280 m_pocaZ = pocaPosition.Z();
281 m_pocaX = pocaPosition.X();
282 m_pocaY = pocaPosition.Y();
283 m_cmsE = m_selector.getCMSEnergy();
284 m_charge = trk.getCharge();
285 m_PDG = trk.getPDGCode();
286
287 // fill output tree
288 auto alignTree = getObjectPtr<TTree>(name);
289 alignTree->Fill();
290
291 // fill control histograms
292 std::string slotName = "_s" + to_string(m_targetMid);
293 auto h2 = getObjectPtr<TH1F>("local_z" + slotName);
294 h2->Fill(m_z);
295 auto h3 = getObjectPtr<TH2F>("cth_vs_p" + slotName);
296 h3->Fill(m_p, cos(m_theta));
297 auto h4 = getObjectPtr<TH2F>("poca_xy" + slotName);
298 h4->Fill(m_pocaX, m_pocaY);
299 auto h5 = getObjectPtr<TH1F>("poca_z" + slotName);
300 h5->Fill(m_pocaZ);
301 auto h6 = getObjectPtr<TH1F>("Ecms" + slotName);
302 h6->Fill(m_cmsE);
303 auto h7 = getObjectPtr<TH1F>("charge" + slotName);
304 h7->Fill(m_charge);
305 auto h8 = getObjectPtr<TH2F>("timeHits" + slotName);
306 for (const auto& digit : m_digits) {
307 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
308 if (digit.getModuleID() != m_targetMid) continue;
309 h8->Fill(digit.getChannel(), digit.getTime());
310 }
311 auto h9 = getObjectPtr<TH1F>("numPhot" + slotName);
312 h9->Fill(m_numPhot);
313
314 } // tracks
315
316 }

◆ collect() [2/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here.

Reimplemented from CalibrationCollectorModule.

Definition at line 91 of file TOPAsicShiftsBS13dCollectorModule.cc.

92 {
93
94 if (m_requireRecBunch) {
95 if (not m_recBunch.isValid()) return;
96 if (not m_recBunch->isReconstructed()) return;
97 }
98
99 auto time_vs_BS = getObjectPtr<TH2F>("time_vs_BS");
100 auto timeReference = getObjectPtr<TH1F>("time_reference");
101 std::vector<TH1F*> timeCarriers;
102 for (unsigned i = 0; i < 4; i++) {
103 string name = "time_carr_" + to_string(i);
104 auto h = getObjectPtr<TH1F>(name);
105 timeCarriers.push_back(h);
106 }
107
108 for (const auto& digit : m_topDigits) {
109 if (digit.getModuleID() != 13) continue;
110 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
111 double time = digit.getTime() - m_timeOffset;
112 time_vs_BS->Fill(digit.getChannel(), time);
113 if (digit.getBoardstackNumber() < 3) {
114 timeReference->Fill(time);
115 } else {
116 auto c = digit.getCarrierNumber();
117 timeCarriers[c]->Fill(time);
118 }
119 }
120
121 }

◆ collect() [3/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 70 of file TOPChannelMaskCollectorModule.cc.

71 {
72
73 std::vector<TH1F*> slots;
74 for (const auto& name : m_names) {
75 auto h = getObjectPtr<TH1F>(name);
76 slots.push_back(h);
77 }
78
79 std::vector<TH2F*> asics;
80 for (const auto& name : m_asicNames) {
81 auto h = getObjectPtr<TH2F>(name);
82 asics.push_back(h);
83 }
84
85 int NGood = 0;
86 for (const auto& digit : m_digits) {
87 if (digit.getHitQuality() == TOPDigit::c_Junk) continue;
88 NGood++;
89 unsigned m = digit.getModuleID() - 1;
90 if (m < slots.size()) slots[m]->Fill(digit.getChannel());
91 if (m < asics.size()) asics[m]->Fill(digit.getChannel() / 8, digit.getRawTime() / 64 + 220);
92 }
93
94 auto h = getObjectPtr<TH1F>("nhits");
95 h->Fill(NGood);
96
97 }

◆ collect() [4/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 68 of file TOPCommonT0BFCollectorModule.cc.

69 {
70
71 if (not m_recBunch.isValid()) return;
72 if (not m_recBunch->isReconstructed()) return;
73 if (m_recBunch->getNumTracks() != 2) return;
74
75 auto h1a = getObjectPtr<TH1F>("offset_a");
76 auto h1b = getObjectPtr<TH1F>("offset_b");
77 auto offset = m_recBunch->getCurrentOffset();
78 if (m_commonT0->isCalibrated()) offset += m_commonT0->getT0();
79
80 // wrap-around into [-1/2, 1/2] of bunch cycle
81 auto a = offset - round(offset / m_bunchTimeSep) * m_bunchTimeSep;
82 h1a->Fill(a);
83
84 // wrap-around into [0, 1] of bunch cycle
85 auto b = offset - round(offset / m_bunchTimeSep - 0.5) * m_bunchTimeSep;
86 h1b->Fill(b);
87
88 }

◆ collect() [5/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 148 of file TOPCommonT0LLCollectorModule.cc.

149 {
150 // bunch must be reconstructed
151
152 if (not m_recBunch.isValid()) return;
153 if (not m_recBunch->isReconstructed()) return;
154
155 TOPRecoManager::setDefaultTimeWindow();
156 double timeMin = TOPRecoManager::getMinTime();
157 double timeMax = TOPRecoManager::getMaxTime();
158
159 // correct-back digits for common T0
160
161 double T0 = 0;
162 if (m_commonT0->isCalibrated()) T0 = m_commonT0->getT0();
163 for (auto& digit : m_digits) {
164 if (digit.isCommonT0Calibrated()) digit.subtractT0(-T0);
165 if (digit.hasStatus(TOPDigit::c_BunchOffsetSubtracted)) digit.subtractT0(-m_recBunch->getAverageOffset());
166 }
167
168 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
169
170 int ntra = 0;
171 for (const auto& track : m_tracks) {
172
173 // track selection
174 TOPTrack trk(track);
175 if (not trk.isValid()) continue;
176
177 if (not m_selector.isSelected(trk)) continue;
178
179 // construct PDF
180 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
181 if (not pdfConstructor.isValid()) continue;
182
183 // minimization procedure: accumulate
184 int sub = gRandom->Integer(c_numSets); // generate sub-sample number
185 auto h = getObjectPtr<TH1D>(m_names[sub]);
186 for (int ibin = 0; ibin < h->GetNbinsX(); ibin++) {
187 double t0 = h->GetBinCenter(ibin + 1);
188 double chi = h->GetBinContent(ibin + 1);
189 chi += -2 * pdfConstructor.getLogL(t0, m_sigmaSmear).logL;
190 h->SetBinContent(ibin + 1, chi);
191 }
192 auto h1 = getObjectPtr<TH1F>("tracks_per_set");
193 h1->Fill(sub);
194
195 // fill histograms of hits
196 auto h2 = getObjectPtr<TH1F>("numHits");
197 auto h3 = getObjectPtr<TH2F>("timeHits");
198 for (const auto& digit : m_digits) {
199 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
200 if (digit.getModuleID() != trk.getModuleID()) continue;
201 if (digit.getTime() < timeMin) continue;
202 if (digit.getTime() > timeMax) continue;
203 h2->Fill(digit.getModuleID());
204 int bs = digit.getBoardstackNumber();
205 h3->Fill((digit.getModuleID() * 4 + bs - 1.5) / 4.0, digit.getTime());
206 }
207 ntra++;
208 }
209
210 // fill just another control histogram
211
212 if (ntra > 0) {
213 auto h4 = getObjectPtr<TH1F>("offset");
214 h4->Fill(m_recBunch->getCurrentOffset());
215 }
216
217 }

◆ collect() [6/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 78 of file TOPModuleT0DeltaTCollectorModule.cc.

79 {
80
81 if (m_timeZeros.getEntries() != 2) return;
82
83 const auto* timeZero1 = m_timeZeros[0];
84 const auto* timeZero2 = m_timeZeros[1];
85 if (timeZero1->getModuleID() > timeZero2->getModuleID()) {
86 timeZero1 = m_timeZeros[1];
87 timeZero2 = m_timeZeros[0];
88 }
89
90 int slot1 = timeZero1->getModuleID();
91 int slot2 = timeZero2->getModuleID();
92 if (slot1 > 9 or slot2 - slot1 < 7 or slot2 - slot1 > 9) return;
93 string name = "deltaT0_" + to_string(slot1) + "-" + to_string(slot2);
94 auto h = getObjectPtr<TH1F>(name);
95 if (not h) return;
96
97 double t1 = timeZero1->getTime();
98 if (m_moduleT0->isCalibrated(slot1)) t1 += m_moduleT0->getT0(slot1);
99 double t2 = timeZero2->getTime();
100 if (m_moduleT0->isCalibrated(slot2)) t2 += m_moduleT0->getT0(slot2);
101 h->Fill(t1 - t2);
102
103 auto slotPairs = getObjectPtr<TH2F>("slots");
104 slotPairs->Fill(slot1, slot2);
105 }

◆ collect() [7/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 150 of file TOPModuleT0LLCollectorModule.cc.

151 {
152 // bunch must be reconstructed
153
154 if (not m_recBunch.isValid()) return;
155 if (not m_recBunch->isReconstructed()) return;
156
157 TOPRecoManager::setDefaultTimeWindow();
158 double timeMin = TOPRecoManager::getMinTime();
159 double timeMax = TOPRecoManager::getMaxTime();
160
161 // correct-back digits for module T0
162
163 for (auto& digit : m_digits) {
164 int slot = digit.getModuleID();
165 if (digit.isModuleT0Calibrated()) digit.subtractT0(-m_moduleT0->getT0(slot));
166 if (digit.hasStatus(TOPDigit::c_BunchOffsetSubtracted)) digit.subtractT0(-m_recBunch->getAverageOffset());
167 }
168
169 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
170
171 int ntra = 0;
172 for (const auto& track : m_tracks) {
173
174 // track selection
175 TOPTrack trk(track);
176 if (not trk.isValid()) continue;
177
178 if (not m_selector.isSelected(trk)) continue;
179
180 // construct PDF
181 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
182 if (not pdfConstructor.isValid()) continue;
183
184 // minimization procedure: accumulate
185 int sub = gRandom->Integer(c_numSets); // generate sub-sample number
186 unsigned module = trk.getModuleID() - 1;
187 if (module >= m_names[sub].size()) continue;
188 auto h = getObjectPtr<TH1D>(m_names[sub][module]);
189 for (int ibin = 0; ibin < h->GetNbinsX(); ibin++) {
190 double t0 = h->GetBinCenter(ibin + 1);
191 double chi = h->GetBinContent(ibin + 1);
192 chi += -2 * pdfConstructor.getLogL(t0, m_sigmaSmear).logL;
193 h->SetBinContent(ibin + 1, chi);
194 }
195 auto h1 = getObjectPtr<TH2F>("tracks_per_slot");
196 h1->Fill(trk.getModuleID(), sub);
197
198 // fill histograms of hits
199 auto h2 = getObjectPtr<TH1F>("numHits");
200 auto h3 = getObjectPtr<TH2F>("timeHits");
201 for (const auto& digit : m_digits) {
202 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
203 if (digit.getModuleID() != trk.getModuleID()) continue;
204 if (digit.getTime() < timeMin) continue;
205 if (digit.getTime() > timeMax) continue;
206 h2->Fill(digit.getModuleID());
207 int bs = digit.getBoardstackNumber();
208 h3->Fill((digit.getModuleID() * 4 + bs - 1.5) / 4.0, digit.getTime());
209 }
210 ntra++;
211 }
212
213 // fill just another control histogram
214
215 if (ntra > 0) {
216 auto h4 = getObjectPtr<TH1F>("offset");
217 h4->Fill(m_recBunch->getCurrentOffset());
218 }
219
220 }

◆ collect() [8/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 72 of file TOPOffsetCollectorModule.cc.

73 {
74 if (not m_recBunch->isReconstructed()) return;
75
76 for (const auto& x : m_names) {
77 const auto& detector = x.first;
78 if (m_eventT0->hasTemporaryEventT0(detector)) {
79 auto eventT0s = m_eventT0->getTemporaryEventT0s(detector);
80 if (eventT0s.empty()) continue;
81 if (detector == Const::CDC and eventT0s.back().algorithm != "chi2") continue;
82 double t0 = eventT0s.back().eventT0;
83 auto h = getObjectPtr<TH1F>(x.second);
84 h->Fill(t0 - m_recBunch->getTime());
85 }
86 }
87
88 auto h = getObjectPtr<TH1F>("recBuckets");
89 h->Fill(m_recBunch->getBucketNumber(0, m_bunchStructure->getRFBucketsPerRevolution()));
90 }

◆ collect() [9/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 181 of file TOPPhotonYieldsCollectorModule.cc.

182 {
183 // bunch must be reconstructed
184
185 if (not m_recBunch->isReconstructed()) return;
186
187 // loop over reconstructed tracks, make a selection and fill histograms
188
189 for (const auto& track : m_tracks) {
190 // track selection
191 TOPTrack trk(track);
192 if (not trk.isValid()) continue;
193 if (not m_selector.isSelected(trk)) continue;
194
195 // fill histograms
196 auto timeStamp = getObjectPtr<TProfile>("timeStamp");
197 timeStamp->Fill(0.5, m_eventMetaData->getTime() / 1000000000);
198
199 int slot = trk.getModuleID();
200 auto numTracks = getObjectPtr<TH1F>("numTracks");
201 numTracks->Fill(slot);
202
203 auto muonZ = getObjectPtr<TH1F>(m_muonZNames[slot - 1]);
204 muonZ->Fill(m_selector.getLocalPosition().Z());
205
206 auto signalHits = getObjectPtr<TH1F>(m_signalNames[slot - 1]);
207 auto bkgHits = getObjectPtr<TH1F>(m_bkgNames[slot - 1]);
208 auto pulseHeight = getObjectPtr<TH2F>(m_pulseHeightNames[slot - 1]);
209 for (const auto& digit : m_digits) {
210 if (digit.getModuleID() != slot) continue;
211 if (digit.getHitQuality() != TOPDigit::c_Good) continue; // junk hit or pixel masked-out
212 if (std::abs(digit.getTime()) > m_timeWindow) continue;
213 if (digit.getTime() > 0) {
214 signalHits->Fill(digit.getPixelID());
215 pulseHeight->Fill(digit.getPixelID(), digit.getPulseHeight());
216 } else {
217 bkgHits->Fill(digit.getPixelID());
218 }
219 }
220
221 auto activePixels = getObjectPtr<TH1F>(m_activeNames[slot - 1]);
222 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
223 for (int pixel = 1; pixel <= activePixels->GetNbinsX(); pixel++) {
224 unsigned channel = chMapper.getChannel(pixel);
225 if (m_channelMask->isActive(slot, channel) and m_asicMask->isActive(slot, channel)) activePixels->Fill(pixel);
226 }
227
228 auto alphaLow = getObjectPtr<TH1F>(m_alphaLowNames[slot - 1]);
229 auto alphaHigh = getObjectPtr<TH1F>(m_alphaHighNames[slot - 1]);
230 auto effectiveSignalHits = getObjectPtr<TH1F>(m_effectiveSignalNames[slot - 1]);
231 for (const auto& digit : m_digits) {
232 if (digit.getModuleID() != slot) continue;
233 if (digit.getHitQuality() != TOPDigit::c_Good) continue; // junk hit or pixel masked-out
234 const auto* pdf = digit.getRelated<TOPAssociatedPDF>();
235 if (not pdf) continue;
236 const auto* peak = pdf->getSinglePeak();
237 if (not peak) continue; // hit associated with background
238 effectiveSignalHits->Fill(digit.getPixelID());
239 if (std::abs(m_selector.getLocalPosition().Z()) > m_excludedZ) {
240 double alpha = acos(std::abs(peak->kzd)) / Unit::deg;
241 if (alpha > 60) continue;
242 if (alpha < 30) alphaLow->Fill(digit.getPixelID());
243 else alphaHigh->Fill(digit.getPixelID());
244 }
245 }
246 } // loop over tracks
247
248 }

◆ collect() [10/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 90 of file TOPPulseHeightCollectorModule.cc.

91 {
92
93 std::vector<TH2F*> slots;
94 for (const auto& name : m_names) {
95 auto h = getObjectPtr<TH2F>(name);
96 slots.push_back(h);
97 }
98
99 auto h1a = getObjectPtr<TH1F>("time");
100 auto h1b = getObjectPtr<TH1F>("time_sel");
101 auto h2a = getObjectPtr<TH2F>("ph_vs_width");
102 auto h2b = getObjectPtr<TH2F>("ph_vs_width_sel");
103
104 for (const auto& digit : m_digits) {
105 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
106 auto t = digit.getTime();
107 auto w = digit.getPulseWidth();
108 auto ph = digit.getPulseHeight();
109 h1a->Fill(t);
110 h2a->Fill(w, ph);
111 if (m_widthWindow.size() == 2) {
112 if (w < m_widthWindow[0] or w > m_widthWindow[1]) continue;
113 }
114 if (m_timeWindow.size() == 2) {
115 if (t < m_timeWindow[0] or t > m_timeWindow[1]) continue;
116 }
117 h1b->Fill(t);
118 h2b->Fill(w, ph);
119 unsigned m = digit.getModuleID() - 1;
120 if (m < slots.size()) slots[m]->Fill(digit.getChannel(), ph);
121 }
122
123 }

◆ collect() [11/11]

void collect ( )
finalprivatevirtual

Replacement for event().

Fill your calibration data objects here

Reimplemented from CalibrationCollectorModule.

Definition at line 233 of file TOPValidationCollectorModule.cc.

234 {
235 // bunch must be reconstructed
236
237 if (not m_recBunch.isValid()) return;
238 if (not m_recBunch->isReconstructed()) return;
239
240 TOPRecoManager::setDefaultTimeWindow();
241 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
242
243 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
244
245 for (const auto& track : m_tracks) {
246
247 // track selection
248 TOPTrack trk(track);
249 if (not trk.isValid()) continue;
250
251 if (not m_selector.isSelected(trk)) continue;
252
253 // construct PDF
254 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
255 if (not pdfConstructor.isValid()) continue;
256
257 // minimization procedure: accumulate
258 unsigned module = trk.getModuleID() - 1;
259 if (module >= m_namesChi.size()) continue;
260 auto h = getObjectPtr<TH2F>(m_namesChi[module]);
261 int set = gRandom->Integer(c_numSets); // generate sub-sample number
262 auto& finder = m_finders[set][module];
263 for (int ibin = 0; ibin < h->GetNbinsY(); ibin++) {
264 double t0 = h->GetYaxis()->GetBinCenter(ibin + 1);
265 const auto& pixelLogLs = pdfConstructor.getPixelLogLs(t0, m_sigmaSmear);
266 for (unsigned channel = 0; channel < c_numChannels; channel++) {
267 int pix = chMapper.getPixelID(channel) - 1;
268 double chi = h->GetBinContent(channel + 1, ibin + 1);
269 chi += -2 * pixelLogLs[pix].logL;
270 h->SetBinContent(channel + 1, ibin + 1, chi);
271 }
272 double logL = 0;
273 for (auto& LL : pixelLogLs) logL += LL.logL;
274 finder.add(ibin, -2 * logL);
275 }
276 m_treeEntry.numTracks++;
277
278 auto h1 = getObjectPtr<TH2F>(m_namesHit[module]);
279 for (const auto& digit : m_digits) {
280 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
281 if (digit.getModuleID() != trk.getModuleID()) continue;
282 h1->Fill(digit.getChannel(), digit.getTime());
283 }
284
285 }
286 }

◆ defineHisto() [1/7]

void defineHisto ( )
overridevirtual

Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....

are supposed to be placed in this function.

Reimplemented from HistoModule.

Definition at line 59 of file TOPDQMModule.cc.

60 {
61 // Create a separate histogram directory and cd into it.
62
63 TDirectory* oldDir = gDirectory;
64 oldDir->mkdir(m_histogramDirectoryName.c_str())->cd();
65
66 // Variables needed for booking
67
68 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
69 m_numModules = geo->getNumModules();
70 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / 24;
71
72 // Histograms
73
74 m_BoolEvtMonitor = new TH1D("BoolEvtMonitor", "Event synchronization", 2, -0.5, 1.5);
75 m_BoolEvtMonitor->GetYaxis()->SetTitle("number of digits");
76 m_BoolEvtMonitor->GetXaxis()->SetBinLabel(1, "synchronized");
77 m_BoolEvtMonitor->GetXaxis()->SetBinLabel(2, "de-synchronized");
78 m_BoolEvtMonitor->GetXaxis()->SetLabelSize(0.05);
79 m_BoolEvtMonitor->GetXaxis()->SetAlphanumeric();
80 m_BoolEvtMonitor->SetMinimum(0);
81
82 m_window_vs_slot = new TH2F("window_vs_slot", "Asic windows", 16, 0.5, 16.5, 512, 0, 512);
83 m_window_vs_slot->SetXTitle("slot number");
84 m_window_vs_slot->SetYTitle("window number w.r.t reference window");
85 m_window_vs_slot->SetStats(kFALSE);
86 m_window_vs_slot->SetMinimum(0);
87 m_window_vs_slot->GetXaxis()->SetNdivisions(16);
88
89 int nbinsT0 = 75;
90 double rangeT0 = nbinsT0 * m_bunchTimeSep;
91 m_eventT0 = new TH1F("eventT0", "Event T0; event T0 [ns]; events per bin", nbinsT0, -rangeT0 / 2, rangeT0 / 2);
92
93 m_bunchOffset = new TH1F("bunchOffset", "Bunch offset", 100, -m_bunchTimeSep / 2, m_bunchTimeSep / 2);
94 m_bunchOffset->SetXTitle("offset [ns]");
95 m_bunchOffset->SetYTitle("events per bin");
96 m_bunchOffset->SetMinimum(0);
97
98 m_time = new TH1F("goodHitTimes", "Time distribution of good hits", 1000, -20, 80);
99 m_time->SetXTitle("time [ns]");
100 m_time->SetYTitle("hits per bin");
101
102 m_timeBG = new TH1F("goodHitTimesBG", "Time distribution of good hits (background)", 1000, -20, 80);
103 m_timeBG->SetXTitle("time [ns]");
104 m_timeBG->SetYTitle("hits per bin");
105
106 m_signalHits = new TProfile("signalHits", "Number of good hits per track in [0, 50] ns", 16, 0.5, 16.5, 0, 1000);
107 m_signalHits->SetXTitle("slot number");
108 m_signalHits->SetYTitle("hits per track");
109 m_signalHits->SetMinimum(0);
110 m_signalHits->GetXaxis()->SetNdivisions(16);
111
112 m_backgroundHits = new TProfile("backgroundHits", "Number of good hits pet track in [-50, 0] ns", 16, 0.5, 16.5, 0, 1000);
113 m_backgroundHits->SetXTitle("slot number");
114 m_backgroundHits->SetYTitle("hits per track");
115 m_backgroundHits->SetMinimum(0);
116 m_backgroundHits->GetXaxis()->SetNdivisions(16);
117
118 m_trackHits = new TH2F("trackHits", "Number of events w/ and w/o track in the slot", 16, 0.5, 16.5, 2, 0, 2);
119 m_trackHits->SetXTitle("slot number");
120 m_trackHits->SetYTitle("numTracks > 0");
121
122 int nbinsHits = 1000;
123 double xmaxHits = 10000;
124 m_goodHitsPerEventAll = new TH1F("goodHitsPerEventAll", "Number of good hits per event", nbinsHits, 0, xmaxHits);
125 m_goodHitsPerEventAll->GetXaxis()->SetTitle("hits per event");
126 m_goodHitsPerEventAll->GetYaxis()->SetTitle("entries per bin");
127
128 m_badHitsPerEventAll = new TH1F("badHitsPerEventAll", "Number of junk hits per event", nbinsHits, 0, xmaxHits);
129 m_badHitsPerEventAll->GetXaxis()->SetTitle("hits per event");
130 m_badHitsPerEventAll->GetYaxis()->SetTitle("entries per bin");
131
132 int nbinsTDC = 400;
133 double xminTDC = -100;
134 double xmaxTDC = 700;
135 m_goodTDCAll = new TH1F("goodTDCAll", "Raw time distribution of good hits", nbinsTDC, xminTDC, xmaxTDC);
136 m_goodTDCAll->SetXTitle("raw time [samples]");
137 m_goodTDCAll->SetYTitle("hits per sample");
138
139 m_badTDCAll = new TH1F("badTDCAll", "Raw time distribution of junk hits", nbinsTDC, xminTDC, xmaxTDC);
140 m_badTDCAll->SetXTitle("raw time [samples]");
141 m_badTDCAll->SetYTitle("hits per sample");
142
143 m_TOPOccAfterInjLER = new TH1F("TOPOccInjLER", "TOPOccInjLER/Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
144 m_TOPOccAfterInjHER = new TH1F("TOPOccInjHER", "TOPOccInjHER/Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
145 m_TOPEOccAfterInjLER = new TH1F("TOPEOccInjLER", "TOPEOccInjLER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
146 m_TOPEOccAfterInjHER = new TH1F("TOPEOccInjHER", "TOPEOccInjHER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
147
148 m_nhitInjLER = new TProfile2D("nhitInjLER",
149 "LER: average Nhits; "
150 "time since injection [msec]; time within beam cycle [syst. clk]; Nhits average",
151 160, 0, 80, 256, 0, 1280, 0, 100000);
152 m_nhitInjHER = new TProfile2D("nhitInjHER",
153 "HER: average Nhits; "
154 "time since injection [msec]; time within beam cycle [syst. clk]; Nhits average",
155 160, 0, 80, 256, 0, 1280, 0, 100000);
156 m_nhitInjLERcut = new TProfile2D("nhitInjLERcut",
157 "LER: average Nhits (Nhits>1000); "
158 "time since injection [msec]; time within beam cycle [syst. clk]; Nhits average",
159 160, 0, 80, 256, 0, 1280, 0, 100000);
160 m_nhitInjHERcut = new TProfile2D("nhitInjHERcut",
161 "HER: average Nhits (Nhits>1000); "
162 "time since injection [msec]; time within beam cycle [syst. clk]; Nhits average",
163 160, 0, 80, 256, 0, 1280, 0, 100000);
164 m_eventInjLER = new TH2F("eventInjLER",
165 "LER: event distribution; "
166 "time since injection [msec]; time within beam cycle [syst. clk]; events per bin",
167 160, 0, 80, 256, 0, 1280);
168 m_eventInjHER = new TH2F("eventInjHER",
169 "HER: event distribution; "
170 "time since injection [msec]; time within beam cycle [syst. clk]; events per bin",
171 160, 0, 80, 256, 0, 1280);
172 m_eventInjLERcut = new TH2F("eventInjLERcut",
173 "LER: event distribution (Nhits>1000); "
174 "time since injection [msec]; time within beam cycle [syst. clk]; events per bin",
175 160, 0, 80, 256, 0, 1280);
176 m_eventInjHERcut = new TH2F("eventInjHERcut",
177 "HER: event distribution (Nhits>1000); "
178 "time since injection [msec]; time within beam cycle [syst. clk]; events per bin",
179 160, 0, 80, 256, 0, 1280);
180
181 for (int i = 0; i < m_numModules; i++) {
182 int module = i + 1;
183 string name, title;
184 TH1F* h1 = 0;
185 TH2F* h2 = 0;
186
187 name = str(format("window_vs_asic_%1%") % (module));
188 title = str(format("Asic windows for slot #%1%") % (module));
189 h2 = new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 512, 0, 512);
190 h2->SetStats(kFALSE);
191 h2->SetXTitle("ASIC number");
192 h2->SetYTitle("window number w.r.t reference window");
193 h2->SetMinimum(0);
194 m_window_vs_asic.push_back(h2);
195
196 name = str(format("good_hits_xy_%1%") % (module));
197 title = str(format("Distribution of good hits for slot #%1%") % (module));
198 h2 = new TH2F(name.c_str(), title.c_str(), 64, 0.5, 64.5, 8, 0.5, 8.5);
199 h2->SetStats(kFALSE);
200 h2->GetXaxis()->SetTitle("pixel column");
201 h2->GetYaxis()->SetTitle("pixel row");
202 h2->SetMinimum(0);
203 m_goodHitsXY.push_back(h2);
204
205 name = str(format("bad_hits_xy_%1%") % (module));
206 title = str(format("Distribution of junk hits for slot #%1%") % (module));
207 h2 = new TH2F(name.c_str(), title.c_str(), 64, 0.5, 64.5, 8, 0.5, 8.5);
208 h2->SetStats(kFALSE);
209 h2->GetXaxis()->SetTitle("pixel column");
210 h2->GetYaxis()->SetTitle("pixel row");
211 h2->SetMinimum(0);
212 m_badHitsXY.push_back(h2);
213
214 name = str(format("good_hits_asics_%1%") % (module));
215 title = str(format("Distribution of good hits for slot #%1%") % (module));
216 h2 = new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 8, 0, 8);
217 h2->SetStats(kFALSE);
218 h2->GetXaxis()->SetTitle("ASIC number");
219 h2->GetYaxis()->SetTitle("ASIC channel");
220 h2->SetMinimum(0);
221 m_goodHitsAsics.push_back(h2);
222
223 name = str(format("bad_hits_asics_%1%") % (module));
224 title = str(format("Distribution of junk hits for slot #%1%") % (module));
225 h2 = new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 8, 0, 8);
226 h2->SetStats(kFALSE);
227 h2->GetXaxis()->SetTitle("ASIC number");
228 h2->GetYaxis()->SetTitle("ASIC channel");
229 h2->SetMinimum(0);
230 m_badHitsAsics.push_back(h2);
231
232 name = str(format("good_TDC_%1%") % (module));
233 title = str(format("Raw time distribution of good hits for slot #%1%") % (module));
234 h1 = new TH1F(name.c_str(), title.c_str(), nbinsTDC, xminTDC, xmaxTDC);
235 h1->GetXaxis()->SetTitle("raw time [samples]");
236 h1->GetYaxis()->SetTitle("hits per sample");
237 m_goodTDC.push_back(h1);
238
239 name = str(format("bad_TDC_%1%") % (module));
240 title = str(format("Raw time distribution of junk hits for slot #%1%") % (module));
241 h1 = new TH1F(name.c_str(), title.c_str(), nbinsTDC, xminTDC, xmaxTDC);
242 h1->GetXaxis()->SetTitle("raw time [samples]");
243 h1->GetYaxis()->SetTitle("hits per sample");
244 m_badTDC.push_back(h1);
245
246 name = str(format("good_timing_%1%") % (module));
247 title = str(format("Time distribution of good hits for slot #%1%") % (module));
248 h1 = new TH1F(name.c_str(), title.c_str(), 200, -20, 80);
249 h1->GetXaxis()->SetTitle("time [ns]");
250 h1->GetYaxis()->SetTitle("hits per time bin");
251 m_goodTiming.push_back(h1);
252
253 name = str(format("good_timing_%1%BG") % (module));
254 title = str(format("Time distribution of good hits (background) for slot #%1%") % (module));
255 h1 = new TH1F(name.c_str(), title.c_str(), 200, -20, 80);
256 h1->GetXaxis()->SetTitle("time [ns]");
257 h1->GetYaxis()->SetTitle("hits per time bin");
258 m_goodTimingBG.push_back(h1);
259
260 name = str(format("good_channel_hits_%1%") % (module));
261 title = str(format("Distribution of good hits for slot #%1%") % (module));
262 int numPixels = geo->getModule(i + 1).getPMTArray().getNumPixels();
263 h1 = new TH1F(name.c_str(), title.c_str(), numPixels, 0, numPixels);
264 h1->GetXaxis()->SetTitle("channel number");
265 h1->GetYaxis()->SetTitle("hits per channel");
266 h1->SetMinimum(0);
267 m_goodChannelHits.push_back(h1);
268
269 name = str(format("bad_channel_hits_%1%") % (module));
270 title = str(format("Distribution of junk hits for slot #%1%") % (module));
271 h1 = new TH1F(name.c_str(), title.c_str(), numPixels, 0, numPixels);
272 h1->GetXaxis()->SetTitle("channel number");
273 h1->GetYaxis()->SetTitle("hits per channel");
274 h1->SetMinimum(0);
275 m_badChannelHits.push_back(h1);
276
277 name = str(format("pulseHeights_%1%") % (module));
278 title = str(format("Average pulse heights for slot #%1%") % (module));
279 auto* prof = new TProfile(name.c_str(), title.c_str(), 32, 0.5, 32.5, 0, 2000);
280 prof->GetXaxis()->SetTitle("PMT number");
281 prof->GetYaxis()->SetTitle("pulse height [ADC counts]");
282 prof->SetMarkerStyle(20);
283 prof->SetMinimum(0);
284 m_pulseHeights.push_back(prof);
285 }
286
287 // cd back to root directory
288 oldDir->cd();
289 }

◆ defineHisto() [2/7]

void defineHisto ( )
overridevirtual

Define TTree branches to store fit results for each channel This TTree is saved in an output file given by "histoFileName" parameter of "HistoManager" module.

Reimplemented from HistoModule.

Definition at line 90 of file TOPGainEfficiencyCalculatorModule.cc.

91 {
92 m_tree = new TTree("tree", "TTree for gain/efficiency monitor summary");
93 m_branch[0].push_back(m_tree->Branch("slotId", &m_targetSlotId, "slotId/S"));
94 m_branch[0].push_back(m_tree->Branch("pmtId", &m_targetPmtId, "pmtId/S"));
95 m_branch[0].push_back(m_tree->Branch("pixelId", &m_pixelId, "pixelId/S"));
96 m_branch[0].push_back(m_tree->Branch("pmtChId", &m_pmtChId, "pmtChId/S"));
97 m_branch[0].push_back(m_tree->Branch("hvDiff", &m_hvDiff, "hvDiff/S"));
98 m_branch[0].push_back(m_tree->Branch("threshold", &m_threshold, "threshold/F"));
99 m_branch[0].push_back(m_tree->Branch("thresholdForIntegral", &m_thresholdForIntegral, "thresholdForIntegral/F"));
100
101 m_branch[1].push_back(m_tree->Branch("nCalPulse", &m_nCalPulse, "nCalPulse/I"));
102 m_branch[1].push_back(m_tree->Branch("hitTimingForGain", &m_hitTiming, "hitTimingForGain/F"));
103 m_branch[1].push_back(m_tree->Branch("hitTimingSigmaForGain", &m_hitTimingSigma, "hitTimingSigmaForGain/F"));
104 m_branch[1].push_back(m_tree->Branch("nEntriesForGain", &m_nEntries, "nEntriesForGain/I"));
105 m_branch[1].push_back(m_tree->Branch("nOverflowEventsForGain", &m_nOverflowEvents, "nOverflowEventsForGain/I"));
106 m_branch[1].push_back(m_tree->Branch("meanPulseHeightForGain", &m_meanPulseHeight, "meanPulseHeightForGain/F"));
107 m_branch[1].push_back(m_tree->Branch("meanPulseHeightErrorForGain", &m_meanPulseHeightError, "meanPulseHeightErrorForGain/F"));
108 m_branch[1].push_back(m_tree->Branch("fitMaxForGain", &m_fitMax, "fitMaxForGain/F"));
109 m_branch[1].push_back(m_tree->Branch("gain", &m_gain, "gain/F"));
110 m_branch[1].push_back(m_tree->Branch("efficiency", &m_efficiency, "efficiency/F"));
111 m_branch[1].push_back(m_tree->Branch("p0ForGain", &m_p0, "p0ForGain/F"));
112 m_branch[1].push_back(m_tree->Branch("p1ForGain", &m_p1, "p1ForGain/F"));
113 m_branch[1].push_back(m_tree->Branch("p2ForGain", &m_p2, "p2ForGain/F"));
114 m_branch[1].push_back(m_tree->Branch("x0ForGain", &m_x0, "x0ForGain/F"));
115 m_branch[1].push_back(m_tree->Branch("p0ErrorForGain", &m_p0Error, "p0ErrorForGain/F"));
116 m_branch[1].push_back(m_tree->Branch("p1ErrorForGain", &m_p1Error, "p1ErrorForGain/F"));
117 m_branch[1].push_back(m_tree->Branch("p2ErrorForGain", &m_p2Error, "p2ErrorForGain/F"));
118 m_branch[1].push_back(m_tree->Branch("x0ErrorForGain", &m_x0Error, "x0ErrorForGain/F"));
119 m_branch[1].push_back(m_tree->Branch("chisquareForGain", &m_chisquare, "chisquareForGain/F"));
120 m_branch[1].push_back(m_tree->Branch("ndfForGain", &m_ndf, "ndfForGain/I"));
121 m_branch[1].push_back(m_tree->Branch("funcFullRangeIntegralForGain", &m_funcFullRangeIntegral, "funcFullRangeIntegralForGain/F"));
122 m_branch[1].push_back(m_tree->Branch("funcFitRangeIntegralForGain", &m_funcFitRangeIntegral, "funcFitRangeIntegralForGain/F"));
123 m_branch[1].push_back(m_tree->Branch("histoFitRangeIntegralForGain", &m_histoFitRangeIntegral, "histoFitRangeIntegralForGain/F"));
124 m_branch[1].push_back(m_tree->Branch("histoMeanAboveThreForGain", &m_histoMeanAboveThre, "histoMeanAboveThreForGain/F"));
125
126 m_branch[2].push_back(m_tree->Branch("hitTimingForEff", &m_hitTiming, "hitTimingForEff/F"));
127 m_branch[2].push_back(m_tree->Branch("hitTimingSigmaForEff", &m_hitTimingSigma, "hitTimingSigmaForEff/F"));
128 m_branch[2].push_back(m_tree->Branch("nEntriesForEff", &m_nEntries, "nEntriesForEff/I"));
129 m_branch[2].push_back(m_tree->Branch("nOverflowEventsForEff", &m_nOverflowEvents, "nOverflowEventsForEff/I"));
130 m_branch[2].push_back(m_tree->Branch("meanPulseHeightForEff", &m_meanPulseHeight, "meanPulseHeightForEff/F"));
131 m_branch[2].push_back(m_tree->Branch("meanPulseHeightErrorForEff", &m_meanPulseHeightError, "meanPulseHeightErrorForEff/F"));
132 m_branch[2].push_back(m_tree->Branch("histoMeanAboveThreForEff", &m_histoMeanAboveThre, "histoMeanAboveThreForEff/F"));
133
134 m_branch[3].push_back(m_tree->Branch("meanIntegral", &m_meanPulseHeight, "meanIntegral/F"));
135 m_branch[3].push_back(m_tree->Branch("meanIntegralError", &m_meanPulseHeightError, "meanIntegralError/F"));
136 m_branch[3].push_back(m_tree->Branch("nOverflowEventsUseIntegral", &m_nOverflowEvents, "nOverflowEventsUseIntegral/I"));
137 m_branch[3].push_back(m_tree->Branch("fitMaxUseIntegral", &m_fitMax, "fitMaxUseIntegral/F"));
138 m_branch[3].push_back(m_tree->Branch("gainUseIntegral", &m_gain, "gainUseIntegral/F"));
139 m_branch[3].push_back(m_tree->Branch("efficiencyUseIntegral", &m_efficiency, "efficiencyUseIntegral/F"));
140 m_branch[3].push_back(m_tree->Branch("p0UseIntegral", &m_p0, "p0UseIntegral/F"));
141 m_branch[3].push_back(m_tree->Branch("p1UseIntegral", &m_p1, "p1UseIntegral/F"));
142 m_branch[3].push_back(m_tree->Branch("p2UseIntegral", &m_p2, "p2UseIntegral/F"));
143 m_branch[3].push_back(m_tree->Branch("x0UseIntegral", &m_x0, "x0UseIntegral/F"));
144 m_branch[3].push_back(m_tree->Branch("p0ErrorUseIntegral", &m_p0Error, "p0ErrorUseIntegral/F"));
145 m_branch[3].push_back(m_tree->Branch("p1ErrorUseIntegral", &m_p1Error, "p1ErrorUseIntegral/F"));
146 m_branch[3].push_back(m_tree->Branch("p2ErrorUseIntegral", &m_p2Error, "p2ErrorUseIntegral/F"));
147 m_branch[3].push_back(m_tree->Branch("x0ErrorUseIntegral", &m_x0Error, "x0ErrorUseIntegral/F"));
148 m_branch[3].push_back(m_tree->Branch("chisquareUseIntegral", &m_chisquare, "chisquareUseIntegral/F"));
149 m_branch[3].push_back(m_tree->Branch("ndfUseIntegral", &m_ndf, "ndfUseIntegral/I"));
150 m_branch[3].push_back(m_tree->Branch("funcFullRangeIntegralUseIntegral", &m_funcFullRangeIntegral,
151 "funcFullRangeIntegralUseIntegral/F"));
152 m_branch[3].push_back(m_tree->Branch("funcFitRangeIntegralUseIntegral", &m_funcFitRangeIntegral,
153 "funcFitRangeIntegralUseIntegral/F"));
154 m_branch[3].push_back(m_tree->Branch("histoFitRangeIntegralUseIntegral", &m_histoFitRangeIntegral,
155 "histoFitRangeIntegralUseIntegral/F"));
156 m_branch[3].push_back(m_tree->Branch("histoMeanAboveThreUseIntegral", &m_histoMeanAboveThre, "histoMeanAboveThreUseIntegral/F"));
157
158 }

◆ defineHisto() [3/7]

void defineHisto ( )
overridevirtual

Module funcions to define histograms.

Reimplemented from HistoModule.

Definition at line 98 of file TOPInterimFENtupleModule.cc.

99 {
100
101 m_tree = new TTree("tree", "TTree for generator output");
102
103 std::ostringstream nModuleStr;
104 nModuleStr << "[" << c_NModule << "]";
105
106 m_tree->Branch("nHit", &m_nHit, "nHit/I");
107 m_tree->Branch("eventNum", &m_eventNum, "eventNum/i");
108 m_tree->Branch("eventNumCopper", m_eventNumCopper,
109 std::string(std::string("eventNumCopper") + nModuleStr.str() + "/i").c_str());
110 m_tree->Branch("ttuTime", m_ttuTime,
111 std::string(std::string("ttuTime") + nModuleStr.str() + "/i").c_str());
112 m_tree->Branch("ttcTime", m_ttcTime,
113 std::string(std::string("ttcTime") + nModuleStr.str() + "/i").c_str());
114 m_tree->Branch("slotNum", m_slotNum, "slotNum[nHit]/S");
115 m_tree->Branch("pixelId", m_pixelId, "pixelId[nHit]/S");
116 m_tree->Branch("channelId", m_channelId, "channel[nHit]/S");
117 m_tree->Branch("isCalCh", m_isCalCh, "isCalCh[nHit]/O");
118 m_tree->Branch("winNum", m_winNum, "winNum[nHit]/S");
119 m_tree->Branch("eventWinNum", m_eventWinNum, "eventWinNum[nHit]/S");
120 m_tree->Branch("trigWinNum", m_trigWinNum, "trigWinNum[nHit]/S");
121 m_tree->Branch("revo9Counter", m_revo9Counter, "revo9Counter[nHit]/S");
122 m_tree->Branch("windowsInOrder", m_windowsInOrder, "windowsInOrder[nHit]/O");
123 m_tree->Branch("hitQuality", m_hitQuality, "hitQuality[nHit]/b");
124 m_tree->Branch("time", m_time, "time[nHit]/F");
125 m_tree->Branch("rawTime", m_rawTime, "rawTime[nHit]/F");
126 m_tree->Branch("refTime", m_refTime, "refTime[nHit]/F");
127 m_tree->Branch("globalRefTime", &m_globalRefTime, "globalRefTime/F");
128 m_tree->Branch("sample", m_sample, "sample[nHit]/s");
129 m_tree->Branch("height", m_height, "height[nHit]/F");
130 m_tree->Branch("integral", m_integral, "integral[nHit]/F");
131 m_tree->Branch("width", m_width, "width[nHit]/F");
132 m_tree->Branch("peakSample", m_peakSample, "peakSampe[nHit]/s");
133 m_tree->Branch("offlineFlag", m_offlineFlag, "offlineFlag[nHit]/B");
134 m_tree->Branch("nHitOfflineFE", m_nHitOfflineFE, "nHitOfflineFE[nHit]/S");
135 std::ostringstream brstr[2];
136 brstr[0] << "winNumList[nHit][" << c_NWindow << "]/S";
137 m_tree->Branch("winNumList", m_winNumList, brstr[0].str().c_str());
138 if (m_saveWaveform) {
139 brstr[1] << "waveform[nHit][" << c_NWaveformSample << "]/S";
140 m_tree->Branch("waveform", m_waveform, brstr[1].str().c_str());
141 }
142 m_tree->Branch("waveformStartSample", m_waveformStartSample, "waveformStartSample[nHit]/S");
143 m_tree->Branch("nWaveformSample", m_nWaveformSample, "nWaveformSample[nHit]/s");
144
145 m_tree->Branch("nFEHeader", &m_nFEHeader, "nFEHeader/S");
146 m_tree->Branch("nEmptyFEHeader", &m_nEmptyFEHeader, "nEmptyFEHeader/S");
147 m_tree->Branch("nWaveform", &m_nWaveform, "nWaveform/S");
148 m_tree->Branch("errorFlag", &m_errorFlag, "errorFlag/i");
149 m_tree->Branch("eventErrorFlag", &m_eventErrorFlag, "eventErrorFlag/i");
150
151 m_tree->Branch("nDebugInfo", &m_nDebugInfo, "nDebugInfo/I");
152 m_tree->Branch("scordCtime", m_scrodCtime, "scrodCtime[nDebugInfo]/s");
153 m_tree->Branch("phase", m_phase, "phase[nDebugInfo]/s");
154 m_tree->Branch("asicMask", m_asicMask, "asicMask[nDebugInfo]/s");
155 m_tree->Branch("eventQueuDepth", m_eventQueuDepth, "eventQueuDepth[nDebugInfo]/s");
156 m_tree->Branch("eventNumberByte", m_eventNumberByte, "eventNumberByte[nDebugInfo]/s");
157 }

◆ defineHisto() [4/7]

void defineHisto ( )
overridevirtual

create timing-height 2D histograms for all 8192 pixels

Reimplemented from HistoModule.

Definition at line 102 of file TOPLaserHitSelectorModule.cc.

103 {
104 for (int iPixel = 0 ; iPixel < c_NPixelPerModule * c_NModule ; iPixel++) {
105
106 short slotId = (iPixel / c_NPixelPerModule) + 1;
107 short pixelId = (iPixel % c_NPixelPerModule) + 1;
108 short pmtId = ((pixelId - 1) % c_NPixelPerRow) / c_NChannelPerPMTRow + c_NPMTPerRow * ((pixelId - 1) / (c_NPixelPerModule / 2)) + 1;
109 short pmtChId = (pixelId - 1) % c_NChannelPerPMTRow + c_NChannelPerPMTRow * ((pixelId - 1) %
110 (c_NPixelPerModule / 2) / c_NPixelPerRow) + 1;
111
112 std::ostringstream pixelstr;
113 pixelstr << "s" << std::setw(2) << std::setfill('0') << slotId << "_PMT"
114 << std::setw(2) << std::setfill('0') << pmtId
115 << "_" << std::setw(2) << std::setfill('0') << pmtChId;
116
117 std::ostringstream hnameForgain;
118 hnameForgain << "hTimeHeight_gain_" << pixelstr.str();
119 std::ostringstream htitleForgain;
120 htitleForgain << "2D distribution of hit timing and pulse height for Gain" << pixelstr.str();
121 m_TimeHeightHistogramForFit[iPixel] = new TH2F(hnameForgain.str().c_str(), htitleForgain.str().c_str(),
122 m_timeHistogramBinning[0], m_timeHistogramBinning[1], m_timeHistogramBinning[2],
123 m_chargeHistogramBinning[0], m_chargeHistogramBinning[1],
124 m_chargeHistogramBinning[2]);
125
126 std::ostringstream hnameForIntegral;
127 hnameForIntegral << "hTimeIntegral_gain_" << pixelstr.str();
128 std::ostringstream htitleForIntegral;
129 htitleForIntegral << "2D distribution of hit timing and integral for Gain" << pixelstr.str();
130 m_TimeIntegralHistogramForFit[iPixel] = new TH2F(hnameForIntegral.str().c_str(), htitleForIntegral.str().c_str(),
131 m_timeHistogramBinning[0], m_timeHistogramBinning[1], m_timeHistogramBinning[2],
132 m_chargeHistogramBinning[3], m_chargeHistogramBinning[4],
133 m_chargeHistogramBinning[5]);
134
135 std::ostringstream hnameForeff;
136 hnameForeff << "hTimeHeight_efficiency_" << pixelstr.str();
137 std::ostringstream htitleForeff;
138 htitleForeff << "2D distribution of hit timing and pulse height for efficiency" << pixelstr.str();
139 m_TimeHeightHistogramForHitRate[iPixel] = new TH2F(hnameForeff.str().c_str(), htitleForeff.str().c_str(),
140 m_timeHistogramBinning[0], m_timeHistogramBinning[1], m_timeHistogramBinning[2],
141 m_chargeHistogramBinning[0], m_chargeHistogramBinning[1],
142 m_chargeHistogramBinning[2]);
143 }
144
145 const short nAsic = c_NPixelPerModule / c_NChannelPerAsic * c_NChannelPerPMT;
146 m_nCalPulseHistogram = new TH1F("hNCalPulse", "number of calibration pulses identificed for each asic",
147 nAsic, -0.5, nAsic - 0.5);
148 }

◆ defineHisto() [5/7]

void defineHisto ( )
overridevirtual

Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....

are supposed to be placed in this function.

Reimplemented from HistoModule.

Definition at line 69 of file TOPPDFCheckerModule.cc.

70 {
71
72 // time vs. pixel ID
73 m_hits = new TH2F("hits", "photon hits", 512, 0.5, 512.5,
74 m_numBins, m_minTime, m_maxTime);
75 m_hits->SetXTitle("pixel ID");
76 m_hits->SetYTitle("time [ns]");
77
78 m_pdf = new TH2F("pdf", "PDF", 512, 0.5, 512.5,
79 m_numBins, m_minTime, m_maxTime);
80 m_pdf->SetXTitle("pixel ID");
81 m_pdf->SetYTitle("time [ns]");
82
83 // time vs pixel column
84 m_hitsCol = new TH2F("hitsCol", "photon hits", 64, 0.5, 64.5,
85 m_numBins, m_minTime, m_maxTime);
86 m_hitsCol->SetXTitle("pixel column");
87 m_hitsCol->SetYTitle("time [ns]");
88
89 m_pdfCol = new TH2F("pdfCol", "PDF", 64, 0.5, 64.5,
90 m_numBins, m_minTime, m_maxTime);
91 m_pdfCol->SetXTitle("pixel column");
92 m_pdfCol->SetYTitle("time [ns]");
93
94 }

◆ defineHisto() [6/7]

void defineHisto ( )
overridevirtual

Defining the histograms.

Reads once the m_inputDirectoryList to initialize the proper amount of histograms. Every new histogram added to the module has to be initialized here.

Reimplemented from HistoModule.

Definition at line 61 of file TOPTBCComparatorModule.cc.

62 {
63 // opens the file contining the list of directories and the labels
64 ifstream inputDirectoryListFile(m_inputDirectoryList.c_str());
65
66 // checks the input file
67 if (!inputDirectoryListFile) {
68 B2ERROR("Unable to open the input file with the list of CalSets to analyze");
69 return;
70 }
71
72 B2INFO("Initializing histograms");
73
74
75 std::string inputString;
76
77 // reads the Input file line by-line to initialize the correct number of histogram sets, and reads the labels..
78 // This is effectively a loop over all the calsets.
79 while (std::getline(inputDirectoryListFile, inputString)) {
80
81 // This initializes m_calSetDirectory and m_calSetLabel, even if now only m_calSetLabel will be used
82 parseInputDirectoryLine(inputString);
83
84 B2INFO("Initializing histograms for Calibration set located at " << m_calSetDirectory << " with label " << m_calSetLabel);
85
86 // To be used to initialize the histograms in the following
87 std::string name;
88 std::string title;
89
90
91 // ------
92 // Calset-by-calset histograms.
93 // initialize here all the histograms that appear once per calibration set, and not slot-by-slot
94 // ------
95
96 // Average DeltaT across the whole detector
97 name = str(format("TOPAverageDeltaT_CalSet_%1%") % m_calSetLabel);
98 title = str(format("Average value of #Delta T VS global channel number. CalSet %1%") % m_calSetLabel);
99 m_topAverageDeltaT.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
100
101 // St.dev. of Delta T across the whole detector
102 name = str(format("TOPSigmaDeltaT_CalSet_%1%") % m_calSetLabel);
103 title = str(format("Sigma value of #Delta T VS global channel number. CalSet %1%") % m_calSetLabel);
104 m_topSigmaDeltaT.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
105
106 // Average occupancy agross the whole detector
107 name = str(format("TOPSampleOccupancy_CalSet_%1%") % m_calSetLabel);
108 title = str(format("Average number of calpulses per sample VS global channel number. CalSet %1%") % m_calSetLabel);
109 m_topSampleOccupancy.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
110
111
112 // Ratio of the average DeltaT across the whole detector
113 name = str(format("TOPAverageDeltaTComparison_CalSet_%1%") % m_calSetLabel);
114 title = str(format("Ratio of the average #Delta T in CalSet %1% over the previous one, over the whole detector") % m_calSetLabel);
115 m_topAverageDeltaTComparison.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
116
117 // Ratio of the st.dev on DeltaT across the whole detector
118 name = str(format("TOPSigmaDeltaTComparison_CalSet_%1%") % m_calSetLabel);
119 title = str(format("Ratio of the st. dev. of #Delta T in CalSet %1% over the previous one, , over the whole detector") %
120 m_calSetLabel);
121 m_topSigmaDeltaTComparison.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
122
123 // Ratio of the average number of calpulses across the whole detector
124 name = str(format("TOPSampleOccupancyComparison_CalSet_%1%") % m_calSetLabel);
125 title = str(
126 format("Ratio of the average number of calpulses per sample in CalSet %1% over the previous one, over the whole detector") %
127 m_calSetLabel);
128 m_topSampleOccupancyComparison.push_back(new TH1F(name.c_str(), title.c_str(), 512 * 16, 0., 512 * 16.));
129
130
131 // ------
132 // Slot-by-slot histograms.
133 // Use this loop to initialize all the histograms that appear once per calibration set and per each slot
134 // ------
135 for (int iSlot = 0; iSlot < 16; iSlot ++) {
136
137 // Average DeltaT stuff
138 name = str(format("SlotAverageDeltaT_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
139 title = str(format("Average value of #Delta T VS Channel number. Slot %1%, CalSet %2%") % (iSlot) % m_calSetLabel);
140 m_slotAverageDeltaT[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
141
142 name = str(format("SlotSigmaDeltaT_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
143 title = str(format("Standard deviation of #Delta T VS Channel number. Slot %1%, CalSet %2%") % (iSlot) % m_calSetLabel);
144 m_slotSigmaDeltaT[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
145
146 name = str(format("SlotAverageDeltaTMap_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
147 title = str(format("Map of the average value of #Delta T on the 256 samples. Slot %1%, CalSet %2%") % (iSlot) % m_calSetLabel);
148 m_slotAverageDeltaTMap[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
149
150 name = str(format("SlotSigmaDeltaTMap_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
151 title = str(format("Map of the RMS of #Delta T on the 256 samples . Slot %1%, CalSet %2%") % (iSlot) % m_calSetLabel);
152 m_slotSigmaDeltaTMap[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
153
154
155 // Occupancy stuff
156 name = str(format("SlotSampleOccupancy_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
157 title = str(format("Average occupancy per sample. Slot %1%, CalSet %2%") % (iSlot) % m_calSetLabel);
158 m_slotSampleOccupancy[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
159
160 name = str(format("SlotEmptySamples_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
161 title = str(format("Number samples with less than %3% calpulses per each slot channel. Slot %1%, CalSet %2%") %
162 (iSlot) % m_calSetLabel % m_minCalPulses);
163 m_slotEmptySamples[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
164
165 name = str(format("SlotSampleOccupancyMap_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
166 title = str(format("Map of the average occupancy per sample. Slot %1%, CalSet %2%") %
167 (iSlot) % m_calSetLabel);
168 m_slotSampleOccupancyMap[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
169
170 name = str(format("SlotEmptySamplesMap_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
171 title = str(format("Map of the number samples with less than %3% calpulses per each. Slot %1%, CalSet %2%") %
172 (iSlot) % m_calSetLabel % m_minCalPulses);
173 m_slotEmptySamplesMap[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
174
175
176
177 // Ratios
178 name = str(format("SlotAverageDeltaTComparison_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
179 title = str(format("Ratio of the average #Delta T in CalSet %2% over the previous one. Slot %1%") % (iSlot) % m_calSetLabel);
180 m_slotAverageDeltaTComparison[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
181
182 name = str(format("SlotRMSDeltaTComparison_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
183 title = str(format("Ratio of the RMS of #Delta T in CalSet %2% over the previous one. Slot %1%") % (iSlot) % m_calSetLabel);
184 m_slotSigmaDeltaTComparison[iSlot].push_back(new TH1F(name.c_str(), title.c_str(), 512, 0., 512.));
185
186 name = str(format("SlotAverageDeltaTMapComparison_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
187 title = str(format("Map of the ratio of the average #Delta T in CalSet %2% over the previous one. Slot %1%") %
188 (iSlot) % m_calSetLabel);
189 m_slotAverageDeltaTMapComparison[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
190
191 name = str(format("SlotRMSDeltaTMapComparison_Slot%1%_CalSet_%2%") % (iSlot) % m_calSetLabel);
192 title = str(format("Map of the ratio of the RMS of #Delta T in CalSet %2% over the previous one. Slot %1%") %
193 (iSlot) % m_calSetLabel);
194 m_slotSigmaDeltaTMapComparison[iSlot].push_back(new TH2F(name.c_str(), title.c_str(), 64, 0., 64., 8, 0., 8.));
195
196 }
197
198 //counts how many sets are there. To be used when doing the ratios
199 m_totCalSets++;
200 }
201 B2INFO("Initialization of the histograms for " << m_totCalSets << " CalSets done.");
202 return;
203 }

◆ defineHisto() [7/7]

void defineHisto ( )
overridevirtual

Books the empty histograms.

Reimplemented from HistoModule.

Definition at line 51 of file TOPWaveformQualityPlotterModule.cc.

52 {
53 TDirectory* oldDir = gDirectory;
54 m_directory = oldDir->mkdir(m_histogramDirectoryName.c_str());
55 m_directory->cd();
56 m_samples = new TH1F("ADCvalues", "ADC values ", 100, -50, 50);
57 m_samples->GetXaxis()->SetTitle("ADC Value");
58 m_samples->GetYaxis()->SetTitle("Number of Samples");
59 m_scrod_id = new TH1F("scrodID", "scrodID", 100, 0, 100);
60 m_asic = new TH1F("IRSX", "IRSX", 4, 0, 4);
61 m_carrier = new TH1F("carrier", "asic col", 4, 0, 4);
62 m_asic_ch = new TH1F("asicCh", "channel", 8, 0, 8);
63 m_errorFlag = new TH1F("errorFlag", "errorFlag", 1000, 0, 1000);
64 m_asic_win = new TH1F("window", "window", 4, 0, 4);
65 m_entries = new TH1F("entries", "entries", 100, 0, 2600);
66 m_moduleID = new TH1F("moduleID", "moduleID", 16, 1, 17);
67 m_pixelID = new TH1F("pixelID", "pixelID", 512, 1, 513);
68 oldDir->cd();
69 }

◆ DrawResult()

void DrawResult ( const std::string & histotype,
EHistogramType LoadHisto )

Draw results of gain/efficiency calculation for each channel to a given output file.

Definition at line 465 of file TOPGainEfficiencyCalculatorModule.cc.

466 {
467 std::ostringstream pdfFilename;
468 pdfFilename << m_outputPDFFile << "_" << histotype;
469 if (m_targetPmtChId != -1)
470 pdfFilename << "_" << "ch" << std::setw(2) << std::setfill('0') << m_targetPmtChId;
471 pdfFilename << ".pdf";
472
473 gStyle->SetFrameFillStyle(0);
474 gStyle->SetFillStyle(0);
475 gStyle->SetStatStyle(0);
476 gStyle->SetOptStat(112210);
477 gStyle->SetOptFit(1110);
478 TCanvas* canvas = new TCanvas();
479 canvas->SetFillStyle(0);
480 canvas->Print((pdfFilename.str() + "[").c_str());
481
482 TLine* line = new TLine();
483 line->SetLineWidth(1);
484 line->SetLineStyle(1);
485 line->SetLineColor(4);
486 TArrow* arrow = new TArrow();
487 arrow->SetLineWidth(1);
488 arrow->SetLineStyle(1);
489 arrow->SetLineColor(3);
490 TLatex* latex = new TLatex();
491 latex->SetNDC();
492 latex->SetTextFont(22);
493 latex->SetTextSize(0.05);
494 latex->SetTextAlign(32);
495 TObject* object;
496
497 float threshold;
498 if (LoadHisto == c_LoadForFitIntegral) threshold = m_thresholdForIntegral;
499 else threshold = m_threshold;
500
501 for (int iHisto = 0 ; iHisto < c_NChannelPerPMT ; iHisto++) {
502
503 if ((iHisto % c_NChannelPerPage) == 0) {
504 canvas->Clear();
505 canvas->Divide(c_NPlotsPerChannel, c_NChannelPerPage);
506 }
507
508 //2D (time vs pulse charge) histogram
509 canvas->cd(3 * (iHisto % c_NChannelPerPage) + 1);
510 gPad->SetFrameFillStyle(0);
511 gPad->SetFillStyle(0);
512 TH2F* h2D = m_timeChargeHistogram[iHisto];
513 if (h2D) {
514 h2D->Draw("colz");
515 h2D->GetXaxis()->SetTitle("hit timing [ns]");
516 h2D->GetYaxis()->SetTitle("pulse charge [ADC count]");
517 }
518
519 //timing histogram
520 canvas->cd(c_NPlotsPerChannel * (iHisto % c_NChannelPerPage) + 2);
521 gPad->SetFrameFillStyle(0);
522 gPad->SetFillStyle(0);
523 TH1D* hTime = m_timeHistogram[iHisto];
524 if (hTime) {
525 gPad->SetLogy();
526 hTime->Draw();
527 hTime->SetLineColor(1);
528 hTime->GetXaxis()->SetTitle("hit timing [ns]");
529 float binWidth = hTime->GetXaxis()->GetBinUpEdge(1) - hTime->GetXaxis()->GetBinLowEdge(1);
530 std::ostringstream ytitle;
531 ytitle << "Entries [/(" << binWidth << " ns)]";
532 hTime->GetYaxis()->SetTitle(ytitle.str().c_str());
533
534 TF1* funcLaser = m_funcForLaser[iHisto];
535 if (funcLaser) {
536 double charge = funcLaser->GetParameter(0);
537 double peakTime = funcLaser->GetParameter(1);
538 float xMin = hTime->GetXaxis()->GetBinLowEdge(hTime->GetXaxis()->FindBin(peakTime - 2 * m_fitHalfWidth));
539 float xMax = hTime->GetXaxis()->GetBinUpEdge(hTime->GetXaxis()->FindBin(peakTime + 2 * m_fitHalfWidth));
540 line->DrawLine(xMin, 0.5, xMin, charge * 2.);
541 line->DrawLine(xMax, 0.5, xMax, charge * 2.);
542 arrow->DrawArrow(xMin, charge * 1.5, xMax, charge * 1.5, 0.01, "<>");
543 }
544 }
545
546 //charge histogram with fit result (after timing cut)
547 canvas->cd(c_NPlotsPerChannel * (iHisto % c_NChannelPerPage) + 3);
548 gPad->SetFrameFillStyle(0);
549 gPad->SetFillStyle(0);
550 TH1D* hCharge = m_chargeHistogram[iHisto];
551 if (hCharge) {
552 gPad->SetLogy();
553 hCharge->Draw();
554 hCharge->SetLineColor(1);
555 hCharge->GetXaxis()->SetTitle("charge [ADC counts]");
556 float binWidth = hCharge->GetXaxis()->GetBinUpEdge(1) - hCharge->GetXaxis()->GetBinLowEdge(1);
557 std::ostringstream ytitle;
558 ytitle << "Entries [/(" << binWidth << " ADC counts)]";
559 hCharge->GetYaxis()->SetTitle(ytitle.str().c_str());
560
561 if (m_funcForFitRange[iHisto] && m_funcForFullRange[iHisto]) {
562 m_funcForFullRange[iHisto]->Draw("same");
563 m_funcForFitRange[iHisto]->Draw("same");
564 double charge = hCharge->GetBinContent(hCharge->GetMaximumBin());
565 line->DrawLine(threshold, 0.5, threshold, charge * 2.);
566
567 if ((object = gROOT->FindObject("dummy"))) delete object;
568 std::ostringstream cut;
569 cut << "pmtChId==" << (iHisto + 1);
570 long nEntries = 0;
571 std::ostringstream summarystr[2];
572 if (LoadHisto == c_LoadForFitHeight) {
573 nEntries = m_tree->Project("dummy", "gain:efficiency", cut.str().c_str());
574 if (nEntries == 1) {
575 summarystr[0] << "gain = " << std::setiosflags(std::ios::fixed) << std::setprecision(1)
576 << m_tree->GetV1()[0];
577 latex->DrawLatex(0.875, 0.34, summarystr[0].str().c_str());
578 summarystr[1] << "efficiency = " << std::setiosflags(std::ios::fixed) << std::setprecision(1)
579 << (m_tree->GetV2()[0] * 100) << " %";
580 latex->DrawLatex(0.875, 0.29, summarystr[1].str().c_str());
581 }
582 } else if (LoadHisto == c_LoadForFitIntegral) {
583 nEntries = m_tree->Project("dummy", "gainUseIntegral:efficiencyUseIntegral", cut.str().c_str());
584 if (nEntries == 1) {
585 summarystr[0] << "gain = " << std::setiosflags(std::ios::fixed) << std::setprecision(1)
586 << m_tree->GetV1()[0];
587 latex->DrawLatex(0.875, 0.34, summarystr[0].str().c_str());
588 summarystr[1] << "efficiency = " << std::setiosflags(std::ios::fixed) << std::setprecision(1)
589 << (m_tree->GetV2()[0] * 100) << " %";
590 latex->DrawLatex(0.875, 0.29, summarystr[1].str().c_str());
591 }
592 }
593
594 if (nEntries > 1) {
595 B2WARNING("TOPGainEfficiencyCalculator : mutliple entries with the same channel ID ("
596 << m_pmtChId << ") in the output TTree");
597 }
598 }
599 }
600
601 if (((iHisto + 1) % c_NChannelPerPage) == 0)
602 canvas->Print(pdfFilename.str().c_str());
603 }
604 for (int iHisto = (c_NChannelPerPMT - 1) % c_NChannelPerPage + 1 ; iHisto < c_NChannelPerPage ; iHisto++) {
605 for (int iPad = 0 ; iPad < c_NPlotsPerChannel ; iPad++) {
606 canvas->cd(c_NPlotsPerChannel * (iHisto % c_NChannelPerPage) + iPad + 1);
607 gPad->SetFrameFillStyle(0);
608 gPad->SetFillStyle(0);
609 }
610 if (((iHisto + 1) % c_NChannelPerPage) == 0)
611 canvas->Print(pdfFilename.str().c_str());
612 }
613
614 canvas->Print((pdfFilename.str() + "]").c_str());
615
616 delete latex;
617 delete arrow;
618 delete line;
619 delete canvas;
620 if ((object = gROOT->FindObject("dummy"))) delete object;
621
622 return;
623 }
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition EvtPDLUtil.cc:44

◆ drawWaveforms()

void drawWaveforms ( const TOPRawWaveform & rawwave)

Draws the full waveforms onto the TProfiles.

Parameters
rawwavethe raw waveform

Definition at line 111 of file TOPWaveformQualityPlotterModule.cc.

112 {
113 vector<short> waveform = v.getWaveform();
114 if (waveform.empty()) {
115 return;
116 }
117 int scrodid = v.getScrodID();
118 // skip broken events
119 if (scrodid == 0) {
120 return;
121 }
122 int asicNumber = v.getASICNumber();
123 int carrierNumber = v.getCarrierNumber();
124 int iChannel = v.getASICChannel();
125 string gname = string("scrod_") + to_string(scrodid) + string("_carrier") + to_string(carrierNumber) + string("_asic") + to_string(
126 asicNumber) + to_string(iChannel);
127 if (m_waveformHists[scrodid][carrierNumber][asicNumber].find(iChannel) ==
128 m_waveformHists[scrodid][carrierNumber][asicNumber].end()) {
129 // FIXME ? This assumes exactly 256 samples in a waveform (FE data)
130 auto h = new TProfile(gname.c_str(), gname.c_str(), 256, 0, 256);
131 h->Sumw2(false); // unweighted filling.
132 m_waveformHists[scrodid][carrierNumber][asicNumber][iChannel] = h;
133 }
134 // FIXME assumes 256 samples in a waveform
135 for (size_t i = 0; i < 256; ++i) {
136 // exit broken waveforms early
137 if (i >= waveform.size()) {
138 break;
139 }
140 m_waveformHists[scrodid][carrierNumber][asicNumber][iChannel]->Fill(i + 0.5, iChannel * 1500 + waveform[i]);
141 }
142 }

◆ DummyFillBranch()

void DummyFillBranch ( EHistogramType LoadHisto)

Fill Dummy for Branch.

Use it when there aren't 2D-Histogram.

Definition at line 432 of file TOPGainEfficiencyCalculatorModule.cc.

433 {
434 m_fitMax = -1;
435 m_hitTiming = -1;
436 m_hitTimingSigma = -1;
437 m_nEntries = -1;
438 m_nCalPulse = -1;
439 m_nOverflowEvents = -1;
440 m_meanPulseHeight = -1;
441 m_meanPulseHeightError = -1;
442 m_gain = -1;
443 m_efficiency = -1;
444 m_p0 = -1;
445 m_p1 = -1;
446 m_p2 = -1;
447 m_x0 = -1;
448 m_p0Error = -1;
449 m_p1Error = -1;
450 m_p2Error = -1;
451 m_x0Error = -1;
452 m_chisquare = -1;
453 m_ndf = -1;
454 m_funcFullRangeIntegral = -1;
455 m_funcFitRangeIntegral = -1;
456 m_histoFitRangeIntegral = -1;
457 m_histoMeanAboveThre = -1;
458
459 for (auto itr = m_branch[LoadHisto].begin(); itr != m_branch[LoadHisto].end(); ++itr) {
460 (*itr)->Fill();
461 }
462 }

◆ endRun() [1/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 399 of file TOPBackgroundModule.cc.

400 {
401 B2INFO("TOPBackground: Finished:");
402 }

◆ endRun() [2/17]

void endRun ( void )
overridevirtual

End-of-run action.

Reimplemented from Module.

Definition at line 89 of file TOPChannelT0MCModule.cc.

90 {
91 }

◆ endRun() [3/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 219 of file TOPDoublePulseGeneratorModule.cc.

220 {
221 }

◆ endRun() [4/17]

void endRun ( void )
overridevirtual

Draw plots to show fitting results for each channel and save them into a given PDF file (outputPDFFile).

Reimplemented from HistoModule.

Definition at line 168 of file TOPGainEfficiencyCalculatorModule.cc.

169 {
170 }

◆ endRun() [5/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from HistoModule.

Definition at line 331 of file TOPInterimFENtupleModule.cc.

332 {
333 }

◆ endRun() [6/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 109 of file TOPLaserCalibratorModule.cc.

110 {
111 }

◆ endRun() [7/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from HistoModule.

Definition at line 256 of file TOPLaserHitSelectorModule.cc.

257 {
258 }

◆ endRun() [8/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 142 of file TOPMCTrackMakerModule.cc.

143 {
144 }

◆ endRun() [9/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 270 of file TOPNtupleModule.cc.

271 {
272 }

◆ endRun() [10/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 123 of file TOPPackerModule.cc.

124 {
125 }

◆ endRun() [11/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 477 of file TOPRawDigitConverterModule.cc.

478 {
479 }

◆ endRun() [12/17]

void endRun ( void )
overridevirtual

End-of-run action.

The main analysis loop over the calibration sets happens here. This function has to be modified only if the directory structure of the TOPTimeBaseCalibrator module output is changed Both the core functions analyzeCalFile() and makeComparisons() are called here.

Reimplemented from HistoModule.

Definition at line 356 of file TOPTBCComparatorModule.cc.

357 {
358 // opens the file containing the list of directories and the labels
359 ifstream inputDirectoryListFile(m_inputDirectoryList.c_str());
360
361 // checsk the input file
362 if (!inputDirectoryListFile) {
363 B2ERROR("Unable to open the input file with the list of CalSets to analyze");
364 return;
365 }
366
367 std::string inputString;
368 // reads the Input file line by-line
369 while (std::getline(inputDirectoryListFile, inputString)) {
370 // This initializes m_calSetDirectory and m_calSetLabel
371
372 parseInputDirectoryLine(inputString);
373
374 B2INFO("Processing the calibration set located in " << m_calSetDirectory << " and labelled " << m_calSetLabel);
375 TSystemDirectory calSetDir(m_calSetDirectory.c_str(), (m_calSetDirectory).c_str());
376
377 // lists the content of the directory
378 TList* calSetDirContent = calSetDir.GetListOfFiles();
379 if (calSetDirContent) {
380 TSystemFile* entry;
381 TIter next(calSetDirContent);
382 while ((entry = (TSystemFile*)next())) {
383
384 // gets the name of the entry in the list of the content of m_calSetDirectory
385 std::string entryName = entry->GetName();
386
387 // Case 1: the entry is already a root file
388 if (!entry->IsDirectory() && TString(entryName.c_str()).EndsWith(".root")) {
389 // Initializes the file name
390 m_calSetFile = new TFile((m_calSetDirectory + entryName).c_str(), " ");
391 // Finds out the Slot and BS ID
392 int parserStatus = parseSlotAndScrodIDfromFileName(entryName);
393 // Fills the histograms
394 if (parserStatus == 1)
395 analyzeCalFile();
396 // Closes the file
397 m_calSetFile->Close();
398 }
399
400 // Case 2: the entry is a sub-foder, containing the rootfiles
401 // The default direcotry structure is
402 // calSetDirectory/tbc_chxx/*.root,
403 // so this should be the normal case
404 if (entry->IsDirectory() && entryName != "." && entryName != "..") {
405 entryName += "/";
406 // resets the directory where to look for root files
407 TSystemDirectory calSetSubDir((m_calSetDirectory + entryName).c_str(), (m_calSetDirectory + entryName).c_str());
408
409 // lists the content of the directory
410 TList* calSetSubDirContent = calSetSubDir.GetListOfFiles();
411 if (calSetSubDirContent) {
412 TSystemFile* file;
413 TIter nextSub(calSetSubDirContent);
414 while ((file = (TSystemFile*)nextSub())) {
415 // gets the name of the entry in the list of the content of m_calSetDirectory
416 std::string fileName = file->GetName();
417
418 if (!file->IsDirectory() && TString(fileName.c_str()).EndsWith(".root")) {
419 // Initializes the file name
420 m_calSetFile = new TFile((m_calSetDirectory + entryName + fileName).c_str(), " ");
421 // Finds out the Slot and BS ID
422 int parserStatus = parseSlotAndScrodIDfromFileName(fileName);
423 // Fills the histograms
424 if (parserStatus == 1)
425 analyzeCalFile();
426 // Closes the file
427 m_calSetFile->Close();
428 } else if (file->IsDirectory() && fileName != "." && fileName != "..") {
429 B2WARNING("Additional subdirectory " << fileName << " found in " << m_calSetDirectory + entryName <<
430 ", where only .root and .log files are expected ");
431 continue;
432 }
433
434 }
435 }
436 }
437 }
438 } else {
439 B2WARNING("Error in creating the TList form the directory " << m_calSetDirectory);
440 continue;
441 }
442 m_calSetID++; // jump to the next directory (i.e. the next calset)
443 }
444 B2INFO("Analisys concluded.");
445
446 makeComparisons();
447
448 return;
449 }

◆ endRun() [13/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 216 of file TOPTimeBaseCalibratorModule.cc.

217 {
218 }

◆ endRun() [14/17]

void endRun ( void )
overridevirtual

End-of-run action.

Reimplemented from Module.

Definition at line 149 of file TOPTriggerDigitizerModule.cc.

150 {
151
152 }

◆ endRun() [15/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 1245 of file TOPUnpackerModule.cc.

1246 {
1247 B2INFO("TOPUnpacker: Channels seen per event statistics:");
1248 B2INFO("TOPUnpacker: nChn\tcount");
1249 for (auto& entry : m_channelStatistics) {
1250 B2INFO("TOPUnpacker: " << entry.first << "\t\t" << entry.second);
1251 }
1252 }

◆ endRun() [16/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from Module.

Definition at line 140 of file TOPWaveformFeatureExtractorModule.cc.

141 {
142 }

◆ endRun() [17/17]

void endRun ( void )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from HistoModule.

Definition at line 181 of file TOPWaveformQualityPlotterModule.cc.

182 {
183 if (m_DRAWWAVES) {
184 // Each waveform was stored in a TH1F
185 // This now gets transformed to a TGraph
186 // All 8 channels for a given ASIC are put in the same TMultiGraph
187 // Then we make one canvas of several TMultigraphs for each scrod
188 // FIXME: This is going to get called at the end of the run; the mem leak I am introducing here should be fixed by somebody more patient with ROOT memory management than me.
189 for (auto scrod_it : m_waveformHists) {
190 int scrodid = scrod_it.first;
191 string name = string("scrod_") + to_string(scrodid);
192 TCanvas* c = new TCanvas(name.c_str(), name.c_str());
193 c->Divide(4, 4);
194 int canvasPad = 0;
195 for (auto carrier_it : scrod_it.second) {
196 int carrierNumber = carrier_it.first;
197 for (auto asic_it : carrier_it.second) {
198 int asicNumber = asic_it.first;
199 canvasPad += 1;
200 string gname = string("scrod_") + to_string(scrodid) + string("_carrier") + to_string(carrierNumber) + string("_asic") + to_string(
201 asicNumber);
202 TMultiGraph* mg = new TMultiGraph(gname.c_str(), gname.c_str());
203 for (auto channel_it : asic_it.second) {
204 // read the data from the TProfile
205 TGraphErrors* g = new TGraphErrors(channel_it.second);
206 g->SetMarkerStyle(7);
207 mg->Add(g);
208 }
209 // FIXME nSamples is hard-coded to 256
210 TH2F* h = new TH2F(gname.c_str(), gname.c_str(), 256, 0, 256, 8, -500, -500 + 8 * 1500);
211 for (int ibin = 0; ibin < 8; ibin++) {
212 h->GetYaxis()->SetBinLabel(ibin + 1, to_string(ibin).c_str());
213 }
214 h->GetYaxis()->SetTickSize(0);
215 h->GetYaxis()->SetTickLength(0);
216 h->SetStats(0);
217 c->cd(canvasPad);
218 h->Draw();
219 mg->Draw("P");
220 }
221 }
222 m_directory->WriteTObject(c);
223 }
224 }
225 }

◆ event() [1/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 150 of file OpticalGunModule.cc.

151 {
152 // generate number of photons
153 int numPhotons = 1;
154 if (m_numPhotons > 0) numPhotons = gRandom->Poisson(m_numPhotons);
155
156 // start time
157 double startTime = m_startTime;
158 if (m_simCalPulses.getEntries() > 0) { // TOPCalPulseGenerator in the path
159 startTime += m_simCalPulses[0]->getTime(); // set start time w.r.t cal pulse
160 }
161
162 // generate photons and store them to MCParticles
163 for (int i = 0; i < numPhotons; i++) {
164
165 // generate emission point
166 double x, y;
167 do {
168 x = m_diameter * (gRandom->Rndm() - 0.5);
169 y = m_diameter * (gRandom->Rndm() - 0.5);
170 } while (x * x + y * y > m_diameter * m_diameter / 4.0);
171 XYZPoint point(x, y, 0);
172
173 // generate direction
174 XYZVector direction;
175 if (m_angularDistribution == string("uniform")) {
176 direction = getDirectionUniform();
177 } else if (m_angularDistribution == string("Lambertian")) {
178 direction = getDirectionLambertian();
179 } else if (m_angularDistribution == string("Gaussian")) {
180 direction = getDirectionGaussian();
181 } else { // we already have tested the formula and initialized the TF1 in the initialize() method
182 direction = getDirectionCustom();
183 }
184 XYZVector momentum = m_energy * direction;
185
186 // check if photon passes the slit
187 if (not isInsideSlit(point, direction)) continue;
188
189 // generate polarization vector (unpolarized light source assumed)
190 double alphaPol = 2.0 * M_PI * gRandom->Rndm();
191 XYZVector polarization(cos(alphaPol), sin(alphaPol), 0);
192 func::rotateUz(polarization, direction);
193
194 // generate emission time
195 double emissionTime = gRandom->Gaus(startTime, m_pulseWidth);
196
197 // transform to Belle II frame
198 point = m_transform * point;
199 momentum = m_transform * momentum;
200 polarization = m_transform * polarization;
201
202 // store generated photon
203 auto* part = m_MCParticles.appendNew();
204 part->setPDG(0); // optical photon
205 part->setMass(0);
206 part->setStatus(MCParticle::c_PrimaryParticle);
207 part->addStatus(MCParticle::c_StableInGenerator);
208 part->setProductionVertex(static_cast<XYZVector>(point));
209 part->setProductionTime(emissionTime);
210 part->setMomentum(momentum);
211 part->setEnergy(m_energy);
212 part->setDecayVertex(polarization); // use this location temporary to pass photon polarization to FullSim
213 }
214
215 }

◆ event() [2/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 162 of file TOPAlignerModule.cc.

163 {
164
165 // check bunch reconstruction status and run alignment:
166 // - if object exists and bunch is found (collision data w/ bunch finder in the path)
167 // - if object doesn't exist (cosmic data and other cases w/o bunch finder)
168
169 if (m_recBunch.isValid()) {
170 if (not m_recBunch->isReconstructed()) return;
171 }
172
173 // track-by-track iterations
174
175 for (const auto& track : m_tracks) {
176
177 // construct TOPtrack from mdst track
178 TOPTrack trk(track);
179 if (not trk.isValid()) continue;
180
181 // skip if track not hitting target module
182 if (trk.getModuleID() != m_targetMid) continue;
183
184 // track selection
185 if (not m_selector.isSelected(trk)) continue;
186
187 // do an iteration
188 int err = m_align.iterate(trk, m_chargedStable);
189 m_iter++;
190
191 // check number of consecutive failures, and in case reset
192 if (err == 0) {
193 m_countFails = 0;
194 } else if (m_countFails <= m_maxFails) {
195 m_countFails++;
196 } else {
197 B2INFO("Reached maximum allowed number of failed iterations. "
198 "Resetting TOPalign object");
199 m_align.reset();
200 m_countFails = 0;
201 }
202
203 // get new parameter values and estimated errors
204 m_vAlignPars = m_align.getParameters();
205 m_vAlignParsErr = m_align.getErrors();
206 m_ntrk = m_align.getNumUsedTracks();
207 m_errorCode = err;
208 m_valid = m_align.isValid();
209 m_numPhot = m_align.getNumOfPhotons();
210
211 // set other ntuple variables
212 const auto& localPosition = m_selector.getLocalPosition();
213 m_x = localPosition.X();
214 m_y = localPosition.Y();
215 m_z = localPosition.Z();
216 const auto& localMomentum = m_selector.getLocalMomentum();
217 m_p = localMomentum.R();
218 m_theta = localMomentum.Theta();
219 m_phi = localMomentum.Phi();
220 const auto& pocaPosition = m_selector.getPOCAPosition();
221 m_pocaR = pocaPosition.Rho();
222 m_pocaZ = pocaPosition.Z();
223 m_pocaX = pocaPosition.X();
224 m_pocaY = pocaPosition.Y();
225 m_cmsE = m_selector.getCMSEnergy();
226 m_charge = trk.getCharge();
227 m_PDG = trk.getPDGCode();
228
229 // fill output tree
230 m_alignTree->Fill();
231
232 // print info
233 TString resMsg = "M= ";
234 resMsg += m_align.getModuleID();
235 resMsg += " ntr=";
236 resMsg += m_ntrk;
237 resMsg += " err=";
238 resMsg += m_errorCode;
239 resMsg += " v=";
240 resMsg += m_align.isValid();
241 for (auto par : m_vAlignPars) {
242 resMsg += " ";
243 resMsg += par;
244 }
245 B2DEBUG(20, resMsg);
246
247 }
248
249 }

◆ event() [3/32]

void event ( void )
overridevirtual

Event processor.

Convert TOPSimHits of the event to TOPHits.

Reimplemented from Module.

Definition at line 201 of file TOPBackgroundModule.cc.

202 {
203 StoreArray<TOPSimHit> topSimhits;
204 StoreArray<MCParticle> mcParticles;
205 StoreArray<TOPDigit> topDigits;
206 StoreArray<TOPBarHit> topTracks;
207
208 int nHits = topDigits.getEntries();
209 for (int i = 0; i < nHits; i++) {
210 TOPDigit* aDigit = topDigits[i];
211 int barID = aDigit->getModuleID();
212
213 peflux->AddBinContent(barID * 2, 1. / m_TimeOfSimulation / 32.0);
214
215 const TOPSimHit* simHit = DataStore::getRelated<TOPSimHit>(aDigit);
216 if (!simHit) continue;
217 int PMTID = simHit->getPmtID();
218
219 module_occupancy->SetPoint(count_occ, PMTID, barID);
220 count_occ++;
221
222 genergy->Fill(simHit->getEnergy());
223
224 const MCParticle* particle = DataStore::getRelated<MCParticle>(simHit);
225
226 if (particle) {
227 const MCParticle* currParticle = particle;
228
229 const MCParticle* mother = currParticle->getMother();
230
231 while (mother) {
232 const MCParticle* pommother = mother->getMother();
233 if (!pommother) {
234
235 zdist->Fill(mother->getVertex().Z());
236 zdistg->Fill(mother->getVertex().Z(), 1. / m_TimeOfSimulation / 32.0 / 16.0);
237 originpe_x = mother->getVertex().X();
238 originpe_y = mother->getVertex().Y();
239 originpe_z = mother->getVertex().Z();
240 originpe->Fill();
241 ROOT::Math::XYZVector momentum = mother->getMomentum();
242 if (m_BkgType.at(m_BkgType.size() - 3) == 'L') ROOT::Math::VectorUtil::RotateY(momentum, 0.0415);
243 else if (m_BkgType.at(m_BkgType.size() - 3) == 'H') ROOT::Math::VectorUtil::RotateY(momentum, -0.0415);
244 double px = momentum.X();
245 double py = momentum.Y();
246 double pt = sqrt(px * px + py * py);
247 originpt->Fill(pt);
248 }
249 mother = pommother;
250 }
251 }
252 }
253
254
255 StoreArray<BeamBackHit> beamBackHits;
256 nHits = beamBackHits.getEntries();
257
258 for (int iHit = 0; iHit < nHits; ++iHit) {
259 BeamBackHit* tophit = beamBackHits[iHit];
260 int subdet = tophit->getSubDet();
261 if (subdet != 5) continue;
262
263 auto pos = tophit->getPosition();
264 double phi = ROOT::Math::VectorUtil::Phi_0_2pi(pos.Phi()) * TMath::RadToDeg();
265 int barID = int (phi / 22.5 + 0.5);
266 if (barID == 16) {
267 barID = 0;
268 }
269 barID++;
270
271
272 if (tophit->getPDG() == Const::neutron.getPDGCode()) {
273 double w = tophit->getNeutronWeight();
274 double tlen = tophit->getTrackLength();
275
276 nflux->AddBinContent(barID * 2, w / m_TimeOfSimulation / PCBarea * yearns * tlen / 0.2);
277
278 } else {
279 double edep = tophit->getEnergyDeposit();
280 rdose->AddBinContent(barID * 2, edep / m_TimeOfSimulation * yearns / PCBmass * evtoJ);
281 }
282 }
283
284 nHits = topTracks.getEntries();
285 for (int iHit = 0; iHit < nHits; ++iHit) {
286 TOPBarHit* toptrk = topTracks[iHit];
287
288 int PDG = toptrk->getPDG();
289 int barID = toptrk->getModuleID();
290
291 if (PDG == Const::neutron.getPDGCode()) {
292 nflux_bar->Fill(toptrk->getPosition().Z(), (barID - 1) * 22.5,
293 1. / 917.65 / m_TimeOfSimulation * yearns * 2.);
294 norigin->Fill(toptrk->getProductionPoint().Z());
295 } else {
296 if (PDG == Const::photon.getPDGCode()) {
297 gflux_bar->Fill(toptrk->getPosition().Z(), (barID - 1) * 22.5,
298 1. / 917.65 / m_TimeOfSimulation * 2.);
299 gorigin->Fill(toptrk->getProductionPoint().Z());
300 genergy2->Fill(toptrk->getMomentum().R() * 1000);
301 origin_zx->SetPoint(count, toptrk->getProductionPoint().Z(),
302 toptrk->getProductionPoint().X());
303 origin_zy->SetPoint(count, toptrk->getProductionPoint().Z() / 0.999143,
304 toptrk->getProductionPoint().Y());
305 origingamma_x = toptrk->getProductionPoint().X();
306 origingamma_y = toptrk->getProductionPoint().Y();
307 origingamma_z = toptrk->getProductionPoint().Z();
308 origingamma->Fill();
309 count++;
310
311 } else {
312 cflux_bar->Fill(toptrk->getPosition().Z(), (barID - 1) * 22.5,
313 1. / 917.65 / m_TimeOfSimulation * 2.);
314 corigin->Fill(toptrk->getProductionPoint().Z());
315 }
316 }
317
318 }
319 }

◆ event() [4/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 238 of file TOPBunchFinderModule.cc.

239 {
240
241 m_processed++;
242 TOPRecoManager::setDefaultTimeWindow();
243
244 // define output for the reconstructed bunch
245
246 if (not m_recBunch.isValid()) {
247 m_recBunch.create();
248 } else {
249 m_revo9Counter = m_recBunch->getRevo9Counter();
250 m_recBunch->clearReconstructed();
251 }
252 m_timeZeros.clear();
253
254 if (not m_eventT0.isValid()) m_eventT0.create();
255
256 // set MC truth if available
257
258 if (m_initialParticles.isValid()) {
259 double simTime = m_initialParticles->getTime();
260 int simBunchNumber = round(simTime / m_bunchTimeSep);
261 m_recBunch->setSimulated(simBunchNumber, simTime);
262 }
263 m_isMC = m_recBunch->isSimulated();
264
265 // set revo9 counter from the first raw digit if available (all should be the same)
266
267 if (m_topRawDigits.getEntries() > 0) {
268 const auto* rawDigit = m_topRawDigits[0];
269 m_revo9Counter = rawDigit->getRevo9Counter();
270 m_recBunch->setRevo9Counter(m_revo9Counter);
271 }
272
273 // full time window in which data are taken (smaller time window is used in reconstruction)
274
275 const auto& tdc = TOPGeometryPar::Instance()->getGeometry()->getNominalTDC();
276 double timeWindow = m_feSetting->getReadoutWindows() * tdc.getSyncTimeBase() / static_cast<double>(TOPNominalTDC::c_syncWindows);
277
278 // counters and temporary containers
279
280 int numTrk = 0;
281 m_nodEdxCount = 0;
282 std::vector<TOPTrack> topTracks;
283 std::vector<PDFConstructor> pdfConstructors;
284 std::vector<PDF1Dim> top1Dpdfs;
285 std::vector<int> numPhotons;
286 std::vector<double> assumedMasses;
287 std::vector<Chi2MinimumFinder1D> finders;
288
289 // loop over reconstructed tracks, make a selection and push to containers
290
291 for (const auto& track : m_tracks) {
292 TOPTrack trk(track);
293 if (not trk.isValid()) continue;
294
295 // track selection
296 const auto* fitResult = track.getTrackFitResultWithClosestMass(Const::pion);
297 if (not fitResult) {
298 B2ERROR("No TrackFitResult available. Must be a bug somewhere.");
299 continue;
300 }
301 if (fitResult->getHitPatternCDC().getNHits() < m_minNHitsCDC) continue;
302 if (fabs(fitResult->getD0()) > m_maxD0) continue;
303 if (fabs(fitResult->getZ0()) > m_maxZ0) continue;
304 auto pt = fitResult->getTransverseMomentum();
305 if (pt < m_minPt or pt > m_maxPt) continue;
306
307 // determine most probable particle mass
308 auto chargedStable = Const::pion;
309 if (m_useMCTruth) {
310 if (not trk.getMCParticle()) continue;
311 if (not trk.getBarHit()) continue;
312 chargedStable = Const::chargedStableSet.find(abs(trk.getMCParticle()->getPDG()));
313 if (chargedStable == Const::invalidParticle) continue;
314 } else {
315 if (trk.getMomentumMag() < 4.0) chargedStable = getMostProbable(track);
316 }
317
318 // construct PDF
319 PDFConstructor pdfConstructor(trk, chargedStable, PDFConstructor::c_Rough);
320 if (not pdfConstructor.isValid()) continue;
321 numTrk++;
322
323 // make PDF projection to time axis with bin size of ~0.5 ns
324 PDF1Dim pdf1d(pdfConstructor, 0.5, timeWindow);
325 pdfConstructor.switchOffDeltaRayPDF(); // to speed-up fine search
326
327 // do further track selection
328 double expSignal = pdf1d.getExpectedSignal();
329 double expDelta = pdf1d.getExpectedDeltaPhotons();
330 double expBG = pdf1d.getExpectedBG();
331 double expPhot = expSignal + expDelta + expBG;
332 double numPhot = pdf1d.getNumOfPhotons();
333 if (expSignal < m_minSignal) continue;
334 if (expSignal < m_minSBRatio * expBG) continue;
335 if (numPhot < m_minDERatio * expPhot) continue;
336 if (numPhot > m_maxDERatio * expPhot) continue;
337
338 topTracks.push_back(trk);
339 pdfConstructors.push_back(pdfConstructor);
340 top1Dpdfs.push_back(pdf1d);
341 numPhotons.push_back(numPhot);
342 assumedMasses.push_back(pdfConstructors.back().getHypothesis().getMass());
343 }
344 m_recBunch->setNumTracks(numTrk, topTracks.size(), m_nodEdxCount);
345 if (topTracks.empty()) return;
346
347 // get time seed
348
349 auto timeSeed = getTimeSeed();
350
351 if (timeSeed.sigma == 0) { // time seed is not given - perform coarse search
352
353 // set time region for coarse search
354
355 double minT0 = -m_timeRangeCoarse / 2;
356 double maxT0 = m_timeRangeCoarse / 2;
357 if (m_autoRange) {
358 minT0 = top1Dpdfs[0].getMinT0();
359 maxT0 = top1Dpdfs[0].getMaxT0();
360 for (const auto& pdf : top1Dpdfs) {
361 minT0 = std::min(minT0, pdf.getMinT0());
362 maxT0 = std::max(maxT0, pdf.getMaxT0());
363 }
364 }
365 double binSize = top1Dpdfs[0].getBinSize();
366 int numBins = (maxT0 - minT0) / binSize;
367 maxT0 = minT0 + binSize * numBins;
368
369 // find coarse T0
370
371 for (const auto& pdf : top1Dpdfs) {
372 finders.push_back(Chi2MinimumFinder1D(numBins, minT0, maxT0));
373 auto& finder = finders.back();
374 const auto& bins = finder.getBinCenters();
375 for (unsigned i = 0; i < bins.size(); i++) {
376 double t0 = bins[i];
377 finder.add(i, -2 * pdf.getLogL(t0));
378 }
379 }
380 auto coarseFinder = finders[0];
381 for (size_t i = 1; i < finders.size(); i++) {
382 coarseFinder.add(finders[i]);
383 }
384
385 const auto& t0Coarse = coarseFinder.getMinimum();
386 if (m_saveHistograms) {
387 m_recBunch->addHistogram(coarseFinder.getHistogram("chi2_coarse_",
388 "coarse T0; t_{0} [ns]; -2 log L"));
389 }
390 if (t0Coarse.position < minT0 or t0Coarse.position > maxT0 or not t0Coarse.valid) {
391 B2DEBUG(20, "Coarse T0 finder: returning invalid or out of range T0");
392 return;
393 }
394 timeSeed.t0 = t0Coarse.position;
395 }
396
397 // find precise T0
398
399 finders.clear();
400
401 double timeMin = TOPRecoManager::getMinTime() + timeSeed.t0;
402 double timeMax = TOPRecoManager::getMaxTime() + timeSeed.t0;
403 double timeRangeFine = std::max(m_timeRangeFine, timeSeed.sigma * 6);
404 double t0min = timeSeed.t0 - timeRangeFine / 2;
405 double t0max = timeSeed.t0 + timeRangeFine / 2;
406
407 for (size_t itrk = 0; itrk < topTracks.size(); itrk++) {
408 finders.push_back(Chi2MinimumFinder1D(m_numBins, t0min, t0max));
409 const auto& reco = pdfConstructors[itrk];
410 numPhotons[itrk] = setFinder(finders.back(), reco, timeMin, timeMax);
411 const auto& trk = topTracks[itrk];
412 double momentum = trk.getMomentumMag();
413 if (not m_useMCTruth and momentum > 0.7 and topTracks.size() <= m_nTrackLimit) {
414 std::vector<Const::ChargedStable> other;
415 if (reco.getHypothesis() == Const::kaon) {
416 other.push_back(Const::pion);
417 if (momentum < 4.0) other.push_back(Const::proton);
418 } else if (reco.getHypothesis() == Const::proton) {
419 other.push_back(Const::pion);
420 if (momentum < 2.0) other.push_back(Const::kaon);
421 } else {
422 if (momentum < 2.0) other.push_back(Const::kaon);
423 if (momentum < 4.0) other.push_back(Const::proton);
424 }
425 for (const auto& chargedStable : other) {
426 PDFConstructor pdfConstructor(trk, chargedStable, PDFConstructor::c_Rough);
427 if (not pdfConstructor.isValid()) continue;
428 pdfConstructor.switchOffDeltaRayPDF(); // to speed-up fine search
429 if (pdfConstructor.getExpectedSignalPhotons() < m_minSignal) continue;
430 Chi2MinimumFinder1D finder(m_numBins, t0min, t0max);
431 int numPhot = setFinder(finder, pdfConstructor, timeMin, timeMax);
432 if (numPhot != numPhotons[itrk])
433 B2ERROR("Different number of photons used for log likelihood of different mass hypotheses");
434 if (finder.getMinChi2() < finders.back().getMinChi2()) {
435 finders.back() = finder;
436 assumedMasses[itrk] = chargedStable.getMass();
437 }
438 }
439 }
440 }
441
442 if (finders.size() == 0) return; // just in case
443 auto finderSum = finders[0];
444 for (size_t i = 1; i < finders.size(); i++) {
445 finderSum.add(finders[i]);
446 }
447
448 if (timeSeed.sigma > 0) {
449 const auto& binCenters = finderSum.getBinCenters();
450 for (unsigned i = 0; i < binCenters.size(); i++) {
451 double t0 = binCenters[i];
452 finderSum.add(i, pow((t0 - timeSeed.t0) / timeSeed.sigma, 2)); // add chi2 according to timeSeed resolution
453 }
454 }
455
456 const auto& T0 = finderSum.getMinimum();
457 if (m_saveHistograms) {
458 m_recBunch->addHistogram(finderSum.getHistogram("chi2_fine_", "precise T0; t_{0} [ns]; -2 log L"));
459 }
460 if (T0.position < t0min or T0.position > t0max or not T0.valid) {
461 B2DEBUG(20, "Fine T0 finder: returning invalid or out of range T0");
462 return;
463 }
464
465 // bunch time and current offset
466
467 int bunchNo = lround(T0.position / m_bunchTimeSep); // round to nearest integer
468 double offset = T0.position - m_bunchTimeSep * bunchNo;
469 if (not m_commonT0->isCalibrated()) { // auto set offset range
470 double deltaOffset = offset - m_runningOffset;
471 if (fabs(deltaOffset + m_bunchTimeSep) < fabs(deltaOffset)) {
472 offset += m_bunchTimeSep;
473 bunchNo--;
474 } else if (fabs(deltaOffset - m_bunchTimeSep) < fabs(deltaOffset)) {
475 offset -= m_bunchTimeSep;
476 bunchNo++;
477 }
478 }
479 double error = T0.error;
480
481 // averaging with first order filter (with adoptable time constant)
482
483 double tau = 10 + m_success / 2; // empirically with toy MC
484 if (tau > m_tau) tau = m_tau;
485 double a = exp(-1.0 / tau);
486 m_runningOffset = a * m_runningOffset + (1 - a) * offset;
487 double err1 = a * m_runningError;
488 double err2 = (1 - a) * error;
489 m_runningError = sqrt(err1 * err1 + err2 * err2);
490
491 // when not running in HLT mode, check if reconstructed bunch is filled
492
493 if (not m_HLTmode) {
494 bool isFilled = isBucketFilled(bunchNo); // stores in addition the bucket number and fill status in m_recBunch
495 if (m_useFillPattern and not isFilled) return;
496 }
497
498 // store the results
499
500 double bunchTime = bunchNo * m_bunchTimeSep;
501 m_recBunch->setReconstructed(bunchNo, bunchTime, offset, error, m_runningOffset, m_runningError, timeSeed.detector);
502 m_recBunch->setMinChi2(T0.chi2);
503 double svdOffset = m_eventT0Offset.isValid() and not m_isMC ? m_eventT0Offset->get(Const::SVD).offset : 0;
504 m_eventT0->addTemporaryEventT0(EventT0::EventT0Component(bunchTime + svdOffset, error, Const::TOP, "bunchFinder"));
505 m_success++;
506
507 // store T0 of single tracks relative to bunchTime
508
509 if (finders.size() == topTracks.size()) {
510 for (size_t itrk = 0; itrk < topTracks.size(); itrk++) {
511 const auto& trk = topTracks[itrk];
512 auto& finder = finders[itrk];
513 const auto& t0trk = finder.getMinimum();
514 auto* timeZero = m_timeZeros.appendNew(trk.getModuleID(),
515 t0trk.position - bunchTime,
516 t0trk.error, numPhotons[itrk]);
517 timeZero->setAssumedMass(assumedMasses[itrk]);
518 if (not t0trk.valid) timeZero->setInvalid();
519 timeZero->setMinChi2(finder.getMinChi2());
520 timeZero->addRelationTo(trk.getExtHit());
521
522 if (m_saveHistograms) {
523 std::string num = std::to_string(itrk);
524 auto chi2 = finder.getHistogram("chi2_" + num,
525 "precise T0 single track; t_{0} [ns]; -2 log L");
526 auto pdf = top1Dpdfs[itrk].getHistogram("pdf1D_" + num,
527 "PDF projected to time axis; time [ns]");
528 TH1F hits(("hits_" + num).c_str(),
529 "time distribution of hits (t0-subtracted); time [ns]",
530 pdf.GetNbinsX(), pdf.GetXaxis()->GetXmin(), pdf.GetXaxis()->GetXmax());
531 for (const auto& hit : trk.getSelectedHits()) {
532 hits.Fill(hit.time - t0trk.position);
533 }
534 timeZero->setHistograms(chi2, pdf, hits);
535 }
536 }
537 }
538
539 // correct time in TOPDigits
540
541 if (m_correctDigits) {
542 for (auto& digit : m_topDigits) {
543 digit.subtractT0(bunchTime);
544 digit.addStatus(TOPDigit::c_EventT0Subtracted);
545 if (m_HLTmode and m_subtractRunningOffset) {
546 digit.subtractT0(m_runningOffset);
547 double err = digit.getTimeError();
548 digit.setTimeError(sqrt(err * err + m_runningError * m_runningError));
549 digit.addStatus(TOPDigit::c_BunchOffsetSubtracted);
550 }
551 }
552 }
553
554 }

◆ event() [5/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 101 of file TOPCalPulseGeneratorModule.cc.

102 {
103 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
104
105 double time = m_delay + gRandom->Uniform(m_windowSize);
106 for (auto moduleID : m_moduleIDs) {
107 for (unsigned asic = 0; asic < 64; asic++) {
108 for (auto asicChannel : m_asicChannels) {
109 unsigned channel = asic * 8 + asicChannel;
110 auto pixelID = chMapper.getPixelID(channel);
111 m_calPulses.appendNew(moduleID, channel, pixelID, time, m_amplitude);
112 }
113 }
114 }
115
116 }

◆ event() [6/32]

void event ( void )
overridevirtual

event method: removes channels from the reconstruction pdf, flags hits from noisy channels as junk

Reimplemented from Module.

Definition at line 69 of file TOPChannelMaskerModule.cc.

70 {
71
72 // have those payloads changed?
73
74 bool pmtInstalled = m_pmtInstalled.hasChanged();
75 bool pmtQEData = m_pmtQEData.hasChanged();
76 bool channelRQE = m_channelRQE.hasChanged();
77 bool thresholdEff = m_thresholdEff.hasChanged();
78
79 // if at least one then pass pixel relative efficiencies to the reconstructon code
80
81 if (pmtInstalled or pmtQEData or channelRQE or thresholdEff) {
82 TOPRecoManager::setChannelEffi();
83 }
84
85 // have asic masks changed?
86
87 bool asicMasksChanged = false;
88 if (m_eventAsicMask.isValid()) {
89 if (m_eventAsicMask->get() != m_savedAsicMask.get()) {
90 m_savedAsicMask.set(m_eventAsicMask->get());
91 asicMasksChanged = true;
92 }
93 }
94
95 // have channel masks or calibration changed?
96
97 bool channelMaskChanged = m_channelMask.hasChanged();
98 bool channelT0Changed = m_channelT0.hasChanged();
99 bool timebaseChanged = m_timebase.hasChanged();
100
101 // if at least one then pass the new masking to the reconstruction code
102
103 if (channelMaskChanged or asicMasksChanged or
104 (m_maskUncalibratedChannelT0 and channelT0Changed) or
105 (m_maskUncalibratedTimebase and timebaseChanged)) {
106
107 TOPRecoManager::setChannelMask(m_channelMask, m_savedAsicMask);
108 if (m_maskUncalibratedChannelT0) {
109 TOPRecoManager::setUncalibratedChannelsOff(m_channelT0);
110 }
111 if (m_maskUncalibratedTimebase) {
112 TOPRecoManager::setUncalibratedChannelsOff(m_timebase);
113 }
114 }
115
116 // now flag actual data Cherenkov hits as coming from masked channels
117
118 for (auto& digit : m_digits) {
119 // if already set switch the state back to c_Good (e.g. for digits read from file)
120 if (digit.getHitQuality() == TOPDigit::c_Masked or
121 digit.getHitQuality() == TOPDigit::c_Uncalibrated) {
122 digit.setHitQuality(TOPDigit::c_Good);
123 }
124 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
125
126 // now do the new masking of c_Good
127 auto slotID = digit.getModuleID();
128 auto channel = digit.getChannel();
129 if (not m_channelMask->isActive(slotID, channel)) {
130 digit.setHitQuality(TOPDigit::c_Masked);
131 continue;
132 }
133 if (not m_savedAsicMask.isActive(slotID, channel)) {
134 digit.setHitQuality(TOPDigit::c_Masked);
135 const unsigned maxCount = 10; // at HLT this means (10 * number-of-processes) messages before being suppressed
136 if (m_errorCount < maxCount) {
137 B2ERROR("Unexpected hit found in a channel that is masked-out by firmware"
138 << LogVar("slotID", slotID) << LogVar("channel", channel));
139 } else if (m_errorCount == maxCount) {
140 B2ERROR("Unexpected hit found in a channel that is masked-out by firmware"
141 << LogVar("slotID", slotID) << LogVar("channel", channel)
142 << LogVar("... message will be suppressed now, errorCount", m_errorCount));
143 }
144 m_errorCount++;
145 continue;
146 }
147 if (m_maskUncalibratedChannelT0 and not m_channelT0->isCalibrated(slotID, channel)) {
148 digit.setHitQuality(TOPDigit::c_Uncalibrated);
149 continue;
150 }
151 if (m_maskUncalibratedTimebase) {
152 const auto& fe_mapper = TOPGeometryPar::Instance()->getFrontEndMapper();
153 const auto* fe = fe_mapper.getMap(slotID, channel / 128);
154 if (not fe) {
155 B2ERROR("No front-end map found" << LogVar("slotID", slotID) << LogVar("channel", channel));
156 digit.setHitQuality(TOPDigit::c_Uncalibrated);
157 continue;
158 }
159 auto scrodID = fe->getScrodID();
160 const auto* sampleTimes = m_timebase->getSampleTimes(scrodID, channel);
161 if (not sampleTimes->isCalibrated()) {
162 digit.setHitQuality(TOPDigit::c_Uncalibrated);
163 }
164 }
165 }
166
167 }

◆ event() [7/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 176 of file TOPChannelT0CalibratorModule.cc.

177 {
178 /* check bunch reconstruction status and run alignment:
179 - if object exists and bunch is found (collision data w/ bunch finder in the path)
180 - if object doesn't exist (cosmic data and other cases w/o bunch finder)
181 */
182
183 if (m_recBunch.isValid()) {
184 if (not m_recBunch->isReconstructed()) return;
185 }
186
187 TOPRecoManager::setDefaultTimeWindow();
188 double timeMin = TOPRecoManager::getMinTime();
189 double timeMax = TOPRecoManager::getMaxTime();
190 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
191
192 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
193
194 for (const auto& track : m_tracks) {
195
196 // track selection
197 TOPTrack trk(track);
198 if (not trk.isValid()) continue;
199
200 if (not m_selector.isSelected(trk)) continue;
201
202 // construct PDF
203 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
204 if (not pdfConstructor.isValid()) continue;
205
206 // minimization procedure: accumulate
207 const unsigned module = trk.getModuleID() - 1;
208 if (module >= c_numModules) continue;
209 int sub = gRandom->Integer(2); // generate sub-sample number
210 auto& finders = m_finders[sub][module];
211 const auto& binCenters = finders[0].getBinCenters();
212 for (unsigned ibin = 0; ibin < binCenters.size(); ibin++) {
213 double t0 = binCenters[ibin];
214 const auto& pixelLogLs = pdfConstructor.getPixelLogLs(t0, m_sigmaSmear);
215 for (unsigned channel = 0; channel < c_numChannels; channel++) {
216 int pix = chMapper.getPixelID(channel) - 1;
217 finders[channel].add(ibin, -2 * pixelLogLs[pix].logL);
218 }
219 }
220
221 // fill histograms of hits
222 m_numPhotons = 0;
223 for (const auto& digit : m_digits) {
224 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
225 if (digit.getModuleID() != trk.getModuleID()) continue;
226 if (digit.getTime() < timeMin) continue;
227 if (digit.getTime() > timeMax) continue;
228 m_numPhotons++;
229 auto& h1 = m_hits1D[module];
230 h1.Fill(digit.getChannel());
231 auto& h2 = m_hits2D[module];
232 h2.Fill(digit.getChannel(), digit.getTime());
233 }
234
235 // fill output tree
236 m_moduleID = trk.getModuleID();
237 const auto& localPosition = m_selector.getLocalPosition();
238 m_x = localPosition.X();
239 m_y = localPosition.Y();
240 m_z = localPosition.Z();
241 const auto& localMomentum = m_selector.getLocalMomentum();
242 m_p = localMomentum.R();
243 m_theta = localMomentum.Theta();
244 m_phi = localMomentum.Phi();
245 const auto& pocaPosition = m_selector.getPOCAPosition();
246 m_pocaR = pocaPosition.Rho();
247 m_pocaZ = pocaPosition.Z();
248 m_pocaX = pocaPosition.X();
249 m_pocaY = pocaPosition.Y();
250 m_cmsE = m_selector.getCMSEnergy();
251 m_charge = trk.getCharge();
252 m_PDG = trk.getPDGCode();
253 m_tree->Fill();
254 }
255
256 }

◆ event() [8/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 67 of file TOPChannelT0MCModule.cc.

68 {
69
70 for (auto& digit : m_digits) {
71 unsigned channel = digit.getChannel();
72 if (channel < c_NumChannels) {
73 auto histo = m_histo[channel];
74 if (!histo) {
75 stringstream ss;
76 ss << "chan" << channel ;
77 string name;
78 ss >> name;
79 string title = "Times " + name;
80 histo = new TH1F(name.c_str(), title.c_str(), (int)m_fitRange[0], m_fitRange[1], m_fitRange[2]);
81 m_histo[channel] = histo;
82 }
83 if (digit.getTime() < m_fitRange[1] || digit.getTime() > m_fitRange[2]) continue;
84 histo->Fill(digit.getTime());
85 }
86 }
87 }

◆ event() [9/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 162 of file TOPCommonT0CalibratorModule.cc.

163 {
164 /* check bunch reconstruction status and run alignment:
165 - if object exists and bunch is found (collision data w/ bunch finder in the path)
166 - if object doesn't exist (cosmic data and other cases w/o bunch finder)
167 */
168
169 if (m_recBunch.isValid()) {
170 if (not m_recBunch->isReconstructed()) return;
171 }
172
173 TOPRecoManager::setDefaultTimeWindow();
174 double timeMin = TOPRecoManager::getMinTime();
175 double timeMax = TOPRecoManager::getMaxTime();
176
177 // running offset must not be subtracted in TOPDigits: issue an error if it is
178
179 if (isRunningOffsetSubtracted()) {
180 B2ERROR("Running offset subtracted in TOPDigits: common T0 will not be correct");
181 }
182
183 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
184
185 for (const auto& track : m_tracks) {
186
187 // track selection
188 TOPTrack trk(track);
189 if (not trk.isValid()) continue;
190
191 if (not m_selector.isSelected(trk)) continue;
192
193 // construct PDF
194 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
195 if (not pdfConstructor.isValid()) continue;
196
197 // minimization procedure: accumulate
198 int sub = gRandom->Integer(c_numSets); // generate sub-sample number
199 auto& finder = m_finders[sub];
200 const auto& binCenters = finder.getBinCenters();
201 for (unsigned ibin = 0; ibin < binCenters.size(); ibin++) {
202 double t0 = binCenters[ibin];
203 finder.add(ibin, -2 * pdfConstructor.getLogL(t0, m_sigmaSmear).logL);
204 }
205
206 // fill histograms of hits
207 m_numPhotons = 0;
208 for (const auto& digit : m_digits) {
209 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
210 if (digit.getModuleID() != trk.getModuleID()) continue;
211 if (digit.getTime() < timeMin) continue;
212 if (digit.getTime() > timeMax) continue;
213 m_numPhotons++;
214 m_hits1D.Fill(digit.getModuleID());
215 int bs = digit.getBoardstackNumber();
216 m_hits2D.Fill((digit.getModuleID() * 4 + bs - 1.5) / 4.0, digit.getTime());
217 }
218
219 // fill output tree
220 m_moduleID = trk.getModuleID();
221 const auto& localPosition = m_selector.getLocalPosition();
222 m_x = localPosition.X();
223 m_y = localPosition.Y();
224 m_z = localPosition.Z();
225 const auto& localMomentum = m_selector.getLocalMomentum();
226 m_p = localMomentum.R();
227 m_theta = localMomentum.Theta();
228 m_phi = localMomentum.Phi();
229 const auto& pocaPosition = m_selector.getPOCAPosition();
230 m_pocaR = pocaPosition.Rho();
231 m_pocaZ = pocaPosition.Z();
232 m_pocaX = pocaPosition.X();
233 m_pocaY = pocaPosition.Y();
234 m_cmsE = m_selector.getCMSEnergy();
235 m_charge = trk.getCharge();
236 m_PDG = trk.getPDGCode();
237 m_tree->Fill();
238 }
239
240 }

◆ event() [10/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 103 of file TOPCosmicT0FinderModule.cc.

104 {
105 TOPRecoManager::setDefaultTimeWindow();
106
107 // select track: if several, choose highest momentum track
108
109 StoreArray<Track> tracks;
110 const ExtHit* selectedExtHit = 0;
111 double p0 = 0;
112 for (const auto& track : tracks) {
113 const auto extHits = track.getRelationsWith<ExtHit>();
114 const ExtHit* extHit0 = 0;
115 for (const auto& extHit : extHits) {
116 if (abs(extHit.getPdgCode()) != Const::muon.getPDGCode()) continue;
117 if (extHit.getDetectorID() != Const::EDetector::TOP) continue;
118 if (extHit.getCopyID() <= 0) continue;
119 double dot = extHit.getPosition().Dot(extHit.getMomentum());
120 if (m_useIncomingTrack) {
121 if (dot > 0) continue;
122 if (not extHit0) extHit0 = &extHit;
123 if (extHit.getTOF() < extHit0->getTOF()) extHit0 = &extHit;
124 } else {
125 if (dot < 0) continue;
126 if (not extHit0) extHit0 = &extHit;
127 if (extHit.getTOF() > extHit0->getTOF()) extHit0 = &extHit;
128 }
129 }
130 if (not extHit0) continue;
131 double p = extHit0->getMomentum().R();
132 if (p > p0) {
133 p0 = p;
134 selectedExtHit = extHit0;
135 }
136 }
137 if (not selectedExtHit) return;
138
139 TOPTrack topTrack(selectedExtHit);
140 if (not topTrack.isValid()) return;
141
142 // require minimal number of photon hits
143
144 if (topTrack.getSelectedHits().size() < m_minHits) return;
145
146 // construct PDF for muon
147
148 PDFConstructor pdfConstructor(topTrack, Const::muon, PDFConstructor::c_Rough);
149 if (not pdfConstructor.isValid()) return;
150
151 // require minimal expected signal
152
153 if (pdfConstructor.getExpectedSignalPhotons() < m_minSignal) return;
154
155 // event is accepted for t0 determination
156
157 m_acceptedCount++;
158
159 // full time window in which data are taken (smaller time window is used in reconstruction)
160
161 const auto& tdc = TOPGeometryPar::Instance()->getGeometry()->getNominalTDC();
162 double timeWindow = m_feSetting->getReadoutWindows() * tdc.getSyncTimeBase() / static_cast<double>(TOPNominalTDC::c_syncWindows);
163
164 // find rough t0
165
166 PDF1Dim pdf1d(pdfConstructor, 1.0, timeWindow); // ~1 ns bin size
167 pdfConstructor.switchOffDeltaRayPDF(); // to speed-up fine search
168
169 Chi2MinimumFinder1D roughFinder(pdf1d.getNumBinsT0(), pdf1d.getMinT0(), pdf1d.getMaxT0());
170 const auto& bins = roughFinder.getBinCenters();
171 for (unsigned i = 0; i < bins.size(); i++) {
172 double t0 = bins[i];
173 roughFinder.add(i, -2 * pdf1d.getLogL(t0));
174 }
175 const auto& t0Rough = roughFinder.getMinimum();
176
177 // find precise t0
178
179 double timeMin = TOPRecoManager::getMinTime() + t0Rough.position;
180 double timeMax = TOPRecoManager::getMaxTime() + t0Rough.position;
181 double t0min = t0Rough.position - m_timeRange / 2;
182 double t0max = t0Rough.position + m_timeRange / 2;
183 Chi2MinimumFinder1D finder(m_numBins, t0min, t0max);
184 const auto& binCenters = finder.getBinCenters();
185 int numPhotons = 0;
186 for (unsigned i = 0; i < binCenters.size(); i++) {
187 double t0 = binCenters[i];
188 auto LL = pdfConstructor.getLogL(t0, timeMin, timeMax, m_sigma);
189 finder.add(i, -2 * LL.logL);
190 if (i == 0) numPhotons = LL.numPhotons;
191 }
192 const auto& t0 = finder.getMinimum();
193 if (t0.position < t0min or t0.position > t0max or not t0.valid) return; // out of range
194
195 // event t0 is successfully determined
196
197 m_successCount++;
198
199 // store results
200
201 StoreArray<TOPTimeZero> timeZeros;
202 auto* timeZero = timeZeros.appendNew(topTrack.getModuleID(), t0.position, t0.error, numPhotons);
203 timeZero->addRelationTo(topTrack.getTrack());
204 timeZero->addRelationTo(topTrack.getExtHit());
205 if (topTrack.getBarHit()) timeZero->addRelationTo(topTrack.getBarHit());
206
207 // save histograms
208
209 if (m_saveHistograms) {
210 std::string name;
211
212 name = "chi2_" + to_string(m_num);
213 std::string title = "muon -2 logL vs. t0; t_{0} [ns]; -2 log L_{#mu}";
214 auto chi2 = finder.getHistogram(name, title);
215
216 name = "pdf_" + to_string(m_num);
217 auto pdf = pdf1d.getHistogram(name, "PDF projected to time axis");
218 pdf.SetName(name.c_str());
219 pdf.SetXTitle("time [ns]");
220 pdf.SetLineColor(2);
221 pdf.SetOption("hist");
222
223 name = "hits_" + to_string(m_num);
224 TH1F hits(name.c_str(), "time distribution of photons (t0-subtracted)",
225 pdf.GetNbinsX(), pdf.GetXaxis()->GetXmin(), pdf.GetXaxis()->GetXmax());
226 hits.SetXTitle("time [ns]");
227 for (const auto& hit : topTrack.getSelectedHits()) {
228 hits.Fill(hit.time - t0.position);
229 }
230 timeZero->setHistograms(chi2, pdf, hits);
231 m_num++;
232 }
233
234 // subtract T0 in digits
235
236 if (m_applyT0) {
237 StoreArray<TOPDigit> topDigits;
238 for (auto& digit : topDigits) {
239 digit.subtractT0(t0.position);
240 double err = digit.getTimeError();
241 digit.setTimeError(sqrt(err * err + t0.error * t0.error));
242 digit.addStatus(TOPDigit::c_EventT0Subtracted);
243 }
244 }
245
246 }
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors

◆ event() [11/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 237 of file TOPDigitizerModule.cc.

238 {
239
240 // get or generate revo9 count
241 unsigned revo9cnt = 0;
242 if (m_simClockState.isValid()) {
243 revo9cnt = m_simClockState->getRevo9Count();
244 } else {
245 revo9cnt = gRandom->Integer(11520);
246 }
247
248 // from revo9 count determine trigger time offset and the number of offset windows
249 double SSTfrac = (revo9cnt % 6) / 6.0;
250 double offset = m_feSetting->getOffset() / 24.0;
251 double trgTimeOffset = (SSTfrac + offset) * m_syncTimeBase; // in [ns]
252 int offsetWindows = m_feSetting->getWindowShift(revo9cnt);
253 TimeDigitizer::setOffsetWindows(offsetWindows);
254
255 // from revo9 and write depths determine reference window, phase and storage depth
256 int SSTcnt = revo9cnt / 6;
257 int refWindow = SSTcnt * 2; // same as lastWriteAddr
258 const auto& writeDepths = m_feSetting->getWriteDepths();
259 if (writeDepths.empty()) {
260 B2ERROR("TOPDigitzer: vector of write depths is empty. No digitization possible");
261 return;
262 }
263 int lastDepth = writeDepths.back();
264 unsigned phase = 0;
265 for (auto depth : writeDepths) {
266 SSTcnt -= depth;
267 if (SSTcnt < 0) break;
268 phase++;
269 refWindow = SSTcnt * 2;
270 lastDepth = depth;
271 }
272 unsigned storageDepth = lastDepth * 2;
273 TimeDigitizer::setStorageDepth(storageDepth);
274
275 // from reference window and lookback determine first of the readout windows
276 int lookBackWindows = m_feSetting->getLookbackWindows();
277 if (m_lookBackWindows > 0) lookBackWindows = m_lookBackWindows;
278 lookBackWindows -= m_feSetting->getExtraWindows();
279 int window = refWindow - lookBackWindows;
280 if (window < 0) window += storageDepth;
281 TimeDigitizer::setFirstWindow(window);
282
283 // geometry and nominal data
284 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
285
286 // time range for digitization
287 double timeMin = geo->getSignalShape().getTMin() + offsetWindows * m_syncTimeBase / 2;
288 double timeMax = geo->getSignalShape().getTMax() +
289 (m_feSetting->getReadoutWindows() + offsetWindows) * m_syncTimeBase / 2;
290
291 // simulate start time jitter
292 double startTimeJitter = gRandom->Gaus(0, m_timeZeroJitter);
293
294 // get electronic efficiency
295 double electronicEfficiency = geo->getNominalTDC().getEfficiency();
296
297 // define pixels with time digitizers
298 std::map<unsigned, TimeDigitizer> pixels;
299 typedef std::map<unsigned, TimeDigitizer>::iterator Iterator;
300
301 // add simulated hits to time digitizers
302
303 for (const auto& simHit : m_simHits) {
304 if (not m_useWaveforms) {
305 // simulate electronic efficiency
306 if (gRandom->Rndm() > electronicEfficiency) continue;
307 }
308 // do spatial digitization
309 double x = simHit.getX();
310 double y = simHit.getY();
311 int pmtID = simHit.getPmtID();
312 int moduleID = simHit.getModuleID();
313 if (not geo->isModuleIDValid(moduleID)) continue;
314 int pixelID = geo->getModule(moduleID).getPMTArray().getPixelID(x, y, pmtID);
315 if (pixelID == 0) continue;
316
317 // add start time jitter and generated TTS to photon time
318 double time = simHit.getTime() + startTimeJitter;
319 if (m_simulateTTS) {
320 const auto& tts = TOPGeometryPar::Instance()->getTTS(moduleID, pmtID);
321 time += tts.generateTTS();
322 }
323
324 // get time offset for a given pixel
325 auto timeOffset = getTimeOffset(trgTimeOffset, moduleID, pixelID);
326
327 // time range cut (to speed up digitization)
328 if (time + timeOffset.value < timeMin + timeOffset.timeShift) continue;
329 if (time + timeOffset.value > timeMax + timeOffset.timeShift) continue;
330
331 // generate pulse height
332 double pulseHeight = generatePulseHeight(moduleID, pixelID);
333 auto hitType = TimeDigitizer::c_Hit;
334
335 // add time and pulse height to digitizer of a given pixel
336 TimeDigitizer digitizer(moduleID, pixelID, timeOffset.value, timeOffset.error,
337 timeOffset.windowShift, m_rmsNoise, m_sampleTimes);
338 if (not digitizer.isValid()) continue;
339 unsigned id = digitizer.getUniqueID();
340 Iterator it = pixels.insert(pair<unsigned, TimeDigitizer>(id, digitizer)).first;
341 it->second.addTimeOfHit(time, pulseHeight, hitType, &simHit);
342 }
343
344 // add calibration pulses
345
346 for (const auto& simCalPulses : m_simCalPulses) {
347 auto moduleID = simCalPulses.getModuleID();
348 auto pixelID = simCalPulses.getPixelID();
349 auto pulseHeight = simCalPulses.getAmplitude();
350 auto time = simCalPulses.getTime();
351 auto hitType = TimeDigitizer::c_CalPulse;
352
353 // get time offset for a given pixel
354 auto timeOffset = getTimeOffset(trgTimeOffset, moduleID, pixelID);
355
356 // time range cut (to speed up digitization)
357 if (time + timeOffset.value < timeMin + timeOffset.timeShift) continue;
358 if (time + timeOffset.value > timeMax + timeOffset.timeShift) continue;
359
360 // add time and pulse height to digitizer of a given pixel
361 TimeDigitizer digitizer(moduleID, pixelID, timeOffset.value, timeOffset.error,
362 timeOffset.windowShift, m_rmsNoise, m_sampleTimes);
363 if (not digitizer.isValid()) continue;
364 unsigned id = digitizer.getUniqueID();
365 Iterator it = pixels.insert(pair<unsigned, TimeDigitizer>(id, digitizer)).first;
366 it->second.addTimeOfHit(time, pulseHeight, hitType);
367 }
368
369 // add randomly distributed dark noise (maybe not needed anymore?)
370
371 if (m_darkNoise > 0) {
372 int numModules = geo->getNumModules();
373 for (int moduleID = 1; moduleID <= numModules; moduleID++) {
374 int numPixels = geo->getModule(moduleID).getPMTArray().getNumPixels();
375 int numHits = gRandom->Poisson(m_darkNoise);
376 for (int i = 0; i < numHits; i++) {
377 int pixelID = int(gRandom->Rndm() * numPixels) + 1;
378 double time = (timeMax - timeMin) * gRandom->Rndm() + timeMin;
379 double pulseHeight = generatePulseHeight(moduleID, pixelID);
380 auto hitType = TimeDigitizer::c_Hit;
381 auto timeOffset = getTimeOffset(trgTimeOffset, moduleID, pixelID);
382 time += timeOffset.timeShift;
383 time -= timeOffset.value;
384 TimeDigitizer digitizer(moduleID, pixelID, timeOffset.value, timeOffset.error,
385 timeOffset.windowShift, m_rmsNoise, m_sampleTimes);
386 if (not digitizer.isValid()) continue;
387 unsigned id = digitizer.getUniqueID();
388 Iterator it = pixels.insert(pair<unsigned, TimeDigitizer>(id, digitizer)).first;
389 it->second.addTimeOfHit(time, pulseHeight, hitType);
390 }
391 }
392 }
393
394 // if making waveforms for all channels, add missing digitizers.
395
396 if (m_allChannels) {
397 int numModules = geo->getNumModules();
398 for (int moduleID = 1; moduleID <= numModules; moduleID++) {
399 int numPixels = geo->getModule(moduleID).getPMTArray().getNumPixels();
400 for (int pixelID = 1; pixelID <= numPixels; pixelID++) {
401 auto timeOffset = getTimeOffset(trgTimeOffset, moduleID, pixelID);
402 TimeDigitizer digitizer(moduleID, pixelID, timeOffset.value, timeOffset.error,
403 timeOffset.windowShift, m_rmsNoise, m_sampleTimes);
404 if (not digitizer.isValid()) continue;
405 unsigned id = digitizer.getUniqueID();
406 pixels.insert(pair<unsigned, TimeDigitizer>(id, digitizer));
407 }
408 }
409 }
410
411 // replace equidistant time base with calibrated one if available
412
413 if (m_useDatabase or m_useSampleTimeCalibration) {
414 for (auto& pixel : pixels) {
415 auto& digitizer = pixel.second;
416 const auto* sampleTimes = m_timebases->getSampleTimes(digitizer.getScrodID(),
417 digitizer.getChannel());
418 if (not sampleTimes) continue;
419 if (sampleTimes->isCalibrated()) digitizer.setSampleTimes(sampleTimes);
420 }
421 }
422
423 // replace default noise level with channel dependent one if available,
424
425 if (m_useDatabase) {
426 for (auto& pixel : pixels) {
427 auto& digitizer = pixel.second;
428 auto moduleID = digitizer.getModuleID();
429 auto channel = digitizer.getChannel();
430 auto rmsNoise = m_noises->getNoise(moduleID, channel);
431 if (rmsNoise > 0) {
432 digitizer.setNoise(rmsNoise);
433 }
434 }
435 }
436
437 // digitize in time
438
439 for (auto& pixel : pixels) {
440 const auto& digitizer = pixel.second;
441 int threshold = m_threshold;
442 if (m_useDatabase) { // use channel dependent ones
443 threshold = m_thresholds->getThr(digitizer.getModuleID(), digitizer.getChannel());
444 if (threshold <= 0) threshold = m_threshold; // not available, use the default
445 }
446 if (m_useWaveforms) {
447 digitizer.digitize(m_waveforms, m_rawDigits, m_digits,
448 threshold, m_hysteresis, m_thresholdCount);
449 } else {
450 digitizer.digitize(m_rawDigits, m_digits,
451 threshold, m_thresholdCount, m_electronicJitter);
452 }
453 }
454
455 // set additional info
456
457 for (auto& rawDigit : m_rawDigits) {
458 rawDigit.setRevo9Counter(revo9cnt);
459 rawDigit.setPhase(phase);
460 rawDigit.setLastWriteAddr(refWindow);
461 rawDigit.setLookBackWindows(lookBackWindows);
462 rawDigit.setOfflineFlag();
463 }
464
465 for (auto& waveform : m_waveforms) {
466 waveform.setRevo9Counter(revo9cnt);
467 waveform.setOffsetWindows(offsetWindows);
468 }
469
470 // set calibration flags
471
472 if (m_useDatabase) {
473 for (auto& digit : m_digits) {
474 if (m_channelT0->isCalibrated(digit.getModuleID(), digit.getChannel())) {
475 digit.addStatus(TOPDigit::c_ChannelT0Calibrated);
476 }
477 if (m_moduleT0->isCalibrated(digit.getModuleID())) {
478 digit.addStatus(TOPDigit::c_ModuleT0Calibrated);
479 }
480 if (m_commonT0->isCalibrated()) {
481 digit.addStatus(TOPDigit::c_CommonT0Calibrated);
482 }
483 }
484 }
485
486 // cut on product of pulse width and height, as for data in TOPRawDigitConverter
487
488 for (auto& digit : m_digits) {
489 if (digit.getPulseWidth() * digit.getPulseHeight() < m_minWidthXheight)
490 digit.setHitQuality(TOPDigit::c_Junk);
491 }
492
493 }
map< unsigned, size_t >::const_iterator Iterator
Iteratior for m_map.

◆ event() [12/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 162 of file TOPDoublePulseGeneratorModule.cc.

163 {
164
165 StoreArray<TOPDigit> digits;
166
167 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
168 const auto& feMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
169
170 double timeError = m_timeResolution / sqrt(2.0); // for single pulse
171
172 for (auto moduleID : m_moduleIDs) {
173 for (unsigned asic = 0; asic < 64; asic++) {
174 for (auto asicChannel : m_asicChannels) {
175 unsigned channel = asic * 8 + asicChannel;
176 auto pixelID = chMapper.getPixelID(channel);
177
178 // sample times: from steering or database
179 const TOPSampleTimes* sampleTimes = &m_sampleTimes;
180 if (m_useDatabase) {
181 unsigned scrodID = 0;
182 int bs = asic / 16;
183 const auto* feMap = feMapper.getMap(moduleID, bs);
184 if (feMap) scrodID = feMap->getScrodID();
185 sampleTimes = (*m_timebase)->getSampleTimes(scrodID, channel % 128);
186 if (!sampleTimes->isCalibrated()) {
187 B2WARNING("No sample time calibration available for SCROD " << scrodID
188 << " channel " << channel % 128 << " - equidistant will be used");
189 }
190 }
191
192 // first calpulse
193 double time = gRandom->Rndm() * sampleTimes->getTimeRange();
194 unsigned window = gRandom->Rndm() * m_storageWindows;
195 double sample = sampleTimes->getSample(window, time);
196 auto* digit = digits.appendNew(moduleID, pixelID, sample);
197 digit->setFirstWindow(window);
198 digit->setTime(time);
199 digit->setTimeError(timeError);
200 digit->setChannel(channel);
201 digit->setHitQuality(TOPDigit::c_CalPulse);
202
203 // second calpulse
204 time += gRandom->Gaus(m_timeDifference, m_timeResolution);
205 sample = sampleTimes->getSample(window, time);
206 digit = digits.appendNew(moduleID, pixelID, sample);
207 digit->setFirstWindow(window);
208 digit->setTime(time);
209 digit->setTimeError(timeError);
210 digit->setChannel(channel);
211 digit->setHitQuality(TOPDigit::c_CalPulse);
212 }
213 }
214 }
215
216 }

◆ event() [13/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 351 of file TOPDQMModule.cc.

352 {
353
354 // check if event time is reconstructed; distinguish collision data and cosmics
355
356 bool recBunchValid = false;
357 bool cosmics = false;
358 if (m_recBunch.isValid()) { // collision data
359 recBunchValid = m_recBunch->isReconstructed(); // event time is reconstructed
360 } else if (m_timeZeros.getEntries() == 1) { // cosmics w/ reconstructed event time
361 cosmics = true;
362 m_eventT0->Fill(m_timeZeros[0]->getTime());
363 }
364
365 // fill bunch offset
366
367 if (recBunchValid) {
368 double t0 = m_commonT0->isRoughlyCalibrated() ? m_commonT0->getT0() : 0;
369 double offset = m_recBunch->getCurrentOffset() - t0;
370 offset -= m_bunchTimeSep * lround(offset / m_bunchTimeSep); // wrap around
371 m_bunchOffset->Fill(offset);
372 m_eventT0->Fill(m_recBunch->getTime());
373 }
374
375 // fill event desynchronization
376
377 if (m_digits.getEntries() > 0) {
378 for (const auto& digit : m_digits) {
379 int x = digit.getFirstWindow() != m_digits[0]->getFirstWindow() ? 1 : 0 ;
380 m_BoolEvtMonitor->Fill(x);
381 }
382 }
383
384 // count tracks in the modules and store the momenta
385
386 std::vector<int> numTracks(m_numModules, 0);
387 std::vector<double> trackMomenta(m_numModules, 0);
388 for (const auto& track : m_tracks) {
389 const auto* fitResult = track.getTrackFitResultWithClosestMass(Const::pion);
390 if (not fitResult) continue;
391 int slot = getModuleID(track);
392 if (slot == 0) continue;
393 numTracks[slot - 1]++;
394 trackMomenta[slot - 1] = std::max(trackMomenta[slot - 1], fitResult->getMomentum().R());
395 }
396
397 // count events w/ and w/o track in the slot
398
399 if (recBunchValid or cosmics) {
400 for (size_t i = 0; i < numTracks.size(); i++) {
401 bool hit = numTracks[i] > 0;
402 m_trackHits->Fill(i + 1, hit);
403 }
404 }
405
406 // select modules for counting hits in signal and background time windows
407
408 std::vector<bool> selectedSlots(m_numModules, false);
409 for (size_t i = 0; i < selectedSlots.size(); i++) {
410 selectedSlots[i] = (recBunchValid or cosmics) and numTracks[i] == 1 and trackMomenta[i] > m_momentumCut;
411 }
412
413 // prepare counters
414
415 int nHits_good = 0;
416 int nHits_bad = 0;
417 std::vector<int> numSignalHits(m_numModules, 0);
418 std::vector<int> numBackgroundHits(m_numModules, 0);
419
420 // loop over digits, fill histograms and increment counters
421
422 for (const auto& digit : m_digits) {
423 int slot = digit.getModuleID();
424 if (slot < 1 or slot > m_numModules) {
425 B2ERROR("Invalid slot ID found in TOPDigits: ID = " << slot);
426 continue;
427 }
428 int asic_no = digit.getChannel() / 8;
429 int asic_ch = digit.getChannel() % 8;
430
431 m_window_vs_slot->Fill(digit.getModuleID(), digit.getRawTime() / 64 + 220);
432 m_window_vs_asic[slot - 1]->Fill(asic_no, digit.getRawTime() / 64 + 220);
433
434 if (digit.getHitQuality() != TOPDigit::c_Junk) { // good hits
435 m_goodHitsXY[slot - 1]->Fill(digit.getPixelCol(), digit.getPixelRow());
436 m_goodHitsAsics[slot - 1]->Fill(asic_no, asic_ch);
437 m_goodTDC[slot - 1]->Fill(digit.getRawTime());
438 m_goodTDCAll->Fill(digit.getRawTime());
439 m_goodChannelHits[slot - 1]->Fill(digit.getChannel());
440 m_pulseHeights[slot - 1]->Fill(digit.getPMTNumber(), digit.getPulseHeight());
441 nHits_good++;
442 if (digit.hasStatus(TOPDigit::c_EventT0Subtracted)) {
443 double time = digit.getTime();
444 if (cosmics) time += 10; // move for 10 ns in order to get the complete signal at positive times
445 if (numTracks[slot - 1] > 0) {
446 m_goodTiming[slot - 1]->Fill(time);
447 m_time->Fill(time);
448 } else {
449 m_goodTimingBG[slot - 1]->Fill(time);
450 m_timeBG->Fill(time);
451 }
452 if (selectedSlots[slot - 1] and abs(time) < 50) {
453 if (time > 0) numSignalHits[slot - 1]++;
454 else numBackgroundHits[slot - 1]++;
455 }
456 }
457 } else { // bad hits: FE not valid, pedestal jump, too short or too wide pulses
458 m_badHitsXY[slot - 1]->Fill(digit.getPixelCol(), digit.getPixelRow());
459 m_badHitsAsics[slot - 1]->Fill(asic_no, asic_ch);
460 m_badTDC[slot - 1]->Fill(digit.getRawTime());
461 m_badTDCAll->Fill(digit.getRawTime());
462 m_badChannelHits[slot - 1]->Fill(digit.getChannel());
463 nHits_bad++;
464 }
465 }
466
467 // histogram counters
468
469 m_goodHitsPerEventAll->Fill(nHits_good);
470 m_badHitsPerEventAll->Fill(nHits_bad);
471 for (int slot = 1; slot <= m_numModules; slot++) {
472 if (selectedSlots[slot - 1]) {
473 m_signalHits->Fill(slot, numSignalHits[slot - 1]);
474 m_backgroundHits->Fill(slot, numBackgroundHits[slot - 1]);
475 }
476 }
477
478 // fill injection histograms
479
480 for (auto& it : m_rawFTSWs) {
481 B2DEBUG(29, "TTD FTSW : " << hex << it.GetTTUtime(0) << " " << it.GetTTCtime(0) << " EvtNr " << it.GetEveNo(0) << " Type " <<
482 (it.GetTTCtimeTRGType(0) & 0xF) << " TimeSincePrev " << it.GetTimeSincePrevTrigger(0) << " TimeSinceInj " <<
483 it.GetTimeSinceLastInjection(0) << " IsHER " << it.GetIsHER(0) << " Bunch " << it.GetBunchNumber(0));
484 auto time_clk = it.GetTimeSinceLastInjection(0); // expressed in system clock
485 if (time_clk != 0x7FFFFFFF) {
486 unsigned int nentries = m_digits.getEntries();
487 double time_us = time_clk / 127.0; // 127MHz clock ticks to us, inexact rounding
488 double time_ms = time_us / 1000;
489 double time_1280 = time_clk % 1280; // within beam cycle, experssed in system clock
490 if (it.GetIsHER(0)) {
491 m_TOPOccAfterInjHER->Fill(time_us, nentries);
492 m_TOPEOccAfterInjHER->Fill(time_us);
493 m_nhitInjHER->Fill(time_ms, time_1280, nHits_good);
494 m_eventInjHER->Fill(time_ms, time_1280);
495 if (nHits_good > 1000) {
496 m_nhitInjHERcut->Fill(time_ms, time_1280, nHits_good);
497 m_eventInjHERcut->Fill(time_ms, time_1280);
498 }
499 } else {
500 m_TOPOccAfterInjLER->Fill(time_us, nentries);
501 m_TOPEOccAfterInjLER->Fill(time_us);
502 m_nhitInjLER->Fill(time_ms, time_1280, nHits_good);
503 m_eventInjLER->Fill(time_ms, time_1280);
504 if (nHits_good > 1000) {
505 m_nhitInjLERcut->Fill(time_ms, time_1280, nHits_good);
506 m_eventInjLERcut->Fill(time_ms, time_1280);
507 }
508 }
509 }
510 }
511
512 }

◆ event() [14/32]

void event ( void )
overridevirtual

This will be empty as the all the processes are done in beginRun() function thus input file can be a dummy file.

Reimplemented from HistoModule.

Definition at line 164 of file TOPGainEfficiencyCalculatorModule.cc.

165 {
166 }

◆ event() [15/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 163 of file TOPInterimFENtupleModule.cc.

164 {
165
166 m_nHit = 0;
167 m_nFEHeader = 0;
168 m_nEmptyFEHeader = 0;
169 m_nWaveform = 0;
170 m_errorFlag = 0;
171
172 StoreObjPtr<EventMetaData> EventMetaDataPtr;
173 StoreArray<RawTOP> rawTOPs;
174 StoreArray<TOPDigit> digits;
175
176 for (int iSlot = 0 ; iSlot < c_NModule ; iSlot++) {
177 m_eventNumCopper[iSlot] = -1;
178 m_ttuTime[iSlot] = -1;
179 m_ttcTime[iSlot] = -1;
180 }
181 int iSlotTTC = 0;
182 short trigCtime = -1;
183 for (auto& rawTOP : rawTOPs) {
184 if (iSlotTTC >= c_NModule) {
185 B2WARNING("too many TTC information");
186 break;
187 }
188 m_eventNumCopper[iSlotTTC] = rawTOP.GetEveNo(0);
189 m_ttuTime[iSlotTTC] = rawTOP.GetTTUtime(0);
190 m_ttcTime[iSlotTTC] = rawTOP.GetTTCtime(0);
191
192 if (trigCtime < 0)
193 trigCtime = ((((long)m_ttcTime[iSlotTTC] + (long)(m_ttuTime[iSlotTTC] - 1524741300) * 127216000) % 11520) % 3840) % 1284;
194 iSlotTTC++;
195 }
196
197 std::map<short, short> nHitOfflineFEMap;
198 static std::set<short> noisyChannelBlackListSet;
199 UInt_t EventNum = EventMetaDataPtr->getEvent();
200 m_eventNum = EventNum;
201 m_eventErrorFlag = EventMetaDataPtr->getErrorFlag();
202 for (const auto& digit : digits) {
203
204 if (m_nHit >= c_NMaxHitEvent) {
205 B2WARNING("TOPInterimFENtuple : too many hits found (>=" << c_NMaxHitEvent
206 << "), EventNo = " << EventNum << ", no more hits are recorded.");
207 break;
208 }
209
210 m_slotNum[m_nHit] = digit.getModuleID();
211 m_pixelId[m_nHit] = (short)digit.getPixelID();
212 m_channelId[m_nHit] = (short)digit.getChannel();
213 m_isCalCh[m_nHit] = (digit.getASICChannel() == m_calibrationChannel);
214 m_winNum[m_nHit] = -1;
215 m_eventWinNum[m_nHit] = (short)digit.getFirstWindow();
216 m_trigWinNum[m_nHit] = trigCtime;
217 m_revo9Counter[m_nHit] = -1;
218 m_hitQuality[m_nHit] = (unsigned char)digit.getHitQuality();
219 m_isReallyJunk[m_nHit] = false;
220 m_windowsInOrder[m_nHit] = true;
221 m_rawTime[m_nHit] = digit.getRawTime();
222 m_time[m_nHit] = digit.getTime() + m_winNum[m_nHit] * m_timePerWin;
223 m_sample[m_nHit] = TMath::FloorNint(m_rawTime[m_nHit] + m_winNum[m_nHit] * c_NSamplePerWindow) % c_NSampleTBC;
224 m_height[m_nHit] = digit.getPulseHeight();
225 m_integral[m_nHit] = digit.getIntegral();
226 m_width[m_nHit] = digit.getPulseWidth();
227 m_peakSample[m_nHit] = -1;
228 for (int iWindow = 0 ; iWindow < c_NWindow ; iWindow++)
229 m_winNumList[m_nHit][iWindow] = -32767;
230 for (int iSample = 0 ; iSample < c_NWaveformSample ; iSample++)
231 m_waveform[m_nHit][iSample] = -32767;
232 m_waveformStartSample[m_nHit] = -1;
233
234 short globalChannelId = m_pixelId[m_nHit] - 1 + (m_slotNum[m_nHit] - 1) * c_NPixelPerModule;
235 if (nHitOfflineFEMap.count(globalChannelId) == 0) nHitOfflineFEMap[globalChannelId] = 0;
236 else if (nHitOfflineFEMap[globalChannelId] > c_NMaxHitPerChannel) {
237 if (noisyChannelBlackListSet.count(globalChannelId) == 0) {
238 // cppcheck-suppress stlFindInsert
239 noisyChannelBlackListSet.insert(globalChannelId);
240 B2WARNING("TOPInterimFENtuple : noisy channel with too many hits (slotNum="
241 << (globalChannelId / c_NPixelPerModule + 1) << ", pixelId = "
242 << (globalChannelId / c_NPixelPerModule + 1) << ") ");
243 }
244 continue;
245 }
246
247 const auto* rawDigit = digit.getRelated<TOPRawDigit>();
248 if (rawDigit) {
249 m_winNum[m_nHit] = rawDigit->getASICWindow();
250 m_revo9Counter[m_nHit] = rawDigit->getRevo9Counter();
251 m_peakSample[m_nHit] = rawDigit->getSamplePeak();
252 m_windowsInOrder[m_nHit] = rawDigit->areWindowsInOrder();
253 if (rawDigit->getDataType() == TOPRawDigit::c_Interim)
254 m_trigWinNum[m_nHit] = (short)rawDigit->getLastWriteAddr();
255 if (rawDigit->isPedestalJump()) m_isReallyJunk[m_nHit] = true;
256 const auto* waveform = rawDigit->getRelated<TOPRawWaveform>();
257 if (waveform) {
258 if (rawDigit->isMadeOffline()) {
259
260 //fill hit flags ; =1 : first hit from offline FE, =2 : second ... , =0 : online FE, -1 : no waveform
261 nHitOfflineFEMap[globalChannelId]++;
262 m_offlineFlag[m_nHit] = nHitOfflineFEMap[globalChannelId];
263 } else { //hit from online feature extraction
264 m_offlineFlag[m_nHit] = 0;
265
266 //store waveform data
267 unsigned nSampleWfm = waveform->getSize();
268 unsigned nSample = TMath::Min((UShort_t)nSampleWfm, (UShort_t)c_NWaveformSample);
269 if (nSample > c_NWaveformSample)
270 B2WARNING("TOPInterimFENtuple: too many waveform samples in TOPRawWaveform : " << nSampleWfm << ", only first " << nSample <<
271 " are considered.");
272 for (unsigned iSample = 0 ; iSample < nSample ; iSample++)
273 m_waveform[m_nHit][iSample] = waveform->getWaveform()[iSample];
274 m_waveformStartSample[m_nHit] = (short)waveform->getStartSample();
275 m_nWaveformSample[m_nHit] = nSampleWfm;
276 //store window number
277 int iWin = 0;
278 for (const auto& window : waveform->getStorageWindows()) {
279 if (iWin < c_NWindow)
280 m_winNumList[m_nHit][iWin] = window;
281 else
282 B2WARNING("TOPInterimFENtuple: too many windows were found");
283
284 iWin++;
285 }
286
287 }
288 }//if( waveform )
289 else m_offlineFlag[m_nHit] = -1;
290 } else {
291 B2WARNING("TOPInterimFENtuple : no TOPRawDigit object found!");
292 m_offlineFlag[m_nHit] = -100;
293 }//if( rawDigit )
294
295
296 m_nHit++;
297 }//for( const auto& digit : digits )
298
299 for (int iHit = 0 ; iHit < m_nHit ; iHit++) {
300
301 short globalChannelId = m_pixelId[iHit] - 1 + (m_slotNum[iHit] - 1) * c_NPixelPerModule;
302 m_nHitOfflineFE[iHit] = nHitOfflineFEMap[globalChannelId];
303
304 }//for(int iHit)
305
306 StoreArray<TOPInterimFEInfo> infos;
307 for (const auto& info : infos) {
308 m_nFEHeader += info.getFEHeadersCount();
309 m_nEmptyFEHeader += info.getEmptyFEHeadersCount();
310 m_nWaveform += info.getWaveformsCount();
311 m_errorFlag |= info.getErrorFlags();
312 }
313
314 StoreArray<TOPProductionEventDebug> prodDebugs;
315 m_nDebugInfo = 0;
316 for (const auto& prodDebug : prodDebugs) {
317 m_scrodCtime[m_nDebugInfo] = prodDebug.getCtime();
318 m_phase[m_nDebugInfo] = prodDebug.getPhase();
319 m_asicMask[m_nDebugInfo] = prodDebug.getAsicMask();
320 m_eventQueuDepth[m_nDebugInfo] = prodDebug.getEventQueueDepth();
321 m_eventNumberByte[m_nDebugInfo] = prodDebug.getEventNumberByte();
322 m_nDebugInfo++;
323 }
324
325 //identify cal. pulse timing
326 getReferenceTiming();
327
328 m_tree->Fill();
329 }

◆ event() [16/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 85 of file TOPLaserCalibratorModule.cc.

86 {
87 for (auto& digit : m_digits) {
88 if (m_barID != 0 && digit.getModuleID() != m_barID) continue; //if m_barID == 0, use all 16 slots(for MC test)
89 unsigned channel = digit.getChannel();
90 if (channel < c_NumChannels) {
91 auto histo = m_histo[channel];
92 if (!histo) {
93 stringstream ss;
94 ss << "chan" << channel ;
95 string name;
96 ss >> name;
97 string title = "Times " + name;
98 histo = new TH1F(name.c_str(), title.c_str(), (int)m_fitRange[0], m_fitRange[1], m_fitRange[2]);
99 m_histo[channel] = histo;
100 }
101 if (digit.getHitQuality() != TOPDigit::EHitQuality::c_Good) continue;
102 if (digit.getTime() < m_fitRange[1] || digit.getTime() > m_fitRange[2]) continue;
103 if (!digit.isTimeBaseCalibrated()) continue;
104 histo->Fill(digit.getTime()); //get Time from TOPDigit
105 }
106 }
107 }

◆ event() [17/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 154 of file TOPLaserHitSelectorModule.cc.

155 {
156 StoreArray<TOPDigit> digits;
157
158 std::map<short, float> refTimingMap;//map of pixel id and time
159 std::map<short, std::vector<hitInfo_t> >
160 calPulsesMap;//map of pixel id and hit information (timing and pulse charge) for cal. pulse candidetes
161
162 //first, identify cal. pulse
163 for (const auto& digit : digits) {
164
165 short slotId = digit.getModuleID();
166 short pixelId = digit.getPixelID();
167 short globalPixelId = (slotId - 1) * c_NPixelPerModule + pixelId - 1;
168 if (digit.getHitQuality() == TOPDigit::c_CalPulse) {
169 calPulsesMap[globalPixelId].push_back((hitInfo_t) { (float)digit.getTime(), (float)digit.getPulseHeight() });
170 }
171 }// for digit pair
172
173
174 //cal. pulse timing calculation
175 for (const auto& calPulse : calPulsesMap) {
176
177 short globalPixelId = calPulse.first;
178 short globalAsicId = globalPixelId / c_NChannelPerAsic;
179 std::vector<hitInfo_t> vec = calPulse.second;
180 double calPulseTiming = 9999999;
181 unsigned nCalPulseCandidates = vec.size();
182 if (!m_useDoublePulse) { //try to find the first cal. pulse in case that both of double cal. pulses are not required (choose the largest hit)
183 double maxPulseHeight = -1;
184 double maxHeightTiming = 9999999;
185 for (unsigned iVec = 0 ; iVec < nCalPulseCandidates ; iVec++) {
186 if (maxPulseHeight < vec[iVec].m_height) {
187 maxPulseHeight = vec[iVec].m_height;
188 maxHeightTiming = vec[iVec].m_time;
189 }
190 }
191 if (maxPulseHeight > m_calibrationPulseThreshold1)
192 calPulseTiming = maxHeightTiming;
193 } else { //try to identify both of double cal. pulses when specified by option (default)
194 for (unsigned iVec = 0 ; iVec < nCalPulseCandidates ; iVec++) {
195 for (unsigned jVec = 0 ; jVec < nCalPulseCandidates ; jVec++) {
196
197 if (iVec == jVec || vec[iVec].m_time > vec[jVec].m_time) continue;
198 if (vec[iVec].m_height > m_calibrationPulseThreshold1
199 && vec[jVec].m_height > m_calibrationPulseThreshold2
200 && TMath::Abs(vec[jVec].m_time - vec[iVec].m_time - m_calibrationPulseInterval) < m_calibrationPulseIntervalRange) {
201
202 //in case multiple candidates of double cal. pulses are found,
203 //choose a pair with the earliest 1st cal. pulse timing
204 if (refTimingMap.count(globalAsicId) == 0 || refTimingMap[globalAsicId] > vec[iVec].m_time)
205 calPulseTiming = vec[iVec].m_time;
206 }
207 }//for(jVec)
208 }//for(iVec)
209 }//if(m_useDoublePulse)
210
211 if (calPulseTiming < 9999998) { //when cal. pulse(s) are properly identified
212 refTimingMap[globalAsicId] = calPulseTiming;
213 m_nCalPulseHistogram->Fill(globalAsicId);
214 }
215 }//for(pair)
216
217 //calculate hit timing with respect to cal. pulse and fill hit info. histogram
218 for (const auto& digit : digits) {
219 short slotId = digit.getModuleID();
220 short pixelId = digit.getPixelID();
221 short globalPixelId = (slotId - 1) * c_NPixelPerModule + pixelId - 1;
222 short globalAsicId = globalPixelId / c_NChannelPerAsic;
223
224 if (digit.getHitQuality() == TOPDigit::c_Junk
225 || digit.getHitQuality() == TOPDigit::c_CrossTalk) continue;
226
227 float hitTime = digit.getTime() - refTimingMap[globalAsicId];
228 float pulseHeight = digit.getPulseHeight();
229 float Integral = digit.getIntegral();
230 short windowNumberOfHit = (short)(digit.getFirstWindow()) + (short)(digit.getRawTime() / 64);
231 if (m_windowSelect && windowNumberOfHit % 2 != (m_windowSelect - 1)) continue;
232
233 if (m_includeAllChargeShare) {
234 m_TimeHeightHistogramForHitRate[globalPixelId]->Fill(hitTime, pulseHeight);
235 m_TimeIntegralHistogramForFit[globalPixelId]->Fill(hitTime, Integral);
236 m_TimeHeightHistogramForFit[globalPixelId]->Fill(hitTime, pulseHeight);
237 continue;
238 }
239
240 if (!digit.isSecondaryChargeShare()) {
241 m_TimeHeightHistogramForHitRate[globalPixelId]->Fill(hitTime, pulseHeight);
242 if (m_includePrimaryChargeShare) {
243 m_TimeIntegralHistogramForFit[globalPixelId]->Fill(hitTime, Integral);
244 m_TimeHeightHistogramForFit[globalPixelId]->Fill(hitTime, pulseHeight);
245 continue;
246 }
247 }
248
249 if (digit.isSecondaryChargeShare() || digit.isPrimaryChargeShare()) continue;
250 m_TimeIntegralHistogramForFit[globalPixelId]->Fill(hitTime, Integral);
251 m_TimeHeightHistogramForFit[globalPixelId]->Fill(hitTime, pulseHeight);
252 }
253
254 }

◆ event() [18/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 92 of file TOPMCTrackMakerModule.cc.

93 {
94
95 StoreArray<MCParticle> mcParticles;
96 StoreArray<TOPBarHit> barHits;
97
98 StoreArray<Track> tracks;
99 StoreArray<TrackFitResult> fitResults;
100 StoreArray<ExtHit> extHits;
101
102 for (const auto& mcParticle : mcParticles) {
103 if (mcParticle.getStatus(MCParticle::c_PrimaryParticle) == 0) continue;
104 if (mcParticle.getCharge() == 0) continue;
105 const auto* barHit = mcParticle.getRelated<TOPBarHit>();
106 if (!barHit) continue;
107
108 TMatrixDSym cov(6); // infinite precission
109 fitResults.appendNew(mcParticle.getVertex(),
110 mcParticle.getMomentum(),
111 cov,
112 mcParticle.getCharge(),
113 Const::pion,
114 1.0, // pValue
115 BFieldManager::getField(0, 0, 0).Z() / Unit::T,
116 0x38FFFFFFFFFFFFFF, // 56 hits, in all CDC layers
117 0, 56 - 5); // NDF = 56-5
118 auto* track = tracks.appendNew();
119 track->setTrackFitResultIndex(Const::pion, fitResults.getEntries() - 1);
120 track->addRelationTo(&mcParticle);
121
122 const Const::ChargedStable& chargedStable = Const::pion;
123 double pmom = barHit->getMomentum().R();
124 double mass = chargedStable.getMass();
125 double beta = pmom / sqrt(pmom * pmom + mass * mass);
126 double tof = barHit->getLength() / beta / Const::speedOfLight;
127 auto* extHit = extHits.appendNew(tof,
128 chargedStable.getPDGCode(),
129 Const::TOP,
130 barHit->getModuleID(),
131 EXT_ENTER,
132 false,
133 barHit->getPosition(),
134 barHit->getMomentum(),
135 cov);
136 track->addRelationTo(extHit);
137 }
138
139 }

◆ event() [19/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 169 of file TOPModuleT0CalibratorModule.cc.

170 {
171 /* check bunch reconstruction status and run alignment:
172 - if object exists and bunch is found (collision data w/ bunch finder in the path)
173 - if object doesn't exist (cosmic data and other cases w/o bunch finder)
174 */
175
176 if (m_recBunch.isValid()) {
177 if (not m_recBunch->isReconstructed()) return;
178 }
179
180 TOPRecoManager::setDefaultTimeWindow();
181 double timeMin = TOPRecoManager::getMinTime();
182 double timeMax = TOPRecoManager::getMaxTime();
183
184 // running offset must not be subtracted in TOPDigits: issue an error if it is
185
186 if (isRunningOffsetSubtracted()) {
187 B2ERROR("Running offset subtracted in TOPDigits: module T0 will not be correct");
188 }
189
190 // loop over reconstructed tracks, make a selection and accumulate log likelihoods
191
192 for (const auto& track : m_tracks) {
193
194 // track selection
195 TOPTrack trk(track);
196 if (not trk.isValid()) continue;
197
198 if (not m_selector.isSelected(trk)) continue;
199
200 // construct PDF
201 PDFConstructor pdfConstructor(trk, m_selector.getChargedStable(), m_PDFOption);
202 if (not pdfConstructor.isValid()) continue;
203
204 // minimization procedure: accumulate
205 const unsigned module = trk.getModuleID() - 1;
206 if (module >= c_numModules) continue;
207 int sub = gRandom->Integer(2); // generate sub-sample number
208 auto& finder = m_finders[sub][module];
209 const auto& binCenters = finder.getBinCenters();
210 for (unsigned ibin = 0; ibin < binCenters.size(); ibin++) {
211 double t0 = binCenters[ibin];
212 finder.add(ibin, -2 * pdfConstructor.getLogL(t0, m_sigmaSmear).logL);
213 }
214
215 // fill histograms of hits
216 m_numPhotons = 0;
217 for (const auto& digit : m_digits) {
218 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
219 if (digit.getModuleID() != trk.getModuleID()) continue;
220 if (digit.getTime() < timeMin) continue;
221 if (digit.getTime() > timeMax) continue;
222 m_numPhotons++;
223 m_hits1D.Fill(digit.getModuleID());
224 int bs = digit.getBoardstackNumber();
225 m_hits2D.Fill((digit.getModuleID() * 4 + bs - 1.5) / 4.0, digit.getTime());
226 }
227
228 // fill output tree
229 m_moduleID = trk.getModuleID();
230 const auto& localPosition = m_selector.getLocalPosition();
231 m_x = localPosition.X();
232 m_y = localPosition.Y();
233 m_z = localPosition.Z();
234 const auto& localMomentum = m_selector.getLocalMomentum();
235 m_p = localMomentum.R();
236 m_theta = localMomentum.Theta();
237 m_phi = localMomentum.Phi();
238 const auto& pocaPosition = m_selector.getPOCAPosition();
239 m_pocaR = pocaPosition.Rho();
240 m_pocaZ = pocaPosition.Z();
241 m_pocaX = pocaPosition.X();
242 m_pocaY = pocaPosition.Y();
243 m_cmsE = m_selector.getCMSEnergy();
244 m_charge = trk.getCharge();
245 m_PDG = trk.getPDGCode();
246 m_tree->Fill();
247 }
248
249 }

◆ event() [20/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 131 of file TOPNtupleModule.cc.

132 {
133
134 StoreObjPtr<EventMetaData> evtMetaData;
135 StoreArray<Track> tracks;
136 StoreObjPtr<MCInitialParticles> mcInitialParticles;
137 double trueEventT0 = 0;
138 if (mcInitialParticles.isValid()) trueEventT0 = mcInitialParticles->getTime();
139
140 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
141
142 for (const auto& track : tracks) {
143 const auto* trackFit = track.getTrackFitResultWithClosestMass(Const::pion);
144 if (!trackFit) continue;
145 const TOPLikelihood* top = track.getRelated<TOPLikelihood>();
146 if (!top) continue;
147 if (top->getFlag() != 1) continue;
148
149 const ExtHit* extHit = top->getRelated<ExtHit>();
150 const TOPBarHit* barHit = top->getRelated<TOPBarHit>();
151 const MCParticle* mcParticle = track.getRelated<MCParticle>();
152 const MCParticle* mother = 0;
153 if (mcParticle) {
154 mother = mcParticle->getMother();
155 if (not barHit) { // Track MC matching probably done after TOPReconstructor so no relation from TOPLikelihood
156 const auto barHits = mcParticle->getRelationsWith<TOPBarHit>();
157 for (const auto& bHit : barHits) {
158 if (bHit.getModuleID() == extHit->getCopyID()) barHit = &bHit;
159 }
160 }
161 }
162
163 m_top.clear();
164
165 m_top.evt = evtMetaData->getEvent();
166 m_top.run = evtMetaData->getRun();
167
168 ROOT::Math::XYZVector mom = trackFit->getMomentum();
169 m_top.p = mom.R();
170 m_top.cth = cos(mom.Theta());
171 m_top.phi = mom.Phi();
172 m_top.pValue = trackFit->getPValue();
173
174 if (mcParticle) {
175 m_top.PDG = mcParticle->getPDG();
176 if (mother) m_top.motherPDG = mother->getPDG();
177 m_top.primary = mcParticle->getStatus(MCParticle::c_PrimaryParticle);
178 m_top.seen = mcParticle->hasSeenInDetector(Const::TOP);
179 ROOT::Math::XYZVector prodVertex = mcParticle->getProductionVertex();
180 m_top.rhoProd = prodVertex.Rho();
181 m_top.zProd = prodVertex.Z();
182 m_top.phiProd = prodVertex.Phi();
183 ROOT::Math::XYZVector decVertex = mcParticle->getDecayVertex();
184 m_top.rhoDec = decVertex.Rho();
185 m_top.zDec = decVertex.Z();
186 m_top.phiDec = decVertex.Phi();
187 const auto digits = mcParticle->getRelationsWith<TOPDigit>();
188 for (size_t i = 0; i < digits.size(); i++) {
189 double wt = digits.weight(i);
190 if (wt <= 0) continue; // photon not from this MC particle
191 const auto* digit = digits[i];
192 if (digit->getHitQuality() != TOPDigit::c_Good) continue;
193 if (digit->getModuleID() != top->getModuleID()) continue;
194 if (digit->getTime() < TOPRecoManager::getMinTime() or digit->getTime() > TOPRecoManager::getMaxTime()) continue;
195 m_top.yieldMC++;
196 }
197 }
198
199 m_top.numPhot = top->getNphot();
200 m_top.numBkg = top->getEstBkg();
201 m_top.moduleID = top->getModuleID();
202
203 m_top.phot.e = top->getEstPhot(Const::electron);
204 m_top.phot.mu = top->getEstPhot(Const::muon);
205 m_top.phot.pi = top->getEstPhot(Const::pion);
206 m_top.phot.K = top->getEstPhot(Const::kaon);
207 m_top.phot.p = top->getEstPhot(Const::proton);
208 m_top.phot.d = top->getEstPhot(Const::deuteron);
209
210 m_top.yield.e = top->getEffectiveSignalYield(Const::electron);
211 m_top.yield.mu = top->getEffectiveSignalYield(Const::muon);
212 m_top.yield.pi = top->getEffectiveSignalYield(Const::pion);
213 m_top.yield.K = top->getEffectiveSignalYield(Const::kaon);
214 m_top.yield.p = top->getEffectiveSignalYield(Const::proton);
215 m_top.yield.d = top->getEffectiveSignalYield(Const::deuteron);
216
217 m_top.logL.e = top->getLogL(Const::electron);
218 m_top.logL.mu = top->getLogL(Const::muon);
219 m_top.logL.pi = top->getLogL(Const::pion);
220 m_top.logL.K = top->getLogL(Const::kaon);
221 m_top.logL.p = top->getLogL(Const::proton);
222 m_top.logL.d = top->getLogL(Const::deuteron);
223
224 if (extHit) {
225 int moduleID = extHit->getCopyID();
226 auto position = static_cast<ROOT::Math::XYZPoint>(extHit->getPosition());
227 auto momentum = extHit->getMomentum();
228 if (geo->isModuleIDValid(moduleID)) {
229 const auto& module = geo->getModule(moduleID);
230 position = module.pointToLocal(position);
231 momentum = module.momentumToLocal(momentum);
232 }
233 m_top.extHit.moduleID = moduleID;
234 m_top.extHit.PDG = extHit->getPdgCode();
235 m_top.extHit.x = position.X();
236 m_top.extHit.y = position.Y();
237 m_top.extHit.z = position.Z();
238 m_top.extHit.p = momentum.R();
239 m_top.extHit.theta = momentum.Theta();
240 m_top.extHit.phi = momentum.Phi();
241 m_top.extHit.time = extHit->getTOF();
242 }
243
244 if (barHit) {
245 int moduleID = barHit->getModuleID();
246 auto position = barHit->getPosition();
247 auto momentum = barHit->getMomentum();
248 if (geo->isModuleIDValid(moduleID)) {
249 const auto& module = geo->getModule(moduleID);
250 position = module.pointToLocal(position);
251 momentum = module.momentumToLocal(momentum);
252 }
253 m_top.barHit.moduleID = moduleID;
254 m_top.barHit.PDG = barHit->getPDG();
255 m_top.barHit.x = position.X();
256 m_top.barHit.y = position.Y();
257 m_top.barHit.z = position.Z();
258 m_top.barHit.p = momentum.R();
259 m_top.barHit.theta = momentum.Theta();
260 m_top.barHit.phi = momentum.Phi();
261 m_top.barHit.time = barHit->getTime() - trueEventT0;
262 }
263
264 m_tree->Fill();
265 }
266
267 }
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
Definition Particle.h:580

◆ event() [21/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 103 of file TOPPackerModule.cc.

104 {
105
106 switch (m_dataType) {
107 case TOP::RawDataType::c_Type0Ver16:
108 packType0Ver16();
109 break;
110 case TOP::RawDataType::c_ProductionDebug01:
111 packProductionDebug();
112 break;
113 case TOP::RawDataType::c_Draft:
114 packProductionDraft();
115 break;
116 default:
117 B2ERROR("TOPPacker: data format unknown or not implemented");
118 }
119
120 }

◆ event() [22/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 118 of file TOPPDFCheckerModule.cc.

119 {
120 TOPRecoManager::setTimeWindow(m_minTime, m_maxTime);
121 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
122
123 // loop over reconstructed tracks, call reconstruction and fill histograms
124
125 int numTrk = 0;
126 for (const auto& track : m_tracks) {
127 TOPTrack trk(track);
128 if (not trk.isValid()) continue;
129 if (not trk.getMCParticle()) continue;
130 if (not trk.getBarHit()) continue;
131
132 auto chargedStable = Const::chargedStableSet.find(abs(trk.getPDGCode()));
133 if (chargedStable == Const::invalidParticle) continue;
134
135 PDFConstructor pdfConstructor(trk, chargedStable, PDFConstructor::c_Fine);
136 if (not pdfConstructor.isValid()) continue;
137 numTrk++;
138
139 // average values - to print in terminate()
140 const auto& module = geo->getModule(trk.getModuleID());
141 m_avrgMomentum += module.momentumToLocal(trk.getExtHit()->getMomentum());
142 m_avrgPosition += static_cast<XYZVector>(module.pointToLocal(static_cast<XYZPoint>(trk.getExtHit()->getPosition())));
143 m_numTracks++;
144 m_slotIDs.emplace(trk.getModuleID());
145 m_PDGCodes.emplace(trk.getPDGCode());
146
147 // histogram photons in a slot crossed by the track
148 for (const auto& digit : m_digits) {
149 if (digit.getModuleID() == trk.getModuleID() and digit.getTime() < m_maxTime) {
150 if (not isFromThisParticle(digit, trk.getMCParticle())) continue;
151 m_hits->Fill(digit.getPixelID(), digit.getTime());
152 m_hitsCol->Fill(digit.getPixelCol(), digit.getTime());
153 }
154 }
155
156 // histogram PDF using MC approach
157 for (const auto& signalPDF : pdfConstructor.getSignalPDF()) {
158 int pixelID = signalPDF.getPixelID();
159 for (const auto& peak : signalPDF.getPDFPeaks()) {
160 double numPhot = pdfConstructor.getExpectedSignalPhotons() * peak.nph;
161 double sigma = sqrt(peak.wid);
162 for (ULong64_t i = 0; i < gRandom->Poisson(numPhot); i++) {
163 double time = gRandom->Gaus(peak.t0, sigma);
164 m_pdf->Fill(pixelID, time);
165 int pixelCol = (pixelID - 1) % 64 + 1;
166 m_pdfCol->Fill(pixelCol, time);
167 }
168 }
169 }
170
171 }
172
173 if (numTrk == 0) {
174 B2WARNING("No track hitting the bars");
175 } else if (numTrk > 1) {
176 B2WARNING("More than one track hits the bars");
177 }
178
179 }

◆ event() [23/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 121 of file TOPPDFDebuggerModule.cc.

122 {
123 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
124 TOPRecoManager::setTimeWindow(m_minTime, m_maxTime);
125
126 // reconstruct track-by-track and store the results
127
128 for (const auto& track : m_tracks) {
129 TOPTrack trk(track);
130 if (not trk.isValid()) continue;
131
132 // add this vector of vector of triplets to the TOPPDFCollection
133 TOPPDFCollection* topPDFColl = m_pdfCollection.appendNew();
134 const auto& module = geo->getModule(trk.getModuleID());
135 topPDFColl->setLocalPositionMomentum(module.pointToLocal(static_cast<XYZPoint>(trk.getExtHit()->getPosition())),
136 module.momentumToLocal(trk.getExtHit()->getMomentum()),
137 trk.getModuleID());
138
139 TOPPixelLikelihood* topPLkhs = m_pixelData.appendNew();
140 topPLkhs->setModuleID(trk.getModuleID());
141
142 for (const auto& chargedStable : m_chargedStables) {
143 const PDFConstructor pdfConstructor(trk, chargedStable, m_PDFOption, PDFConstructor::c_Full);
144 if (not pdfConstructor.isValid()) {
145 B2ERROR("PDFConstructor found not valid - bug in reconstruction code?"
146 << LogVar("PDG", chargedStable.getPDGCode()));
147 continue;
148 }
149
150 // associate PDF peaks with photons using S-plot technique
151 associatePDFPeaks(pdfConstructor);
152
153 // collection of gaussian_t's for each pixel
154 TOPPDFCollection::modulePDF_t channelPDFCollection;
155
156 // store PDF peaks in the collection
157 for (const auto& signalPDF : pdfConstructor.getSignalPDF()) {
158 int pixelID = signalPDF.getPixelID();
159 for (const auto& peak : signalPDF.getPDFPeaks()) {
160 float position = peak.t0;
161 float width = sqrt(peak.wid);
162 float numPhotons = pdfConstructor.getExpectedSignalPhotons() * peak.nph;
163 auto tp = TOPPDFCollection::Gaussian(position, width, numPhotons);
164 channelPDFCollection.at(pixelID - 1).push_back(tp);
165 } // end loop over peaks in the pdf for this pixel
166 } // end loop over pixels
167
168 topPDFColl->addHypothesisPDF(channelPDFCollection, chargedStable.getPDGCode());
169
170 // Initialize logL and sfot pixel arrays
171 TOPPixelLikelihood::PixelArray_t pixLogLs, pixSigPhots;
172 pixLogLs.fill(0);
173 pixSigPhots.fill(0);
174
175 const auto& pixelLogLs = pdfConstructor.getPixelLogLs(0);
176 for (size_t i = 0; i < std::min(pixelLogLs.size(), pixLogLs.size()); i++) {
177 pixLogLs[i] = pixelLogLs[i].logL;
178 pixSigPhots[i] = pixelLogLs[i].expPhotons;
179 }
180
181 topPLkhs->addHypothesisLikelihoods(pixLogLs, chargedStable.getPDGCode());
182 topPLkhs->addHypothesisSignalPhotons(pixSigPhots, chargedStable.getPDGCode());
183 }
184 track.addRelationTo(topPDFColl);
185 track.addRelationTo(topPLkhs);
186
187 } // end loop over tracks
188
189 }

◆ event() [24/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 195 of file TOPRawDigitConverterModule.cc.

196 {
197
198 // get mappers
199
200 const auto& feMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
201 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
202 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
203
204 // clear TOPDigits
205
206 m_digits.clear();
207
208 // set storage windows in RawDigits if not already done in unpacker
209
210 for (auto& rawDigit : m_rawDigits) {
211 const auto* waveform = rawDigit.getRelated<TOPRawWaveform>();
212 if (waveform and rawDigit.getStorageWindows().empty()) {
213 rawDigit.setStorageWindows(waveform->getStorageWindows());
214 }
215 }
216
217 // set asic masks (asics and whole boardstacks masked in firmware for this event)
218
219 m_asicMask.create();
220 if (m_eventDebugs.getEntries() > 0) {
221 std::vector<unsigned short> masks(64, 0xFFFF);
222 for (const auto& eventDebug : m_eventDebugs) {
223 auto scrodID = eventDebug.getScrodID();
224 const auto* feemap = feMapper.getMap(scrodID);
225 if (not feemap) {
226 B2WARNING("TOPRawDigitConverter: No front-end map available."
227 << LogVar("scrodID", scrodID));
228 continue;
229 }
230 auto moduleID = feemap->getModuleID();
231 auto boardstack = feemap->getBoardstackNumber();
232 unsigned bs = (moduleID - 1) * 4 + boardstack;
233 if (bs < 64) {
234 masks[bs] = eventDebug.getAsicMask();
235 } else {
236 B2ERROR("TOPRawDigitConverter: Invalid global boardstack number."
237 << LogVar("bs", bs));
238 }
239 }
240 m_asicMask->set(masks);
241 }
242
243 // convert to TOPDigits
244
245 for (const auto& rawDigit : m_rawDigits) {
246
247 if (rawDigit.getErrorFlags() != 0) continue;
248
249 // determine moduleID, pixedID and channel
250
251 auto scrodID = rawDigit.getScrodID();
252 const auto* feemap = feMapper.getMap(scrodID);
253 if (not feemap) {
254 B2WARNING("TOPRawDigitConverter: No front-end map available."
255 << LogVar("scrodID", scrodID));
256 continue;
257 }
258 auto moduleID = feemap->getModuleID();
259 auto boardstack = feemap->getBoardstackNumber();
260 auto channel = chMapper.getChannel(boardstack,
261 rawDigit.getCarrierNumber(),
262 rawDigit.getASICNumber(),
263 rawDigit.getASICChannel());
264 auto pixelID = chMapper.getPixelID(channel);
265
266 // get raw times
267
268 double rawTimeLeading = rawDigit.getCFDLeadingTime(); // time in [samples]
269 double rawTimeFalling = rawDigit.getCFDFallingTime(); // time in [samples]
270
271 // get ASIC window
272
273 int window = rawDigit.getASICWindow();
274
275 // timing alignment: set time origin according to data type
276
277 double timeOffset = 0;
278 int storageDepth = m_storageDepth;
279 if (rawDigit.getDataType() == TOPRawDigit::c_Interim) {
280
281 // correct raw times for possible window discontinuity
282 rawTimeLeading = rawDigit.correctTime(rawTimeLeading, m_storageDepth);
283 rawTimeFalling = rawDigit.correctTime(rawTimeFalling, m_storageDepth);
284
285 // set window number: number of look back windows back from the last write address
286 int lastWriteAddr = rawDigit.getLastWriteAddr();
287 int nback = lastWriteAddr - window;
288 if (nback < 0) nback += m_storageDepth;
289 int lookBackWindows = m_feSetting->getLookbackWindows();
290 if (m_lookBackWindows > 0) lookBackWindows = m_lookBackWindows;
291 int nwin = lookBackWindows - nback;
292 window -= nwin;
293 if (window < 0) window += m_storageDepth;
294 if (window >= (int) m_storageDepth) window -= m_storageDepth;
295
296 // add samples to raw time to account for the new window number
297 rawTimeLeading += nwin * TOPRawDigit::c_WindowSize;
298 rawTimeFalling += nwin * TOPRawDigit::c_WindowSize;
299 } else if (rawDigit.getDataType() == TOPRawDigit::c_ProductionDebug) {
300
301 // take revo9 counter and calculate corresponding SST count and its fraction
302 int revo9cnt = rawDigit.getRevo9Counter();
303 int SSTcnt = revo9cnt / 6;
304 double SSTfrac = (revo9cnt % 6) / 6.0;
305 double offset = m_feSetting->getOffset() / 24.0;
306 timeOffset = (SSTfrac + offset) * m_syncTimeBase; // in [ns], to be subtracted
307
308 // find reference window
309 int refWindow = SSTcnt * 2; // seems to be the same as lastWriteAddr
310 const auto& writeDepths = m_feSetting->getWriteDepths();
311 if (writeDepths.empty()) {
312 B2ERROR("TOPRawDigitConverter: vector of write depths is empty. Return!");
313 return;
314 }
315 int lastDepth = writeDepths.back();
316 unsigned phase = 0;
317 for (auto depth : writeDepths) {
318 SSTcnt -= depth;
319 if (SSTcnt < 0) break;
320 phase++;
321 refWindow = SSTcnt * 2;
322 lastDepth = depth;
323 }
324 if (m_setPhase) const_cast<TOPRawDigit&>(rawDigit).setPhase(phase);
325 storageDepth = lastDepth * 2;
326
327 if (window >= storageDepth) {
328 B2WARNING("TOPRawDigitConverter: window number greater than storage depth."
329 << LogVar("window number", window)
330 << LogVar("storage depth", storageDepth)
331 << LogVar("refWindow", refWindow)
332 << LogVar("phase", phase));
333 continue;
334 }
335
336 // set window number: number of look back windows back from the reference window
337 int deltaWindow = window - refWindow;
338 if (deltaWindow > 0) deltaWindow -= storageDepth;
339 int lookBackWindows = m_feSetting->getLookbackWindows();
340 if (m_lookBackWindows > 0) lookBackWindows = m_lookBackWindows;
341 lookBackWindows -= m_feSetting->getExtraWindows();
342
343 int nwin = lookBackWindows + deltaWindow;
344 int startWindow = refWindow - lookBackWindows;
345 if (startWindow < 0) startWindow += storageDepth;
346 window = startWindow;
347
348 // add samples to raw time to account for the new window number
349 rawTimeLeading += nwin * TOPRawDigit::c_WindowSize;
350 rawTimeFalling += nwin * TOPRawDigit::c_WindowSize;
351 }
352
353 // convert raw time to time using equidistant or calibrated time base
354
355 unsigned short statusBits = 0;
356 const auto* sampleTimes = &m_sampleTimes; // equidistant sample times
357 if (m_useSampleTimeCalibration) {
358 sampleTimes = m_timebase->getSampleTimes(scrodID, channel % 128);
359 if (sampleTimes->isCalibrated()) {
360 statusBits |= TOPDigit::c_TimeBaseCalibrated;
361 }
362 }
363 // time and width in [ns]
364 double time = sampleTimes->getTime(window, rawTimeLeading) - timeOffset;
365 double width = sampleTimes->getDeltaTime(window, rawTimeFalling, rawTimeLeading);
366
367 // default time uncertainty
368 double timeError = geo->getNominalTDC().getTimeJitter();
369
370 if (rawDigit.getDataType() == TOPRawDigit::c_MC) {
371 // MC with simplified digitization
372 time -= geo->getNominalTDC().getOffset();
373 statusBits |= TOPDigit::c_OffsetSubtracted;
374 } else {
375 // data and MC with full waveform digitization
376 if (m_pedestalRMS > 0) {
377 double rmsNoise = m_pedestalRMS;
378 if (m_noises->isCalibrated(moduleID, channel)) {
379 rmsNoise = m_noises->getNoise(moduleID, channel);
380 }
381 double rawErr = rawDigit.getCFDLeadingTimeError(rmsNoise); // in [samples]
382 int sample = static_cast<int>(rawTimeLeading);
383 if (rawTimeLeading < 0) sample--;
384 timeError = rawErr * sampleTimes->getTimeBin(window, sample); // [ns]
385 }
386
387 auto pulseHeight = rawDigit.getValuePeak();
388 double timeErrorSq = timeError * timeError;
389 if (m_timeWalk.isValid()) timeErrorSq += m_timeWalk->getSigmaSq(pulseHeight);
390
391 if (m_useTimeWalkCalibration and m_timeWalk.isValid()) {
392 if (m_timeWalk->isCalibrated()) {
393 time -= m_timeWalk->getTimeWalk(pulseHeight);
394 }
395 }
396 if (m_useChannelT0Calibration) {
397 const auto& cal = m_channelT0;
398 if (cal->isCalibrated(moduleID, channel)) {
399 time -= cal->getT0(moduleID, channel);
400 double err = cal->getT0Error(moduleID, channel);
401 timeErrorSq += err * err;
402 statusBits |= TOPDigit::c_ChannelT0Calibrated;
403 }
404 }
405 if (m_useAsicShiftCalibration) {
406 auto asic = channel / 8;
407 if (m_asicShift->isCalibrated(moduleID, asic)) {
408 time -= m_asicShift->getT0(moduleID, asic);
409 }
410 }
411 if (m_useModuleT0Calibration) {
412 const auto& cal = m_moduleT0;
413 if (cal->isCalibrated(moduleID)) {
414 time -= cal->getT0(moduleID);
415 double err = cal->getT0Error(moduleID);
416 timeErrorSq += err * err;
417 statusBits |= TOPDigit::c_ModuleT0Calibrated;
418 }
419 }
420 if (m_useCommonT0Calibration) {
421 const auto& cal = m_commonT0;
422 if (cal->isCalibrated()) {
423 time -= cal->getT0();
424 double err = cal->getT0Error();
425 timeErrorSq += err * err;
426 statusBits |= TOPDigit::c_CommonT0Calibrated;
427 }
428 }
429 timeError = sqrt(timeErrorSq);
430 }
431
432 // append new TOPDigit and set it
433
434 auto* digit = m_digits.appendNew(moduleID, pixelID, rawTimeLeading);
435 digit->setTime(time);
436 digit->setTimeError(timeError);
437 digit->setPulseHeight(rawDigit.getValuePeak());
438 digit->setIntegral(rawDigit.getIntegral());
439 digit->setPulseWidth(width);
440 digit->setChannel(channel);
441 digit->setFirstWindow(window);
442 digit->setStatus(statusBits);
443 if (m_addRelations) digit->addRelationTo(&rawDigit);
444
445 if (not rawDigit.isFEValid() or rawDigit.isPedestalJump())
446 digit->setHitQuality(TOPDigit::c_Junk);
447 if (rawDigit.isAtWindowDiscontinuity(storageDepth))
448 digit->setHitQuality(TOPDigit::c_Junk);
449 if (digit->getPulseWidth() < m_minPulseWidth or
450 digit->getPulseWidth() > m_maxPulseWidth or
451 digit->getPulseWidth() * digit->getPulseHeight() < m_minWidthXheight)
452 digit->setHitQuality(TOPDigit::c_Junk);
453 }
454
455 // if calibration channel given, select and flag cal pulses
456
457 unsigned calibrationChannel = m_calibrationChannel;
458 if (calibrationChannel < 8) {
459 for (auto& digit : m_digits) {
460 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
461 if (digit.getASICChannel() != calibrationChannel) continue;
462 if (digit.getPulseHeight() < m_calpulseHeightMin) continue;
463 if (digit.getPulseHeight() > m_calpulseHeightMax) continue;
464 if (digit.getPulseWidth() < m_calpulseWidthMin) continue;
465 if (digit.getPulseWidth() > m_calpulseWidthMax) continue;
466 if (m_calpulseTimeMax > m_calpulseTimeMin) {
467 if (digit.getTime() < m_calpulseTimeMin) continue;
468 if (digit.getTime() > m_calpulseTimeMax) continue;
469 }
470 digit.setHitQuality(TOPDigit::c_CalPulse);
471 }
472 }
473
474 }

◆ event() [25/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 91 of file TOPReconstructorModule.cc.

92 {
93 // clear output collections
94
95 m_likelihoods.clear();
96 m_topPulls.clear();
97
98 // check bunch reconstruction status and do the reconstruction:
99 // - if object exists and bunch is found (collision data w/ bunch finder in the path)
100 // - if object doesn't exist (cosmic data and other cases w/o bunch finder in the path)
101
102 if (m_recBunch.isValid()) {
103 if (not m_recBunch->isReconstructed()) return;
104 }
105
106 // set time window in which photon hits are accepted for likelihood determination
107
108 TOPRecoManager::setTimeWindow(m_minTime, m_maxTime);
109
110 // sort tracks by module ID
111
112 std::unordered_multimap<int, const TOPTrack*> topTracks; // tracks sorted by top modules
113 for (const auto& track : m_tracks) {
114 auto* trk = new TOPTrack(track, m_topDigitCollectionName);
115 if (trk->isValid() and trk->getTransverseMomentum() > m_pTCut) {
116 topTracks.emplace(trk->getModuleID(), trk);
117 } else {
118 delete trk;
119 }
120 }
121
122 // reconstruct module-by-module
123
124 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
125 for (unsigned moduleID = 1; moduleID <= geo->getNumModules(); moduleID++) {
126
127 // make a vector of PDF collections for a given TOP module
128
129 std::vector<PDFCollection> pdfCollections;
130 const auto& range = topTracks.equal_range(moduleID);
131 for (auto it = range.first; it != range.second; ++it) {
132 const auto* trk = it->second;
133 PDFCollection collection(*trk, m_deltaRayModeling);
134 if (collection.isValid) pdfCollections.push_back(collection);
135 }
136 if (pdfCollections.empty()) continue;
137
138 // add most probable PDF's of other tracks if present
139
140 if (pdfCollections.size() > 1) {
141 std::vector<int> lastMostProbables;
142 for (int iter = 0; iter < 10; iter++) {
143 std::vector<int> mostProbables;
144 for (auto& collection : pdfCollections) { // set most probable PDF
145 collection.setMostProbable();
146 mostProbables.push_back(collection.mostProbable->getHypothesis().getPDGCode());
147 }
148 if (mostProbables == lastMostProbables) break;
149 else lastMostProbables = mostProbables;
150
151 for (auto& collection : pdfCollections) collection.clearPDFOther(); // reset
152 for (auto& collection : pdfCollections) { // append
153 for (auto& other : pdfCollections) {
154 if (&other == &collection) continue;
155 collection.appendPDFOther(other.mostProbable);
156 }
157 }
158 } // loop: iter
159 }
160
161 // determine and save log likelihoods
162
163 for (auto& collection : pdfCollections) {
164 auto* topLL = m_likelihoods.appendNew();
165 const auto* trk = collection.topTrack;
166 const auto* track = trk->getTrack();
167 track->addRelationTo(topLL);
168 topLL->addRelationTo(trk->getExtHit());
169 topLL->addRelationTo(trk->getBarHit());
170
171 int pdgCode = (m_PDGCode != 0) ? m_PDGCode : trk->getPDGCode(); // PDG code used for providing pulls
172 std::set<int> nfotSet; // to x-check if the number of photons is the same for all particle hypotheses
173 std::set<double> nbkgSet; // to x-check if the background is the same for all particle hypotheses
174
175 for (const auto* pdfConstructor : collection.PDFs) {
176 const auto& chargedStable = pdfConstructor->getHypothesis();
177 auto LL = pdfConstructor->getLogL();
178 auto expBkgPhotons = pdfConstructor->getExpectedBkgPhotons();
179 topLL->set(chargedStable, LL.numPhotons, LL.logL, LL.expPhotons, expBkgPhotons, LL.effectiveSignalYield);
180
181 nfotSet.insert(LL.numPhotons);
182 nbkgSet.insert(expBkgPhotons);
183
184 if (abs(chargedStable.getPDGCode()) == abs(pdgCode)) {
185 for (const auto& p : pdfConstructor->getPulls()) {
186 auto* pull = m_topPulls.appendNew(p.pixelID, p.time, p.peakT0 + p.ttsT0, p.sigma, p.phiCer, p.wt);
187 track->addRelationTo(pull);
188 }
189 }
190 }
191 topLL->setFlag(1);
192 topLL->setModuleID(trk->getModuleID());
193 const auto& emi = trk->getEmissionPoint();
194 topLL->setXZ(emi.position.X(), emi.position.Z());
195
196 if (nfotSet.size() > 1) B2ERROR("Bug in TOP::PDFConstructor: number of photons differs between particle hypotheses");
197 if (nbkgSet.size() > 1) B2ERROR("Bug in TOP::PDFConstructor: estimated background differs between particle hypotheses");
198 }
199
200 for (auto& collection : pdfCollections) collection.deletePDFs();
201
202 } // loop: moduleID
203
204 for (auto& x : topTracks) delete x.second;
205
206 }

◆ event() [26/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 347 of file TOPTBCComparatorModule.cc.

348 {
349 return;
350 }

◆ event() [27/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 147 of file TOPTimeBaseCalibratorModule.cc.

148 {
149 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
150 double sampleWidth = geo->getNominalTDC().getSampleWidth();
151
152 vector<Hit> hits[c_NumChannels];
153
154 for (const auto& digit : m_digits) {
155 if (digit.getModuleID() != m_moduleID) continue;
156 if (digit.getHitQuality() != TOPDigit::c_Junk) {
157 m_goodHits.Fill(digit.getPulseWidth(), digit.getPulseHeight());
158 }
159 if (digit.getHitQuality() != TOPDigit::c_CalPulse) continue;
160 double rawTime = digit.getRawTime();
161 double errScaleFactor = 1;
162 if (m_useFallingEdge) {
163 const auto* rawDigit = digit.getRelated<TOPRawDigit>();
164 if (!rawDigit) {
165 B2ERROR("No relation to TOPRawDigit - can't determine falling edge time error");
166 continue;
167 }
168 // rawTime may include corrections due to window number discontinuity,
169 // therefore one must add the width and not just use getCFDFallingTime()
170 rawTime += rawDigit->getFWHM();
171 errScaleFactor = rawDigit->getCFDFallingTimeError(1.0) / rawDigit->getCFDLeadingTimeError(1.0);
172 }
173 double t = rawTime + digit.getFirstWindow() * c_WindowSize;
174 if (t < 0) {
175 B2ERROR("Got negative sample number - digit ignored");
176 continue;
177 }
178 double et = digit.getTimeError() / sampleWidth * errScaleFactor;
179 if (et <= 0) {
180 B2ERROR("Time error is not given - digit ignored");
181 continue;
182 }
183 unsigned channel = digit.getChannel();
184 if (channel < c_NumChannels) {
185 hits[channel].push_back(Hit(t, et, digit.getPulseHeight(), digit.getPulseWidth()));
186 }
187 }
188
189 for (unsigned channel = 0; channel < c_NumChannels; channel++) {
190 const auto& channelHits = hits[channel];
191 if (channelHits.size() == 2) {
192 double t0 = channelHits[0].time;
193 double t1 = channelHits[1].time;
194 auto diff = fabs(t0 - t1); // since not sorted yet
195 if (diff < m_minTimeDiff) continue;
196 if (diff > m_maxTimeDiff) continue;
197 double sig0 = channelHits[0].timeErr;
198 double sig1 = channelHits[1].timeErr;
199 double sigma = sqrt(sig0 * sig0 + sig1 * sig1);
200 m_ntuples[channel].push_back(TwoTimes(t0, t1, sigma));
201 if (t0 < t1) { // check, since not sorted yet
202 m_calPulseFirst.Fill(channelHits[0].pulseWidth, channelHits[0].pulseHeight);
203 m_calPulseSecond.Fill(channelHits[1].pulseWidth, channelHits[1].pulseHeight);
204 } else {
205 m_calPulseSecond.Fill(channelHits[0].pulseWidth, channelHits[0].pulseHeight);
206 m_calPulseFirst.Fill(channelHits[1].pulseWidth, channelHits[1].pulseHeight);
207 }
208 } else if (channelHits.size() > 2) {
209 B2WARNING("More than two cal pulses per channel found - ignored");
210 }
211 }
212
213 }

◆ event() [28/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 143 of file TOPTimeRecalibratorModule.cc.

144 {
145 int revo9cnt = m_recBunch->getRevo9Counter();
146 double SSTfrac = (revo9cnt % 6) / 6.0;
147 double offset = m_feSetting->getOffset() / 24.0;
148 double timeOffset = (SSTfrac + offset) * m_syncTimeBase; // in [ns], to be subtracted
149 const auto& feMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
150 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
151
152 for (auto& digit : m_digits) {
153
154 // save MC offset status
155 bool offsetStatus = digit.hasStatus(TOPDigit::c_OffsetSubtracted);
156
157 // reset status bits
158 unsigned short statusBits = 0;
159 digit.setStatus(statusBits);
160
161 // get what's needed from a digit
162 double rawTimeLeading = digit.getRawTime();
163 auto window = digit.getFirstWindow();
164 auto moduleID = digit.getModuleID();
165 auto channel = digit.getChannel();
166
167 // convert raw time to time using equidistant or calibrated time base
168 const auto* sampleTimes = &m_sampleTimes; // equidistant sample times
169 if (m_useSampleTimeCalibration) {
170 auto bs = channel / 128;
171 const auto* feemap = feMapper.getMap(moduleID, bs);
172 if (not feemap) {
173 B2ERROR("No front-end map available."
174 << LogVar("slot", moduleID)
175 << LogVar("boardstack", bs));
176 continue;
177 }
178 auto scrodID = feemap->getScrodID();
179 sampleTimes = m_timebase->getSampleTimes(scrodID, channel % 128);
180 if (sampleTimes->isCalibrated()) {
181 statusBits |= TOPDigit::c_TimeBaseCalibrated;
182 }
183 }
184 double time = sampleTimes->getTime(window, rawTimeLeading) - timeOffset;
185
186 // apply other calibrations
187 if (m_useTimeWalkCalibration and m_timeWalk.isValid()) {
188 if (m_timeWalk->isCalibrated()) {
189 time -= m_timeWalk->getTimeWalk(digit.getPulseHeight());
190 }
191 }
192 if (m_useChannelT0Calibration) {
193 const auto& cal = m_channelT0;
194 if (cal->isCalibrated(moduleID, channel)) {
195 time -= cal->getT0(moduleID, channel);
196 statusBits |= TOPDigit::c_ChannelT0Calibrated;
197 }
198 }
199 if (m_useAsicShiftCalibration) {
200 auto asic = channel / 8;
201 if (m_asicShift->isCalibrated(moduleID, asic)) {
202 time -= m_asicShift->getT0(moduleID, asic);
203 }
204 }
205 if (m_useModuleT0Calibration) {
206 const auto& cal = m_moduleT0;
207 if (cal->isCalibrated(moduleID)) {
208 time -= cal->getT0(moduleID);
209 statusBits |= TOPDigit::c_ModuleT0Calibrated;
210 }
211 }
212 if (m_useCommonT0Calibration) {
213 const auto& cal = m_commonT0;
214 if (cal->isCalibrated()) {
215 time -= cal->getT0();
216 statusBits |= TOPDigit::c_CommonT0Calibrated;
217 }
218 }
219
220 // subtract bunch time
221 if (m_subtractBunchTime and m_recBunch->isReconstructed()) {
222 time -= m_recBunch->getTime();
223 statusBits |= TOPDigit::c_EventT0Subtracted;
224 }
225
226 // subtract offset used in MC if status bit was set in this digit
227 if (offsetStatus) {
228 time -= geo->getNominalTDC().getOffset();
229 statusBits |= TOPDigit::c_OffsetSubtracted;
230 }
231
232 // set re-calibrated time and status bits
233 digit.setTime(time);
234 digit.setStatus(statusBits);
235 }
236
237 }

◆ event() [29/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 90 of file TOPTriggerDigitizerModule.cc.

91 {
92
93 // input: simulated waveforms
94 StoreArray<TOPRawWaveform> waveforms;
95
96 // output: time stamps for trigger input
97 StoreArray<TOPTriggerDigit> digits;
98 StoreObjPtr<TOPTriggerMCInfo> mcInfo;
99 mcInfo.create();
100
101 if (waveforms.getEntries() == 0) {
102 B2ERROR("No waveforms available for digitization");
103 return;
104 }
105 unsigned revo9count = waveforms[0]->getRevo9Counter();
106 int offsetSamples = waveforms[0]->getOffsetWindows() * TOPRawWaveform::c_WindowSize +
107 (revo9count % 6) * TOPRawWaveform::c_WindowSize / 3;
108
109 int bunchTimeStamp = int((revo9count + gRandom->Rndm()) * static_cast<double>(c_SamplingCycle) / 3.0);
110 mcInfo->setBunchTimeStamp(bunchTimeStamp);
111
112 int offset = bunchTimeStamp - offsetSamples / c_SamplingCycle;
113
114 for (const auto& waveform : waveforms) {
115 const auto& data = waveform.getWaveform();
116 int currentThr = m_threshold;
117 bool lastState = false;
118 int gate = 0;
119 TOPTriggerDigit* digit = 0;
120 for (int i = 0; i < (int) data.size(); i++) {
121 gate--;
122 if (data[i] > currentThr) {
123 currentThr = m_threshold - m_hysteresis;
124 if (!lastState) gate = m_gateWidth;
125 lastState = true;
126 } else {
127 currentThr = m_threshold;
128 lastState = false;
129 }
130 if (i % c_SamplingCycle == m_samplingPhase and gate > 0) {
131 if (i / c_SamplingCycle == 0) continue; // first time stamp is not correct
132 if (!digit) {
133 digit = digits.appendNew(waveform.getModuleID(),
134 waveform.getChannel(),
135 waveform.getScrodID());
136 digit->addRelationTo(&waveform);
137 }
138 int timeStamp = i / c_SamplingCycle + offset;
139 while (timeStamp < 0) {timeStamp += c_Frame9Period;};
140 timeStamp = timeStamp % c_Frame9Period;
141 digit->appendTimeStamp(timeStamp);
142 }
143 }
144 }
145
146 }

◆ event() [30/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 118 of file TOPUnpackerModule.cc.

119 {
120 if (m_resetEventCount) {
121 m_numErrors = m_errorCount;
122 m_errorCount = 0;
123 m_eventCount = 0;
124 m_resetEventCount = false;
125 }
126 m_eventCount++;
127
128 // clear output store arrays
129 m_digits.clear();
130 m_rawDigits.clear();
131 m_waveforms.clear();
132 m_productionEventDebugs.clear();
133 m_productionHitDebugs.clear();
134 m_templateFitResults.clear();
135 m_slowData.clear();
136 m_interimFEInfos.clear();
137
138 StoreObjPtr<EventMetaData> evtMetaData;
139 for (auto& raw : m_rawData) {
140 for (int finesse = 0; finesse < raw.GetMaxNumOfCh(0); finesse++) {
141 const int* buffer = raw.GetDetectorBuffer(0, finesse);
142 int bufferSize = raw.GetDetectorNwords(0, finesse);
143 if (bufferSize < 1) continue;
144
145 int err = 0;
146
147 int dataFormat = m_dataFormat;
148 if (dataFormat == 0) { // auto detect data format
149 DataArray array(buffer, bufferSize, m_swapBytes);
150 unsigned word = array.getWord();
151 dataFormat = (word >> 16);
152 bool isKnownDataFormat = false;
153 for (auto& t : TOP::membersRawDataType) {
154 if (static_cast<int>(t) == dataFormat) {
155 isKnownDataFormat = true;
156 break;
157 }
158 }
159
160 if (!isKnownDataFormat) { //dataformat word is not recognised, might be interim format.
161 if (evtMetaData->getExperiment() == 1) { // all exp.1 data was taken with interim format
162 dataFormat = 0x0301;
163 m_swapBytes = true;
164 } else {
165 if (unpackHeadersInterimFEVer01(buffer, bufferSize, true)) { //if buffer unpacks without errors assuming it's interim format
166 B2DEBUG(22, "Assuming interim FW data format");
167 dataFormat = 0x0301; //assume it's interim format
168 m_swapBytes = true;
169 } else {
170 B2WARNING("TOPUnpacker: Could not establish data format.");
171 err = bufferSize;
172 }
173 }
174 }
175 }
176
177 switch (dataFormat) {
178 case static_cast<int>(TOP::RawDataType::c_Type0Ver16):
179 unpackType0Ver16(buffer, bufferSize);
180 break;
181 case static_cast<int>(TOP::RawDataType::c_Type2Ver1):
182 err = unpackInterimFEVer01(buffer, bufferSize, false);
183 break;
184 case static_cast<int>(TOP::RawDataType::c_Type3Ver1):
185 err = unpackInterimFEVer01(buffer, bufferSize, true);
186 break;
187 case static_cast<int>(TOP::RawDataType::c_Draft):
188 unpackProductionDraft(buffer, bufferSize);
189 break;
190 case static_cast<int>(TOP::RawDataType::c_ProductionDebug01):
191 err = unpackProdDebug(buffer, bufferSize, TOP::RawDataType::c_ProductionDebug01, true);
192 break;
193 case static_cast<int>(TOP::RawDataType::c_ProductionDebug02):
194 err = unpackProdDebug(buffer, bufferSize, TOP::RawDataType::c_ProductionDebug02, true);
195 break;
196
197 default:
198 if (printTheError()) {
199 B2ERROR("TOPUnpacker: unknown data format, " << getFrontEndName(raw, finesse)
200 << LogVar("Type", (dataFormat >> 8))
201 << LogVar("Version", (dataFormat & 0xFF)));
202 }
203 return;
204 }
205
206 if (err != 0) {
207 if (printTheError()) {
208 B2ERROR("TOPUnpacker: error in unpacking data from " << getFrontEndName(raw, finesse)
209 << LogVar("words unused", err));
210 }
211 }
212
213 } // finesse loop
214 } // m_rawData loop
215
216 }

◆ event() [31/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 82 of file TOPWaveformFeatureExtractorModule.cc.

83 {
84
85 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
86 const auto& tdc = geo->getNominalTDC();
87 int sampleDivisions = 0x1 << tdc.getSubBits();
88
89 StoreArray<TOPRawDigit> rawDigits(m_inputRawDigitsName);
90 int initSize = rawDigits.getEntries();
91
92 for (int i = 0; i < initSize; i++) {
93 auto& rawDigit = *rawDigits[i];
94 const auto* waveform = rawDigit.getRelated<TOPRawWaveform>();
95 if (!waveform) continue;
96 if (m_setIntegral) {
97 auto integral = waveform->getIntegral(rawDigit.getSampleRise(),
98 rawDigit.getSamplePeak(),
99 rawDigit.getSampleFall());
100 rawDigit.setIntegral(integral);
101 }
102 waveform->featureExtraction(m_threshold, m_hysteresis, m_thresholdCount);
103 const auto& features = waveform->getFeatureExtractionData();
104 int sampleRise = rawDigit.getSampleRise();
105 int sampleFall = rawDigit.getSampleFall() + 1;
106 for (const auto& feature : features) {
107
108 // skip it, if hit already in rawDigits
109 int sRise = feature.sampleRise;
110 if (sRise >= sampleRise and sRise <= sampleFall) continue;
111 int sFall = feature.sampleFall + 1;
112 if (sFall >= sampleRise and sFall <= sampleFall) continue;
113
114 // if not, append it
115 auto* newDigit = rawDigits.appendNew(rawDigit);
116 newDigit->setOfflineFlag();
117 newDigit->setSampleRise(feature.sampleRise);
118 newDigit->setDeltaSamplePeak(feature.samplePeak - feature.sampleRise);
119 newDigit->setDeltaSampleFall(feature.sampleFall - feature.sampleRise);
120 newDigit->setValueRise0(feature.vRise0);
121 newDigit->setValueRise1(feature.vRise1);
122 newDigit->setValueFall0(feature.vFall0);
123 newDigit->setValueFall1(feature.vFall1);
124 newDigit->setValuePeak(feature.vPeak);
125 newDigit->setIntegral(feature.integral);
126 double rawTime = newDigit->getCFDLeadingTime();
127 unsigned tfine = int(rawTime * sampleDivisions) % sampleDivisions; // TODO: <0 ?
128 newDigit->setTFine(tfine);
129 newDigit->addRelationTo(waveform);
130 }
131 }
132
133 int finalSize = rawDigits.getEntries();
134 B2DEBUG(20, "TOPWaveformFeatureExtractor: appended " << finalSize - initSize
135 << " raw digits to initial " << initSize);
136
137 }

◆ event() [32/32]

void event ( void )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 145 of file TOPWaveformQualityPlotterModule.cc.

146 {
147 if (not m_waveform) {
148 return;
149 }
150 for (auto evtwave : m_waveform) {
151 if (m_DRAWWAVES) {
152 drawWaveforms(evtwave);
153 }
154 if (m_DEBUGGING) {
155 basicDebuggingPlots(evtwave);
156 }
157 if (m_NOISE) {
158 auto channelID = evtwave.getChannel();
159 const vector<short> v_samples = evtwave.getWaveform();
160 size_t nsamples = v_samples.size();
161 if (m_channelNoiseMap.find(channelID) == m_channelNoiseMap.end()) {
162 string idName = string("noise_") + to_string(channelID);
163 m_channelNoiseMap.insert(make_pair(channelID, new TH1F(idName.c_str(), idName.c_str(), 200, -100, 100)));
164 m_channelEventMap.insert(make_pair(channelID, m_iEvent));
165 }
166 TH1F* noise = m_channelNoiseMap[channelID];
167 // Plot all samples in common histogram for quick sanity check
168 for (size_t s = 0; s < nsamples; s++) {
169 double adc = v_samples.at(s);
170 m_samples->Fill(adc);
171 if (s < nsamples - 1) {
172 noise->Fill(v_samples[s + 1] - adc);
173 }
174 }
175 }
176 }
177 m_iEvent += 1;
178 return;
179 }

◆ FindPeakForSmallerXThan()

double FindPeakForSmallerXThan ( TH1 * histo,
double xmax = 0 )
static

Find peak and return its position for a limited range of x (x smaller than the given value (xmax))

Definition at line 646 of file TOPGainEfficiencyCalculatorModule.cc.

647 {
648 double histo_xmax = histo->GetXaxis()->GetBinUpEdge(histo->GetXaxis()->GetNbins() - 1);
649 if (xmax > histo_xmax) xmax = histo_xmax;
650
651 int iBin = 1;
652 double peakPos = histo->GetXaxis()->GetBinCenter(iBin);
653 double peakCharge = histo->GetBinContent(iBin);
654 while (true) {
655 iBin++;
656 double x = histo->GetXaxis()->GetBinCenter(iBin);
657 if (x > xmax) break;
658
659 double binEntry = histo->GetBinContent(iBin);
660 if (binEntry > peakCharge) {
661 peakPos = x;
662 peakCharge = binEntry;
663 }
664 }
665
666 return peakPos;
667 }

◆ FitHistograms()

void FitHistograms ( EHistogramType LoadHisto)

Fit charge (or integrated charged) distribution to calculate gain and efficiency for each channel.

Definition at line 276 of file TOPGainEfficiencyCalculatorModule.cc.

277 {
278 float threshold = m_threshold;
279 int globalAsicId = 0;
280 if (LoadHisto == c_LoadForFitIntegral || LoadHisto == c_LoadHitRateIntegral) threshold = m_thresholdForIntegral;
281
282 for (int iHisto = 0 ; iHisto < c_NChannelPerPMT ; iHisto++) {
283 if (m_targetPmtChId != -1 && iHisto + 1 != m_targetPmtChId) continue;
284
285 m_pixelId = ((m_targetPmtId - 1) % c_NPMTPerRow) * c_NChannelPerPMTRow
286 + ((m_targetPmtId - 1) / c_NPMTPerRow) * c_NPixelPerModule / 2
287 + (iHisto / c_NChannelPerPMTRow) * c_NPixelPerRow + (iHisto % c_NChannelPerPMTRow) + 1;
288 m_pmtChId = (iHisto + 1);
289 globalAsicId = ((m_targetSlotId - 1) * c_NPixelPerModule + (m_pixelId - 1)) / c_NChannelPerAsic;
290 if (LoadHisto == c_LoadForFitHeight) {
291 for (auto itr = m_branch[0].begin(); itr != m_branch[0].end(); ++itr) {
292 (*itr)->Fill();
293 }
294 }
295
296 TH1D* hCharge = m_chargeHistogram[iHisto];
297 if (!hCharge) { DummyFillBranch(LoadHisto); continue;}
298
299 std::cout << " ***** fitting charge distribution for " << hCharge->GetName() << " *****" << std::endl;
300 int nBins = hCharge->GetXaxis()->GetNbins();
301 double binWidth = hCharge->GetXaxis()->GetBinUpEdge(1) - hCharge->GetXaxis()->GetBinLowEdge(1);
302 double histoMax = hCharge->GetXaxis()->GetBinUpEdge(nBins);
303 m_fitMax = threshold;
304 double wholeIntegral = hCharge->Integral(0, hCharge->GetXaxis()->GetNbins() + 1);
305 double fitRangeFraction = (m_fracFit > 0 ? m_fracFit : 1. - 10. / wholeIntegral);
306 while (hCharge->Integral(0, hCharge->GetXaxis()->FindBin(m_fitMax - 0.01 * binWidth)) / wholeIntegral < fitRangeFraction)
307 m_fitMax += binWidth;
308 if (m_fitMax < threshold + static_cast<double>(c_NParameterGainFit) * binWidth) {
309 B2WARNING("TOPGainEfficiencyCalculator : no enough entries for fitting at slot"
310 << std::setw(2) << std::setfill('0') << m_targetSlotId << ", PMT"
311 << std::setw(2) << std::setfill('0') << m_targetPmtId << ", Ch"
312 << std::setw(2) << std::setfill('0') << m_pmtChId);
313 DummyFillBranch(LoadHisto); continue;
314 }
315
316 std::ostringstream fname;
317 fname << "func_" << (iHisto + 1);
318 TObject* object = gROOT->FindObject(fname.str().c_str());
319 if (object) delete object;
320 TF1* func = new TF1(fname.str().c_str(), TOPGainFunc, threshold, m_fitMax, c_NParameterGainFit);
321 double initGain = TMath::Max(hCharge->GetMean(), 26.1) - 25;
322 double initP1 = TMath::Min(4.0, TMath::Max(10000.*TMath::Power(initGain - 25, -2), 0.01));
323 double initP2 = TMath::Min(0.8 + 0.005 * TMath::Power(initP1, -3), 4.);
324 double initX0 = TMath::Max(initGain * 2 - 150, 10.);
325 //if (initP1 > initP2) initX0 = initX0 / 10.
326 double initP1overP2 = initP1 / initP2;
327 double initP0 = hCharge->GetBinContent(hCharge->GetMaximumBin())
328 / (TMath::Power(initP1overP2, initP1overP2) * TMath::Exp(-initP1overP2)) / binWidth;
329 if (m_initialX0 < 0)func->SetParameter(3, initX0);
330 else if (LoadHisto == c_LoadForFitHeight)
331 func->SetParameter(3, 150 + 0.5 * hCharge->GetMean());
332 else if (LoadHisto == c_LoadForFitIntegral)
333 func->SetParameter(3, 1000 + 0.5 * hCharge->GetMean());
334 if (m_initialP2 < 0)func->SetParameter(2, initP2);
335 else func->SetParameter(2, m_initialP2);
336 if (m_initialP1 < 0)func->SetParameter(1, initP1);
337 else func->SetParameter(1, m_initialP1);
338 if (m_initialP0 < 0)func->SetParameter(0, initP0);
339 else func->SetParameter(0, m_initialP0 * hCharge->GetEntries()*binWidth);
340
341 func->FixParameter(4, 0);
342 func->FixParameter(5, m_pedestalSigma);
343 func->SetParName(0, "#it{p}_{0}");
344 func->SetParName(1, "#it{p}_{1}");
345 func->SetParName(2, "#it{p}_{2}");
346 func->SetParName(3, "#it{x}_{0}");
347 func->SetParName(4, "pedestal");
348 func->SetParName(5, "pedestal #sigma");
349 func->SetParLimits(0, 1e-8, 1e8);
350 func->SetParLimits(1, 1e-8, 10);
351 func->SetParLimits(2, 1e-8, 10);
352 func->SetParLimits(3, 1e-8, 1e8);
353 func->SetLineColor(2);
354 func->SetLineWidth(1);
355 TF1* funcFull = NULL;
356 if (LoadHisto == c_LoadForFitHeight or LoadHisto == c_LoadForFitIntegral) {
357 hCharge->Fit(func, m_fitoption.c_str(), "", threshold, m_fitMax);
358
359 if (func->GetNDF() < 2) { DummyFillBranch(LoadHisto); continue;}
360
361 double funcFullMax = histoMax * 2;
362 funcFull = new TF1((fname.str() + "_full").c_str(), TOPGainFunc, (-1)*func->GetParameter(5), funcFullMax, c_NParameterGainFit);
363 for (int iPar = 0 ; iPar < c_NParameterGainFit ; iPar++)
364 funcFull->SetParameter(iPar, func->GetParameter(iPar));
365 funcFull->SetLineColor(3);
366 funcFull->SetLineWidth(2);
367
368 double totalWeight = 0;
369 double weightedIntegral = 0;
370 double x = (-1) * func->GetParameter(5);
371 while (x < funcFullMax) {
372 double funcVal = funcFull->Eval(x);
373 totalWeight += funcVal;
374 weightedIntegral += funcVal * x;
375 x += binWidth / 5.;
376 }
377
378 //fill results to the output TTree
379 m_gain = weightedIntegral / totalWeight;
380 m_efficiency = funcFull->Integral(threshold, funcFullMax) / funcFull->Integral((-1) * func->GetParameter(5), funcFullMax);
381 m_p0 = func->GetParameter(0);
382 m_p1 = func->GetParameter(1);
383 m_p2 = func->GetParameter(2);
384 m_x0 = func->GetParameter(3);
385 m_p0Error = func->GetParError(0);
386 m_p1Error = func->GetParError(1);
387 m_p2Error = func->GetParError(2);
388 m_x0Error = func->GetParError(3);
389 m_chisquare = func->GetChisquare();
390 m_ndf = func->GetNDF();
391 m_funcFullRangeIntegral = funcFull->Integral((-1) * func->GetParameter(5), funcFullMax) / binWidth;
392 m_funcFitRangeIntegral = funcFull->Integral(threshold, m_fitMax) / binWidth;
393 } else std::cout << "*****fitting is skipped***** " << std::endl;
394 int threBin = hCharge->GetXaxis()->FindBin(threshold + 0.01 * binWidth);
395 int fitMaxBin = hCharge->GetXaxis()->FindBin(m_fitMax - 0.01 * binWidth);
396 m_histoFitRangeIntegral = hCharge->Integral(threBin, fitMaxBin);
397
398 m_histoMeanAboveThre = 0;
399 for (int iBin = threBin ; iBin < nBins + 1 ; iBin++) {
400 m_histoMeanAboveThre += (hCharge->GetBinContent(iBin) * hCharge->GetXaxis()->GetBinCenter(iBin));
401 }
402 m_histoMeanAboveThre /= hCharge->Integral(threBin, nBins);
403 m_nEntries = hCharge->GetEntries();
404 m_nCalPulse = (m_nCalPulseHistogram ? m_nCalPulseHistogram->GetBinContent(globalAsicId + 1) : -1);
405 m_nOverflowEvents = TMath::FloorNint(hCharge->GetBinContent(nBins + 1));
406 m_meanPulseHeight = hCharge->GetMean();
407 m_meanPulseHeightError = hCharge->GetMeanError();
408 m_hitTiming = 0;
409 m_hitTimingSigma = -1;
410
411 TF1* funcLaser = m_funcForLaser[iHisto];
412 if (m_timeHistogram[iHisto] && funcLaser) {
413 m_hitTiming = funcLaser->GetParameter(1);
414 m_hitTimingSigma = funcLaser->GetParameter(2);
415 }
416
417 m_funcForFitRange[iHisto] = func;
418 m_funcForFullRange[iHisto] = funcFull;
419
420 for (auto itr = m_branch[LoadHisto].begin(); itr != m_branch[LoadHisto].end(); ++itr) {
421 (*itr)->Fill();
422 }
423
424 std::cout << std::endl;
425 }
426 if (m_targetPmtChId == -1) m_tree->SetEntries(c_NChannelPerPMT);
427 else m_tree->SetEntries(1);
428
429 return;
430 }

◆ generatePulseHeight()

double generatePulseHeight ( int moduleID,
int pixelID ) const
private

Generates and returns pulse height.

Parameters
moduleIDmodule ID (1-based)
pixelIDpixel ID (1-based)
Returns
pulse height [ADC counts]

Definition at line 533 of file TOPDigitizerModule.cc.

534 {
535 if (m_useDatabase) {
536 const auto& channelMapper = TOPGeometryPar::Instance()->getChannelMapper();
537 auto channel = channelMapper.getChannel(pixelID);
538 if (m_pulseHeights->isCalibrated(moduleID, channel)) {
539 const auto& par = m_pulseHeights->getParameters(moduleID, channel);
540 PulseHeightGenerator generator(par.x0, par.p1, par.p2, m_ADCmax);
541 return generator.generate();
542 }
543 }
544
545 return m_pulseHeightGenerator.generate();
546 }

◆ getDirectionCustom()

XYZVector getDirectionCustom ( ) const
private

Return photon direction according to a custom angular distribution given by TFormula.

Returns
photon direction (unit vector)

Definition at line 269 of file OpticalGunModule.cc.

270 {
271 double alpha = m_customDistribution->GetRandom();
272 double phi = 2.0 * M_PI * gRandom->Rndm();
273 return XYZVector(cos(phi) * sin(alpha), sin(phi) * sin(alpha), cos(alpha));
274 }

◆ getDirectionGaussian()

XYZVector getDirectionGaussian ( ) const
private

Return photon direction according to a projected 2D gaussian distribution based on numerical aperture NA.

Returns
photon direction (unit vector)

Definition at line 237 of file OpticalGunModule.cc.

238 {
239 // NA is defined as the aperture where the amplitude is 5% of that of the
240 // peak, which translates into 2.45 sigma for a gaussian distribution
241 double x = 0;
242 double y = 0;
243 double z = 0;
244 do {
245 x = gRandom->Gaus(0., asin(m_na) / 2.45);
246 y = gRandom->Gaus(0., asin(m_na) / 2.45);
247 z = 1. - x * x - y * y;
248 } while (z < 0);
249 return XYZVector(x, y, sqrt(z));
250 }

◆ getDirectionLambertian()

XYZVector getDirectionLambertian ( ) const
private

Return photon direction according to a lambertian distribution with opening angle alpha.

Returns
photon direction (unit vector)

Definition at line 260 of file OpticalGunModule.cc.

261 {
262 double cosTheta = sqrt((m_cosMinAlpha * m_cosMinAlpha - m_cosMaxAlpha * m_cosMaxAlpha) * gRandom->Rndm() +
263 m_cosMaxAlpha * m_cosMaxAlpha);
264 double sinTheta = sqrt(1.0 - cosTheta * cosTheta);
265 double phi = 2.0 * M_PI * gRandom->Rndm();
266 return XYZVector(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
267 }

◆ getDirectionUniform()

XYZVector getDirectionUniform ( ) const
private

Return photon direction according to a projected uniform distribution with opening angle alpha.

Be careful.

Returns
photon direction (unit vector)

Definition at line 252 of file OpticalGunModule.cc.

253 {
254 double cosTheta = (m_cosMinAlpha - m_cosMaxAlpha) * gRandom->Rndm() + m_cosMaxAlpha;
255 double sinTheta = sqrt(1.0 - cosTheta * cosTheta);
256 double phi = 2.0 * M_PI * gRandom->Rndm();
257 return XYZVector(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
258 }

◆ getFrontEndName()

std::string getFrontEndName ( RawTOP & raw,
int finesse ) const
private

Returns the name of the front-end.

Parameters
rawraw data
finessefinesse number
Returns
front-end name

Definition at line 219 of file TOPUnpackerModule.cc.

220 {
221 std::string name;
222 if (raw.GetMaxNumOfCh(0) <= 4) { // COPPER
223 int copper = ((raw.GetNodeID(0) >> 24) * 1000 + (raw.GetNodeID(0) & 0x3FF));
224 name = "frontend cpr" + std::to_string(copper) + char('a' + finesse);
225 } else { // PCIe40
226 int slot = (raw.GetNodeID(0) & 0xF) * 8 - 7 + finesse / 4;
227 name = (slot < 10) ? "boardstack s0" : "boardstack s";
228 name += std::to_string(slot) + char('a' + finesse % 4);
229 }
230 return name;
231 }

◆ getModuleID()

int getModuleID ( const Track & track) const
private

Returns slot ID of the module that is hit by the track.

Parameters
trackcharged track
Returns
slotID or 0 if track does not hit any module

Definition at line 515 of file TOPDQMModule.cc.

516 {
517 Const::EDetector myDetID = Const::EDetector::TOP;
518 int pdgCode = std::abs(Const::pion.getPDGCode());
519
520 RelationVector<ExtHit> extHits = track.getRelationsWith<ExtHit>();
521 for (const auto& extHit : extHits) {
522 if (std::abs(extHit.getPdgCode()) != pdgCode) continue;
523 if (extHit.getDetectorID() != myDetID) continue;
524 if (extHit.getCopyID() < 1 or extHit.getCopyID() > m_numModules) continue;
525 return extHit.getCopyID();
526 }
527
528 return 0;
529 }

◆ getMostProbable()

Const::ChargedStable getMostProbable ( const Track & track)
private

Returns most probable charged stable particle according to dEdx and predefined prior probabilities.

Parameters
trackreconstructed track
Returns
charged stable

Definition at line 564 of file TOPBunchFinderModule.cc.

565 {
566
567 std::vector<double> logL;
568 std::vector<double> priors;
569
570 if (m_usePIDLikelihoods) {
571 const auto* pid = track.getRelated<PIDLikelihood>();
572 if (not pid) {
573 m_nodEdxCount++;
574 return Const::pion;
575 }
576 auto subset = Const::PIDDetectorSet(Const::SVD);
577 subset += Const::PIDDetectorSet(Const::CDC);
578 for (const auto& type : Const::chargedStableSet) {
579 logL.push_back(pid->getLogL(type, subset));
580 priors.push_back(m_priors[abs(type.getPDGCode())]);
581 }
582 } else {
583 const auto* cdcdedx = track.getRelated<CDCDedxLikelihood>();
584 const auto* vxddedx = track.getRelated<VXDDedxLikelihood>();
585 if (not cdcdedx and not vxddedx) {
586 m_nodEdxCount++;
587 return Const::pion;
588 }
589 for (const auto& type : Const::chargedStableSet) {
590 if (cdcdedx and vxddedx) {
591 logL.push_back(cdcdedx->getLogL(type) + vxddedx->getLogL(type));
592 } else if (cdcdedx) {
593 logL.push_back(cdcdedx->getLogL(type));
594 } else {
595 logL.push_back(vxddedx->getLogL(type));
596 }
597 priors.push_back(m_priors[abs(type.getPDGCode())]);
598 }
599 }
600
601 // get maximal logL
602 auto logL_max = logL[0];
603 for (auto x : logL) {
604 if (x > logL_max) logL_max = x;
605 }
606
607 // calculate probabilities, normalizaton is not needed
608 std::vector<double> probability(logL.size());
609 for (unsigned i = 0; i < logL.size(); ++i) {
610 probability[i] = exp(logL[i] - logL_max) * priors[i];
611 }
612
613 // find most probable
614 unsigned i0 = 0;
615 for (unsigned i = 0; i < probability.size(); ++i) {
616 if (probability[i] > probability[i0]) i0 = i;
617 }
618 return Const::chargedStableSet.at(i0);
619
620 }
std::bitset< max - min+1 > subset(std::bitset< nbits > set)
extract a subset of bitstring, like substring.
Definition Cosim.h:120

◆ getReferenceTiming()

void getReferenceTiming ( )
private

Find reference timing.

In case that the waveform analysis is enabled, try to find a pair of calibration pulses and timing of the first one is used as reference timing for the correcponding asic. If not enabled, feature extracted timing for a calibration channel is used.

Definition at line 339 of file TOPInterimFENtupleModule.cc.

340 {
341 static short globalRefAsic = m_globalRefAsicNum + 100 * m_globalRefSlotNum;
342 m_globalRefTime = -99999;
343 std::map<short, short> iRefHitMap;
344 for (int iHit = 0 ; iHit < m_nHit ; iHit++) {
345 if (!m_isCalCh[iHit]) continue;
346 short reducedPixelId = (m_pixelId[iHit] - 1) / 8 + 100 * m_slotNum[iHit];
347 if (iRefHitMap.count(reducedPixelId) > 0) continue;
348
349 if (!m_useDoublePulse) {
350 iRefHitMap[reducedPixelId] = iHit;
351 continue;
352 }
353
354 std::vector<short> iHitVec;
355 iHitVec.push_back(iHit);
356 for (int jHit = iHit + 1 ; jHit < m_nHit ; jHit++) {
357 short jReducedPixelId = (m_pixelId[jHit] - 1) / 8 + 100 * m_slotNum[jHit];
358 if (m_isCalCh[jHit] && jReducedPixelId == reducedPixelId) iHitVec.push_back(jHit);
359 }
360
361 int nCands = 0;
362 for (unsigned int iVec = 0 ; iVec < iHitVec.size() ; iVec++) {
363 int jHit = iHitVec[iVec];
364 for (unsigned int jVec = iVec + 1 ; jVec < iHitVec.size() ; jVec++) {
365 int kHit = iHitVec[jVec];
366 float timediff = m_time[kHit] - m_time[jHit];
367 if (m_height[jHit] > m_calibrationPulseThreshold1
368 && m_height[kHit] > m_calibrationPulseThreshold2
369 && TMath::Abs(timediff - m_calibrationPulseInterval) < m_calibrationPulseIntervalRange) {
370 if (nCands == 0) {
371 iRefHitMap[reducedPixelId] = jHit;
372 m_hitQuality[jHit] += 100;
373 m_hitQuality[kHit] += 200;
374 }
375 nCands++;
376 }
377 //in case jHit and kHit are not in time order (added at 28th Nov)
378 else if (timediff < 0 && m_height[kHit] > m_calibrationPulseThreshold1
379 && m_height[jHit] > m_calibrationPulseThreshold2
380 && TMath::Abs(timediff + m_calibrationPulseInterval) < m_calibrationPulseIntervalRange) {
381 if (nCands == 0) {
382 iRefHitMap[reducedPixelId] = kHit;
383 m_hitQuality[kHit] += 100;
384 m_hitQuality[jHit] += 200;
385 }
386 nCands++;
387 }//satisfy selection criteria for calibration signal
388 }
389 }//iVec (finish selecting a calibration signal candidate)
390 }
391
392
393 //loop all hits again to fill the array "refTime"
394 for (int iHit = 0 ; iHit < m_nHit ; iHit++) {
395 short reducedPixelId = (m_pixelId[iHit] - 1) / 8 + 100 * m_slotNum[iHit];
396 if (iRefHitMap.count(reducedPixelId) > 0) {
397 int iRef = iRefHitMap[reducedPixelId];
398 m_refTime[iHit] = m_time[iRef];
399 if (reducedPixelId == globalRefAsic) m_globalRefTime = m_time[iRef];
400 if (!m_isReallyJunk[iHit] && m_hitQuality[iRef] >= 100) {
401 m_hitQuality[iHit] += 10;
402 }
403 } else m_refTime[iHit] = -99999;
404 }
405
406 return;
407 }

◆ getTimeOffset()

TOPDigitizerModule::TimeOffset getTimeOffset ( double trgOffset,
int moduleID,
int pixelID )
private

Returns a complete time offset by adding time mis-calibration to trgOffset.

Parameters
trgOffsettrigger related time offset
moduleIDslot ID
pixelIDpixel ID
Returns
time offset and its error squared

Definition at line 496 of file TOPDigitizerModule.cc.

499 {
500 double timeOffset = trgOffset;
501 double calErrorSq = 0;
502 int winShift = 0;
503 double timeShift = 0;
504 if (m_useDatabase) {
505 const auto& channelMapper = TOPGeometryPar::Instance()->getChannelMapper();
506 auto channel = channelMapper.getChannel(pixelID);
507 if (m_channelT0->isCalibrated(moduleID, channel)) {
508 timeOffset += m_channelT0->getT0(moduleID, channel);
509 double err = m_channelT0->getT0Error(moduleID, channel);
510 calErrorSq += err * err;
511 }
512 auto asic = channel / 8;
513 if (m_asicShift->isCalibrated(moduleID, asic)) {
514 timeOffset += m_asicShift->getT0(moduleID, asic);
515 winShift = lround(m_asicShift->getT0(moduleID, asic) / m_syncTimeBase * 2);
516 timeShift = winShift * m_syncTimeBase / 2;
517 }
518 if (m_moduleT0->isCalibrated(moduleID)) {
519 timeOffset += m_moduleT0->getT0(moduleID);
520 double err = m_moduleT0->getT0Error(moduleID);
521 calErrorSq += err * err;
522 }
523 if (m_commonT0->isCalibrated()) {
524 timeOffset += m_commonT0->getT0();
525 double err = m_commonT0->getT0Error();
526 calErrorSq += err * err;
527 }
528 }
529 return TimeOffset(timeOffset, calErrorSq, winShift, timeShift);
530 }

◆ getTimeSeed()

TOPBunchFinderModule::TimeSeed getTimeSeed ( )
private

Returns a time seed.

Returns
time seed

Definition at line 643 of file TOPBunchFinderModule.cc.

644 {
645 TimeSeed timeSeed; // default time seed; sigma == 0 signals that the seed is not given
646
647 if (m_HLTmode) return timeSeed;
648 if (m_autoRange) return timeSeed;
649 if (not m_useTimeSeed) return timeSeed;
650 if (not m_eventT0Offset.isValid()) return timeSeed;
651
652 for (auto detector : {Const::SVD, Const::CDC}) {
653 if (m_eventT0Offset->isAvailable(detector) and m_eventT0->hasTemporaryEventT0(detector)) {
654 auto eventT0s = m_eventT0->getTemporaryEventT0s(detector);
655 if (eventT0s.empty()) continue;
656 if (detector == Const::CDC and eventT0s.back().algorithm != "chi2") continue;
657 double t0 = eventT0s.back().eventT0;
658 if (std::abs(t0) > m_timeRangeCoarse / 2) continue;
659 timeSeed.t0 = m_isMC ? t0 : t0 - m_eventT0Offset->get(detector).offset;
660 timeSeed.sigma = m_eventT0Offset->get(detector).sigma;
661 timeSeed.detector = detector;
662 break;
663 }
664 }
665
666 return timeSeed;
667 }

◆ initialize() [1/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 90 of file OpticalGunModule.cc.

91 {
92 // data store objects registration
93 m_MCParticles.registerInDataStore();
94 m_simCalPulses.isOptional();
95
96 // parameters check
97 if (m_wavelength < 150 or m_wavelength > 1000)
98 B2FATAL("Wavelength does not correspond to optical photons.");
99 if (m_na < 0 or m_na > 1)
100 B2FATAL("Numerical aperture must be between 0 and 1.");
101 if (m_minAlpha < 0)
102 B2FATAL("Minimum emission angle must be positive");
103 if (m_maxAlpha < 0)
104 B2FATAL("Maximum emission angle must be positive");
105 if (m_minAlpha >= m_maxAlpha)
106 B2FATAL("Minimum emission angle must me smaller than the maximum emission angle");
107
108 if (m_angularDistribution == string("uniform") or
109 m_angularDistribution == string("Lambertian") or
110 m_angularDistribution == string("Gaussian"))
111 B2INFO("Using the pre-defined angular distribution " << m_angularDistribution);
112 else {
113 B2INFO(m_angularDistribution << " is not a pre-defined distribution. "
114 << "Checking if it's a valid, positively-defined TFormula.");
115 TFormula testFormula("testFormula", m_angularDistribution.c_str());
116 int result = testFormula.Compile();
117 if (result != 0) {
118 B2FATAL(m_angularDistribution << " TFormula does not compile.");
119 }
120 double testPoint = m_minAlpha; // let's test if the function is postive defined everywhere
121 while (testPoint < m_maxAlpha) {
122 double value = testFormula.Eval(testPoint * Unit::deg);
123 if (value < 0) {
124 B2FATAL("The formula " << m_angularDistribution << " is not positively defined at the test point "
125 << testPoint << " deg (value = " << value << ")");
126 }
127 testPoint += (m_maxAlpha - m_minAlpha) / 100.;
128 }
129 m_customDistribution = new TF1("m_customDistribution", m_angularDistribution.c_str(), m_minAlpha * Unit::deg,
130 m_maxAlpha * Unit::deg);
131 }
132
133 // set other private variables
134 m_cosMinAlpha = cos(m_minAlpha * Unit::deg);
135 m_cosMaxAlpha = cos(m_maxAlpha * Unit::deg);
136 m_energy = TOPGeometryPar::c_hc / m_wavelength * Unit::eV;
137
138 EulerAngles ea(-m_phi * Unit::deg, -m_theta * Unit::deg, -m_psi * Unit::deg); // rotation of an object as in TRotation
139 m_transform = Transform3D(Rotation3D(ea), Translation3D(m_x, m_y, m_z)); // source positioning and elevation
140 if (m_slotID != 0) {
141 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
142 if (not geo->isModuleIDValid(m_slotID)) B2FATAL("Slot ID is not valid");
143 const auto& T = geo->getModule(m_slotID).getTransformation(); // slot to BelleII
144 m_transform = T * m_transform;
145 }
146
147 }

◆ initialize() [2/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 87 of file TOPAlignerModule.cc.

88 {
89 // check if target module ID is valid
90
91 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
92 if (not geo->isModuleIDValid(m_targetMid)) {
93 B2ERROR("Target module ID = " << m_targetMid << " is invalid.");
94 }
95
96 // check if sample type is valid
97
98 if (not(m_sample == "dimuon" or m_sample == "bhabha" or m_sample == "cosmics")) {
99 B2ERROR("Invalid sample type '" << m_sample << "'");
100 }
101 if (m_sample == "bhabha") m_chargedStable = Const::electron;
102
103 // set track selector
104
105 m_selector = TrackSelector(m_sample);
106 m_selector.setMinMomentum(m_minMomentum);
107 m_selector.setDeltaEcms(m_deltaEcms);
108 m_selector.setCutOnPOCA(m_dr, m_dz);
109 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
110
111 // set alignment object
112
113 m_align.setModuleID(m_targetMid);
114 m_align.setSteps(m_stepPosition, m_stepAngle, m_stepTime);
115 m_align.setParameters(m_parInit);
116 for (const auto& parName : m_parFixed) {
117 m_align.fixParameter(parName);
118 }
119
120 // input
121
122 m_digits.isRequired();
123 m_tracks.isRequired();
124 m_extHits.isRequired();
125 m_recBunch.isOptional();
126
127 // open output file
128
129 m_file = TFile::Open(m_outFileName.c_str(), "RECREATE");
130 if (m_file->IsZombie()) {
131 B2FATAL("Couldn't open file '" << m_outFileName << "' for writing!");
132 return;
133 }
134
135 // create output tree
136
137 m_alignTree = new TTree("alignTree", "TOP alignment results");
138 m_alignTree->Branch("ModuleId", &m_targetMid);
139 m_alignTree->Branch("iter", &m_iter);
140 m_alignTree->Branch("ntrk", &m_ntrk);
141 m_alignTree->Branch("errorCode", &m_errorCode);
142 m_alignTree->Branch("iterPars", &m_vAlignPars);
143 m_alignTree->Branch("iterParsErr", &m_vAlignParsErr);
144 m_alignTree->Branch("valid", &m_valid);
145 m_alignTree->Branch("numPhot", &m_numPhot);
146 m_alignTree->Branch("x", &m_x);
147 m_alignTree->Branch("y", &m_y);
148 m_alignTree->Branch("z", &m_z);
149 m_alignTree->Branch("p", &m_p);
150 m_alignTree->Branch("theta", &m_theta);
151 m_alignTree->Branch("phi", &m_phi);
152 m_alignTree->Branch("r_poca", &m_pocaR);
153 m_alignTree->Branch("z_poca", &m_pocaZ);
154 m_alignTree->Branch("x_poca", &m_pocaX);
155 m_alignTree->Branch("y_poca", &m_pocaY);
156 m_alignTree->Branch("Ecms", &m_cmsE);
157 m_alignTree->Branch("charge", &m_charge);
158 m_alignTree->Branch("PDG", &m_PDG);
159
160 }

◆ initialize() [3/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 115 of file TOPBackgroundModule.cc.

116 {
117
118 // CPU time start
119
120 // Initializing the output root file
121 m_rootFile = TFile::Open(m_OutputFileName.c_str(), "RECREATE");
122 origingamma = new TTree("origingamma", "tree");
123 originpe = new TTree("originpe", "tree2");
124
125 origingamma->Branch("x", &origingamma_x);
126 origingamma->Branch("y", &origingamma_y);
127 origingamma->Branch("z", &origingamma_z);
128 originpe->Branch("x", &originpe_x);
129 originpe->Branch("y", &originpe_y);
130 originpe->Branch("z", &originpe_z);
131
132 peflux = new TH1F("Photoelectron flux", "Photoelectron flux", 33, -11.25, 360);
133 nflux = new TH1F("Neutron flux", "Neutron flux", 33, -11.25, 360);
134 rdose = new TH1F("Radiation dose", "Radiation dose", 33, -11.25, 360);
135 zdist = new TH1F("Photoelectron origin", "Photoelectron origin", 200, -400, 400);
136 genergy = new TH1F("Energy distribution of photons", "Energy distribution of photons", 150, 0, 5);
137 genergy2 = new TH1F("Energy distribution of gammas", "Energy distribution of gammas", 500, 0, 5);
138
139 zdistg = new TH1F("Photoelectron flux z", "Photoelectron flux Z projection", 800, -400, 400);
140 originpt = new TH1F("P_t of origin electron", "P_t of origin electron", 300, 0.06, 0.14);
141
142 nflux_bar = new TH2F("Neutron flux on bar", "Neutron flux on bar", 32, -114.8, 211.5, 16, -0, 360);
143 gflux_bar = new TH2F("Gamma flux on bar", "Gamma flux on bar MHz/cm^{2}", 32, -114.8, 211.5, 16, -0, 360);
144 cflux_bar = new TH2F("Charged flux on bar", "Charged flux on bar MHz/cm^{2}", 32, -114.8, 211.5, 16, -0, 360);
145
146 norigin = new TH1F("neutron(BAR) origin", "neutron(BAR) origin", 200, -400, 400);
147 gorigin = new TH1F("gamma(BAR) origin", "gamma(BAR) origin", 200, -400, 400);
148 corigin = new TH1F("charged(BAR) origin", "charged(BAR) origin", 200, -400, 400);
149
150 nprim = new TH1F("neutron(BAR) primary", "neutron(BAR) primary", 200, -400, 400);
151 gprim = new TH1F("gamma(BAR) primary", "gamma(BAR) primary", 200, -400, 400);
152 cprim = new TH1F("charged(BAR) primary", "charged(BAR) primary", 200, -400, 400);
153
154 origin_zx = new TGraph();
155 origin_zy = new TGraph();
156
157 prim_zx = new TGraph();
158 prim_zy = new TGraph();
159 module_occupancy = new TGraph();
160
161 origin_zy->SetName("originZY");
162 origin_zx->SetName("originZX");
163 module_occupancy->SetName("occupancy");
164
165 const auto& geo = TOP::TOPGeometryPar::Instance()->getGeometry()->getFrontEnd();
166 double S1 = geo.getFrontBoardWidth() * geo.getFrontBoardHeight();
167 double S2 = geo.getHVBoardWidth() * geo.getHVBoardLength();
168 double V1 = S1 * geo.getFrontBoardThickness();
169 double V2 = S2 * geo.getHVBoardThickness();
170 G4Material* material1 = geometry::Materials::get(geo.getFrontBoardMaterial());
171 if (!material1) B2FATAL("Material '" << geo.getFrontBoardMaterial() << "' not found");
172 G4Material* material2 = geometry::Materials::get(geo.getHVBoardMaterial());
173 if (!material2) B2FATAL("Material '" << geo.getHVBoardMaterial() << "' not found");
174 double density1 = material1->GetDensity() / CLHEP::kg * CLHEP::cm * CLHEP::cm * CLHEP::cm;
175 double density2 = material2->GetDensity() / CLHEP::kg * CLHEP::cm * CLHEP::cm * CLHEP::cm;
176
177 PCBarea = S1 + S2; // [cm^2], old value was: 496.725
178 PCBmass = V1 * density1 + V2 * density2; // [kg], old value was: 0.417249
179
180 yearns = 1.e13;
181 evtoJ = 1.60217653 * 1e-10;
182 mtoc = 1.97530864197531;
183 count = 0;
184 count_occ = 0;
185
186 origingamma_x = 0;
187 origingamma_y = 0;
188 origingamma_z = 0;
189 originpe_x = 0;
190 originpe_y = 0;
191 originpe_z = 0;
192 }

◆ initialize() [4/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 111 of file TOPBunchFinderModule.cc.

112 {
113 // input collections
114
115 m_topDigits.isRequired();
116 m_topRawDigits.isOptional();
117 m_tracks.isRequired();
118 StoreArray<ExtHit> extHits;
119 extHits.isRequired();
120 m_initialParticles.isOptional();
121
122 if (m_useMCTruth) {
123 StoreArray<MCParticle> mcParticles;
124 mcParticles.isRequired();
125 StoreArray<TOPBarHit> barHits;
126 barHits.isRequired();
127 } else {
128 if (m_usePIDLikelihoods) {
129 StoreArray<PIDLikelihood> pidLikelihoods;
130 pidLikelihoods.isRequired();
131 } else {
132 StoreArray<CDCDedxLikelihood> cdcDedxLikelihoods;
133 cdcDedxLikelihoods.isRequired();
134 StoreArray<VXDDedxLikelihood> vxdDedxLikelihoods;
135 vxdDedxLikelihoods.isOptional();
136 }
137 }
138
139 // output
140
141 m_recBunch.registerInDataStore();
142 m_timeZeros.registerInDataStore();
143 m_timeZeros.registerRelationTo(extHits);
144 m_eventT0.registerInDataStore(); // usually it is already registered in tracking
145
146 // bunch separation in time
147
148 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
149 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / m_bunchesPerSSTclk;
150
151 // prior probabilities: from generic BBbar simulation
152 // - MCParticles with reconstructed track and at least 5 detected Cherenkov photons
153
154 m_priors[11] = 0.062; // electrons
155 m_priors[13] = 0.086; // muons
156 m_priors[211] = 0.734; // pions
157 m_priors[321] = 0.106; // kaons
158 m_priors[2212] = 0.013; // protons
159 m_priors[1000010020] = 0; // deuterons
160
161 double s = 0;
162 for (const auto& prior : m_priors) s += prior.second;
163 for (auto& prior : m_priors) prior.second /= s;
164
165 if (not m_commonT0.isValid()) {
166 B2ERROR("Common T0 calibration payload requested but not available");
167 return;
168 }
169
170 /*************************************************************************
171 * auto detection of HLT/express reco mode via status of common T0 payload:
172 * c_Default -> HLT/express reco mode
173 * c_Calibrated -> data processing mode
174 * c_Unusable -> HLT/express reco mode
175 * c_roughlyCalibrated -> HLT/express reco mode
176 *************************************************************************/
177
178 if (m_commonT0->isCalibrated()) {
179 m_HLTmode = false;
180 m_runningOffset = 0; // since digits are already commonT0 calibrated
181 m_runningError = m_commonT0->getT0Error();
182 } else if (m_commonT0->isRoughlyCalibrated()) {
183 m_HLTmode = true;
184 m_runningOffset = m_commonT0->getT0(); // since digits are not commonT0 calibrated
185 m_runningError = m_commonT0->getT0Error();
186 } else {
187 m_HLTmode = true;
188 m_runningOffset = 0;
189 m_runningError = m_bunchTimeSep / sqrt(12.0);
190 }
191
192 if (m_HLTmode) {
193 m_nTrackLimit = 0; // use single particle hypothesis to save execution time
194 B2INFO("TOPBunchFinder: running in HLT/express reco mode");
195 } else {
196 B2INFO("TOPBunchFinder: running in data processing mode");
197 }
198
199 }

◆ initialize() [5/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 68 of file TOPCalPulseGeneratorModule.cc.

69 {
70 // Output
71
72 m_calPulses.registerInDataStore();
73
74 // prepare vectors to loop on
75
76 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
77
78 if (m_moduleIDs.empty()) {
79 for (const auto& module : geo->getModules()) {
80 m_moduleIDs.push_back(module.getModuleID());
81 }
82 } else {
83 for (auto moduleID : m_moduleIDs) {
84 if (!geo->isModuleIDValid(moduleID))
85 B2ERROR("Invalid module ID found in input list: " << moduleID);
86 }
87 }
88
89 if (m_asicChannels.empty()) {
90 for (unsigned ch = 0; ch < 8; ch++) m_asicChannels.push_back(ch);
91 } else {
92 for (unsigned ch : m_asicChannels) {
93 if (ch > 7)
94 B2ERROR("Invalid ASIC channel found in input list: " << ch);
95 }
96 }
97
98 }

◆ initialize() [6/33]

void initialize ( void )
overridevirtual

initialize method: registers datastore objects (the TOP hits)

Reimplemented from Module.

Definition at line 47 of file TOPChannelMaskerModule.cc.

48 {
49 // register data objects
50 m_digits.isRequired();
51 m_eventAsicMask.isOptional();
52 }

◆ initialize() [7/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 76 of file TOPChannelT0CalibratorModule.cc.

77 {
78 // input collections
79 m_digits.isRequired();
80 m_tracks.isRequired();
81 m_extHits.isRequired();
82 m_recBunch.isOptional();
83
84 // Parse PDF option
85 if (m_pdfOption == "rough") {
86 m_PDFOption = PDFConstructor::c_Rough;
87 } else if (m_pdfOption == "fine") {
88 m_PDFOption = PDFConstructor::c_Fine;
89 } else if (m_pdfOption == "optimal") {
90 m_PDFOption = PDFConstructor::c_Optimal;
91 } else {
92 B2ERROR("TOPPDFDebuggerModule: unknown PDF option '" << m_pdfOption << "'");
93 }
94
95 // set track selector
96 m_selector = TrackSelector(m_sample);
97 m_selector.setMinMomentum(m_minMomentum);
98 m_selector.setDeltaEcms(m_deltaEcms);
99 m_selector.setCutOnPOCA(m_dr, m_dz);
100 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
101
102 // minimum finders
103 double tmin = -m_timeRange / 2;
104 double tmax = m_timeRange / 2;
105 for (unsigned i = 0; i < 2; i++) {
106 for (unsigned m = 0; m < c_numModules; m++) {
107 for (unsigned c = 0; c < c_numChannels; c++) {
108 m_finders[i][m][c] = Chi2MinimumFinder1D(m_numBins, tmin, tmax);
109 }
110 }
111 }
112
113 // if file name includes *'s replace them with a run number
114 auto pos = m_outFileName.find("*");
115 if (pos != std::string::npos) {
116 StoreObjPtr<EventMetaData> evtMetaData;
117 auto run = std::to_string(evtMetaData->getRun());
118 while (run.size() < 5) run = "0" + run;
119 while (pos != std::string::npos) {
120 m_outFileName.replace(pos, 1, run);
121 pos = m_outFileName.find("*");
122 }
123 }
124
125 // open root file for ntuple and histogram output
126 m_file = TFile::Open(m_outFileName.c_str(), "RECREATE");
127 if (not m_file) {
128 B2ERROR("Cannot open output file '" << m_outFileName << "'");
129 return;
130 }
131
132 // histograms
133 for (unsigned module = 0; module < c_numModules; module++) {
134 int moduleID = module + 1;
135
136 std::string slotNum = std::to_string(moduleID);
137 if (moduleID < 10) slotNum = "0" + slotNum;
138
139 std::string name = "numHits_slot" + slotNum;
140 std::string title = "Number of hits per channel for slot " + slotNum;
141 TH1F h1(name.c_str(), title.c_str(), c_numChannels, 0, c_numChannels);
142 h1.SetXTitle("channel number");
143 h1.SetYTitle("hits per channel");
144 m_hits1D.push_back(h1);
145
146 name = "timeHits_slot" + slotNum;
147 title = "hit time vs. channel for slot " + slotNum;
148 TH2F h2(name.c_str(), title.c_str(), c_numChannels, 0, c_numChannels,
149 200, 0.0, 20.0);
150 h2.SetXTitle("channel number");
151 h2.SetYTitle("time [ns]");
152 m_hits2D.push_back(h2);
153 }
154
155 // create output tree
156
157 m_tree = new TTree("tree", "Channel T0 calibration results");
158 m_tree->Branch("slot", &m_moduleID);
159 m_tree->Branch("numPhotons", &m_numPhotons);
160 m_tree->Branch("x", &m_x);
161 m_tree->Branch("y", &m_y);
162 m_tree->Branch("z", &m_z);
163 m_tree->Branch("p", &m_p);
164 m_tree->Branch("theta", &m_theta);
165 m_tree->Branch("phi", &m_phi);
166 m_tree->Branch("r_poca", &m_pocaR);
167 m_tree->Branch("z_poca", &m_pocaZ);
168 m_tree->Branch("x_poca", &m_pocaX);
169 m_tree->Branch("y_poca", &m_pocaY);
170 m_tree->Branch("Ecms", &m_cmsE);
171 m_tree->Branch("charge", &m_charge);
172 m_tree->Branch("PDG", &m_PDG);
173
174 }

◆ initialize() [8/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 56 of file TOPChannelT0MCModule.cc.

57 {
58
59 m_digits.isRequired();
60
61 }

◆ initialize() [9/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 73 of file TOPCommonT0CalibratorModule.cc.

74 {
75 // input collections
76 m_digits.isRequired();
77 m_tracks.isRequired();
78 m_extHits.isRequired();
79 m_recBunch.isOptional();
80
81 // bunch separation in time
82
83 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
84 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / 24;
85
86 // Parse PDF option
87 if (m_pdfOption == "rough") {
88 m_PDFOption = PDFConstructor::c_Rough;
89 } else if (m_pdfOption == "fine") {
90 m_PDFOption = PDFConstructor::c_Fine;
91 } else if (m_pdfOption == "optimal") {
92 m_PDFOption = PDFConstructor::c_Optimal;
93 } else {
94 B2ERROR("TOPPDFDebuggerModule: unknown PDF option '" << m_pdfOption << "'");
95 }
96
97 // set track selector
98 m_selector = TrackSelector(m_sample);
99 m_selector.setMinMomentum(m_minMomentum);
100 m_selector.setDeltaEcms(m_deltaEcms);
101 m_selector.setCutOnPOCA(m_dr, m_dz);
102 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
103
104 // Chi2 minimum finders
105 double tmin = -m_timeRange / 2;
106 double tmax = m_timeRange / 2;
107 for (unsigned i = 0; i < c_numSets; i++) {
108 m_finders[i] = Chi2MinimumFinder1D(m_numBins, tmin, tmax);
109 }
110
111 // if file name includes *'s replace them with a run number
112 auto pos = m_outFileName.find("*");
113 if (pos != std::string::npos) {
114 StoreObjPtr<EventMetaData> evtMetaData;
115 auto run = std::to_string(evtMetaData->getRun());
116 while (run.size() < 5) run = "0" + run;
117 while (pos != std::string::npos) {
118 m_outFileName.replace(pos, 1, run);
119 pos = m_outFileName.find("*");
120 }
121 }
122
123 // open root file for ntuple and histogram output
124 m_file = TFile::Open(m_outFileName.c_str(), "RECREATE");
125 if (not m_file) {
126 B2ERROR("Cannot open output file '" << m_outFileName << "'");
127 return;
128 }
129
130 // control histograms
131 m_hits1D = TH1F("numHits", "Number of photons per slot",
132 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
133 m_hits1D.SetXTitle("slot number");
134 m_hits1D.SetYTitle("hits per slot");
135
136 m_hits2D = TH2F("timeHits", "Photon times vs. boardstacks",
137 c_numModules * 4, 0.5, static_cast<float>(c_numModules) + 0.5, 200, 0.0, 20.0);
138 m_hits2D.SetXTitle("slot number");
139 m_hits2D.SetYTitle("time [ns]");
140
141 // create output tree
142 m_tree = new TTree("tree", "Channel T0 calibration results");
143 m_tree->Branch("slot", &m_moduleID);
144 m_tree->Branch("numPhotons", &m_numPhotons);
145 m_tree->Branch("x", &m_x);
146 m_tree->Branch("y", &m_y);
147 m_tree->Branch("z", &m_z);
148 m_tree->Branch("p", &m_p);
149 m_tree->Branch("theta", &m_theta);
150 m_tree->Branch("phi", &m_phi);
151 m_tree->Branch("r_poca", &m_pocaR);
152 m_tree->Branch("z_poca", &m_pocaZ);
153 m_tree->Branch("x_poca", &m_pocaX);
154 m_tree->Branch("y_poca", &m_pocaY);
155 m_tree->Branch("Ecms", &m_cmsE);
156 m_tree->Branch("charge", &m_charge);
157 m_tree->Branch("PDG", &m_PDG);
158
159 }

◆ initialize() [10/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 78 of file TOPCosmicT0FinderModule.cc.

79 {
80 // input
81
82 StoreArray<TOPDigit> topDigits;
83 topDigits.isRequired();
84
85 StoreArray<Track> tracks;
86 tracks.isRequired();
87
88 StoreArray<ExtHit> extHits;
89 extHits.isRequired();
90
91 StoreArray<TOPBarHit> barHits;
92 barHits.isOptional();
93
94 // output
95
96 StoreArray<TOPTimeZero> timeZeros;
97 timeZeros.registerInDataStore();
98 timeZeros.registerRelationTo(tracks);
99 timeZeros.registerRelationTo(extHits);
100 timeZeros.registerRelationTo(barHits);
101 }

◆ initialize() [11/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 103 of file TOPDigitizerModule.cc.

104 {
105 // input from datastore
106 m_simHits.isRequired();
107 m_simCalPulses.isOptional();
108 m_mcParticles.isOptional();
109 m_simClockState.isOptional();
110
111 // output to datastore
112 m_rawDigits.registerInDataStore();
113 m_digits.registerInDataStore();
114 m_digits.registerRelationTo(m_simHits);
115 m_digits.registerRelationTo(m_mcParticles);
116 m_digits.registerRelationTo(m_rawDigits);
117 m_waveforms.registerInDataStore(DataStore::c_DontWriteOut);
118 m_rawDigits.registerRelationTo(m_waveforms, DataStore::c_Event,
119 DataStore::c_DontWriteOut);
120
121 // geometry and nominal data
122 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
123
124 if (m_electronicJitter < 0) {
125 m_electronicJitter = geo->getNominalTDC().getTimeJitter();
126 }
127
128 // set pile-up and double hit resolution times (needed for BG overlay)
129 TOPDigit::setDoubleHitResolution(geo->getNominalTDC().getDoubleHitResolution());
130 TOPDigit::setPileupTime(geo->getNominalTDC().getPileupTime());
131
132 // default sample times (equidistant)
133 m_syncTimeBase = geo->getNominalTDC().getSyncTimeBase();
134 m_sampleTimes.setTimeAxis(m_syncTimeBase); // equidistant time base
135
136 // default pulse height generator
137 m_pulseHeightGenerator = PulseHeightGenerator(m_ADCx0, m_ADCp1, m_ADCp2, m_ADCmax);
138
139 }

◆ initialize() [12/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 90 of file TOPDoublePulseGeneratorModule.cc.

91 {
92 // Output
93
94 StoreArray<TOPDigit> digits;
95 digits.registerInDataStore();
96
97 // prepare vectors to loop on
98
99 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
100
101 if (m_moduleIDs.empty()) {
102 for (const auto& module : geo->getModules()) {
103 m_moduleIDs.push_back(module.getModuleID());
104 }
105 } else {
106 for (auto moduleID : m_moduleIDs) {
107 if (!geo->isModuleIDValid(moduleID))
108 B2ERROR("Invalid module ID found in input list: " << moduleID);
109 }
110 }
111
112 if (m_asicChannels.empty()) {
113 for (unsigned ch = 0; ch < 8; ch++) m_asicChannels.push_back(ch);
114 } else {
115 for (unsigned ch : m_asicChannels) {
116 if (ch > 7)
117 B2ERROR("Invalid ASIC channel found in input list: " << ch);
118 }
119 }
120
121 // set sample times
122
123 double syncTimeBase = geo->getNominalTDC().getSyncTimeBase();
124 m_sampleTimes.setTimeAxis(syncTimeBase); // equidistant
125 m_sampleDivisions = (0x1 << geo->getNominalTDC().getSubBits());
126
127 if (m_useDatabase) {
128 m_timebase = new DBObjPtr<TOPCalTimebase>;
129 } else if (m_sampleTimeIntervals.empty()) {
130 B2INFO("TOPDoublePulseGenerator: using equidistant sample times");
131 } else if (m_sampleTimeIntervals.size() == 256) {
132 std::vector<double> timeAxis;
133 timeAxis.push_back(0);
134 for (auto dt : m_sampleTimeIntervals) timeAxis.push_back(dt + timeAxis.back());
135 double rescale = 2 * syncTimeBase / timeAxis.back();
136 for (auto& t : timeAxis) t *= rescale;
137 m_sampleTimes.setTimeAxis(timeAxis, syncTimeBase); // given by steering
138 B2INFO("TOPDoublePulseGenerator: using sample times from steering");
139 } else {
140 B2ERROR("sampleTimeIntervals: size must be 256 or empty");
141 }
142
143 if (!m_outputFileName.empty()) storeSampleTimes(m_outputFileName);
144
145 }

◆ initialize() [13/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

better use isRequired(), but RawFTSW is not in sim

Reimplemented from HistoModule.

Definition at line 291 of file TOPDQMModule.cc.

292 {
293 // Register histograms (calls back defineHisto)
294
295 REG_HISTOGRAM;
296
297 // register dataobjects
298
299 m_rawFTSWs.isOptional();
300 m_digits.isRequired();
301 m_recBunch.isOptional();
302 m_timeZeros.isOptional();
303 m_tracks.isOptional();
304
305 }

◆ initialize() [14/33]

void initialize ( void )
overridevirtual

Load time vs charge 2D histogram from a given input file (paramter "inputFile") and prepare hit timing and pulse charge distribution for each channel.

Reimplemented from HistoModule.

Definition at line 85 of file TOPGainEfficiencyCalculatorModule.cc.

86 {
87 REG_HISTOGRAM;
88 }

◆ initialize() [15/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 53 of file TOPGeometryParInitializerModule.cc.

54 {
55 auto* gp = TOPGeometryPar::Instance();
56 if (gp->isValid()) {
57 B2WARNING("TOPGeometryPar has already been initialized");
58 return;
59 }
60
61 if (m_useDB) {
62 gp->Initialize();
63 } else {
64 bool found = false;
65 GearDir detectorDir("/Detector");
66 for (const GearDir& component : detectorDir.getNodes("DetectorComponent")) {
67 if (component.getString("@name") == "TOP") {
68 gp->Initialize(GearDir(component, "Content"));
69 found = true;
70 break;
71 }
72 }
73 if (not found) B2ERROR("Component TOP does not exist or is empty");
74 }
75
76 }

◆ initialize() [16/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from HistoModule.

Definition at line 80 of file TOPInterimFENtupleModule.cc.

81 {
82 REG_HISTOGRAM;
83
84 StoreArray<RawTOP> rawTOPs;
85 rawTOPs.isRequired();
86 StoreArray<TOPRawDigit> rawDigits;
87 rawDigits.isRequired();
88 StoreArray<TOPDigit> digits;
89 digits.isRequired();
90 StoreArray<TOPInterimFEInfo> infos;
91 infos.isRequired();
92 StoreArray<TOPProductionEventDebug> prodDebugs;
93 prodDebugs.isRequired();
94 StoreArray<TOPRawWaveform> waveforms;
95 waveforms.isRequired();
96 }

◆ initialize() [17/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 75 of file TOPLaserCalibratorModule.cc.

76 {
77 B2WARNING("You are using an old version of the laser fitter, now deprecated. This module has been superseded by the CAF collector TOPLaserCalibratorCollector and the CAF fitter TOPLocalCalFitter.");
78 m_digits.isRequired();
79 }

◆ initialize() [18/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from HistoModule.

Definition at line 94 of file TOPLaserHitSelectorModule.cc.

95 {
96 REG_HISTOGRAM;
97
98 StoreArray<TOPDigit> digits;
99 digits.isRequired();
100 }

◆ initialize() [19/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 61 of file TOPMCTrackMakerModule.cc.

62 {
63
64 // input
65
66 StoreArray<MCParticle> mcParticles;
67 mcParticles.isRequired();
68
69 StoreArray<TOPBarHit> barHits;
70 barHits.isRequired();
71
72 // output
73
74 StoreArray<Track> tracks;
75 tracks.registerInDataStore();
76
77 StoreArray<TrackFitResult> fitResults;
78 fitResults.registerInDataStore();
79
80 StoreArray<ExtHit> extHits;
81 extHits.registerInDataStore();
82
83 tracks.registerRelationTo(mcParticles);
84 tracks.registerRelationTo(extHits);
85
86 }

◆ initialize() [20/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 72 of file TOPModuleT0CalibratorModule.cc.

73 {
74 // input collections
75 m_digits.isRequired();
76 m_tracks.isRequired();
77 m_extHits.isRequired();
78 m_recBunch.isOptional();
79
80 // toggle has changed status to prevent warning in beginRun for the first IOV
81 m_moduleT0.hasChanged();
82
83 // Parse PDF option
84 if (m_pdfOption == "rough") {
85 m_PDFOption = PDFConstructor::c_Rough;
86 } else if (m_pdfOption == "fine") {
87 m_PDFOption = PDFConstructor::c_Fine;
88 } else if (m_pdfOption == "optimal") {
89 m_PDFOption = PDFConstructor::c_Optimal;
90 } else {
91 B2ERROR("TOPPDFDebuggerModule: unknown PDF option '" << m_pdfOption << "'");
92 }
93
94 // set track selector
95 m_selector = TrackSelector(m_sample);
96 m_selector.setMinMomentum(m_minMomentum);
97 m_selector.setDeltaEcms(m_deltaEcms);
98 m_selector.setCutOnPOCA(m_dr, m_dz);
99 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
100
101 // Chi2 minimum finders
102 double tmin = -m_timeRange / 2;
103 double tmax = m_timeRange / 2;
104 for (unsigned i = 0; i < 2; i++) {
105 for (unsigned m = 0; m < c_numModules; m++) {
106 m_finders[i][m] = Chi2MinimumFinder1D(m_numBins, tmin, tmax);
107 }
108 }
109
110 // if file name includes *'s replace them with a run number
111 auto pos = m_outFileName.find("*");
112 if (pos != std::string::npos) {
113 StoreObjPtr<EventMetaData> evtMetaData;
114 auto run = std::to_string(evtMetaData->getRun());
115 while (run.size() < 5) run = "0" + run;
116 while (pos != std::string::npos) {
117 m_outFileName.replace(pos, 1, run);
118 pos = m_outFileName.find("*");
119 }
120 }
121
122 // open root file for ntuple and histogram output
123 m_file = TFile::Open(m_outFileName.c_str(), "RECREATE");
124 if (not m_file) {
125 B2ERROR("Cannot open output file '" << m_outFileName << "'");
126 return;
127 }
128
129 // histograms
130 m_hits1D = TH1F("numHits", "Number of photons per slot",
131 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
132 m_hits1D.SetXTitle("slot number");
133 m_hits1D.SetYTitle("hits per slot");
134
135 m_hits2D = TH2F("timeHits", "Photon times vs. boardstacks",
136 c_numModules * 4, 0.5, static_cast<float>(c_numModules) + 0.5, 200, 0.0, 20.0);
137 m_hits2D.SetXTitle("slot number");
138 m_hits2D.SetYTitle("time [ns]");
139
140 // create output tree
141 m_tree = new TTree("tree", "Channel T0 calibration results");
142 m_tree->Branch("slot", &m_moduleID);
143 m_tree->Branch("numPhotons", &m_numPhotons);
144 m_tree->Branch("x", &m_x);
145 m_tree->Branch("y", &m_y);
146 m_tree->Branch("z", &m_z);
147 m_tree->Branch("p", &m_p);
148 m_tree->Branch("theta", &m_theta);
149 m_tree->Branch("phi", &m_phi);
150 m_tree->Branch("r_poca", &m_pocaR);
151 m_tree->Branch("z_poca", &m_pocaZ);
152 m_tree->Branch("x_poca", &m_pocaX);
153 m_tree->Branch("y_poca", &m_pocaY);
154 m_tree->Branch("Ecms", &m_cmsE);
155 m_tree->Branch("charge", &m_charge);
156 m_tree->Branch("PDG", &m_PDG);
157
158 }

◆ initialize() [21/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 72 of file TOPNtupleModule.cc.

73 {
74 TDirectory::TContext context;
75 m_file = TFile::Open(m_outputFileName.c_str(), "RECREATE");
76 if (m_file->IsZombie()) {
77 B2FATAL("Couldn't open file '" << m_outputFileName << "' for writing!");
78 return;
79 }
80
81 m_tree = new TTree("top", "TOP validation ntuple");
82
83 m_tree->Branch("evt", &m_top.evt, "evt/I");
84 m_tree->Branch("run", &m_top.run, "run/I");
85
86 m_tree->Branch("p", &m_top.p, "p/F");
87 m_tree->Branch("cth", &m_top.cth, "cth/F");
88 m_tree->Branch("phi", &m_top.phi, "phi/F");
89 m_tree->Branch("pValue", &m_top.pValue, "pValue/F");
90
91 m_tree->Branch("PDG", &m_top.PDG, "PDG/I");
92 m_tree->Branch("motherPDG", &m_top.motherPDG, "motherPDG/I");
93 m_tree->Branch("primary", &m_top.primary, "primary/S");
94 m_tree->Branch("seen", &m_top.seen, "seen/S");
95 m_tree->Branch("rhoProd", &m_top.rhoProd, "rhoProd/F");
96 m_tree->Branch("zProd", &m_top.zProd, "zProd/F");
97 m_tree->Branch("phiProd", &m_top.phiProd, "phiProd/F");
98 m_tree->Branch("rhoDec", &m_top.rhoDec, "rhoDec/F");
99 m_tree->Branch("zDec", &m_top.zDec, "zDec/F");
100 m_tree->Branch("phiDec", &m_top.phiDec, "phiDec/F");
101 m_tree->Branch("yieldMC", &m_top.yieldMC, "yieldMC/I");
102
103 m_tree->Branch("numPhot", &m_top.numPhot, "numPhot/I");
104 m_tree->Branch("numBkg", &m_top.numBkg, "numBkg/F");
105 m_tree->Branch("moduleID", &m_top.moduleID, "moduleID/I");
106 m_tree->Branch("phot", &m_top.phot, "e/F:mu:pi:K:p:d");
107 m_tree->Branch("yield", &m_top.yield, "e/F:mu:pi:K:p:d");
108 m_tree->Branch("logL", &m_top.logL, "e/F:mu:pi:K:p:d");
109
110 m_tree->Branch("extHit", &m_top.extHit, "moduleID/I:PDG:x/F:y:z:p:theta:phi:time");
111 m_tree->Branch("barHit", &m_top.barHit, "moduleID/I:PDG:x/F:y:z:p:theta:phi:time");
112
113 StoreArray<Track> tracks;
114 tracks.isRequired();
115 StoreArray<ExtHit> extHits;
116 extHits.isRequired();
117 StoreArray<TOPLikelihood> likelihoods;
118 likelihoods.isRequired();
119 StoreArray<MCParticle> mcParticles;
120 mcParticles.isOptional();
121 StoreArray<TOPBarHit> barHits;
122 barHits.isOptional();
123 StoreObjPtr<MCInitialParticles> mcInitialParticles;
124 mcInitialParticles.isOptional();
125 }

◆ initialize() [22/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 70 of file TOPPackerModule.cc.

71 {
72
73 if (m_format == "draft") {
74 m_dataType = TOP::RawDataType::c_Draft;
75 StoreArray<TOPDigit> digits(m_inputDigitsName);
76 digits.isRequired();
77 } else if (m_format == "FE") {
78 m_dataType = TOP::RawDataType::c_Type0Ver16;
79 StoreArray<TOPRawDigit> rawDigits(m_inputRawDigitsName);
80 rawDigits.isRequired();
81 } else if (m_format == "production") {
82 m_dataType = TOP::RawDataType::c_ProductionDebug01;
83 StoreArray<TOPRawDigit> rawDigits(m_inputRawDigitsName);
84 rawDigits.isRequired();
85 } else {
86 B2ERROR("TOPPacker: unknown data format."
87 << LogVar("format", m_format));
88 }
89
90 StoreArray<RawTOP> rawData(m_outputRawDataName);
91 rawData.registerInDataStore();
92
93 // check if front end mappings are available
94 const auto& mapper = m_topgp->getFrontEndMapper();
95 if (!mapper.isValid()) B2ERROR("No front-end mapping available for TOP");
96
97 }

◆ initialize() [23/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from HistoModule.

Definition at line 96 of file TOPPDFCheckerModule.cc.

97 {
98 // Register histograms (calls back defineHisto)
99 REG_HISTOGRAM;
100
101 // input
102
103 m_digits.isRequired();
104 m_tracks.isRequired();
105
106 StoreArray<ExtHit> extHits;
107 extHits.isRequired();
108
109 StoreArray<MCParticle> mcParticles;
110 mcParticles.isRequired();
111
112 StoreArray<TOPBarHit> barHits;
113 barHits.isRequired();
114
115 }

◆ initialize() [24/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 72 of file TOPPDFDebuggerModule.cc.

73 {
74 // input
75 m_digits.isRequired();
76 m_tracks.isRequired();
77
78 StoreArray<ExtHit> extHits;
79 extHits.isRequired();
80
81 StoreArray<MCParticle> mcParticles;
82 mcParticles.isOptional();
83
84 StoreArray<TOPBarHit> barHits;
85 barHits.isOptional();
86
87 // output
88 m_pdfCollection.registerInDataStore();
89 m_tracks.registerRelationTo(m_pdfCollection);
90 m_associatedPDFs.registerInDataStore();
91 m_digits.registerRelationTo(m_associatedPDFs);
92 m_pixelData.registerInDataStore();
93 m_tracks.registerRelationTo(m_pixelData);
94
95 // particle hypotheses
96 if (m_pdgCodes.empty()) {
97 for (const auto& part : Const::chargedStableSet) {
98 m_chargedStables.push_back(part);
99 }
100 } else {
101 for (auto pdg : m_pdgCodes) {
102 auto part = Const::ChargedStable(abs(pdg)); //throws runtime error for invalid pdg
103 m_chargedStables.push_back(part);
104 }
105 }
106
107 // Parse PDF option
108 if (m_pdfOption == "rough") {
109 m_PDFOption = PDFConstructor::c_Rough;
110 } else if (m_pdfOption == "fine") {
111 m_PDFOption = PDFConstructor::c_Fine;
112 } else if (m_pdfOption == "optimal") {
113 m_PDFOption = PDFConstructor::c_Optimal;
114 } else {
115 B2ERROR("TOPPDFDebuggerModule: unknown PDF option '" << m_pdfOption << "'");
116 }
117
118 }

◆ initialize() [25/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 114 of file TOPRawDigitConverterModule.cc.

115 {
116
117 // registration of objects in datastore
118 m_rawDigits.isRequired(m_inputRawDigitsName);
119 m_eventDebugs.isOptional();
120 m_digits.registerInDataStore(m_outputDigitsName);
121 m_digits.registerRelationTo(m_rawDigits);
122 m_asicMask.registerInDataStore();
123
124 // equidistant sample times in case calibration is not required
125 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
126 m_syncTimeBase = geo->getNominalTDC().getSyncTimeBase();
127 m_sampleTimes.setTimeAxis(m_syncTimeBase);
128
129 }

◆ initialize() [26/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 69 of file TOPReconstructorModule.cc.

70 {
71 // input
72
73 m_digits.isRequired(m_topDigitCollectionName);
74 m_tracks.isRequired();
75 m_extHits.isRequired();
76 m_barHits.isOptional();
77 m_recBunch.isOptional();
78
79 // output
80
81 m_likelihoods.registerInDataStore(m_topLikelihoodCollectionName);
82 m_likelihoods.registerRelationTo(m_extHits);
83 m_likelihoods.registerRelationTo(m_barHits);
84 m_tracks.registerRelationTo(m_likelihoods);
85
86 m_topPulls.registerInDataStore(m_topPullCollectionName, DataStore::c_DontWriteOut);
87 m_tracks.registerRelationTo(m_topPulls, DataStore::c_Event, DataStore::c_DontWriteOut);
88 }

◆ initialize() [27/33]

void initialize ( void )
overridevirtual

Initialize the module.

Reimplemented from HistoModule.

Definition at line 336 of file TOPTBCComparatorModule.cc.

337 {
338 REG_HISTOGRAM;
339 }

◆ initialize() [28/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 106 of file TOPTimeBaseCalibratorModule.cc.

107 {
108
109 // input
110 m_digits.isRequired();
111
112 // checks
113 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
114 if (!geo->isModuleIDValid(m_moduleID))
115 B2ERROR("Invalid module ID: " << m_moduleID);
116
117 // check for existance and mkdir if not
118 if (m_directoryName.empty()) m_directoryName = "./";
119 if (m_directoryName != "./") gSystem->mkdir(m_directoryName.c_str(), kTRUE);
120
121 // synchronization time corresponding to two ASIC windows
122 m_syncTimeBase = geo->getNominalTDC().getSyncTimeBase();
123
124 // control histograms
125 m_goodHits = TH2F("goodHits", "pulse height vs. pulse width of all good hits",
126 100, 0, 10, 100, 0, 2000);
127 m_goodHits.SetXTitle("pulse width (FWHM) [ns]");
128 m_goodHits.SetYTitle("pulse height [ADC counts]");
129 m_calPulseFirst = TH2F("calPulseFirst",
130 "pulse height vs. pulse width of the first calibration pulse",
131 100, 0, 10, 100, 0, 2000);
132 m_calPulseFirst.SetXTitle("pulse width (FWHM) [ns]");
133 m_calPulseFirst.SetYTitle("pulse height [ADC counts]");
134 m_calPulseSecond = TH2F("calPulseSecond",
135 "pulse height vs. pulse width of the second calibration pulse",
136 100, 0, 10, 100, 0, 2000);
137 m_calPulseSecond.SetXTitle("pulse width (FWHM) [ns]");
138 m_calPulseSecond.SetYTitle("pulse height [ADC counts]");
139
140 }

◆ initialize() [29/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 71 of file TOPTimeRecalibratorModule.cc.

72 {
73
74 // registration of objects in datastore
75 m_digits.isRequired();
76 m_recBunch.isRequired();
77
78 // equidistant sample times in case calibration is not required
79 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
80 m_syncTimeBase = geo->getNominalTDC().getSyncTimeBase();
81 m_sampleTimes.setTimeAxis(m_syncTimeBase);
82
83 }

◆ initialize() [30/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 68 of file TOPTriggerDigitizerModule.cc.

69 {
70 // input
71 StoreArray<TOPRawWaveform> waveforms;
72 waveforms.isRequired();
73
74 // output
75 StoreArray<TOPTriggerDigit> digits;
76 digits.registerInDataStore();
77 digits.registerRelationTo(waveforms);
78 StoreObjPtr<TOPTriggerMCInfo> mcInfo;
79 mcInfo.registerInDataStore();
80
81 if (m_samplingPhase < 0 or m_samplingPhase >= c_SamplingCycle)
82 B2ERROR("samplingPhase must be positive and less than " << c_SamplingCycle);
83
84 }

◆ initialize() [31/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 82 of file TOPUnpackerModule.cc.

83 {
84
85 // input
86
87 m_rawData.isRequired(m_inputRawDataName);
88
89 // output
90
91 m_digits.registerInDataStore(m_outputDigitsName);
92 m_rawDigits.registerInDataStore(m_outputRawDigitsName);
93 m_slowData.registerInDataStore();
94 m_interimFEInfos.registerInDataStore(DataStore::c_DontWriteOut);
95 m_waveforms.registerInDataStore(m_outputWaveformsName, DataStore::c_DontWriteOut);
96 m_productionEventDebugs.registerInDataStore(DataStore::c_DontWriteOut);
97 m_productionHitDebugs.registerInDataStore(DataStore::c_DontWriteOut);
98 m_templateFitResults.registerInDataStore(m_templateFitResultName, DataStore::c_DontWriteOut);
99
100 m_rawDigits.registerRelationTo(m_waveforms, DataStore::c_Event, DataStore::c_DontWriteOut);
101 m_rawDigits.registerRelationTo(m_templateFitResults, DataStore::c_Event, DataStore::c_DontWriteOut);
102 m_rawDigits.registerRelationTo(m_interimFEInfos, DataStore::c_Event, DataStore::c_DontWriteOut);
103 m_rawDigits.registerRelationTo(m_productionHitDebugs, DataStore::c_Event, DataStore::c_DontWriteOut);
104 m_waveforms.registerRelationTo(m_interimFEInfos, DataStore::c_Event, DataStore::c_DontWriteOut);
105
106 // check if front end mappings are available
107 const auto& mapper = m_topgp->getFrontEndMapper();
108 int mapSize = mapper.getMapSize();
109 if (mapSize == 0) B2ERROR("TOPUnpacker: No front-end mapping available for TOP");
110
111 }

◆ initialize() [32/33]

void initialize ( void )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 70 of file TOPWaveformFeatureExtractorModule.cc.

71 {
72
73 StoreArray<TOPRawDigit> rawDigits(m_inputRawDigitsName);
74 rawDigits.isRequired();
75
76 }

◆ initialize() [33/33]

void initialize ( void )
overridevirtual

Module initialization, calls defineHisto and gets waveform.

Reimplemented from HistoModule.

Definition at line 72 of file TOPWaveformQualityPlotterModule.cc.

73 {
74 // Register histograms (calls back defineHisto)
75 REG_HISTOGRAM;
76 //Get Waveform from datastore
77 m_waveform.isRequired();
78 }

◆ isBucketFilled()

bool isBucketFilled ( int bunchNo)
private

Does reconstructed bunch number correspond to filled bucket.

Parameters
bunchNoreconstructed relative bunch number
Returns
true if filled

Definition at line 670 of file TOPBunchFinderModule.cc.

671 {
672 // return true if needed information is not available or fill pattern offset is not calibrated
673
674 if (not m_bunchStructure->isSet()) return true;
675 if (m_revo9Counter == 0xFFFF) return true;
676 if (not m_fillPatternOffset.isValid()) return true;
677 if (not m_fillPatternOffset->isCalibrated()) return true;
678
679 // fill pattern offset; it is always zero on MC, because we are not simulating it
680
681 int offset = m_isMC ? 0 : m_fillPatternOffset->get();
682
683 // corresponding bucket number and fill status
684
685 int RFBuckets = m_bunchStructure->getRFBucketsPerRevolution();
686 int bucket = TOPRecBunch::getBucketNumber(bunchNo, m_revo9Counter, offset, RFBuckets);
687 bool isFilled = m_bunchStructure->getBucket(bucket);
688
689 // store them in TOPRecBunch
690
691 m_recBunch->setBucketNumber(bucket);
692 m_recBunch->setBucketFillStatus(isFilled);
693
694 return isFilled;
695 }

◆ isFromThisParticle()

bool isFromThisParticle ( const TOPDigit & digit,
const MCParticle * particle )
private

Checks if digit comes from given MC particle.

Parameters
digitTOP digit
particleMC particle

Definition at line 207 of file TOPPDFCheckerModule.cc.

209 {
210 const auto particles = digit.getRelationsWith<MCParticle>();
211 for (unsigned i = 0; i < particles.size(); ++i) {
212 if (particles[i] == particle and particles.weight(i) > 0) return true;
213 }
214 return false;
215 }

◆ isInsideSlit()

bool isInsideSlit ( const ROOT::Math::XYZPoint & point,
const ROOT::Math::XYZVector & direction ) const
private

Checks if photon passes the slit.

Parameters
pointphoton emission point
directionphoton emission direction
Returns
true on success

Definition at line 218 of file OpticalGunModule.cc.

220 {
221 if (m_slitZ < 0.01) return true; // no screen with a slit is put infront of a source
222 if (direction.Z() < 1.0e-6) return false; // must fly toward the slit
223
224 double pathLength = (m_slitZ - point.Z()) / direction.Z();
225 if (m_slitDX > 0) {
226 double x = point.X() + pathLength * direction.X();
227 if (abs(x - m_slitX0) > m_slitDX / 2.0) return false;
228 }
229 if (m_slitDY > 0) {
230 double y = point.Y() + pathLength * direction.Y();
231 if (abs(y - m_slitY0) > m_slitDY / 2.0) return false;
232 }
233
234 return true;
235 }

◆ isRunningOffsetSubtracted() [1/2]

bool isRunningOffsetSubtracted ( )
private

Checks if running offset is subtracted in TOPDigits.

Returns
true if subtracted at least in one digit

Definition at line 305 of file TOPCommonT0CalibratorModule.cc.

306 {
307 for (const auto& digit : m_digits) {
308 if (digit.hasStatus(TOPDigit::c_BunchOffsetSubtracted)) return true;
309 }
310 return false;
311 }

◆ isRunningOffsetSubtracted() [2/2]

bool isRunningOffsetSubtracted ( )
private

Checks if running offset is subtracted in TOPDigits.

Returns
true if subtracted at least in one digit

Definition at line 333 of file TOPModuleT0CalibratorModule.cc.

334 {
335 for (const auto& digit : m_digits) {
336 if (digit.hasStatus(TOPDigit::c_BunchOffsetSubtracted)) return true;
337 }
338 return false;
339 }

◆ Iteration()

void Iteration ( const std::vector< TwoTimes > & ntuple,
std::vector< double > & xval )
private

Iteration function called by iterativeTBC()

Parameters
ntuplentuple data
xvalTBC constants of 256 samples, time interval is the difference of nearby xvals, xval[0]=0 and xval[256]=2*m_syncTimeBase

Definition at line 623 of file TOPTimeBaseCalibratorModule.cc.

624 {
625 for (int i = 0; i < c_TimeAxisSize; i++) {
626 double wdth = xval[i + 1] - xval[i];
627 if (wdth < m_min_binwidth) {
628 xval[i] = xval[i] - 0.5 * fabs(wdth) - 0.5 * m_min_binwidth;
629 xval[i + 1] = xval[i + 1] + 0.5 * fabs(wdth) + 0.5 * m_min_binwidth;
630 }
631 if (wdth > m_max_binwidth) {
632 xval[i] = xval[i] - 0.5 * fabs(wdth) - 0.5 * m_max_binwidth;
633 xval[i + 1] = xval[i + 1] + 0.5 * fabs(wdth) + 0.5 * m_max_binwidth;
634 }
635 }
636
637 if (xval[0] != 0)
638 for (int i = 0; i < c_TimeAxisSize; i++) xval[i] = xval[i] - xval[0];
639
640 std::vector<double> xxval(c_TimeAxisSize + 1, 0.0);
641 for (int i = 0; i < c_TimeAxisSize + 1; i++) xxval[i] = xval[i];
642
643 double chi2_0 = Chisq(ntuple, xxval);
644 if (chi2_0 < 0) B2ERROR("iTBC chisq_0<0! xval has problem.");
645
646 std::vector<double> dr_chi2(c_TimeAxisSize + 1, 0.0);
647 TH1D hdrsamp_try("hdrsamp_try", "dchi2/dx distribution", 100, -0.01, 0.01);
648
649 for (int smp = 1; smp < c_TimeAxisSize; smp++) {
650 xxval[smp] = xval[smp] + m_dev_step;
651 double chi2_ch = Chisq(ntuple, xxval);
652 if (chi2_ch < 0)continue;
653 dr_chi2[smp] = (chi2_ch - chi2_0) / m_dev_step;
654 hdrsamp_try.Fill(dr_chi2[smp]);
655 xxval[smp] = xval[smp];
656 }
657
658 for (int smp = 1; smp < c_TimeAxisSize; smp++) {
659 double vx_it_step = dr_chi2[smp] * m_xstep;
660 xval[smp] = xval[smp] - vx_it_step;
661 }
662
663 //save rms of dchi2/dxval.
664 m_dchi2dxv = hdrsamp_try.GetRMS();
665 //change m_xstep
666 if (fabs(m_dchi2dxv) < m_change_xstep) m_xstep = m_new_xstep;
667 }

◆ iterativeTBC()

bool iterativeTBC ( const std::vector< TwoTimes > & ntuple,
unsigned scrodID,
unsigned scrodChannel,
double meanTimeDifference,
TH1F & Hchi2,
TH1F & Hndf,
TH1F & HDeltaT )
private

Method by iteration of chi2 minimization.

Parameters
ntuplentuple data
scrodIDSCROD ID
scrodChannelchannel number within SCROD (0 - 127)
meanTimeDifferenceaverage time difference [samples]
Hchi2histogram to store normalized chi^2
Hndfhistogram to store degrees of freedom
HDeltaThistogram to store fittet double pulse delay
Returns
true on success

Definition at line 538 of file TOPTimeBaseCalibratorModule.cc.

543 {
544 std::vector<double> xval(c_TimeAxisSize + 1, 0.0);
545 double wx = 2 * m_syncTimeBase / static_cast<double>(c_TimeAxisSize);
546 for (int i = 0; i < c_TimeAxisSize + 1; i++) xval[i] = i * wx;
547
548 B2INFO("TimeBaseCalibration starts for channel#" << chan);
549
550 double pre_chi2 = 10000000.0;
551 unsigned num_small_dev = 0;
552
553 for (unsigned j = 0; j < m_numIterations; j++) {
554
555 Iteration(ntuple, xval);
556 double this_chi2 = Chisq(ntuple, xval);
557 if (this_chi2 < 0)continue;
558 double deltaChi2 = pre_chi2 - this_chi2;
559 if (deltaChi2 < -m_dchi2_min) break;
560 if (fabs(deltaChi2) < m_deltamin) num_small_dev++;
561 if (num_small_dev > m_conv_iter) break;
562 pre_chi2 = this_chi2;
563 }
564
565 // calculate chi^2
566
567 double chi2 = Chisq(ntuple, xval);
568 Hchi2.SetBinContent(chan + 1, chi2);
569 Hndf.SetBinContent(chan + 1, m_good);
570
571 // constrain sum of x to 2*syncTimeBase and calculate sample times, not necessary here
572
573 double sum = 0;
574 for (auto xi : xval) sum += xi;
575 if (sum == 0) {
576 B2ERROR("sum == 0");
577 return false;
578 }
579
580 double DeltaT = meanTimeDifference * (2 * m_syncTimeBase / static_cast<double>(c_TimeAxisSize));
581 HDeltaT.SetBinContent(chan + 1, DeltaT);
582
583 std::vector<double> timeInterval;
584 for (int i = 0; i < c_TimeAxisSize; i++)timeInterval.push_back(xval[i + 1] - xval[i]);
585
586
587 std::vector<double> sampleTimes;
588 for (auto xi : xval) sampleTimes.push_back(xi);
589
590 // save results as histograms
591 std::string forWhat = "scrod " + to_string(scrodID) + " channel " + to_string(chan);
592 saveAsHistogram(timeInterval, "dt_ch" + to_string(chan), "Sample time bins for " + forWhat,
593 "sample number", "#Delta t [ns]");
594 saveAsHistogram(sampleTimes, "sampleTimes_ch" + to_string(chan),
595 "Time base corrections for " + forWhat, "sample number", "t [ns]");
596
597 // calibrated cal pulse time difference
598 std::string name = "timeDiffcal_ch" + to_string(chan);
599 std::string title = "Calibrated cal pulse time difference vs. sample for " + forWhat;
600 TH2F Hcor(name.c_str(), title.c_str(), c_TimeAxisSize, 0, c_TimeAxisSize,
601 100, DeltaT - 0.5, DeltaT + 0.5);
602 Hcor.SetXTitle("sample number");
603 Hcor.SetYTitle("time difference [ns]");
604 Hcor.SetStats(kTRUE);
605
606 TOPSampleTimes timeBase;
607 timeBase.setTimeAxis(sampleTimes, sampleTimes.back() / 2);
608
609 for (const auto& twoTimes : ntuple) {
610 if (!twoTimes.good) continue;
611 double dt = timeBase.getDeltaTime(0, twoTimes.t2, twoTimes.t1);
612 int sample = int(twoTimes.t1) % c_TimeAxisSize;
613 Hcor.Fill(sample, dt);
614 }
615 Hcor.Write();
616
617 B2INFO("... channel " << chan << " OK (chi^2/ndf = " << chi2
618 << ", ndf = " << m_good << ")");
619
620 return true;
621 }

◆ LoadHistograms()

void LoadHistograms ( const std::string & histotype)

Load 2D histograms from a given input file (output of TOPLaserHitSelector) and create timing and charge distribution as projection histograms for the x- and y-axis, respectively.

Timing cut is also applied for charge distributiion

Definition at line 218 of file TOPGainEfficiencyCalculatorModule.cc.

219 {
220
221 TFile* f = new TFile(m_inputFile.c_str());
222 if (!f->IsOpen()) {
223 B2ERROR("TOPGainEfficiencyCalculator : fail to open input file \"" << m_inputFile << "\"");
224 return;
225 }
226
227 for (int iHisto = 0 ; iHisto < c_NChannelPerPMT ; iHisto++) {
228 if (m_targetPmtChId != -1 && iHisto + 1 != m_targetPmtChId) continue;
229 std::ostringstream pixelstr;
230 pixelstr << histotype << "_"
231 << "s" << std::setw(2) << std::setfill('0') << m_targetSlotId << "_PMT"
232 << std::setw(2) << std::setfill('0') << m_targetPmtId
233 << "_" << std::setw(2) << std::setfill('0') << (iHisto + 1);
234 std::ostringstream hname;
235 hname << "hTime" << pixelstr.str();
236
237 //first get 2D histogram from a given input (=an output file of TOPLaserHitSelector)
238 m_timeChargeHistogram[iHisto] = (TH2F*)f->Get(hname.str().c_str());
239 TH2F* h2D = m_timeChargeHistogram[iHisto];
240 if (!h2D) continue;
241
242 //create a projection histogram along the x-axis and fit the distribution (hit timing) to get direct laser hit timing
243 std::ostringstream hnameProj[2];
244 hnameProj[0] << "hTime_" << pixelstr.str();
245 hnameProj[1] << "hCharge_" << pixelstr.str();
246 TH1D* hTime = (TH1D*)h2D->ProjectionX(hnameProj[0].str().c_str());
247 m_timeHistogram[iHisto] = hTime;
248 double peakTime = FindPeakForSmallerXThan(hTime, 0);
249 //double peakTime = hTime->GetXaxis()->GetBinCenter(hTime->GetMaximumBin());
250 double fitMin = peakTime - m_fitHalfWidth;
251 double fitMax = peakTime + m_fitHalfWidth;
252 TF1* funcLaser = new TF1(std::string(std::string("func_") + hnameProj[1].str()).c_str(),
253 "gaus(0)", fitMin, fitMax);
254 funcLaser->SetParameters(hTime->GetBinContent(hTime->GetXaxis()->FindBin(peakTime)), peakTime, m_fitHalfWidth);
255 funcLaser->SetParLimits(1, fitMin, fitMax);
256 hTime->Fit(funcLaser, "Q", "", fitMin, fitMax);
257 //if (funcLaser->GetNDF() < 1) continue;
258 m_funcForLaser[iHisto] = funcLaser;
259
260 //if the fitting is successful, create y-projection histogram with timing cut
261 m_hitTiming = funcLaser->GetParameter(1);
262 int binNumMin = hTime->GetXaxis()->FindBin(m_hitTiming - 2 * m_fitHalfWidth);
263 int binNumMax = hTime->GetXaxis()->FindBin(m_hitTiming + 2 * m_fitHalfWidth);
264 TH1D* hCharge = (TH1D*)h2D->ProjectionY(hnameProj[1].str().c_str(),
265 binNumMin, binNumMax);
266 m_chargeHistogram[iHisto] = hCharge;
267 }
268
269 m_nCalPulseHistogram = (TH1F*)f->Get("hNCalPulse");
270 if (!m_nCalPulseHistogram)
271 B2WARNING("TOPGainEfficiencyCalculator : no histogram for the number of events with calibration pulses identified in the given input file");
272 m_thresholdForIntegral = m_threshold * m_p1HeightIntegral + m_p0HeightIntegral;
273 return;
274 }

◆ makeComparisons()

int makeComparisons ( )

Last function to be called, compared the histograms of different datasets filled by analyzeCalFile() Every new comparison histogram added to the module has to be filled here.

Definition at line 301 of file TOPTBCComparatorModule.cc.

302 {
303 // Set to compare with
304 short refSet = 0;
305 B2INFO("Making comparisons for " << m_totCalSets << " sets.");
306
307 // Loop over the sets. Do not make the comparison for the set #0
308 for (int iSet = 1; iSet < m_totCalSets; iSet++) {
309 if (m_compareToPreviousSet) refSet = iSet - 1;
310
311 m_topAverageDeltaTComparison[iSet] = calculateHistoRatio(m_topAverageDeltaTComparison[iSet], m_topAverageDeltaT[iSet],
312 m_topAverageDeltaT[refSet]);
313 m_topSigmaDeltaTComparison[iSet] = calculateHistoRatio(m_topSigmaDeltaTComparison[iSet], m_topSigmaDeltaT[iSet],
314 m_topSigmaDeltaT[refSet]);
315 m_topSampleOccupancyComparison[iSet] = calculateHistoRatio(m_topSampleOccupancyComparison[iSet], m_topSampleOccupancy[iSet],
316 m_topSampleOccupancy[refSet]);
317
318 // Loop over the sets. Do not make the comparison for the set #0
319 for (int iSlot = 0; iSlot < 16; iSlot++) {
320 m_slotAverageDeltaTComparison[iSlot][iSet] = calculateHistoRatio(m_slotAverageDeltaTComparison[iSlot][iSet],
321 m_slotAverageDeltaT[iSlot][iSet], m_slotAverageDeltaT[iSlot][refSet]);
322 m_slotAverageDeltaTMapComparison[iSlot][iSet] = calculateHistoRatio(m_slotAverageDeltaTMapComparison[iSlot][iSet],
323 m_slotAverageDeltaTMap[iSlot][iSet], m_slotAverageDeltaTMap[iSlot][refSet]);
324 m_slotSigmaDeltaTComparison[iSlot][iSet] = calculateHistoRatio(m_slotSigmaDeltaTComparison[iSlot][iSet],
325 m_slotSigmaDeltaT[iSlot][iSet], m_slotSigmaDeltaT[iSlot][refSet]);
326 m_slotSigmaDeltaTMapComparison[iSlot][iSet] = calculateHistoRatio(m_slotSigmaDeltaTMapComparison[iSlot][iSet],
327 m_slotSigmaDeltaTMap[iSlot][iSet], m_slotSigmaDeltaTMap[iSlot][refSet]);
328 }
329 }
330 B2INFO("Comparisons done");
331
332 return 1;
333 }

◆ matrixInversion()

bool matrixInversion ( const std::vector< TwoTimes > & ntuple,
unsigned scrodID,
unsigned scrodChannel,
double meanTimeDifference,
TH1F & Hchi2,
TH1F & Hndf,
TH1F & HDeltaT )
private

Method by matrix inversion.

Parameters
ntuplentuple data
scrodIDSCROD ID
scrodChannelchannel number within SCROD (0 - 127)
meanTimeDifferenceaverage time difference [samples]
Hchi2histogram to store normalized chi^2
Hndfhistogram to store degrees of freedom
HDeltaThistogram to store fittet double pulse delay
Returns
true on success

Definition at line 398 of file TOPTimeBaseCalibratorModule.cc.

403 {
404
405 // Ax = b: construct matrix A and right side vector b
406
407 TMatrixDSym A(c_TimeAxisSize);
408 vector<double> b(c_TimeAxisSize, 0.0);
409
410 for (const auto& twoTimes : ntuple) {
411 if (!twoTimes.good) continue;
412
413 vector<double> m(c_TimeAxisSize, 0.0);
414 int i1 = int(twoTimes.t1);
415 m[i1 % c_TimeAxisSize] = 1.0 - (twoTimes.t1 - i1);
416 int i2 = int(twoTimes.t2);
417 m[i2 % c_TimeAxisSize] = twoTimes.t2 - i2;
418 i2 = i1 + (i2 - i1) % c_TimeAxisSize;
419 for (int k = i1 + 1; k < i2; k++) m[k % c_TimeAxisSize] = 1;
420
421 double relSigma = twoTimes.sigma / meanTimeDifference;
422 double sig2 = relSigma * relSigma;
423
424 for (int jj = i1; jj < i2 + 1; jj++) {
425 int j = jj % c_TimeAxisSize;
426 for (int kk = i1; kk < i2 + 1; kk++) {
427 int k = kk % c_TimeAxisSize;
428 A(j, k) += m[j] * m[k] / sig2;
429 }
430 }
431 for (int k = 0; k < c_TimeAxisSize; k++) b[k] += m[k] / sig2;
432 }
433
434 // save as histograms
435
436 string forWhat = "scrod " + to_string(scrodID) + " channel " + to_string(chan);
437 if (m_saveMatrix) {
438 saveAsHistogram(A, "matA_ch" + to_string(chan), "Matrix for " + forWhat);
439 saveAsHistogram(b, "vecB_ch" + to_string(chan), "Right side for " + forWhat);
440 }
441
442 // invert matrix A and solve the equation: x = A^{-1}b
443
444 double det = 0;
445 A.Invert(&det);
446 if (det == 0) {
447 B2INFO("... channel " << chan << " failed");
448 return false;
449 }
450
451 vector<double> x(c_TimeAxisSize, 0.0);
452 for (int k = 0; k < c_TimeAxisSize; k++) {
453 for (int j = 0; j < c_TimeAxisSize; j++) {
454 x[k] += A(k, j) * b[j];
455 }
456 }
457
458 // calculate chi^2
459
460 double chi2 = 0;
461 int ndf = -c_TimeAxisSize;
462
463 for (const auto& twoTimes : ntuple) {
464 if (!twoTimes.good) continue;
465
466 vector<double> m(c_TimeAxisSize, 0.0);
467 int i1 = int(twoTimes.t1);
468 m[i1 % c_TimeAxisSize] = 1.0 - (twoTimes.t1 - i1);
469 int i2 = int(twoTimes.t2);
470 m[i2 % c_TimeAxisSize] = twoTimes.t2 - i2;
471 i2 = i1 + (i2 - i1) % c_TimeAxisSize;
472 for (int k = i1 + 1; k < i2; k++) m[k % c_TimeAxisSize] = 1;
473 double s = -1.0;
474 for (int k = 0; k < c_TimeAxisSize; k++) s += m[k] * x[k];
475 double relSigma = twoTimes.sigma / meanTimeDifference;
476 double sig2 = relSigma * relSigma;
477 chi2 += s * s / sig2;
478 ndf++;
479 }
480 Hchi2.SetBinContent(chan + 1, chi2 / ndf);
481 Hndf.SetBinContent(chan + 1, ndf);
482
483 // constrain sum of x to 2*syncTimeBase and calculate sample times
484
485 double sum = 0;
486 for (auto xi : x) sum += xi;
487 if (sum == 0) {
488 B2ERROR("sum == 0");
489 return false;
490 }
491 double DeltaT = 2 * m_syncTimeBase / sum;
492 for (auto& xi : x) xi *= DeltaT;
493 HDeltaT.SetBinContent(chan + 1, DeltaT);
494
495 vector<double> err;
496 for (int k = 0; k < c_TimeAxisSize; k++) err.push_back(sqrt(A(k, k)) * DeltaT);
497
498 vector<double> sampleTimes;
499 sampleTimes.push_back(0);
500 for (auto xi : x) sampleTimes.push_back(xi + sampleTimes.back());
501
502 // save results as histograms
503
504 if (m_saveMatrix) saveAsHistogram(A, "invA_ch" + to_string(chan), "Inverted matrix for " + forWhat);
505 saveAsHistogram(x, err, "dt_ch" + to_string(chan), "Sample time bins for " + forWhat,
506 "sample number", "#Delta t [ns]");
507 saveAsHistogram(sampleTimes, "sampleTimes_ch" + to_string(chan),
508 "Time base corrections for " + forWhat, "sample number", "t [ns]");
509
510 // calibrated cal pulse time difference
511
512 string name = "timeDiffcal_ch" + to_string(chan);
513 string title = "Calibrated cal pulse time difference vs. sample for " + forWhat;
514 TH2F Hcor(name.c_str(), title.c_str(), c_TimeAxisSize, 0, c_TimeAxisSize,
515 100, DeltaT - 0.5, DeltaT + 0.5);
516 Hcor.SetXTitle("sample number");
517 Hcor.SetYTitle("time difference [ns]");
518 Hcor.SetStats(kTRUE);
519
520 TOPSampleTimes timeBase;
521 timeBase.setTimeAxis(sampleTimes, sampleTimes.back() / 2);
522
523 for (const auto& twoTimes : ntuple) {
524 if (!twoTimes.good) continue;
525 double dt = timeBase.getDeltaTime(0, twoTimes.t2, twoTimes.t1);
526 int sample = int(twoTimes.t1) % c_TimeAxisSize;
527 Hcor.Fill(sample, dt);
528 }
529 Hcor.Write();
530
531 B2INFO("... channel " << chan << " OK (chi^2/ndf = " << chi2 / ndf
532 << ", ndf = " << ndf << ")");
533
534 return true;
535 }

◆ myprint()

void myprint ( TH1F * histo,
const char * path,
const char * xtit = "",
const char * ytit = "",
double tresh = 0 )

Print histogram 1D, helper function.

Definition at line 322 of file TOPBackgroundModule.cc.

323 {
324
325 gROOT->Reset();
326 gStyle->SetOptStat("");
327 gStyle->SetOptFit(1111);
328
329 gStyle->SetCanvasColor(-1);
330 gStyle->SetPadColor(-1);
331 gStyle->SetFrameFillColor(-1);
332 gStyle->SetHistFillColor(-1);
333 gStyle->SetTitleFillColor(-1);
334 gStyle->SetFillColor(-1);
335 gStyle->SetFillStyle(4000);
336 gStyle->SetStatStyle(0);
337 gStyle->SetTitleStyle(0);
338 gStyle->SetCanvasBorderSize(0);
339 gStyle->SetCanvasBorderMode(0);
340 gStyle->SetPadBorderMode(0);
341 // gStyle->SetTitleMode(0);
342 gStyle->SetFrameBorderSize(0);
343 gStyle->SetLegendBorderSize(0);
344 gStyle->SetStatBorderSize(0);
345 gStyle->SetTitleBorderSize(0);
346 //gROOT->ForceStyle();*/
347
348
349
350 TCanvas* c1 = new TCanvas("c1", "", 1920, 1200);
351
352 double x1 = histo->GetBinLowEdge(1);
353 double nb = histo->GetNbinsX();
354 double bin = histo->GetBinWidth(1);
355 double x2 = x1 + bin * nb;
356
357 double max = histo->GetBinContent(histo->GetMaximumBin());
358
359 if (max < tresh) {
360 histo->GetYaxis()->SetRangeUser(0, tresh * 1.1);
361 }
362
363 TLine* line = new TLine(x1, tresh, x2, tresh);
364 line->SetLineColor(1);
365 line->SetLineWidth(3);
366 line->SetLineStyle(2);
367
368
369 histo->SetFillColor(2);
370 histo->SetLineColor(1);
371
372 gPad->SetTopMargin(0.08);
373 gPad->SetBottomMargin(0.15);
374 gPad->SetGridy();
375
376 histo->GetXaxis()->SetLabelSize(0.06);
377 histo->GetYaxis()->SetLabelSize(0.06);
378 histo->GetXaxis()->SetTitleSize(0.06);
379 histo->GetYaxis()->SetTitleSize(0.06);
380 histo->GetXaxis()->SetTitle(xtit);
381 histo->GetYaxis()->SetTitle(ytit);
382 histo->GetXaxis()->SetTitleOffset(0.9);
383 histo->GetYaxis()->SetTitleOffset(0.7);
384
385 histo->Draw();
386
387 TLegend* leg = new TLegend(0.75, 0.95, 0.90, 1.00);
388 leg->AddEntry(histo, m_BkgType.c_str(), "pf");
389 leg->Draw("SAME");
390 if (tresh > 0.01) {
391 line->Draw("SAME");
392 }
393
394 c1->Print(path);
395 }

◆ OpticalGunModule()

Constructor.

Definition at line 47 of file OpticalGunModule.cc.

47 : Module()
48 {
49 // set module description
50 setDescription("Source of optical photons");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // Add parameters
54 addParam("x", m_x, "position in x [cm]", 0.0);
55 addParam("y", m_y, "position in y [cm]", 0.0);
56 addParam("z", m_z, "position in z [cm]", 0.0);
57 addParam("diameter", m_diameter, "source diameter [cm]", 0.0);
58 addParam("minAlpha", m_minAlpha, "source minimum emission angle [deg]. ", 0.0);
59 addParam("maxAlpha", m_maxAlpha, "source maximum emission angle [deg]. ", 30.);
60 addParam("na", m_na, "source numerical aperture. It is used only by the Gaussian distribution", 0.50);
61 addParam("angularDistribution", m_angularDistribution,
62 "source angular distribution: uniform, Lambertian, an arbitrary TFormula, or Gaussian "
63 "(numerical aperture instead of minAlpha and maxAlpha). If you are writing a TFormula, "
64 "assume the angles are measured in degrees. The conversion to radians is done internally.",
65 string("Gaussian"));
66 addParam("wavelength", m_wavelength, "wavelength of photons [nm]", 405.0);
67 addParam("phi", m_phi, "first rotation angle (around z) [deg]", 0.0);
68 addParam("theta", m_theta, "second rotation angle (around x) [deg]", 0.0);
69 addParam("psi", m_psi, "third rotation angle (around z) [deg]", 0.0);
70 addParam("startTime", m_startTime,
71 "start time [ns]. If TOPCalPulseGenerator is in path this is relative to the first cal pulse", 0.0);
72 addParam("pulseWidth", m_pulseWidth, "pulse duration (Gaussian sigma) [ns]", 0.0);
73 addParam("numPhotons", m_numPhotons,
74 "average number of photons per pulse, if positive, otherwise exactly one", 0.0);
75 addParam("slotID", m_slotID,
76 "TOP slot ID (1-16): if valid, source position and rotation angles assumed to be given in a local bar frame, "
77 "otherwise Belle II frame is assumed", 0);
78 addParam("slitDX", m_slitDX, "slit size in x [cm], if positive, otherwise full open", 0.0);
79 addParam("slitDY", m_slitDY, "slit size in y [cm], if positive, otherwise full open", 0.0);
80 addParam("slitX0", m_slitX0, "slit x-offset in respect to source [cm] ", 0.0);
81 addParam("slitY0", m_slitY0, "slit y-offset in respect to source [cm] ", 0.0);
82 addParam("slitZ", m_slitZ, "slit distance to source [cm], if > 0.01, otherwise slit full open", 0.0);
83 }

◆ packProductionDebug()

void packProductionDebug ( )
private

Pack in format: Production Debugging Data Format 01.

Definition at line 295 of file TOPPackerModule.cc.

296 {
297 StoreObjPtr<EventMetaData> evtMetaData;
298 StoreArray<TOPRawDigit> digits(m_inputRawDigitsName);
299 StoreArray<RawTOP> rawData(m_outputRawDataName);
300
301 const auto& mapper = m_topgp->getFrontEndMapper();
302 int mapSize = mapper.getMapSize();
303 if (mapSize <= 0) return;
304
305 auto* sortedDigits = new vector<const TOPRawDigit*>[mapSize];
306
307 for (const auto& digit : digits) {
308 auto scrodID = digit.getScrodID();
309 const auto* feemap = mapper.getMap(scrodID);
310 if (!feemap) {
311 B2ERROR("TOPPacker: no front-end map available."
312 << LogVar("scrodID", scrodID));
313 continue;
314 }
315 sortedDigits[feemap->getIndex()].push_back(&digit);
316 }
317
318 unsigned revo9count = 0;
319 unsigned phase = 0;
320 if (digits.getEntries() > 0) {
321 revo9count = digits[0]->getRevo9Counter();
322 phase = digits[0]->getPhase();
323 }
324
325 for (const auto& copperID : mapper.getCopperIDs()) {
326 vector<int> Buffer[4];
327 for (int finesse = 0; finesse < 4; finesse++) {
328 const auto* feemap = mapper.getMapFromCopper(copperID, finesse);
329 if (!feemap) continue;
330 unsigned scrodID = feemap->getScrodID();
331 unsigned format = static_cast<unsigned>(TOP::RawDataType::c_ProductionDebug01);
332
333 unsigned head0 = (format << 16) | (0xA << 12) | (scrodID & 0x0FFF);
334 Buffer[finesse].push_back(head0);
335
336 unsigned numWordsCore = sortedDigits[feemap->getIndex()].size() * 5 + 1;
337 unsigned head1 = ((phase & 0xF) << 12) | (numWordsCore & 0xFFF);
338 Buffer[finesse].push_back(head1);
339
340 unsigned head2 = revo9count & 0xFFFF;
341 Buffer[finesse].push_back(head2);
342
343 unsigned head3 = 0;
344 Buffer[finesse].push_back(head3);
345
346 unsigned Nhits = 0;
347 for (const auto& digit : sortedDigits[feemap->getIndex()]) {
348 unsigned checkSum = 0; // IPv4 checksum
349 unsigned word0 =
350 (digit->getCarrierNumber() << 30) |
351 ((digit->getASICNumber() & 0x3) << 28) |
352 ((digit->getASICChannel() & 0x7) << 25) |
353 ((digit->getASICWindow() & 0x1FF) << 16) |
354 (0xB << 12) |
355 ((digit->getTFine() & 0xF) << 8);
356 checkSum += (word0 & 0xFFFF) + ((word0 >> 16) & 0xFFFF);
357 Buffer[finesse].push_back(word0);
358 unsigned word1 =
359 ((digit->getValuePeak() & 0x1FFF) << 16) |
360 (digit->getIntegral() & 0xFFFF);
361 checkSum += (word1 & 0xFFFF) + ((word1 >> 16) & 0xFFFF);
362 Buffer[finesse].push_back(word1);
363 unsigned word2 =
364 ((digit->getValueRise0() & 0x1FFF) << 16) |
365 (digit->getValueRise1() & 0x1FFF);
366 checkSum += (word2 & 0xFFFF) + ((word2 >> 16) & 0xFFFF);
367 Buffer[finesse].push_back(word2);
368 unsigned word3 =
369 ((digit->getValueFall0() & 0x1FFF) << 16) |
370 (digit->getValueFall1() & 0x1FFF);
371 checkSum += (word3 & 0xFFFF) + ((word3 >> 16) & 0xFFFF);
372 Buffer[finesse].push_back(word3);
373 unsigned word4 =
374 (digit->getSampleRise() << 24) |
375 ((digit->getDeltaSamplePeak() & 0xF) << 20) |
376 ((digit->getDeltaSampleFall() & 0xF) << 16);
377 checkSum += (word4 & 0xFFFF) + ((word4 >> 16) & 0xFFFF);
378 while ((checkSum >> 16) > 0) {
379 checkSum = (checkSum & 0xFFFF) + (checkSum >> 16);
380 }
381 word4 |= ((~checkSum) & 0xFFFF);
382 Buffer[finesse].push_back(word4);
383 Nhits++;
384 }
385 unsigned tail = (0x5 << 9) | (Nhits & 0x1FF);
386 Buffer[finesse].push_back(tail);
387 }
388
389 RawCOPPERPackerInfo info;
390 info.exp_num = evtMetaData->getExperiment();
391 // run number : 14bits, subrun # : 8bits
392 info.run_subrun_num = (evtMetaData->getRun() << 8) +
393 (evtMetaData->getSubrun() & 0xFF);
394 info.eve_num = evtMetaData->getEvent();
395 info.node_id = TOP_ID + copperID;
396 info.tt_ctime = 0;
397 info.tt_utime = 0;
398 info.b2l_ctime = 0;
399 info.hslb_crc16_error_bit = 0;
400 info.truncation_mask = 0;
401 info.type_of_data = 0;
402
403 auto* raw = rawData.appendNew();
404 raw->PackDetectorBuf(Buffer[0].data(), Buffer[0].size(),
405 Buffer[1].data(), Buffer[1].size(),
406 Buffer[2].data(), Buffer[2].size(),
407 Buffer[3].data(), Buffer[3].size(),
408 info);
409 }
410 delete [] sortedDigits;
411 }

◆ packProductionDraft()

void packProductionDraft ( )
private

Pack in format: c_Draft (tentative production format) this format was never implemented in firmware!

Definition at line 132 of file TOPPackerModule.cc.

133 {
134 StoreObjPtr<EventMetaData> evtMetaData;
135 StoreArray<TOPDigit> digits(m_inputDigitsName);
136 StoreArray<RawTOP> rawData(m_outputRawDataName);
137
138 const auto& mapper = m_topgp->getFrontEndMapper();
139 int mapSize = mapper.getMapSize();
140 if (mapSize <= 0) return;
141
142 vector<const TOPDigit*>* sortedDigits = new vector<const TOPDigit*>[mapSize];
143
144 for (const auto& digit : digits) {
145 int moduleID = digit.getModuleID();
146 int boardstack = digit.getChannel() / 128;
147 const auto* feemap = mapper.getMap(moduleID, boardstack);
148 if (!feemap) {
149 B2ERROR("TOPPacker: no front-end map available."
150 << LogVar("moduleID", moduleID)
151 << LogVar("boardstack", boardstack));
152 continue;
153 }
154 sortedDigits[feemap->getIndex()].push_back(&digit);
155 }
156
157 auto subBits = m_topgp->getGeometry()->getNominalTDC().getSubBits();
158 int sampleDivisions = 0x1 << subBits;
159
160 for (const auto& copperID : mapper.getCopperIDs()) {
161 vector<int> Buffer[4];
162 for (int finesse = 0; finesse < 4; finesse++) {
163 const auto* feemap = mapper.getMapFromCopper(copperID, finesse);
164 if (!feemap) continue;
165 unsigned scrodID = feemap->getScrodID();
166 unsigned dataFormat = static_cast<unsigned>(TOP::RawDataType::c_Draft);
167 Buffer[finesse].push_back(scrodID + (dataFormat << 16));
168 for (const auto& digit : sortedDigits[feemap->getIndex()]) {
169 double rawTime = digit->getRawTime();
170 unsigned tdc = int(rawTime * sampleDivisions) & 0xFFFF;
171 unsigned chan = digit->getChannel() % 128;
172 unsigned flags = (unsigned) digit->getHitQuality();
173 Buffer[finesse].push_back(tdc + (chan << 16) + (flags << 24));
174 }
175 }
176 RawCOPPERPackerInfo info;
177 info.exp_num = evtMetaData->getExperiment();
178 // run number : 14bits, subrun # : 8bits
179 info.run_subrun_num = (evtMetaData->getRun() << 8) +
180 (evtMetaData->getSubrun() & 0xFF);
181 info.eve_num = evtMetaData->getEvent();
182 info.node_id = TOP_ID + copperID;
183 info.tt_ctime = 0;
184 info.tt_utime = 0;
185 info.b2l_ctime = 0;
186 info.hslb_crc16_error_bit = 0;
187 info.truncation_mask = 0;
188 info.type_of_data = 0;
189
190 auto* raw = rawData.appendNew();
191 raw->PackDetectorBuf(Buffer[0].data(), Buffer[0].size(),
192 Buffer[1].data(), Buffer[1].size(),
193 Buffer[2].data(), Buffer[2].size(),
194 Buffer[3].data(), Buffer[3].size(),
195 info);
196 }
197 delete [] sortedDigits;
198 }

◆ packType0Ver16()

void packType0Ver16 ( )
private

Pack in format: c_Type0Ver16 (Feature-extracted data) this format was never implemented in firmware!

Definition at line 201 of file TOPPackerModule.cc.

202 {
203 StoreObjPtr<EventMetaData> evtMetaData;
204 StoreArray<TOPRawDigit> digits(m_inputRawDigitsName);
205 StoreArray<RawTOP> rawData(m_outputRawDataName);
206
207 const auto& mapper = m_topgp->getFrontEndMapper();
208 int mapSize = mapper.getMapSize();
209 if (mapSize <= 0) return;
210
211 auto* sortedDigits = new vector<const TOPRawDigit*>[mapSize];
212
213 for (const auto& digit : digits) {
214 auto scrodID = digit.getScrodID();
215 const auto* feemap = mapper.getMap(scrodID);
216 if (!feemap) {
217 B2ERROR("TOPPacker: no front-end map available."
218 << LogVar("scrodID", scrodID));
219 continue;
220 }
221 sortedDigits[feemap->getIndex()].push_back(&digit);
222 }
223
224 for (const auto& copperID : mapper.getCopperIDs()) {
225 vector<int> Buffer[4];
226 for (int finesse = 0; finesse < 4; finesse++) {
227 const auto* feemap = mapper.getMapFromCopper(copperID, finesse);
228 if (!feemap) continue;
229 unsigned scrodID = feemap->getScrodID();
230 unsigned dataFormat = static_cast<unsigned>(TOP::RawDataType::c_Type0Ver16);
231
232 // production data v2.1 (data_format_v2_1.xlsx from Lynn 06/26/2016)
233 unsigned head = (dataFormat << 16) | (0xA << 12) | (scrodID & 0x0FFF);
234 Buffer[finesse].push_back(head);
235 unsigned Nhits = 0;
236 for (const auto& digit : sortedDigits[feemap->getIndex()]) {
237 unsigned word1 =
238 (digit->getCarrierNumber() << 30) |
239 ((digit->getASICNumber() & 0x3) << 28) |
240 ((digit->getASICChannel() & 0x7) << 25) |
241 ((digit->getASICWindow() & 0x1FF) << 16) |
242 (0xB << 12) |
243 ((digit->getTFine() & 0xF) << 8);
244 Buffer[finesse].push_back(word1);
245 unsigned word2 =
246 ((digit->getValuePeak() & 0x1FFF) << 16) |
247 (digit->getIntegral() & 0xFFFF);
248 Buffer[finesse].push_back(word2);
249 unsigned word3 =
250 ((digit->getValueRise0() & 0x1FFF) << 16) |
251 (digit->getValueRise1() & 0x1FFF);
252 Buffer[finesse].push_back(word3);
253 unsigned word4 =
254 ((digit->getValueFall0() & 0x1FFF) << 16) |
255 (digit->getValueFall1() & 0x1FFF);
256 Buffer[finesse].push_back(word4);
257 unsigned word5 =
258 (digit->getSampleRise() << 24) |
259 ((digit->getDeltaSamplePeak() & 0xF) << 20) |
260 ((digit->getDeltaSampleFall() & 0xF) << 16);
261 short checkSum = -(sumShorts(word1) + sumShorts(word2) + sumShorts(word3) +
262 sumShorts(word4) + sumShorts(word5));
263 word5 |= (checkSum & 0xFFFF);
264 Buffer[finesse].push_back(word5);
265 Nhits++;
266 }
267 unsigned tail = (0x5 << 9) | (Nhits & 0x1FF);
268 Buffer[finesse].push_back(tail);
269 }
270 RawCOPPERPackerInfo info;
271 info.exp_num = evtMetaData->getExperiment();
272 // run number : 14bits, subrun # : 8bits
273 info.run_subrun_num = (evtMetaData->getRun() << 8) +
274 (evtMetaData->getSubrun() & 0xFF);
275 info.eve_num = evtMetaData->getEvent();
276 info.node_id = TOP_ID + copperID;
277 info.tt_ctime = 0;
278 info.tt_utime = 0;
279 info.b2l_ctime = 0;
280 info.hslb_crc16_error_bit = 0;
281 info.truncation_mask = 0;
282 info.type_of_data = 0;
283
284 auto* raw = rawData.appendNew();
285 raw->PackDetectorBuf(Buffer[0].data(), Buffer[0].size(),
286 Buffer[1].data(), Buffer[1].size(),
287 Buffer[2].data(), Buffer[2].size(),
288 Buffer[3].data(), Buffer[3].size(),
289 info);
290 }
291 delete [] sortedDigits;
292 }

◆ parseInputDirectoryLine()

int parseInputDirectoryLine ( std::string inputString)

Utility function to get the directory name and the label from a line of the m_inputDirectoryList file Sets the values of m_calSetDirectory and m_calSetLabel.

Definition at line 509 of file TOPTBCComparatorModule.cc.

510 {
511 // resets the strings
512 m_calSetDirectory.clear();
513 m_calSetLabel.clear();
514
515 // reads the string char by char to break it up in m_calSetDirectory and m_calSetLabel
516 bool isDirectoryNameChar = true;
517 bool isAtBeginning = true;
518
519 for (std::string::size_type i = 0; i < inputString.size(); ++i) {
520 char c = inputString[i];
521 // The following ifs should catch all the possible cases
522 if (c == ' ' && isAtBeginning) continue; // and empty space at the beginning of the line
523 if (c == ' ' && !isAtBeginning) { // an empty space between the two parts
524 isDirectoryNameChar = false;
525 isAtBeginning = false;
526 continue;
527 }
528 if (c != ' ' && isDirectoryNameChar) { // a good char belonging to the first part of the string
529 m_calSetDirectory += c;
530 isAtBeginning = false;
531 continue;
532 }
533 if (c != ' ' && !isDirectoryNameChar) { // a good char belonging to the second part of the string
534 m_calSetLabel += c;
535 isAtBeginning = false;
536 continue;
537 }
538 B2WARNING("Uncaught exception in parsing the input string. Ending the parsing."); // I should never reach thispoint
539 return 0;
540 }
541
542 return 1;
543 }

◆ parseSlotAndScrodIDfromFileName()

int parseSlotAndScrodIDfromFileName ( std::string inputString)

Utility function to parse the slot and BS id from the calibration file names.

Definition at line 547 of file TOPTBCComparatorModule.cc.

548 {
549 // resets the IDs
550 m_slotID = -1;
551 m_boardstackID = -1;
552 m_scrodID = -1;
553
554 // reads the string char by char to break it up in m_calSetDirectory and m_calSetLabel
555
556
557 std::string stringSlot = "";
558 std::string stringBS = "";
559 std::string stringScrod = "";
560
561
562 // We may eventually implement a more clever parsere that is not so sensitive to the file name...
563 //
564 // tbcSlotXX_Y-scrodZZZ.root
565 // tbcSlotXX_Y-scrodZZ.root
566 // 012345678901234567890
567 //
568
569 if (!(inputString[0] == 't' && inputString[1] == 'b' && inputString[2] == 'c')) {
570 B2WARNING(inputString << " is not a valid TBC file. Skipping it.");
571 return 0;
572 }
573 stringSlot += inputString[7];
574 stringSlot += inputString[8];
575 stringBS += inputString[10];
576 stringScrod += inputString[17];
577 stringScrod += inputString[18];
578 if (inputString[19] != '.')
579 stringScrod += inputString[19];
580
581
582 m_slotID = std::stoi(stringSlot);
583 m_scrodID = std::stoi(stringScrod);
584 m_boardstackID = std::stoi(stringBS);
585
586 return 1;
587 }

◆ prepare() [1/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 79 of file TOPAlignmentCollectorModule.cc.

80 {
81 // input collections
82
83 m_digits.isRequired();
84 m_tracks.isRequired();
85 m_extHits.isRequired();
86 m_recBunch.isRequired();
87
88 // check if target module ID is valid
89
90 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
91 if (!geo->isModuleIDValid(m_targetMid)) {
92 B2FATAL("Target module ID = " << m_targetMid << " is invalid. Exiting...");
93 }
94
95 // set track selector
96
97 if (m_sample == "dimuon" or m_sample == "bhabha") {
98 m_selector = TrackSelector(m_sample);
99 m_selector.setDeltaEcms(m_deltaEcms);
100 m_selector.setCutOnPOCA(m_dr, m_dz);
101 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
102 } else {
103 B2ERROR("Invalid sample type '" << m_sample << "'");
104 }
105
106 // set alignment objects
107
108 for (int set = 0; set < c_numSets; set++) {
109 auto align = ModuleAlignment();
110 align.setModuleID(m_targetMid);
111 align.setSteps(m_stepPosition, m_stepAngle, m_stepTime);
112 align.setParameters(m_parInit);
113 for (const auto& parName : m_parFixed) {
114 align.fixParameter(parName);
115 }
116 m_align.push_back(align);
117 m_countFails.push_back(0);
118 }
119
120 // create and register output histograms and ntuples
121
122 int numModules = geo->getNumModules();
123 auto h1 = new TH2F("tracks_per_slot", "Number of tracks per slot and sample",
124 numModules, 0.5, numModules + 0.5, c_numSets, 0, c_numSets);
125 h1->SetXTitle("slot number");
126 h1->SetYTitle("sample number");
127 registerObject<TH2F>("tracks_per_slot", h1);
128
129 for (int slot = 1; slot <= numModules; slot++) {
130 std::string slotName = "_s" + to_string(slot);
131 std::string slotTitle = "(slot " + to_string(slot) + ")";
132
133 std::string hname = "local_z" + slotName;
134 std::string title = "Distribution of tracks along bar " + slotTitle;
135 auto h2 = new TH1F(hname.c_str(), title.c_str(), 100, -150.0, 150.0);
136 h2->SetXTitle("local z [cm]");
137 registerObject<TH1F>(hname, h2);
138
139 hname = "cth_vs_p" + slotName;
140 title = "Track momentum " + slotTitle;
141 auto h3 = new TH2F(hname.c_str(), title.c_str(), 100, 0.0, 7.0, 100, -1.0, 1.0);
142 h3->SetXTitle("p [GeV/c]");
143 h3->SetYTitle("cos #theta");
144 registerObject<TH2F>(hname, h3);
145
146 hname = "poca_xy" + slotName;
147 title = "Track POCA in x-y " + slotTitle;
148 auto h4 = new TH2F(hname.c_str(), title.c_str(), 100, -m_dr, m_dr, 100, -m_dr, m_dr);
149 h4->SetXTitle("x [cm]");
150 h4->SetYTitle("y [cm]");
151 registerObject<TH2F>(hname, h4);
152
153 hname = "poca_z" + slotName;
154 title = "Track POCA in z " + slotTitle;
155 auto h5 = new TH1F(hname.c_str(), title.c_str(), 100, -m_dz, m_dz);
156 h5->SetXTitle("z [cm]");
157 registerObject<TH1F>(hname, h5);
158
159 hname = "Ecms" + slotName;
160 title = "Track c.m.s. energy " + slotTitle;
161 auto h6 = new TH1F(hname.c_str(), title.c_str(), 100, 5.1, 5.4);
162 h6->SetXTitle("E_{cms} [GeV]");
163 registerObject<TH1F>(hname, h6);
164
165 hname = "charge" + slotName;
166 title = "Charge of track " + slotTitle;
167 auto h7 = new TH1F(hname.c_str(), title.c_str(), 3, -1.5, 1.5);
168 h7->SetXTitle("charge");
169 registerObject<TH1F>(hname, h7);
170
171 hname = "timeHits" + slotName;
172 title = "Photon time distribution " + slotTitle;
173 auto h8 = new TH2F(hname.c_str(), title.c_str(), 512, 0, 512, 200, 0, 50);
174 h8->SetXTitle("channel number");
175 h8->SetYTitle("time [ns]");
176 registerObject<TH2F>(hname, h8);
177
178 hname = "numPhot" + slotName;
179 title = "Number of photons " + slotTitle;
180 auto h9 = new TH1F(hname.c_str(), title.c_str(), 100, 0, 100);
181 h9->SetXTitle("photons per track");
182 registerObject<TH1F>(hname, h9);
183 }
184
185 for (int set = 0; set < c_numSets; set++) {
186 std::string name = "alignTree" + to_string(set);
187 m_treeNames.push_back(name);
188 auto alignTree = new TTree(name.c_str(), "TOP alignment results");
189 alignTree->Branch("ModuleId", &m_targetMid);
190 alignTree->Branch("iter", &m_iter);
191 alignTree->Branch("ntrk", &m_ntrk);
192 alignTree->Branch("errorCode", &m_errorCode);
193 alignTree->Branch("iterPars", &m_vAlignPars);
194 alignTree->Branch("iterParsErr", &m_vAlignParsErr);
195 alignTree->Branch("valid", &m_valid);
196 alignTree->Branch("numPhot", &m_numPhot);
197 alignTree->Branch("x", &m_x);
198 alignTree->Branch("y", &m_y);
199 alignTree->Branch("z", &m_z);
200 alignTree->Branch("p", &m_p);
201 alignTree->Branch("theta", &m_theta);
202 alignTree->Branch("phi", &m_phi);
203 alignTree->Branch("r_poca", &m_pocaR);
204 alignTree->Branch("z_poca", &m_pocaZ);
205 alignTree->Branch("x_poca", &m_pocaX);
206 alignTree->Branch("y_poca", &m_pocaY);
207 alignTree->Branch("Ecms", &m_cmsE);
208 alignTree->Branch("charge", &m_charge);
209 alignTree->Branch("PDG", &m_PDG);
210 registerObject<TTree>(name, alignTree);
211 }
212
213 }

◆ prepare() [2/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well.

Reimplemented from CalibrationCollectorModule.

Definition at line 52 of file TOPAsicShiftsBS13dCollectorModule.cc.

53 {
54
55 m_topDigits.isRequired();
56 if (m_requireRecBunch) {
57 m_recBunch.isRequired();
58 } else {
59 m_recBunch.isOptional();
60 }
61
62 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
63 double timeStep = geo->getNominalTDC().getSyncTimeBase() / 6;
64 double xmi = - m_nx * timeStep / 2;
65 double xma = m_nx * timeStep / 2;
66
67 auto time_vs_BS = new TH2F("time_vs_BS", "time vs BS, slot 13",
68 16, 0.0, 512.0, m_nx, xmi, xma);
69 time_vs_BS->SetXTitle("channel number");
70 time_vs_BS->SetYTitle("time [ns]");
71 registerObject<TH2F>("time_vs_BS", time_vs_BS);
72
73 auto timeReference = new TH1F("time_reference", "time, slot 13(a, b, c)",
74 m_nx, xmi, xma);
75 timeReference->SetXTitle("time [ns]");
76 timeReference->SetYTitle("entries per bin [arbitrary]");
77 registerObject<TH1F>("time_reference", timeReference);
78
79 for (unsigned i = 0; i < 4; i++) {
80 string name = "time_carr_" + to_string(i);
81 string title = "time, slot 13d, carrier " + to_string(i);
82 auto h = new TH1F(name.c_str(), title.c_str(), m_nx, xmi, xma);
83 h->SetXTitle("time [ns]");
84 h->SetYTitle("entries per bin [arbitrary]");
85 registerObject<TH1F>(name, h);
86 }
87
88 }

◆ prepare() [3/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 39 of file TOPChannelMaskCollectorModule.cc.

40 {
41
42 m_digits.isRequired();
43
44 auto nhits = new TH1F("nhits", "Number of good hits per event; hits per event; entries per bin", 200, 0, 2000);
45 registerObject<TH1F>("nhits", nhits);
46
47 for (int slot = 1; slot <= 16; slot++) {
48 string name = "hits_" + to_string(slot);
49 string title = "Channel occupancies for slot " + to_string(slot);
50 auto h = new TH1F(name.c_str(), title.c_str(), 512, 0, 512);
51 h->SetXTitle("channel number");
52 h->SetYTitle("number of hits per channel");
53 registerObject<TH1F>(name, h);
54 m_names.push_back(name);
55 }
56
57 for (int slot = 1; slot <= 16; slot++) {
58 string name = "window_vs_asic_" + to_string(slot);
59 string title = "Window vs. asic for slot " + to_string(slot);
60 auto h = new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 512, 0, 512);
61 h->SetXTitle("ASIC number");
62 h->SetYTitle("window number w.r.t reference window");
63 registerObject<TH2F>(name, h);
64 m_asicNames.push_back(name);
65 }
66
67 }

◆ prepare() [4/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 49 of file TOPCommonT0BFCollectorModule.cc.

50 {
51
52 m_recBunch.isRequired();
53
54 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
55 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / m_bunchesPerSSTclk;
56
57 auto h1a = new TH1F("offset_a", "current offset; offset [ns]",
58 m_nx, -m_bunchTimeSep / 2, m_bunchTimeSep / 2);
59 registerObject<TH1F>("offset_a", h1a);
60
61 auto h1b = new TH1F("offset_b", "current offset; offset [ns]",
62 m_nx, 0.0, m_bunchTimeSep);
63 registerObject<TH1F>("offset_b", h1b);
64
65 }

◆ prepare() [5/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 75 of file TOPCommonT0LLCollectorModule.cc.

76 {
77 // input collections
78
79 m_digits.isRequired();
80 m_tracks.isRequired();
81 m_extHits.isRequired();
82 m_recBunch.isRequired();
83
84 // bunch time separation
85
86 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
87 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / m_bunchesPerSSTclk;
88
89 // Parse PDF option
90
91 if (m_pdfOption == "rough") {
92 m_PDFOption = PDFConstructor::c_Rough;
93 } else if (m_pdfOption == "fine") {
94 m_PDFOption = PDFConstructor::c_Fine;
95 } else if (m_pdfOption == "optimal") {
96 m_PDFOption = PDFConstructor::c_Optimal;
97 } else {
98 B2ERROR("Unknown PDF option '" << m_pdfOption << "'");
99 }
100
101 // set track selector
102
103 if (m_sample == "dimuon" or m_sample == "bhabha") {
104 m_selector = TrackSelector(m_sample);
105 m_selector.setDeltaEcms(m_deltaEcms);
106 m_selector.setCutOnPOCA(m_dr, m_dz);
107 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
108 } else {
109 B2ERROR("Invalid sample type '" << m_sample << "'");
110 }
111
112 // create and register histograms
113
114 double tmin = -m_timeRange / 2;
115 double tmax = m_timeRange / 2;
116 for (unsigned i = 0; i < c_numSets; i++) {
117 string name = "chi2_set" + to_string(i);
118 auto h = new TH1D(name.c_str(), "chi2 scan; t0 [ns]; chi2", m_numBins, tmin, tmax);
119 registerObject<TH1D>(name, h);
120 m_names.push_back(name);
121 }
122
123 auto h1 = new TH1F("tracks_per_set", "tracks per sample; sample number; num tracks",
124 c_numSets, 0, c_numSets);
125 registerObject<TH1F>("tracks_per_set", h1);
126
127 auto h2 = new TH1F("numHits", "Number of photons per slot",
128 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
129 h2->SetXTitle("slot number");
130 h2->SetYTitle("hits per slot");
131 registerObject<TH1F>("numHits", h2);
132
133 auto h3 = new TH2F("timeHits", "Photon times vs. boardstacks",
134 c_numModules * 4, 0.5, static_cast<float>(c_numModules) + 0.5, 200, 0.0, 20.0);
135 h3->SetXTitle("slot number");
136 h3->SetYTitle("time [ns]");
137 registerObject<TH2F>("timeHits", h3);
138
139 // this one is needed primarely to pass bunch time separation to the algorithm,
140 // since DB interface doesn't work there
141 auto h4 = new TH1F("offset", "current offset from input files; offset [ns]",
142 200, -m_bunchTimeSep / 2, m_bunchTimeSep / 2);
143 registerObject<TH1F>("offset", h4);
144
145 }

◆ prepare() [6/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 50 of file TOPModuleT0DeltaTCollectorModule.cc.

51 {
52
53 m_timeZeros.isRequired();
54
55 auto slotPairs = new TH2F("slots", "slot pairs: number of events",
56 16, 0.5, 16.5, 16, 0.5, 16.5);
57 slotPairs->SetXTitle("first slot number");
58 slotPairs->SetYTitle("second slot number");
59 registerObject<TH2F>("slots", slotPairs);
60
61 double xmin = -m_timeRange / 2;
62 double xmax = m_timeRange / 2;
63 for (int slot1 = 1; slot1 <= 9; slot1++) {
64 for (int slot2 = slot1 + 7; slot2 <= slot1 + 9; slot2++) {
65 if (slot2 > 16) continue;
66 string name = "deltaT0_" + to_string(slot1) + "-" + to_string(slot2);
67 string title = "time difference: slot " + to_string(slot1) + " - slot "
68 + to_string(slot2);
69 auto h = new TH1F(name.c_str(), title.c_str(), m_numBins, xmin, xmax);
70 h->SetXTitle("time difference [ns]");
71 registerObject<TH1F>(name, h);
72 }
73 }
74
75 }

◆ prepare() [7/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 75 of file TOPModuleT0LLCollectorModule.cc.

76 {
77 // input collections
78
79 m_digits.isRequired();
80 m_tracks.isRequired();
81 m_extHits.isRequired();
82 m_recBunch.isRequired();
83
84 // Parse PDF option
85
86 if (m_pdfOption == "rough") {
87 m_PDFOption = PDFConstructor::c_Rough;
88 } else if (m_pdfOption == "fine") {
89 m_PDFOption = PDFConstructor::c_Fine;
90 } else if (m_pdfOption == "optimal") {
91 m_PDFOption = PDFConstructor::c_Optimal;
92 } else {
93 B2ERROR("Unknown PDF option '" << m_pdfOption << "'");
94 }
95
96 // set track selector
97
98 if (m_sample == "dimuon" or m_sample == "bhabha") {
99 m_selector = TrackSelector(m_sample);
100 m_selector.setDeltaEcms(m_deltaEcms);
101 m_selector.setCutOnPOCA(m_dr, m_dz);
102 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
103 } else {
104 B2ERROR("Invalid sample type '" << m_sample << "'");
105 }
106
107 // create and register histograms
108
109 double tmin = -m_timeRange / 2;
110 double tmax = m_timeRange / 2;
111 for (unsigned i = 0; i < c_numSets; i++) {
112 for (int slot = 1; slot <= c_numModules; slot++) {
113 double T0 = 0;
114 if (m_moduleT0->isCalibrated(slot)) T0 = m_moduleT0->getT0(slot);
115 string name = "chi2_set" + to_string(i) + "_slot" + to_string(slot);
116 string title = "chi2 scan, slot" + to_string(slot) + "; t0 [ns]; chi2";
117 auto h = new TH1D(name.c_str(), title.c_str(), m_numBins, tmin + T0, tmax + T0);
118 registerObject<TH1D>(name, h);
119 m_names[i].push_back(name);
120 }
121 }
122
123 auto h1 = new TH2F("tracks_per_slot", "tracks per slot and sample",
124 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5, c_numSets, 0, c_numSets);
125 h1->SetXTitle("slot number");
126 h1->SetYTitle("sample number");
127 registerObject<TH2F>("tracks_per_slot", h1);
128
129 auto h2 = new TH1F("numHits", "Number of photons per slot",
130 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
131 h2->SetXTitle("slot number");
132 h2->SetYTitle("hits per slot");
133 registerObject<TH1F>("numHits", h2);
134
135 auto h3 = new TH2F("timeHits", "Photon times vs. boardstacks",
136 c_numModules * 4, 0.5, static_cast<float>(c_numModules) + 0.5, 200, 0.0, 20.0);
137 h3->SetXTitle("slot number");
138 h3->SetYTitle("time [ns]");
139 registerObject<TH2F>("timeHits", h3);
140
141 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
142 double bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / 24;
143 auto h4 = new TH1F("offset", "current offset from input files; offset [ns]",
144 200, -bunchTimeSep / 2, bunchTimeSep / 2);
145 registerObject<TH1F>("offset", h4);
146
147 }

◆ prepare() [8/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 40 of file TOPOffsetCollectorModule.cc.

41 {
42 m_recBunch.isRequired();
43 m_eventT0.isRequired();
44
45 m_names[Const::SVD] = "svdOffset";
46 m_names[Const::CDC] = "cdcOffset";
47 for (const auto& x : m_names) {
48 registerObject<TH1F>(x.second, new TH1F(x.second.c_str(), "Event T0 difference w.r.t TOP; #Delta T_{0} [ns]",
49 500, -50, 50));
50 }
51
52 int RFBuckets = m_bunchStructure->getRFBucketsPerRevolution();
53 registerObject<TH1F>("fillPattern", new TH1F("fillPattern", "Fill pattern from DB; bucket number",
54 RFBuckets, 0, RFBuckets));
55 registerObject<TH1F>("recBuckets", new TH1F("recBuckets", "Reconstructed buckets; bucket number",
56 RFBuckets, 0, RFBuckets));
57 }

◆ prepare() [9/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 57 of file TOPPhotonYieldsCollectorModule.cc.

58 {
59 // input collections
60 m_digits.isRequired();
61 m_tracks.isRequired();
62 m_extHits.isRequired();
63 m_recBunch.isRequired();
64 m_asicMask.isRequired();
65 m_associatedPDFs.isRequired();
66
67 // set track selector
68 if (m_sample == "dimuon" or m_sample == "bhabha") {
69 m_selector = TrackSelector(m_sample);
70 m_selector.setDeltaEcms(m_deltaEcms);
71 m_selector.setCutOnPOCA(m_dr, m_dz);
72 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
73 } else {
74 B2ERROR("Invalid sample type '" << m_sample << "'");
75 }
76
77 // create and register histograms
78
79 const int numModules = 16;
80 const int numPixels = 512;
81
82 // time stamp (average unix time and its standard deviation)
83 auto* timeStamp = new TProfile("timeStamp", "Time stamp; ; unix time", 1, 0, 1, 0, 1.0e10, "S");
84 registerObject<TProfile>("timeStamp", timeStamp);
85
86 // number of selected tracks per slot
87 auto* numTracks = new TH1F("numTracks", "Number of tracks per slot; slot number; track count", numModules, 0.5, numModules + 0.5);
88 registerObject<TH1F>("numTracks", numTracks);
89
90 // number of pixel hits in a signal time window
91 for (int slot = 1; slot <= numModules; slot++) {
92 string name = (slot < 10) ? "signalHits_0" + to_string(slot) : "signalHits_" + to_string(slot);
93 string title = "Hits in signal window for slot " + to_string(slot);
94 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
95 h->SetXTitle("pixel number");
96 h->SetYTitle("hit count");
97 registerObject<TH1F>(name, h);
98 m_signalNames.push_back(name);
99 }
100
101 // number of pixel hits in a background time window
102 for (int slot = 1; slot <= numModules; slot++) {
103 string name = (slot < 10) ? "bkgHits_0" + to_string(slot) : "bkgHits_" + to_string(slot);
104 string title = "Hits in background window for slot " + to_string(slot);
105 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
106 h->SetXTitle("pixel number");
107 h->SetYTitle("hit count");
108 registerObject<TH1F>(name, h);
109 m_bkgNames.push_back(name);
110 }
111
112 // active pixels
113 for (int slot = 1; slot <= numModules; slot++) {
114 string name = (slot < 10) ? "activePixels_0" + to_string(slot) : "activePixels_" + to_string(slot);
115 string title = "Active pixels for slot " + to_string(slot);
116 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
117 h->SetXTitle("pixel number");
118 h->SetYTitle("track count");
119 registerObject<TH1F>(name, h);
120 m_activeNames.push_back(name);
121 }
122
123 // number of effective signal hits in pixels
124 for (int slot = 1; slot <= numModules; slot++) {
125 string name = (slot < 10) ? "effectiveSignalHits_0" + to_string(slot) : "effectiveSignalHits_" + to_string(slot);
126 string title = "Effective signal hits for slot " + to_string(slot);
127 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
128 h->SetXTitle("pixel number");
129 h->SetYTitle("hit count");
130 registerObject<TH1F>(name, h);
131 m_effectiveSignalNames.push_back(name);
132 }
133
134 // number of pixel hits with low impact angle on photo cathode
135 for (int slot = 1; slot <= numModules; slot++) {
136 string name = (slot < 10) ? "alphaLow_0" + to_string(slot) : "alphaLow_" + to_string(slot);
137 string title = "Hits w/ low alpha for slot " + to_string(slot);
138 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
139 h->SetXTitle("pixel number");
140 h->SetYTitle("hit count");
141 registerObject<TH1F>(name, h);
142 m_alphaLowNames.push_back(name);
143 }
144
145 // number of pixel hits with high impact angle on photo cathode
146 for (int slot = 1; slot <= numModules; slot++) {
147 string name = (slot < 10) ? "alphaHigh_0" + to_string(slot) : "alphaHigh_" + to_string(slot);
148 string title = "Hits w/ high alpha for slot " + to_string(slot);
149 auto h = new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
150 h->SetXTitle("pixel number");
151 h->SetYTitle("hit count");
152 registerObject<TH1F>(name, h);
153 m_alphaHighNames.push_back(name);
154 }
155
156 // pixel pulse-height distributions
157 for (int slot = 1; slot <= numModules; slot++) {
158 string name = (slot < 10) ? "pulseHeights_0" + to_string(slot) : "pulseHeights_" + to_string(slot);
159 string title = "Pulse height distributions for slot " + to_string(slot);
160 auto h = new TH2F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5, 200, 0, 2000);
161 h->SetXTitle("pixel number");
162 h->SetYTitle("pulse height");
163 registerObject<TH2F>(name, h);
164 m_pulseHeightNames.push_back(name);
165 }
166
167 // local z-distribution of tracks
168 for (int slot = 1; slot <= numModules; slot++) {
169 string name = (slot < 10) ? "muonZ_0" + to_string(slot) : "muonZ_" + to_string(slot);
170 string title = "Track z-distribution for slot " + to_string(slot);
171 auto h = new TH1F(name.c_str(), title.c_str(), 100, m_minZ, m_maxZ);
172 h->SetXTitle("local z [cm]");
173 h->SetYTitle("track count");
174 registerObject<TH1F>(name, h);
175 m_muonZNames.push_back(name);
176 }
177
178 }

◆ prepare() [10/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 52 of file TOPPulseHeightCollectorModule.cc.

53 {
54
55 m_digits.isRequired();
56
57 auto h1a = new TH1F("time", "time distribution (all hits)", 1000, -100, 250);
58 h1a->SetXTitle("time [ns]");
59 registerObject<TH1F>("time", h1a);
60
61 auto h1b = new TH1F("time_sel", "time distribution (selected hits)", 1000, -100, 250);
62 h1b->SetXTitle("time [ns]");
63 registerObject<TH1F>("time_sel", h1b);
64
65 auto h2a = new TH2F("ph_vs_width", "pulse height vs. width (all hits)",
66 200, 0, 10, 200, 0, 2000);
67 h2a->SetXTitle("pulse width [ns]");
68 h2a->SetYTitle("pulse height [ADC counts]");
69 registerObject<TH2F>("ph_vs_width", h2a);
70
71 auto h2b = new TH2F("ph_vs_width_sel", "pulse height vs. width (selected hits)",
72 200, 0, 10, 200, 0, 2000);
73 h2b->SetXTitle("pulse width [ns]");
74 h2b->SetYTitle("pulse height [ADC counts]");
75 registerObject<TH2F>("ph_vs_width_sel", h2b);
76
77 for (int slot = 1; slot <= 16; slot++) {
78 string name = "ph_slot_" + to_string(slot);
79 string title = "pulse-height vs. channel for slot " + to_string(slot);
80 auto h = new TH2F(name.c_str(), title.c_str(), 512, 0, 512, m_nx, 0, m_xmax);
81 h->SetXTitle("channel number");
82 h->SetYTitle("pulse height [ADC counts]");
83 registerObject<TH2F>(name, h);
84 m_names.push_back(name);
85 }
86
87 }

◆ prepare() [11/11]

void prepare ( )
finalprivatevirtual

Replacement for initialize().

Register calibration dataobjects here as well

Reimplemented from CalibrationCollectorModule.

Definition at line 76 of file TOPValidationCollectorModule.cc.

77 {
78 // input collections
79
80 m_digits.isRequired();
81 m_tracks.isRequired();
82 m_extHits.isRequired();
83 m_recBunch.isRequired();
84
85 // Parse PDF option
86
87 if (m_pdfOption == "rough") {
88 m_PDFOption = PDFConstructor::c_Rough;
89 } else if (m_pdfOption == "fine") {
90 m_PDFOption = PDFConstructor::c_Fine;
91 } else if (m_pdfOption == "optimal") {
92 m_PDFOption = PDFConstructor::c_Optimal;
93 } else {
94 B2ERROR("Unknown PDF option '" << m_pdfOption << "'");
95 }
96
97 // set track selector
98
99 if (m_sample == "dimuon" or m_sample == "bhabha") {
100 m_selector = TrackSelector(m_sample);
101 m_selector.setDeltaEcms(m_deltaEcms);
102 m_selector.setCutOnPOCA(m_dr, m_dz);
103 m_selector.setCutOnLocalZ(m_minZ, m_maxZ);
104 } else {
105 B2ERROR("Invalid sample type '" << m_sample << "'");
106 }
107
108 // create chi2 minimum finders
109
110 double tmin = -m_timeRange / 2;
111 double tmax = m_timeRange / 2;
112 for (int set = 0; set < c_numSets; set++) {
113 for (int slot = 1; slot <= c_numModules; slot++) {
114 m_finders[set].push_back(Chi2MinimumFinder1D(m_numBins, tmin, tmax));
115 }
116 }
117
118 // create and register histograms and tree
119
120 for (int slot = 1; slot <= c_numModules; slot++) {
121 string slotName = to_string(slot);
122 if (slot < 10) slotName.insert(0, "0");
123 string name = "chi2_slot" + slotName;
124 string title = "Chi2 scan, slot" + slotName + "; channel; t0 [ns]";
125 auto h = new TH2F(name.c_str(), title.c_str(), c_numChannels, 0, c_numChannels, m_numBins, tmin, tmax);
126 registerObject<TH2F>(name, h);
127 m_namesChi.push_back(name);
128 }
129
130 for (int slot = 1; slot <= c_numModules; slot++) {
131 string slotName = to_string(slot);
132 if (slot < 10) slotName.insert(0, "0");
133 string name = "hits_slot" + slotName;
134 string title = "Photon hits, slot" + slotName + "; channel; time [ns]";
135 auto h = new TH2F(name.c_str(), title.c_str(), c_numChannels, 0, c_numChannels, 100, 0., 20.);
136 registerObject<TH2F>(name, h);
137 m_namesHit.push_back(name);
138 }
139
140 auto h = new TH1F("moduleT0_pulls", "Module T0 pulls; pulls", 200, -15.0, 15.0);
141 registerObject<TH1F>("moduleT0_pulls", h);
142
143 auto tree = new TTree("tree", "TOP calibration validation tree");
144 tree->Branch("expNo", &m_treeEntry.expNo, "expNo/I");
145 tree->Branch("runNo", &m_treeEntry.runNo, "runNo/I");
146 tree->Branch("numTracks", &m_treeEntry.numTracks, "numTracks/I");
147 tree->Branch("commonT0", &m_treeEntry.commonT0, "commonT0/F");
148 tree->Branch("commonT0Err", &m_treeEntry.commonT0Err, "commonT0Err/F");
149 tree->Branch("moduleT0", &m_treeEntry.moduleT0, "moduleT0[16]/F");
150 tree->Branch("moduleT0Err", &m_treeEntry.moduleT0Err, "moduleT0Err[16]/F");
151 tree->Branch("numTBCalibrated", &m_treeEntry.numTBCalibrated, "numTBCalibrated[16]/I");
152 tree->Branch("numT0Calibrated", &m_treeEntry.numT0Calibrated, "numT0Calibrated[16]/I");
153 tree->Branch("numActive", &m_treeEntry.numActive, "numActive[16]/I");
154 tree->Branch("numActiveCalibrated", &m_treeEntry.numActiveCalibrated, "numActiveCalibrated[16]/I");
155 tree->Branch("thrEffi", &m_treeEntry.thrEffi, "thrEffi[16]/F");
156 tree->Branch("asicShifts", &m_treeEntry.asicShifts, "asicShifts[4]/F");
157 tree->Branch("svdOffset", &m_treeEntry.svdOffset, "svdOffset/F");
158 tree->Branch("svdSigma", &m_treeEntry.svdSigma, "svdSigma/F");
159 tree->Branch("cdcOffset", &m_treeEntry.cdcOffset, "cdcOffset/F");
160 tree->Branch("cdcSigma", &m_treeEntry.cdcSigma, "cdcSigma/F");
161 tree->Branch("fillPatternOffset", &m_treeEntry.fillPatternOffset, "fillPatternOffset/F");
162 tree->Branch("fillPatternFraction", &m_treeEntry.fillPatternFraction, "fillPatternFraction/F");
163 registerObject<TTree>("tree", tree);
164 }

◆ printModuleParams()

void printModuleParams ( ) const

Prints module parameters.

Definition at line 439 of file TOPBackgroundModule.cc.

440 {
441
442 }

◆ printTheError()

bool printTheError ( )
private

Error messages suppression logic.

Returns
true to print the error message, false to suppress it

Definition at line 234 of file TOPUnpackerModule.cc.

235 {
236 if (m_eventCount < m_errorSuppressFactor * m_numErrors) return false;
237 m_errorCount++;
238 m_resetEventCount = true;
239 return true;
240 }

◆ saveAsHistogram() [1/4]

void saveAsHistogram ( const std::vector< double > & vec,
const std::string & name,
const std::string & title,
const std::string & xTitle = "",
const std::string & yTitle = "" ) const
private

Save vector to histogram and write it out.

Parameters
vecvector of bin values
namehistogram name
titlehistogram title
xTitlex-axis title
yTitley-axis title

Definition at line 299 of file TOPDoublePulseGeneratorModule.cc.

304 {
305 if (vec.empty()) return;
306
307 TH1F h(name.c_str(), title.c_str(), vec.size(), 0, vec.size());
308 h.SetXTitle(xTitle.c_str());
309 h.SetYTitle(yTitle.c_str());
310 if (name.find("Fit") != string::npos) h.SetLineColor(2);
311
312 for (unsigned i = 0; i < vec.size(); i++) h.SetBinContent(i + 1, vec[i]);
313
314 h.Write();
315 }

◆ saveAsHistogram() [2/4]

void saveAsHistogram ( const std::vector< double > & vec,
const std::string & name,
const std::string & title,
const std::string & xTitle = "",
const std::string & yTitle = "" ) const
private

Save vector to histogram and write it out.

Parameters
vecvector of bin values
namehistogram name
titlehistogram title
xTitlex-axis title
yTitley-axis title

Definition at line 711 of file TOPTimeBaseCalibratorModule.cc.

716 {
717 if (vec.empty()) return;
718
719 TH1F h(name.c_str(), title.c_str(), vec.size(), 0, vec.size());
720 h.SetXTitle(xTitle.c_str());
721 h.SetYTitle(yTitle.c_str());
722 if (name.find("Fit") != string::npos) h.SetLineColor(2);
723
724 for (unsigned i = 0; i < vec.size(); i++) h.SetBinContent(i + 1, vec[i]);
725
726 h.Write();
727 }

◆ saveAsHistogram() [3/4]

void saveAsHistogram ( const std::vector< double > & vec,
const std::vector< double > & err,
const std::string & name,
const std::string & title,
const std::string & xTitle = "",
const std::string & yTitle = "" ) const
private

Save vector and errors to histogram and write it out.

Parameters
vecvector of bin values
errvector of bin errors
namehistogram name
titlehistogram title
xTitlex-axis title
yTitley-axis title

Definition at line 730 of file TOPTimeBaseCalibratorModule.cc.

736 {
737 if (vec.empty()) return;
738
739 TH1F h(name.c_str(), title.c_str(), vec.size(), 0, vec.size());
740 h.SetXTitle(xTitle.c_str());
741 h.SetYTitle(yTitle.c_str());
742
743 for (unsigned i = 0; i < vec.size(); i++) h.SetBinContent(i + 1, vec[i]);
744 for (unsigned i = 0; i < err.size(); i++) h.SetBinError(i + 1, err[i]);
745
746 h.Write();
747 }

◆ saveAsHistogram() [4/4]

void saveAsHistogram ( const TMatrixDSym & M,
const std::string & name,
const std::string & title ) const
private

Save matrix to histogram and write it out.

Parameters
Mmatrix
namehistogram name
titlehistogram title

Definition at line 750 of file TOPTimeBaseCalibratorModule.cc.

753 {
754 int n = M.GetNrows();
755 TH2F h(name.c_str(), title.c_str(), n, 0, n, n, 0, n);
756 h.SetXTitle("columns");
757 h.SetYTitle("rows");
758
759 for (int j = 0; j < n; j++) {
760 for (int k = 0; k < n; k++) {
761 h.SetBinContent(j + 1, n - k, M(j, k));
762 }
763 }
764
765 h.Write();
766 }

◆ setFinder()

int setFinder ( TOP::Chi2MinimumFinder1D & finder,
const TOP::PDFConstructor & reco,
double timeMin,
double timeMax )
private

Sets finder object with chi2 values.

Parameters
finderfinder object
recoreconstruction object
timeMinlower edge of photon time window
timeMaxupper edge of photon time window
Returns
number of photons in the time window

Definition at line 623 of file TOPBunchFinderModule.cc.

624 {
625 std::set<int> nfotSet; // for control only
626 const auto& binCenters = finder.getBinCenters();
627 int numPhotons = 0;
628 double logL_bkg = reco.getBackgroundLogL(timeMin, timeMax).logL;
629 for (unsigned i = 0; i < binCenters.size(); i++) {
630 double t0 = binCenters[i];
631 auto LL = reco.getLogL(t0, timeMin, timeMax, m_sigmaSmear);
632 finder.add(i, -2 * (LL.logL - logL_bkg));
633 if (i == 0) numPhotons = LL.numPhotons;
634 nfotSet.insert(LL.numPhotons);
635 }
636
637 if (nfotSet.size() != 1) B2ERROR("Different number of photons used for log likelihood of different time shifts");
638
639 return numPhotons;
640 }

◆ startRun() [1/2]

void startRun ( )
finalprivatevirtual

Replacement for beginRun().

Do anything you would normally do in beginRun here

Reimplemented from CalibrationCollectorModule.

Definition at line 60 of file TOPOffsetCollectorModule.cc.

61 {
62 auto h = getObjectPtr<TH1F>("fillPattern");
63 if (m_bunchStructure->isSet()) {
64 int RFBuckets = m_bunchStructure->getRFBucketsPerRevolution();
65 for (int i = 0; i < RFBuckets; i++) {
66 if (m_bunchStructure->getBucket(i)) h->SetBinContent(i + 1, 1);
67 }
68 }
69 }

◆ startRun() [2/2]

void startRun ( )
finalprivatevirtual

Replacement for beginRun().

Do anything you would normally do in beginRun here

Reimplemented from CalibrationCollectorModule.

Definition at line 167 of file TOPValidationCollectorModule.cc.

168 {
169 // initialize tree variables
170
171 m_treeEntry.clear();
172 StoreObjPtr<EventMetaData> evtMetaData;
173 m_treeEntry.expNo = evtMetaData->getExperiment();
174 m_treeEntry.runNo = evtMetaData->getRun();
175
176 // clear minimum finders
177
178 for (auto& finders : m_finders) {
179 for (auto& finder : finders) finder.clear();
180 }
181
182 // pass payload summaries to tree
183
184 const auto& fe_mapper = TOPGeometryPar::Instance()->getFrontEndMapper();
185 for (unsigned module = 0; module < c_numModules; module++) {
186 auto& numTBCalibrated = m_treeEntry.numTBCalibrated[module];
187 auto& numT0Calibrated = m_treeEntry.numT0Calibrated[module];
188 auto& numActive = m_treeEntry.numActive[module];
189 auto& numActiveCalibrated = m_treeEntry.numActiveCalibrated[module];
190 auto& thrEffi = m_treeEntry.thrEffi[module];
191 int slot = module + 1;
192 for (unsigned channel = 0; channel < c_numChannels; channel++) {
193 bool tbCalibrated = false;
194 const auto* fe = fe_mapper.getMap(slot, channel / 128);
195 if (fe) {
196 tbCalibrated = m_timebase->isAvailable(fe->getScrodID(), channel);
197 } else {
198 B2ERROR("No front-end map found");
199 }
200 bool t0Calibrated = m_channelT0->isCalibrated(slot, channel);
201 bool active = m_channelMask->isActive(slot, channel);
202 if (tbCalibrated) numTBCalibrated++;
203 if (t0Calibrated) numT0Calibrated++;
204 if (active) numActive++;
205 if (tbCalibrated and t0Calibrated and active) {
206 numActiveCalibrated++;
207 thrEffi += m_thresholdEff->getThrEff(slot, channel);
208 }
209 }
210 if (numActiveCalibrated > 0) thrEffi /= numActiveCalibrated;
211 }
212
213 for (unsigned carrier = 0; carrier < 4; carrier++) {
214 unsigned asic = (3 * 4 + carrier) * 4;
215 m_treeEntry.asicShifts[carrier] = m_asicShift->isCalibrated(13, asic) ? m_asicShift->getT0(13, asic) :
216 std::numeric_limits<float>::quiet_NaN();
217 }
218
219 const auto& svd = m_eventT0Offset->get(Const::SVD);
220 m_treeEntry.svdOffset = svd.offset;
221 m_treeEntry.svdSigma = svd.sigma;
222
223 const auto& cdc = m_eventT0Offset->get(Const::CDC);
224 m_treeEntry.cdcOffset = cdc.offset;
225 m_treeEntry.cdcSigma = cdc.sigma;
226
227 m_treeEntry.fillPatternOffset = m_fillPatternOffset->isCalibrated() ? m_fillPatternOffset->get() :
228 std::numeric_limits<float>::quiet_NaN();
229 m_treeEntry.fillPatternFraction = m_fillPatternOffset->getFraction();
230 }

◆ storeSampleTimes()

void storeSampleTimes ( std::string fileName)
private

Optionally store sample times used by the generator as root histograms fileName root output file name.

Definition at line 228 of file TOPDoublePulseGeneratorModule.cc.

229 {
230 if (fileName.empty()) return;
231
232 TFile* fout = TFile::Open(fileName.c_str(), "recreate");
233 if (!fout) {
234 B2ERROR("Can't open the output file " << fileName);
235 return;
236 }
237
238 const auto& feMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
239
240 TH1F scrods("scrodID", "scrod ID's mapped to slots/boardstacks", 64, -0.5, 63.5);
241 scrods.SetXTitle("(slot - 1) * 4 + boardstack");
242 scrods.SetYTitle("scrod ID");
243
244 for (auto moduleID : m_moduleIDs) {
245 for (int bs = 0; bs < 4; bs++) {
246 const auto* feMap = feMapper.getMap(moduleID, bs);
247 if (!feMap) {
248 B2ERROR("No front-end mapping available for slot " << moduleID
249 << " boardstack " << bs);
250 continue;
251 }
252 unsigned scrodID = feMap->getScrodID();
253 std::string subdir = "scrod" + std::to_string(scrodID);
254 int i = (moduleID - 1) * 4 + bs;
255 scrods.SetBinContent(i + 1, scrodID);
256 fout->mkdir(subdir.c_str());
257 }
258 }
259 scrods.Write();
260
261 for (auto moduleID : m_moduleIDs) {
262 for (unsigned asic = 0; asic < 64; asic++) {
263 int bs = asic / 16;
264 const auto* feMap = feMapper.getMap(moduleID, bs);
265 if (!feMap) continue;
266 unsigned scrodID = feMap->getScrodID();
267 std::string subdir = "scrod" + std::to_string(scrodID);
268 fout->cd(subdir.c_str());
269 for (auto asicChannel : m_asicChannels) {
270 unsigned channel = (asic * 8 + asicChannel) % 128;
271 const TOPSampleTimes* sampleTimes = &m_sampleTimes;
272 if (m_useDatabase) {
273 sampleTimes = (*m_timebase)->getSampleTimes(scrodID, channel);
274 }
275 string forWhat = "scrod " + to_string(scrodID) +
276 " channel " + to_string(channel) +
277 " (slot" + to_string(moduleID) + ", as" + to_string(asic) +
278 ", ch" + to_string(asicChannel) + ")";
279 auto timeAxis = sampleTimes->getTimeAxis();
280 saveAsHistogram(timeAxis, "sampleTimes_ch" + to_string(channel),
281 "Generator input: sample times for " + forWhat,
282 "sample number", "t [ns]");
283 std::vector<double> dt;
284 for (unsigned i = 1; i < timeAxis.size(); i++) {
285 dt.push_back(timeAxis[i] - timeAxis[i - 1]);
286 }
287 saveAsHistogram(dt, "dt_ch" + to_string(channel),
288 "Generator input: sample time bins for " + forWhat,
289 "sample number", "#Delta t [ns]");
290 }
291 }
292 }
293
294 fout->Close();
295
296 }

◆ terminate() [1/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 252 of file TOPAlignerModule.cc.

253 {
254
255 m_file->cd();
256 m_alignTree->Write();
257
258 TH1F valid("valid", "status valid", 16, 0.5, 16.5);
259 valid.SetXTitle("slot ID");
260 valid.SetBinContent(m_targetMid, m_valid);
261 valid.Write();
262
263 TH1F ntrk("ntrk", "number of tracks", 16, 0.5, 16.5);
264 ntrk.SetXTitle("slot ID");
265 ntrk.SetBinContent(m_targetMid, m_ntrk);
266 ntrk.Write();
267
268 std::string name, title;
269 name = "results_slot" + to_string(m_targetMid);
270 title = "alignment parameters, slot " + to_string(m_targetMid);
271 int npar = m_align.getParams().size();
272 TH1F h0(name.c_str(), title.c_str(), npar, 0, npar);
273 const auto& par = m_align.getParams();
274 const auto& err = m_align.getErrors();
275 for (int i = 0; i < npar; i++) {
276 h0.SetBinContent(i + 1, par[i]);
277 h0.SetBinError(i + 1, err[i]);
278 }
279 h0.Write();
280
281 name = "errMatrix_slot" + to_string(m_targetMid);
282 title = "error matrix, slot " + to_string(m_targetMid);
283 TH2F h1(name.c_str(), title.c_str(), npar, 0, npar, npar, 0, npar);
284 const auto& errMatrix = m_align.getErrorMatrix();
285 for (int i = 0; i < npar; i++) {
286 for (int k = 0; k < npar; k++) {
287 h1.SetBinContent(i + 1, k + 1, errMatrix[i][k]);
288 }
289 }
290 h1.Write();
291
292 name = "corMatrix_slot" + to_string(m_targetMid);
293 title = "correlation matrix, slot " + to_string(m_targetMid);
294 TH2F h2(name.c_str(), title.c_str(), npar, 0, npar, npar, 0, npar);
295 std::vector<double> diag;
296 for (int i = 0; i < npar; i++) {
297 double d = errMatrix[i][i];
298 if (d != 0) d = 1.0 / sqrt(d);
299 diag.push_back(d);
300 }
301 for (int i = 0; i < npar; i++) {
302 for (int k = 0; k < npar; k++) {
303 h2.SetBinContent(i + 1, k + 1, diag[i] * diag[k] * errMatrix[i][k]);
304 }
305 }
306 h2.Write();
307
308 m_file->Close();
309
310 if (m_valid) {
311 B2RESULT("TOPAligner: slot = " << m_targetMid << ", status = successful, "
312 << "iterations = " << m_iter << ", tracks used = " << m_ntrk);
313 } else {
314 B2RESULT("TOPAligner: slot = " << m_targetMid << ", status = failed, "
315 << "error code = " << m_errorCode
316 << ", iterations = " << m_iter << ", tracks used = " << m_ntrk);
317 }
318 }

◆ terminate() [2/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 404 of file TOPBackgroundModule.cc.

405 {
406 /*
407 myprint(peflux, ("peflux_" + m_BkgType + ".pdf").c_str(), "#phi", "MHz / PMT", 1.);
408 myprint(zdist, ("zdist_" + m_BkgType + ".pdf").c_str(), "z[cm]", "", 0.0);
409 myprint(nflux, ("nflux_" + m_BkgType + ".pdf").c_str(), "#phi", "neutrons / cm^{2} / year", 0.0);
410 myprint(rdose, ("rdose_" + m_BkgType + ".pdf").c_str(), "#phi", "Gy/year", 0.0);
411 */
412
413 m_rootFile->cd();
414 origingamma->Write();
415 originpe->Write();
416 peflux->Write();
417 zdist->Write();
418 nflux->Write();
419 rdose->Write();
420 genergy->Write();
421 genergy2->Write();
422 nflux_bar->Write();
423 gflux_bar->Write();
424 origin_zx->Write();
425 origin_zy->Write();
426 module_occupancy->Write();
427 gorigin->Write();
428 norigin->Write();
429 zdistg->Write();
430 originpt->Write();
431 m_rootFile->Close();
432
433 // Announce
434 B2INFO("TOPBackground finished");
435
436
437 }

◆ terminate() [3/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 557 of file TOPBunchFinderModule.cc.

558 {
559 B2RESULT("TOPBunchFinder: event T0 determined for " << m_success << "/"
560 << m_processed << " events");
561 }

◆ terminate() [4/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 259 of file TOPChannelT0CalibratorModule.cc.

260 {
261
262 // determine scaling factor for errors from two statistically independent results
263
264 TH1F h_pulls("pulls", "Pulls of the two statistically independent results",
265 200, -15.0, 15.0);
266 h_pulls.SetXTitle("pulls");
267 for (unsigned module = 0; module < c_numModules; module++) {
268 for (unsigned channel = 0; channel < c_numChannels; channel++) {
269 std::vector<double> pos, err;
270 for (int i = 0; i < 2; i++) {
271 const auto& minimum = m_finders[i][module][channel].getMinimum();
272 if (not minimum.valid) continue;
273 pos.push_back(minimum.position);
274 err.push_back(minimum.error);
275 }
276 if (pos.size() < 2) continue;
277 double pull = (pos[0] - pos[1]) / sqrt(err[0] * err[0] + err[1] * err[1]);
278 h_pulls.Fill(pull);
279 }
280 }
281 h_pulls.Write();
282 double scaleError = h_pulls.GetRMS();
283
284 // merge two statistically independent finders and store results into histograms
285
286 for (unsigned module = 0; module < c_numModules; module++) {
287 int moduleID = module + 1;
288
289 std::string slotNum = std::to_string(moduleID);
290 if (moduleID < 10) slotNum = "0" + slotNum;
291
292 std::string name = "channelT0_slot" + slotNum;
293 std::string title = "Relative channel T0 for slot " + slotNum;
294 TH1F h_channelT0(name.c_str(), title.c_str(), c_numChannels, 0, c_numChannels);
295 h_channelT0.SetXTitle("channel number");
296 h_channelT0.SetYTitle("relative channel T0 [ns]");
297
298 for (unsigned channel = 0; channel < c_numChannels; channel++) {
299 auto& finder = m_finders[0][module][channel].add(m_finders[1][module][channel]);
300 const auto& minimum = finder.getMinimum();
301 if (minimum.valid) {
302 h_channelT0.SetBinContent(channel + 1, minimum.position);
303 h_channelT0.SetBinError(channel + 1, minimum.error * scaleError);
304 }
305 }
306
307 h_channelT0.Write();
308
309 }
310
311 // merge all finders of a slot to find module T0
312
313 TH1F h_moduleT0("moduleT0", "Relative module T0",
314 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
315 h_moduleT0.SetXTitle("slot number");
316 h_moduleT0.SetYTitle("relative module T0 [ns]");
317 auto finderCommon = m_finders[0][0][0];
318 finderCommon.clear();
319 for (unsigned module = 0; module < c_numModules; module++) {
320 auto finder = m_finders[0][module][0];
321 finder.clear();
322 for (unsigned channel = 0; channel < c_numChannels; channel++) {
323 finder.add(m_finders[0][module][channel]);
324 }
325 finderCommon.add(finder);
326 const auto& minimum = finder.getMinimum();
327 if (minimum.valid) {
328 h_moduleT0.SetBinContent(module + 1, minimum.position);
329 h_moduleT0.SetBinError(module + 1, minimum.error * scaleError);
330 }
331 }
332 h_moduleT0.Write();
333
334 // find common T0
335
336 TH1F h_commonT0("commonT0", "Relative common T0", 1, 0, 1);
337 h_commonT0.SetYTitle("relative common T0 [ns]");
338 const auto& minimum = finderCommon.getMinimum();
339 if (minimum.valid) {
340 h_commonT0.SetBinContent(1, minimum.position);
341 h_commonT0.SetBinError(1, minimum.error * scaleError);
342 }
343 h_commonT0.Write();
344
345 // write other histograms and ntuple; close the file
346
347 for (auto& h : m_hits1D) h.Write();
348 for (auto& h : m_hits2D) h.Write();
349
350 m_tree->Write();
351 m_file->Close();
352
353 B2RESULT("Results available in " << m_outFileName);
354 }

◆ terminate() [5/23]

void terminate ( void )
overridevirtual

Termination action.

Output MC extraction

Reimplemented from Module.

Definition at line 93 of file TOPChannelT0MCModule.cc.

94 {
95 auto file = new TFile(m_outputFile.c_str(), "RECREATE");
96 auto otree = new TTree("t0MC", "extract channel t0 info. from MC");
97
98 unsigned channel = 0;
99 double maxpos = 0;
100
101 otree->Branch("maxpos", &maxpos, "maxpos/D");
102 otree->Branch("channel", &channel, "channel/I");
103
104 for (int i = 0; i < c_NumChannels; i++) {
105 channel = i;
106 maxpos = m_histo[i]->GetXaxis()->GetBinCenter(m_histo[i]->GetMaximumBin());
107 otree->Fill();
108 }
109 otree->Write();
110 delete otree;
111 file->Close();
112 delete file;
113 }

◆ terminate() [6/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 243 of file TOPCommonT0CalibratorModule.cc.

244 {
245
246 // determine scaling factor for errors from statistically independent results
247
248 TH1F h_pulls("pulls", "Pulls of statistically independent results",
249 200, -15.0, 15.0);
250 h_pulls.SetXTitle("pulls");
251 std::vector<double> pos, err;
252 for (int i = 0; i < c_numSets; i++) {
253 const auto& minimum = m_finders[i].getMinimum();
254 if (not minimum.valid) continue;
255 pos.push_back(minimum.position);
256 err.push_back(minimum.error);
257 }
258 for (unsigned i = 0; i < pos.size(); i++) {
259 for (unsigned j = i + 1; j < pos.size(); j++) {
260 double pull = (pos[i] - pos[j]) / sqrt(err[i] * err[i] + err[j] * err[j]);
261 h_pulls.Fill(pull);
262 }
263 }
264 h_pulls.Write();
265 double scaleError = 1;
266 if (h_pulls.GetEntries() > 1) scaleError = h_pulls.GetRMS();
267
268 // merge statistically independent finders and store results into histograms
269
270 auto finder = m_finders[0];
271 for (int i = 1; i < c_numSets; i++) {
272 finder.add(m_finders[i]);
273 }
274
275 TH1F h_relCommonT0("relCommonT0", "relative common T0", 1, 0, 1);
276 h_relCommonT0.SetYTitle("common T0 residual [ns]");
277 TH1F h_commonT0("commonT0", "Common T0", 1, 0, 1);
278 h_commonT0.SetYTitle("common T0 [ns]");
279
280 const auto& minimum = finder.getMinimum();
281 auto h = finder.getHistogram("chi2", "chi2");
282 h.Write();
283 if (minimum.valid) {
284 h_relCommonT0.SetBinContent(1, minimum.position);
285 h_relCommonT0.SetBinError(1, minimum.error * scaleError);
286 double T0 = minimum.position;
287 if (m_commonT0->isCalibrated()) T0 += m_commonT0->getT0();
288 T0 -= round(T0 / m_bunchTimeSep) * m_bunchTimeSep; // wrap around
289 h_commonT0.SetBinContent(1, T0);
290 h_commonT0.SetBinError(1, minimum.error * scaleError);
291 }
292 h_relCommonT0.Write();
293 h_commonT0.Write();
294
295 // write other histograms and ntuple; close the file
296
297 m_hits1D.Write();
298 m_hits2D.Write();
299 m_tree->Write();
300 m_file->Close();
301
302 B2RESULT("Results available in " << m_outFileName);
303 }

◆ terminate() [7/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 249 of file TOPCosmicT0FinderModule.cc.

250 {
251 B2RESULT("TOPCosmicT0Finder: accepted events " << m_acceptedCount
252 << ", event T0 determined for " << m_successCount << " events");
253 }

◆ terminate() [8/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 223 of file TOPDoublePulseGeneratorModule.cc.

224 {
225 }

◆ terminate() [9/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from HistoModule.

Definition at line 173 of file TOPGainEfficiencyCalculatorModule.cc.

174 {
175 //first, check validity of input parameters
176 bool areGoodParameters = true;
177 if (m_targetSlotId < 1 || m_targetSlotId > c_NModule) {
178 B2ERROR("TOPGainEfficiencyCalculator : invalid slotID : " << m_targetSlotId);
179 areGoodParameters = false;
180 }
181 if (m_targetPmtId < 1 || m_targetPmtId > c_NPMTPerModule) {
182 B2ERROR("TOPGainEfficiencyCalculator : invalid PMT ID : " << m_targetPmtId);
183 areGoodParameters = false;
184 }
185 if (m_pedestalSigma < 1e-6) {
186 B2ERROR("TOPGainEfficiencyCalculator : pedestal sigma must be non-zero positive value");
187 areGoodParameters = false;
188 }
189
190 //do not proceed to the main process unless all the input parameters are not valid
191 if (areGoodParameters) {
192 if (m_outputPDFFile.size() == 0) {
193 if (m_inputFile.rfind(".") == std::string::npos)
194 m_outputPDFFile = m_inputFile;
195 else
196 m_outputPDFFile = m_inputFile.substr(0, m_inputFile.rfind("."));
197 }
198
199 //gain run using height distribution
200 LoadHistograms("Height_gain");
201 FitHistograms(c_LoadForFitHeight);
202 DrawResult("Height_gain", c_LoadForFitHeight);
203
204 //efficiency run
205 LoadHistograms("Height_efficiency");
206 FitHistograms(c_LoadHitRateHeight);
207 DrawResult("Height_efficiency", c_LoadHitRateHeight);
208
209 //gain run using integral distribution
210 LoadHistograms("Integral_gain");
211 FitHistograms(c_LoadForFitIntegral);
212 DrawResult("Integral_gain", c_LoadForFitIntegral);
213
214 }
215 }

◆ terminate() [10/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from HistoModule.

Definition at line 335 of file TOPInterimFENtupleModule.cc.

336 {
337 }

◆ terminate() [11/23]

void terminate ( void )
overridevirtual

Termination action.

Do fits , clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 113 of file TOPLaserCalibratorModule.cc.

114 {
115 std::vector<TH1F*> v_histo;
116 for (int i = 0; i < c_NumChannels; ++i) {
117 v_histo.push_back(m_histo[i]);
118 }
119
120 double dataT[c_NumChannels] = {0};
121 double dataTErr[c_NumChannels] = {0};
122 double mcT[c_NumChannels] = {0};
123
124 TOP::LaserCalibratorFit t0fit(m_barID);
125 t0fit.setHist(v_histo); //set time hist vector
126 t0fit.setFitMethod(m_fitMethod);
127 t0fit.setFitRange(m_fitRange[1], m_fitRange[2]);
128 if (m_fitChannel == c_NumChannels) {
129 for (int i = 0; i < c_NumChannels; ++i) {
130 t0fit.fitChannel(i);
131 dataT[i] = t0fit.getFitT();
132 dataTErr[i] = t0fit.getFitTErr();
133 }
134 } else {
135 t0fit.fitChannel(m_fitChannel);
136 dataT[m_fitChannel] = t0fit.getFitT();
137 }
138 //cout<<"chisq=\t"<<t0fit.getFitChisq(6)<<endl;
139 t0fit.writeFile(m_dataFitOutput); //write to root file
140
141 //read laser propagation time from MC (TOPChannelT0MC)
142 auto mcFile = new TFile(m_mcInput.c_str());
143 auto tree = static_cast<TTree*>(mcFile->Get("t0MC"));
144 int channel_mc;
145 double maxpos;
146
147 tree->SetBranchAddress("channel", &channel_mc);
148 tree->SetBranchAddress("maxpos", &maxpos);
149 for (int i = 0; i < tree->GetEntries(); i++) {
150 tree->GetEntry(i);
151 mcT[channel_mc] = maxpos;
152 }
153
154 //w.r.t. ref. channel
155 for (int i = 0; i < c_NumChannels; i++) {
156 if (i == m_refCh) continue;
157 dataT[i] = dataT[i] - dataT[m_refCh];
158 mcT[i] = mcT[i] - mcT[m_refCh];
159 }
160
161 delete tree;
162 mcFile->Close();
163 delete mcFile;
164
165 //calculate T0 Const, write to root file
166 auto file = new TFile(m_chT0C.c_str(), "RECREATE");
167 auto otree = new TTree("chT0", "Channel T0 Const");
168
169 unsigned channel = 0;
170 double t0_const = 0;
171 double t0ConstRaw = 0;
172 double fittedTime = 0;
173 double fittedTimeError = 0;
174 double mcTime = 0;
175 double mcCorrection = 0;
176 double t0ConstError = 0;
177
178 otree->Branch("fittedTime", &fittedTime, "fittedTime/D");
179 otree->Branch("fittedTimeError", &fittedTimeError, "fittedTimeError/D");
180 otree->Branch("mcTime", &mcTime, "mcTime/D");
181 otree->Branch("t0ConstRaw", &t0ConstRaw, "t0ConstRaw/D");
182 otree->Branch("mcCorrection", &mcCorrection, "mcCorrection/D");
183 otree->Branch("t0Const", &t0_const, "t0_const/D");
184 otree->Branch("t0ConstError", &t0ConstError, "t0ConstError/D");
185 otree->Branch("channel", &channel, "channel/I");
186 otree->Branch("slot", &m_barID, "slot/I");
187
188 for (int i = 0; i < c_NumChannels; i++) {
189 if (i == m_refCh) {
190 fittedTime = dataT[i];
191 mcTime = mcT[i];
192 } else {
193 fittedTime = dataT[i] + dataT[m_refCh];
194 mcTime = mcT[i] + mcT[m_refCh];
195 }
196 fittedTimeError = dataTErr[i];
197 t0ConstRaw = dataT[i];
198 mcCorrection = mcT[i];
199 channel = i;
200 t0_const = dataT[i] - mcT[i];
201 // assuming that the MC error is negligible
202 t0ConstError = TMath::Sqrt(dataTErr[i] * dataTErr[i] + dataTErr[m_refCh] * dataTErr[m_refCh]);
203 if (i == m_refCh) {
204 t0_const = 0;
205 t0ConstError = dataTErr[m_refCh];
206 }
207 otree->Fill();
208 }
209 otree->Write();
210 delete otree;
211 file->Close();
212 delete file;
213
214 // ...
215 // write to database; next to do ...
216 // ...
217 }

◆ terminate() [12/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from HistoModule.

Definition at line 260 of file TOPLaserHitSelectorModule.cc.

261 {
262 }

◆ terminate() [13/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 146 of file TOPMCTrackMakerModule.cc.

147 {
148 }

◆ terminate() [14/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 252 of file TOPModuleT0CalibratorModule.cc.

253 {
254 // determine scaling factor for errors from two statistically independent results
255
256 TH1F h_pulls("pulls", "Pulls of the two statistically independent results",
257 200, -15.0, 15.0);
258 h_pulls.SetXTitle("pulls");
259 for (unsigned module = 0; module < c_numModules; module++) {
260 std::vector<double> pos, err;
261 for (int i = 0; i < 2; i++) {
262 const auto& minimum = m_finders[i][module].getMinimum();
263 if (not minimum.valid) continue;
264 pos.push_back(minimum.position);
265 err.push_back(minimum.error);
266 }
267 if (pos.size() < 2) continue;
268 double pull = (pos[0] - pos[1]) / sqrt(err[0] * err[0] + err[1] * err[1]);
269 h_pulls.Fill(pull);
270 }
271 h_pulls.Write();
272 double scaleError = h_pulls.GetRMS();
273
274 // merge two statistically independent finders and store results into histograms
275
276 TH1F h_relModuleT0("relModuleT0", "Module T0 relative to calibration",
277 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
278 h_relModuleT0.SetXTitle("slot number");
279 h_relModuleT0.SetYTitle("module T0 residual [ns]");
280
281 for (unsigned module = 0; module < c_numModules; module++) {
282 auto& finder = m_finders[0][module].add(m_finders[1][module]);
283 const auto& minimum = finder.getMinimum();
284 if (minimum.valid) {
285 h_relModuleT0.SetBinContent(module + 1, minimum.position);
286 h_relModuleT0.SetBinError(module + 1, minimum.error * scaleError);
287 }
288 std::string slotNum = to_string(module + 1);
289 auto h = finder.getHistogram("chi2_slot_" + slotNum, "slot " + slotNum);
290 h.Write();
291 }
292 h_relModuleT0.Write();
293
294 // absolute module T0
295 TH1F h_moduleT0("moduleT0", "Module T0",
296 c_numModules, 0.5, static_cast<float>(c_numModules) + 0.5);
297 h_moduleT0.SetXTitle("slot number");
298 h_moduleT0.SetYTitle("module T0 [ns]");
299
300 double average = 0; // average to be subtracted
301 int num = 0;
302 for (int slot = 1; slot <= c_numModules; slot++) {
303 if (h_relModuleT0.GetBinError(slot) > 0) {
304 double T0 = 0;
305 if (m_moduleT0->isCalibrated(slot)) T0 = m_moduleT0->getT0(slot);
306 average += h_relModuleT0.GetBinContent(slot) + T0;
307 num++;
308 }
309 }
310 if (num > 0) average /= num;
311
312 for (int slot = 1; slot <= c_numModules; slot++) {
313 double T0 = 0;
314 if (m_moduleT0->isCalibrated(slot)) T0 = m_moduleT0->getT0(slot);
315 double t0 = h_relModuleT0.GetBinContent(slot) + T0 - average;
316 double err = h_relModuleT0.GetBinError(slot);
317 h_moduleT0.SetBinContent(slot, t0);
318 h_moduleT0.SetBinError(slot, err);
319 }
320 h_moduleT0.Write();
321
322 // write other histograms and ntuple; close the file
323
324 m_hits1D.Write();
325 m_hits2D.Write();
326 m_tree->Write();
327 m_file->Close();
328
329 B2RESULT(num << "/16 calibrated. Results available in " << m_outFileName);
330 }

◆ terminate() [15/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 274 of file TOPNtupleModule.cc.

275 {
276 TDirectory::TContext context;
277 m_file->cd();
278 m_tree->Write();
279 m_file->Close();
280 }

◆ terminate() [16/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 127 of file TOPPackerModule.cc.

128 {
129 }

◆ terminate() [17/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from HistoModule.

Definition at line 182 of file TOPPDFCheckerModule.cc.

183 {
184 m_avrgPosition *= 1.0 / m_numTracks;
185 m_avrgMomentum *= 1.0 / m_numTracks;
186
187 cout << "Average particle parameters at entrance to bar (in local frame):" << endl;
188 cout << " slot ID: ";
189 for (auto slot : m_slotIDs) cout << slot << " ";
190 cout << endl;
191 cout << " PDG code: ";
192 for (auto pdg : m_PDGCodes) cout << pdg << " ";
193 cout << endl;
194 cout << " position: x = " << m_avrgPosition.X()
195 << ", y = " << m_avrgPosition.Y()
196 << ", z = " << m_avrgPosition.Z() << endl;
197 cout << " momentum: p = " << m_avrgMomentum.R()
198 << ", theta = " << m_avrgMomentum.Theta() / Unit::deg
199 << ", phi = " << m_avrgMomentum.Phi() / Unit::deg << endl;
200 cout << "Number of particles: " << m_numTracks << endl;
201 cout << "Photons per particle: simulation = " << m_hits->GetSum() / m_numTracks
202 << ", PDF = " << m_pdf->GetSum() / m_numTracks << endl;
203
204 }

◆ terminate() [18/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 481 of file TOPRawDigitConverterModule.cc.

482 {
483 }

◆ terminate() [19/23]

void terminate ( void )
overridevirtual

Termination action.

The historam writing takes place here

Reimplemented from HistoModule.

Definition at line 453 of file TOPTBCComparatorModule.cc.

454 {
455 // writes the histos
456 B2INFO("Creating output file " << m_outputFile);
457 TFile outfile(m_outputFile.c_str(), "recreate");
458
459 B2INFO("Writing histograms ");
460
461 // opens the input list to retrive, one last time, the labels
462 ifstream inputDirectoryListFile(m_inputDirectoryList.c_str());
463 std::string inputString;
464 int iSet = 0;
465
466 while (std::getline(inputDirectoryListFile, inputString)) {
467 parseInputDirectoryLine(inputString);
468 TDirectory* dirSet = outfile.mkdir(m_calSetLabel.c_str());
469 dirSet->cd();
470
471 m_topAverageDeltaT[iSet]->Write();
472 m_topSigmaDeltaT[iSet]->Write();
473 m_topSampleOccupancy[iSet]->Write();
474 m_topAverageDeltaTComparison[iSet]->Write();
475 m_topSigmaDeltaTComparison[iSet]->Write();
476 m_topSampleOccupancyComparison[iSet]->Write();
477
478 for (int iSlot = 0; iSlot < 16; iSlot ++) {
479 TDirectory* dirSlot = dirSet->mkdir(str(format("slot%1%") % (iSlot + 1)).c_str());
480 dirSlot->cd();
481
482 m_slotAverageDeltaT[iSlot][iSet]->Write();
483 m_slotSigmaDeltaT[iSlot][iSet]->Write();
484 m_slotAverageDeltaTMap[iSlot][iSet]->Write();
485 m_slotSigmaDeltaTMap[iSlot][iSet]->Write();
486 m_slotSampleOccupancy[iSlot][iSet]->Write();
487 m_slotEmptySamples[iSlot][iSet]->Write();
488 m_slotSampleOccupancyMap[iSlot][iSet]->Write();
489 m_slotEmptySamplesMap[iSlot][iSet]->Write();
490
491 m_slotAverageDeltaTComparison[iSlot][iSet]->Write();
492 m_slotSigmaDeltaTComparison[iSlot][iSet]->Write();
493 m_slotAverageDeltaTMapComparison[iSlot][iSet]->Write();
494 m_slotSigmaDeltaTMapComparison[iSlot][iSet]->Write();
495 }
496 dirSet->cd();
497 iSet++;
498 }
499 }

◆ terminate() [20/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 220 of file TOPTimeBaseCalibratorModule.cc.

221 {
222
223 const auto& feMapper = TOPGeometryPar::Instance()->getFrontEndMapper();
224
225 for (unsigned bs = 0; bs < c_NumBoardstacks; bs ++) {
226
227 // determine scrod ID
228
229 const auto* feMap = feMapper.getMap(m_moduleID, bs);
230 if (!feMap) {
231 B2ERROR("No front-end map available for slot " << m_moduleID << ", BS" << bs);
232 continue;
233 }
234 unsigned scrodID = feMap->getScrodID();
235
236 // open output root file
237
238 string fileName = m_directoryName + "/tbcSlot";
239 if (m_moduleID < 10) {
240 fileName += "0" + to_string(m_moduleID);
241 } else {
242 fileName += to_string(m_moduleID);
243 }
244 fileName += "_" + to_string(bs) + "-scrod" +
245 to_string(scrodID) + ".root";
246 TFile* fout = TFile::Open(fileName.c_str(), "recreate");
247 if (!fout) {
248 B2ERROR("Can't open the output file " << fileName);
249 continue;
250 }
251
252 // write control histograms
253
254 m_goodHits.Write();
255 m_calPulseFirst.Write();
256 m_calPulseSecond.Write();
257
258 B2INFO("Fitting time base corrections for SCROD " << scrodID
259 << ", output file: " << fileName);
260
261 // book histograms
262
263 TH1F Hchan("channels", "channels with cal pulse",
264 c_NumScrodChannels, 0, c_NumScrodChannels);
265 Hchan.SetXTitle("channel number");
266 Hchan.SetYTitle("double cal pulse counts");
267 TH1F Hsuccess("success", "successfuly fitted channels",
268 c_NumScrodChannels, 0, c_NumScrodChannels);
269 Hsuccess.SetXTitle("channel number");
270 TH1F Hchi2("chi2", "normalized chi2",
271 c_NumScrodChannels, 0, c_NumScrodChannels);
272 Hchi2.SetXTitle("channel number");
273 Hchi2.SetYTitle("chi2/ndf");
274 TH1F Hndf("ndf", "degrees of freedom",
275 c_NumScrodChannels, 0, c_NumScrodChannels);
276 Hndf.SetXTitle("channel number");
277 Hndf.SetYTitle("ndf");
278 TH1F HDeltaT("DeltaT", "Fitted double pulse delay time",
279 c_NumScrodChannels, 0, c_NumScrodChannels);
280 HDeltaT.SetXTitle("channel number");
281 HDeltaT.SetYTitle("#Delta T [ns]");
282
283 // loop over channels of a single SCROD
284
285 for (unsigned chan = 0; chan < c_NumScrodChannels; chan++) {
286 unsigned channel = chan + bs * c_NumScrodChannels;
287 auto& ntuple = m_ntuples[channel];
288 Hchan.SetBinContent(chan + 1, ntuple.size());
289 if (ntuple.size() > m_minHits) {
290 bool ok = calibrateChannel(ntuple, scrodID, chan, Hchi2, Hndf, HDeltaT);
291 if (ok) Hsuccess.Fill(chan);
292 } else {
293 B2INFO("... channel " << chan << " statistics too low ("
294 << ntuple.size() << " double cal pulses)");
295 }
296 }
297
298 // write histograms and close the file
299
300 Hchan.Write();
301 Hsuccess.Write();
302 Hchi2.Write();
303 Hndf.Write();
304 HDeltaT.Write();
305 fout->Close();
306
307 }
308 }

◆ terminate() [21/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 154 of file TOPTriggerDigitizerModule.cc.

155 {
156
157 }

◆ terminate() [22/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 1254 of file TOPUnpackerModule.cc.

1255 {
1256 }

◆ terminate() [23/23]

void terminate ( void )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 144 of file TOPWaveformFeatureExtractorModule.cc.

145 {
146 }

◆ TOPAlignerModule()

Constructor.

Definition at line 44 of file TOPAlignerModule.cc.

44 : Module()
45
46 {
47 // set module description
48 setDescription("Alignment of TOP");
49 // setPropertyFlags(c_ParallelProcessingCertified);
50
51 // Add parameters
52 addParam("targetModule", m_targetMid,
53 "Module to be aligned. Must be 1 <= Mid <= 16.", 1);
54 addParam("maxFails", m_maxFails,
55 "Maximum number of consecutive failed iterations before resetting the procedure", 100);
56 addParam("sample", m_sample,
57 "sample type: one of dimuon, bhabha or cosmics", std::string("dimuon"));
58 addParam("minMomentum", m_minMomentum,
59 "minimal track momentum if sample is cosmics", 1.0);
60 addParam("deltaEcms", m_deltaEcms,
61 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
62 addParam("dr", m_dr, "cut on POCA in r", 2.0);
63 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
64 addParam("minZ", m_minZ,
65 "minimal local z of extrapolated hit", -130.0);
66 addParam("maxZ", m_maxZ,
67 "maximal local z of extrapolated hit", 130.0);
68 addParam("outFileName", m_outFileName,
69 "Root output file name containing alignment results",
70 std::string("TopAlignPars.root"));
71 addParam("stepPosition", m_stepPosition, "step size for translations", 1.0);
72 addParam("stepAngle", m_stepAngle, "step size for rotations", 0.01);
73 addParam("stepTime", m_stepTime, "step size for t0", 0.05);
74 std::string names;
75 for (const auto& parName : m_align.getParameterNames()) names += parName + ", ";
76 names.pop_back();
77 names.pop_back();
78 addParam("parInit", m_parInit,
79 "initial parameter values in the order [" + names + "]. "
80 "If list is too short, the missing ones are set to 0.", m_parInit);
81 auto parFixed = m_parFixed;
82 addParam("parFixed", m_parFixed, "list of names of parameters to be fixed. "
83 "Valid names are: " + names, parFixed);
84
85 }

◆ TOPAlignmentCollectorModule()

Constructor.

Definition at line 42 of file TOPAlignmentCollectorModule.cc.

43 {
44 // set module description and processing properties
45 setDescription("A collector for geometrical alignment of a TOP module with dimuons or Bhabhas. Iterative alignment procedure (NIMA 876 (2017) 260-264) is run here, algorithm just collects the results.");
46 setPropertyFlags(c_ParallelProcessingCertified);
47
48 // module parameters
49 addParam("targetModule", m_targetMid,
50 "Module to be aligned. Must be 1 <= Mid <= 16.");
51 addParam("maxFails", m_maxFails,
52 "Maximum number of consecutive failed iterations before resetting the procedure", 100);
53 addParam("sample", m_sample,
54 "sample type: one of dimuon or bhabha", std::string("dimuon"));
55 addParam("deltaEcms", m_deltaEcms,
56 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
57 addParam("dr", m_dr, "cut on POCA in r", 1.0);
58 addParam("dz", m_dz, "cut on POCA in abs(z)", 2.0);
59 addParam("minZ", m_minZ, "minimal local z of extrapolated hit", -130.0);
60 addParam("maxZ", m_maxZ, "maximal local z of extrapolated hit", 130.0);
61 addParam("stepPosition", m_stepPosition, "step size for translations", 1.0);
62 addParam("stepAngle", m_stepAngle, "step size for rotations", 0.01);
63 addParam("stepTime", m_stepTime, "step size for t0", 0.05);
64 std::string names;
65 auto align = ModuleAlignment();
66 for (const auto& parName : align.getParameterNames()) names += parName + ", ";
67 names.pop_back();
68 names.pop_back();
69 addParam("parInit", m_parInit,
70 "initial parameter values in the order [" + names + "]. "
71 "If list is too short, the missing ones are set to 0.", m_parInit);
72 auto parFixed = m_parFixed;
73 addParam("parFixed", m_parFixed, "list of names of parameters to be fixed. "
74 "Valid names are: " + names, parFixed);
75
76 }

◆ TOPAsicShiftsBS13dCollectorModule()

Constructor.

Definition at line 36 of file TOPAsicShiftsBS13dCollectorModule.cc.

37 {
38 // set module description and processing properties
39 setDescription("A collector for calibration of carrier shifts of BS13d.");
40 setPropertyFlags(c_ParallelProcessingCertified);
41
42 // module parameters
43 addParam("timeOffset", m_timeOffset, "time offset", 0.0);
44 addParam("nx", m_nx, "number of histogram bins (bin size ~8 ns)", 50);
45 addParam("requireRecBunch", m_requireRecBunch,
46 "if True, require reconstructed bunch (to be used on cdst files only!)",
47 false);
48
49 }

◆ TOPBackgroundModule()

Constructor.

Definition at line 59 of file TOPBackgroundModule.cc.

59 : Module(),
60 m_rootFile(0),
61 origingamma(0),
62 originpe(0),
63 peflux(0),
64 nflux(0),
65 rdose(0),
66 zdist(0),
67 genergy(0),
68 genergy2(0),
69 zdistg(0),
70 originpt(0),
71 nflux_bar(0),
72 gflux_bar(0),
73 cflux_bar(0),
74 norigin(0),
75 gorigin(0),
76 corigin(0),
77 nprim(0),
78 gprim(0),
79 cprim(0),
80 origin_zx(0),
81 origin_zy(0),
82 prim_zx(0),
83 prim_zy(0),
84 module_occupancy(0),
85 PCBmass(0),
86 PCBarea(0),
87 yearns(0),
88 evtoJ(0),
89 mtoc(0),
90 count(0),
91 count_occ(0),
92 origingamma_x(0),
93 origingamma_y(0),
94 origingamma_z(0),
95 originpe_x(0),
96 originpe_y(0),
97 originpe_z(0)
98 {
99 // Set description()
100 setDescription("A module to analyze beam background simulations regarding TOP");
101
102 // Add parameters
103 addParam("Type", m_BkgType, "Backgound type", string("Backgound"));
104 addParam("Output", m_OutputFileName, "Name of the output file",
105 string("Backgound.root"));
106 addParam("TimeOfSimulation", m_TimeOfSimulation,
107 "Real time in micro seconds that corresponds to simulated data", 5.);
108 }

◆ TOPBunchFinderModule()

Constructor.

Definition at line 53 of file TOPBunchFinderModule.cc.

53 : Module()
54 {
55 // set module description (e.g. insert text)
56 setDescription("A precise event T0 determination w.r.t local time reference of TOP counter. "
57 "Results available in TOPRecBunch.");
58 setPropertyFlags(c_ParallelProcessingCertified);
59
60 // Add parameters
61 addParam("numBins", m_numBins, "number of bins of fine search region", 200);
62 addParam("timeRangeFine", m_timeRangeFine,
63 "time range in which to do fine search [ns]", 10.0);
64 addParam("timeRangeCoarse", m_timeRangeCoarse,
65 "time range in which to do coarse search, if autoRange turned off [ns]", 100.0);
66 addParam("autoRange", m_autoRange,
67 "turn on/off automatic determination of the coarse search region (false means off)", false);
68 addParam("sigmaSmear", m_sigmaSmear,
69 "sigma in [ns] for additional smearing of PDF", 0.0);
70 addParam("minSignal", m_minSignal,
71 "minimal number of signal photons to accept track", 8.0);
72 addParam("minSBRatio", m_minSBRatio,
73 "minimal signal-to-background ratio to accept track", 0.0);
74 addParam("minDERatio", m_minDERatio,
75 "minimal ratio of detected-to-expected photons to accept track", 0.2);
76 addParam("maxDERatio", m_maxDERatio,
77 "maximal ratio of detected-to-expected photons to accept track", 2.5);
78 addParam("minPt", m_minPt, "minimal p_T of the track", 0.3);
79 addParam("maxPt", m_maxPt, "maximal p_T of the track", 6.0);
80 addParam("maxD0", m_maxD0, "maximal absolute value of helix perigee distance", 2.0);
81 addParam("maxZ0", m_maxZ0, "maximal absolute value of helix perigee z coordinate", 4.0);
82 addParam("minNHitsCDC", m_minNHitsCDC, "minimal number of hits in CDC", 20);
83 addParam("useMCTruth", m_useMCTruth,
84 "if true, use MC truth for particle mass instead of the most probable from dEdx",
85 false);
86 addParam("saveHistograms", m_saveHistograms,
87 "if true, save histograms to TOPRecBunch and TOPTimeZeros", false);
88 addParam("tau", m_tau,
89 "first order filter time constant [number of events]", 100.0);
90 addParam("correctDigits", m_correctDigits,
91 "if true, subtract bunch time in TOPDigits", true);
92 addParam("subtractRunningOffset", m_subtractRunningOffset,
93 "if true and correctDigits = True, subtract running offset in TOPDigits "
94 "when running in HLT mode. It must be set to false when running calibration.",
95 true);
96 addParam("bunchesPerSSTclk", m_bunchesPerSSTclk,
97 "number of bunches per SST clock period", 24);
98 addParam("usePIDLikelihoods", m_usePIDLikelihoods,
99 "use PIDLikelihoods instead of DedxLikelihoods (only if run on cdst files)",
100 false);
101 addParam("nTrackLimit", m_nTrackLimit,
102 "maximum number of tracks (inclusive) to use three particle hypotheses in fine search "
103 "(only when running in data processing mode).", unsigned(3));
104 addParam("useTimeSeed", m_useTimeSeed, "use SVD or CDC event T0 as a seed "
105 "(only when running in data processing mode and autoRange turned off).", true);
106 addParam("useFillPattern", m_useFillPattern, "use known accelerator fill pattern to enhance efficiency "
107 "(only when running in data processing mode).", true);
108 }

◆ TOPCalPulseGeneratorModule()

Constructor.

Definition at line 45 of file TOPCalPulseGeneratorModule.cc.

45 : Module()
46
47 {
48 // set module description
49 setDescription("Realistic generator of calibration double pulses. "
50 "Needs TOPDigitizer to digitize");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // Add parameters
54 addParam("moduleIDs", m_moduleIDs,
55 "list of slots for which to generate cal pulse, empty list means all slots.",
56 m_moduleIDs);
57 m_asicChannels.push_back(0);
58 addParam("asicChannels", m_asicChannels,
59 "ASIC calibration channels (0 - 7), empty list means all channels.",
60 m_asicChannels);
61 // default for these three below are set according to laser run 8/414
62 addParam("amplitude", m_amplitude, "amplitude of cal pulse [ADC counts]", 600.0);
63 addParam("delay", m_delay, "delay of cal pulse [ns]", 10.5);
64 addParam("windowSize", m_windowSize, "size of time window in which to generate cal pulses [ns]", 8.0);
65 }

◆ TOPChannelMaskCollectorModule()

Constructor.

Definition at line 31 of file TOPChannelMaskCollectorModule.cc.

32 {
33 // set module description and processing properties
34 setDescription("A collector for preparing masks of dead and hot channels");
35 setPropertyFlags(c_ParallelProcessingCertified);
36 }

◆ TOPChannelMaskerModule()

Constructor: Sets the description of the module.

Definition at line 32 of file TOPChannelMaskerModule.cc.

32 : Module()
33 {
34 // Set module properties
35 setDescription("Masks dead, hot and uncalibrated channels from the reconstruction");
36
37 // Set property flags
38 setPropertyFlags(c_ParallelProcessingCertified);
39
40 // Add parameters
41 addParam("maskUncalibratedChannelT0", m_maskUncalibratedChannelT0,
42 "if true, mask channelT0-uncalibrated channels", true);
43 addParam("maskUncalibratedTimebase", m_maskUncalibratedTimebase,
44 "if true, mask timebase-uncalibrated channels ", true);
45 }

◆ TOPChannelT0CalibratorModule()

Constructor.

Definition at line 38 of file TOPChannelT0CalibratorModule.cc.

38 : Module()
39
40 {
41 // set module description
42 setDescription("Alternative channel T0 calibration with dimuons or bhabhas. "
43 "This module can also be used to check the calibration "
44 "(channel, module and common T0).\n"
45 "Note: after this kind of calibration one cannot do the alignment.");
46 // setPropertyFlags(c_ParallelProcessingCertified);
47
48 // Add parameters
49 addParam("numBins", m_numBins, "number of bins of the search region", 200);
50 addParam("timeRange", m_timeRange,
51 "time range in which to search for the minimum [ns]", 10.0);
52 addParam("sigmaSmear", m_sigmaSmear,
53 "sigma in [ns] for additional smearing of PDF", 0.0);
54 addParam("sample", m_sample,
55 "sample type: one of dimuon, bhabha or cosmics", std::string("dimuon"));
56 addParam("minMomentum", m_minMomentum,
57 "minimal track momentum if sample is cosmics", 1.0);
58 addParam("deltaEcms", m_deltaEcms,
59 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
60 addParam("dr", m_dr, "cut on POCA in r", 2.0);
61 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
62 addParam("minZ", m_minZ,
63 "minimal local z of extrapolated hit", -130.0);
64 addParam("maxZ", m_maxZ,
65 "maximal local z of extrapolated hit", 130.0);
66 addParam("outputFileName", m_outFileName,
67 "Root output file name containing calibration results. "
68 "File name can include *'s; "
69 "they will be replaced with a run number from the first input file",
70 std::string("calibrationT0_r*.root"));
71 addParam("pdfOption", m_pdfOption,
72 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
73
74 }

◆ TOPChannelT0MCModule()

Constructor.

Definition at line 40 of file TOPChannelT0MCModule.cc.

40 : Module()
41 {
42 std::vector<double> frange = {100, 0., 1.};
43 // set module description (e.g. insert text)
44 setDescription("TOP channel T0 Calibration of MC extraction");
45 // Add parameters
46 addParam("outputFile", m_outputFile, "Output root file name",
47 string(""));
48 addParam("fitRange", m_fitRange, "fit range[nbins, xmin, xmax]", frange);
49
50 }

◆ TOPCommonT0BFCollectorModule()

Constructor.

Definition at line 35 of file TOPCommonT0BFCollectorModule.cc.

36 {
37 // set module description and processing properties
38 setDescription("A collector for common T0 calibration with a fit of bunch finder residuals (method BF)");
39 setPropertyFlags(c_ParallelProcessingCertified);
40
41 // module parameters
42 addParam("bunchesPerSSTclk", m_bunchesPerSSTclk,
43 "number of bunches per SST clock period", 24);
44 addParam("nx", m_nx, "number of histogram bins", 200);
45
46 }

◆ TOPCommonT0CalibratorModule()

Constructor.

Definition at line 37 of file TOPCommonT0CalibratorModule.cc.

37 : Module()
38
39 {
40 // set module description
41 setDescription("Common T0 calibration with dimuons or bhabhas.");
42 // setPropertyFlags(c_ParallelProcessingCertified);
43
44 // Add parameters
45 addParam("numBins", m_numBins, "number of bins of the search region", 200);
46 addParam("timeRange", m_timeRange,
47 "time range in which to search for the minimum [ns]", 10.0);
48 addParam("sigmaSmear", m_sigmaSmear,
49 "sigma in [ns] for additional smearing of PDF", 0.0);
50 addParam("sample", m_sample,
51 "sample type: one of dimuon, bhabha or cosmics", std::string("dimuon"));
52 addParam("minMomentum", m_minMomentum,
53 "minimal track momentum if sample is cosmics", 1.0);
54 addParam("deltaEcms", m_deltaEcms,
55 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
56 addParam("dr", m_dr, "cut on POCA in r", 2.0);
57 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
58 addParam("minZ", m_minZ,
59 "minimal local z of extrapolated hit", -130.0);
60 addParam("maxZ", m_maxZ,
61 "maximal local z of extrapolated hit", 130.0);
62 addParam("outputFileName", m_outFileName,
63 "Root output file name containing calibration results. "
64 "File name can include *'s; "
65 "they will be replaced with a run number from the first input file",
66 std::string("commonT0_r*.root"));
67 addParam("pdfOption", m_pdfOption,
68 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
69
70 }

◆ TOPCommonT0LLCollectorModule()

Constructor.

Definition at line 45 of file TOPCommonT0LLCollectorModule.cc.

46 {
47 // set module description and processing properties
48 setDescription("A collector for common T0 calibration with dimuons or Bhabha's using "
49 "neg. log likelihood minimization (method LL)");
50 setPropertyFlags(c_ParallelProcessingCertified);
51
52 // module parameters
53 addParam("bunchesPerSSTclk", m_bunchesPerSSTclk,
54 "number of bunches per SST clock period", 24);
55 addParam("numBins", m_numBins, "number of bins of the search region", 200);
56 addParam("timeRange", m_timeRange,
57 "time range in which to search for the minimum [ns]", 10.0);
58 addParam("sigmaSmear", m_sigmaSmear,
59 "sigma in [ns] for additional smearing of PDF", 0.0);
60 addParam("sample", m_sample,
61 "sample type: one of dimuon or bhabha", std::string("dimuon"));
62 addParam("deltaEcms", m_deltaEcms,
63 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
64 addParam("dr", m_dr, "cut on POCA in r", 2.0);
65 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
66 addParam("minZ", m_minZ,
67 "minimal local z of extrapolated hit", -130.0);
68 addParam("maxZ", m_maxZ,
69 "maximal local z of extrapolated hit", 130.0);
70 addParam("pdfOption", m_pdfOption,
71 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
72 }

◆ TOPCosmicT0FinderModule()

Constructor.

Definition at line 56 of file TOPCosmicT0FinderModule.cc.

56 : Module()
57
58 {
59 // set module description
60 setDescription("Event T0 finder for global cosmic runs");
61 setPropertyFlags(c_ParallelProcessingCertified);
62
63 // Add parameters
64 addParam("useIncomingTrack", m_useIncomingTrack,
65 "if true, use incoming track, otherwise use outcoming track", true);
66 addParam("minHits", m_minHits,
67 "minimal number of detected photons in a module", (unsigned) 10);
68 addParam("minSignal", m_minSignal,
69 "minimal number of expected signal photons", 5.0);
70 addParam("applyT0", m_applyT0, "if true, subtract T0 in TOPDigits", true);
71 addParam("numBins", m_numBins, "number of bins time range is divided to", 200);
72 addParam("timeRange", m_timeRange, "time range in which to search [ns]", 10.0);
73 addParam("sigma", m_sigma, "additional time spread added to PDF [ns]", 0.0);
74 addParam("saveHistograms", m_saveHistograms,
75 "save histograms to TOPTimeZero", false);
76 }

◆ TOPDigitizerModule()

Constructor.

Definition at line 50 of file TOPDigitizerModule.cc.

50 : Module()
51 {
52 // Set description()
53 setDescription("Digitize TOPSimHits");
54 setPropertyFlags(c_ParallelProcessingCertified);
55
56 // Add parameters
57 addParam("timeZeroJitter", m_timeZeroJitter,
58 "r.m.s of T0 jitter [ns]", 15e-3);
59 addParam("electronicJitter", m_electronicJitter,
60 "r.m.s of electronic jitter [ns], "
61 "if negative the one from TOPNominalTDC is used. "
62 "This parameter is ignored in the full waveform digitization.", -1.0);
63 addParam("darkNoise", m_darkNoise,
64 "uniformly distributed dark noise (hits per module)", 0.0);
65 addParam("ADCx0", m_ADCx0,
66 "pulse height distribution parameter [ADC counts]", 204.1);
67 addParam("ADCp1", m_ADCp1,
68 "pulse height distribution parameter (must be non-negative)", 1.0);
69 addParam("ADCp2", m_ADCp2,
70 "pulse height distribution parameter (must be non-negative)", 1.025);
71 addParam("ADCmax", m_ADCmax,
72 "pulse height distribution upper bound [ADC counts]", 2000.0);
73 addParam("rmsNoise", m_rmsNoise,
74 "r.m.s of noise [ADC counts]", 9.7);
75 addParam("threshold", m_threshold,
76 "pulse height threshold [ADC counts]", 40);
77 addParam("hysteresis", m_hysteresis,
78 "pulse height threshold hysteresis [ADC counts]", 10);
79 addParam("thresholdCount", m_thresholdCount,
80 "minimal number of samples above threshold", 3);
81 addParam("useWaveforms", m_useWaveforms,
82 "if true, use full waveform digitization", true);
83 addParam("allChannels", m_allChannels,
84 "if true, make waveforms for all 8192 channels "
85 "(note: this will slow-down digitization)", false);
86 addParam("useDatabase", m_useDatabase,
87 "if true, use channel dependent constants from database (incl. time base)",
88 true);
89 addParam("useSampleTimeCalibration", m_useSampleTimeCalibration,
90 "if true, use only time base calibration from database "
91 "(has no effect if useDatabase = True)", false);
92 addParam("simulateTTS", m_simulateTTS,
93 "if true, simulate time transition spread. "
94 "Should be always switched ON, except for some dedicated timing studies.",
95 true);
96 addParam("minWidthXheight", m_minWidthXheight,
97 "minimal product of width and height [ns * ADC counts]", 100.0);
98 addParam("lookBackWindows", m_lookBackWindows,
99 "number of look back windows, if positive override the number from database", 0);
100 }

◆ TOPDoublePulseGeneratorModule()

Constructor.

Definition at line 52 of file TOPDoublePulseGeneratorModule.cc.

52 : Module()
53
54 {
55 // set module description
56 setDescription("Generator of calibration double pulses");
57 setPropertyFlags(c_ParallelProcessingCertified);
58
59 // Add parameters
60 addParam("moduleIDs", m_moduleIDs,
61 "list of slots for which to generate cal pulse, empty list means all slots.",
62 m_moduleIDs);
63 m_asicChannels.push_back(0);
64 addParam("asicChannels", m_asicChannels,
65 "ASIC calibration channels (0 - 7), empty list means all channels.",
66 m_asicChannels);
67 addParam("timeDifference", m_timeDifference,
68 "time difference between first and second pulse [ns].", 21.87);
69 addParam("timeResolution", m_timeResolution,
70 "sigma of time difference [ns].", 40.0e-3);
71 addParam("sampleTimeIntervals", m_sampleTimeIntervals,
72 "vector of 256 sample time intervals to construct sample times. "
73 "If empty, equidistant intervals will be used.", m_sampleTimeIntervals);
74 addParam("useDatabase", m_useDatabase,
75 "if true, use sample times from database instead of sampleTimeIntervals.",
76 false);
77 addParam("storageWindows", m_storageWindows,
78 "number of storage windows (old FW used 64 out of 512)", (unsigned) 512);
79 addParam("outputFileName", m_outputFileName,
80 "if given, sample times will be saved as root histograms in this file",
81 std::string(""));
82
83 }

◆ TOPDQMModule()

Constructor.

Definition at line 41 of file TOPDQMModule.cc.

41 : HistoModule()
42 {
43 // set module description (e.g. insert text)
44 setDescription("TOP DQM histogrammer");
45 setPropertyFlags(c_ParallelProcessingCertified);
46
47 // Add parameters
48 addParam("histogramDirectoryName", m_histogramDirectoryName,
49 "histogram directory in ROOT file", string("TOP"));
50 addParam("momentumCut", m_momentumCut,
51 "momentum cut used to histogram number of photons per track", 0.5);
52 }

◆ TOPGainEfficiencyCalculatorModule()

Constructor.

Definition at line 47 of file TOPGainEfficiencyCalculatorModule.cc.

47 : HistoModule()
48 {
49 // Set description()
50 setDescription("Calculate pixel gain and efficiency for a given PMT from 2D histogram of hit timing and pulse charge, "
51 "created by TOPLaserHitSelectorModule.");
52
53 // Add parameters
54 addParam("inputFile", m_inputFile, "input file name containing 2D histogram", std::string(""));
55 addParam("outputPDFFile", m_outputPDFFile, "output PDF file to store plots", std::string(""));
56 addParam("targetSlotId", m_targetSlotId, "TOP module ID in slot number (1-16)", (short)0);
57 addParam("targetPmtId", m_targetPmtId, "PMT number (1-32)", (short)0);
58 addParam("targetPmtChId", m_targetPmtChId, "PMT channel number (1-16)", (short) - 1);
59 addParam("hvDiff", m_hvDiff, "HV difference from nominal HV value", (short)0);
60 addParam("fitHalfWidth", m_fitHalfWidth, "half fit width for direct laser hit peak in [ns] unit", (float)1.0);
61 addParam("threshold", m_threshold,
62 "pulse height (or integrated charge) threshold in fitting its distribution and calculating efficiency", (float)100.);
63 addParam("p0HeightIntegral", m_p0HeightIntegral,
64 "Parameter from p0 + x*p1 function fitting height-integral distribtion.", (float) - 50.0);
65 addParam("p1HeightIntegral", m_p1HeightIntegral,
66 "Parameter from p0 + x*p1 function fitting height-integral distribtion.", (float)6.0);
67 addParam("fracFit", m_fracFit, "fraction of events to be used in fitting. "
68 "An upper limit of a fit range is given to cover this fraction of events. "
69 "Set negative value to calculate the fraction to exclude only 10 events in tail.", (float)(-1)); //,(float)0.99);
70 addParam("initialP0", m_initialP0, "initial value of the fit parameter p0 divided by histogram entries."
71 "Set negative value to calculate from histogram inforamtion automatically.", (float)(0.0001)); //,(float)1e-6);
72 addParam("initialP1", m_initialP1, "initial value of the fit parameter p1."
73 "Set negative value to calculate from histogram inforamtion automatically.", (float)(1.0)); //,(float)1.0);
74 addParam("initialP2", m_initialP2, "initial value of the fit parameter p2."
75 "Set negative value to calculate from histogram inforamtion automatically.", (float)(1.0)); //,(float)1.0);
76 addParam("initialX0", m_initialX0, "initial value of the fit parameter x0 divided by histogram bin width."
77 "Set negative value to calculate from histogram inforamtion automatically.", (float)(100)); //, (float)100.);
78 addParam("pedestalSigma", m_pedestalSigma, "sigma of pedestal width", (float)10.);
79 addParam("fitoption", m_fitoption, "fit option likelihood: default chisquare: R", std::string("L"));
80
81 }

◆ TOPGainFunc()

double TOPGainFunc ( double * var,
double * par )
static

Fit function of pulse charge (or charnge) distribution for channel(pixel)-by-channel gain extraction, given by "[0]*pow(x-[4],[1])*exp(-pow(x-[4],[2])/[3])" smeared by Gaussian with a constant sigma to consider baseline fluctuation.

Definition at line 625 of file TOPGainEfficiencyCalculatorModule.cc.

626 {
627
628 double pedestal = par[4];
629 double pedestalWidth = par[5];
630 double x = (var[0] - pedestal);
631
632 double output = 0;
633 double step = pedestalWidth / 100.;
634 double t = TMath::Max(step, x - pedestalWidth * 10);
635 //double t = TMath::Max( g_xStep, x ); //for test
636 while (t < x + pedestalWidth * 10) {
637 output += TMath::Gaus(x, t, pedestalWidth) * TMath::Power(t / par[3], par[1])
638 * TMath::Exp((-1) * TMath::Power(t / par[3], par[2]));
639 t += step;
640 }
641 // TF1* func = new TF1( "func", "[0]*pow(x-[4],[1])*exp(-pow(x-[4],[2])/[3])",
642
643 return par[0] * output * step;
644 }

◆ TOPGeometryParInitializerModule()

Constructor.

Definition at line 39 of file TOPGeometryParInitializerModule.cc.

39 : Module()
40
41 {
42 // set module description
43 setDescription("Class for initializing TOPGeometryPar. "
44 "This class is by default initialized when Geant geometry is created. "
45 "Useful if Geant geometry is not needed. Be carefull when using!");
46 setPropertyFlags(c_ParallelProcessingCertified);
47
48 // Add parameters
49 addParam("useDB", m_useDB,
50 "If true load the Geometry from the database instead of the gearbox", true);
51 }

◆ TOPInterimFENtupleModule()

Constructor.

Definition at line 47 of file TOPInterimFENtupleModule.cc.

47 : HistoModule()
48 {
49 setDescription("Create ntuple mainly from TOPDigit with double pulse identification. "
50 "Data taken with both InterimFE FW and production FW are available. (since Jan, 2017)");
51
52 addParam("calibrationChannel", m_calibrationChannel, "asic channel # where calibration pulses routed",
53 (unsigned)0);
54 addParam("saveWaveform", m_saveWaveform, "whether to save waveform data or not",
55 (bool)false);
56 addParam("useDoublePulse", m_useDoublePulse,
57 "set true when you require both of double calibration pulses for reference timing. You need to enable offline feature extraction.",
58 (bool)true);
59 // addParam("averageSamplingRate", m_averageSamplingRate, "sampling rate with assumption of uniform interval in a unit of GHz",
60 // (float)2.71394);
61 addParam("minHeightFirstCalPulse", m_calibrationPulseThreshold1, "pulse height threshold for the first cal. pulse",
62 (float)600.);
63 addParam("minHeightSecondCalPulse", m_calibrationPulseThreshold2, "pulse height threshold for the second cal. pulse",
64 (float)450.);
65 addParam("nominalDeltaT", m_calibrationPulseInterval, "nominal DeltaT (time interval of the double calibration pulses) [ns]",
66 (float)21.85);
67 addParam("nominalDeltaTRange", m_calibrationPulseIntervalRange,
68 "acceptable DeltaT shift from the noinal value before calibration [ns]",
69 (float)2.);
70 addParam("globalRefSlotNum", m_globalRefSlotNum,
71 "slot number where a global reference asic exists. slot01-asic0 (pixelId=1-8) is default.", 1);
72 addParam("globalRefAsicNum", m_globalRefAsicNum,
73 "asic number defined as int((pixelId-1)/8) of a global reference asic", 0);
74
75 addParam("timePerWin", m_timePerWin, "time interval of a single window (=64 samples) [ns]", (float)23.581939);
76 }

◆ TOPLaserCalibratorModule()

Constructor.

Definition at line 49 of file TOPLaserCalibratorModule.cc.

49 : Module()
50 {
51 setDescription("T0 Calibration using the laser calibration system");
52
53 std::vector<double> frange = {100, 0., 1.};
54 // Add parameters
55 addParam("dataFitOutput", m_dataFitOutput, "Output root file for data",
56 string("")); //output fitting results
57 addParam("mcInput", m_mcInput, "Input root file from MC", string(""));
58 addParam("channelT0constant", m_chT0C, "Output of channel T0 constant", string(""));
59 addParam("fitChannel", m_fitChannel, "set 0 - 511 to a specific channel; set 0 to all channels in the fit",
60 512);
61 addParam("barID", m_barID, "ID of TOP module to calibrate");
62 addParam("refCh", m_refCh, "reference channel of T0 constant");
63 addParam("fitMethod", m_fitMethod, "gauss: single gaussian; cb: single Crystal Ball; cb2: double Crystal Ball", string("gauss"));
64 addParam("fitRange", m_fitRange, "fit range[nbins, xmin, xmax]", frange);
65
66 for (int i = 0; i < c_NumChannels; ++i) {
67 m_histo[i] = 0;
68 }
69 }

◆ TOPLaserHitSelectorModule()

Constructor.

Definition at line 44 of file TOPLaserHitSelectorModule.cc.

44 : HistoModule()
45 {
46 // Set description()
47 setDescription("TOP pixel-by-pixel gain analysis - first step : create hit timing-pulse charge histogram");
48
49 // Add parameters
50 m_timeHistogramBinning.push_back(140);//140 for time axis
51 m_timeHistogramBinning.push_back(-55);//-25
52 m_timeHistogramBinning.push_back(15);//45
53 m_chargeHistogramBinning.push_back(125);//for height
54 m_chargeHistogramBinning.push_back(-50);//
55 m_chargeHistogramBinning.push_back(2450);//
56 m_chargeHistogramBinning.push_back(150);//for integral
57 m_chargeHistogramBinning.push_back(-500);//
58 m_chargeHistogramBinning.push_back(29500);//
59
60 addParam("timeHistogramBinning", m_timeHistogramBinning,
61 "histogram binning (the number of bins, lower limit, upper limit) for hit timing distribution (should be integer value)",
62 m_timeHistogramBinning);
63 addParam("chargeHistogramBinning", m_chargeHistogramBinning,
64 "histogram binning (the number of bins, lower limit, upper limit) for pulse charge distribution (should be integer value)",
65 m_chargeHistogramBinning);
66
67 // addParam("calibrationChannel", m_calibrationChannel, "asic channel # where calibration pulses routed",
68 // (unsigned)0);
69 addParam("useDoublePulse", m_useDoublePulse,
70 "set true when you require both of double calibration pulses for reference timing. You need to enable offline feature extraction.",
71 (bool)true);
72 addParam("minHeightFirstCalPulse", m_calibrationPulseThreshold1, "pulse height threshold for the first cal. pulse",
73 (float)300.);
74 addParam("minHeightSecondCalPulse", m_calibrationPulseThreshold2, "pulse height threshold for the second cal. pulse",
75 (float)100.);
76 addParam("nominalDeltaT", m_calibrationPulseInterval, "nominal DeltaT (time interval of the double calibration pulses) [ns]",
77 (float)25.5);
78 addParam("nominalDeltaTRange", m_calibrationPulseIntervalRange,
79 "acceptable DeltaT range from the nominal value before calibration [ns]",
80 (float)2.);
81 addParam("windowSelect", m_windowSelect,
82 "select window number (All=0, Odd=2, Even=1)",
83 0);
84 addParam("includePrimaryChargeShare", m_includePrimaryChargeShare,
85 "set ture when you require without primary chargeshare cut for making 2D histogram",
86 (bool)false);
87 addParam("includeAllChargeShare", m_includeAllChargeShare,
88 "set ture when you require without all chargeshare cut for making 2D histogram",
89 (bool)false);
90 }

◆ TOPMCTrackMakerModule()

Constructor.

Definition at line 45 of file TOPMCTrackMakerModule.cc.

45 : Module()
46
47 {
48 // set module description (e.g. insert text)
49 setDescription("Constructs Tracks and ExtHits from MCParticles and TOPBarHits. "
50 "Utility needed for testing and debugging of TOP reconstruction.");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // Add parameters
54
55 }

◆ TOPModuleT0CalibratorModule()

Constructor.

Definition at line 36 of file TOPModuleT0CalibratorModule.cc.

36 : Module()
37
38 {
39 // set module description
40 setDescription("Module T0 calibration with dimuons or bhabhas. "
41 "Useful when the geometrical alignment is fine.");
42 // setPropertyFlags(c_ParallelProcessingCertified);
43
44 // Add parameters
45 addParam("numBins", m_numBins, "number of bins of the search region", 200);
46 addParam("timeRange", m_timeRange,
47 "time range in which to search for the minimum [ns]", 10.0);
48 addParam("sigmaSmear", m_sigmaSmear,
49 "sigma in [ns] for additional smearing of PDF", 0.0);
50 addParam("sample", m_sample,
51 "sample type: one of dimuon, bhabha or cosmics", std::string("dimuon"));
52 addParam("minMomentum", m_minMomentum,
53 "minimal track momentum if sample is cosmics", 1.0);
54 addParam("deltaEcms", m_deltaEcms,
55 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
56 addParam("dr", m_dr, "cut on POCA in r", 2.0);
57 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
58 addParam("minZ", m_minZ,
59 "minimal local z of extrapolated hit", -130.0);
60 addParam("maxZ", m_maxZ,
61 "maximal local z of extrapolated hit", 130.0);
62 addParam("outputFileName", m_outFileName,
63 "Root output file name containing calibration results. "
64 "File name can include *'s; "
65 "they will be replaced with a run number from the first input file",
66 std::string("moduleT0_r*.root"));
67 addParam("pdfOption", m_pdfOption,
68 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
69
70 }

◆ TOPModuleT0DeltaTCollectorModule()

Constructor.

Definition at line 32 of file TOPModuleT0DeltaTCollectorModule.cc.

33 {
34 // set module description and processing properties
35 setDescription("A collector for module T0 calibration with chi2 minimization of "
36 "time differences between slots (method DeltaT). Useful for initial "
37 "(rough) calibration, since the results are found slightly biased. "
38 "For the final (precise) calibration one has to use LL method.");
39 setPropertyFlags(c_ParallelProcessingCertified);
40
41 // module parameters
42 addParam("numBins", m_numBins,
43 "number of bins of histograms of time difference", 400);
44 addParam("timeRange", m_timeRange,
45 "time range [ns] of histograms of time difference", 20.0);
46
47 }

◆ TOPModuleT0LLCollectorModule()

Constructor.

Definition at line 45 of file TOPModuleT0LLCollectorModule.cc.

46 {
47 // set module description and processing properties
48 setDescription("A collector for module T0 calibration with neg. log likelihood "
49 "minimization (method LL). Aimed for the final (precise) calibration"
50 "after initial one with DeltaT method.");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // module parameters
54 addParam("numBins", m_numBins, "number of bins of the search region", 200);
55 addParam("timeRange", m_timeRange,
56 "time range in which to search for the minimum [ns]", 10.0);
57 addParam("sigmaSmear", m_sigmaSmear,
58 "sigma in [ns] for additional smearing of PDF", 0.0);
59 addParam("sample", m_sample,
60 "sample type: one of dimuon or bhabha", std::string("dimuon"));
61 addParam("deltaEcms", m_deltaEcms,
62 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
63 addParam("dr", m_dr, "cut on POCA in r", 2.0);
64 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
65 addParam("minZ", m_minZ,
66 "minimal local z of extrapolated hit", -130.0);
67 addParam("maxZ", m_maxZ,
68 "maximal local z of extrapolated hit", 130.0);
69 addParam("pdfOption", m_pdfOption,
70 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
71
72 }

◆ TOPNtupleModule()

Constructor.

Definition at line 57 of file TOPNtupleModule.cc.

57 : Module()
58 {
59 // set module description
60 setDescription("Writes ntuple of TOPLikelihoods with tracking info into a root file");
61
62 // Add parameters
63 addParam("outputFileName", m_outputFileName, "Output file name",
64 string("TOPNtuple.root"));
65
66 }

◆ TOPOffsetCollectorModule()

Constructor.

Definition at line 32 of file TOPOffsetCollectorModule.cc.

33 {
34 // set module description and processing properties
35 setDescription("A collector for eventT0 and fill pattern offset calibrations");
36 setPropertyFlags(c_ParallelProcessingCertified);
37
38 }

◆ TOPPackerModule()

Constructor.

Definition at line 48 of file TOPPackerModule.cc.

48 : Module()
49 {
50 // set module description (e.g. insert text)
51 setDescription("Raw data packer for TOP");
52 setPropertyFlags(c_ParallelProcessingCertified);
53
54 // Add parameters
55 addParam("inputDigitsName", m_inputDigitsName,
56 "name of TOPDigit store array", string(""));
57 addParam("inputRawDigitsName", m_inputRawDigitsName,
58 "name of TOPRawDigit store array", string(""));
59 addParam("outputRawDataName", m_outputRawDataName,
60 "name of RawTOP store array", string(""));
61 addParam("format", m_format,
62 "data format (draft, FE, production)", string("production"));
63
64 }

◆ TOPPDFCheckerModule()

Constructor.

Definition at line 52 of file TOPPDFCheckerModule.cc.

52 : HistoModule()
53
54 {
55 // set module description
56 setDescription("Module for checking analytic PDF used in likelihood calculation");
57 setPropertyFlags(c_ParallelProcessingCertified);
58
59 // Add parameters
60 addParam("minTime", m_minTime,
61 "histogram lower bound in time [ns]", 0.0);
62 addParam("maxTime", m_maxTime,
63 "histogram upper bound in time [ns]", 50.0);
64 addParam("numBins", m_numBins,
65 "histogram number of bins in time", 1000);
66
67 }

◆ TOPPDFDebuggerModule()

Constructor.

Definition at line 49 of file TOPPDFDebuggerModule.cc.

49 : Module()
50 {
51 // Set description
52 setDescription("This module makes an analytic PDF available in "
53 "a store array TOPPDFCollections, related from Tracks");
54
55 // Set property flags
56 setPropertyFlags(c_ParallelProcessingCertified);
57
58 // Add parameters
59 addParam("minTime", m_minTime,
60 "lower limit for photon time [ns] (default from DB used, if minTime >= maxTime)", 0.0);
61 addParam("maxTime", m_maxTime,
62 "upper limit for photon time [ns] (default from DB used, if minTime >= maxTime)", 0.0);
63 addParam("pdfOption", m_pdfOption,
64 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("fine"));
65 addParam("pdgCodes", m_pdgCodes,
66 "PDG codes of charged stable particles for which to construct PDF. "
67 "Empty list means all charged stable particles.",
68 m_pdgCodes);
69 }

◆ TOPPhotonYieldsCollectorModule()

Constructor.

Definition at line 42 of file TOPPhotonYieldsCollectorModule.cc.

43 {
44 // set module description and processing properties
45 setDescription("A collector for photon pixel yields aimed for PMT ageing studies and for finding optically decoupled PMT's");
46 setPropertyFlags(c_ParallelProcessingCertified);
47
48 // module parameters
49 addParam("sample", m_sample, "sample type: one of dimuon or bhabha", std::string("dimuon"));
50 addParam("deltaEcms", m_deltaEcms, "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
51 addParam("dr", m_dr, "cut on POCA in r", 2.0);
52 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
53
54 }

◆ TOPPulseHeightCollectorModule()

Constructor.

Definition at line 31 of file TOPPulseHeightCollectorModule.cc.

32 {
33 // set module description and processing properties
34 setDescription("A collector for channel pulse-height distributions");
35 setPropertyFlags(c_ParallelProcessingCertified);
36
37 // module parameters
38 addParam("nx", m_nx, "number of histogram bins", 200);
39 addParam("xmax", m_xmax, "histogram upper limit [ADC counts]", 2000.0);
40 addParam("pulseWidthWindow", m_widthWindow,
41 "lower and upper bound of pulse-width selection window [ns]. "
42 "Empty list means no selection on the pulse width. "
43 "Note: selection on pulse width will influence pulse-height distribution.",
44 m_widthWindow);
45 addParam("timeWindow", m_timeWindow,
46 "lower and upper bound of time selection window [ns]. "
47 "Empty list means no selection on photon time.", m_timeWindow);
48
49 }

◆ TOPRawDigitConverterModule()

Constructor.

Definition at line 48 of file TOPRawDigitConverterModule.cc.

48 : Module()
49
50 {
51 // set module description (e.g. insert text)
52 setDescription("Converts row digits to digits and applies time calibration");
53 setPropertyFlags(c_ParallelProcessingCertified);
54
55 // Add parameters
56 addParam("inputRawDigitsName", m_inputRawDigitsName,
57 "name of TOPRawDigit store array", string(""));
58 addParam("outputDigitsName", m_outputDigitsName,
59 "name of TOPDigit store array", string(""));
60 addParam("useSampleTimeCalibration", m_useSampleTimeCalibration,
61 "if true, use sample time calibration", true);
62 addParam("useAsicShiftCalibration", m_useAsicShiftCalibration,
63 "if true, use ASIC shifts calibration", true);
64 addParam("useChannelT0Calibration", m_useChannelT0Calibration,
65 "if true, use channel T0 calibration", true);
66 addParam("useModuleT0Calibration", m_useModuleT0Calibration,
67 "if true, use module T0 calibration", true);
68 addParam("useCommonT0Calibration", m_useCommonT0Calibration,
69 "if true, use common T0 calibration", true);
70 addParam("useTimeWalkCalibration", m_useTimeWalkCalibration,
71 "if true, use time-walk calibration", true);
72 addParam("pedestalRMS", m_pedestalRMS,
73 "r.m.s of pedestals [ADC counts], "
74 "if positive, timeError will be estimated from FE data. "
75 "This is the default value used if r.m.s is not available from DB.", 9.7);
76 addParam("minPulseWidth", m_minPulseWidth,
77 "minimal pulse width [ns] to flag digit as good", 1.0);
78 addParam("maxPulseWidth", m_maxPulseWidth,
79 "maximal pulse width [ns] to flag digit as good", 10.0);
80 addParam("minWidthXheight", m_minWidthXheight,
81 "minimal product of width and height [ns * ADC counts]", 100.0);
82 addParam("storageDepth", m_storageDepth,
83 "ASIC analog storage depth of Interim FE format (ignored in other formats)",
84 (unsigned) 508);
85 addParam("lookBackWindows", m_lookBackWindows,
86 "number of look back windows, if positive override the number from database",
87 0);
88 addParam("setPhase", m_setPhase,
89 "if true, set (override) phase in TOPRawDigits", true);
90 addParam("calibrationChannel", m_calibrationChannel,
91 "calpulse selection: ASIC channel (use -1 to turn off the selection)", -1);
92 addParam("calpulseWidthMin", m_calpulseWidthMin,
93 "calpulse selection: minimal width [ns]", 0.0);
94 addParam("calpulseWidthMax", m_calpulseWidthMax,
95 "calpulse selection: maximal width [ns]", 0.0);
96 addParam("calpulseHeightMin", m_calpulseHeightMin,
97 "calpulse selection: minimal height [ADC counts]", 0);
98 addParam("calpulseHeightMax", m_calpulseHeightMax,
99 "calpulse selection: maximal height [ADC counts]", 0);
100 addParam("calpulseTimeMin", m_calpulseTimeMin,
101 "calpulse selection (ON if max > min): minimal time [ns]", 0.0);
102 addParam("calpulseTimeMax", m_calpulseTimeMax,
103 "calpulse selection (ON if max > min): maximal time [ns]", 0.0);
104 addParam("addRelations", m_addRelations, "if true, make relations to TOPRawDigits", true);
105
106 }

◆ TOPReconstructorModule()

Constructor.

Definition at line 40 of file TOPReconstructorModule.cc.

40 : Module()
41 {
42 // Set description
43 setDescription("Reconstruction for TOP counter. Uses reconstructed tracks "
44 "extrapolated to TOP and TOPDigits to calculate log likelihoods "
45 "for charged stable particles");
46
47 // Set property flags
48 setPropertyFlags(c_ParallelProcessingCertified);
49
50 // Add parameters
51 addParam("minTime", m_minTime,
52 "lower limit for photon time [ns] (if minTime >= maxTime use the default from DB)", 0.0);
53 addParam("maxTime", m_maxTime,
54 "upper limit for photon time [ns] (if minTime >= maxTime use the default from DB)", 0.0);
55 addParam("PDGCode", m_PDGCode,
56 "PDG code of hypothesis to construct pulls (0 means: use MC truth, -1: switched off)", -1);
57 addParam("deltaRayModeling", m_deltaRayModeling,
58 "include (True) or exclude (False) delta-ray modeling in log likelihood calculation", false);
59 addParam("pTCut", m_pTCut,
60 "pT cut to suppress badly extrapolated tracks that cannot reach TOP counter", 0.27);
61 addParam("TOPDigitCollectionName", m_topDigitCollectionName,
62 "Name of the collection of TOPDigits", string(""));
63 addParam("TOPLikelihoodCollectionName", m_topLikelihoodCollectionName,
64 "Name of the produced collection of TOPLikelihoods", string(""));
65 addParam("TOPPullCollectionName", m_topPullCollectionName, "Name of the collection of produced TOPPulls", string(""));
66 }

◆ TOPTBCComparatorModule()

Constructor.

Definition at line 41 of file TOPTBCComparatorModule.cc.

41 : HistoModule()
42 {
43 setDescription("TOP Time Base Correction monitor module ");
44
45 addParam("inputDirectorList", m_inputDirectoryList,
46 "List of the directories (one per IOV) in which the files with the calibration constants of the SCODS are stored. The format of each line must be: folderpath/ label ",
47 string(" "));
48 addParam("compareToPreviousSet", m_compareToPreviousSet,
49 "If true, each CalSet is compared to the previous one in the order determined by the inputDirectorList file. If false, the reference CalSet is the first of the list",
50 bool(true));
51 addParam("outputFile", m_outputFile,
52 "output file containing the monitoring plots", string("TBCComparisonResults.root"));
53 addParam("minCalPulses", m_minCalPulses,
54 "minimum number of calibration pulses need to flag a sample as non-empty", short(200));
55 addParam("numSamples", m_numSamples,
56 "number of samples that have been calibrated", short(256));
57
58 }

◆ TOPTimeBaseCalibratorModule()

Constructor.

Definition at line 54 of file TOPTimeBaseCalibratorModule.cc.

54 : Module()
55
56 {
57 // set module description
58 setDescription("Sample time calibrator");
59 // setPropertyFlags(c_ParallelProcessingCertified | c_InitializeInProcess);
60
61 // Add parameters
62 addParam("moduleID", m_moduleID, "slot ID to calibrate.");
63 addParam("minTimeDiff", m_minTimeDiff,
64 "lower bound on time difference [samples].", 0.0);
65 addParam("maxTimeDiff", m_maxTimeDiff,
66 "upper bound on time difference [samples].", 100.0);
67 addParam("directoryName", m_directoryName,
68 "name (with path) of the directory for the output root files.",
69 string(""));
70 addParam("minHits", m_minHits,
71 "minimal required hits per channel.", (unsigned) 1000);
72 addParam("numIterations", m_numIterations,
73 "number of iTBC iterations", (unsigned) 100);
74 addParam("numConvIter", m_conv_iter,
75 "Max number of iTBC iterations for conversion.", (unsigned) 50);
76 addParam("minChi2Change", m_dchi2_min,
77 "Minimal of chi2 change in iterations.", 0.2);
78 addParam("dtMin", m_dt_min,
79 "minimum Delta T of raw calpulse in iTBC", 20.0);
80 addParam("dtMax", m_dt_max,
81 "maximum Delta T of raw calpulse in iTBC", 24.0);
82 addParam("xStep", m_xstep,
83 "unit for an interation of delta(X_s)", 0.020);
84 addParam("devStep", m_dev_step,
85 "a step size to calculate the value of d(chisq)/dxval", 0.001);
86 addParam("chgStep", m_change_xstep,
87 "update m_xstep if m_dchi2dxv < m_change_step", 0.015);
88 addParam("newStep", m_new_xstep,
89 "a new step for delta(X_s) if m_dchi2dxv < m_change_step", 2.0 * m_xstep);
90 addParam("sigm2_exp", m_sigm2_exp,
91 "(sigma_0(dT))**2 for nomarlization of chisq = sum{dT^2/sigma^2}", 0.0424 * 0.0424);
92
93 addParam("method", m_method, "method: 0 - profile histograms only, "
94 "1 - matrix inversion, 2 - iterative, "
95 "3 - matrix inversion w/ singular value decomposition.", (unsigned) 1);
96 addParam("useFallingEdge", m_useFallingEdge,
97 "if true, use cal pulse falling edge instead of rising edge", false);
98 addParam("saveMatrix", m_saveMatrix, "if true, save also matrix and its inverse in a root file", false);
99
100 }

◆ TOPTimeRecalibratorModule()

Constructor.

Definition at line 43 of file TOPTimeRecalibratorModule.cc.

43 : Module()
44
45 {
46 // set module description
47 setDescription("Utility module for re-calibrating time of TOPDigits. "
48 "Useful for checking new calibrations on existing cDST files. "
49 "Note that pulseWidth and timeError are not changed "
50 "although they also depend on time calibration.");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // Add parameters
54 addParam("useSampleTimeCalibration", m_useSampleTimeCalibration,
55 "if true, use sample time calibration", true);
56 addParam("useAsicShiftCalibration", m_useAsicShiftCalibration,
57 "if true, use ASIC shifts calibration", true);
58 addParam("useChannelT0Calibration", m_useChannelT0Calibration,
59 "if true, use channel T0 calibration", true);
60 addParam("useModuleT0Calibration", m_useModuleT0Calibration,
61 "if true, use module T0 calibration", true);
62 addParam("useCommonT0Calibration", m_useCommonT0Calibration,
63 "if true, use common T0 calibration", true);
64 addParam("useTimeWalkCalibration", m_useTimeWalkCalibration,
65 "if true, use time-walk calibration", true);
66 addParam("subtractBunchTime", m_subtractBunchTime,
67 "if true, subtract reconstructed bunch time", true);
68
69 }

◆ TOPTriggerDigitizerModule()

Constructor.

Definition at line 47 of file TOPTriggerDigitizerModule.cc.

47 : Module()
48 {
49 // Set description()
50 setDescription("Digitizer that provides time stamps for TOP trigger");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 // Add parameters
54 addParam("threshold", m_threshold,
55 "pulse height threshold [ADC counts]", 27);
56 addParam("hysteresis", m_hysteresis,
57 "pulse height threshold hysteresis [ADC counts]", 10);
58 addParam("gateWidth", m_gateWidth,
59 "width of discriminator gate [samples]", 8);
60 addParam("samplingPhase", m_samplingPhase,
61 "sampling phase [samples]", 7);
62 }

◆ TOPUnpackerModule()

Constructor.

Definition at line 51 of file TOPUnpackerModule.cc.

51 : Module()
52 {
53 // set module description
54 setDescription("Raw data unpacker for TOP");
55 setPropertyFlags(c_ParallelProcessingCertified);
56
57 // Add parameters
58 addParam("inputRawDataName", m_inputRawDataName,
59 "name of RawTOP store array", string(""));
60 addParam("outputDigitsName", m_outputDigitsName,
61 "name of TOPDigit store array", string(""));
62 addParam("outputWaveformsName", m_outputWaveformsName,
63 "name of TOP(Raw/Production)Waveform store array", string(""));
64 addParam("outputRawDigitsName", m_outputRawDigitsName,
65 "name of TOPRawDigit store array", string(""));
66 addParam("outputTemplateFitResultName", m_templateFitResultName,
67 "name of TOPTemplateFitResult", string(""));
68 addParam("swapBytes", m_swapBytes, "if true, swap bytes", false);
69 addParam("dataFormat", m_dataFormat,
70 "data format as defined in top/include/RawDataTypes.h, 0 = auto detect", 0);
71 addParam("addRelations", m_addRelations,
72 "if true, make relations to TOPProductionHitDebugs (production debug data format only)", true);
73 addParam("errorSuppressFactor", m_errorSuppressFactor,
74 "error messages suppression factor (0 = no suppression)", (unsigned) 1000);
75
76 }

◆ TOPValidationCollectorModule()

Constructor.

Definition at line 48 of file TOPValidationCollectorModule.cc.

49 {
50 // set module description and processing properties
51 setDescription("A collector for automatic validation of TOP calibration");
52 setPropertyFlags(c_ParallelProcessingCertified);
53
54 // module parameters
55 addParam("numBins", m_numBins, "number of bins of the search region", 100);
56 addParam("timeRange", m_timeRange,
57 "time range in which to search for the minimum [ns]", 10.0);
58 addParam("sigmaSmear", m_sigmaSmear,
59 "sigma in [ns] for additional smearing of PDF", 0.0);
60 addParam("sample", m_sample,
61 "sample type: one of dimuon or bhabha", std::string("dimuon"));
62 addParam("deltaEcms", m_deltaEcms,
63 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
64 addParam("dr", m_dr, "cut on POCA in r", 2.0);
65 addParam("dz", m_dz, "cut on POCA in abs(z)", 4.0);
66 addParam("minZ", m_minZ,
67 "minimal local z of extrapolated hit", -130.0);
68 addParam("maxZ", m_maxZ,
69 "maximal local z of extrapolated hit", 130.0);
70 addParam("pdfOption", m_pdfOption,
71 "PDF option, one of 'rough', 'fine', 'optimal'", std::string("rough"));
72
73 }

◆ TOPWaveformFeatureExtractorModule()

Constructor.

Definition at line 44 of file TOPWaveformFeatureExtractorModule.cc.

44 : Module()
45
46 {
47 // set module description (e.g. insert text)
48 setDescription("Module adds raw digits that are found in waveforms "
49 "but not already present in TOPRawDigits. "
50 "Only waveforms related to TOPRawDigits are used.");
51 setPropertyFlags(c_ParallelProcessingCertified);
52
53 addParam("inputRawDigitsName", m_inputRawDigitsName,
54 "name of TOPRawDigit store array", string(""));
55 addParam("threshold", m_threshold,
56 "pulse height threshold [ADC counts]", 40);
57 addParam("hysteresis", m_hysteresis,
58 "threshold hysteresis [ADC counts]", 10);
59 addParam("thresholdCount", m_thresholdCount,
60 "minimal number of samples above threshold", 3);
61 addParam("setIntegral", m_setIntegral,
62 "calculate and set integral for online-extracted hits", true);
63
64 }

◆ TOPWaveformQualityPlotterModule()

Constructor.

Definition at line 39 of file TOPWaveformQualityPlotterModule.cc.

40 : HistoModule()
41 {
42 setDescription("TOP DQM histogram module");
43 addParam("histogramDirectoryName", m_histogramDirectoryName,
44 "histogram directory in ROOT file", string("TOP"));
45 addParam("drawWaves", m_DRAWWAVES, "option to draw waveforms", true);
46 addParam("debugHistos", m_DEBUGGING, "option to draw debug histograms", true);
47 addParam("noisemaps", m_NOISE, "option to draw noisemaps", false);
48 }

◆ unpackHeadersInterimFEVer01()

bool unpackHeadersInterimFEVer01 ( const int * buffer,
int bufferSize,
bool swapBytes )
private

Tries to unpack raw data assuming it is in feature-extraction interim format.

Does not write out anything, just checks integrity.

Parameters
bufferraw data buffer
bufferSizebuffer size
swapBytesif true, swap bytes in buffer
Returns
true if buffer resembles interim format, false if not.

Definition at line 345 of file TOPUnpackerModule.cc.

346 {
347 B2DEBUG(22, "Checking whether buffer unpacks as InterimFEVer01, dataSize = " << bufferSize);
348
349 DataArray array(buffer, bufferSize, swapBytes);
350
351 array.getWord(); // header word 0
352 array.getWord(); // header word 1 (what it contains?)
353 while (array.getRemainingWords() > 0) {
354 unsigned header = array.getWord(); // word 0
355 if ((header & 0xFF) == 0xBE) { //this is a super short FE header
356 continue;
357 }
358
359 if (header != 0xaaaa0104 and header != 0xaaaa0103 and header != 0xaaaa0100) {//cannot be interim firmware
360 return false; //abort
361 }
362
363
364 array.getWord(); // word 1
365 array.getWord(); // word 2
366
367 if (header != 0xaaaa0104) {
368 // feature-extracted data (positive signal)
369 array.getWord(); // word 3
370 array.getWord(); // word 4
371 array.getWord(); // word 5
372 array.getWord(); // word 6
373 array.getWord(); // word 7
374 array.getWord(); // word 8
375 array.getWord(); // word 9
376 array.getWord(); // word 10
377 array.getWord(); // word 11
378 array.getWord(); // word 12
379 array.getWord(); // word 13
380 array.getWord(); // word 14
381 }
382
383 unsigned magicWord = array.getWord(); // word 15
384 if (magicWord != 0x7473616c) {//invalid magic word
385 return false; //abort
386 }
387
388 if (header != 0xaaaa0103) continue;
389 array.getWord(); // word 16
390
391 array.getWord(); // word 17
392 array.getWord(); // word 18
393 array.getWord(); // word 19
394
395 array.getWord(); // word 20
396
397 array.getWord(); // word 21
398
399 array.getWord(); // word 22
400
401 int numWords = 4 * 32; // (numPoints + 1) / 2;
402 if (array.getRemainingWords() < numWords) { //not enough remaining words for waveform data
403 return false; //abort
404 }
405
406 for (int i = 0; i < numWords; i++) {
407 array.getWord();
408 }
409 }
410
411 return true;
412 }

◆ unpackInterimFEVer01()

int unpackInterimFEVer01 ( const int * buffer,
int bufferSize,
bool pedestalSubtracted )
private

Unpack raw data given in feature-extraction interim format.

Parameters
bufferraw data buffer
bufferSizebuffer size
pedestalSubtractedfalse for version 2, true for version 3
Returns
number of words remaining in data buffer

Definition at line 415 of file TOPUnpackerModule.cc.

417 {
418
419 B2DEBUG(22, "Unpacking InterimFEVer01 to TOPRawDigits and TOPRawWaveforms, "
420 "dataSize = " << bufferSize);
421
422 int moduleID = 0;
423 int boardstack = 0;
424
425 DataArray array(buffer, bufferSize, m_swapBytes);
426
427 map<unsigned short, int> evtNumCounter; //counts the occurence of carrier-generated event numbers.
428 std::vector<unsigned short> channelCounter(128, 0); //counts occurence of carrier/asic/channel combinations
429
430 unsigned word = array.getWord(); // header word 0
431 unsigned short scrodID = word & 0x0FFF;
432 auto* info = m_interimFEInfos.appendNew(scrodID, bufferSize);
433
434 word = array.getWord(); // header word 1 (what it contains?)
435
436
437 while (array.getRemainingWords() > 0) {
438
439 unsigned header = array.getWord(); // word 0
440
441 if ((header & 0xFF) == 0xBE) { //this is a super short FE header
442// B2DEBUG(21, "0b" << std::bitset<8>(header & 0xFF) << " " << std::bitset<8>((header>>8) & 0xFF) << " " << std::bitset<8>((header>>16) & 0xFF) << " " << std::bitset<8>((header>>24) & 0xFF));
443
444 unsigned short scrodID_SSFE;
445 unsigned short carrier_SSFE;
446 unsigned short asic_SSFE;
447 unsigned short channel_SSFE;
448 unsigned short evtNum_SSFE;
449
450 evtNum_SSFE = (header >> 8) & 0xFF;
451 scrodID_SSFE = (header >> 16) & 0x7F;
452 channel_SSFE = (header >> 24) & 0x07;
453 asic_SSFE = (header >> 27) & 0x03;
454 carrier_SSFE = (header >> 29) & 0x03;
455
456 const auto* feemap = m_topgp->getFrontEndMapper().getMap(scrodID_SSFE);
457 if (feemap) {
458 moduleID = feemap->getModuleID();
459 boardstack = feemap->getBoardstackNumber();
460 } else {
461 B2ERROR("TOPUnpacker: no front-end map available."
462 << LogVar("SCROD ID", scrodID_SSFE));
463 info->setErrorFlag(TOPInterimFEInfo::c_InvalidScrodID);
464 }
465
466 if (scrodID_SSFE != scrodID) {
467 B2ERROR("TOPUnpacker: corrupted data - "
468 << "different scrodID's in HLSB and super short FE header."
469 << LogVar("SCROD", scrodID_SSFE)
470 << LogVar("slot", moduleID)
471 << LogVar("BS", boardstack));
472 B2DEBUG(21, "Different scrodID's in HLSB and FE header: " << scrodID << " " << scrodID_SSFE << " word = 0x" << std::hex << word);
473 info->setErrorFlag(TOPInterimFEInfo::c_DifferentScrodIDs);
474 return array.getRemainingWords();
475 }
476
477 B2DEBUG(21, scrodID_SSFE << "\t" << carrier_SSFE << "\t" << asic_SSFE << "\t" << channel_SSFE << "\t" << evtNum_SSFE);
478
479 int channelID = carrier_SSFE * 32 + asic_SSFE * 8 + channel_SSFE;
480 channelCounter[channelID] += 1;
481 evtNumCounter[evtNum_SSFE] += 1;
482
483 info->incrementFEHeadersCount();
484 info->incrementEmptyFEHeadersCount();
485
486 continue;
487 }
488
489 if (header != 0xaaaa0104 and header != 0xaaaa0103 and header != 0xaaaa0100) {
490 B2ERROR("TOPUnpacker: corrupted data - invalid FE header word");
491 B2DEBUG(21, "Invalid FE header word: " << std::hex << header << " 0b" << std::bitset<32>(header));
492 B2DEBUG(21, "SCROD ID: " << scrodID << " " << std::hex << scrodID);
493
494 info->setErrorFlag(TOPInterimFEInfo::c_InvalidFEHeader);
495 return array.getRemainingWords();
496 }
497
498
499 word = array.getWord(); // word 1
500 unsigned short scrodID_FE = word >> 25;
501 unsigned short convertedAddr = (word >> 16) & 0x1FF;
502 unsigned short evtNum_numWin_trigPat_FEheader = word & 0xFFFF;
503 unsigned short evtNum_FEheader = evtNum_numWin_trigPat_FEheader & 0xFF;
504 evtNumCounter[evtNum_FEheader] += 1;
505
506 if (scrodID_FE != scrodID) {
507 B2ERROR("TOPUnpacker: different scrodID's in HLSB and FE header."
508 << LogVar("scrodID (HSLB)", scrodID)
509 << LogVar("scrodID (FE)", scrodID_FE));
510
511 info->setErrorFlag(TOPInterimFEInfo::c_DifferentScrodIDs);
512 return array.getRemainingWords();
513 }
514
515 word = array.getWord(); // word 2
516 // unsigned lastWrAddr = word & 0x1FF;
517 unsigned lastWrAddr = (word & 0x0FF) << 1;
518 //unsigned short asicChannelFE = (word >> 9) & 0x07;
519 unsigned short asicChannelFE = (word >> 8) & 0x07;
520 unsigned short asicFE = (word >> 12) & 0x03;
521 unsigned short carrierFE = (word >> 14) & 0x03;
522 unsigned short channelID = carrierFE * 32 + asicFE * 8 + asicChannelFE;
523 //B2DEBUG(21, "carrier asic chn " << carrierFE << " " << asicFE << " " << asicChannelFE << " " << channelID << " 0b" << std::bitset<32>(word) );
524
525 B2DEBUG(21, scrodID_FE << "\t" << carrierFE << "\t" << asicFE << "\t" << asicChannelFE << "\t" << evtNum_FEheader);
526
527 channelCounter[channelID] += 1;
528
529 std::vector<TOPRawDigit*> digits; // needed for creating relations to waveforms
530
531 if (header != 0xaaaa0104) {
532 // feature-extracted data (positive signal)
533 array.getWord(); // word 3
534 word = array.getWord(); // word 4
535 short samplePeak_p = word & 0xFFFF;
536 short valuePeak_p = (word >> 16) & 0xFFFF;
537
538 word = array.getWord(); // word 5
539 short sampleRise_p = word & 0xFFFF;
540 short valueRise0_p = (word >> 16) & 0xFFFF;
541
542 word = array.getWord(); // word 6
543 short valueRise1_p = word & 0xFFFF;
544 short sampleFall_p = (word >> 16) & 0xFFFF;
545
546 word = array.getWord(); // word 7
547 short valueFall0_p = word & 0xFFFF;
548 short valueFall1_p = (word >> 16) & 0xFFFF;
549
550 word = array.getWord(); // word 8
551 short integral_p = word & 0xFFFF;
552 // short qualityFlags_p = (word >> 16) & 0xFFFF;
553
554 // feature-extracted data (negative signal)
555 array.getWord(); // word 9
556 //word = array.getWord(); // word 9
557 //short n_samp_i = (word >> 16) & 0xFFFF;
558 word = array.getWord(); // word 10
559 short samplePeak_n = word & 0xFFFF;
560 short valuePeak_n = (word >> 16) & 0xFFFF;
561
562 array.getWord(); // word 11
563 //word = array.getWord(); // word 11
564 //short sampleRise_n = word & 0xFFFF;
565 //short valueRise0_n = (word >> 16) & 0xFFFF;
566
567 array.getWord(); // word 12
568 //word = array.getWord(); // word 12
569 //short valueRise1_n = word & 0xFFFF;
570 //short sampleFall_n = (word >> 16) & 0xFFFF;
571
572 array.getWord(); // word 13
573 //word = array.getWord(); // word 13
574 //short valueFall0_n = word & 0xFFFF;
575 //short valueFall1_n = (word >> 16) & 0xFFFF;
576
577 word = array.getWord(); // word 14
578 short integral_n = word & 0xFFFF;
579 short qualityFlags_n = (word >> 16) & 0xFFFF;
580
581 if (abs(valuePeak_p) != 9999) {
582 auto* digit = m_rawDigits.appendNew(scrodID, TOPRawDigit::c_Interim);
583 digit->setCarrierNumber(carrierFE);
584 digit->setASICNumber(asicFE);
585 digit->setASICChannel(asicChannelFE);
586 digit->setASICWindow(convertedAddr);
587 digit->setLastWriteAddr(lastWrAddr);
588 digit->setSampleRise(sampleRise_p);
589 digit->setDeltaSamplePeak(samplePeak_p - sampleRise_p);
590 digit->setDeltaSampleFall(sampleFall_p - sampleRise_p);
591 digit->setValueRise0(valueRise0_p);
592 digit->setValueRise1(valueRise1_p);
593 digit->setValuePeak(valuePeak_p);
594 digit->setValueFall0(valueFall0_p);
595 digit->setValueFall1(valueFall1_p);
596 digit->setIntegral(integral_p);
597 // digit->setErrorFlags(qualityFlags_p); // not good solution !
598 digit->addRelationTo(info);
599 digits.push_back(digit);
600 //template fit result is saved in negative pulse fe data
601 if (valuePeak_p < 150) {
602 auto* tlpfResult = m_templateFitResults.appendNew();
603 tlpfResult->setBackgroundOffset(samplePeak_n);
604 tlpfResult->setAmplitude(valuePeak_n);
605 tlpfResult->setChisquare(qualityFlags_n);
606 tlpfResult->setRisingEdgeAndConvert(integral_n);
607 digit->addRelationTo(tlpfResult);
608 }
609 }
610 /*if (abs(valuePeak_n) != 9999) {
611 auto* digit = m_rawDigits.appendNew(scrodID, TOPRawDigit::c_Interim);
612 digit->setCarrierNumber(carrierFE);
613 digit->setASICNumber(asicFE);
614 digit->setASICChannel(asicChannelFE);
615 digit->setASICWindow(convertedAddr);
616 digit->setLastWriteAddr(lastWrAddr);
617 digit->setSampleRise(sampleRise_n);
618 digit->setDeltaSamplePeak(samplePeak_n - sampleRise_n);
619 digit->setDeltaSampleFall(sampleFall_n - sampleRise_n);
620 digit->setValueRise0(valueRise0_n);
621 digit->setValueRise1(valueRise1_n);
622 digit->setValuePeak(valuePeak_n);
623 digit->setValueFall0(valueFall0_n);
624 digit->setValueFall1(valueFall1_n);
625 digit->setIntegral(integral_n);
626 // digit->setErrorFlags(qualityFlags_n); // not good solution !
627 digit->addRelationTo(info);
628 digits.push_back(digit);
629 }*/
630 }
631
632 // magic word
633 word = array.getWord(); // word 15
634 if (word != 0x7473616c) {
635 //B2ERROR("TOPUnpacker: corrupted data - no magic word at the end of FE header");
636 //B2DEBUG(21, "No magic word at the end of FE header, found: "
637 //<< std::hex << word);
638 info->setErrorFlag(TOPInterimFEInfo::c_InvalidMagicWord);
639 //return array.getRemainingWords(); do not abort event for now as footer is invalid in current debugging version of firmware
640 }
641
642 // store to raw digits
643
644 info->incrementFEHeadersCount();
645 if (digits.empty()) info->incrementEmptyFEHeadersCount();
646
647 if (header != 0xaaaa0103) continue;
648
649 // waveform header
650 word = array.getWord(); // word 16
651 unsigned long evtNum_numWaves_refWin_WFheader = word;
652 unsigned short evtNum_WFheader = (evtNum_numWaves_refWin_WFheader >> 24) & 0xFF;
653
654 if (evtNum_WFheader != evtNum_FEheader) {
655 B2ERROR("TOPUnpacker: different carrier event number in WF and FE header."
656 << LogVar("Event number (FE header)", evtNum_FEheader)
657 << LogVar("Event number (WF header)", evtNum_WFheader));
658 }
659
660 array.getWord(); // word 17
661 array.getWord(); // word 18
662 word = array.getWord(); // word 19
663 // int numPoints = (word >> 16) & 0xFFFF;
664 unsigned short carrier = (word >> 14) & 0x03;
665 unsigned short asic = (word >> 12) & 0x03;
666 unsigned short asicChannel = (word >> 9) & 0x07;
667 unsigned short window = word & 0x1FF;
668
669 // checks for data corruption
670 if (carrier != carrierFE) {
671 B2ERROR("TOPUnpacker: different carrier numbers in FE and WF header");
672 B2DEBUG(21, "Different carrier numbers in FE and WF header: "
673 << carrierFE << " " << carrier);
674 info->setErrorFlag(TOPInterimFEInfo::c_DifferentCarriers);
675 }
676 if (asic != asicFE) {
677 B2ERROR("TOPUnpacker: different ASIC numbers in FE and WF header");
678 B2DEBUG(21, "Different ASIC numbers in FE and WF header: "
679 << asicFE << " " << asic);
680 info->setErrorFlag(TOPInterimFEInfo::c_DifferentAsics);
681 }
682 if (asicChannel != asicChannelFE) {
683 B2ERROR("TOPUnpacker: different ASIC channel numbers in FE and WF header");
684 B2DEBUG(21, "Different ASIC channel numbers in FE and WF header: "
685 << asicChannelFE << " " << asicChannel);
686 info->setErrorFlag(TOPInterimFEInfo::c_DifferentChannels);
687 }
688 if (window != convertedAddr) {
689 B2ERROR("TOPUnpacker: different window numbers in FE and WF header");
690 B2DEBUG(21, "Different window numbers in FE and WF header: "
691 << convertedAddr << " " << window);
692 info->setErrorFlag(TOPInterimFEInfo::c_DifferentWindows);
693 }
694
695 // reading out all four window addresses
696 // to be for correcnt alignment of individual readout windows in written waveform
697 std::vector<unsigned short> windows;
698 windows.push_back(window);
699
700 word = array.getWord(); // word 20
701 windows.push_back(word & 0x1FF);
702
703 word = array.getWord(); // word 21
704 windows.push_back(word & 0x1FF);
705
706 word = array.getWord(); // word 22
707 windows.push_back(word & 0x1FF);
708
709 int numWords = 4 * 32; // (numPoints + 1) / 2;
710 if (array.getRemainingWords() < numWords) {
711 B2ERROR("TOPUnpacker: too few words for waveform data."
712 << LogVar("needed", numWords)
713 << LogVar("available", array.getRemainingWords()));
714 info->setErrorFlag(TOPInterimFEInfo::c_InsufficientWFData);
715 return array.getRemainingWords();
716 }
717
718 // unpack waveforms
719 std::vector<short> adcData;
720 for (int i = 0; i < numWords; i++) {
721 word = array.getWord();
722 adcData.push_back(word & 0xFFFF);
723 adcData.push_back((word >> 16) & 0xFFFF);
724 }
725 // if (numWords * 2 != numPoints) adcData.pop_back(); // numPoints is even
726
727 // determine slot number (moduleID) and boardstack
728 moduleID = 0;
729 boardstack = 0;
730 const auto* feemap = m_topgp->getFrontEndMapper().getMap(scrodID);
731 if (feemap) {
732 moduleID = feemap->getModuleID();
733 boardstack = feemap->getBoardstackNumber();
734 } else {
735 B2ERROR("TOPUnpacker: no front-end map available."
736 << LogVar("SCROD ID", scrodID));
737 info->setErrorFlag(TOPInterimFEInfo::c_InvalidScrodID);
738 }
739
740 // determine hardware channel and pixelID (valid only if feemap available!)
741 const auto& mapper = m_topgp->getChannelMapper();
742 unsigned channel = mapper.getChannel(boardstack, carrier, asic, asicChannel);
743 int pixelID = mapper.getPixelID(channel);
744
745 // store to raw waveforms
746 auto* waveform = m_waveforms.appendNew(moduleID, pixelID, channel, scrodID,
747 window, 0, adcData);
748 waveform->setLastWriteAddr(lastWrAddr);
749 waveform->setStorageWindows(windows);
750 waveform->setPedestalSubtractedFlag(pedestalSubtracted);
751 waveform->addRelationTo(info);
752 info->incrementWaveformsCount();
753
754 // create relations btw. raw digits and waveform
755 for (auto& digit : digits) digit->addRelationTo(waveform);
756
757 }
758
759 if (evtNumCounter.size() != 1) {
760 B2ERROR("TOPUnpacker: Possible frame shift detected "
761 << "(More than one unique carrier event number in this readout event)."
762 << LogVar("SCROD", scrodID)
763 << LogVar("slot", moduleID)
764 << LogVar("BS", boardstack));
765 }
766
767 int nASICs = 0;
768
769 string evtNumOutputString;
770 evtNumOutputString += "Carrier event numbers and their counts for SCROD ID " + std::to_string(scrodID) + ":\n";
771 for (auto const& it : evtNumCounter) {
772 nASICs += it.second;
773 evtNumOutputString += std::to_string(it.first) + ":\t" + std::to_string(it.second) + "\n";
774 }
775 evtNumOutputString += "Total:\t" + std::to_string(nASICs);
776 B2DEBUG(21, evtNumOutputString);
777
778 int nChannels = 0;
779 int nChannelsDiff = 0;
780
781 string channelOutputString;
782 channelOutputString += "Detected channels and their counts for SCROD ID (channels with count == 1 are omitted)" + std::to_string(
783 scrodID) + ":\n";
784
785 int channelIndex(0);
786 for (auto const& it : channelCounter) {
787 if (it > 0) {
788 nChannelsDiff += 1;
789 }
790 nChannels += it;
791
792 int channelID = channelIndex;
793 int carrier = channelID / 32;
794 int asic = (channelID % 32) / 8;
795 int chn = channelID % 8;
796
797 if (it != 1) {
798 channelOutputString += "carrier: " + std::to_string(carrier) + " asic: " + std::to_string(asic) + " chn: " + std::to_string(
799 chn) + " occurence: " + std::to_string(it) + "\n";
800 B2WARNING("TOPUnpacker: interim FE - ASIC channel seen more than once"
801 << LogVar("ScrodID", scrodID)
802 << LogVar("carrier", carrier)
803 << LogVar("ASIC", asic)
804 << LogVar("channel", chn)
805 << LogVar("times seen", it));
806 }
807 channelIndex += 1;
808 }
809
810 m_channelStatistics[nChannels] += 1;
811
812 channelOutputString += "Total:\t" + std::to_string(nChannels) + " " + std::to_string(nChannelsDiff);
813 B2DEBUG(21, channelOutputString);
814
815 return array.getRemainingWords();
816
817
818 }

◆ unpackProdDebug()

int unpackProdDebug ( const int * buffer,
int bufferSize,
TOP::RawDataType dataFormat,
bool pedestalSubtracted )
private

Unpack raw data given in production debugging format.

Parameters
bufferraw data buffer
bufferSizebuffer size
dataFormatdata format
pedestalSubtractedtrue, if pedestal is subtracted in waveforms
Returns
number of words remaining in data buffer

Definition at line 821 of file TOPUnpackerModule.cc.

823 {
824
825 B2DEBUG(22, "Unpacking Production firmware debug data format to TOPRawDigits "
826 "dataSize = " << bufferSize);
827
828 DataArray array(buffer, bufferSize, m_swapBytes);
829 unsigned word;
830
831 word = array.getWord(); // word 0, type(8)/version(8)/0xA(4)/ScrodID(12)
832 unsigned int evtType = word >> 24;
833 unsigned int evtVersion = (word >> 16) & 0xFF;
834 unsigned int evtMagicHeader = (word >> 12) & 0xF;
835 unsigned int evtScrodID = word & 0xFFF;
836
837 // determine slot number (moduleID) and boardstack
838 int moduleID = 0;
839 int boardstack = 0;
840 const auto* feemap = m_topgp->getFrontEndMapper().getMap(evtScrodID);
841 if (feemap) {
842 moduleID = feemap->getModuleID();
843 boardstack = feemap->getBoardstackNumber();
844 } else {
845 B2WARNING("TOPUnpacker: no front-end map available."
846 << LogVar("SCROD ID", evtScrodID));
847 }
848
849
850 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
851 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
852 << "\tevtType = " << evtType
853 << ", evtVersion = " << evtVersion
854 << ", evtMagicHeader = " << evtMagicHeader
855 << ", evtScrodID = " << evtScrodID);
856
857 if (evtMagicHeader != 0xA) {
858 B2WARNING("TOPUnpacker: event header magic word mismatch. should be 0xA."
859 << LogVar("Magic word", evtMagicHeader));
860 return array.getRemainingWords();
861 }
862
863 word = array.getWord(); // word 1, extra(3)/numWordsBonus(13)/phase(4)/numWordsCore(12)
864 unsigned int evtExtra = word >> 29;
865 unsigned int evtNumWordsBonus = (word >> 16) & 0x1FFF;
866 unsigned int evtPhase = (word >> 12) & 0xF;
867 unsigned int evtNumWordsCore = word & 0xFFF;
868
869 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
870 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
871 << "\tevtExtra = " << evtExtra
872 << ", evtNumWordsBonus = " << evtNumWordsBonus
873 << ", evtPhase = " << evtPhase
874 << ", numWordsCore = " << evtNumWordsCore);
875
876 word = array.getWord(); // word 2, skipHit(1)/reserved(4)/ctime LSBs(11)/revo9counter(16)
877 bool evtSkipHit = word >> 29;
878 unsigned int evtCtime = (word >> 16) & 0x7FF;
879 unsigned int evtRevo9Counter = word & 0xFFFF;
880
881 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
882 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
883 << "\tevtSkipHit = " << evtSkipHit
884 << ", evtCtime = " << evtCtime
885 << ", evtRevo9Counter = " << evtRevo9Counter);
886
887 word = array.getWord(); // word 3, asicMask(16)/eventQueueDepth(8)/eventNumberByte(8)
888 unsigned int evtAsicMask = word >> 16;
889 unsigned int evtEventQueueDepth = (word >> 8) & 0xFF;
890 unsigned int evtEventNumberByte = word & 0xFF;
891
892 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
893 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
894 << "\tevtAsicMask = " << evtAsicMask
895 << ", evtEventQueueDepth = " << evtEventQueueDepth
896 << ", evtEventNumberByte = " << evtEventNumberByte);
897
898 m_productionEventDebugs.appendNew(evtType,
899 evtVersion,
900 evtScrodID,
901 evtSkipHit,
902 evtCtime,
903 evtPhase,
904 evtAsicMask,
905 evtEventQueueDepth,
906 evtEventNumberByte);
907
908 B2DEBUG(22, "end of event header, start of hits:");
909
910 const int numWordsPerHit = 4 + evtExtra;
911 unsigned int numHitsFound = 0;
912 unsigned int numExpectedWaveforms = 0;
913
914 std::vector<TOPRawDigit*> digitsWithWaveform; // digits that have waveforms
915
916 while (array.getRemainingWords() > numWordsPerHit //one more full hit + one word of footer
917 && array.getIndex() < evtNumWordsCore - 2) { // -1 for 0-based counting, -1 for hit footer word
918 array.resetChecksum();
919
920
921 //need to predefine some variables here as we need to branch out between two data format versions for the next two words
922 unsigned int hitCarrier = 0;
923 unsigned int hitAsic = 0;
924 unsigned int hitChannel = 0;
925 unsigned int hitWindow = 0;
926 unsigned int hitMagicHeader = 0;
927 unsigned int hitTFine = 0;
928 bool hitHasWaveform = false;
929 bool hitIsOnHeap = false;
930 unsigned int hitHeapWindow = 0;
931 bool hitIsOnHeapStraddle = false;
932 unsigned int hitHeapWindowStraddle = 0;
933 bool hitIsWindowStraddle = false;
934 short hitIntegral = 0;
935 short hitVPeak = 0;
936
937 if (dataFormat == TOP::RawDataType::c_ProductionDebug01) { //dataformat 0x0401
938 word = array.getWord(); // hit word 0, carrier(2)/asic(2)/channel(3)/window(9)/0xB(4)/tFine(4)/hasWaveform(1)/isOnHeap(1)/heapWindow(6)
939 hitCarrier = word >> 30;
940 hitAsic = (word >> 28) & 0x3;
941 hitChannel = (word >> 25) & 0x7;
942 hitWindow = (word >> 16) & 0x1FF;
943 hitMagicHeader = (word >> 12) & 0xF;
944 hitTFine = (word >> 8) & 0xF;
945 hitHasWaveform = (word >> 7) & 0x1;
946 hitIsOnHeap = (word >> 6) & 0x1;
947 hitHeapWindow = word & 0x3F;
948
949
950 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
951 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
952 << "\thitCarrier = " << hitCarrier
953 << ", hitAsic = " << hitAsic
954 << ", hitChannel = " << hitChannel
955 << ", hitWindow = " << hitWindow
956 // << ", hitMagicHeader = " << hitMagicHeader
957 // << ", hitTFine = " << hitTFine
958 << ", hitHasWaveform = " << hitHasWaveform
959 // << ", hitIsOnHeap = " << hitIsOnHeap
960 // << ", hitHeapWindow = " << hitHeapWindow
961 );
962
963
964 word = array.getWord(); // hit word 1, reserved(3)/vPeak(13)/integral(16)
965 hitVPeak = expand13to16bits(word >> 16);
966 hitIntegral = word & 0xFFFF;
967 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
968 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
969 << "\thitVPeak = " << hitVPeak
970 << ", hitIntegral = " << hitIntegral);
971
972 } else if (dataFormat == TOP::RawDataType::c_ProductionDebug02) { //dataformat 0x0402
973 word = array.getWord(); // hit word 0, carrier(2)/asic(2)/channel(3)/window(9)/0xB(4)/tFine(4)/hasWaveform(1)/isWindowStraddle(1)/integral(6)
974 hitCarrier = word >> 30;
975 hitAsic = (word >> 28) & 0x3;
976 hitChannel = (word >> 25) & 0x7;
977 hitWindow = (word >> 16) & 0x1FF;
978 hitMagicHeader = (word >> 12) & 0xF;
979 hitTFine = (word >> 8) & 0xF;
980 hitHasWaveform = (word >> 7) & 0x1;
981 hitIsWindowStraddle = (word >> 6) & 0x1;
982 hitIntegral = word & 0x3F;
983
984
985 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
986 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
987 << "\thitCarrier = " << hitCarrier
988 << ", hitAsic = " << hitAsic
989 << ", hitChannel = " << hitChannel
990 << ", hitWindow = " << hitWindow
991 // << ", hitMagicHeader = " << hitMagicHeader
992 // << ", hitTFine = " << hitTFine
993 << ", hitHasWaveform = " << hitHasWaveform
994 << ", hitIsWindowStraddle = " << hitHasWaveform
995 << ", hitIntegral = " << hitIntegral
996 // << ", hitHeapWindow = " << hitHeapWindow
997 );
998
999 word = array.getWord(); // hit word 1, reserved(3)/vPeak(13)/isOnHeap1(1)/heapWindow1(7)/isOnHeap0(1)/heapWindow0(7)
1000 hitVPeak = expand13to16bits(word >> 16);
1001 hitIsOnHeapStraddle = (word >> 15) & 0x1;
1002 hitHeapWindowStraddle = (word >> 8) & 0x7F;
1003 hitIsOnHeap = (word >> 7) & 0x1;
1004 hitHeapWindow = word & 0x1;
1005
1006 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1007 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1008 << "\thitVPeak = " << hitVPeak
1009 << ", hitIsOnHeapStraddle = " << hitIsOnHeapStraddle
1010 << ", hitHeapWindowStraddle = " << hitHeapWindowStraddle
1011 << ", hitIsOnHeap = " << hitIsOnHeap
1012 << ", hitHeapWindow = " << hitHeapWindow);
1013 } else { //could not match the data format
1014 B2WARNING("TOPUnpacker: could not match data type inside unpackProdDebug()"
1015 << LogVar("evtType", evtType) << LogVar("evtVersion", evtVersion));
1016 return array.getRemainingWords();
1017 }
1018
1019
1020 if (hitHasWaveform) {
1021 numExpectedWaveforms += 1;
1022 }
1023
1024 if (hitMagicHeader != 0xB) {
1025 B2WARNING("TOPUnpacker: hit header magic word mismatch. should be 0xB."
1026 << LogVar("Magic word", hitMagicHeader));
1027 return array.getRemainingWords();
1028 }
1029
1030 word = array.getWord(); // hit word 2, reserved(3)/vRise0(13)/reserved(3)/vRise1(13)
1031 short hitVRise0 = expand13to16bits(word >> 16);
1032 short hitVRise1 = expand13to16bits(word);
1033 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1034 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1035 << "\thitVRise0 = " << hitVRise0
1036 << ", hitVRise1 = " << hitVRise1);
1037
1038 word = array.getWord(); // hit word 3, reserved(3)/vFall0(13)/reserved(3)/vFall1(13)
1039 short hitVFall0 = expand13to16bits(word >> 16);
1040 short hitVFall1 = expand13to16bits(word);
1041 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1042 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1043 << "\thitVFall0 = " << hitVFall0
1044 << ", hitVFall1 = " << hitVFall1);
1045
1046 word = array.getWord(); // hit word 4, sampleRise(8)/dSampPeak(4)/dSampFall(4)/headerChecksum(16)
1047 unsigned short hitSampleRise = (word >> 24);
1048 short hitDSampPeak = (word >> 20) & 0xF;
1049 short hitDSampFall = (word >> 16) & 0xF;
1050 unsigned short hitHeaderChecksum = word & 0xFFFF;
1051 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1052 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1053 << "\thitSampleRise = " << hitSampleRise
1054 << ", hitDSampPeak = " << hitDSampPeak
1055 << ", hitDSampFall = " << hitDSampFall
1056 << ", hitheaderChecksum = " << hitHeaderChecksum
1057 << ", checksum " << (array.validateChecksum() ? "OK" : "NOT OK"));
1058
1059 if (!array.validateChecksum()) {
1060 B2WARNING("TOPUnpacker: hit checksum invalid.");
1061 return array.getRemainingWords();
1062 }
1063
1064 // append digit
1065 auto* digit = m_rawDigits.appendNew(evtScrodID, TOPRawDigit::c_ProductionDebug);
1066 digit->setCarrierNumber(hitCarrier);
1067 digit->setASICNumber(hitAsic);
1068 digit->setASICChannel(hitChannel);
1069 digit->setASICWindow(hitWindow);
1070 digit->setLastWriteAddr(0);
1071 digit->setSampleRise(hitSampleRise);
1072 digit->setDeltaSamplePeak(hitDSampPeak);
1073 digit->setDeltaSampleFall(hitDSampFall);
1074 digit->setValueRise0(hitVRise0);
1075 digit->setValueRise1(hitVRise1);
1076 digit->setValuePeak(hitVPeak);
1077 digit->setValueFall0(hitVFall0);
1078 digit->setValueFall1(hitVFall1);
1079 digit->setTFine(hitTFine);
1080 digit->setIntegral(hitIntegral);
1081 digit->setRevo9Counter(evtRevo9Counter);
1082 digit->setPhase(evtPhase);
1083
1084
1085 if (hitHasWaveform) {
1086 digitsWithWaveform.push_back(digit);
1087 }
1088
1089 TOPProductionHitDebug* hitDebug = 0;
1090 if (dataFormat == TOP::RawDataType::c_ProductionDebug01) { // dataformat 0x0401
1091 hitDebug = m_productionHitDebugs.appendNew(hitHasWaveform,
1092 hitIsOnHeap,
1093 hitWindow,
1094 hitIsOnHeap ? 428 + hitHeapWindow : hitWindow, //hitHeapWindow is counted from the start of the heap
1095 hitIsWindowStraddle);
1096 } else if (dataFormat == TOP::RawDataType::c_ProductionDebug02) { // dataformat 0x0402
1097 hitDebug = m_productionHitDebugs.appendNew(hitHasWaveform,
1098 hitIsOnHeap,
1099 hitWindow,
1100 hitIsOnHeap ? 428 + hitHeapWindow : hitWindow, //hitHeapWindow is counted from the start of the heap
1101 hitIsWindowStraddle,
1102 hitWindow + 1, //logical address of straddle window is always +1
1103 hitIsOnHeapStraddle ? 428 + hitHeapWindowStraddle : hitWindow +
1104 1); //physical address might be entirely different if straddled window is on heap
1105 }
1106
1107 //parse extra words if exist:
1108 for (unsigned int i = 0; i < evtExtra; ++i) {
1109 word = array.getWord(); // extra hit word i, undefined so far
1110 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1111 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1112 << "\thit extra word " << i << " (" << evtExtra << ")");
1113 hitDebug->appendExtraWord(word);
1114 }
1115
1116 if (m_addRelations and hitDebug) {
1117 digit->addRelationTo(hitDebug);
1118 }
1119
1120 numHitsFound += 1;
1121 } // end of hits loop
1122
1123 word = array.getWord(); // event footer word, sdType(8)/sdData(12)/0x5(3)/nHits(9)
1124 unsigned int evtSdType = (word >> 24);
1125 unsigned int evtSdData = (word >> 12) & 0xFFF;
1126 unsigned int evtMagicFooter = (word >> 9) & 0x7;
1127 unsigned int evtNHits = word & 0x1FF;
1128 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1129 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1130 << "\tevtSdType = " << evtSdType
1131 << ", evtSdData = " << evtSdData
1132 << ", evtMagicFooter = " << evtMagicFooter
1133 << ", evtNHits = " << evtNHits << " (" << numHitsFound << ")");
1134
1135 if (evtSdType != 0) {
1136 m_slowData.appendNew(evtScrodID, evtSdType, evtSdData);
1137 }
1138
1139 if (evtMagicFooter != 0x5) {
1140 B2WARNING("TOPUnpacker: event footer magic word mismatch. should be 0x5."
1141 << LogVar("Magic word", evtMagicFooter));
1142 return array.getRemainingWords();
1143 }
1144
1145 B2DEBUG(22, "the rest:");
1146
1147 unsigned int numParsedWaveforms = 0;
1148 while (array.peekWord() != 0x6c617374 //next word is not wf footer word
1149 && array.getRemainingWords() > 0) {
1150
1151 word = array.getWord(); // waveform word 0, nSamples(16)/0x0(5)/nWindows(3)/0(1)/carrier(2)/asic(2)/channel(3)
1152 unsigned int wfNSamples = (word >> 16);
1153 unsigned int wfNWindows = (word >> 8) & 0x7;
1154 unsigned int wfCarrier = (word >> 5) & 0x3;
1155 unsigned int wfAsic = (word >> 3) & 0x3;
1156 unsigned int wfChannel = word & 0x7;
1157
1158 // determine hardware channel and pixelID (valid only if feemap available!)
1159 const auto& mapper = m_topgp->getChannelMapper();
1160 unsigned channel = mapper.getChannel(boardstack, wfCarrier, wfAsic, wfChannel);
1161 int pixelID = mapper.getPixelID(channel);
1162
1163 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1164 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1165 << "\twfNSamples = " << wfNSamples
1166 << ", wfNWindows = " << wfNWindows
1167 << ", wfCarrier = " << wfCarrier
1168 << ", wfAsic = " << wfAsic
1169 << ", wfChannel " << wfChannel);
1170
1171 if (wfNSamples != 32 && wfNSamples != 16) {
1172 B2WARNING("TOPUnpacker: suspicious value for wfNSamples."
1173 << LogVar("wfNSamples", wfNSamples));
1174 return array.getRemainingWords();
1175 }
1176
1177 word = array.getWord(); // waveform word 1, 0x0(1)/startSamp(6)/logAddress(9)/carrierEventNumber(7)/readAddr(9)
1178 unsigned int wfStartSample = (word >> 25) & 0x3F;
1179 unsigned int wfWindowLogic = (word >> 16) & 0x1FF;
1180 unsigned int wfEventNumber = (word >> 9) & 0x7F;
1181 unsigned int wfWindowPhysical = word & 0x1FF;
1182
1183 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1184 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1185 << "\twfStartSample = " << wfStartSample
1186 << ", wfWindowLogic = " << wfWindowLogic
1187 << ", wfEventNumber = " << wfEventNumber
1188 << ", wfWindowPhysical = " << wfWindowPhysical);
1189
1190 std::vector<short> wfSamples;
1191
1192 for (unsigned int i = 0; i < wfNSamples / 2; ++i) {
1193 short wfSampleLast = 0;
1194 short wfSampleFirst = 0;
1195
1196
1197 word = array.getWord(); // waveform sample word i, reserved(4)/sample 2*i+1(12)/reserved(4)/sample 2*i(12)
1198 if (pedestalSubtracted) {
1199 wfSampleLast = (word >> 16);
1200 wfSampleFirst = word & 0xFFFF;
1201 } else {
1202 wfSampleLast = (word >> 16) & 0xFFF;
1203 wfSampleFirst = word & 0xFFF;
1204
1205 }
1206
1207 B2DEBUG(22, std::dec << array.getIndex() << ":\t" << setfill('0') << setw(4) << std::hex <<
1208 (word >> 16) << " " << setfill('0') << setw(4) << (word & 0xFFFF) << std::dec
1209 << "\twfSample" << 2 * i + 1 << " = " << wfSampleLast
1210 << ", wfSample" << 2 * i << " = " << wfSampleFirst);
1211
1212 wfSamples.push_back(wfSampleFirst);
1213 wfSamples.push_back(wfSampleLast);
1214 }
1215
1216 // append waveform
1217 auto* waveform = m_waveforms.appendNew(moduleID, pixelID, channel, evtScrodID,
1218 wfWindowLogic, wfStartSample, wfSamples);
1219 waveform->setPedestalSubtractedFlag(pedestalSubtracted);
1220 waveform->setPhysicalWindow(wfWindowPhysical);
1221 if (numParsedWaveforms < digitsWithWaveform.size()) {
1222 const auto* digit = digitsWithWaveform[numParsedWaveforms];
1223 if (digit->getScrodChannel() == channel % 128) {
1224 digit->addRelationTo(waveform);
1225 } else {
1226 B2WARNING("TOPUnpacker: hit and its waveform have different channel number."
1227 << LogVar("channel (hit)", digit->getScrodChannel())
1228 << LogVar("channel (waveform)", channel % 128));
1229 }
1230 }
1231 numParsedWaveforms += 1;
1232
1233 } // end of waveform segments loop
1234
1235 if (numExpectedWaveforms != numParsedWaveforms) {
1236 B2WARNING("TOPUnpacker: number of expected and parsed waveforms does not match."
1237 << LogVar("expected", numExpectedWaveforms)
1238 << LogVar("parsed", numParsedWaveforms));
1239 }
1240
1241 return array.getRemainingWords();
1242 }

◆ unpackProductionDraft()

void unpackProductionDraft ( const int * buffer,
int bufferSize )
private

Unpack raw data given in a tentative production format (will vanish in future)

Parameters
bufferraw data buffer
bufferSizebuffer size

Definition at line 243 of file TOPUnpackerModule.cc.

244 {
245
246 B2DEBUG(22, "Unpacking ProductionDraft to TOPDigits, dataSize = " << bufferSize);
247
248 unsigned short scrodID = buffer[0] & 0xFFFF;
249 const auto* feemap = m_topgp->getFrontEndMapper().getMap(scrodID);
250 if (!feemap) {
251 B2ERROR("TOPUnpacker: no front-end map available."
252 << LogVar("SCROD ID", scrodID));
253 return;
254 }
255 int moduleID = feemap->getModuleID();
256 int boardstack = feemap->getBoardstackNumber();
257 const auto& mapper = m_topgp->getChannelMapper();
258
259 const auto* geo = m_topgp->getGeometry();
260 auto subBits = geo->getNominalTDC().getSubBits();
261 int sampleDivisions = 0x1 << subBits;
262
263 for (int i = 1; i < bufferSize; i++) {
264 int word = buffer[i];
265 int tdc = word & 0xFFFF;
266 double rawTime = double(tdc) / sampleDivisions;
267 unsigned chan = ((word >> 16) & 0x7F) + boardstack * 128;
268 unsigned flags = (word >> 24) & 0xFF;
269 int pixelID = mapper.getPixelID(chan);
270 auto* digit = m_digits.appendNew(moduleID, pixelID, rawTime);
271 digit->setTime(geo->getNominalTDC().getTime(tdc));
272 digit->setChannel(chan);
273 digit->setHitQuality((TOPDigit::EHitQuality) flags);
274 }
275
276 }

◆ unpackType0Ver16()

void unpackType0Ver16 ( const int * buffer,
int bufferSize )
private

Unpack raw data given in feature-extraction production format.

Parameters
bufferraw data buffer
bufferSizebuffer size

Definition at line 279 of file TOPUnpackerModule.cc.

280 {
281
282 B2DEBUG(22, "Unpacking Type0Ver16 to TOPRawDigits, dataSize = " << bufferSize);
283
284 DataArray array(buffer, bufferSize, m_swapBytes);
285 unsigned word = array.getWord();
286 unsigned short scrodID = word & 0x0FFF;
287
288 unsigned last = array.getLastWord();
289 int Nhits = last & 0x01FF;
290 if (bufferSize != 5 * Nhits + 2) {
291 B2ERROR("TOPUnpacker: corrupted data (feature-extraction format)."
292 << LogVar("SCROD ID", scrodID));
293 return;
294 }
295
296 short SDType = last >> 24;
297 short SDValue = (last >> 12) & 0x0FFF;
298 if (SDType != 0) m_slowData.appendNew(scrodID, SDType, SDValue);
299
300 unsigned short errorFlags = 0;
301 if (((word >> 12) & 0x0F) != 0x0A) errorFlags |= TOPRawDigit::c_HeadMagic;
302 if (((last >> 9) & 0x07) != 0x05) errorFlags |= TOPRawDigit::c_TailMagic;
303
304 for (int hit = 0; hit < Nhits; hit++) {
305 auto* digit = m_rawDigits.appendNew(scrodID, TOPRawDigit::c_Production);
306
307 word = array.getWord(); // word 1
308 digit->setCarrierNumber((word >> 30) & 0x03);
309 digit->setASICNumber((word >> 28) & 0x03);
310 digit->setASICChannel((word >> 25) & 0x07);
311 digit->setASICWindow((word >> 16) & 0x1FF);
312 digit->setTFine((word >> 8) & 0x0F);
313 auto flags = errorFlags;
314 if (((word >> 12) & 0x0F) != 0x0B) flags |= TOPRawDigit::c_HitMagic;
315 unsigned short checkSum = sumShorts(word);
316
317 word = array.getWord(); // word 2
318 digit->setValuePeak(expand13to16bits(word >> 16));
319 digit->setIntegral(word & 0xFFFF);
320 checkSum += sumShorts(word);
321
322 word = array.getWord(); // word 3
323 digit->setValueRise0(expand13to16bits(word >> 16));
324 digit->setValueRise1(expand13to16bits(word));
325 checkSum += sumShorts(word);
326
327 word = array.getWord(); // word 4
328 digit->setValueFall0(expand13to16bits(word >> 16));
329 digit->setValueFall1(expand13to16bits(word));
330 checkSum += sumShorts(word);
331
332 word = array.getWord(); // word 5
333 digit->setSampleRise(word >> 24);
334 digit->setDeltaSamplePeak((word >> 20) & 0x0F);
335 digit->setDeltaSampleFall((word >> 16) & 0x0F);
336 checkSum += sumShorts(word);
337 if (checkSum != 0) flags |= TOPRawDigit::c_HitChecksum;
338
339 digit->setErrorFlags(flags);
340
341 }
342
343 }

◆ ~OpticalGunModule()

~OpticalGunModule ( )
virtual

Destructor.

Definition at line 85 of file OpticalGunModule.cc.

86 {
87 if (m_customDistribution) delete m_customDistribution;
88 }

◆ ~TOPBackgroundModule()

~TOPBackgroundModule ( )
virtual

Destructor.

Definition at line 110 of file TOPBackgroundModule.cc.

111 {
112
113 }

◆ ~TOPChannelT0MCModule()

~TOPChannelT0MCModule ( )
virtual

Destructor.

Definition at line 52 of file TOPChannelT0MCModule.cc.

53 {
54 }

◆ ~TOPDoublePulseGeneratorModule()

Destructor.

Definition at line 85 of file TOPDoublePulseGeneratorModule.cc.

86 {
87 if (m_timebase) delete m_timebase;
88 }

◆ ~TOPDQMModule()

~TOPDQMModule ( )
virtual

Destructor.

Definition at line 55 of file TOPDQMModule.cc.

56 {
57 }

◆ ~TOPGainEfficiencyCalculatorModule()

Destructor.

Definition at line 83 of file TOPGainEfficiencyCalculatorModule.cc.

83{}

◆ ~TOPInterimFENtupleModule()

Destructor.

Definition at line 78 of file TOPInterimFENtupleModule.cc.

78{}

◆ ~TOPLaserCalibratorModule()

Destructor.

Definition at line 71 of file TOPLaserCalibratorModule.cc.

72 {
73 }

◆ ~TOPLaserHitSelectorModule()

Destructor.

Definition at line 92 of file TOPLaserHitSelectorModule.cc.

92{}

◆ ~TOPMCTrackMakerModule()

~TOPMCTrackMakerModule ( )
virtual

Destructor.

Definition at line 57 of file TOPMCTrackMakerModule.cc.

58 {
59 }

◆ ~TOPNtupleModule()

~TOPNtupleModule ( )
virtual

Destructor.

Definition at line 68 of file TOPNtupleModule.cc.

69 {
70 }

◆ ~TOPPackerModule()

~TOPPackerModule ( )
virtual

Destructor.

Definition at line 66 of file TOPPackerModule.cc.

67 {
68 }

◆ ~TOPRawDigitConverterModule()

Destructor.

Definition at line 109 of file TOPRawDigitConverterModule.cc.

110 {
111 }

◆ ~TOPTimeBaseCalibratorModule()

Destructor.

Definition at line 102 of file TOPTimeBaseCalibratorModule.cc.

103 {
104 }

◆ ~TOPTriggerDigitizerModule()

Destructor.

Definition at line 64 of file TOPTriggerDigitizerModule.cc.

65 {
66 }

◆ ~TOPUnpackerModule()

~TOPUnpackerModule ( )
virtual

Destructor.

Definition at line 78 of file TOPUnpackerModule.cc.

79 {
80 }

◆ ~TOPWaveformFeatureExtractorModule()

Destructor.

Definition at line 66 of file TOPWaveformFeatureExtractorModule.cc.

67 {
68 }