TBigRIPSPPACPhysics.h 6.77 KB
Newer Older
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#ifndef TBIGRIPSPPACPHYSICS_H
#define TBIGRIPSPPACPHYSICS_H
/*****************************************************************************
 * Copyright (C) 2009-2016    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: Adrien MATTA  contact address: matta@lpccaen.in2p3.fr    *
 *                                                                           *
 * Creation Date  : October 2020                                             *
 * Last update    :                                                          *
 *---------------------------------------------------------------------------*
 * Decription:                                                               *
 *  This class hold SamuraiFDC2 treated data                                 *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * Comment:                                                                  *
 *                                                                           *  
 *                                                                           *
 *                                                                           *
 *****************************************************************************/
// STL
#include <vector>
#include <map>

// NPL
#include "TBigRIPSPPACData.h"
#include "BigRIPSPPACVariables.h"
//#include "TBigRIPSPPACSpectra.h"
#include "NPCalibrationManager.h"
#include "NPVDetector.h"
#include "NPInputParser.h"
#include "NPXmlParser.h"
#include "NPDCReconstruction.h"
// ROOT 
#include "TVector3.h" 
// Forward declaration
//class TBigRIPSPPACSpectra;


using namespace std ;

class TBigRIPSPPACPhysics : public TObject, public NPL::VDetector{
  public:
    TBigRIPSPPACPhysics();
    ~TBigRIPSPPACPhysics() {};

  public: 
    void Clear();   
    void Clear(const Option_t*) {};
    void Print();   

  public:
57 58
    std::vector<int> ID;
    std::vector<int> FP;
59 60 61 62 63 64 65
    std::vector<double> TX1;
    std::vector<double> TX2;
    std::vector<double> TY1;
    std::vector<double> TY2;
    std::vector<double> TA;
    std::vector<double> TSumX;
    std::vector<double> TDiffX;
66
    std::vector<double> X;
67 68
    std::vector<double> TSumY;
    std::vector<double> TDiffY;
69 70
    std::vector<double> Y;
    std::vector<int> multiHit;
71 72 73 74 75 76 77 78 79 80 81 82
    //map<int,vector<double>> Data ;

    int PileUp;

  public:
    // Projected position at given Z plan
    TVector3 ProjectedPosition(double Z);

  private: // Xml file read to add PPACs and their parameters 
    void AddPPACs(string name, NPL::XmlParser&);//! take the XML file and fill in parameters of each PPAC
    map<int,double> RawUpperLimit;//! Upper Value of TDC range considered for a PPAC
    map<int,double> RawLowerLimit;//! Lower Value of TDC range considered for a PPAC 
83
    map<int,int>  IDtoFP;//! Focal plane where the PPAC is located
84 85 86 87 88
    map<int,double> ch2ns_TX1; 
    map<int,double> ch2ns_TX2; 
    map<int,double> ch2ns_TY1; 
    map<int,double> ch2ns_TY2; 
    map<int,double> ch2ns_TA;
89 90 91 92 93 94 95 96
    map<int,double> xns_off;
    map<int,double> yns_off;
    map<int,double> x_offset;
    map<int,double> xpos_offset;
    map<int,double> x_ns2mm;
    map<int,double> y_offset;
    map<int,double> ypos_offset;
    map<int,double> y_ns2mm;
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
  
  public: //   Innherited from VDetector Class

    // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token
    void ReadConfiguration(NPL::InputParser) ;

    // Add Parameter to the CalibrationManger
    void AddParameterToCalibrationManager() ;      

    // Activated associated Branches and link it to the private member DetectorData address
    // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated
    void InitializeRootInputRaw() ;

    // Activated associated Branches and link it to the private member DetectorPhysics address
    // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated
    void InitializeRootInputPhysics() ;

    // Create associated branches and associated private member DetectorPhysics address
    void InitializeRootOutput() ;

    // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. 
    void BuildPhysicalEvent() ;

    // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...).
    // This method aimed to be used for analysis performed during experiment, when speed is requiered.
    // NB: This method can eventually be the same as BuildPhysicalEvent.
    void BuildSimplePhysicalEvent() ;

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

    // Those two method all to clear the Event Physics or Data
    void ClearEventPhysics() {Clear();}      
    void ClearEventData()    {m_EventData->Clear();}   

    // Method related to the TSpectra classes, aimed at providing a framework for online applications
    // Instantiate the Spectra class and the histogramm throught it
    void InitSpectra();
    // Fill the spectra hold by the spectra class
    void FillSpectra();
    // Used for Online mainly, perform check on the histo and for example change their color if issues are found
    void CheckSpectra();
    // Used for Online only, clear all the spectra hold by the Spectra class
    void ClearSpectra();
    // Write Spectra to file
    void WriteSpectra();

  public:      //   Specific to SamuraiFDC2 Array

    //   Clear The PreTeated object
    void ClearPreTreatedData()   {m_PreTreatedData->Clear();}

    //   Remove bad channel, calibrate the data and apply threshold
    void PreTreat();

    // Retrieve raw and pre-treated data
    TBigRIPSPPACData* GetRawData()        const {return m_EventData;}
    TBigRIPSPPACData* GetPreTreatedData() const {return m_PreTreatedData;}

  private:   //   Root Input and Output tree classes
    TBigRIPSPPACData*         m_EventData;//!
    TBigRIPSPPACData*         m_PreTreatedData;//!
    TBigRIPSPPACPhysics*      m_EventPhysics;//!


  private: // Spectra Class
   // TBigRIPSPPACSpectra* m_Spectra; // !

  public: // Spectra Getter
    map< string , TH1*> GetSpectra(); 

  public: // Static constructor to be passed to the Detector Factory
    static NPL::VDetector* Construct();
    ClassDef(TBigRIPSPPACPhysics,1)  // BigRIPSPPACPhysics structure
};

#endif