Skip to content
Snippets Groups Projects
Commit 5ab7635a authored by GIRARD ALCINDOR Valérian's avatar GIRARD ALCINDOR Valérian
Browse files

Updating conversion

parent f1460bfc
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,30 @@ link_directories(../install/lib)
link_directories($ENV{NPTOOL_HOME}/$ENV{NPTOOL_ENV}/lib)
if(DEFINED ENV{MFMLIB})
SET(MFMLIB $ENV{MFMLIB})
SET(MFM_DIR $ENV{MFMLIB})
MESSAGE(STATUS "The libraries and software will be build using MFM libraries")
SET(MFM_LIBRARY_DIR ${MFM_DIR}/lib)
# Set MFM_BIN_DIR
SET(MFM_BIN_DIR ${MFM_DIR}/bin)
# Set MFM_INCLUDE_DIR
SET(MFM_INCLUDES ${MFM_DIR}/include)
SET(MFM_INCLUDE_DIRS ${MFM_DIR}/include )
SET(MFM_LIBRARIES "-L${MFM_LIBRARY_DIR} -lMFM")
LIST(APPEND COMPDEF "WITH_MFM")
LIST(APPEND MFMCOMPLIB ${MFM_LIBRARIES})
LIST(APPEND INCLUDE_DIR ${MFM_INCLUDE_DIRS})
if(EXISTS "${MFM_DIR}/lib/libMFM${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(MFM_FOUND true)
else()
set(MFM_FOUND false)
endif()
endif()
### ROOT ###
# find package
find_package(ROOT QUIET)
......
add_library(NPZdd SHARED ZddDetector.cxx ZddData.cxx ZddPhysics.cxx)
target_link_libraries(NPZdd PUBLIC PUBLIC ROOT::RIO ROOT::Tree ROOT::Physics ROOT::Imt NPRoot nptool )
if(MFM_FOUND)
target_compile_definitions(NPZdd PUBLIC MFM_FOUND)
target_link_libraries(NPZdd PUBLIC ${MFMCOMPLIB})
endif()
install(DIRECTORY ./ DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY} FILES_MATCHING PATTERN "*.h" )
ROOT_GENERATE_DICTIONARY(ZddDict ZddData.h ZddPhysics.h LINKDEF Zddlinkdef.hh MODULE NPZdd)
......@@ -18,65 +18,135 @@ ZddDetector::~ZddDetector() {}
////////////////////////////////////////////////////////////////////////////////
void ZddDetector::ReadConfiguration(nptool::InputParser parser) {
auto blocks = parser.GetAllBlocksWithToken("zdd");
vector<string> TokenZDD = {"R", "Theta"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){
if (blocks[i]->HasTokenList(TokenZDD)) {
double R = blocks[i]->GetDouble("R", "mm");
double Theta = blocks[i]->GetDouble("Theta", "deg");
Add_ZDD(R, Theta);
}
else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
auto blocks = parser.GetAllBlocksWithToken("zdd");
std::vector<std::string> token = {"Type", "Board", "NUMEXOChannel"};
for (unsigned int i = 0; i < blocks.size(); i++) {
if (blocks[i]->HasTokenList(token)) {
std::string Type = blocks[i]->GetString("Type");
unsigned int Board = blocks[i]->GetInt("Board");
std::vector<int> NUMEXOChannel = blocks[i]->GetVectorInt("NUMEXOChannel");
unsigned int NUMEXOChannel_size = NUMEXOChannel.size();
for (unsigned int j = 0; j < NUMEXOChannel_size; j++) {
unsigned int index = Board * 1e3 + (unsigned int)NUMEXOChannel[j];
SetNumexoMap(Type, Board, (unsigned int)NUMEXOChannel[j]);
// m_BoardDataTypeMap[index] = "ZDD";
}
}
}
ReadAnalysisConfig();
}
////////////////////////////////////////////////////////////////////////////////
void ZddDetector::SetNumexoMap(std::string Type, unsigned int Board,
unsigned int NUMEXOChannel) {
unsigned int index = Board * 1e3 + NUMEXOChannel;
m_NumexoMap[index] = Type;
}
////////////////////////////////////////////////////////////////////////////////
std::string ZddDetector::GetTypeFromNumexoMap(unsigned int Board,
unsigned int Channel) {
unsigned int index = Board * 1e3 + Channel;
std::string Type = m_NumexoMap[index];
return Type;
}
////////////////////////////////////////////////////////////////////////////////
void ZddDetector::BuildRawEvent(const std::string& daq_name,
const std::string& st_type_key,
void* commonframe) {
#ifdef MFM_FOUND
int type_key = ((MFMCommonFrame*)commonframe)->GetFrameType();
if (type_key == MFM_REA_GENE_FRAME_TYPE) {
TreatFrame((MFMCommonFrame*)commonframe);
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
void ZddDetector::TreatFrame(void* commonframe) {
#ifdef MFM_FOUND
std::shared_ptr<MFMReaGenericFrame> ReaFrame = std::make_shared<MFMReaGenericFrame>();
ReaFrame->SetAttributs(((MFMCommonFrame*)commonframe)->GetPointHeader());
int Board = -1;
int Channel = -1;
unsigned short E = 0;
unsigned long long TS = 0;
int Time = -1;
Board = ReaFrame->GetBoardId();
Channel = ReaFrame->GetTGCristalId();
E = ReaFrame->GetEnergy();
TS = ReaFrame->GetTimeStamp();
Time = ReaFrame->GetTime();
std::string Type = GetTypeFromNumexoMap(Board, Channel);
if (Type == "PL") {
m_RawData->SetZDDPL(Channel, E, TS);
} else if (Type == "IC") {
m_RawData->SetZDDIC(Channel, E, TS);
} else if (Type == "DC") {
m_RawData->SetZDDDC(Channel, E, TS);
} else if (Type == "EXO") {
m_RawData->SetZDDEXO(Channel, E, TS);
}
#endif
}
void ZddDetector::BuildPhysicalEvent() {
// if (NPOptionManager::getInstance()->IsReader() == true) {
// m_RawData = &(**r_ReaderEventData);
// }
// if (NPOptionManager::getInstance()->IsReader() == true) {
// m_RawData = &(**r_ReaderEventData);
// }
// apply thresholds and calibration
PreTreat();
// match energy and time together
Match_IC1();
if(m_PhysicsData->IC_Nbr.size() > 0)
if (m_PhysicsData->IC_Nbr.size() > 0)
Match_PL();
// Treat_DC();
}
///////////////////////////////////////////////////////////////////////////
void ZddDetector::Treat_DC(){
/* // Dont have anything to modify for the moment
unsigned int mysizeDC = m_CalData->GetMultDrift();
for(int i = 0; i < mysizeDC; i++){
DC_DetectorNumber.push_back(m_CalData->GetDrift_DetectorNbr(i));
DC_DriftTime.push_back(m_CalData->Get_DriftTime(i));
}*/
void ZddDetector::Treat_DC() {
/* // Dont have anything to modify for the moment
unsigned int mysizeDC = m_CalData->GetMultDrift();
for(int i = 0; i < mysizeDC; i++){
DC_DetectorNumber.push_back(m_CalData->GetDrift_DetectorNbr(i));
DC_DriftTime.push_back(m_CalData->Get_DriftTime(i));
}*/
}
///////////////////////////////////////////////////////////////////////////
void ZddDetector::Match_IC(){
//////////////////////////////// Currently Simply matching if mult = 5, could be improved to treat mult > 5
if(m_CalData->GetZDD_ICMult() == 5){
// CHecking that each IC is only encountered once and then sorting them in the right order with the map
for(unsigned int i = 0; i < m_CalData->GetZDD_ICMult(); i++){
if(SortIC.find(m_CalData->GetZDD_ICN(i)) != SortIC.end()){
SortIC.clear();
break;
}
SortIC[m_CalData->GetZDD_ICN(i)] = std::make_pair(m_CalData->GetZDD_ICE(i),m_CalData->GetZDD_ICTS(i));
void ZddDetector::Match_IC() {
//////////////////////////////// Currently Simply matching if mult = 5, could
/// be improved to treat mult > 5
if (m_CalData->GetZDD_ICMult() == 5) {
// CHecking that each IC is only encountered once and then sorting them in
// the right order with the map
for (unsigned int i = 0; i < m_CalData->GetZDD_ICMult(); i++) {
if (SortIC.find(m_CalData->GetZDD_ICN(i)) != SortIC.end()) {
SortIC.clear();
break;
}
SortIC[m_CalData->GetZDD_ICN(i)]
= std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
}
// Adding the IC info to the std::vectors
m_PhysicsData->ICSum = 0;
for(auto it = SortIC.begin(); it != SortIC.end(); ++it){
m_PhysicsData->ICSum+= (it->second).first;
// std::cout << "Test " << it->first << " " << it->second.first << std::endl;
for (auto it = SortIC.begin(); it != SortIC.end(); ++it) {
m_PhysicsData->ICSum += (it->second).first;
// std::cout << "Test " << it->first << " " << it->second.first <<
// std::endl;
m_PhysicsData->IC_Nbr.push_back(it->first);
m_PhysicsData->IC_E.push_back((it->second).first);
m_PhysicsData->IC_TS.push_back((it->second).second);
......@@ -84,51 +154,56 @@ void ZddDetector::Match_IC(){
}
}
void ZddDetector::Match_IC1(){
//////////////////////////////// Currently Simply matching if mult = 5, could be improved to treat mult > 5
// CHecking that each IC is only encountered once and then sorting them in the right order with the map
for(unsigned int i = 0; i < m_CalData->GetZDD_ICMult(); i++){
if(SortIC.find(m_CalData->GetZDD_ICN(i)) == SortIC.end()){
SortIC[m_CalData->GetZDD_ICN(i)] = std::make_pair(m_CalData->GetZDD_ICE(i),m_CalData->GetZDD_ICTS(i));
}
void ZddDetector::Match_IC1() {
//////////////////////////////// Currently Simply matching if mult = 5, could
/// be improved to treat mult > 5
// CHecking that each IC is only encountered once and then sorting them in the
// right order with the map
for (unsigned int i = 0; i < m_CalData->GetZDD_ICMult(); i++) {
if (SortIC.find(m_CalData->GetZDD_ICN(i)) == SortIC.end()) {
SortIC[m_CalData->GetZDD_ICN(i)]
= std::make_pair(m_CalData->GetZDD_ICE(i), m_CalData->GetZDD_ICTS(i));
}
// Adding the IC info to the std::vectors
m_PhysicsData->ICSum = 0;
for(auto it = SortIC.begin(); it != SortIC.end(); ++it){
m_PhysicsData->ICSum+= (it->second).first;
}
// Adding the IC info to the std::vectors
m_PhysicsData->ICSum = 0;
for (auto it = SortIC.begin(); it != SortIC.end(); ++it) {
m_PhysicsData->ICSum += (it->second).first;
m_PhysicsData->IC_Nbr.push_back(it->first);
m_PhysicsData->IC_E.push_back((it->second).first);
m_PhysicsData->IC_TS.push_back((it->second).second);
}
}
}
void ZddDetector::Match_PL(){
for(unsigned int i = 0; i < m_CalData->GetZDD_PLMult(); i++){
SortPL[m_CalData->GetZDD_PLN(i)] = std::make_pair(m_CalData->GetZDD_PLE(i),m_CalData->GetZDD_PLTS(i));
void ZddDetector::Match_PL() {
for (unsigned int i = 0; i < m_CalData->GetZDD_PLMult(); i++) {
SortPL[m_CalData->GetZDD_PLN(i)]
= std::make_pair(m_CalData->GetZDD_PLE(i), m_CalData->GetZDD_PLTS(i));
}
for(auto it = SortPL.begin(); it != SortPL.end(); ++it){
m_PhysicsData->PL_Nbr.push_back(it->first);
m_PhysicsData->PL_E.push_back((it->second).first);
m_PhysicsData->PL_TS.push_back((it->second).second);
for (auto it = SortPL.begin(); it != SortPL.end(); ++it) {
m_PhysicsData->PL_Nbr.push_back(it->first);
m_PhysicsData->PL_E.push_back((it->second).first);
m_PhysicsData->PL_TS.push_back((it->second).second);
}
}
void ZddDetector::PreTreat() {
ClearPreTreatedData();
}
void ZddDetector::PreTreat() { ClearPreTreatedData(); }
///////////////////////////////////////////////////////////////////////////
void ZddDetector::PreTreatEnergy(std::string Detector){
void ZddDetector::PreTreatEnergy(std::string Detector) {
/*unsigned int mysize = m_RawData->GetMultEnergy(Detector);
for (UShort_t i = 0; i < mysize ; ++i) {
if (m_RawData->Get_Energy(Detector, i) > m_E_RAW_Threshold) {
Double_t Energy = Cal->ApplyCalibration("ZDD/ENERGY"+nptool::itoa(m_RawData->GetE_DetectorNbr(Detector, i)),m_RawData->Get_Energy(Detector, i));
if (Energy > m_E_Threshold) {
Double_t Energy =
Cal->ApplyCalibration("ZDD/ENERGY"+nptool::itoa(m_RawData->GetE_DetectorNbr(Detector,
i)),m_RawData->Get_Energy(Detector, i)); if (Energy > m_E_Threshold) {
if(Detector == "IC")
m_CalData->Set_IC_Energy(m_RawData->GetE_DetectorNbr(Detector, i), Energy);
m_CalData->Set_IC_Energy(m_RawData->GetE_DetectorNbr(Detector, i),
Energy);
else if(Detector == "Plastic")
m_CalData->Set_Plastic_Energy(m_RawData->GetE_DetectorNbr(Detector, i), Energy);
m_CalData->Set_Plastic_Energy(m_RawData->GetE_DetectorNbr(Detector,
i), Energy);
}
}
}
......@@ -136,18 +211,19 @@ void ZddDetector::PreTreatEnergy(std::string Detector){
}
///////////////////////////////////////////////////////////////////////////
void ZddDetector::PreTreatTime(std::string Detector){
/* unsigned int mysize = m_RawData->GetMultTime(Detector);
for (UShort_t i = 0; i < mysize; ++i) {
Double_t Time= Cal->ApplyCalibration("ZDD/TIME"+nptool::itoa(m_RawData->GetT_DetectorNbr(Detector, i)),m_RawData->Get_Time(Detector,i));
if(Detector == "IC")
m_CalData->Set_IC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
else if(Detector == "Plastic")
m_CalData->Set_Plastic_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
else if(Detector == "DC")
m_CalData->Set_DC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
}
*/
void ZddDetector::PreTreatTime(std::string Detector) {
/* unsigned int mysize = m_RawData->GetMultTime(Detector);
for (UShort_t i = 0; i < mysize; ++i) {
Double_t Time=
Cal->ApplyCalibration("ZDD/TIME"+nptool::itoa(m_RawData->GetT_DetectorNbr(Detector,
i)),m_RawData->Get_Time(Detector,i)); if(Detector == "IC")
m_CalData->Set_IC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
else if(Detector == "Plastic")
m_CalData->Set_Plastic_Time(m_RawData->GetT_DetectorNbr(Detector, i),
Time); else if(Detector == "DC")
m_CalData->Set_DC_Time(m_RawData->GetT_DetectorNbr(Detector, i), Time);
}
*/
}
///////////////////////////////////////////////////////////////////////////
......@@ -162,63 +238,62 @@ void ZddDetector::ReadAnalysisConfig() {
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigZDD.dat found: Default parameter loaded for Analayis " << FileName << endl;
cout << " No ConfigZDD.dat found: Default parameter loaded for Analayis "
<< FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigZDD.dat " << endl;
//// Save it in a TAsciiFile
//TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
//asciiConfig->AppendLine("%%% ConfigZDD.dat %%%");
//asciiConfig->Append(FileName.c_str());
//asciiConfig->AppendLine("");
// read analysis config file
string LineBuffer,DataBuffer,whatToDo;
// TAsciiFile* asciiConfig =
// RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
// asciiConfig->AppendLine("%%% ConfigZDD.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 = "ConfigZDD";
if (LineBuffer.compare(0, name.length(), name) == 0)
if (LineBuffer.compare(0, name.length(), name) == 0)
ReadingStatus = true;
// loop on tokens and data
while (ReadingStatus ) {
whatToDo="";
while (ReadingStatus) {
whatToDo = "";
AnalysisConfigFile >> whatToDo;
// Search for comment symbol (%)
if (whatToDo.compare(0, 1, "%") == 0) {
AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' );
AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n');
}
else if (whatToDo=="IC_E_RAW_THRESHOLD") {
else if (whatToDo == "IC_E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_IC_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_IC_E_RAW_Threshold << endl;
}
else if (whatToDo=="PL_E_RAW_THRESHOLD") {
} else if (whatToDo == "PL_E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_PL_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_PL_E_RAW_Threshold << endl;
}
else if (whatToDo=="DC_E_RAW_THRESHOLD") {
} else if (whatToDo == "DC_E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_DC_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_DC_E_RAW_Threshold << endl;
}
else if (whatToDo=="EXO_E_RAW_THRESHOLD") {
} else if (whatToDo == "EXO_E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_EXO_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_EXO_E_RAW_Threshold << endl;
}
else if (whatToDo=="MAP_IC") {
} else if (whatToDo == "MAP_IC") {
AnalysisConfigFile >> DataBuffer;
Map_IC[atoi(DataBuffer.substr(0,1).c_str())] = atoi(DataBuffer.substr(1,1).c_str());
cout << whatToDo << " " << atoi(DataBuffer.substr(0,1).c_str()) << " " << atoi(DataBuffer.substr(1,1).c_str()) << endl;
}
else if (whatToDo=="E_THRESHOLD") {
Map_IC[atoi(DataBuffer.substr(0, 1).c_str())]
= atoi(DataBuffer.substr(1, 1).c_str());
cout << whatToDo << " " << atoi(DataBuffer.substr(0, 1).c_str()) << " "
<< atoi(DataBuffer.substr(1, 1).c_str()) << endl;
} else if (whatToDo == "E_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_E_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_E_Threshold << endl;
......
......@@ -18,6 +18,11 @@
#include "TVector2.h"
#include "TVector3.h"
// MFM
#ifdef MFM_FOUND
#include "MFMAllFrames.h"
#endif
namespace zdd {
class ZddDetector : public nptool::VDetector {
......@@ -40,7 +45,7 @@ public: // inherrited from nptool::VDetector
void ReadConfiguration(nptool::InputParser);
// Add Parameter to the CalibrationManger
void AddParameterToCalibrationManager(){};
void AddParameterToCalibrationManager() {};
// Activated associated Branches and link it to the private member
// DetectorData address In this method mother Branches (Detector) AND
......@@ -60,6 +65,24 @@ public: // inherrited from nptool::VDetector
// address
void InitializeDataOutputPhysics(std::shared_ptr<nptool::VDataOutput>);
// This method is called at each event of a conversion to fill in the data
// class
void BuildRawEvent(const std::string& daq_name, const std::string& label,
void* commonframe);
void SetNumexoMap(std::string Type, unsigned int Board,
unsigned int NUMEXOChannel);
std::string GetTypeFromNumexoMap(unsigned int Board, unsigned int Channel);
void TreatFrame(void* commonframe);
#ifdef MFM_FOUND
MFMMergeFrame* MergeFrame;
MFMCommonFrame* InsideFrame;
#endif
std::map<unsigned int, std::string> m_NumexoMap;
// This method is called at each event read from the Input Tree. Aim is to
// build treat Raw dat in order to extract physical parameter.
void BuildPhysicalEvent();
......@@ -67,8 +90,8 @@ public: // inherrited from nptool::VDetector
void PreTreat();
void ClearPreTreatedData() { m_CalData->Clear(); }
// Those two method all to clear the Event Physics or Data
void ClearEventPhysics(){};
void ClearEventData(){};
void ClearEventPhysics() { m_PhysicsData->Clear(); };
void ClearEventData() { m_RawData->Clear(); };
void Treat_DC();
// Matching IC
......@@ -124,18 +147,18 @@ private:
// 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(){};
void InitSpectra() {};
// Fill the spectra hold by the spectra class
void FillSpectra(){};
void FillSpectra() {};
// Write the spectra to a file
void WriteSpectra(){};
void WriteSpectra() {};
// Used for Online mainly, perform check on the histo and for example change
// their color if issues are found
void CheckSpectra(){};
void CheckSpectra() {};
// Used for Online only, clear all the spectra hold by the Spectra class
void ClearSpectra(){};
void ClearSpectra() {};
// Used for interoperability with other framework
void SetRawDataPointer(void*){};
void SetRawDataPointer(void*) {};
private:
private: // Parameter used in the analysis
......
#include "ZddPhysics.h"
///////////////////////////////////////////////////////////////////////////
// void ZddDetector::Clear() {
// m_PhysicsData->IC_Nbr.clear();
// m_PhysicsData->IC_E.clear();
// m_PhysicsData->IC_TS.clear();
// m_PhysicsData->PL_Nbr.clear();
// m_PhysicsData->PL_E.clear();
// m_PhysicsData->PL_TS.clear();
// m_PhysicsData->ICSum = 0;
// SortIC.clear();
// SortPL.clear();
// DC_DetectorNumber.clear();
// DC_DriftTime.clear();
// }
void zdd::ZddPhysics::Clear() {
IC_Nbr.clear();
IC_E.clear();
IC_TS.clear();
PL_Nbr.clear();
PL_E.clear();
PL_TS.clear();
ICSum = 0;
// SortIC.clear();
// SortPL.clear();
DC_DetectorNumber.clear();
DC_DriftTime.clear();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment