Commit 00ffa8ae authored by Riccardo Longo's avatar Riccardo Longo
Browse files

Many bug fixings and additions

parent 2e5615f3
......@@ -10,6 +10,7 @@
#define CONTAINERS_H
#include "Containers.h"
#include <iostream>
class Channel {
......@@ -42,8 +43,8 @@ class Channel {
bool is_on;
/** Operating voltage of the channel**/
int Vop;
/** Raw waveform for a particular event **/
std::vector < Channel > WF;
/** Raw waveform for a particular event **/
//std::vector < Channel > WF;
};
......
......@@ -42,7 +42,7 @@ class DataReader{
void ReadListOfFiles( std::string listname );
std::vector< Channel > LoadConfigurationFile(std::string _inFile);
std::vector< Channel* > LoadConfigurationFile(std::string _inFile);
void Run();
......
......@@ -13,30 +13,34 @@
#include <vector>
#include <string>
#include "Containers.h"
class Detector{
public:
Detector( );
Detector( std::vector< Channel > _element ){ Element = _element;}
Detector( std::vector< Channel* > _element ){ m_Element = _element;}
virtual ~Detector( );
virtual Channel* GetElement (int row, int column);
virtual double* GetPosition ( ) { return Position; };
virtual double* GetAngle ( ) { return Angle; };
virtual void SetElement ( Channel _entry) { Element.push_back(_entry); };
virtual void SetPosition (double x, double y, double z) { Position[0] = x; Position[1] = y; Position[3] = z; };
virtual void SetAngle (double a = 0, double b = 0, double c = 0) { Angle[0] = a; Angle[1] = b; Angle[3] = c; };
virtual std::vector < Channel* > GetChannelsVector () { return m_Element; }
virtual double* GetPosition ( ) { return m_Position; }
virtual double* GetAngle ( ) { return m_Angle; }
virtual void SetElement ( Channel* _entry) { m_Element.push_back(_entry); }
virtual void SetPosition (double x, double y, double z) { m_Position[0] = x; m_Position[1] = y; m_Position[2] = z; }
virtual void SetAngle (double _cosx = 0, double _cosy = 0, double _cosz = 0) { m_Angle[0] = _cosx; m_Angle[1] = _cosy; m_Angle[2] = _cosz; }
virtual void PrintMap ( ) = 0;
private:
std::vector< Channel > Element;
/** Vector of channels associated to the dector **/
std::vector< Channel* > m_Element;
/** Three element array with x, y, and z of some pre-defined point on the detector **/
double Position[3];
double m_Position[3];
/** Three element array of angle about the x, y, and z axis **/
double Angle[3];
double m_Angle[3];
};
#endif
......@@ -4,22 +4,24 @@
* This contains the prototypes and members
* for RPD
*
* @author Chad Lantz
* @author Chad Lantz, Riccardo Longo
* @bug No known bugs.
*/
#ifndef RPD_H
#define RPD_H
#include "Containers.h"
#include "Detector.h"
class RPD : public Detector{
public:
RPD( );
virtual ~RPD( );
RPD( std::vector< Channel* > _readOut );
~RPD( );
virtual void PrintMap ( );
virtual void PrintMap( );
};
......
......@@ -4,7 +4,7 @@
* This contains the prototypes and members
* for ZDC
*
* @author Chad Lantz
* @author Chad Lantz, Riccardo Longo
* @bug No known bugs.
*/
......@@ -17,14 +17,14 @@ class ZDC : public Detector{
public:
ZDC( );
ZDC(std::vector<Channel *> _readOut , int _zdcNumber);
virtual ~ZDC( );
virtual ~ZDC( int _number ) { Number = _number; };
virtual void PrintMap ( );
virtual void SetNumber ( int _number ) { Number = _number; };
void SetNumber ( int _number ) { m_Number = _number; }
private:
int Number;
int m_Number;
};
#endif
......@@ -14,5 +14,3 @@
#include <iostream>
#include "Containers.h"
......@@ -21,6 +21,8 @@
#include "DataReader.h"
#include "Analysis.h"
#include "Containers.h"
#include "RPD.h"
#include "ZDC.h"
/** @brief Default Constructor for DataReader.
*/
......@@ -103,7 +105,7 @@ void DataReader::ReadListOfFiles( std::string listname ){
m_fListOfFiles = listname;
}
std::vector < Channel > DataReader::LoadConfigurationFile(std::string _inFile "$JCaPA/Utils/ConfigFile2018.xml"){
std::vector < Channel* > DataReader::LoadConfigurationFile(std::string _inFile = "$JCaPA/Utils/ConfigFile2018.xml"){
//Temporary implementation - objects will be just created within this method and loaded here.
//TODO: incorporate them in a data-member or better in a ZDC and RPD objects inheriting from a Detector class and return them
......@@ -117,11 +119,11 @@ std::vector < Channel > DataReader::LoadConfigurationFile(std::string _inFile "$
std::cout << "Loading .xml Configuration File..." << std::endl;
std::cout << "Found " << m_XMLparser->getBaseNodeCount("channel") << " channel entries " << std::endl;
std::vector < Channel > channelEntries;
std::vector < Channel* > channelEntries;
int first_run, last_run;
for (unsigned int i = 0; i < m_XMLparser->getBaseNodeCount("channel"); i++) {
Channel buffer_ch;
Channel *buffer_ch;
m_XMLparser->getChildValue("channel",i,"start_run",first_run);
m_XMLparser->getChildValue("channel",i,"end_run",last_run);
......@@ -129,15 +131,15 @@ std::vector < Channel > DataReader::LoadConfigurationFile(std::string _inFile "$
if(m_runNumber < first_run || m_runNumber > last_run) continue;
//If the entry applies, we store it in the vector
m_XMLparser->getChildValue("channel",i,"detector",buffer_ch.detector);
m_XMLparser->getChildValue("channel",i,"name",buffer_ch.name);
m_XMLparser->getChildValue("channel",i,"mapping_row",buffer_ch.mapping_row);
m_XMLparser->getChildValue("channel",i,"mapping_column",buffer_ch.mapping_column);
m_XMLparser->getChildValue("channel",i,"delay",buffer_ch.delay);
m_XMLparser->getChildValue("channel",i,"offset",buffer_ch.offset);
m_XMLparser->getChildValue("channel",i,"HV",buffer_ch.HV);
m_XMLparser->getChildValue("channel",i,"is_on",buffer_ch.is_on);
m_XMLparser->getChildValue("channel",i,"Vop",buffer_ch.Vop);
m_XMLparser->getChildValue("channel",i,"detector",buffer_ch->detector);
m_XMLparser->getChildValue("channel",i,"name",buffer_ch->name);
m_XMLparser->getChildValue("channel",i,"mapping_row",buffer_ch->mapping_row);
m_XMLparser->getChildValue("channel",i,"mapping_column",buffer_ch->mapping_column);
m_XMLparser->getChildValue("channel",i,"delay",buffer_ch->delay);
m_XMLparser->getChildValue("channel",i,"offset",buffer_ch->offset);
m_XMLparser->getChildValue("channel",i,"HV",buffer_ch->HV);
m_XMLparser->getChildValue("channel",i,"is_on",buffer_ch->is_on);
m_XMLparser->getChildValue("channel",i,"Vop",buffer_ch->Vop);
channelEntries.push_back(buffer_ch);
}
......
......@@ -5,11 +5,12 @@
* This is the mother class for detectors.
* Methods common to all detectors are implemented here.
*
* @author Chad Lantz
* @author Chad Lantz, Riccardo Longo
* @bug No known bugs.
*/
#include "Detector.h"
#include "Containers.h"
/** @brief Default Constructor for Detector.
......@@ -26,19 +27,21 @@ Detector::~Detector( ){
/** @brief Get the properties of a detector element
*
* Returns a pointer to the Channel stored in Elements with the
* Returns a pointer to the Channel stored in m_Elements with the
* requested row and column.
* If the requested element is not found, return an NULL pointer.
* If the requested element is not found, return a warning message and a NULL pointer.
*
*/
Channel* Detector::GetElement(int row, int column){
int entries=Element.size();
for(int i=0; i<entries; i++){
if(row==Element[i].mapping_row && column==Element[i].mapping_column){
return &Element[i];
for(int i=0; i < (int)m_Element.size(); i++){
if(row == m_Element[i]->mapping_row && column == m_Element[i]->mapping_column){
return m_Element[i];
}
}
std::cerr << " WARNING: Element (" << row << "," << column << ") not found! " << std::endl;
return nullptr;
}
......
......@@ -11,6 +11,8 @@
#include "RPD.h"
#include <string>
#include <stdio.h>
/** @brief Default Constructor for RPD.
*/
......@@ -18,6 +20,19 @@ RPD::RPD( ){
}
/** @brief Constructor that takes the whole vector of channels readout and selects and stores only the RPD ones
*/
RPD::RPD( std::vector < Channel* > _readOut){
for(int i = 0; i < (int)_readOut.size(); i++){
if(_readOut.at(i)->name == "RPD"){
SetElement(_readOut.at(i));
}
}
std::cout << "RPD object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
}
/** @brief Destructor for RPD.
*/
RPD::~RPD( ){
......@@ -33,33 +48,20 @@ RPD::~RPD( ){
* third line.
*
*/
void PrintMap(){
std::cout<<" _______________________________ "<<std::endl;
for(int row=1;row<=4;row++){
Channel *c[4];
c[0]=GetElement(row,1,"RPD");
c[1]=GetElement(row,2,"RPD");
c[2]=GetElement(row,3,"RPD");
c[3]=GetElement(row,4,"RPD");
std::cout<<"| "<<Form("%d,4",row);
std::cout<<" | "<<Form("%d,4",row);
std::cout<<" | "<<Form("%d,4",row);
std::cout<<" | "<<Form("%d,4",row);
std::cout<<" |"<<std::endl;
std::cout<<"| "<<*c[3]->name;
std::cout<<" | "<<*c[2]->name;
std::cout<<" | "<<*c[1]->name;
std::cout<<" | "<<*c[0]->name;
std::cout<<" |"<<std::endl;
std::cout<<"| "<<*c[3]->is_on;
std::cout<<" | "<<*c[2]->is_on;
std::cout<<" | "<<*c[1]->is_on;
std::cout<<" | "<<*c[0]->is_on;
std::cout<<" |"<<std::endl;
std::cout<<"|_______|_______|_______|_______|"<<std::endl;
}
void RPD::PrintMap(){
std::cout << " ___________________________________ " << std::endl;
//RPD has 4 rows and 4 columns
for(int row = 1; row <= 4; row++){
Channel* c[4];
std::string status, name;
for(int cln = 1; cln <= 4; cln++){
c[cln] = GetElement(row,cln);
if(c[cln]->is_on) status = "ON";
else status = "OFF";
if (cln == 1) std::cout << "| " << row << "," << cln << " --> " << c[cln]->name << " , " << status;
else std::cout << " | " << row << "," << cln << " --> " << c[cln]->name << " , " << status;
}//End of the loop over columns
}//End of the loop over rows
}
......@@ -34,7 +34,6 @@ WFAnalysis::~WFAnalysis( ){
/** @brief Initialization method for WFAnalysis
*
* Get pointer to output file.
* Can add other things here that you would
* perhaps not put into the constructor.
* I.e. a TTree, some tools. Etc.
......
......@@ -20,7 +20,6 @@ XMLSettingsReader::XMLSettingsReader( void ){
XMLPlatformUtils::Initialize();
} catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
std::cout << "Fatal error during the parser initialization! " << std::endl;
XMLString::release(&message);
}
......
......@@ -18,6 +18,19 @@ ZDC::ZDC( ){
}
ZDC::ZDC( std::vector < Channel* > _readOut, int _zdcNumber){
m_Number = _zdcNumber;
for(int i = 0; i < (int)_readOut.size(); i++){
if(_readOut.at(i)->name == "ZDC" && _readOut.at(i)->mapping_column == m_Number){
SetElement(_readOut.at(i));
}
}
if(GetChannelsVector().size() > 1) std::cout << "WARNING : more than one entry for one ZDC module. Check the config.xml" << std::endl;
std::cout << "ZDC object created with " << GetChannelsVector().size() << " channel entries " << std::endl;
}
/** @brief Destructor for ZDC.
*/
ZDC::~ZDC( ){
......@@ -33,11 +46,11 @@ ZDC::~ZDC( ){
*
*/
void ZDC::PrintMap(){
Channel *c = GetElement(0,Number);
Channel *c = GetElement(0,m_Number);
std::cout<<"| " << Number <<" |"<<std::endl;
std::cout<<"| " << m_Number <<" |"<<std::endl;
std::cout<<"| " << c->name <<" |"<<std::endl;
std::cout<<"| |"<< std::endl;
std::cout<<"|_______|"<< std::endl;
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment