Commit 7c4be5e4 authored by Morfouace's avatar Morfouace
Browse files

Adding FissionChamber itself. Not containing inside the ChiNU detector.

Adding modification to Actar as well
parent 264934b4
......@@ -78,7 +78,6 @@ void Analysis::TreatEvent(){
TVector3 vX = TVector3(1,0,0);
TVector3 aTrack, vB;
if(TrackMult>1){
vTrack = Actar->GetTracks();
double scalarproduct=0;
......@@ -106,7 +105,8 @@ void Analysis::TreatEvent(){
double ZBeamPoint = vTrack[BeamTrack].GetZh();
TVector3 vBeamPos = TVector3(XBeamPoint,YBeamPoint,ZBeamPoint);
vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam*DriftVelocity);
//vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam*DriftVelocity);
vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam);
BeamAngle = (vX.Angle(vB))*180/TMath::Pi();
for(unsigned int i=0; i<TrackMult; i++){
......@@ -117,9 +117,11 @@ void Analysis::TreatEvent(){
double vertex_x = vTrack[i].GetVertexPostion(vBeam,vBeamPos).X()*PadSizeX;
double vertex_y = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Y()*PadSizeY;
double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z()*DriftVelocity;
//double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z()*DriftVelocity;
double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z();
aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir*DriftVelocity);
//aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir*DriftVelocity);
aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir);
double angle = vX.Angle(aTrack)*180/TMath::Pi();
//double angle = vB.Angle(aTrack)*180/TMath::Pi();
if(angle>90) angle = 180-angle;
......@@ -130,8 +132,10 @@ void Analysis::TreatEvent(){
double y2 = vTrack[i].GetYh()*PadSizeY-0.5*NumberOfPadsY*PadSizeY;
//double z1 = -(vTrack[i].GetZm()-256)*DriftVelocity;
//double z2 = -(vTrack[i].GetZh()-256)*DriftVelocity;
double z1 = vTrack[i].GetZm()*DriftVelocity;
double z2 = vTrack[i].GetZh()*DriftVelocity;
//double z1 = vTrack[i].GetZm()*DriftVelocity;
double z1 = vTrack[i].GetZm();
//double z2 = vTrack[i].GetZh()*DriftVelocity;
double z2 = vTrack[i].GetZh();
if(vertex_x>0 && vertex_x<256){
......
ConfigActar
RecoRansac= 0
RecoCluster= 1
RecoVisu= 0
RecoRansac= 1
RecoCluster= 0
RecoVisu= 1
HIT_THRESHOLD= 2
Q_THRESHOLD= 0
T_THRESHOLD= 0
......@@ -17,4 +17,4 @@ Gas= iC4H10
%Gas= D2
%Pressure in mbar
Pressure= 100
DriftVelocity= 2.66
DriftVelocity= 0.8e-2
......@@ -17,7 +17,7 @@ void LoadCut()
void LoadChain()
{
chain = new TChain("PhysicsTree");
chain->Add("../../Outputs/Analysis/Example4.root");
chain->Add("../../../Outputs/Analysis/Example4.root");
}
////////////////////////////////////////////////
......
......@@ -18,7 +18,7 @@ void LoadCut()
void LoadChain()
{
chain = new TChain("PhysicsTree");
chain->Add("../../Outputs/Analysis/Example4.root");
chain->Add("../../../Outputs/Analysis/Example4.root");
}
////////////////////////////////////////////////
......
This diff is collapsed.
add_custom_command(OUTPUT TFissionChamberPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TFissionChamberPhysics.h TFissionChamberPhysicsDict.cxx TFissionChamberPhysics.rootmap libNPFissionChamber.dylib DEPENDS TFissionChamberPhysics.h)
add_custom_command(OUTPUT TFissionChamberDataDict.cxx COMMAND ../../scripts/build_dict.sh TFissionChamberData.h TFissionChamberDataDict.cxx TFissionChamberData.rootmap libNPFissionChamber.dylib DEPENDS TFissionChamberData.h)
add_library(NPFissionChamber SHARED TFissionChamberSpectra.cxx TFissionChamberData.cxx TFissionChamberPhysics.cxx TFissionChamberDataDict.cxx TFissionChamberPhysicsDict.cxx )
target_link_libraries(NPFissionChamber ${ROOT_LIBRARIES} NPCore)
install(FILES TFissionChamberData.h TFissionChamberPhysics.h TFissionChamberSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
/*****************************************************************************
* 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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TFissionChamberData.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
ClassImp(TFissionChamberData)
//////////////////////////////////////////////////////////////////////
TFissionChamberData::TFissionChamberData() {
}
//////////////////////////////////////////////////////////////////////
TFissionChamberData::~TFissionChamberData() {
}
//////////////////////////////////////////////////////////////////////
void TFissionChamberData::Clear() {
// Energy
fFissionChamber_E_DetectorNbr.clear();
fFissionChamber_Energy.clear();
// Time
fFissionChamber_T_DetectorNbr.clear();
fFissionChamber_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TFissionChamberData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TFissionChamberData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fFissionChamber_E_DetectorNbr.size();
cout << "FissionChamber_E_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fFissionChamber_E_DetectorNbr[i]
<< " Energy: " << fFissionChamber_Energy[i];
}
// Time
mysize = fFissionChamber_T_DetectorNbr.size();
cout << "FissionChamber_T_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fFissionChamber_T_DetectorNbr[i]
<< " Time: " << fFissionChamber_Time[i];
}
}
#ifndef __FissionChamberDATA__
#define __FissionChamberDATA__
/*****************************************************************************
* 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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using namespace std;
// ROOT
#include "TObject.h"
class TFissionChamberData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
// Energy
vector<UShort_t> fFissionChamber_E_DetectorNbr;
vector<Double_t> fFissionChamber_Energy;
// Time
vector<UShort_t> fFissionChamber_T_DetectorNbr;
vector<Double_t> fFissionChamber_Time;
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TFissionChamberData();
~TFissionChamberData();
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void Clear();
void Clear(const Option_t*) {};
void Dump() const;
//////////////////////////////////////////////////////////////
// Getters and Setters
// Prefer inline declaration to avoid unnecessary called of
// frequently used methods
// add //! to avoid ROOT creating dictionnary for the methods
public:
////////////////////// SETTERS ////////////////////////
// Energy
inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){
fFissionChamber_E_DetectorNbr.push_back(DetNbr);
fFissionChamber_Energy.push_back(Energy);
};//!
// Time
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
fFissionChamber_T_DetectorNbr.push_back(DetNbr);
fFissionChamber_Time.push_back(Time);
};//!
////////////////////// GETTERS ////////////////////////
// Energy
inline UShort_t GetMultEnergy() const
{return fFissionChamber_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fFissionChamber_E_DetectorNbr[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fFissionChamber_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fFissionChamber_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fFissionChamber_T_DetectorNbr[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fFissionChamber_Time[i];}//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TFissionChamberData,1) // FissionChamberData structure
};
#endif
/*****************************************************************************
* 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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TFissionChamberPhysics.h"
// STL
#include <sstream>
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <limits>
using namespace std;
// NPL
#include "RootInput.h"
#include "RootOutput.h"
#include "NPDetectorFactory.h"
#include "NPOptionManager.h"
// ROOT
#include "TChain.h"
ClassImp(TFissionChamberPhysics)
///////////////////////////////////////////////////////////////////////////
TFissionChamberPhysics::TFissionChamberPhysics()
: m_EventData(new TFissionChamberData),
m_PreTreatedData(new TFissionChamberData),
m_EventPhysics(this),
m_Spectra(0),
m_E_RAW_Threshold(0), // adc channels
m_E_Threshold(0), // MeV
m_NumberOfDetectors(0) {
}
///////////////////////////////////////////////////////////////////////////
/// A usefull method to bundle all operation to add a detector
void TFissionChamberPhysics::AddDetector(TVector3 , string ){
// In That simple case nothing is done
// Typically for more complex detector one would calculate the relevant
// positions (stripped silicon) or angles (gamma array)
m_NumberOfDetectors++;
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::AddDetector(double R, double Theta, double Phi, string shape){
// Compute the TVector3 corresponding
TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta));
// Call the cartesian method
AddDetector(Pos,shape);
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::BuildSimplePhysicalEvent() {
BuildPhysicalEvent();
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::BuildPhysicalEvent() {
// apply thresholds and calibration
PreTreat();
// match energy and time together
unsigned int mysizeE = m_PreTreatedData->GetMultEnergy();
unsigned int mysizeT = m_PreTreatedData->GetMultTime();
for (UShort_t e = 0; e < mysizeE ; e++) {
for (UShort_t t = 0; t < mysizeT ; t++) {
if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) {
DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e));
Energy.push_back(m_PreTreatedData->Get_Energy(e));
Time.push_back(m_PreTreatedData->Get_Time(t));
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::PreTreat() {
// This method typically applies thresholds and calibrations
// Might test for disabled channels for more complex detector
// clear pre-treated object
ClearPreTreatedData();
// instantiate CalibrationManager
static CalibrationManager* Cal = CalibrationManager::getInstance();
// Energy
unsigned int mysize = m_EventData->GetMultEnergy();
for (UShort_t i = 0; i < mysize ; ++i) {
if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) {
Double_t Energy = Cal->ApplyCalibration("FissionChamber/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i));
if (Energy > m_E_Threshold) {
m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy);
}
}
}
// Time
mysize = m_EventData->GetMultTime();
for (UShort_t i = 0; i < mysize; ++i) {
Double_t Time= Cal->ApplyCalibration("FissionChamber/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to file
string FileName = "./configs/ConfigFissionChamber.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigFissionChamber.dat found: Default parameter loaded for Analayis " << FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigFissionChamber.dat " << endl;
// Save it in a TAsciiFile
TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
asciiConfig->AppendLine("%%% ConfigFissionChamber.dat %%%");
asciiConfig->Append(FileName.c_str());
asciiConfig->AppendLine("");
// read analysis config file
string LineBuffer,DataBuffer,whatToDo;
while (!AnalysisConfigFile.eof()) {
// Pick-up next line
getline(AnalysisConfigFile, LineBuffer);
// search for "header"
string name = "ConfigFissionChamber";
if (LineBuffer.compare(0, name.length(), name) == 0)
ReadingStatus = true;
// loop on tokens and data
while (ReadingStatus ) {
whatToDo="";
AnalysisConfigFile >> whatToDo;
// Search for comment symbol (%)
if (whatToDo.compare(0, 1, "%") == 0) {
AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' );
}
else if (whatToDo=="E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_E_RAW_Threshold << endl;
}
else if (whatToDo=="E_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_E_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_E_Threshold << endl;
}
else {
ReadingStatus = false;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::Clear() {
DetectorNumber.clear();
Energy.clear();
Time.clear();
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::ReadConfiguration(NPL::InputParser parser) {
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("FissionChamber");
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl;
vector<string> cart = {"POS","Shape"};
vector<string> sphe = {"R","Theta","Phi","Shape"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(cart)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// FissionChamber " << i+1 << endl;
TVector3 Pos = blocks[i]->GetTVector3("POS","mm");
string Shape = blocks[i]->GetString("Shape");
AddDetector(Pos,Shape);
}
else if(blocks[i]->HasTokenList(sphe)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// FissionChamber " << i+1 << endl;
double R = blocks[i]->GetDouble("R","mm");
double Theta = blocks[i]->GetDouble("Theta","deg");
double Phi = blocks[i]->GetDouble("Phi","deg");
string Shape = blocks[i]->GetString("Shape");
AddDetector(R,Theta,Phi,Shape);
}
else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::InitSpectra() {
m_Spectra = new TFissionChamberSpectra(m_NumberOfDetectors);
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::FillSpectra() {
m_Spectra -> FillRawSpectra(m_EventData);
m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData);
m_Spectra -> FillPhysicsSpectra(m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::CheckSpectra() {
m_Spectra->CheckSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::ClearSpectra() {
// To be done
}
///////////////////////////////////////////////////////////////////////////
map< string , TH1*> TFissionChamberPhysics::GetSpectra() {
if(m_Spectra)
return m_Spectra->GetMapHisto();
else{
map< string , TH1*> empty;
return empty;
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::WriteSpectra() {
m_Spectra->WriteSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::AddParameterToCalibrationManager() {
CalibrationManager* Cal = CalibrationManager::getInstance();
for (int i = 0; i < m_NumberOfDetectors; ++i) {
Cal->AddParameter("FissionChamber", "D"+ NPL::itoa(i+1)+"_ENERGY","FissionChamber_D"+ NPL::itoa(i+1)+"_ENERGY");
Cal->AddParameter("FissionChamber", "D"+ NPL::itoa(i+1)+"_TIME","FissionChamber_D"+ NPL::itoa(i+1)+"_TIME");
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::InitializeRootInputRaw() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchStatus("FissionChamber", true );
inputChain->SetBranchAddress("FissionChamber", &m_EventData );
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::InitializeRootInputPhysics() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchAddress("FissionChamber", &m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::InitializeRootOutput() {
TTree* outputTree = RootOutput::getInstance()->GetTree();
outputTree->Branch("FissionChamber", "TFissionChamberPhysics", &m_EventPhysics