Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:07

0001 #ifndef TPCCALIB_TPCSPACECHARGERECONSTRUCTIONHELPER_H
0002 #define TPCCALIB_TPCSPACECHARGERECONSTRUCTIONHELPER_H
0003 /**
0004  * \file TpcSpaceChargeReconstructionHelper.h
0005  * \brief performs simple histogram manipulations for generating space charge distortion map suitable for correcting TPC clusters
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  */
0008 
0009 #include <array>
0010 #include <cstdint>
0011 #include <vector>
0012 
0013 // forward declarations
0014 class TH2;
0015 class TH3;
0016 class TString;
0017 
0018 class TpcSpaceChargeReconstructionHelper
0019 {
0020  public:
0021   /// create TPOT acceptance mask, using provided binning
0022   /**
0023    * this histogram contains 1 in cells that match the TPOT acceptance
0024    * only Micromegas in the central sector (TPC sectors 9 and 21) are considered
0025    */
0026   static void create_tpot_mask(TH3* /*source*/);
0027 
0028   /// first z extrapolation
0029   /**
0030    * interpolate along z between the two micromegas modules fully equiped sector
0031    * the mask is used to decide in which bins the extrapolation must be performed
0032    */
0033   static void extrapolate_z(TH3* /*source*/, const TH3* /*mask*/);
0034 
0035   /// second z extrapolation
0036   /**
0037    * interpolate along z between the readout plane (at which location the distortion is zero) and the outermost micromegas module
0038    * the mask is used to decide in which bins the extrapolation must be performed
0039    * the side is a bit mask to tell on which side of the histograms the pad-planes are
0040    */
0041   enum Side : uint8_t
0042   {
0043     Side_negative = 1 << 0,
0044     Side_positive = 1 << 1,
0045     Side_both = Side_negative | Side_positive
0046   };
0047 
0048   static void extrapolate_z2(TH3* /*source*/, const TH3* /*mask*/, uint8_t /* side */);
0049 
0050   /// first phi extrapolation
0051   /**
0052    * copy the full z dependence of reference sector to all other sectors
0053    * normalized by the measurement from provided micromegas, at the appropriate z
0054    * the mask is used to decide in which bins the extrapolation must be performed
0055    */
0056   static void extrapolate_phi1(TH3* /*source*/, const TH2* /*source_cm*/, const TH3* /*mask*/);
0057 
0058   /// second phi extrapolation
0059   /**
0060    * for each r, z and phi bin, linearly extrapolate between neighbor phi sector measurements
0061    */
0062   static void extrapolate_phi2(TH3* /*source*/, const TH3* /*mask*/);
0063 
0064   /// separate positive and negative z histograms
0065   /**
0066    * split histograms in two, the first with negative z values only, the second with positive z values
0067    * this must be done before adding guarding bins around each axis, in order to prevent artifacts during calls to Interpolate
0068    * at the central membrane (z = 0)
0069    */
0070   static std::tuple<TH3*, TH3*> split(const TH3* /*source*/);
0071 
0072   /**
0073    * copy input histogram into output, with new name, while adding two "guarding bins" on
0074    * each axis, with identical content and error as the first and last bin of the original histogram
0075    * this is necessary for being able to call TH3->Interpolate() when using these histograms
0076    * to correct for the space charge distortions.
0077    */
0078   static TH3* add_guarding_bins(const TH3* /*source*/, const TString& /*name*/);
0079 
0080   /// shortcut to angular window, needed to define TPOT acceptance
0081   using range_t = std::pair<double, double>;
0082 
0083   /// list of angular windows
0084   using range_list_t = std::vector<range_t>;
0085 
0086   //!@name define phi range for each TPOT sector
0087   //@{
0088   static void set_phi_range_central( const range_t& );
0089   static void set_phi_range_east( const range_t& );
0090   static void set_phi_range_west( const range_t& );
0091   //@}
0092 
0093   //!@name define theta range in each TPOT sector.
0094   //@{
0095   static void set_theta_range_central( const range_list_t& range_list )
0096   { theta_range_central = range_list; }
0097 
0098   static void set_theta_range_east( const range_list_t& range_list )
0099   { theta_range_east = range_list; }
0100 
0101   static void set_theta_range_west( const range_list_t& range_list )
0102   { theta_range_west = range_list; }
0103   //@}
0104 
0105   private:
0106 
0107   ///@name detector geometry
0108   //@{
0109   /// phi range for central sector (TPC sectors 9 and 21)
0110   static range_t phi_range_central;
0111 
0112   /// phi range for east sector (TPC sectors 8 and 20)
0113   static range_t phi_range_east;
0114 
0115   /// phi range for west sector (TPC sectors 10 and 22)
0116   static range_t phi_range_west;
0117 
0118   /// list of theta angles for each micromeas in central sector with theta defined as atan2(z,r)
0119   static range_list_t theta_range_central;
0120 
0121   /// list of theta angles for each micromeas in central sector with theta defined as atan2(z,r)
0122   static range_list_t theta_range_east;
0123 
0124   /// list of theta angles for each micromeas in central sector with theta defined as atan2(z,r)
0125   static range_list_t theta_range_west;
0126   //@}
0127 
0128 };
0129 
0130 #endif