Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:21:08

0001 #ifndef TPOT_TPOTMON_H
0002 #define TPOT_TPOTMON_H
0003 
0004 #include "MicromegasGeometry.h"
0005 
0006 #include <micromegas/MicromegasDefs.h>
0007 #include <micromegas/MicromegasMapping.h>
0008 #include <micromegas/MicromegasCalibrationData.h>
0009 #include <onlmon/OnlMon.h>
0010 
0011 #include <array>
0012 #include <memory>
0013 
0014 class Event;
0015 class TH1;
0016 class TH2;
0017 class TH2Poly;
0018 
0019 class TpotMon : public OnlMon
0020 {
0021   public:
0022 
0023   //! constructor
0024   TpotMon(const std::string &name);
0025 
0026   //! destructor
0027   ~TpotMon() override = default;
0028 
0029   int process_event(Event *evt) override;
0030   int Init() override;
0031   int BeginRun(const int runno) override;
0032   int Reset() override;
0033 
0034   //! calibration file
0035   void set_calibration_file( const std::string& value )
0036   { m_calibration_filename = value; }
0037 
0038   //! max sample
0039   void set_max_sample( int value )
0040   { m_max_sample = value; }
0041 
0042   /// set number of RMS sigma used to defined static threshold on a given channel
0043   void set_n_sigma( double value ) { m_n_sigma = value; }
0044 
0045   /// set minimum ADC value, disregarding pedestal and RMS. This removes channels for which calibration has failed
0046   void set_min_adc( double value ) { m_min_adc = value; }
0047 
0048   // define signal sample window
0049   using sample_window_t = std::pair<int, int>;
0050   void set_sample_window_signal( const sample_window_t& value )
0051   { m_sample_window_signal = value; }
0052 
0053   private:
0054 
0055   //! setup bins in a TH2Poly. One bin per detector
0056   void setup_detector_bins( TH2Poly* );
0057 
0058   //! setup bins in TH2Poly, one bin per Resist sector
0059   void setup_resist_bins( TH2Poly*, MicromegasDefs::SegmentationType );
0060 
0061   //! keep track of number of events
0062   int m_evtcnt = 0;
0063 
0064   //! keep track of number of 'full' triggers
0065   /*
0066    * it is estimated by counting the number of lvl1 taggers received for each packet
0067    * and dividing by the number of active packets (2)
0068    */
0069   double m_triggercnt = 0;
0070 
0071   //! mapping
0072   MicromegasMapping m_mapping;
0073 
0074   //! geometry
0075   MicromegasGeometry m_geometry;
0076 
0077   //! calibration filename
0078   std::string m_calibration_filename;
0079 
0080   //! calibration data
0081   MicromegasCalibrationData m_calibration_data;
0082 
0083   //! max sample
0084   int m_max_sample = 105;
0085 
0086   // sample window
0087   sample_window_t m_sample_window_signal = {3, 18};
0088 
0089   //! number of RMS sigma used to define threshold
0090   double m_n_sigma = 5;
0091 
0092   //! minimum ADC value, disregarding pedestal and RMS. This removes channels for which calibration has failed
0093   double m_min_adc = 50;
0094 
0095   //! counter
0096   TH1* m_counters = nullptr;
0097 
0098   //! TPOT per/detector multiplicity
0099   TH2Poly* m_detector_multiplicity_z = nullptr;
0100   TH2Poly* m_detector_multiplicity_phi = nullptr;
0101 
0102   //! TPOT per/detector occupancy
0103   TH2Poly* m_detector_occupancy_z = nullptr;
0104   TH2Poly* m_detector_occupancy_phi = nullptr;
0105 
0106   //! TPOT per/detector multiplicity
0107   TH2Poly* m_resist_multiplicity_z = nullptr;
0108   TH2Poly* m_resist_multiplicity_phi = nullptr;
0109 
0110   //! TPOT per/detector occupancy
0111   TH2Poly* m_resist_occupancy_z = nullptr;
0112   TH2Poly* m_resist_occupancy_phi = nullptr;
0113 
0114   //@name per detector structure
0115   //@{
0116   class detector_histograms_t
0117   {
0118     public:
0119 
0120     /// counts avoce threshold vs sample id in each detector
0121     TH1* m_counts_sample = nullptr;
0122 
0123     /// adc counts vs sample id in each detector
0124     TH2* m_adc_sample = nullptr;
0125 
0126     /// adc counts vs strip id in each detector
0127     TH2* m_adc_channel = nullptr;
0128 
0129     /// sample vs channel above threshold
0130     TH2* m_sample_channel = nullptr;
0131 
0132     /// total charge per hit in each detector
0133     TH1* m_hit_charge = nullptr;
0134 
0135     /// number of signal hits per event in each detector
0136     TH1* m_hit_multiplicity = nullptr;
0137 
0138     /// number of wafeforms per strip in each detector
0139     TH1* m_wf_vs_channel = nullptr;
0140 
0141     /// number of signal hits per strip in each detector
0142     TH1* m_hit_vs_channel = nullptr;
0143 
0144     /// number hearbeat per strip in each detector
0145     TH1* m_heartbeat_vs_channel = nullptr;
0146 
0147   };
0148   //@}
0149 
0150   //@name map tile centers (from MicromegasGeometry) to fee_id
0151   std::map<int, MicromegasGeometry::point_t> m_tile_centers;
0152 
0153   //@name map detector histograms to fee id
0154   std::map<int, detector_histograms_t> m_detector_histograms;
0155 
0156 };
0157 
0158 #endif /* TPOT_TPOTMON_H */