Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:21

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef PROTOTYPE4_CALOTEMPLATEFIT_H
0004 #define PROTOTYPE4_CALOTEMPLATEFIT_H
0005 
0006 //* Unpacks raw HCAL PRDF files *//
0007 // Abhisek Sen
0008 
0009 #include <fun4all/SubsysReco.h>
0010 
0011 #include <phparameter/PHParameters.h>
0012 
0013 #include <string>
0014 #include<TProfile.h>
0015 #include<TH1.h>
0016 #include <TThread.h>
0017 #include <ROOT/TThreadExecutor.hxx>
0018 #include <ROOT/TThreadedObject.hxx>
0019 #include "TThread.h"
0020 
0021 class PHCompositeNode;
0022 class RawTowerContainer;
0023 
0024 class CaloTemplateFit : public SubsysReco
0025 {
0026  public:
0027   CaloTemplateFit(const std::string &name);
0028 
0029   int InitRun(PHCompositeNode *topNode);
0030 
0031   int process_event(PHCompositeNode *topNode);
0032 
0033   void CreateNodeTree(PHCompositeNode *topNode);
0034 
0035   std::string get_calib_tower_node_prefix() const
0036   {
0037     return _calib_tower_node_prefix;
0038   }
0039 
0040   void set_calib_tower_node_prefix(const std::string &calibTowerNodePrefix)
0041   {
0042     _calib_tower_node_prefix = calibTowerNodePrefix;
0043   }
0044 
0045   std::string get_raw_tower_node_prefix() const
0046   {
0047     return _raw_tower_node_prefix;
0048   }
0049 
0050   void set_raw_tower_node_prefix(const std::string &rawTowerNodePrefix)
0051   {
0052     _raw_tower_node_prefix = rawTowerNodePrefix;
0053   }
0054 
0055   void set_nthreads(int nthreads)
0056   {
0057     _nthreads= nthreads;
0058   }
0059   void set_nsamples(int nsamples)
0060   {
0061     _nsamples= nsamples;
0062   }
0063   void set_templatefile (const std::string &templatename)
0064   {
0065     template_input_file =templatename;
0066   }
0067 
0068 
0069   //! Get the parameters for readonly
0070   const PHParameters &GetCalibrationParameters() const { return _calib_params; } 
0071 
0072   //! Get the parameters for update. Useful fields are listed in
0073   //! SetDefaultParameters();
0074   PHParameters &GetCalibrationParameters() { return _calib_params; } 
0075 
0076   //! Overwrite the parameter. Useful fields are listed in
0077   //! SetDefaultParameters();
0078    void SetCalibrationParameters(const PHParameters &calib_params) 
0079    { 
0080      _calib_params = calib_params; 
0081    } 
0082 
0083   enum FitMethodType
0084   {
0085     //! single power-low-exp fit, PROTOTYPE4_FEM::SampleFit_PowerLawExp()
0086     kPowerLawExp,
0087 
0088     //! power-low-double-exp fit, PROTOTYPE4_FEM::SampleFit_PowerLawDoubleExp
0089     kPowerLawDoubleExp,
0090 
0091     //! power-low-double-exp fit, PROTOTYPE4_FEM::SampleFit_PowerLawDoubleExp,
0092     //! and constraining all tower take identical shape
0093     kPowerLawDoubleExpWithGlobalFitConstraint,
0094 
0095     //! just use the peak sample, PROTOTYPE4_FEM::SampleFit_PeakSample()
0096     kPeakSample
0097 
0098   };
0099 
0100   void SetFitType(FitMethodType t) { _fit_type = t; } 
0101 
0102  private:
0103   RawTowerContainer *_calib_towers;
0104   RawTowerContainer *_raw_towers;
0105 
0106   std::string detector;
0107   std::string RawTowerNodeName;
0108   std::string CaliTowerNodeName;
0109 
0110   std::string _calib_tower_node_prefix;
0111   std::string _raw_tower_node_prefix;
0112 
0113 
0114   int _nthreads;
0115 
0116   int _nsamples;
0117 
0118 
0119   static TProfile* h_template; 
0120   static double template_function(double *x, double *par);
0121   std::vector<std::vector<float>>  calo_processing_perchnl(std::vector<std::vector<float>> chnlvector);
0122   std::vector<float>  calo_processing_singlethread(std::vector<float> chnlvector);
0123   /* ROOT::TThreadedObject<TF1> testfit; */
0124   std::string template_input_file;
0125 
0126   TH1F* h_data;
0127   TF1* f_fit;
0128 
0129   PHParameters _calib_params;
0130 
0131   FitMethodType _fit_type; 
0132 
0133   //! load the default parameter to param
0134   void SetDefaultParameters(PHParameters &param);
0135 };
0136 
0137 #endif