Commit 8ff013f1 authored by Lennart Huth's avatar Lennart Huth
Browse files

ongoing work on MuPix

parent 497e1280
......@@ -4,12 +4,15 @@ CORRYVRECKAN_ENABLE_DEFAULT(OFF)
CORRYVRECKAN_GLOBAL_MODULE(MODULE_NAME)
FIND_PACKAGE(MUPIX8DAQ)
FIND_PACKAGE(MUPIX8DAQ REQUIRED)
find_package(Eigen3 REQUIRED)
IF(NOT MUPIX8DAQ_FOUND)
MESSAGE(FATAL_ERROR "Could not find MuPix-telescope. You need to do: \n export MUPIX8DAQ=/path/to/repo")
ENDIF()
INCLUDE_DIRECTORIES(SYSTEM ${MUPIX8DAQ_INCLUDE_DIR})
#INCLUDE_DIRECTORIES(SYSTEM ${MUPIX8DAQ_INCLUDE_DIR})
#include_directories(${EIGEN3_INCLUDE_DIR})
# Add source files to library
CORRYVRECKAN_MODULE_SOURCES(${MODULE_NAME}
......
......@@ -8,11 +8,10 @@
*/
#include "EventLoaderMuPixTelescope.h"
#include "dirent.h"
using namespace corryvreckan;
using namespace std;
// using namespace std;
EventLoaderMuPixTelescope::EventLoaderMuPixTelescope(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)), m_blockFile(nullptr) {
......@@ -20,25 +19,30 @@ EventLoaderMuPixTelescope::EventLoaderMuPixTelescope(Configuration config, std::
m_runNumber = m_config.get<int>("Run", -1); // meaningless default runnumber
m_isSorted = m_config.get<bool>("isSorted", false);
m_ts2IsGray = m_config.get<bool>("ts2IsGray", false);
m_counter = 0;
// We need to check for the config files in case of scans... TBI
}
void EventLoaderMuPixTelescope::initialise() {
int i = 0;
for(auto& detector : get_detectors()) {
LOG(DEBUG) << "Initialise for detector " + detector->name();
_sensors.push_back(new SensorHistograms(i, detector->name(), false));
i++;
}
// Need to check if the files do exist
DIR* directory = opendir(m_inputDirectory.c_str());
if(directory == nullptr) {
LOG(ERROR) << "Directory " << m_inputDirectory << " does not exist";
return;
}
// check the entries and if the correct file exists - seems to be inefficient
// check the entries and if the correct file exists continue - seems to be inefficient
dirent* entry;
bool foundFile = false;
while((entry = readdir(directory))) {
if(entry->d_name == string("telescope_run_000360.blck")) {
if(entry->d_name == string("telescope_run_001020_mergedFrames.blck")) {
foundFile = true;
break;
}
......@@ -56,13 +60,14 @@ void EventLoaderMuPixTelescope::initialise() {
return;
} else
LOG(STATUS) << "Loaded Reader";
hHitMap = new TH2F("hitMap", "hitMap", 50, -1.5, 49.5, 202, -1.5, 201.5);
hHitMap = new TH2F("hitMap", "hitMap", 50, -.5, 49.5, 202, -.5, 201.5);
hPixelToT = new TH1F("pixelToT", "pixelToT", 64, 0, 64);
hTimeStamp = new TH1F("pixelTS", "pixelTS", 1024, -.5, 1023.5);
hPixelToT->GetXaxis()->SetTitle("ToT in TS2 clock cycles.");
hPixelToA = new TH1F("pixelToA", "pixelToA", 100, 0, 100);
hPixelsPerFrame = new TH1F("pixelsPerFrame", "pixelsPerFrame", 200, 0, 200);
hPixelsOverTime = new TH1F("pixelsOverTime", "pixelsOverTime", 2e6, 0, 2e6);
// hPixelToA = new TH1F("pixelToA", "pixelToA", 100, 0, 100);
// hPixelsPerFrame = new TH1F("pixelsPerFrame", "pixelsPerFrame", 200, 0, 200);
// hPixelsOverTime = new TH1F("pixelsOverTime", "pixelsOverTime", 2e6, 0, 2e6);
}
StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard> clipboard) {
......@@ -83,17 +88,24 @@ StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard> clipboard)
if(!m_blockFile->read_next(tf))
return StatusCode::EndRun;
else {
m_counter += 500;
LOG(DEBUG) << "Found " << tf.num_hits() << " in event " << m_eventNumber;
for(uint i = 0; i < tf.num_hits(); ++i) {
RawHit h = tf.get_hit(i);
if(h.tag() == 0x4)
h = tf.get_hit(i, 66);
Pixel* p = new Pixel(detectors.at(h.tag() / 4), h.row(), h.column(), 1, 0, true);
p->setTimestamp(static_cast<double>(h.timestamp_raw()));
p->setTimestamp(static_cast<double>(m_counter)); // tf.timestamp()));//8*static_cast<double>(((tf.timestamp()>>2)
// & 0xFFFFF700)+h.timestamp_raw()));
// p->setTimestamp(static_cast<double>(h.timestamp_raw()));
p->setToT(0); // int(h.get_tot_ns(0,8)));
if(!dataContainers.count(detectors.at(h.tag() / 4)))
dataContainers[detectors.at(h.tag() / 4)] = new Objects();
dataContainers.at(detectors.at(h.tag() / 4))->push_back(p);
hHitMap->Fill(h.column(), h.row());
hTimeStamp->Fill(h.timestamp_raw());
_sensors.at(h.tag() / 4)->Fill({h.column()}, {h.row()});
}
}
......@@ -115,5 +127,6 @@ StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard> clipboard)
void EventLoaderMuPixTelescope::finalise() {
_sensors.at(0)->Write();
LOG(DEBUG) << "Analysed " << m_eventNumber << " events";
}
......@@ -16,11 +16,13 @@
#include <TH2F.h>
#include <iostream>
#include "core/module/Module.hpp"
#include "library/blockfile.hpp"
#include "library/telescope_frame.hpp"
#include "objects/Cluster.hpp"
#include "objects/Pixel.hpp"
#include "objects/Track.hpp"
#include "blockfile.hpp"
#include "monitor_histograms.hpp"
//#include "objects/Cluster.hpp"
//#include "objects/Pixel.hpp"
//#include "objects/Track.hpp"
namespace corryvreckan {
/** @ingroup Modules
......@@ -59,15 +61,18 @@ namespace corryvreckan {
bool m_isSorted;
bool m_ts2IsGray;
int m_runNumber;
int m_counter;
BlockFile* m_blockFile;
TelescopeFrame m_tf;
// Histograms
vector<mudaq::SensorHistograms*> _sensors;
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hPixelToA;
TH1F* hPixelsPerFrame;
TH1F* hPixelsOverTime;
// TH1F* hPixelToA;
// TH1F* hPixelsPerFrame;
// TH1F* hPixelsOverTime;
TH1F* hTimeStamp;
};
} // namespace corryvreckan
Markdown is supported
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