Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-19 09:18:43

0001 /*!
0002  * \file MvtxFakeHitRate.h
0003  * \brief Module to calculate the fake hit rate for the Mvtx
0004  * \author Tanner Mengel <tmengel@bnl.gov>
0005  * \version $Version: 1.0.1 $
0006  * \date $Date: 05/23/2025.
0007  */
0008 
0009 #ifndef MVTXCALIB_MVTXFAKEHITRATE_H
0010 #define MVTXCALIB_MVTXFAKEHITRATE_H
0011 
0012 #include <fun4all/SubsysReco.h>
0013 
0014 #include <cstdint>
0015 #include <string>
0016 #include <vector>
0017 
0018 class PHCompositeNode;
0019 class MvtxHitMap;
0020 class MvtxPixelMask;
0021 class MvtxRawEvtHeader;
0022 class MvtxRawHitContainer;
0023 class TTree;
0024 class TH1;
0025 
0026 class MvtxFakeHitRate : public SubsysReco
0027 {
0028  public:
0029   MvtxFakeHitRate(const std::string& name = "MvtxFakeHitRate")
0030     : SubsysReco(name)
0031   {}
0032   
0033   ~MvtxFakeHitRate() override;
0034 
0035   // standard Fun4All functions
0036   int InitRun(PHCompositeNode* /*topNode*/) override;
0037   int process_event(PHCompositeNode* topNode) override;
0038   int End(PHCompositeNode* /*topNode*/) override;
0039 
0040   void SetOutputfile(const std::string& name) { m_outputfile = name; }
0041   void SetMaxMaskedPixels(int n) { m_max_masked_pixels = n; }
0042   void SelectLayer(int layer = 0) { m_target_layer = layer; }
0043   void StartFromCDB(bool start = true) { m_load_from_cdb = start; }
0044 
0045  private:
0046   // optional output
0047   std::string m_outputfile{"mvtx_fhr.root"};
0048 
0049   int m_max_masked_pixels{1000};
0050   bool m_masked_pixels_in_file{false};
0051   uint64_t m_last_strobe{0};
0052 
0053   int m_target_layer{-1};
0054 
0055   // mask hot pixels
0056   bool m_load_from_cdb{false};
0057   MvtxPixelMask* m_hot_pixel_mask{nullptr};
0058 
0059   // hit map
0060   MvtxHitMap* m_hit_map{nullptr};
0061 
0062   // raw event header and hit container
0063   MvtxRawEvtHeader* m_mvtx_raw_event_header{nullptr};
0064   MvtxRawHitContainer* m_mvtx_raw_hit_container{nullptr};
0065 
0066   TTree* m_tree{nullptr};
0067   int m_num_strobes{0};
0068   int m_num_masked_pixels{0};
0069   double m_noise_threshold{0.0};
0070   std::vector<uint64_t> m_masked_pixels{};
0071 
0072   TTree* m_current_mask{nullptr};
0073   int m_current_nmasked{0};
0074   double m_current_threshold{0.0};
0075   std::vector<uint64_t> m_current_masked_pixels{};
0076 
0077   TH1* m_threshold_vs_nmasked{nullptr};
0078 
0079   int get_nodes(PHCompositeNode* topNode);
0080   int FillCurrentMaskTree();
0081   int CalcFHR();
0082 
0083   double calc_threshold(int nhits) const;
0084 };
0085 
0086 #endif