diff --git a/Inputs/DetectorConfiguration/e628.detector b/Inputs/DetectorConfiguration/e628.detector index c7e491981325826e291dad1351d5dd5503e4de36..7074c4815f16c4feb69439bb1558732e298491ec 100644 --- a/Inputs/DetectorConfiguration/e628.detector +++ b/Inputs/DetectorConfiguration/e628.detector @@ -1,3 +1,19 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSArray +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSDetector + X1_Y1= -34.36 -34.96 -962.5 + X28_Y1= 36.76 -34.96 -962.5 + X1_Y28= -34.36 36.16 -962.5 + X28_Y28= 36.76 36.16 -962.5 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 +CATSDetector + X1_Y1= 34.26 -35.46 -562.5 + X28_Y1= -36.86 -35.46 -562.5 + X1_Y28= 34.26 35.66 -562.5 + X28_Y28= -36.86 35.66 -562.5 + + %%%%%%%%%%%%%%%%%%%%%%%%%%% MUST2Array %%%%%%% Telescope 1 %%%%%%% diff --git a/NPLib/CATS/TCATSPhysics.cxx b/NPLib/CATS/TCATSPhysics.cxx index 1b3cd1014acc6c00166f4ca68bcf21a033e28497..00f896e822b3220b5a409cfedc9807cc95bc6515 100644 --- a/NPLib/CATS/TCATSPhysics.cxx +++ b/NPLib/CATS/TCATSPhysics.cxx @@ -1652,7 +1652,7 @@ namespace LOCAL_CATS double fCATS_X_Q(const TCATSData* m_EventData , const int i) { - return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) + "_Q", + return CalibrationManager::getInstance()->ApplyCalibration( "CATS/D" + itoa( m_EventData->GetCATSDetX(i) ) + "_X" + itoa( m_EventData->GetCATSStripX(i) ) + "_Q", m_EventData->GetCATSChargeX(i) + gRandom->Rndm() - fCATS_Ped_X(m_EventData, i) ); } diff --git a/NPLib/CATS/TCATSSpectra.cxx b/NPLib/CATS/TCATSSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..006b19ca85c07810e498ab7fa0d20f347d429619 --- /dev/null +++ b/NPLib/CATS/TCATSSpectra.cxx @@ -0,0 +1,298 @@ +/***************************************************************************** + * Copyright (C) 2009-2013 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// NPL +#include "TCATSSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + + +// ROOT +#include "TString.h" +#include "TDirectory.h" +#include "TFile.h" + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::TCATSSpectra() +{ + fNumberOfCats = 0; + fStripsNumber = 28; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::TCATSSpectra(unsigned int NumberOfCats) +{ + if (NPOptionManager::getInstance()->GetVerboseLevel() > 0) { + cout << "************************************************" << endl; + cout << "TCATSSpectra: Initalising control spectra for " << NumberOfCats << " detectors" << endl; + cout << "************************************************" << endl; + } + + fNumberOfCats = NumberOfCats; + fStripsNumber = 28; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + + +//////////////////////////////////////////////////////////////////////////////// +TCATSSpectra::~TCATSSpectra() +{ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitRawSpectra() +{ + TString name; + + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + // CATS_STRX_Q_RAW + name = Form("CATS%d_STRX_Q_RAW", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/RAW/STRQ"); + + // CATS_STRY_Q_RAW + name = Form("CATS%d_STRY_Q_RAW", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/RAW/STRQ"); + + // STRX_MULT + name = Form("CATS%d_STRX_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/RAW/CTRL"); + + // STRY_MULT + name = Form("CATS%d_STRY_MULT", i+1); + AddHisto1D(name, name, fStripsNumber, 1, fStripsNumber+1, "CATS/RAW/CTRL"); + } // end loop on number of cats +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitPreTreatedSpectra() +{ + TString name; + + for (unsigned int i = 0; i < fNumberOfCats; ++i) { // loop on number of cats + // CATS_STRX_Q_CAL + name = Form("CATS%d_STRX_Q_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/CAL/STRQ"); + + // CATS_STRY_Q_CAL + name = Form("CATS%d_STRY_Q_CAL", i+1); + AddHisto2D(name, name, fStripsNumber, 1, fStripsNumber+1, 512, 0, 16384, "CATS/CAL/STRQ"); + } // end loop on number of cats +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::InitPhysicsSpectra() +{ +/* TString name; + // X-Y Impact Matrix + name = "HYB_IMPACT_MATRIX"; + AddHisto2D(name, name, 500, -150, 150, 500, -150, 150, "TIARA/HYBALL/PHY"); + + // Kinematic line + name = "HYB_THETA_E"; + AddHisto2D(name, name, 360, 0, 180, 500, 0, 50, "TIARA/HYBALL/PHY"); + + // Ring v.s. Sector Energy Correlation + name = "HYB_XY_COR"; + AddHisto2D(name, name, 500, 0, 50, 500, 0, 50, "TIARA/HYBALL/PHY"); */ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillRawSpectra(TCATSData* RawData) +{ + TString name; + TString family; + + // CATS_STRX_Q_RAW + for (unsigned int i = 0; i < RawData->GetCATSMultX(); ++i) { // loop on vector + family = "CATS/RAW/STRQ"; + name = Form("CATS%d_STRX_Q_RAW", RawData->GetCATSDetX(i)); + GetHisto(family, name) -> Fill(RawData->GetCATSStripX(i), RawData->GetCATSChargeX(i)); + } // end loop on vector + + // CATS_STRY_Q_RAW + for (unsigned int i = 0; i < RawData->GetCATSMultY(); ++i) { // loop on vector + family = "CATS/RAW/STRQ"; + name = Form("CATS%d_STRY_Q_RAW", RawData->GetCATSDetY(i)); + GetHisto(family, name) -> Fill(RawData->GetCATSStripY(i), RawData->GetCATSChargeY(i)); + } // end loop on vector + + // STRX_MULT + int myMULT[fStripsNumber]; + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetCATSMultX(); i++) myMULT[RawData->GetCATSDetX(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRX_MULT", i+1); + family = "CATS/RAW/CTRL"; + GetHisto(family,name) -> Fill(myMULT[i]); + } + + // STRY_MULT + for (unsigned int i = 0; i < fNumberOfCats; i++) myMULT[i] = 0; + for (unsigned int i = 0; i < RawData->GetCATSMultY(); i++) myMULT[RawData->GetCATSDetY(i)-1] += 1; + + for (unsigned int i = 0; i < fNumberOfCats; i++) { + name = Form("CATS%d_STRY_MULT", i+1); + family = "CATS/RAW/CTRL"; + GetHisto(family,name) -> Fill(myMULT[i]); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillPreTreatedSpectra(TCATSData* PreTreatedData) +{ + TString name; + TString family; + + // CATS_STRX_Q_CAL + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultX(); ++i) { // loop on vector + family = "CATS/CAL/STRQ"; + name = Form("CATS%d_STRX_Q_CAL", PreTreatedData->GetCATSDetX(i)); + GetHisto(family,name) -> Fill(PreTreatedData->GetCATSStripX(i), PreTreatedData->GetCATSChargeX(i)); + } // end loop on vector + + // CATS_STRY_Q_CAL + for (unsigned int i = 0; i < PreTreatedData->GetCATSMultY(); ++i) { // loop on vector + family = "CATS/CAL/STRQ"; + name = Form("CATS%d_STRY_Q_CAL", PreTreatedData->GetCATSDetY(i)); + GetHisto(family,name) -> Fill(PreTreatedData->GetCATSStripY(i), PreTreatedData->GetCATSChargeY(i)); + } // end loop on vector +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::FillPhysicsSpectra(TCATSPhysics* Physics) +{ +/* TString name; + TString family= "TIARA/HYBALL/PHY"; + // X-Y Impact Matrix + + for(unsigned int i = 0 ; i < Physics->Si_E.size(); i++){ + name = "MM_IMPACT_MATRIX"; + double x = Physics->GetPositionOfInteraction(i).x(); + double y = Physics->GetPositionOfInteraction(i).y(); + GetHisto(family,name)-> Fill(x,y); + + name = "MM_THETA_E"; + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + Theta = Theta/deg; + GetHisto(family,name)-> Fill(Theta,Physics->Si_E[i]); + + // STRX_E_CAL + name = Form("MM%d_XY_COR", Physics->TelescopeNumber[i]); + GetHisto(family,name)-> Fill(Physics->Si_EX[i],Physics->Si_EY[i]); + }*/ +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family) +{ + // create histo + TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family) +{ + // create histo + TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup); + + vector<TString> index; + index.push_back(family); + index.push_back(name); + + // fill map + fMapHisto[index] = hist; + + return hist; +} + + + +//////////////////////////////////////////////////////////////////////////////// +TH1* TCATSSpectra::GetHisto(TString family, TString name) +{ + vector<TString> index; + index.push_back(family); + index.push_back(name); + + return fMapHisto.at(index); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TCATSSpectra::WriteHisto(TString filename) +{ + TFile* f = NULL; + + if (filename != "VOID") { + f = new TFile(filename,"RECREATE"); + } + + map< vector<TString>, TH1* >::iterator it; + for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) { + it->second->Write(); + } + + if (filename != "VOID") { + f->Close(); + delete f; + } +} diff --git a/NPLib/CATS/TCATSSpectra.h b/NPLib/CATS/TCATSSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..3f70a7b5148a3ac42fbeee3591fc915be558dd96 --- /dev/null +++ b/NPLib/CATS/TCATSSpectra.h @@ -0,0 +1,84 @@ +#ifndef TTIARAHYBALLSPECTRA_H +#define TTIARAHYBALLSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2013 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : dec 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Tiara/Hyball * + * * + *---------------------------------------------------------------------------* + * Comment: * + * + first version (not complete yet) * + * * + * * + *****************************************************************************/ + +// ROOT headers +#include "TObject.h" +#include <TH1.h> +#include <TH2.h> +#include <TString.h> + +// NPLib headers +#include "TCATSData.h" +#include "TCATSPhysics.h" + +// C++ STL headers +#include <map> +using namespace std; + + +// Forward Declaration +class TCATSPhysics; + + +class TCATSSpectra { + public: + // constructor and destructor + TCATSSpectra(); + TCATSSpectra(unsigned int NumberOfCats); + ~TCATSSpectra(); + + private: + // Instantiate and register histo to maps + TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family); + TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, + Int_t nbinsy, Double_t ylow, Double_t yup, TString family); + + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TCATSData*); + void FillPreTreatedSpectra(TCATSData*); + void FillPhysicsSpectra(TCATSPhysics*); + + public: + // get map histo which will be used for GSpectra in GUser + map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;} + TH1* GetHisto(TString family, TString name); + void WriteHisto(TString filename = "VOID"); + + private: // Information on MUST2 + unsigned int fNumberOfCats; + unsigned int fStripsNumber; + + private: + // map holding histo pointers and their family names + map< vector<TString>, TH1* > fMapHisto; +}; + +#endif