Commit 43870504 authored by Lennart Huth's avatar Lennart Huth Committed by Lennart Huth
Browse files

added several debug histograms, changed variable names to match config files,...

added several debug histograms, changed variable names to match  config files, several layers can be read now
parent f63939e7
......@@ -16,7 +16,7 @@ using namespace std;
EventLoaderMuPixTelescope::EventLoaderMuPixTelescope(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)), m_blockFile(nullptr) {
m_filePath = m_config.getPath("input_directory");
m_inputDirectory = m_config.getPath("input_directory");
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);
......@@ -29,16 +29,16 @@ void EventLoaderMuPixTelescope::initialise() {
LOG(DEBUG) << "Initialise for detector " + detector->name();
}
// Need to check if the files do exist
DIR* directory = opendir(m_filePath.c_str());
DIR* directory = opendir(m_inputDirectory.c_str());
if(directory == nullptr) {
LOG(ERROR) << "Directory " << m_filePath << " does not exist";
LOG(ERROR) << "Directory " << m_inputDirectory << " does not exist";
return;
}
// check the entries and if the correct file exists - seems to be inefficient
dirent* entry;
bool foundFile = false;
while((entry = readdir(directory))) {
if(entry->d_name == string("telescope_run_000115.blck")) {
if(entry->d_name == string("telescope_run_000360.blck")) {
foundFile = true;
break;
}
......@@ -46,15 +46,26 @@ void EventLoaderMuPixTelescope::initialise() {
if(!foundFile) {
LOG(ERROR) << "Requested run not existing ";
return;
}
BlockFile bf("bf.blck");
bf.open_read();
// m_blockFile = new BlockFile(to_string(m_filePath+"/"+entry->d_name));
// Initialise member variables
m_eventNumber = 0;
} else
LOG(INFO) << "File found" << endl;
string file = (m_inputDirectory + "/" + entry->d_name);
LOG(INFO) << "reading " << file;
m_blockFile = new BlockFile(file);
if(!m_blockFile->open_read()) {
LOG(ERROR) << "File cannot be read" << endl;
return;
} else
LOG(STATUS) << "Loaded Reader";
hHitMap = new TH2F("hitMap", "hitMap", 50, -1.5, 49.5, 202, -1.5, 201.5);
hPixelToT = new TH1F("pixelToT", "pixelToT", 64, 0, 64);
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);
}
StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard>) {
StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard> clipboard) {
// Loop over all detectors
for(auto& detector : get_detectors()) {
......@@ -62,10 +73,42 @@ StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard>) {
std::string detectorName = detector->name();
LOG(DEBUG) << "Detector with name " << detectorName;
}
map<string, Objects*> dataContainers;
vector<string> detectors;
detectors.push_back("detector0");
detectors.push_back("detector1");
detectors.push_back("detector2");
detectors.push_back("detector3");
TelescopeFrame tf;
if(!m_blockFile->read_next(tf))
return StatusCode::EndRun;
else {
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);
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->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());
}
}
for(auto d : detectors) {
if(!dataContainers.count(d))
continue;
try {
clipboard->put(d, "pixels", dataContainers[d]);
} catch(ModuleError& e) {
LOG(WARNING) << "Unknown detector ";
}
}
// Increment event counter
m_eventNumber++;
LOG(DEBUG) << "Frame with " << tf.num_hits();
// Return value telling analysis to keep running
return StatusCode::Success;
}
......
......@@ -55,12 +55,19 @@ namespace corryvreckan {
private:
int m_eventNumber;
std::string m_filePath;
std::string m_inputDirectory;
bool m_isSorted;
bool m_ts2IsGray;
int m_runNumber;
BlockFile* m_blockFile;
TelescopeFrame m_tf;
// Histograms
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hPixelToA;
TH1F* hPixelsPerFrame;
TH1F* hPixelsOverTime;
};
} // 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