TSofTofWPhysics.h 5.92 KB
Newer Older
Morfouace's avatar
Morfouace committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#ifndef TSofTofWPHYSICS_H
#define TSofTofWPHYSICS_H
/*****************************************************************************
 * Copyright (C) 2009-2020   this file is part of the NPTool Project       *
 *                                                                           *
 * For the licensing terms see $NPTOOL/Licence/NPTool_Licence                *
 * For the list of contributors see $NPTOOL/Licence/Contributors             *
 *****************************************************************************/

/*****************************************************************************
 * Original Author: Pierre Morfouace  contact address: pierre.morfouace2@cea.fr                        *
 *                                                                           *
 * Creation Date  : November 2020                                           *
 * Last update    :                                                          *
 *---------------------------------------------------------------------------*
 * Decription:                                                               *
 *  This class hold TofTofW Treated data                                *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * Comment:                                                                  *
 *                                                                           *   
 *                                                                           *
 *****************************************************************************/

// C++ headers 
#include <vector>
#include <map>
#include <string>
using namespace std;

// ROOT headers
#include "TObject.h"
#include "TH1.h"
#include "TVector3.h"
35
#include "TRandom3.h"
Morfouace's avatar
Morfouace committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
// NPTool headers
#include "TSofTofWData.h"
#include "NPCalibrationManager.h"
#include "NPVDetector.h"
#include "NPInputParser.h"



class TSofTofWPhysics : public TObject, public NPL::VDetector {
  //////////////////////////////////////////////////////////////
  // constructor and destructor
  public:
    TSofTofWPhysics();
    ~TSofTofWPhysics() {};


  //////////////////////////////////////////////////////////////
  // Inherited from TObject and overriden to avoid warnings
  public: 
    void Clear();   
    void Clear(const Option_t*) {};


  //////////////////////////////////////////////////////////////
  // data obtained after BuildPhysicalEvent() and stored in
  // output ROOT file
  public:
63 64 65 66 67 68
    vector<int>      PlasticNbr;
    vector<double>   TimeNs;
    vector<double>   RawPosY;
    vector<double>   CalPosY;
    vector<double>   RawTof;
    vector<double>   CalTof;
Morfouace's avatar
Morfouace committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110

  /// A usefull method to bundle all operation to add a detector
  void AddDetector(TVector3 POS); 
  void AddDetector(double R, double Theta, double Phi); 
  
  //////////////////////////////////////////////////////////////
  // methods inherited from the VDetector ABC class
  public:
    // read stream from ConfigFile to pick-up detector parameters
    void ReadConfiguration(NPL::InputParser);

    // add parameters to the CalibrationManger
    void AddParameterToCalibrationManager();

    // method called event by event, aiming at extracting the 
    // physical information from detector
    void BuildPhysicalEvent();

    // same as BuildPhysicalEvent() method but with a simpler
    // treatment
    void BuildSimplePhysicalEvent();

    // same as above but for online analysis
    void BuildOnlinePhysicalEvent()  {BuildPhysicalEvent();};

    // activate raw data object and branches from input TChain
    // in this method mother branches (Detector) AND daughter leaves 
    // (fDetector_parameter) have to be activated
    void InitializeRootInputRaw();

    // activate physics data object and branches from input TChain
    // in this method mother branches (Detector) AND daughter leaves 
    // (fDetector_parameter) have to be activated
    void InitializeRootInputPhysics();

    // create branches of output ROOT file
    void InitializeRootOutput();

    // clear the raw and physical data objects event by event
    void ClearEventPhysics() {Clear();}      
    void ClearEventData()    {m_EventData->Clear();}   

111 112 113 114 115
    double CalculateTimeNs(int, int, int, int);
    double GetStartTime() {return m_StartTime;}
    double GetTofAlignedValue() {return m_TofAlignedValue;}
    void SetStartTime(double val) {m_StartTime = val;}
    void SetTofAlignedValue(double val) {m_TofAlignedValue = val;}
Morfouace's avatar
Morfouace committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

  //////////////////////////////////////////////////////////////
  // specific methods to SofTofW array
  public:
    // remove bad channels, calibrate the data and apply thresholds
    void PreTreat();

    // clear the pre-treated object
    void ClearPreTreatedData()   {m_PreTreatedData->Clear();}

    // read the user configuration file. If no file is found, load standard one
    void ReadAnalysisConfig();

    // give and external TSofTofWData object to TSofTofWPhysics. 
    // needed for online analysis for example
    void SetRawDataPointer(TSofTofWData* rawDataPointer) {m_EventData = rawDataPointer;}
    
  // objects are not written in the TTree
  private:
    TSofTofWData*         m_EventData;        //!
    TSofTofWData*         m_PreTreatedData;   //!
    TSofTofWPhysics*      m_EventPhysics;     //!

  // getters for raw and pre-treated data object
  public:
    TSofTofWData* GetRawData()        const {return m_EventData;}
    TSofTofWData* GetPreTreatedData() const {return m_PreTreatedData;}

  // parameters used in the analysis
  private:
146 147 148
    double m_StartTime; //!
    double m_TofAlignedValue; //!
    int m_NumberOfPlastics; //!
Morfouace's avatar
Morfouace committed
149 150 151
    double m_E_RAW_Threshold; //!
    double m_E_Threshold;     //!

152
    TRandom3 rand; //!
Morfouace's avatar
Morfouace committed
153 154 155 156 157 158 159 160 161 162 163
  // number of detectors
  private:
    int m_NumberOfDetectors;  //!

  // Static constructor to be passed to the Detector Factory
  public:
    static NPL::VDetector* Construct();

    ClassDef(TSofTofWPhysics,1)  // SofTofWPhysics structure
};
#endif