Commit ed760bf7 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Run make-format

parent 4e4a913a
This diff is collapsed.
......@@ -2,8 +2,8 @@
#define ALIGNMENT_H 1
// ROOT includes
#include "Minuit2/Minuit2Minimizer.h"
#include "Math/Functor.h"
#include "Minuit2/Minuit2Minimizer.h"
#include "TError.h"
// Local includes
#include "core/Algorithm.h"
......@@ -11,23 +11,22 @@
#include "objects/Track.h"
namespace corryvreckan {
class Alignment : public Algorithm {
public:
// Constructors and destructors
Alignment(Configuration config, Clipboard* clipboard);
~Alignment(){}
class Alignment : public Algorithm {
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
public:
// Constructors and destructors
Alignment(Configuration config, Clipboard* clipboard);
~Alignment() {}
// Member variables
Tracks m_alignmenttracks;
int nIterations;
int m_numberOfTracksForAlignment;
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
};
// Member variables
Tracks m_alignmenttracks;
int nIterations;
int m_numberOfTracksForAlignment;
};
}
#endif // ALIGNMENT_H
This diff is collapsed.
#ifndef BASICTRACKING_H
#define BASICTRACKING_H 1
#include "core/Algorithm.h"
#include <iostream>
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "objects/Pixel.h"
#include "core/Algorithm.h"
#include "objects/Cluster.h"
#include "objects/Pixel.h"
#include "objects/Track.h"
namespace corryvreckan {
class BasicTracking : public Algorithm {
public:
// Constructors and destructors
BasicTracking(Configuration config, Clipboard* clipboard);
~BasicTracking(){}
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
// Cluster* getNearestCluster(Cluster*, map<Cluster*, bool>, Clusters*);
Cluster* getNearestCluster(long long int, Clusters);
// Member variables
// Histograms
TH1F* trackChi2;
TH1F* clustersPerTrack;
TH1F* trackChi2ndof;
TH1F* tracksPerEvent;
TH1F* trackAngleX;
TH1F* trackAngleY;
map<string,TH1F*> residualsX;
map<string,TH1F*> residualsY;
// Cuts for tracking
double timingCut;
double spatialCut;
int minHitsOnTrack;
double nTracksTotal;
};
class BasicTracking : public Algorithm {
public:
// Constructors and destructors
BasicTracking(Configuration config, Clipboard* clipboard);
~BasicTracking() {}
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
// Cluster* getNearestCluster(Cluster*, map<Cluster*, bool>, Clusters*);
Cluster* getNearestCluster(long long int, Clusters);
// Member variables
// Histograms
TH1F* trackChi2;
TH1F* clustersPerTrack;
TH1F* trackChi2ndof;
TH1F* tracksPerEvent;
TH1F* trackAngleX;
TH1F* trackAngleY;
map<string, TH1F*> residualsX;
map<string, TH1F*> residualsY;
// Cuts for tracking
double timingCut;
double spatialCut;
int minHitsOnTrack;
double nTracksTotal;
};
}
#endif // BASICTRACKING_H
......@@ -3,135 +3,142 @@
using namespace corryvreckan;
CLICpixEventLoader::CLICpixEventLoader(Configuration config, Clipboard* clipboard)
: Algorithm(std::move(config), clipboard){
m_filename = "";
: Algorithm(std::move(config), clipboard) {
m_filename = "";
}
void CLICpixEventLoader::initialise(Parameters* par) {
void CLICpixEventLoader::initialise(Parameters* par){
parameters = par;
parameters = par;
// File structure is RunX/CLICpix/RunX.dat
// File structure is RunX/CLICpix/RunX.dat
// Take input directory from global parameters
string inputDirectory = parameters->inputDirectory + "/CLICpix";
// Take input directory from global parameters
string inputDirectory = parameters->inputDirectory + "/CLICpix";
// Open the root directory
DIR* directory = opendir(inputDirectory.c_str());
if (directory == NULL){LOG(ERROR)<<"Directory "<<inputDirectory<<" does not exist"; return;}
dirent* entry; dirent* file;
// Read the entries in the folder
while (entry = readdir(directory)){
// Check for the data file
string filename = inputDirectory + "/" + entry->d_name;
if(filename.find(".dat") != string::npos){
m_filename = filename;
// Open the root directory
DIR* directory = opendir(inputDirectory.c_str());
if(directory == NULL) {
LOG(ERROR) << "Directory " << inputDirectory << " does not exist";
return;
}
dirent* entry;
dirent* file;
// Read the entries in the folder
while(entry = readdir(directory)) {
// Check for the data file
string filename = inputDirectory + "/" + entry->d_name;
if(filename.find(".dat") != string::npos) {
m_filename = filename;
}
}
}
// If no data was loaded, give a warning
if(m_filename.length() == 0) LOG(WARNING) <<"No data file was found for CLICpix in "<<inputDirectory;
// If no data was loaded, give a warning
if(m_filename.length() == 0)
LOG(WARNING) << "No data file was found for CLICpix in " << inputDirectory;
// Open the data file for later
m_file.open(m_filename.c_str());
// Open the data file for later
m_file.open(m_filename.c_str());
// Make histograms for debugging
hHitMap = new TH2F("hitMap","hitMap",64,0,64,64,0,64);
hPixelToT = new TH1F("pixelToT","pixelToT",20,0,20);
hShutterLength = new TH1F("shutterLength","shutterLength",3000,0,0.3);
hPixelsPerFrame = new TH1F("pixelsPerFrame","pixelsPerFrame",4100,0,4100);
// Make histograms for debugging
hHitMap = new TH2F("hitMap", "hitMap", 64, 0, 64, 64, 0, 64);
hPixelToT = new TH1F("pixelToT", "pixelToT", 20, 0, 20);
hShutterLength = new TH1F("shutterLength", "shutterLength", 3000, 0, 0.3);
hPixelsPerFrame = new TH1F("pixelsPerFrame", "pixelsPerFrame", 4100, 0, 4100);
}
StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
StatusCode CLICpixEventLoader::run(Clipboard* clipboard){
// LOG(TRACE) <<"Running";
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = parameters->DUT;
// If have reached the end of file, close it and exit program running
if(m_file.eof()){
m_file.close();
return Failure;
}
// Otherwise load a new frame
// LOG(TRACE) <<"Running";
// Assume that the CLICpix is the DUT (if running this algorithm
string detectorID = parameters->DUT;
// Pixel container, shutter information
Pixels* pixels = new Pixels();
long double shutterStartTime, shutterStopTime;
string data;
// If have reached the end of file, close it and exit program running
if(m_file.eof()) {
m_file.close();
return Failure;
}
int npixels=0;
// Read file and load data
while(getline(m_file,data)){
// Otherwise load a new frame
// Pixel container, shutter information
Pixels* pixels = new Pixels();
long double shutterStartTime, shutterStopTime;
string data;
int npixels = 0;
// Read file and load data
while(getline(m_file, data)) {
// LOG(TRACE) <<"Data: "<<data;
// If line is empty then we have finished this event, stop looping
if(data.length() < 5)
break;
// Check if this is a header/shutter/power info
if(data.find("PWR_RISE") != string::npos || data.find("PWR_FALL") != string::npos)
continue;
if(data.find("SHT_RISE") != string::npos) {
// Read the shutter start time
long int timeInt;
string name;
istringstream header(data);
header >> name >> timeInt;
shutterStartTime = (double)timeInt / (40000000.);
LOG(TRACE) << "Shutter rise time: " << shutterStartTime;
continue;
}
if(data.find("SHT_FALL") != string::npos) {
// Read the shutter stop time
long int timeInt;
string name;
istringstream header(data);
header >> name >> timeInt;
shutterStopTime = (double)timeInt / (40000000.);
LOG(TRACE) << "Shutter fall time: " << shutterStopTime;
continue;
}
// Otherwise load data
int row, col, counter, tot(0);
long int time;
LOG(TRACE) << "Pixel data: " << data;
istringstream pixelData(data);
pixelData >> col >> row >> counter >> tot;
tot++;
row = 63 - row;
LOG(TRACE) << "New pixel: " << col << "," << row << " with tot " << tot;
// If this pixel is masked, do not save it
if(parameters->detector[detectorID]->masked(col, row))
continue;
Pixel* pixel = new Pixel(detectorID, row, col, tot, 0);
pixels->push_back(pixel);
npixels++;
hHitMap->Fill(col, row);
hPixelToT->Fill(tot);
}
// LOG(TRACE) <<"Data: "<<data;
// Now set the event time so that the Timepix3 data is loaded correctly
parameters->currentTime = shutterStartTime;
parameters->eventLength = (shutterStopTime - shutterStartTime);
// If line is empty then we have finished this event, stop looping
if(data.length() < 5) break;
LOG(TRACE) << "Loaded " << npixels << " pixels";
// Put the data on the clipboard
if(pixels->size() > 0)
clipboard->put(detectorID, "pixels", (TestBeamObjects*)pixels);
// Check if this is a header/shutter/power info
if(data.find("PWR_RISE") != string::npos || data.find("PWR_FALL") != string::npos) continue;
if(data.find("SHT_RISE") != string::npos){
// Read the shutter start time
long int timeInt; string name;
istringstream header(data);
header >> name >> timeInt;
shutterStartTime = (double)timeInt/(40000000.);
LOG(TRACE) <<"Shutter rise time: "<<shutterStartTime;
continue;
}
if(data.find("SHT_FALL") != string::npos){
// Read the shutter stop time
long int timeInt; string name;
istringstream header(data);
header >> name >> timeInt;
shutterStopTime = (double)timeInt/(40000000.);
LOG(TRACE) <<"Shutter fall time: "<<shutterStopTime;
continue;
}
// Fill histograms
hPixelsPerFrame->Fill(npixels);
hShutterLength->Fill(shutterStopTime - shutterStartTime);
// Otherwise load data
int row, col, counter, tot(0);
long int time;
LOG(TRACE) <<"Pixel data: "<<data;
istringstream pixelData(data);
pixelData >> col >> row >> counter >> tot;
tot++;
row=63-row;
LOG(TRACE) <<"New pixel: "<<col<<","<<row<<" with tot "<<tot;
// If this pixel is masked, do not save it
if(parameters->detector[detectorID]->masked(col,row)) continue;
Pixel* pixel = new Pixel(detectorID,row,col,tot,0);
pixels->push_back(pixel);
npixels++;
hHitMap->Fill(col,row);
hPixelToT->Fill(tot);
}
// Now set the event time so that the Timepix3 data is loaded correctly
parameters->currentTime = shutterStartTime;
parameters->eventLength = (shutterStopTime-shutterStartTime);
LOG(TRACE) <<"Loaded "<<npixels<<" pixels";
// Put the data on the clipboard
if(pixels->size() > 0) clipboard->put(detectorID,"pixels",(TestBeamObjects*)pixels);
// Fill histograms
hPixelsPerFrame->Fill(npixels);
hShutterLength->Fill(shutterStopTime-shutterStartTime);
// Return value telling analysis to keep running
return Success;
// Return value telling analysis to keep running
return Success;
}
void CLICpixEventLoader::finalise(){
LOG(DEBUG) <<"Analysed "<<m_eventNumber<<" events";
void CLICpixEventLoader::finalise() {
LOG(DEBUG) << "Analysed " << m_eventNumber << " events";
}
#ifndef CLICpixEventLoader_H
#define CLICpixEventLoader_H 1
#include "core/Algorithm.h"
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "objects/Pixel.h"
#include "core/Algorithm.h"
#include "objects/Cluster.h"
#include "objects/Pixel.h"
#include "objects/Track.h"
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <dirent.h>
namespace corryvreckan {
class CLICpixEventLoader : public Algorithm {
public:
// Constructors and destructors
CLICpixEventLoader(Configuration config, Clipboard* clipboard);
~CLICpixEventLoader(){}
class CLICpixEventLoader : public Algorithm {
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
public:
// Constructors and destructors
CLICpixEventLoader(Configuration config, Clipboard* clipboard);
~CLICpixEventLoader() {}
// Member variables
int m_eventNumber;
string m_filename;
ifstream m_file;
// Functions
void initialise(Parameters*);
StatusCode run(Clipboard*);
void finalise();
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hShutterLength;
TH1F* hPixelsPerFrame;
// Member variables
int m_eventNumber;
string m_filename;
ifstream m_file;
};
TH2F* hHitMap;
TH1F* hPixelToT;
TH1F* hShutterLength;
TH1F* hPixelsPerFrame;
};
}
#endif // CLICpixEventLoader_H
......@@ -3,127 +3,125 @@
using namespace corryvreckan;
Clicpix2Correlator::Clicpix2Correlator(Configuration config, Clipboard* clipboard)
: Algorithm(std::move(config), clipboard){}
: Algorithm(std::move(config), clipboard) {}
template <typename T>
std::string makeString(T number) {
std::ostringstream ss;
ss << number;
return ss.str();
template <typename T> std::string makeString(T number) {
std::ostringstream ss;
ss << number;
return ss.str();
}
void Clicpix2Correlator::initialise(Parameters* par){
void Clicpix2Correlator::initialise(Parameters* par) {
parameters = par;
parameters = par;
// Get the DUT ID
dutID = parameters->DUT;
// Get the DUT ID
dutID = parameters->DUT;
// Initialise histograms
hTrackDiffX["standard"] = new TH1F("hTrackDiffX_standard","hTrackDiffX_standard",4000,-20,20);
hTrackDiffY["standard"] = new TH1F("hTrackDiffY_standard","hTrackDiffY_standard",4000,-20,20);
// Initialise histograms
hTrackDiffX["standard"] = new TH1F("hTrackDiffX_standard", "hTrackDiffX_standard", 4000, -20, 20);
hTrackDiffY["standard"] = new TH1F("hTrackDiffY_standard", "hTrackDiffY_standard", 4000, -20, 20);
hTrackDiffX["prevEvent"] = new TH1F("hTrackDiffX_prevEvent","hTrackDiffX_prevEvent",4000,-20,20);
hTrackDiffY["prevEvent"] = new TH1F("hTrackDiffY_prevEvent","hTrackDiffY_prevEvent",4000,-20,20);
hTrackDiffX["prevEvent"] = new TH1F("hTrackDiffX_prevEvent", "hTrackDiffX_prevEvent", 4000, -20, 20);
hTrackDiffY["prevEvent"] = new TH1F("hTrackDiffY_prevEvent", "hTrackDiffY_prevEvent", 4000, -20, 20);
// Rotatation histograms
angleStart = 0;
angleStep = 0.6;
angleStop = 2.*M_PI;
for(double angle=angleStart;angle<angleStop;angle+=angleStep){
string name = "rotated" + makeString(angle);
string histo = "hTrackDiffX_" + name;
hTrackDiffX[name] = new TH1F(histo.c_str(),histo.c_str(),4000,-20,20);
}
// Rotatation histograms
angleStart = 0;
angleStep = 0.6;
angleStop = 2. * M_PI;
for(double angle = angleStart; angle < angleStop; angle += angleStep) {
string name = "rotated" + makeString(angle);
string histo = "hTrackDiffX_" + name;
hTrackDiffX[name] = new TH1F(histo.c_str(), histo.c_str(), 4000, -20, 20);
}
// Initialise member variables
m_eventNumber = 0;
// Initialise member variables
m_eventNumber = 0;
}
StatusCode Clicpix2Correlator::run(Clipboard* clipboard){
StatusCode Clicpix2Correlator::run(Clipboard* clipboard) {
// Get the clicpix clusters in this event
Clusters* clusters = (Clusters*)clipboard->get(dutID,"clusters");
if(clusters == NULL){
LOG(DEBUG) <<"No clusters for "<<dutID<<" on the clipboard";
m_eventNumber++;
return Success;
}
// Get the clicpix clusters in this event
Clusters* clusters = (Clusters*)clipboard->get(dutID, "clusters");
if(clusters == NULL) {
LOG(DEBUG) << "No clusters for " << dutID << " on the clipboard";
m_eventNumber++;
return Success;
}
// Get the tracks
Tracks* tracks = (Tracks*)clipboard->get("tracks");
if(tracks == NULL) {
m_eventNumber++;
return Success;
}
// Make local copies of these objects
for(int iTrack = 0; iTrack < tracks->size(); iTrack++) {
Track* track = (*tracks)[iTrack];
Track* storageTrack = new Track(track);
m_eventTracks[m_eventNumber].push_back(storageTrack);
}
for(int iCluster = 0; iCluster < clusters->size(); iCluster++) {
Cluster* cluster = (*clusters)[iCluster];
Cluster* storageCluster = new Cluster(cluster);
m_eventClusters[m_eventNumber].push_back(storageCluster);
}
// Get the tracks
Tracks* tracks = (Tracks*)clipboard->get("tracks");
if(tracks == NULL){
// Increment event counter
m_eventNumber++;
// Return value telling analysis to keep running
return Success;
}
// Make local copies of these objects
for(int iTrack=0; iTrack<tracks->size(); iTrack++){
Track* track = (*tracks)[iTrack];
Track* storageTrack = new Track(track);
m_eventTracks[m_eventNumber].push_back(storageTrack);
}
for(int iCluster=0; iCluster<clusters->size(); iCluster++){
Cluster* cluster = (*clusters)[iCluster];
Cluster* storageCluster = new Cluster(cluster);
m_eventClusters[m_eventNumber].push_back(storageCluster);
}
// Increment event counter
m_eventNumber++;
// Return value telling analysis to keep running
return Success;
}
void Clicpix2Correlator::finalise(){
LOG(DEBUG) <<"Analysed "<<m_eventNumber<<" events";
void Clicpix2Correlator::finalise() {
// Now make all of the correlations. For each event loop over the clusters
// and tracks and make correlations between the two