Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:00

0001 #ifndef Analysis_h
0002 #define Analysis_h
0003 
0004 #include <TROOT.h>
0005 #include <TChain.h>
0006 #include <TFile.h>
0007 #include <TH2.h>
0008 #include <TStyle.h>
0009 #include <TCanvas.h>
0010 
0011 // Header file for the classes stored in the TTree if any.
0012 #include "vector"
0013 
0014 #include <sPhenixStyle.C>
0015 #include "HistSetting.hh"
0016 #include "MipHist.hh"
0017 
0018 class Analysis
0019 {
0020 private:
0021   TTree          *fChain;   //!pointer to the analyzed TTree or TChain
0022   Int_t           fCurrent; //!current Tree number in a TChain
0023   TCanvas* c_;
0024   
0025   int run_ = 0;
0026   int adc7_ = 210;
0027   int counter_too_large_cluster_ = 0;
0028   int cluster_size_max_ = 5;
0029   int hit_num_inner_ = 0;
0030   int hit_num_outer_ = 0;
0031   
0032   double top_margin_ = 0.05; // 0.1;
0033   double right_margin_ = 0.05; // 0.15;
0034   double adc7_modification_factor_ = 0.35;
0035 
0036   bool is_preliminary_ = false;
0037   bool does_adc7_correction_ = true;
0038   bool does_adc14_correction_ = true;
0039  
0040   // Fixed size dimensions of array or collections stored in the TTree if any.
0041 
0042   // Declaration of leaf types
0043   Int_t           evt_clus;
0044   vector<double>  *x_in;
0045   vector<double>  *y_in;
0046   vector<double>  *z_in;
0047   vector<double>  *r_in;
0048   vector<int>     *size_in;
0049   vector<double>  *phi_in;
0050   vector<double>  *theta_in;
0051   vector<double>  *adc_in;
0052   vector<bool>    *is_associated_in;
0053   vector<double>  *track_incoming_theta_in;
0054   vector<double>  *x_out;
0055   vector<double>  *y_out;
0056   vector<double>  *z_out;
0057   vector<double>  *r_out;
0058   vector<int>     *size_out;
0059   vector<double>  *phi_out;
0060   vector<double>  *theta_out;
0061   vector<double>  *adc_out;
0062   vector<bool>    *is_associated_out;
0063   vector<double>  *track_incoming_theta_out;
0064   Double_t        z_vertex;
0065 
0066   // List of branches
0067   TBranch        *b_evt_clus;   //!
0068   TBranch        *b_x_in;   //!
0069   TBranch        *b_y_in;   //!
0070   TBranch        *b_z_in;   //!
0071   TBranch        *b_r_in;   //!
0072   TBranch        *b_size_in;   //!
0073   TBranch        *b_phi_in;   //!
0074   TBranch        *b_theta_in;   //!
0075   TBranch        *b_adc_in;   //!
0076   TBranch        *b_is_associated_in;   //!
0077   TBranch        *b_track_incoming_theta_in;   //!
0078   TBranch        *b_x_out;   //!
0079   TBranch        *b_y_out;   //!
0080   TBranch        *b_z_out;   //!
0081   TBranch        *b_r_out;   //!
0082   TBranch        *b_size_out;   //!
0083   TBranch        *b_phi_out;   //!
0084   TBranch        *b_theta_out;   //!
0085   TBranch        *b_adc_out;   //!
0086   TBranch        *b_is_associated_out;   //!
0087   TBranch        *b_track_incoming_theta_out;   //!
0088   TBranch        *b_z_vertex;   //!
0089 
0090   //TH1D* hist;
0091   vector < MipHist* > hists_;
0092   MipHist* hist_all_;
0093   MipHist* hist_aso_;
0094   MipHist* hist_no_aso_;
0095   MipHist* hist_ang85_; // 85 - 90 deg
0096   MipHist* hist_ang45_; // 45 - 55 deg
0097   MipHist* hist_ang35_; // 35 - 45 deg
0098   MipHist* hist_ang25_; // 25 - 35 deg
0099 
0100   MipHist* hist_ang80_; // 80 - 90 deg
0101   MipHist* hist_ang70_; // 70 - 80 deg
0102   MipHist* hist_ang60_; // 60 - 70 deg
0103   MipHist* hist_ang50_; // 50 - 60 deg
0104   MipHist* hist_ang40_; // 40 - 50 deg
0105   MipHist* hist_ang30_; // 30 - 40 deg
0106   MipHist* hist_ang20_; // 20 - 30 deg
0107   MipHist* hist_ang10_; // 10 - 20 deg
0108   MipHist* hist_ang0_ ; //  0 - 10 deg
0109 
0110   MipHist* hist_ang10_11_ ; //  10 - 11 deg
0111   MipHist* hist_ang20_21_ ; //  20 - 21 deg
0112   MipHist* hist_ang30_31_ ; //  30 - 31 deg
0113 
0114   TH1D* hist_association_;
0115   TH1D* hist_association_in_;
0116   TH1D* hist_association_out_;
0117   TH2D* hist_association_in_out_;
0118   TH2D* hist_correlation_;
0119   
0120   virtual ~Analysis();
0121   virtual Int_t    Cut(Long64_t entry);
0122   virtual Int_t    GetEntry(Long64_t entry);
0123   virtual Long64_t LoadTree(Long64_t entry);
0124   virtual void     Init(TTree *tree);
0125   virtual Bool_t   Notify();
0126 
0127   string GetDate();
0128   double GetExpectedPeakPosition( double theta );
0129   void DrawSingle( MipHist* mip_hist );
0130   void DrawMultiple( vector < MipHist* >& mip_hists, string output_tag, bool use_color_palette = false );
0131   void DrawMultiPanel( vector < MipHist* >& mip_hists, string output_tag );
0132 
0133   TBox* DrawExpectedPeakRegion( double theta_min, double theta_max );
0134   void DrawWords();
0135   void FillClusterInfo( int mode = 0 ); // 0: inner, 1: outer
0136   
0137   template < typename TH >
0138   void DrawStats( TH* hist, double xmin, double ymin, double xmax, double ymax, int font = 4)
0139   {
0140 
0141     gPad->Update();
0142 
0143     TPaveStats *st = (TPaveStats*)hist->FindObject("stats");
0144     if( st == nullptr )
0145       {
0146     string color_red = "\033[31m";
0147     string color_cancel = "\033[m";
0148 
0149     cerr << color_red << endl;
0150     cerr << " " << string( 50, '=' ) << endl;
0151     cerr << " void DrawStats( TH* hist, double xmin, double ymin, double xmax, double ymax, int font = 4)" << endl;
0152     cerr << " TPaveStats *st = (TPaveStats*)hist->FindObject(\"stats\")  ---> nullptr" << endl;
0153     cerr << " Someting wrong!!!" << endl;
0154     cerr << " " << string( 50, '=' ) << endl;
0155     cerr << color_cancel << endl;
0156     return;
0157 
0158       }
0159 
0160     st->SetTextColorAlpha( hist->GetLineColor(), 1.0 );
0161     st->SetLineColorAlpha( hist->GetLineColor(), 1.0 );
0162     st->SetFillStyle( 1001 );
0163     st->SetFillColor( 0 );
0164     //  st->SetTextFont( font );
0165 
0166     st->SetX1NDC( xmin );
0167     st->SetX2NDC( xmax );
0168     st->SetY1NDC( ymin );
0169     st->SetY2NDC( ymax );
0170 
0171     //  st->SetOptStat( 111111 ) ; // overflow and underflos are ON
0172     st->Draw("same");
0173   }
0174 
0175   
0176 public:
0177 
0178   Analysis( int run = 41981 );
0179   
0180   virtual void     Loop();
0181   virtual void     Show(Long64_t entry = -1);
0182 
0183   void Draw();
0184   void InitParameter();
0185 
0186   void Print();
0187   
0188   void SetAdc7Correction( bool flag=true ){ does_adc7_correction_ = flag; };
0189   void SetAdc14Correction( bool flag=true ){ does_adc14_correction_ = flag; };
0190   void SetPreliminary( bool flag ){ is_preliminary_ = flag;};
0191 };
0192 
0193 #endif
0194 
0195 #ifndef Analysis_cxx
0196 #include "Analysis.cc"
0197 #endif // #ifdef Analysis_cxx