mv armory to Armory
This commit is contained in:
parent
1d914f2f0e
commit
749657c0af
|
@ -1,296 +0,0 @@
|
||||||
#ifndef ANALYSIS_LIB_H
|
|
||||||
#define ANALYSIS_LIB_H
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <vector>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <TMacro.h>
|
|
||||||
#include <TList.h>
|
|
||||||
#include <TFile.h>
|
|
||||||
#include <TMath.h>
|
|
||||||
#include <TObjArray.h>
|
|
||||||
#include <TCutG.h>
|
|
||||||
|
|
||||||
namespace AnalysisLib {
|
|
||||||
|
|
||||||
std::vector<std::string> SplitStr(std::string tempLine, std::string splitter, int shift = 0){
|
|
||||||
|
|
||||||
std::vector<std::string> output;
|
|
||||||
|
|
||||||
size_t pos;
|
|
||||||
do{
|
|
||||||
pos = tempLine.find(splitter); /// fine splitter
|
|
||||||
if( pos == 0 ){ ///check if it is splitter again
|
|
||||||
tempLine = tempLine.substr(pos+1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string secStr;
|
|
||||||
if( pos == std::string::npos ){
|
|
||||||
secStr = tempLine;
|
|
||||||
}else{
|
|
||||||
secStr = tempLine.substr(0, pos+shift);
|
|
||||||
tempLine = tempLine.substr(pos+shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
///check if secStr is begin with space
|
|
||||||
while( secStr.substr(0, 1) == " ") secStr = secStr.substr(1);
|
|
||||||
|
|
||||||
///check if secStr is end with space
|
|
||||||
while( secStr.back() == ' ') secStr = secStr.substr(0, secStr.size()-1);
|
|
||||||
|
|
||||||
output.push_back(secStr);
|
|
||||||
///printf(" |%s---\n", secStr.c_str());
|
|
||||||
|
|
||||||
}while(pos != std::string::npos );
|
|
||||||
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//************************************** TCutG
|
|
||||||
|
|
||||||
TObjArray * LoadListOfTCut(TString fileName, TString cutName = "cutList"){
|
|
||||||
|
|
||||||
if( fileName == "" ) return nullptr;
|
|
||||||
|
|
||||||
TObjArray * cutList = nullptr;
|
|
||||||
|
|
||||||
TFile * fCut = new TFile(fileName);
|
|
||||||
bool isCutFileOpen = fCut->IsOpen();
|
|
||||||
if(!isCutFileOpen) {
|
|
||||||
printf( "Failed to open rdt-cutfile 1 : %s\n" , fileName.Data());
|
|
||||||
}else{
|
|
||||||
cutList = (TObjArray *) fCut->FindObjectAny(cutName);
|
|
||||||
|
|
||||||
if( cutList ){
|
|
||||||
int numCut = cutList->GetEntries();
|
|
||||||
printf("=========== found %d cutG in %s \n", numCut, fCut->GetName());
|
|
||||||
|
|
||||||
for(int i = 0; i < numCut ; i++){
|
|
||||||
printf("cut name : %s , VarX: %s, VarY: %s, numPoints: %d \n",
|
|
||||||
cutList->At(i)->GetName(),
|
|
||||||
((TCutG*)cutList->At(i))->GetVarX(),
|
|
||||||
((TCutG*)cutList->At(i))->GetVarY(),
|
|
||||||
((TCutG*)cutList->At(i))->GetN()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cutList;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCutG * LoadSingleTCut( TString fileName, TString cutName = "cutEZ"){
|
|
||||||
|
|
||||||
if( fileName == "" ) return nullptr;
|
|
||||||
TCutG * cut = nullptr;
|
|
||||||
|
|
||||||
TFile * fCut = new TFile(fileName);
|
|
||||||
bool isCutFileOpen = fCut->IsOpen();
|
|
||||||
if( !isCutFileOpen) {
|
|
||||||
printf( "Failed to open E-Z cutfile : %s\n" , fileName.Data());
|
|
||||||
}else{
|
|
||||||
cut = (TCutG *) fCut->FindObjectAny(cutName);
|
|
||||||
if( cut != NULL ) {
|
|
||||||
printf("Found EZ cut| name : %s, VarX: %s, VarY: %s, numPoints: %d \n",
|
|
||||||
cut->GetName(),
|
|
||||||
cut->GetVarX(),
|
|
||||||
cut->GetVarY(),
|
|
||||||
cut->GetN()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cut;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//************************************** Others
|
|
||||||
std::vector<std::vector<double>> combination(std::vector<double> arr, int r){
|
|
||||||
|
|
||||||
std::vector<std::vector<double>> output;
|
|
||||||
|
|
||||||
int n = arr.size();
|
|
||||||
std::vector<int> v(n);
|
|
||||||
std::fill(v.begin(), v.begin()+r, 1);
|
|
||||||
do {
|
|
||||||
//for( int i = 0; i < n; i++) { printf("%d ", v[i]); }; printf("\n");
|
|
||||||
|
|
||||||
std::vector<double> temp;
|
|
||||||
for (int i = 0; i < n; ++i) {
|
|
||||||
if (v[i]) {
|
|
||||||
//printf("%.1f, ", arr[i]);
|
|
||||||
temp.push_back(arr[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//printf("\n");
|
|
||||||
|
|
||||||
output.push_back(temp);
|
|
||||||
|
|
||||||
} while (std::prev_permutation(v.begin(), v.end()));
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
double* sumMeanVar(std::vector<double> data){
|
|
||||||
|
|
||||||
int n = data.size();
|
|
||||||
double sum = 0;
|
|
||||||
for( int k = 0; k < n; k++) sum += data[k];
|
|
||||||
double mean = sum/n;
|
|
||||||
double var = 0;
|
|
||||||
for( int k = 0; k < n; k++) var += pow(data[k] - mean,2);
|
|
||||||
|
|
||||||
static double output[3];
|
|
||||||
output[0] = sum;
|
|
||||||
output[1] = mean;
|
|
||||||
output[2] = var;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
double* fitSlopeIntercept(std::vector<double> dataX, std::vector<double> dataY){
|
|
||||||
|
|
||||||
double * smvY = sumMeanVar(dataY);
|
|
||||||
double sumY = smvY[0];
|
|
||||||
double meanY = smvY[1];
|
|
||||||
|
|
||||||
double * smvX = sumMeanVar(dataX);
|
|
||||||
double sumX = smvX[0];
|
|
||||||
double meanX = smvX[1];
|
|
||||||
double varX = smvX[2];
|
|
||||||
|
|
||||||
int n = dataX.size();
|
|
||||||
double sumXY = 0;
|
|
||||||
for( int j = 0; j < n; j++) sumXY += dataX[j] * dataY[j];
|
|
||||||
|
|
||||||
double slope = ( sumXY - sumX * sumY/n ) / varX;
|
|
||||||
double intercept = meanY - slope * meanX;
|
|
||||||
|
|
||||||
static double output[2];
|
|
||||||
output[0] = slope;
|
|
||||||
output[1] = intercept;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::vector<double>> FindMatchingPair(std::vector<double> enX, std::vector<double> enY){
|
|
||||||
|
|
||||||
//output[0] = fitEnergy;
|
|
||||||
//output[1] = refEnergy;
|
|
||||||
|
|
||||||
int nX = enX.size();
|
|
||||||
int nY = enY.size();
|
|
||||||
|
|
||||||
std::vector<double> fitEnergy;
|
|
||||||
std::vector<double> refEnergy;
|
|
||||||
|
|
||||||
if( nX > nY ){
|
|
||||||
|
|
||||||
std::vector<std::vector<double>> output = combination(enX, nY);
|
|
||||||
|
|
||||||
double * smvY = sumMeanVar(enY);
|
|
||||||
double sumY = smvY[0];
|
|
||||||
double meanY = smvY[1];
|
|
||||||
double varY = smvY[2];
|
|
||||||
|
|
||||||
double optRSquared = 0;
|
|
||||||
double absRSqMinusOne = 1;
|
|
||||||
int maxID = 0;
|
|
||||||
|
|
||||||
for( int k = 0; k < (int) output.size(); k++){
|
|
||||||
|
|
||||||
double * smvX = sumMeanVar(output[k]);
|
|
||||||
double sumX = smvX[0];
|
|
||||||
double meanX = smvX[1];
|
|
||||||
double varX = smvX[2];
|
|
||||||
|
|
||||||
double sumXY = 0;
|
|
||||||
for( int j = 0; j < nY; j++) sumXY += output[k][j] * enY[j];
|
|
||||||
|
|
||||||
double rSq = abs(sumXY - sumX*sumY/nY)/sqrt(varX*varY);
|
|
||||||
|
|
||||||
//for( int j = 0; j < nY ; j++){ printf("%.1f, ", output[k][j]); }; printf("| %.10f\n", rSq);
|
|
||||||
|
|
||||||
if( abs(rSq-1) < absRSqMinusOne ) {
|
|
||||||
absRSqMinusOne = abs(rSq-1);
|
|
||||||
optRSquared = rSq;
|
|
||||||
maxID = k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fitEnergy = output[maxID];
|
|
||||||
refEnergy = enY;
|
|
||||||
|
|
||||||
printf(" R^2 : %.20f\n", optRSquared);
|
|
||||||
|
|
||||||
//calculation fitting coefficient
|
|
||||||
//double * si = fitSlopeIntercept(fitEnergy, refEnergy);
|
|
||||||
//printf( " y = %.4f x + %.4f\n", si[0], si[1]);
|
|
||||||
|
|
||||||
}else if( nX < nY ){
|
|
||||||
|
|
||||||
std::vector<std::vector<double>> output = combination(enY, nX);
|
|
||||||
|
|
||||||
|
|
||||||
double * smvX = sumMeanVar(enX);
|
|
||||||
double sumX = smvX[0];
|
|
||||||
double meanX = smvX[1];
|
|
||||||
double varX = smvX[2];
|
|
||||||
|
|
||||||
double optRSquared = 0;
|
|
||||||
double absRSqMinusOne = 1;
|
|
||||||
int maxID = 0;
|
|
||||||
|
|
||||||
for( int k = 0; k < (int) output.size(); k++){
|
|
||||||
|
|
||||||
double * smvY = sumMeanVar(output[k]);
|
|
||||||
double sumY = smvY[0];
|
|
||||||
double meanY = smvY[1];
|
|
||||||
double varY = smvY[2];
|
|
||||||
|
|
||||||
double sumXY = 0;
|
|
||||||
for( int j = 0; j < nX; j++) sumXY += output[k][j] * enX[j];
|
|
||||||
|
|
||||||
double rSq = abs(sumXY - sumX*sumY/nX)/sqrt(varX*varY);
|
|
||||||
|
|
||||||
//for( int j = 0; j < nX ; j++){ printf("%.1f, ", output[k][j]); }; printf("| %.10f\n", rSq);
|
|
||||||
|
|
||||||
if( abs(rSq-1) < absRSqMinusOne ) {
|
|
||||||
absRSqMinusOne = abs(rSq-1);
|
|
||||||
optRSquared = rSq;
|
|
||||||
maxID = k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fitEnergy = enX;
|
|
||||||
refEnergy = output[maxID];
|
|
||||||
printf(" R^2 : %.20f\n", optRSquared);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
fitEnergy = enX;
|
|
||||||
refEnergy = enY;
|
|
||||||
|
|
||||||
//if nX == nY, ther could be cases that only partial enX and enY are matched.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("fitEnergy = ");for( int k = 0; k < (int) fitEnergy.size() ; k++){ printf("%7.2f, ", fitEnergy[k]); }; printf("\n");
|
|
||||||
printf("refEnergy = ");for( int k = 0; k < (int) refEnergy.size() ; k++){ printf("%7.2f, ", refEnergy[k]); }; printf("\n");
|
|
||||||
|
|
||||||
std::vector<std::vector<double>> haha;
|
|
||||||
haha.push_back(fitEnergy);
|
|
||||||
haha.push_back(refEnergy);
|
|
||||||
|
|
||||||
return haha;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
2861
armory/AutoFit.C
2861
armory/AutoFit.C
File diff suppressed because it is too large
Load Diff
|
@ -1,351 +0,0 @@
|
||||||
#include "SolReader.h"
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "TFile.h"
|
|
||||||
#include "TTree.h"
|
|
||||||
#include "TMath.h"
|
|
||||||
#include "TString.h"
|
|
||||||
#include "TMacro.h"
|
|
||||||
//#include "TClonesArray.h" // plan to save trace as TVector with TClonesArray
|
|
||||||
//#include "TVector.h"
|
|
||||||
|
|
||||||
#define MAX_MULTI 64
|
|
||||||
#define MAX_TRACE_LEN 2500
|
|
||||||
|
|
||||||
#define tick2ns 8 // 1 tick = 8 ns
|
|
||||||
|
|
||||||
SolReader ** reader;
|
|
||||||
Hit ** hit;
|
|
||||||
|
|
||||||
std::vector<std::vector<int>> idList;
|
|
||||||
|
|
||||||
unsigned long totFileSize = 0;
|
|
||||||
unsigned long processedFileSize = 0;
|
|
||||||
|
|
||||||
std::vector<int> activeFileID;
|
|
||||||
std::vector<int> groupIndex;
|
|
||||||
std::vector<std::vector<int>> group; // group[i][j], i = group ID, j = group member)
|
|
||||||
|
|
||||||
void findEarliestTime(int &fileID, int &groupID){
|
|
||||||
|
|
||||||
unsigned long firstTime = 0;
|
|
||||||
for( int i = 0; i < (int) activeFileID.size(); i++){
|
|
||||||
int id = activeFileID[i];
|
|
||||||
if( i == 0 ) {
|
|
||||||
firstTime = hit[id]->timestamp;
|
|
||||||
fileID = id;
|
|
||||||
groupID = i;
|
|
||||||
//printf("%d | %d %lu %d | %d \n", id, reader[id]->GetBlockID(), hit[id]->timestamp, hit[id]->channel, (int) activeFileID.size());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( hit[id]->timestamp <= firstTime) {
|
|
||||||
firstTime = hit[id]->timestamp;
|
|
||||||
fileID = id;
|
|
||||||
groupID = i;
|
|
||||||
//printf("%d | %d %lu %d | %d \n", id, reader[id]->GetBlockID(), hit[id]->timestamp, hit[id]->channel, (int) activeFileID.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long long evID = 0;
|
|
||||||
unsigned int multi = 0;
|
|
||||||
unsigned short bd[MAX_MULTI] = {0};
|
|
||||||
unsigned short sn[MAX_MULTI] = {0};
|
|
||||||
unsigned short ch[MAX_MULTI] = {0};
|
|
||||||
unsigned short e[MAX_MULTI] = {0};
|
|
||||||
unsigned short e2[MAX_MULTI] = {0}; //for PSD energy short
|
|
||||||
unsigned long long e_t[MAX_MULTI] = {0};
|
|
||||||
unsigned short e_f[MAX_MULTI] = {0};
|
|
||||||
unsigned short lowFlag[MAX_MULTI] = {0};
|
|
||||||
unsigned short highFlag[MAX_MULTI] = {0};
|
|
||||||
int traceLen[MAX_MULTI] = {0};
|
|
||||||
int trace[MAX_MULTI][MAX_TRACE_LEN] = {0};
|
|
||||||
|
|
||||||
void fillData(int &fileID, const bool &saveTrace){
|
|
||||||
bd[multi] = idList[fileID][1];
|
|
||||||
sn[multi] = idList[fileID][3];
|
|
||||||
ch[multi] = hit[fileID]->channel;
|
|
||||||
e[multi] = hit[fileID]->energy;
|
|
||||||
e2[multi] = hit[fileID]->energy_short;
|
|
||||||
e_t[multi] = hit[fileID]->timestamp;
|
|
||||||
e_f[multi] = hit[fileID]->fine_timestamp;
|
|
||||||
lowFlag[multi] = hit[fileID]->flags_low_priority;
|
|
||||||
highFlag[multi] = hit[fileID]->flags_high_priority;
|
|
||||||
|
|
||||||
if( saveTrace ){
|
|
||||||
traceLen[multi] = hit[fileID]->traceLenght;
|
|
||||||
for( int i = 0; i < TMath::Min(traceLen[multi], MAX_TRACE_LEN); i++){
|
|
||||||
trace[multi][i] = hit[fileID]->analog_probes[0][i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multi++;
|
|
||||||
reader[fileID]->ReadNextBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void printEvent(){
|
|
||||||
printf("==================== evID : %llu\n", evID);
|
|
||||||
for( int i = 0; i < multi; i++){
|
|
||||||
printf(" %2d | %d %d | %llu %d \n", i, bd[i], ch[i], e_t[i], e[i] );
|
|
||||||
}
|
|
||||||
printf("==========================================\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
//^##################################################################################
|
|
||||||
int main(int argc, char ** argv){
|
|
||||||
|
|
||||||
printf("=======================================================\n");
|
|
||||||
printf("=== SOLARIS Event Builder sol --> root ===\n");
|
|
||||||
printf("=======================================================\n");
|
|
||||||
|
|
||||||
if( argc <= 3){
|
|
||||||
printf("%s [outfile] [timeWindow] [saveTrace] [sol-1] [sol-2] ... \n", argv[0]);
|
|
||||||
printf(" outfile : output root file name\n");
|
|
||||||
printf(" timeWindow : number of tick, 1 tick = %d ns.\n", tick2ns);
|
|
||||||
printf(" saveTrace : 1 = save trace, 0 = no trace\n");
|
|
||||||
printf(" sol-X : the sol file(s)\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for( int i = 0; i < argc; i++){
|
|
||||||
// printf("%d | %s\n", i, argv[i]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
TString outFileName = argv[1];
|
|
||||||
int timeWindow = abs(atoi(argv[2]));
|
|
||||||
const bool saveTrace = atoi(argv[3]);
|
|
||||||
|
|
||||||
const int nFile = argc - 4;
|
|
||||||
TString inFileName[nFile];
|
|
||||||
for( int i = 0 ; i < nFile ; i++){
|
|
||||||
inFileName[i] = argv[i+4];
|
|
||||||
}
|
|
||||||
|
|
||||||
//*======================================== setup reader
|
|
||||||
reader = new SolReader*[nFile];
|
|
||||||
hit = new Hit *[nFile];
|
|
||||||
|
|
||||||
for( int i = 0 ; i < nFile ; i++){
|
|
||||||
reader[i] = new SolReader(inFileName[i].Data());
|
|
||||||
hit[i] = reader[i]->hit; //TODO check is file open propertly
|
|
||||||
reader[i]->ReadNextBlock(); // read the first block
|
|
||||||
}
|
|
||||||
|
|
||||||
//*======================================== group files
|
|
||||||
idList.clear();
|
|
||||||
for( int i = 0; i < nFile; i++){
|
|
||||||
TString fn = inFileName[i];
|
|
||||||
|
|
||||||
int pos = fn.Last('/'); // path
|
|
||||||
fn.Remove(0, pos+1);
|
|
||||||
|
|
||||||
pos = fn.First('_'); // expName;
|
|
||||||
fn.Remove(0, pos+1);
|
|
||||||
|
|
||||||
pos = fn.First('_'); // runNum;
|
|
||||||
fn.Remove(0, pos+1);
|
|
||||||
|
|
||||||
pos = fn.First('_'); // digiID
|
|
||||||
TString f1 = fn;
|
|
||||||
int digiID = f1.Remove(pos).Atoi();
|
|
||||||
fn.Remove(0, pos+1);
|
|
||||||
|
|
||||||
pos = fn.Last('_'); // digi serial num
|
|
||||||
f1 = fn;
|
|
||||||
int digisn = f1.Remove(pos).Atoi();
|
|
||||||
fn.Remove(0, pos+1);
|
|
||||||
|
|
||||||
pos = fn.First('.'); // get the file id;
|
|
||||||
int indexID = fn.Remove(pos).Atoi();
|
|
||||||
|
|
||||||
int fileID = i;
|
|
||||||
std::vector<int> haha = {fileID, digiID, indexID, digisn};
|
|
||||||
idList.push_back(haha);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort by digiID
|
|
||||||
std::sort(idList.begin(), idList.end(), [](const std::vector<int>& a, const std::vector<int>& b){
|
|
||||||
if (a[1] == b[1]) {
|
|
||||||
return a[2] < b[2];
|
|
||||||
}
|
|
||||||
return a[1] < b[1];
|
|
||||||
});
|
|
||||||
|
|
||||||
group.clear(); // group[i][j], i is the group Index = digiID
|
|
||||||
int last_id = 0;
|
|
||||||
std::vector<int> kaka;
|
|
||||||
for( int i = 0; i < (int) idList.size() ; i++){
|
|
||||||
if( i == 0 ) {
|
|
||||||
kaka.clear();
|
|
||||||
last_id = idList[i][1];
|
|
||||||
kaka.push_back(idList[i][0]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( idList[i][1] != last_id ) {
|
|
||||||
last_id = idList[i][1];
|
|
||||||
group.push_back(kaka);
|
|
||||||
kaka.clear();
|
|
||||||
kaka.push_back(idList[i][0]);
|
|
||||||
}else{
|
|
||||||
kaka.push_back(idList[i][0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
group.push_back(kaka);
|
|
||||||
|
|
||||||
printf(" out file : \033[1;33m%s\033[m\n", outFileName.Data());
|
|
||||||
printf(" Event building time window : %d tics = %d nsec \n", timeWindow, timeWindow*tick2ns);
|
|
||||||
printf(" Save Trace ? %s \n", saveTrace ? "Yes" : "No");
|
|
||||||
printf(" Number of input file : %d \n", nFile);
|
|
||||||
for( int i = 0; i < nFile; i++){
|
|
||||||
printf(" %2d| %5.1f MB| %s \n", i, reader[i]->GetFileSize()/1024./1024., inFileName[i].Data());
|
|
||||||
totFileSize += reader[i]->GetFileSize();
|
|
||||||
}
|
|
||||||
printf("------------------------------------\n");
|
|
||||||
for( int i = 0; i < (int) group.size(); i++){
|
|
||||||
printf("Group %d :", i);
|
|
||||||
for( int j = 0; j < (int) group[i].size(); j ++){
|
|
||||||
printf("%d, ", group[i][j]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
printf("------------------------------------\n");
|
|
||||||
|
|
||||||
//*======================================== setup tree
|
|
||||||
TFile * outRootFile = new TFile(outFileName, "recreate");
|
|
||||||
outRootFile->cd();
|
|
||||||
|
|
||||||
TTree * tree = new TTree("tree", outFileName);
|
|
||||||
|
|
||||||
tree->Branch("evID", &evID, "event_ID/l");
|
|
||||||
tree->Branch("multi", &multi, "multi/i");
|
|
||||||
tree->Branch("bd", bd, "board[multi]/s");
|
|
||||||
tree->Branch("sn", sn, "sn[multi]/s");
|
|
||||||
tree->Branch("ch", ch, "channel[multi]/s");
|
|
||||||
tree->Branch("e", e, "energy[multi]/s");
|
|
||||||
tree->Branch("e2", e2, "energy_short[multi]/s");
|
|
||||||
tree->Branch("e_t", e_t, "timestamp[multi]/l");
|
|
||||||
tree->Branch("e_f", e_f, "fine_timestamp[multi]/s");
|
|
||||||
tree->Branch("lowFlag", lowFlag, "lowFlag[multi]/s");
|
|
||||||
tree->Branch("highFlag", highFlag, "highFlag[multi]/s");
|
|
||||||
|
|
||||||
if( saveTrace){
|
|
||||||
tree->Branch("tl", traceLen, "traceLen[multi]/I");
|
|
||||||
tree->Branch("trace", trace, Form("trace[multi][%d]/I", MAX_TRACE_LEN));
|
|
||||||
}
|
|
||||||
|
|
||||||
//*=========================================== build event
|
|
||||||
|
|
||||||
//@---- using file from group[i][0] first
|
|
||||||
|
|
||||||
//--- find earlist time among the files
|
|
||||||
activeFileID.clear();
|
|
||||||
groupIndex.clear(); //the index of each group
|
|
||||||
|
|
||||||
for(int i = 0; i < (int) group.size(); i++) {
|
|
||||||
groupIndex.push_back(0);
|
|
||||||
activeFileID.push_back(group[i][0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int fileID = 0;
|
|
||||||
int groupID = 0;
|
|
||||||
findEarliestTime(fileID, groupID);
|
|
||||||
fillData(fileID, saveTrace);
|
|
||||||
|
|
||||||
unsigned long firstTimeStamp = hit[fileID]->timestamp;
|
|
||||||
unsigned long lastTimeStamp = 0;
|
|
||||||
|
|
||||||
int last_precentage = 0;
|
|
||||||
while((activeFileID.size() > 0)){
|
|
||||||
|
|
||||||
findEarliestTime(fileID, groupID);
|
|
||||||
if( reader[fileID]->IsEndOfFile() ){
|
|
||||||
groupIndex[groupID] ++;
|
|
||||||
if( groupIndex[groupID] < (int) group[groupID].size() ){
|
|
||||||
activeFileID[groupID] = group[groupID][groupIndex[groupID]];
|
|
||||||
fileID = activeFileID[groupID];
|
|
||||||
}else{
|
|
||||||
activeFileID.erase(activeFileID.begin() + groupID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( hit[fileID]->timestamp - e_t[0] < timeWindow ){
|
|
||||||
fillData(fileID, saveTrace);
|
|
||||||
}else{
|
|
||||||
outRootFile->cd();
|
|
||||||
tree->Fill();
|
|
||||||
evID ++;
|
|
||||||
|
|
||||||
multi = 0;
|
|
||||||
fillData(fileID, saveTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
///========= calculate progress
|
|
||||||
processedFileSize = 0;
|
|
||||||
for( int p = 0; p < (int) group.size(); p ++){
|
|
||||||
for( int q = 0; q <= groupIndex[p]; q++){
|
|
||||||
if( groupIndex[p] < (int) group[p].size() ){
|
|
||||||
int id = group[p][q];
|
|
||||||
processedFileSize += reader[id]->GetFilePos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
double percentage = processedFileSize * 100/ totFileSize;
|
|
||||||
if( percentage >= last_precentage ) {
|
|
||||||
printf("Processed : %llu, %.0f%% | %lu/%lu | ", evID, percentage, processedFileSize, totFileSize);
|
|
||||||
for( int i = 0; i < (int) activeFileID.size(); i++) printf("%d, ", activeFileID[i]);
|
|
||||||
printf(" \n\033[A\r");
|
|
||||||
last_precentage = percentage + 1.0;
|
|
||||||
}
|
|
||||||
}; ///====== end of event building loop
|
|
||||||
|
|
||||||
processedFileSize = 0;
|
|
||||||
for( int p = 0; p < (int) group.size(); p ++){
|
|
||||||
for( int q = 0; q < (int) group[p].size(); q++){
|
|
||||||
int id = group[p][q];
|
|
||||||
processedFileSize += reader[id]->GetFilePos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
double percentage = processedFileSize * 100/ totFileSize;
|
|
||||||
printf("Processed : %llu, %.0f%% | %lu/%lu \n", evID, percentage, processedFileSize, totFileSize);
|
|
||||||
|
|
||||||
lastTimeStamp = hit[fileID]->timestamp;
|
|
||||||
//*=========================================== save file
|
|
||||||
outRootFile->cd();
|
|
||||||
tree->Fill();
|
|
||||||
evID ++;
|
|
||||||
tree->Write();
|
|
||||||
|
|
||||||
//*=========================================== Save timestamp as TMacro
|
|
||||||
TMacro timeStamp;
|
|
||||||
TString str;
|
|
||||||
str.Form("%lu", firstTimeStamp); timeStamp.AddLine( str.Data() );
|
|
||||||
str.Form("%lu", lastTimeStamp); timeStamp.AddLine( str.Data() );
|
|
||||||
timeStamp.Write("timeStamp");
|
|
||||||
|
|
||||||
unsigned int numBlock = 0;
|
|
||||||
for( int i = 0; i < nFile; i++){
|
|
||||||
//printf("%d | %8ld | %10u/%10u\n", i, reader[i]->GetBlockID() + 1, reader[i]->GetFilePos(), reader[i]->GetFileSize());
|
|
||||||
numBlock += reader[i]->GetBlockID() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("===================================== done. \n");
|
|
||||||
printf("Number of Block Scanned : %u\n", numBlock);
|
|
||||||
printf(" Number of Event Built : %lld\n", evID);
|
|
||||||
printf(" Output Root File Size : %.2f MB\n", outRootFile->GetSize()/1024./1024.);
|
|
||||||
printf(" first timestamp : %lu \n", firstTimeStamp);
|
|
||||||
printf(" last timestamp : %lu \n", lastTimeStamp);
|
|
||||||
unsigned long duration = lastTimeStamp - firstTimeStamp;
|
|
||||||
printf(" total duration : %lu = %.2f sec \n", duration, duration * tick2ns * 1.0 / 1e9 );
|
|
||||||
printf("===================================== end of summary. \n");
|
|
||||||
|
|
||||||
|
|
||||||
//^############## delete new
|
|
||||||
for( int i = 0; i < nFile; i++) delete reader[i];
|
|
||||||
delete [] reader;
|
|
||||||
outRootFile->Close();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,205 +0,0 @@
|
||||||
#define GeneralSort_cxx
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "GeneralSort.h"
|
|
||||||
|
|
||||||
#include <TH2.h>
|
|
||||||
#include <TStyle.h>
|
|
||||||
#include <TString.h>
|
|
||||||
#include <TSystem.h>
|
|
||||||
#include <TMath.h>
|
|
||||||
|
|
||||||
Long64_t processedEntry = 0;
|
|
||||||
float lastPercentage = 0;
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
Bool_t GeneralSort::Process(Long64_t entry){
|
|
||||||
|
|
||||||
if( entry < 1 ) printf("============================== start processing data\n");
|
|
||||||
|
|
||||||
///initialization
|
|
||||||
for( int i = 0; i < mapping::nDetType; i++){
|
|
||||||
for( int j = 0; j < mapping::detNum[i]; j++){
|
|
||||||
eE[i][j] = TMath::QuietNaN();
|
|
||||||
eT[i][j] = 0;
|
|
||||||
|
|
||||||
if( isTraceExist && traceMethod > 0){
|
|
||||||
teE[i][j] = TMath::QuietNaN();
|
|
||||||
teT[i][j] = TMath::QuietNaN();
|
|
||||||
teR[i][j] = TMath::QuietNaN();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multi = 0;
|
|
||||||
b_event_ID->GetEntry(entry);
|
|
||||||
b_multi->GetEntry(entry);
|
|
||||||
b_bd->GetEntry(entry);
|
|
||||||
b_ch->GetEntry(entry);
|
|
||||||
b_e->GetEntry(entry);
|
|
||||||
b_e_t->GetEntry(entry);
|
|
||||||
|
|
||||||
for( int i = 0 ; i < multi; i++){
|
|
||||||
int detID = mapping::map[bd[i]][ch[i]];
|
|
||||||
int detType = mapping::FindDetTypeIndex(detID);
|
|
||||||
int low = (i == 0 ? 0 : mapping::detMaxID[detType-1]);
|
|
||||||
int reducedDetID = detID - low;
|
|
||||||
|
|
||||||
eE[detType][reducedDetID] = e[i] * mapping::detParity[detType];
|
|
||||||
eT[detType][reducedDetID] = e_t[i];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//@===================================== Trace
|
|
||||||
if( isTraceExist && traceMethod >= 0 ){
|
|
||||||
|
|
||||||
b_tl->GetEntry(entry);
|
|
||||||
b_trace->GetEntry(entry);
|
|
||||||
|
|
||||||
int countTrace = 0;
|
|
||||||
|
|
||||||
arr->Clear("C");
|
|
||||||
|
|
||||||
for( int i = 0; i < multi; i++){
|
|
||||||
int detID = mapping::map[bd[i]][ch[i]];
|
|
||||||
|
|
||||||
|
|
||||||
int traceLength = tl[i];
|
|
||||||
gTrace = (TGraph*) arr->ConstructedAt(countTrace, "C");
|
|
||||||
gTrace->Clear();
|
|
||||||
gTrace->Set(traceLength);
|
|
||||||
|
|
||||||
gTrace->SetTitle(Form("ev:%llu,nHit:%d,id:%d,len:%d", evID, i, detID, traceLength));
|
|
||||||
countTrace ++;
|
|
||||||
|
|
||||||
for( int k = 0 ; k < traceLength; k++){
|
|
||||||
gTrace->SetPoint(k, k, trace[i][k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//***=================== fit
|
|
||||||
if( traceMethod == 1){
|
|
||||||
|
|
||||||
int detType = mapping::FindDetTypeIndex(detID);
|
|
||||||
//TODO use a blackList
|
|
||||||
//if( mapping::detTypeName[detType] != "rdt") continue;
|
|
||||||
|
|
||||||
//TODO try custom build fiting algorithm. May be faster?
|
|
||||||
gFit = new TF1("gFit", fitFunc, 0, traceLength, numPara);
|
|
||||||
gFit->SetLineColor(6);
|
|
||||||
gFit->SetRange(0, traceLength);
|
|
||||||
|
|
||||||
gFit->SetParameter(0, e[i]);
|
|
||||||
gFit->SetParameter(1, 100); //triggerTime //TODO how to not hardcode?
|
|
||||||
gFit->SetParameter(2, 10); //rise time //TODO how to not hardcode?
|
|
||||||
gFit->SetParameter(3, trace[i][0]); //base line
|
|
||||||
gFit->SetParameter(4, 100); // decay //TODO how to not hardcode?
|
|
||||||
gFit->SetParameter(5, -0.01); // pre-rise slope //TODO how to not hardcode?
|
|
||||||
|
|
||||||
gFit->SetParLimits(1, 85, 125); //raneg for the trigger time
|
|
||||||
gFit->SetParLimits(5, -2, 0);
|
|
||||||
|
|
||||||
gTrace->Fit("gFit", "QR", "", 0, traceLength);
|
|
||||||
|
|
||||||
int low = (i == 0 ? 0 : mapping::detMaxID[detType-1]);
|
|
||||||
int reducedDetID = detID - low;
|
|
||||||
|
|
||||||
teE[detType][reducedDetID] = gFit->GetParameter(0);
|
|
||||||
teT[detType][reducedDetID] = gFit->GetParameter(1);
|
|
||||||
teR[detType][reducedDetID] = gFit->GetParameter(2);
|
|
||||||
|
|
||||||
delete gFit;
|
|
||||||
gFit = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//***=================== Trapezoid filter
|
|
||||||
if( traceMethod == 2){
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !isParallel){
|
|
||||||
processedEntry ++;
|
|
||||||
float percentage = processedEntry*100/NumEntries;
|
|
||||||
if( percentage >= lastPercentage ) {
|
|
||||||
TString msg; msg.Form("%lu", NumEntries);
|
|
||||||
int len = msg.Sizeof();
|
|
||||||
printf("Processed : %*lld, %3.0f%% | Elapsed %6.1f sec | expect %6.1f sec\n\033[A\r", len, entry, percentage, stpWatch.RealTime(), stpWatch.RealTime()/percentage*100);
|
|
||||||
stpWatch.Start(kFALSE);
|
|
||||||
lastPercentage = percentage + 1.0;
|
|
||||||
if( lastPercentage >= 100) printf("\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newSaveTree->Fill();
|
|
||||||
|
|
||||||
return kTRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
void GeneralSort::Terminate(){
|
|
||||||
|
|
||||||
printf("=============================== %s\n", __func__);
|
|
||||||
|
|
||||||
DecodeOption();
|
|
||||||
|
|
||||||
if( !isParallel){
|
|
||||||
stpWatch.Start(kFALSE);
|
|
||||||
saveFile->cd();
|
|
||||||
newSaveTree->Print("toponly");
|
|
||||||
newSaveTree->Write();
|
|
||||||
saveFile->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
//get entries
|
|
||||||
saveFile = TFile::Open(saveFileName);
|
|
||||||
if( saveFile->IsOpen() ){
|
|
||||||
TTree * tree = (TTree*) saveFile->FindObjectAny("gen_tree");
|
|
||||||
int validCount = tree->GetEntries();
|
|
||||||
|
|
||||||
saveFile->Close();
|
|
||||||
|
|
||||||
printf("=========================================================================\n");
|
|
||||||
PrintTraceMethod();
|
|
||||||
printf("----- saved as \033[1;33m%s\033[0m. valid event: %d\n", saveFileName.Data() , validCount);
|
|
||||||
printf("=========================================================================\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
void GeneralSort::Begin(TTree * tree){
|
|
||||||
|
|
||||||
printf( "=================================================================\n");
|
|
||||||
printf( "===================== SOLARIS GeneralSort.C =================\n");
|
|
||||||
printf( "=================================================================\n");
|
|
||||||
|
|
||||||
mapping::PrintMapping();
|
|
||||||
|
|
||||||
DecodeOption();
|
|
||||||
if(!isParallel) {
|
|
||||||
tree->GetEntriesFast();
|
|
||||||
stpWatch.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralSort::SlaveBegin(TTree * /*tree*/){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralSort::SlaveTerminate(){
|
|
||||||
if( isParallel){
|
|
||||||
printf("%s::SaveTree\n", __func__);
|
|
||||||
saveFile->cd();
|
|
||||||
newSaveTree->Write();
|
|
||||||
fOutput->Add(proofFile);
|
|
||||||
saveFile->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,362 +0,0 @@
|
||||||
#ifndef GeneralSort_h
|
|
||||||
#define GeneralSort_h
|
|
||||||
|
|
||||||
#include <TROOT.h>
|
|
||||||
#include <TChain.h>
|
|
||||||
#include <TTree.h>
|
|
||||||
#include <TFile.h>
|
|
||||||
#include <TSelector.h>
|
|
||||||
#include <TObjString.h>
|
|
||||||
#include <TGraph.h>
|
|
||||||
#include <TClonesArray.h>
|
|
||||||
#include <TF1.h>
|
|
||||||
#include <TStopwatch.h>
|
|
||||||
#include <TProofOutputFile.h>
|
|
||||||
|
|
||||||
//^######################################### Skip list for trace fitting
|
|
||||||
//TODO
|
|
||||||
|
|
||||||
/*********************************=======
|
|
||||||
|
|
||||||
the sequence of each method
|
|
||||||
|
|
||||||
1) Begin (master, stdout)
|
|
||||||
2) SlaveBegin (slave)
|
|
||||||
3) Init
|
|
||||||
4) Notify
|
|
||||||
5) Process (looping each event)
|
|
||||||
6) SlaveTerminate
|
|
||||||
7) Terminate
|
|
||||||
|
|
||||||
// variable in the Master will not pass to Slave
|
|
||||||
|
|
||||||
******************************************/
|
|
||||||
|
|
||||||
/// in Process_Sort, copy the Mapping.h to ~/.proof/working/
|
|
||||||
#include "../working/Mapping.h"
|
|
||||||
|
|
||||||
//^######################################### FIT FUNCTION
|
|
||||||
const int numPara = 6;
|
|
||||||
double fitFunc(double * x, double * par){
|
|
||||||
/// par[0] = A
|
|
||||||
/// par[1] = t0
|
|
||||||
/// par[2] = rise time
|
|
||||||
/// par[3] = baseline
|
|
||||||
/// par[4] = decay
|
|
||||||
/// par[5] = pre-rise slope
|
|
||||||
|
|
||||||
if( x[0] < par[1] ) return par[3] + par[5] * (x[0]-par[1]);
|
|
||||||
|
|
||||||
return par[3] + par[0] * (1 - TMath::Exp(- (x[0] - par[1]) / par[2]) ) * TMath::Exp(- (x[0] - par[1]) / par[4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//^######################################### TRAPEZOID
|
|
||||||
TGraph * TrapezoidFilter(TGraph * trace){
|
|
||||||
///Trapezoid filter https://doi.org/10.1016/0168-9002(94)91652-7
|
|
||||||
|
|
||||||
//TODO how to not hard code?
|
|
||||||
int baseLineEnd = 80;
|
|
||||||
int riseTime = 10; //ch
|
|
||||||
int flatTop = 20;
|
|
||||||
float decayTime = 2000;
|
|
||||||
|
|
||||||
TGraph * trapezoid = new TGraph();
|
|
||||||
trapezoid->Clear();
|
|
||||||
|
|
||||||
///find baseline;
|
|
||||||
double baseline = 0;
|
|
||||||
for( int i = 0; i < baseLineEnd; i++){
|
|
||||||
baseline += trace->Eval(i);
|
|
||||||
}
|
|
||||||
baseline = baseline*1./baseLineEnd;
|
|
||||||
|
|
||||||
int length = trace->GetN();
|
|
||||||
|
|
||||||
double pn = 0.;
|
|
||||||
double sn = 0.;
|
|
||||||
for( int i = 0; i < length ; i++){
|
|
||||||
|
|
||||||
double dlk = trace->Eval(i) - baseline;
|
|
||||||
if( i - riseTime >= 0 ) dlk -= trace->Eval(i - riseTime) - baseline;
|
|
||||||
if( i - flatTop - riseTime >= 0 ) dlk -= trace->Eval(i - flatTop - riseTime) - baseline;
|
|
||||||
if( i - flatTop - 2*riseTime >= 0) dlk += trace->Eval(i - flatTop - 2*riseTime) - baseline;
|
|
||||||
|
|
||||||
if( i == 0 ){
|
|
||||||
pn = dlk;
|
|
||||||
sn = pn + dlk*decayTime;
|
|
||||||
}else{
|
|
||||||
pn = pn + dlk;
|
|
||||||
sn = sn + pn + dlk*decayTime;
|
|
||||||
}
|
|
||||||
trapezoid->SetPoint(i, i, sn / decayTime / riseTime);
|
|
||||||
}
|
|
||||||
return trapezoid;
|
|
||||||
}
|
|
||||||
|
|
||||||
TStopwatch stpWatch;
|
|
||||||
|
|
||||||
//^######################################### Class definition
|
|
||||||
// Header file for the classes stored in the TTree if any.
|
|
||||||
class GeneralSort : public TSelector {
|
|
||||||
public :
|
|
||||||
TTree *fChain; //!pointer to the analyzed TTree or TChain
|
|
||||||
|
|
||||||
// Fixed size dimensions of array or collections stored in the TTree if any.
|
|
||||||
|
|
||||||
// Declaration of leaf types
|
|
||||||
ULong64_t evID;
|
|
||||||
Int_t multi;
|
|
||||||
Int_t bd[100]; //[multi]
|
|
||||||
Int_t ch[100]; //[multi]
|
|
||||||
Int_t e[100]; //[multi]
|
|
||||||
ULong64_t e_t[100]; //[multi]
|
|
||||||
UShort_t lowFlag[100]; //[multi]
|
|
||||||
UShort_t highFlag[100]; //[multi]
|
|
||||||
Int_t tl[100]; //[multi]
|
|
||||||
Int_t trace[100][2500]; //[multi]
|
|
||||||
|
|
||||||
// List of branches
|
|
||||||
TBranch *b_event_ID; //!
|
|
||||||
TBranch *b_multi; //!
|
|
||||||
TBranch *b_bd; //!
|
|
||||||
TBranch *b_ch; //!
|
|
||||||
TBranch *b_e; //!
|
|
||||||
TBranch *b_e_t; //!
|
|
||||||
TBranch *b_lowFlag; //!
|
|
||||||
TBranch *b_highFlag; //!
|
|
||||||
TBranch *b_tl; //!
|
|
||||||
TBranch *b_trace; //!
|
|
||||||
|
|
||||||
GeneralSort(TTree * /*tree*/ =0) : fChain(0) {
|
|
||||||
printf("constructor :: %s\n", __func__);
|
|
||||||
|
|
||||||
isTraceExist = false;
|
|
||||||
traceMethod = 0; // -1 = ignore trace, 0 = no trace fit, 1 = fit, 2 = trapezoid
|
|
||||||
|
|
||||||
isParallel = false;
|
|
||||||
|
|
||||||
saveFile = nullptr;
|
|
||||||
newSaveTree = nullptr;
|
|
||||||
|
|
||||||
eE = nullptr;
|
|
||||||
eT = nullptr;
|
|
||||||
|
|
||||||
arr = nullptr;
|
|
||||||
gTrace = nullptr;
|
|
||||||
gFit = nullptr;
|
|
||||||
arrTrapezoid = nullptr;
|
|
||||||
gTrapezoid = nullptr;
|
|
||||||
|
|
||||||
teE = nullptr;
|
|
||||||
teT = nullptr;
|
|
||||||
teR = nullptr;
|
|
||||||
|
|
||||||
}
|
|
||||||
virtual ~GeneralSort() { }
|
|
||||||
virtual Int_t Version() const { return 2; }
|
|
||||||
virtual void Begin(TTree *tree);
|
|
||||||
virtual void SlaveBegin(TTree *tree);
|
|
||||||
virtual void Init(TTree *tree);
|
|
||||||
virtual Bool_t Notify();
|
|
||||||
virtual Bool_t Process(Long64_t entry);
|
|
||||||
virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
|
|
||||||
virtual void SetOption(const char *option) { fOption = option; }
|
|
||||||
virtual void SetObject(TObject *obj) { fObject = obj; }
|
|
||||||
virtual void SetInputList(TList *input) { fInput = input; }
|
|
||||||
virtual TList *GetOutputList() const { return fOutput; }
|
|
||||||
virtual void SlaveTerminate();
|
|
||||||
virtual void Terminate();
|
|
||||||
|
|
||||||
ClassDef(GeneralSort,0);
|
|
||||||
|
|
||||||
bool isTraceExist;
|
|
||||||
int traceMethod;
|
|
||||||
|
|
||||||
void SetTraceMethod(int methodID) {traceMethod = methodID;}
|
|
||||||
void PrintTraceMethod();
|
|
||||||
|
|
||||||
void SetUpTree();
|
|
||||||
void DecodeOption();
|
|
||||||
bool isParallel;
|
|
||||||
|
|
||||||
unsigned long NumEntries;
|
|
||||||
|
|
||||||
TString saveFileName;
|
|
||||||
TFile * saveFile; //!
|
|
||||||
TProofOutputFile * proofFile; //!
|
|
||||||
TTree * newSaveTree; //!
|
|
||||||
|
|
||||||
Float_t ** eE; //!
|
|
||||||
ULong64_t ** eT; //!
|
|
||||||
|
|
||||||
//trace
|
|
||||||
TClonesArray * arr ;//!
|
|
||||||
TGraph * gTrace; //!
|
|
||||||
TF1 * gFit; //!
|
|
||||||
TClonesArray * arrTrapezoid ;//!
|
|
||||||
TGraph * gTrapezoid; //!
|
|
||||||
|
|
||||||
//trace energy, trigger time, rise time
|
|
||||||
Float_t **teE; //!
|
|
||||||
Float_t **teT; //!
|
|
||||||
Float_t **teR; //!
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GeneralSort_cxx
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
void GeneralSort::SetUpTree(){
|
|
||||||
|
|
||||||
printf("%s\n", __func__);
|
|
||||||
|
|
||||||
if( isParallel){
|
|
||||||
proofFile = new TProofOutputFile(saveFileName, "M");
|
|
||||||
saveFile = proofFile->OpenFile("RECREATE");
|
|
||||||
}else{
|
|
||||||
saveFile = new TFile(saveFileName,"RECREATE");
|
|
||||||
}
|
|
||||||
|
|
||||||
newSaveTree = new TTree("gen_tree", "Tree After GeneralSort");
|
|
||||||
newSaveTree->SetDirectory(saveFile);
|
|
||||||
newSaveTree->AutoSave();
|
|
||||||
|
|
||||||
newSaveTree->Branch( "evID", &evID, "EventID/l"); // simply copy
|
|
||||||
|
|
||||||
eE = new Float_t * [mapping::nDetType];
|
|
||||||
eT = new ULong64_t * [mapping::nDetType];
|
|
||||||
|
|
||||||
for( int i = 0 ; i < mapping::nDetType; i++){
|
|
||||||
eE[i] = new Float_t[mapping::detNum[i]];
|
|
||||||
eT[i] = new ULong64_t[mapping::detNum[i]];
|
|
||||||
|
|
||||||
for( int j = 0; j < mapping::detNum[i]; j++){
|
|
||||||
eE[i][j] = TMath::QuietNaN();
|
|
||||||
eT[i][j] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
newSaveTree->Branch( mapping::detTypeName[i].c_str(), eE[i], Form("%s[%d]/F", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
|
||||||
newSaveTree->Branch( (mapping::detTypeName[i]+"_t").c_str(), eT[i], Form("%s_Timestamp[%d]/l", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( isTraceExist && traceMethod >= 0){
|
|
||||||
|
|
||||||
arr = new TClonesArray("TGraph");
|
|
||||||
|
|
||||||
newSaveTree->Branch("trace", arr, 256000);
|
|
||||||
arr->BypassStreamer();
|
|
||||||
|
|
||||||
if( traceMethod > 0 ){
|
|
||||||
|
|
||||||
teE = new Float_t * [mapping::nDetType];
|
|
||||||
teT = new Float_t * [mapping::nDetType];
|
|
||||||
teR = new Float_t * [mapping::nDetType];
|
|
||||||
|
|
||||||
for( int i = 0 ; i < mapping::nDetType; i++){
|
|
||||||
teE[i] = new Float_t[mapping::detNum[i]];
|
|
||||||
teT[i] = new Float_t[mapping::detNum[i]];
|
|
||||||
teR[i] = new Float_t[mapping::detNum[i]];
|
|
||||||
|
|
||||||
for( int j = 0; j <mapping::detNum[i]; j++){
|
|
||||||
teE[i][j] = TMath::QuietNaN();
|
|
||||||
teT[i][j] = TMath::QuietNaN();
|
|
||||||
teR[i][j] = TMath::QuietNaN();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO use a blackList to skip some trace
|
|
||||||
|
|
||||||
newSaveTree->Branch( ("w" + mapping::detTypeName[i]).c_str(), teE[i], Form("trace_%s[%d]/F", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
|
||||||
newSaveTree->Branch( ("w" + mapping::detTypeName[i]+"T").c_str(), teT[i], Form("trace_%s_time[%d]/l", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
|
||||||
newSaveTree->Branch( ("w" + mapping::detTypeName[i]+"R").c_str(), teR[i], Form("trace_%s_rise[%d]/l", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
newSaveTree->Print("toponly"); //very important, otherwise the mac will blow up.
|
|
||||||
}
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
void GeneralSort::DecodeOption(){
|
|
||||||
TString option = GetOption();
|
|
||||||
if( option != ""){
|
|
||||||
TObjArray * tokens = option.Tokenize(",");
|
|
||||||
traceMethod = ((TObjString*) tokens->At(0))->String().Atoi();
|
|
||||||
saveFileName = ((TObjString*) tokens->At(1))->String();
|
|
||||||
isParallel = ((TObjString*) tokens->At(2))->String().Atoi();
|
|
||||||
}else{
|
|
||||||
traceMethod = -1;
|
|
||||||
saveFileName = "temp.root";
|
|
||||||
isParallel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("|%s| %d %s %d \n", option.Data(), traceMethod, saveFileName.Data(), isParallel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//^##############################################################
|
|
||||||
void GeneralSort::Init(TTree *tree){
|
|
||||||
|
|
||||||
// Set branch addresses and branch pointers
|
|
||||||
if (!tree) return;
|
|
||||||
fChain = tree;
|
|
||||||
fChain->SetMakeClass(1);
|
|
||||||
|
|
||||||
fChain->SetBranchAddress("evID", &evID, &b_event_ID);
|
|
||||||
fChain->SetBranchAddress("multi", &multi, &b_multi);
|
|
||||||
fChain->SetBranchAddress("bd", bd, &b_bd);
|
|
||||||
fChain->SetBranchAddress("ch", ch, &b_ch);
|
|
||||||
fChain->SetBranchAddress("e", e, &b_e);
|
|
||||||
fChain->SetBranchAddress("e_t", e_t, &b_e_t);
|
|
||||||
fChain->SetBranchAddress("lowFlag", lowFlag, &b_lowFlag);
|
|
||||||
fChain->SetBranchAddress("highFlag", highFlag, &b_highFlag);
|
|
||||||
|
|
||||||
TBranch * br = (TBranch *) fChain->GetListOfBranches()->FindObject("tl");
|
|
||||||
if( br == NULL ){
|
|
||||||
printf(" ++++++++ no Trace.\n");
|
|
||||||
isTraceExist = false;
|
|
||||||
}else{
|
|
||||||
printf(" ++++++++ Found Trace.\n");
|
|
||||||
isTraceExist = true;
|
|
||||||
fChain->SetBranchAddress("tl", tl, &b_tl);
|
|
||||||
fChain->SetBranchAddress("trace", trace, &b_trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
NumEntries = fChain->GetEntries();
|
|
||||||
printf( " ========== total Entry : %ld\n", NumEntries);
|
|
||||||
|
|
||||||
//########################### Get Option
|
|
||||||
DecodeOption();
|
|
||||||
|
|
||||||
if( isTraceExist ){
|
|
||||||
PrintTraceMethod();
|
|
||||||
}else{
|
|
||||||
printf("++++++++ no Trace found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
SetUpTree();
|
|
||||||
|
|
||||||
printf("---- end of Init %s\n ", __func__);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool_t GeneralSort::Notify(){
|
|
||||||
return kTRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralSort::PrintTraceMethod(){
|
|
||||||
const char* traceMethodStr;
|
|
||||||
switch(traceMethod) {
|
|
||||||
case -1 : traceMethodStr = "Ignore Trace"; break;
|
|
||||||
case 0 : traceMethodStr = "Copy"; break;
|
|
||||||
case 1 : traceMethodStr = "Fit"; break;
|
|
||||||
case 2 : traceMethodStr = "Trapezoid"; break;
|
|
||||||
default: traceMethodStr = "Unknown"; break;
|
|
||||||
}
|
|
||||||
printf("\033[1;33m ===== Trace method ? %s \033[m\n", traceMethodStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifdef GeneralSort_cxx
|
|
|
@ -1,56 +0,0 @@
|
||||||
|
|
||||||
#include "TTree.h"
|
|
||||||
#include "TProof.h"
|
|
||||||
#include "TChain.h"
|
|
||||||
#include "TMacro.h"
|
|
||||||
#include "TFile.h"
|
|
||||||
|
|
||||||
void GeneralSortAgent(Int_t runNum, int nWorker = 1, int traceMethod = -1){
|
|
||||||
|
|
||||||
TString name;
|
|
||||||
name.Form("../root_data/run%03d.root", runNum);
|
|
||||||
|
|
||||||
TChain * chain = new TChain("tree");
|
|
||||||
chain->Add(name);
|
|
||||||
|
|
||||||
chain->GetListOfFiles()->Print();
|
|
||||||
|
|
||||||
printf("\033[1;33m---------------------total number of Events %llu\033[0m\n", chain->GetEntries());
|
|
||||||
|
|
||||||
if( chain->GetEntries() == 0 ) return;
|
|
||||||
|
|
||||||
//this is the option for TSelector, the first one is traceMethod, 2nd is save fileName;
|
|
||||||
TString option;
|
|
||||||
|
|
||||||
if( abs(nWorker) == 1){
|
|
||||||
|
|
||||||
option.Form("%d,../root_data/gen_run%03d.root,%d", traceMethod, runNum, 0);
|
|
||||||
chain->Process("../armory/GeneralSort.C+", option);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
TProof * p = TProof::Open("", Form("workers=%d", abs(nWorker)));
|
|
||||||
p->ShowCache();
|
|
||||||
printf("----------------------------\n");
|
|
||||||
|
|
||||||
chain->SetProof();
|
|
||||||
option.Form("%d,../root_data/gen_run%03d.root,%d", traceMethod, runNum, 1);
|
|
||||||
chain->Process("../armory/GeneralSort.C+", option);
|
|
||||||
}
|
|
||||||
|
|
||||||
//========== open the output root and copy teh timestamp Marco
|
|
||||||
|
|
||||||
TFile * f1 = new TFile(Form("../root_data/run%03d.root", runNum), "READ");
|
|
||||||
TMacro * m = (TMacro* ) f1->Get("timeStamp");
|
|
||||||
m->AddLine(Form("%d", runNum));
|
|
||||||
|
|
||||||
TFile * f2 = new TFile(Form("../root_data/gen_run%03d.root", runNum), "UPDATE");
|
|
||||||
f2->cd();
|
|
||||||
m->Write("timeStamp");
|
|
||||||
|
|
||||||
f1->Close();
|
|
||||||
f2->Close();
|
|
||||||
|
|
||||||
delete chain;
|
|
||||||
|
|
||||||
}
|
|
287
armory/Hit.h
287
armory/Hit.h
|
@ -1,287 +0,0 @@
|
||||||
#ifndef HIT_H
|
|
||||||
#define HIT_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define MaxTraceLenght 8100
|
|
||||||
|
|
||||||
enum DataFormat{
|
|
||||||
|
|
||||||
ALL = 0x00,
|
|
||||||
OneTrace = 0x01,
|
|
||||||
NoTrace = 0x02,
|
|
||||||
Minimum = 0x03,
|
|
||||||
MiniWithFineTime = 0x04,
|
|
||||||
Raw = 0x0A,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace DPPType{
|
|
||||||
|
|
||||||
const std::string PHA = "DPP_PHA";
|
|
||||||
const std::string PSD = "DPP_PSD";
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class Hit {
|
|
||||||
public:
|
|
||||||
|
|
||||||
unsigned short dataType;
|
|
||||||
std::string DPPType;
|
|
||||||
|
|
||||||
///============= for dpp-pha
|
|
||||||
uint8_t channel; // 6 bit
|
|
||||||
uint16_t energy; // 16 bit
|
|
||||||
uint16_t energy_short; // 16 bit, only for PSD
|
|
||||||
uint64_t timestamp; // 48 bit
|
|
||||||
uint16_t fine_timestamp; // 10 bit
|
|
||||||
uint16_t flags_low_priority; // 12 bit
|
|
||||||
uint16_t flags_high_priority; // 8 bit
|
|
||||||
size_t traceLenght; // 64 bit
|
|
||||||
uint8_t downSampling; // 8 bit
|
|
||||||
bool board_fail;
|
|
||||||
bool flush;
|
|
||||||
uint8_t analog_probes_type[2]; // 3 bit for PHA, 4 bit for PSD
|
|
||||||
uint8_t digital_probes_type[4]; // 4 bit for PHA, 5 bit for PSD
|
|
||||||
int32_t * analog_probes[2]; // 18 bit
|
|
||||||
uint8_t * digital_probes[4]; // 1 bit
|
|
||||||
uint16_t trigger_threashold; // 16 bit
|
|
||||||
size_t event_size; // 64 bit
|
|
||||||
uint32_t aggCounter; // 32 bit
|
|
||||||
|
|
||||||
///============= for raw
|
|
||||||
uint8_t * data;
|
|
||||||
size_t dataSize; /// number of byte of the data, size/8 = word [64 bits]
|
|
||||||
uint32_t n_events;
|
|
||||||
|
|
||||||
bool isTraceAllZero;
|
|
||||||
|
|
||||||
Hit(){
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Hit(){
|
|
||||||
ClearMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init(){
|
|
||||||
DPPType = DPPType::PHA;
|
|
||||||
dataType = DataFormat::ALL;
|
|
||||||
|
|
||||||
channel = 0;
|
|
||||||
energy = 0;
|
|
||||||
energy_short = 0;
|
|
||||||
timestamp = 0;
|
|
||||||
fine_timestamp = 0;
|
|
||||||
downSampling = 0;
|
|
||||||
board_fail = false;
|
|
||||||
flush = false;
|
|
||||||
flags_low_priority = 0;
|
|
||||||
flags_high_priority = 0;
|
|
||||||
trigger_threashold = 0;
|
|
||||||
event_size = 0;
|
|
||||||
aggCounter = 0;
|
|
||||||
analog_probes[0] = NULL;
|
|
||||||
analog_probes[1] = NULL;
|
|
||||||
digital_probes[0] = NULL;
|
|
||||||
digital_probes[1] = NULL;
|
|
||||||
digital_probes[2] = NULL;
|
|
||||||
digital_probes[3] = NULL;
|
|
||||||
|
|
||||||
analog_probes_type[0] = 0xFF;
|
|
||||||
analog_probes_type[1] = 0xFF;
|
|
||||||
digital_probes_type[0] = 0xFF;
|
|
||||||
digital_probes_type[1] = 0xFF;
|
|
||||||
digital_probes_type[2] = 0xFF;
|
|
||||||
digital_probes_type[3] = 0xFF;
|
|
||||||
data = NULL;
|
|
||||||
|
|
||||||
isTraceAllZero = true; // indicate trace are all zero
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClearMemory(){
|
|
||||||
if( data != NULL ) delete data;
|
|
||||||
|
|
||||||
if( analog_probes[0] != NULL) delete analog_probes[0];
|
|
||||||
if( analog_probes[1] != NULL) delete analog_probes[1];
|
|
||||||
|
|
||||||
if( digital_probes[0] != NULL) delete digital_probes[0];
|
|
||||||
if( digital_probes[1] != NULL) delete digital_probes[1];
|
|
||||||
if( digital_probes[2] != NULL) delete digital_probes[2];
|
|
||||||
if( digital_probes[3] != NULL) delete digital_probes[3];
|
|
||||||
|
|
||||||
isTraceAllZero = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetDataType(unsigned int type, std::string dppType){
|
|
||||||
dataType = type;
|
|
||||||
DPPType = dppType;
|
|
||||||
ClearMemory();
|
|
||||||
|
|
||||||
if( dataType == DataFormat::Raw){
|
|
||||||
data = new uint8_t[20*1024*1024];
|
|
||||||
}else{
|
|
||||||
analog_probes[0] = new int32_t[MaxTraceLenght];
|
|
||||||
analog_probes[1] = new int32_t[MaxTraceLenght];
|
|
||||||
|
|
||||||
digital_probes[0] = new uint8_t[MaxTraceLenght];
|
|
||||||
digital_probes[1] = new uint8_t[MaxTraceLenght];
|
|
||||||
digital_probes[2] = new uint8_t[MaxTraceLenght];
|
|
||||||
digital_probes[3] = new uint8_t[MaxTraceLenght];
|
|
||||||
|
|
||||||
isTraceAllZero = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClearTrace(){
|
|
||||||
if( isTraceAllZero ) return; // no need to clear again
|
|
||||||
|
|
||||||
for( int i = 0; i < MaxTraceLenght; i++){
|
|
||||||
analog_probes[0][i] = 0;
|
|
||||||
analog_probes[1][i] = 0;
|
|
||||||
|
|
||||||
digital_probes[0][i] = 0;
|
|
||||||
digital_probes[1][i] = 0;
|
|
||||||
digital_probes[2][i] = 0;
|
|
||||||
digital_probes[3][i] = 0;
|
|
||||||
}
|
|
||||||
isTraceAllZero = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintEnergyTimeStamp(){
|
|
||||||
printf("ch: %2d, energy: %u, timestamp: %lu ch, traceLenght: %lu\n", channel, energy, timestamp, traceLenght);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AnaProbeType(uint8_t probeType){
|
|
||||||
|
|
||||||
if( DPPType == DPPType::PHA){
|
|
||||||
switch(probeType){
|
|
||||||
case 0: return "ADC";
|
|
||||||
case 1: return "Time filter";
|
|
||||||
case 2: return "Energy filter";
|
|
||||||
default : return "none";
|
|
||||||
}
|
|
||||||
}else if (DPPType == DPPType::PSD){
|
|
||||||
switch(probeType){
|
|
||||||
case 0: return "ADC";
|
|
||||||
case 9: return "Baseline";
|
|
||||||
case 10: return "CFD";
|
|
||||||
default : return "none";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string DigiProbeType(uint8_t probeType){
|
|
||||||
|
|
||||||
if( DPPType == DPPType::PHA){
|
|
||||||
switch(probeType){
|
|
||||||
case 0: return "Trigger";
|
|
||||||
case 1: return "Time filter armed";
|
|
||||||
case 2: return "Re-trigger guard";
|
|
||||||
case 3: return "Energy filter baseline freeze";
|
|
||||||
case 4: return "Energy filter peaking";
|
|
||||||
case 5: return "Energy filter peaking ready";
|
|
||||||
case 6: return "Energy filter pile-up guard";
|
|
||||||
case 7: return "Event pile-up";
|
|
||||||
case 8: return "ADC saturation";
|
|
||||||
case 9: return "ADC saturation protection";
|
|
||||||
case 10: return "Post-saturation event";
|
|
||||||
case 11: return "Energy filter saturation";
|
|
||||||
case 12: return "Signal inhibit";
|
|
||||||
default : return "none";
|
|
||||||
}
|
|
||||||
}else if (DPPType == DPPType::PSD){
|
|
||||||
switch(probeType){
|
|
||||||
case 0: return "Trigger";
|
|
||||||
case 1: return "CFD Filter Armed";
|
|
||||||
case 2: return "Re-trigger guard";
|
|
||||||
case 3: return "ADC Input Baseline freeze";
|
|
||||||
case 20: return "ADC Input OverThreshold";
|
|
||||||
case 21: return "Charge Ready";
|
|
||||||
case 22: return "Long Gate";
|
|
||||||
case 7: return "Pile-Up Trig.";
|
|
||||||
case 24: return "Short Gate";
|
|
||||||
case 25: return "Energy Saturation";
|
|
||||||
case 26: return "Charge over-range";
|
|
||||||
case 27: return "ADC Input Neg. OverThreshold";
|
|
||||||
default : return "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string HighPriority(uint16_t prio){
|
|
||||||
std::string output;
|
|
||||||
|
|
||||||
bool pileup = prio & 0x1;
|
|
||||||
//bool pileupGuard = (prio >> 1) & 0x1;
|
|
||||||
//bool eventSaturated = (prio >> 2) & 0x1;
|
|
||||||
//bool postSatEvent = (prio >> 3) & 0x1;
|
|
||||||
//bool trapSatEvent = (prio >> 4) & 0x1;
|
|
||||||
//bool SCA_Event = (prio >> 5) & 0x1;
|
|
||||||
|
|
||||||
output = std::string("Pile-up: ") + (pileup ? "Yes" : "No");
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO LowPriority
|
|
||||||
|
|
||||||
void PrintAll(){
|
|
||||||
|
|
||||||
switch(dataType){
|
|
||||||
case DataFormat::ALL : printf("============= Type : ALL\n"); break;
|
|
||||||
case DataFormat::OneTrace : printf("============= Type : OneTrace\n"); break;
|
|
||||||
case DataFormat::NoTrace : printf("============= Type : NoTrace\n"); break;
|
|
||||||
case DataFormat::MiniWithFineTime : printf("============= Type : Min with FineTimestamp\n"); break;
|
|
||||||
case DataFormat::Minimum : printf("============= Type : Minimum\n"); break;
|
|
||||||
case DataFormat::Raw : printf("============= Type : Raw\n"); return; break;
|
|
||||||
default : return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush);
|
|
||||||
if( DPPType == DPPType::PHA ) printf("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp);
|
|
||||||
if( DPPType == DPPType::PSD ) printf("energy: %u, energy_S : %u, timestamp: %lu, fine_timestamp: %u \n", energy, energy_short, timestamp, fine_timestamp);
|
|
||||||
printf("flag (high): 0x%02X, (low): 0x%03X, traceLength: %lu\n", flags_high_priority, flags_low_priority, traceLenght);
|
|
||||||
printf("Agg counter : %u, trigger Thr.: %u, downSampling: %u \n", aggCounter, trigger_threashold, downSampling);
|
|
||||||
printf("AnaProbe Type: %s(%u), %s(%u)\n", AnaProbeType(analog_probes_type[0]).c_str(), analog_probes_type[0],
|
|
||||||
AnaProbeType(analog_probes_type[1]).c_str(), analog_probes_type[1]);
|
|
||||||
printf("DigProbe Type: %s(%u), %s(%u), %s(%u), %s(%u)\n", DigiProbeType(digital_probes_type[0]).c_str(), digital_probes_type[0],
|
|
||||||
DigiProbeType(digital_probes_type[1]).c_str(), digital_probes_type[1],
|
|
||||||
DigiProbeType(digital_probes_type[2]).c_str(), digital_probes_type[2],
|
|
||||||
DigiProbeType(digital_probes_type[3]).c_str(), digital_probes_type[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintTrace(unsigned short ID){
|
|
||||||
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
|
|
||||||
if( ID == 0 ) printf("%4d| %6d\n", i, analog_probes[0][i]);
|
|
||||||
if( ID == 1 ) printf("%4d| %6d\n", i, analog_probes[1][i]);
|
|
||||||
if( ID == 2 ) printf("%4d| %u\n", i, digital_probes[0][i]);
|
|
||||||
if( ID == 3 ) printf("%4d| %u\n", i, digital_probes[1][i]);
|
|
||||||
if( ID == 4 ) printf("%4d| %u\n", i, digital_probes[2][i]);
|
|
||||||
if( ID == 5 ) printf("%4d| %u\n", i, digital_probes[3][i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintAllTrace(){
|
|
||||||
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
|
|
||||||
printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes[0][i],
|
|
||||||
analog_probes[1][i],
|
|
||||||
digital_probes[0][i],
|
|
||||||
digital_probes[1][i],
|
|
||||||
digital_probes[2][i],
|
|
||||||
digital_probes[3][i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,12 +0,0 @@
|
||||||
CC=g++
|
|
||||||
CFLAG= -g
|
|
||||||
ROOTFLAG=`root-config --cflags --glibs`
|
|
||||||
|
|
||||||
all: EventBuilder
|
|
||||||
|
|
||||||
EventBuilder: EventBuilder.cpp SolReader.h Hit.h
|
|
||||||
$(CC) $(CFLAG) EventBuilder.cpp -o EventBuilder ${ROOTFLAG}
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm EventBuilder
|
|
|
@ -1,359 +0,0 @@
|
||||||
#ifndef Utilities
|
|
||||||
#define Utilities
|
|
||||||
|
|
||||||
#include <TMath.h>
|
|
||||||
#include <TCanvas.h>
|
|
||||||
|
|
||||||
//This file runs after on Monitor.C
|
|
||||||
//This file is parasite on Monitor.C
|
|
||||||
|
|
||||||
int canvasSize[2] = {2000, 1200};
|
|
||||||
|
|
||||||
void listDraws(void) {
|
|
||||||
printf("------------------- List of Plots -------------------\n");
|
|
||||||
printf(" newCanvas() - Create a new Canvas\n");
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" rawID() - Raw \033[0;31me\033[0m, \033[0;31mring\033[0m, \033[0;31mxf\033[0m, \033[0;31mxn\033[0m vs detID\n");
|
|
||||||
printf(" rawe() - Raw \033[0;31me\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" rawxf() - Raw \033[0;31mxf\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" rawxn() - Raw \033[0;31mxn\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" rawxfVxn() - Raw \033[0;31mxf\033[0m vs. \033[0;31mxn\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" raweVxs() - Raw \033[0;31me\033[0m vs. Raw \033[0;31mxs = xf + xn\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" raweVx() - Raw \033[0;31me\033[0m vs. RAW \033[0;31mx\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" eVxsCal() - Raw \033[0;31me\033[0m vs. Corrected \033[0;31mxs\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" ecal() - Calibrated \033[0;31me\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf("xfCalVxnCal() - Calibrated \033[0;31mxf\033[0m vs. \033[0;31mxn\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf(" eCalVxCal() - Cal \033[0;31me\033[0m vs. \033[0;31mx\033[0m for all %d detectors\n", numDet);
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" recoils() - Raw DE vs. E Recoil spectra\n");
|
|
||||||
//printf(" elum() - Luminosity Energy Spectra\n");
|
|
||||||
//printf(" ic() - Ionization Chamber Spectra\n");
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" eCalVz() - Energy vs. Z\n");
|
|
||||||
printf(" eCalVzRow() - Energy vs. Z for each row\n");
|
|
||||||
printf(" excite() - Excitation Energy\n");
|
|
||||||
printf(" ExThetaCM() - Ex vs ThetaCM\n");
|
|
||||||
printf(" ExVxCal() - Ex vs X for all %d detectors\n", numDet);
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" ShowFitMethod() - Shows various fitting methods \n");
|
|
||||||
printf(" RDTCutCreator() - Create RDT Cuts [May need to edit]\n");
|
|
||||||
printf(" Check_rdtGate() - Check RDT Cuts. \n");
|
|
||||||
printf(" readTrace() - read trace from gen_runXXX.root \n");
|
|
||||||
printf(" readRawTrace() - read trace from runXXX.root \n");
|
|
||||||
printf(" Check1D() - Count Integral within a range\n");
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
printf(" %s\n", canvasTitle.Data());
|
|
||||||
printf("-----------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int xD, yD;
|
|
||||||
void FindBesCanvasDivision(int nPad){
|
|
||||||
for( int i = TMath::Sqrt(nPad); i >= 2 ; i--){
|
|
||||||
if( nPad % i == 0 ) {
|
|
||||||
yD = i;
|
|
||||||
xD = nPad/i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int nCanvas=0;
|
|
||||||
void newCanvas(int sizeX = 800, int sizeY = 600, int posX = 0, int posY = 0){
|
|
||||||
TString name; name.Form("cNewCanvas%d | %s", nCanvas, canvasTitle.Data());
|
|
||||||
TCanvas * cNewCanvas = new TCanvas(name, name, posX, posY, sizeX, sizeY);
|
|
||||||
nCanvas++;
|
|
||||||
cNewCanvas->cd();
|
|
||||||
}
|
|
||||||
|
|
||||||
void rawID(){
|
|
||||||
TCanvas * cRawID = (TCanvas *) gROOT->FindObjectAny("cRawID");
|
|
||||||
if( cRawID == NULL ) cRawID = new TCanvas("cRawID", Form("Raw e, Ring, xf, xn vs ID | %s", canvasTitle.Data()), canvasSize[0], canvasSize[1]);
|
|
||||||
cRawID->Clear();cRawID->Divide(2,2);
|
|
||||||
cRawID->cd(1); cRawID->cd(1)->SetGrid(); heVID->Draw("colz");
|
|
||||||
cRawID->cd(2); cRawID->cd(2)->SetGrid(); hMultiHit->Draw();
|
|
||||||
cRawID->cd(3); cRawID->cd(3)->SetGrid(); hxfVID->Draw("colz");
|
|
||||||
cRawID->cd(4); cRawID->cd(4)->SetGrid(); hxnVID->Draw("colz");
|
|
||||||
}
|
|
||||||
|
|
||||||
void rawe(Bool_t isLogy = false) {
|
|
||||||
TCanvas *cRawE = (TCanvas *) gROOT->FindObjectAny("cRawE");
|
|
||||||
if( cRawE == NULL ) cRawE = new TCanvas("cRawE",Form("E raw | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cRawE->Clear();cRawE->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0; i < numDet; i++) {
|
|
||||||
cRawE->cd(i+1);
|
|
||||||
cRawE->cd(i+1)->SetGrid();
|
|
||||||
if( isLogy ) cRawE->cd(i+1)->SetLogy();
|
|
||||||
he[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rawxf(Bool_t isLogy = false) {
|
|
||||||
TCanvas *cRawXf = (TCanvas *) gROOT->FindObjectAny("cRawXf");
|
|
||||||
if( cRawXf == NULL ) cRawXf = new TCanvas("cRawXf",Form("Xf raw | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cRawXf->Clear();cRawXf->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0; i<numDet; i++) {
|
|
||||||
cRawXf->cd(i+1);
|
|
||||||
cRawXf->cd(i+1)->SetGrid();
|
|
||||||
if( isLogy ) cRawXf->cd(i+1)->SetLogy();
|
|
||||||
hxf[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rawxn(Bool_t isLogy = false) {
|
|
||||||
TCanvas *cRawXn = (TCanvas *) gROOT->FindObjectAny("cRawXn");
|
|
||||||
if( cRawXn == NULL ) cRawXn = new TCanvas("cRawXn",Form("Xn raw | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cRawXn->Clear();cRawXn->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0; i<numDet; i++) {
|
|
||||||
cRawXn->cd(i+1);
|
|
||||||
cRawXn->cd(i+1)->SetGrid();
|
|
||||||
if( isLogy ) cRawXn->cd(i+1)->SetLogy();
|
|
||||||
hxn[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rawxfVxn(void) {
|
|
||||||
TCanvas *cxfxn = (TCanvas *) gROOT->FindObjectAny("cxfxn");
|
|
||||||
if( cxfxn == NULL ) cxfxn = new TCanvas("cxfxn",Form("XF vs. XN | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cxfxn->Clear(); cxfxn->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
cxfxn->cd(i+1);
|
|
||||||
cxfxn->cd(i+1)->SetGrid();
|
|
||||||
hxfVxn[i]->Draw("col");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void raweVxs(void) {
|
|
||||||
TCanvas *cxfxne = (TCanvas *) gROOT->FindObjectAny("cxfxne");
|
|
||||||
if( cxfxne == NULL ) cxfxne = new TCanvas("cxfxne",Form("E - XF+XN | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cxfxne->Clear(); cxfxne->Divide(numCol,numRow);
|
|
||||||
TLine line(0,0, 4000, 4000); line.SetLineColor(2);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
cxfxne->cd(i+1);
|
|
||||||
cxfxne->cd(i+1)->SetGrid();
|
|
||||||
heVxs[i]->Draw("col");
|
|
||||||
line.Draw("same");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void raweVx(void) {
|
|
||||||
TCanvas *ceVx = (TCanvas *) gROOT->FindObjectAny("ceVx");
|
|
||||||
if(ceVx == NULL) ceVx = new TCanvas("ceVx",Form("E vs. X = (xf-xn)/e | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
ceVx->Clear(); ceVx->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
ceVx->cd(i+1); heVx[i]->Draw("col");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void eVxsCal(void) {
|
|
||||||
TCanvas *cxfxneC = (TCanvas *) gROOT->FindObjectAny("cxfxneC");
|
|
||||||
if(cxfxneC == NULL)cxfxneC = new TCanvas("cxfxneC",Form("Raw E - Corrected XF+XN | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cxfxneC->Clear(); cxfxneC->Divide(numCol,numRow);
|
|
||||||
TLine line(0,0, 4000, 4000); line.SetLineColor(2);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
cxfxneC->cd(i+1);
|
|
||||||
cxfxneC->cd(i+1)->SetGrid();
|
|
||||||
heVxsCal[i]->Draw("col");
|
|
||||||
line.Draw("same");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ecal(void) {
|
|
||||||
TCanvas *cEC = (TCanvas *) gROOT->FindObjectAny("cEC");
|
|
||||||
if(cEC == NULL) cEC = new TCanvas("cEC",Form("E corrected | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cEC->Clear();cEC->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0; i<numDet; i++) {
|
|
||||||
cEC->cd(i+1);
|
|
||||||
cEC->cd(i+1)->SetGrid();
|
|
||||||
heCal[i]->Draw("");
|
|
||||||
}
|
|
||||||
|
|
||||||
TCanvas *cEC2 = (TCanvas *) gROOT->FindObjectAny("cEC2");
|
|
||||||
if(cEC2 == NULL) cEC2 = new TCanvas("cEC2",Form("E corrected | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cEC2->Clear();
|
|
||||||
heCalID->Draw("colz");
|
|
||||||
}
|
|
||||||
|
|
||||||
void xfCalVxnCal(void) {
|
|
||||||
TCanvas *cxfxnC = (TCanvas *) gROOT->FindObjectAny("cxfxnC");
|
|
||||||
if(cxfxnC == NULL) cxfxnC = new TCanvas("cxfxnC",Form("XF vs XN corrected | %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cxfxnC->Clear(); cxfxnC->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
cxfxnC->cd(i+1);
|
|
||||||
cxfxnC->cd(i+1)->SetGrid();
|
|
||||||
hxfCalVxnCal[i]->Draw("col");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void eCalVxCal(void) {
|
|
||||||
TCanvas *cecalVxcal = (TCanvas *) gROOT->FindObjectAny("cecalVxcal");
|
|
||||||
if( cecalVxcal == NULL ) cecalVxcal = new TCanvas("cecalVxcal",Form("ECALVXCAL | %s",canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
cecalVxcal->Clear(); cecalVxcal->Divide(numCol,numRow);
|
|
||||||
for (Int_t i=0;i<numDet;i++) {
|
|
||||||
cecalVxcal->cd(i+1);
|
|
||||||
heCalVxCal[i]->SetMarkerStyle(7);
|
|
||||||
heCalVxCal[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void recoils(bool isLogz = false) {
|
|
||||||
TCanvas *crdt = (TCanvas *) gROOT->FindObjectAny("crdt");
|
|
||||||
if( crdt == NULL ) crdt = new TCanvas("crdt",Form("raw RDT | %s", canvasTitle.Data()),1700, 0, 1000,1000);
|
|
||||||
crdt->Clear();crdt->Divide(2,2);
|
|
||||||
|
|
||||||
if( isLogz ) crdt->cd(1)->SetLogz(); crdt->cd(1); hrdt2D[0]->Draw("col");
|
|
||||||
if( isLogz ) crdt->cd(2)->SetLogz(); crdt->cd(2); hrdt2D[1]->Draw("col");
|
|
||||||
if( isLogz ) crdt->cd(3)->SetLogz(); crdt->cd(3); hrdt2D[3]->Draw("col");
|
|
||||||
if( isLogz ) crdt->cd(4)->SetLogz(); crdt->cd(4); hrdt2D[2]->Draw("col");
|
|
||||||
|
|
||||||
TCanvas *crdtID = (TCanvas *) gROOT->FindObjectAny("crdtID");
|
|
||||||
if( crdtID == NULL ) crdtID = new TCanvas("crdtID",Form("raw RDT ID | %s", canvasTitle.Data()),0,0, 500, 500);
|
|
||||||
crdtID->Clear();
|
|
||||||
if( isLogz ) crdtID->SetLogz();
|
|
||||||
hrdtID->Draw("colz");
|
|
||||||
|
|
||||||
TCanvas *crdtS = (TCanvas *) gROOT->FindObjectAny("crdtS");
|
|
||||||
if( crdtS == NULL ) crdtS = new TCanvas("crdtS",Form("raw RDT | %s", canvasTitle.Data()),600, 0, 1000, 1000);
|
|
||||||
crdtS->Clear(); crdtS->Divide(2,4);
|
|
||||||
for( int i = 0; i < 8; i ++){
|
|
||||||
crdtS->cd(i+1);
|
|
||||||
if( isLogz ) crdtS->cd(i+1)->SetLogy();
|
|
||||||
hrdt[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// void elum(void) {
|
|
||||||
// TCanvas *celum = (TCanvas *) gROOT->FindObjectAny("celum");
|
|
||||||
// if( celum == NULL ) celum = new TCanvas("celum",Form("ELUM | %s", canvasTitle.Data()),1000,1000);
|
|
||||||
// celum->Clear(); celum->Divide(4,4);
|
|
||||||
// for( int i = 0 ; i < 16 ; i++){
|
|
||||||
// celum->cd(i+1);
|
|
||||||
// helum[i]->Draw("");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TCanvas *celumID = (TCanvas *) gROOT->FindObjectAny("celumID");
|
|
||||||
// if( celumID == NULL ) celumID = new TCanvas("celumID",Form("ELUM-ID | %s", canvasTitle.Data()),1100, 0, 500,500);
|
|
||||||
// celumID->Clear();
|
|
||||||
// helumID->Draw("colz");
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// void ic(){
|
|
||||||
// TCanvas *cic = (TCanvas *) gROOT->FindObjectAny("cic");
|
|
||||||
// if( cic == NULL ) cic = new TCanvas("cic",Form("Ionization Chamber | %s", canvasTitle.Data() ),1200,800);
|
|
||||||
|
|
||||||
// cic->Clear(); cic->SetGrid(0); cic->Divide(3,2);
|
|
||||||
// gStyle->SetOptStat("neiou");
|
|
||||||
|
|
||||||
// cic->cd(1); hic0->Draw();
|
|
||||||
// cic->cd(2); hic1->Draw();
|
|
||||||
// cic->cd(3); hic2->Draw();
|
|
||||||
// cic->cd(4); hic01->Draw("colz");
|
|
||||||
// cic->cd(5); hic02->Draw("colz");
|
|
||||||
// cic->cd(6); hic12->Draw("colz");
|
|
||||||
// }
|
|
||||||
|
|
||||||
void eCalVz(void) {
|
|
||||||
TCanvas *cecalVz = (TCanvas *) gROOT->FindObjectAny("cecalVz");
|
|
||||||
if( cecalVz == NULL ) cecalVz = new TCanvas("cevalVz",Form("ECALVZ : %s", canvasTitle.Data()),1000,650);
|
|
||||||
cecalVz->Clear(); cecalVz->Divide(2,1);
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
cecalVz->cd(1);heCalVz->Draw("col");
|
|
||||||
cecalVz->cd(2);heCalVzGC->Draw("col");
|
|
||||||
}
|
|
||||||
|
|
||||||
void eCalVzRow() {
|
|
||||||
TCanvas *cecalVzRow = (TCanvas *) gROOT->FindObjectAny("cecalVzRow");
|
|
||||||
if( cecalVzRow == NULL ) cecalVzRow = new TCanvas("cevalVzRow",Form("eCal - Z : %s", canvasTitle.Data()),canvasSize[0], canvasSize[1]);
|
|
||||||
FindBesCanvasDivision(numRow);
|
|
||||||
cecalVzRow->Clear(); cecalVzRow->Divide(xD,yD);
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
|
|
||||||
for(int row = 0; row < numRow; row ++){
|
|
||||||
cecalVzRow->cd(row+1);
|
|
||||||
cecalVzRow->cd(row+1)->SetGrid();
|
|
||||||
hecalVzRow[row]->Draw("colz");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void excite(void) {
|
|
||||||
TCanvas *cex = (TCanvas *) gROOT->FindObjectAny("cex");
|
|
||||||
if( cex == NULL ) cex = new TCanvas("cex",Form("EX : %s", canvasTitle.Data()),0, 0, 1000,650);
|
|
||||||
cex->Clear();
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
hEx->Draw("");
|
|
||||||
|
|
||||||
|
|
||||||
TCanvas *cexI = (TCanvas *) gROOT->FindObjectAny("cexI");
|
|
||||||
if( cexI == NULL ) cexI = new TCanvas("cexI",Form("EX : %s", canvasTitle.Data()),500, 0, 1600,1000);
|
|
||||||
cexI->Clear();cexI->Divide(numCol,numRow);
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
for( int i = 0; i < numDet; i++){
|
|
||||||
cexI->cd(i+1);
|
|
||||||
hExi[i]->Draw("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExThetaCM(void) {
|
|
||||||
TCanvas *cExThetaCM = (TCanvas *) gROOT->FindObjectAny("cExThetaCM");
|
|
||||||
if( cExThetaCM == NULL ) cExThetaCM = new TCanvas("cExThetaCM",Form("EX - ThetaCM | %s", canvasTitle.Data()),650,650);
|
|
||||||
cExThetaCM->Clear();
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
hExThetaCM->Draw("colz");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExVxCal(TString drawOpt = "") {
|
|
||||||
TCanvas *cExVxCal = (TCanvas *) gROOT->FindObjectAny("cExVxCal");
|
|
||||||
if( cExVxCal == NULL ) cExVxCal = new TCanvas("cExVxCal",Form("EX | %s", canvasTitle.Data()),1600,1000);
|
|
||||||
cExVxCal->Clear();
|
|
||||||
gStyle->SetOptStat("neiou");
|
|
||||||
|
|
||||||
cExVxCal->Divide(numCol,numRow);
|
|
||||||
for( int i = 0; i < numDet; i++){
|
|
||||||
cExVxCal->cd(i+1);
|
|
||||||
if( drawOpt == "" )hExVxCal[i]->SetMarkerStyle(7);
|
|
||||||
hExVxCal[i]->Draw(drawOpt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Count1DH(TString name, TH1F * hist, TCanvas * canvas, int padID, double x1, double x2, Color_t color){
|
|
||||||
|
|
||||||
int k1 = hist->FindBin(x1);
|
|
||||||
int k2 = hist->FindBin(x2);
|
|
||||||
|
|
||||||
int hight = 0 ;
|
|
||||||
for( int i = k1; i < k2 ; i ++){
|
|
||||||
int temp = hist->GetBinContent(i);
|
|
||||||
if( temp > hight ) hight = temp;
|
|
||||||
}
|
|
||||||
hight = hight * 1.2;
|
|
||||||
int max = hist->GetMaximum();
|
|
||||||
|
|
||||||
canvas->cd(padID);
|
|
||||||
|
|
||||||
if( color != 0 ){
|
|
||||||
TBox box;
|
|
||||||
box.SetFillColorAlpha(color, 0.1);
|
|
||||||
box.DrawBox(x1, 0, x2, hight);
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = hist->Integral(k1, k2);
|
|
||||||
|
|
||||||
TLatex text;
|
|
||||||
text.SetTextFont(82);
|
|
||||||
text.SetTextSize(0.06);
|
|
||||||
if( color != 0 ){
|
|
||||||
text.SetTextColor(color);
|
|
||||||
text.DrawLatex(x1, hight, Form("%d", count));
|
|
||||||
}else{
|
|
||||||
text.DrawLatex((x1+x2)/2., max, Form("%d", count));
|
|
||||||
}
|
|
||||||
|
|
||||||
printf(" %s : %d \n", name.Data(), count);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,73 +0,0 @@
|
||||||
#!/bin/bash -l
|
|
||||||
|
|
||||||
##############################################
|
|
||||||
#
|
|
||||||
# This script define color, PCID, and dataPath
|
|
||||||
#
|
|
||||||
##############################################
|
|
||||||
|
|
||||||
if [ ! -z $RED ]; then
|
|
||||||
echo "Process_BasicConfig already loaded."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
RED='\033[1;31m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
ORANGE='\033[0;33m'
|
|
||||||
GREEN='\033[1;32m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
CYAN='\033[0;36m'
|
|
||||||
NC='\033[0m' #no color
|
|
||||||
LRED='\033[1;91m'
|
|
||||||
|
|
||||||
############## need to distingish mac and daq
|
|
||||||
Arch="$(uname -s)"
|
|
||||||
PCName="$(hostname)"
|
|
||||||
PCID=-1 #if PCID == 1 (DAQ), 2 (MAC), -1(OTHER)
|
|
||||||
|
|
||||||
#------ Set up data folder, check disk space
|
|
||||||
echo -e "${YELLOW} ##################### Check computer name and arch. ${NC}"
|
|
||||||
echo "PC name : ${PCName}"
|
|
||||||
echo "Archetech: ${Arch}"
|
|
||||||
|
|
||||||
if [ ${Arch} == "Linux" ] && [ ${PCName} == "solaris-daq" ]; then
|
|
||||||
|
|
||||||
PCID=1
|
|
||||||
|
|
||||||
pathsSetting=${HOME}/SOLARIS_QT6_DAQ/programSettings.txt
|
|
||||||
if [ -e ${pathsSetting} ]; then
|
|
||||||
#echo "Found DAQ programSettings.txt for paths settings"
|
|
||||||
|
|
||||||
analysisPath=$(cat ${pathsSetting} | head -n 2 | tail -n 1)
|
|
||||||
|
|
||||||
if [ ! "${analysisPath}" = "$SOLARISANADIR" ]; then
|
|
||||||
echo "The analysisPath from ${analysisPath} is different from present folder $SOLARISANADIR. Abort."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
rawDataPathParent=$(cat ${pathsSetting} | head -n 3 | tail -n 1)
|
|
||||||
rootDataPathParent=$(cat ${pathsSetting} | head -n 4 | tail -n 1)
|
|
||||||
|
|
||||||
databaseIP=$(cat ${pathsSetting} | head -n 6 | tail -n 1)
|
|
||||||
databaseName=$(cat ${pathsSetting} | head -n 7 | tail -n 1)
|
|
||||||
|
|
||||||
#echo ${rawDataPathParent}
|
|
||||||
#echo ${rootDataPathParent}
|
|
||||||
#echo ${databaseIP}
|
|
||||||
#echo ${databaseName}
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
echo "${RED} Cannot found DAQ programSettings.txt for path settings ${NC}"
|
|
||||||
echo "Seek Ryan for help"
|
|
||||||
exit
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${Arch} == "Darwin" ] && [ ${PCName} == "SOLARISs-Mac-Studio.local" ]; then
|
|
||||||
PCID=2
|
|
||||||
rawDataPathParent=${HOME}/experimentalData/
|
|
||||||
rootDataPathParent=${HOME}/experimentalData/
|
|
||||||
fi
|
|
|
@ -1,105 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
|
||||||
echo "$./process_Download [RunNum]"
|
|
||||||
echo " RunNum = run number"
|
|
||||||
echo " * if RunNum = all, sync all"
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
RUN=$1
|
|
||||||
|
|
||||||
runNum=${RUN#0} #remove zero
|
|
||||||
RUN=$(printf '%03d' $runNum) ##add back the zero
|
|
||||||
|
|
||||||
source $SOLARISANADIR/armory/Process_BasicConfig
|
|
||||||
source $SOLARISANADIR/working/expName.sh
|
|
||||||
|
|
||||||
MacRawDataPath=$rawDataPathParent/$expName/
|
|
||||||
IP=solarisdaq # defined at ~/.ssh/config
|
|
||||||
USR=solaris
|
|
||||||
|
|
||||||
if [ ${RUN} == "all" ]; then
|
|
||||||
|
|
||||||
if [ ${PCID} -eq 2 ]; then
|
|
||||||
|
|
||||||
#=========== Ping to check the connectivity
|
|
||||||
echo "Checking $IP connetivity, max wait for 3 sec...."
|
|
||||||
ping -c 3 -W 3 $IP #> /dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$RED !!!!!!! $IP is not alive $NC"
|
|
||||||
else
|
|
||||||
#============ Get the raw data
|
|
||||||
rsync -avuht --progress $USR@$IP:$rawDataPath/$expName_* $MacRawDataPath/data/.
|
|
||||||
|
|
||||||
echo -e "$YELLOW======== rsync RunTimeStamp.dat $NC"
|
|
||||||
rsync -avuht --progress $USR@$IP:$rawDataPath/$RunTimeStamp* $MacRawDataPath/data/.
|
|
||||||
|
|
||||||
echo -e "$YELLOW======== rsync expName.sh $NC"
|
|
||||||
rsync -avuht --progress $USR@$IP:Analysis/working/expName.sh $SOLARISANADIR/working/.
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "$RED############### Only in SOLARIS MAC can donwload data. skip.$NC"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "$YELLOW=============================================$NC"
|
|
||||||
tail -10 $MacRawDataPath/data/RunTimeStamp.dat
|
|
||||||
echo -e "$YELLOW=============================================$NC"
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#just in case people put %03d as RUN
|
|
||||||
if [ "${RUN:0:2}" == "00" ]; then
|
|
||||||
RUN=${RUN:2:1}
|
|
||||||
elif [ "${RUN:0:1}" == "0" ]; then
|
|
||||||
RUN=${RUN:1:2}
|
|
||||||
else
|
|
||||||
RUN=$(printf '%d' $RUN)
|
|
||||||
fi
|
|
||||||
RUN=$(printf '%03d' ${RUN})
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
#################### Download raw data
|
|
||||||
echo -e "${RED}######################### Download raw data: run ${RUN}${NC}"
|
|
||||||
if [ ${PCID} -eq 2 ]; then
|
|
||||||
|
|
||||||
#=========== Ping to check the connectivity
|
|
||||||
echo "Checking $IP connetivity, max wait for 3 sec...."
|
|
||||||
ping -c 3 $IP -W 3 #> /dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo -e "$RED !!!!!!! $IP is not alive $NC"
|
|
||||||
else
|
|
||||||
#============ Get the raw data
|
|
||||||
echo -e "================= RUN $RUN: Get the raw data `date`"
|
|
||||||
|
|
||||||
rsync -avuht --progress $USR@$IP:$rawDataPath/$expName_$RUN* $MacRawDataPath/data/.
|
|
||||||
|
|
||||||
echo -e "$YELLOW======== rsync RunTimeStamp.dat $NC"
|
|
||||||
rsync -avuht --progress $USR@$IP:$rawDataPath/$RunTimeStamp* $MacRawDataPath/data/.
|
|
||||||
|
|
||||||
echo -e "$YELLOW======== rsync expName.sh $NC"
|
|
||||||
rsync -avuht --progress $USR@$IP:Analysis/working/expName.sh $SOLARISANADIR/working/.
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "$RED############### Only in SOLARIS MAC can donwload data. skip.$NC"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "$YELLOW=============================================$NC"
|
|
||||||
tail -10 $MacRawDataPath/data/RunTimeStamp.dat
|
|
||||||
echo -e "$YELLOW=============================================$NC"
|
|
||||||
|
|
||||||
count=`ls -1 $SOLARISANADIR/data_raw/${expName}_${RUN}_*.sol 2>/dev/null | wc -l`
|
|
||||||
echo -e "========== Number of Files : ${count}${NC}"
|
|
||||||
if [ ${count} -eq 0 ]; then
|
|
||||||
echo "============================================"
|
|
||||||
echo "==== RAW Files of RUN-${RUN} not found! "
|
|
||||||
echo "============================================"
|
|
||||||
|
|
||||||
isRunDataExist=false
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}"
|
|
||||||
du -hc $SOLARISANADIR/data_raw/${expName}_${RUN}_*.sol
|
|
||||||
echo -e "$NC============================================="
|
|
||||||
isRunDataExist=true
|
|
||||||
fi
|
|
|
@ -1,108 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -z $SOLARISANADIR ]; then
|
|
||||||
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."
|
|
||||||
echo "better add \"source <path_to_SOLARIS.sh>\" into .bashrc"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -ne 3 ] || [ $1 == "-help" ]; then
|
|
||||||
echo "$ Process_EventBuilder [RunNum] [EventBuild] [timeWin]"
|
|
||||||
echo " RunNum = run number"
|
|
||||||
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
|
||||||
echo " timeWin = number of tick for an event "
|
|
||||||
echo ""
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
RUN=$1
|
|
||||||
EventBld=$2
|
|
||||||
timeWin=$3
|
|
||||||
|
|
||||||
source ${SOLARISANADIR}/armory/Process_BasicConfig
|
|
||||||
source ${SOLARISANADIR}/working/expName.sh
|
|
||||||
|
|
||||||
runNum=${RUN#0} #remove zero
|
|
||||||
RUN=$(printf '%03d' $runNum) ##add back the zero
|
|
||||||
|
|
||||||
rawDataPath=$SOLARISANADIR/data_raw
|
|
||||||
rootDataPath=$SOLARISANADIR/root_data
|
|
||||||
|
|
||||||
rawDataPattern="$rawDataPath/${expName}_${RUN}_*.sol"
|
|
||||||
rootDataName="$rootDataPath/run$RUN.root"
|
|
||||||
|
|
||||||
dir=$(pwd)
|
|
||||||
cd ${SOLARISANADIR}/armory
|
|
||||||
make
|
|
||||||
cd ${dir}
|
|
||||||
|
|
||||||
#==== check raw data exist
|
|
||||||
isRawDataExist=`ls -1 ${rawDataPattern}* 2>/dev/null | wc -l`
|
|
||||||
|
|
||||||
if [ ! $isRawDataExist -gt 0 ]; then
|
|
||||||
echo -e "${LRED}################# Run Data $rawDataPattern not exist. Abort. ${NC}"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${CYAN} ============== list of files ${NC}"
|
|
||||||
\du -h ${rawDataPattern}*
|
|
||||||
|
|
||||||
totSize=$(\du -hc ${rawDataPattern}* | tail -n 1 | awk '{print $1}')
|
|
||||||
echo -e "${CYAN} ============== total file size : ${totSize}${NC}"
|
|
||||||
|
|
||||||
|
|
||||||
#==== check raw data timeStamp
|
|
||||||
if [ ${Arch} == "Linux" ]; then
|
|
||||||
rawDataTime=`stat -c "%Z" ${rawDataPattern}* | sort -rn | head -1`
|
|
||||||
else
|
|
||||||
rawDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rawDataPattern | sort -rn | head -1`
|
|
||||||
fi
|
|
||||||
|
|
||||||
#==== check if root data exist
|
|
||||||
isRootDataExist=`ls -1 $rootDataName 2>/dev/null | wc -l`
|
|
||||||
|
|
||||||
#==== if root data exist, check timeStamp
|
|
||||||
if [ ${isRootDataExist} -gt 0 ]; then
|
|
||||||
if [ ${Arch} == "Linux" ]; then
|
|
||||||
rootDataTime=`stat -c "%Z" $rootDataName | sort -rn | head -1`
|
|
||||||
else
|
|
||||||
rootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rootDataName | sort -rn | head -1`
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
rootDataTime=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ ${EventBld} -eq 0 ]; then
|
|
||||||
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building Skipped by user. ${NC}"
|
|
||||||
|
|
||||||
elif [ ${EventBld} -ge 1 ]; then
|
|
||||||
|
|
||||||
if [ ${rawDataTime} -ge ${rootDataTime} ]; then
|
|
||||||
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building $(date) ${NC}"
|
|
||||||
if [ ${EventBld} -eq 1 ]; then
|
|
||||||
EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern
|
|
||||||
elif [ ${EventBld} -eq 2 ]; then
|
|
||||||
EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern
|
|
||||||
fi
|
|
||||||
echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${GREEN} root data are newer than raw data. No need to merged again.${NC}"
|
|
||||||
echo -e "${GREEN} You can Force merging using option -${EventBld}, ${ORANGE} see ./process_run.sh -help${NC}"
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building Skipped. ${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>> Force Event Building $(date) ${NC}"
|
|
||||||
if [ ${EventBld} -eq -1 ]; then
|
|
||||||
EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern
|
|
||||||
elif [ ${EventBld} -eq -2 ]; then
|
|
||||||
EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern
|
|
||||||
fi
|
|
||||||
echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}"
|
|
||||||
|
|
||||||
fi
|
|
|
@ -1,96 +0,0 @@
|
||||||
#!/bin/bash -l
|
|
||||||
|
|
||||||
if [ -z $SOLARISANADIR ]; then
|
|
||||||
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."
|
|
||||||
echo "better add \"source <path_to_SOLARIS.sh>\" into .bashrc"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -le 2 ] || [ $1 == "-help" ]; then
|
|
||||||
echo "$./process_MultiRuns [RunNum1] [RunNum2] [EventBuild] [GeneralSort] [numMacTerminal]"
|
|
||||||
echo " RunNum1 = start run number"
|
|
||||||
echo " RunNum2 = stop run number"
|
|
||||||
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
|
||||||
echo " GeneralSort = n/0/-n || n = number of worker"
|
|
||||||
echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid"
|
|
||||||
echo " numMacTerminal = n ^ || in order to speed up in Mac "
|
|
||||||
echo " * negative option = force "
|
|
||||||
echo " ^ only for mac, and it will override GeneralSort to be 1 worker. "
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
|
|
||||||
runID1=$1
|
|
||||||
runID2=$2
|
|
||||||
buidEvt=$3
|
|
||||||
nWorker=0
|
|
||||||
traceMethod=0
|
|
||||||
nTerminal=0
|
|
||||||
|
|
||||||
if [ $# -ge 4 ]; then nWorker=$4; fi
|
|
||||||
if [ $# -ge 5 ]; then traceMethod=$5; fi
|
|
||||||
if [ $# -ge 6 ]; then nTerminal=$6; fi
|
|
||||||
|
|
||||||
source ${SOLARISANADIR}/armory/Process_BasicConfig
|
|
||||||
source ${SOLARISANADIR}/working/expName.sh
|
|
||||||
|
|
||||||
|
|
||||||
if [ $PCID -eq 2 ]; then
|
|
||||||
if [ $nTerminal -ge 2 ]; then
|
|
||||||
if [[ $nWorker -ge 0 ]]; then
|
|
||||||
nWorker=1;
|
|
||||||
else
|
|
||||||
nWorker=-1;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
$nTerminal=0;
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ $nTerminal -eq 0 ]; then
|
|
||||||
|
|
||||||
for i in $(seq $runID1 $runID2); do
|
|
||||||
Process_Run $i $buidEvt $nWorker $traceMethod 0
|
|
||||||
done
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
if [ $PCID -ne 2 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate the size of each segment
|
|
||||||
segment_size=$(( ($runID2 - $runID1 + 1) / $nTerminal ))
|
|
||||||
|
|
||||||
# Iterate through the segments
|
|
||||||
for i in $(seq 0 $(( $nTerminal - 1 ))); do
|
|
||||||
start=$(( $runID1 + ($i * $segment_size) ))
|
|
||||||
end=$(( $start + $segment_size - 1 ))
|
|
||||||
|
|
||||||
# Handle the last segment, which may be larger
|
|
||||||
if [[ $i -eq $(( $nTerminal - 1 )) ]]; then
|
|
||||||
end=$runID2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Segment $(( $i + 1 )): [$start, $end]"
|
|
||||||
|
|
||||||
profile_name="Homebrew"
|
|
||||||
width=700
|
|
||||||
height=500
|
|
||||||
x_pos=200
|
|
||||||
y_pos=200
|
|
||||||
|
|
||||||
osascript <<END_SCRIPT
|
|
||||||
tell application "Terminal"
|
|
||||||
activate
|
|
||||||
set newWindow to do script "cd $SOLARISANADIR/working; Process_MultiRuns $start $end $buidEvt $nWorker $traceMethod"
|
|
||||||
set current settings of newWindow to settings set "$profile_name"
|
|
||||||
set size of front window to { $width, $height }
|
|
||||||
set position of front window to { $x_pos + $(( $i * 100 )), $y_pos + $(( $i * 100 )) }
|
|
||||||
end tell
|
|
||||||
END_SCRIPT
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
|
@ -1,93 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
######## default time window = 100 tick
|
|
||||||
timeWin=100
|
|
||||||
|
|
||||||
if [ -z $SOLARISANADIR ]; then
|
|
||||||
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."
|
|
||||||
echo "better add \"source <path_to_SOLARIS.sh>\" into .bashrc"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
|
||||||
echo "$ Process_Run [RunNum] [EventBuild] [GeneralSort] [TraceMethod] [Monitor]"
|
|
||||||
echo " RunNum = run number / \"lastRun\" "
|
|
||||||
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
|
||||||
echo " GeneralSort = n/0/-n || n = number of worker"
|
|
||||||
echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid(not implemented)"
|
|
||||||
echo " Monitor = 2/1/0 || 1 = single run, 2 = using the list in ChainMonitors.C"
|
|
||||||
echo ""
|
|
||||||
echo " * negative option = force (except for TraceMethod and Monitor)."
|
|
||||||
echo " * Defult timeWindow for Event builder is 100 tick = 800 ns."
|
|
||||||
echo ""
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
RUN=$1
|
|
||||||
runNum=$1
|
|
||||||
EventBld=2
|
|
||||||
nWorker=1
|
|
||||||
TraceMethod=-1
|
|
||||||
isMonitor=1
|
|
||||||
|
|
||||||
if [ $# -ge 2 ]; then EventBld=$2; fi
|
|
||||||
if [ $# -ge 3 ]; then nWorker=$3; fi
|
|
||||||
if [ $# -ge 4 ]; then TraceMethod=$4; fi
|
|
||||||
if [ $# -ge 5 ]; then isMonitor=$5; fi
|
|
||||||
|
|
||||||
if [ "$RUN" == "lastRun" ]; then
|
|
||||||
RUN=$runID
|
|
||||||
fi
|
|
||||||
|
|
||||||
RUN=${RUN##*(0)} #remove zero
|
|
||||||
RUN=$(printf '%03d' $RUN) ##add back the zero
|
|
||||||
|
|
||||||
################################### Setting display
|
|
||||||
echo "#################################################"
|
|
||||||
echo "### Process_Run #####"
|
|
||||||
echo "#################################################"
|
|
||||||
echo "### RunID : ${RUN}"
|
|
||||||
echo "### Event Builder : $EventBld"
|
|
||||||
echo "### General Sort : $nWorker worker(s)"
|
|
||||||
echo "### Trace Method : $TraceMethod"
|
|
||||||
echo "### Monitor : $isMonitor"
|
|
||||||
echo "#################################################"
|
|
||||||
|
|
||||||
source ${SOLARISANADIR}/armory/Process_BasicConfig
|
|
||||||
source ${SOLARISANADIR}/working/expName.sh
|
|
||||||
|
|
||||||
if [ "$PWD" != "${SOLARISANADIR}/working" ]; then
|
|
||||||
echo "============= go to the Working directory"
|
|
||||||
cd "${SOLARISANADIR}/working"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#################################### CHECK IS RUN DATA EXIST
|
|
||||||
isRunDataExist=true
|
|
||||||
|
|
||||||
#################################### EVENT BUILDER
|
|
||||||
source Process_Download $RUN
|
|
||||||
|
|
||||||
if [ $isRunDataExist ]; then
|
|
||||||
source Process_EventBuilder $RUN $EventBld $timeWin
|
|
||||||
fi
|
|
||||||
|
|
||||||
#################################### GeneralSort
|
|
||||||
|
|
||||||
if [ $isRunDataExist ]; then
|
|
||||||
source Process_Sort $RUN $nWorker $TraceMethod
|
|
||||||
fi
|
|
||||||
#################################### Monitor
|
|
||||||
|
|
||||||
if [ $isMonitor -eq 0 ]; then
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Monitor Skipped by user. ${NC}"
|
|
||||||
elif [ $isMonitor -eq 1 ]; then
|
|
||||||
root -l "ChainMonitors.C($RUN)"
|
|
||||||
elif [ $isMonitor -eq 2 ]; then
|
|
||||||
root -l "ChainMonitors.C"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
#!/bin/bash -l
|
|
||||||
|
|
||||||
if [ -z $SOLARISANADIR ]; then
|
|
||||||
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."
|
|
||||||
echo "better add \"source <path_to_SOLARIS.sh>\" into .bashrc"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
|
||||||
echo "$ Process_Sort [RunNum] [GeneralSort] [TraceMethod]"
|
|
||||||
echo " RunNum = run number"
|
|
||||||
echo " GeneralSort = n/0/-n || n = number of worker"
|
|
||||||
echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid"
|
|
||||||
echo ""
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
RUN=$1
|
|
||||||
nWorker=$2
|
|
||||||
TraceMethod=$3
|
|
||||||
|
|
||||||
source $SOLARISANADIR/armory/Process_BasicConfig
|
|
||||||
source $SOLARISANADIR/working/expName.sh
|
|
||||||
|
|
||||||
runNum=${RUN#0} #remove zero
|
|
||||||
RUN=$(printf '%03d' $runNum) ##add back the zero
|
|
||||||
|
|
||||||
if [ ${nWorker} -eq 0 ]; then
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> GeneralSort Skipped by user. ${NC}"
|
|
||||||
else
|
|
||||||
source $ROOTSYS/bin/thisroot.sh
|
|
||||||
|
|
||||||
#--------- Check is runXXX.root exist
|
|
||||||
rootDataPath=$SOLARISANADIR/root_data
|
|
||||||
rootDataName="$rootDataPath/run$RUN.root"
|
|
||||||
isRootDataExist=`ls -1 $rootDataName 2>/dev/null | wc -l`
|
|
||||||
|
|
||||||
#==== if root data exist, check timeStamp
|
|
||||||
if [ $isRootDataExist -gt 0 ]; then
|
|
||||||
if [ ${Arch} == "Linux" ]; then
|
|
||||||
rootDataTime=`stat -c "%Z" $rootDataName | sort -rn | head -1`
|
|
||||||
else
|
|
||||||
rootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rootDataName | sort -rn | head -1`
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
rootDataTime=0
|
|
||||||
echo -e "$LRED ################# run$RUN.root does not exist. Abort. $NC"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------- check gen_root timestamp
|
|
||||||
genRootDataName="$rootDataPath/gen_run$RUN.root"
|
|
||||||
isGenRootDataExist=`ls -1 $genRootDataName 2>/dev/null | wc -l`
|
|
||||||
|
|
||||||
#----- if gen_runXXX.data exist, check timeStamp
|
|
||||||
if [ $isGenRootDataExist -gt 0 ]; then
|
|
||||||
if [ ${Arch} == "Linux" ]; then
|
|
||||||
genRootDataTime=`stat -c "%Z" $genRootDataName | sort -rn | head -1`
|
|
||||||
else
|
|
||||||
genRootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $genRootDataName | sort -rn | head -1`
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
genRootDataTime=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p ~/.proof/working
|
|
||||||
cp ${SOLARISANADIR}/working/Mapping.h ~/.proof/working/.
|
|
||||||
|
|
||||||
if [ $nWorker -le -1 ]; then
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>> Force GeneralSort $(date) ${NC}"
|
|
||||||
root -l -q -b "$SOLARISANADIR/armory/GeneralSortAgent.C($runNum, $nWorker, $TraceMethod)"
|
|
||||||
echo -e "${LRED}<<<<<<<<<<<<<<<< Done GeneralSort $(date) ${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $nWorker -ge 1 ]; then
|
|
||||||
|
|
||||||
if [ $rootDataTime -ge $genRootDataTime ]; then
|
|
||||||
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> GeneralSort $(date) ${NC}"
|
|
||||||
root -l -q -b "$SOLARISANADIR/armory/GeneralSortAgent.C($runNum, $nWorker, $TraceMethod)"
|
|
||||||
echo -e "${LRED}<<<<<<<<<<<<<<<< Done GeneralSort $(date) ${NC}"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${GREEN} gen_run$RUN.root is newer than run$RUN.root. No need to GeneralSort again.${NC}"
|
|
||||||
echo -e "${GREEN} You can Force GeneralSort using option -${nWorker}, ${ORANGE} see Process_Run -help${NC}"
|
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> GeneralSort Skipped. ${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
|
@ -1,258 +0,0 @@
|
||||||
#ifndef SOLREADER_H
|
|
||||||
#define SOLREADER_H
|
|
||||||
|
|
||||||
#include <stdio.h> /// for FILE
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h> // time in nano-sec
|
|
||||||
|
|
||||||
#include "Hit.h"
|
|
||||||
|
|
||||||
class SolReader {
|
|
||||||
private:
|
|
||||||
FILE * inFile;
|
|
||||||
unsigned int inFileSize;
|
|
||||||
unsigned int filePos;
|
|
||||||
unsigned int totNumBlock;
|
|
||||||
|
|
||||||
unsigned short blockStartIdentifier;
|
|
||||||
unsigned int numBlock;
|
|
||||||
bool isScanned;
|
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
std::vector<unsigned int> blockPos;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SolReader();
|
|
||||||
SolReader(std::string fileName, unsigned short dataType);
|
|
||||||
~SolReader();
|
|
||||||
|
|
||||||
void OpenFile(std::string fileName);
|
|
||||||
int ReadNextBlock(int isSkip = 0); // opt = 0, noraml, 1, fast
|
|
||||||
int ReadBlock(unsigned int index, bool verbose = false);
|
|
||||||
|
|
||||||
void ScanNumBlock();
|
|
||||||
|
|
||||||
bool IsEndOfFile() const {return (filePos >= inFileSize ? true : false);}
|
|
||||||
unsigned int GetBlockID() const {return numBlock - 1;}
|
|
||||||
unsigned int GetNumBlock() const {return numBlock;}
|
|
||||||
unsigned int GetTotalNumBlock() const {return totNumBlock;}
|
|
||||||
unsigned int GetFilePos() const {return filePos;}
|
|
||||||
unsigned int GetFileSize() const {return inFileSize;}
|
|
||||||
|
|
||||||
void RewindFile();
|
|
||||||
|
|
||||||
Hit * hit;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void SolReader::init(){
|
|
||||||
inFileSize = 0;
|
|
||||||
numBlock = 0;
|
|
||||||
filePos = 0;
|
|
||||||
totNumBlock = 0;
|
|
||||||
hit = new Hit();
|
|
||||||
|
|
||||||
isScanned = false;
|
|
||||||
|
|
||||||
blockPos.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SolReader::SolReader(){
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
|
|
||||||
init();
|
|
||||||
OpenFile(fileName);
|
|
||||||
hit->SetDataType(dataType, DPPType::PHA);
|
|
||||||
}
|
|
||||||
|
|
||||||
SolReader::~SolReader(){
|
|
||||||
if( !inFile ) fclose(inFile);
|
|
||||||
delete hit;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SolReader::OpenFile(std::string fileName){
|
|
||||||
inFile = fopen(fileName.c_str(), "r");
|
|
||||||
if( inFile == NULL ){
|
|
||||||
printf("Cannot open file : %s \n", fileName.c_str());
|
|
||||||
}else{
|
|
||||||
fseek(inFile, 0L, SEEK_END);
|
|
||||||
inFileSize = ftell(inFile);
|
|
||||||
rewind(inFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SolReader::ReadBlock(unsigned int index, bool verbose){
|
|
||||||
if( isScanned == false) return -1;
|
|
||||||
if( index >= totNumBlock )return -1;
|
|
||||||
fseek(inFile, 0L, SEEK_SET);
|
|
||||||
|
|
||||||
if( verbose ) printf("Block index: %u, File Pos: %u byte\n", index, blockPos[index]);
|
|
||||||
|
|
||||||
fseek(inFile, blockPos[index], SEEK_CUR);
|
|
||||||
|
|
||||||
filePos = blockPos[index];
|
|
||||||
|
|
||||||
numBlock = index;
|
|
||||||
|
|
||||||
return ReadNextBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SolReader::ReadNextBlock(int isSkip){
|
|
||||||
if( inFile == NULL ) return -1;
|
|
||||||
if( feof(inFile) ) return -1;
|
|
||||||
if( filePos >= inFileSize) return -1;
|
|
||||||
|
|
||||||
fread(&blockStartIdentifier, 2, 1, inFile);
|
|
||||||
|
|
||||||
if( (blockStartIdentifier & 0xAA00) != 0xAA00 ) {
|
|
||||||
printf("header fail.\n");
|
|
||||||
return -2 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( blockStartIdentifier & 0xF ) == DataFormat::Raw ){
|
|
||||||
hit->SetDataType(DataFormat::Raw, ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD);
|
|
||||||
}
|
|
||||||
hit->dataType = blockStartIdentifier & 0xF;
|
|
||||||
hit->DPPType = ((blockStartIdentifier >> 4) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD;
|
|
||||||
|
|
||||||
if( hit->dataType == DataFormat::ALL){
|
|
||||||
if( isSkip == 0 ){
|
|
||||||
fread(&hit->channel, 1, 1, inFile);
|
|
||||||
fread(&hit->energy, 2, 1, inFile);
|
|
||||||
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
|
|
||||||
fread(&hit->timestamp, 6, 1, inFile);
|
|
||||||
fread(&hit->fine_timestamp, 2, 1, inFile);
|
|
||||||
fread(&hit->flags_high_priority, 1, 1, inFile);
|
|
||||||
fread(&hit->flags_low_priority, 2, 1, inFile);
|
|
||||||
fread(&hit->downSampling, 1, 1, inFile);
|
|
||||||
fread(&hit->board_fail, 1, 1, inFile);
|
|
||||||
fread(&hit->flush, 1, 1, inFile);
|
|
||||||
fread(&hit->trigger_threashold, 2, 1, inFile);
|
|
||||||
fread(&hit->event_size, 8, 1, inFile);
|
|
||||||
fread(&hit->aggCounter, 4, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR);
|
|
||||||
}
|
|
||||||
fread(&hit->traceLenght, 8, 1, inFile);
|
|
||||||
if( isSkip == 0){
|
|
||||||
fread(hit->analog_probes_type, 2, 1, inFile);
|
|
||||||
fread(hit->digital_probes_type, 4, 1, inFile);
|
|
||||||
fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
|
|
||||||
fread(hit->analog_probes[1], hit->traceLenght*4, 1, inFile);
|
|
||||||
fread(hit->digital_probes[0], hit->traceLenght, 1, inFile);
|
|
||||||
fread(hit->digital_probes[1], hit->traceLenght, 1, inFile);
|
|
||||||
fread(hit->digital_probes[2], hit->traceLenght, 1, inFile);
|
|
||||||
fread(hit->digital_probes[3], hit->traceLenght, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, 6 + hit->traceLenght*(12), SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if( hit->dataType == DataFormat::OneTrace){
|
|
||||||
if( isSkip == 0 ){
|
|
||||||
fread(&hit->channel, 1, 1, inFile);
|
|
||||||
fread(&hit->energy, 2, 1, inFile);
|
|
||||||
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
|
|
||||||
fread(&hit->timestamp, 6, 1, inFile);
|
|
||||||
fread(&hit->fine_timestamp, 2, 1, inFile);
|
|
||||||
fread(&hit->flags_high_priority, 1, 1, inFile);
|
|
||||||
fread(&hit->flags_low_priority, 2, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
|
|
||||||
}
|
|
||||||
fread(&hit->traceLenght, 8, 1, inFile);
|
|
||||||
if( isSkip == 0){
|
|
||||||
fread(&hit->analog_probes_type[0], 1, 1, inFile);
|
|
||||||
fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, 1 + hit->traceLenght*4, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if( hit->dataType == DataFormat::NoTrace){
|
|
||||||
if( isSkip == 0 ){
|
|
||||||
fread(&hit->channel, 1, 1, inFile);
|
|
||||||
fread(&hit->energy, 2, 1, inFile);
|
|
||||||
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
|
|
||||||
fread(&hit->timestamp, 6, 1, inFile);
|
|
||||||
fread(&hit->fine_timestamp, 2, 1, inFile);
|
|
||||||
fread(&hit->flags_high_priority, 1, 1, inFile);
|
|
||||||
fread(&hit->flags_low_priority, 2, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if( hit->dataType == DataFormat::MiniWithFineTime){
|
|
||||||
if( isSkip == 0 ){
|
|
||||||
fread(&hit->channel, 1, 1, inFile);
|
|
||||||
fread(&hit->energy, 2, 1, inFile);
|
|
||||||
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
|
|
||||||
fread(&hit->timestamp, 6, 1, inFile);
|
|
||||||
fread(&hit->fine_timestamp, 2, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->DPPType == DPPType::PHA ? 11 : 13, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if( hit->dataType == DataFormat::Minimum){
|
|
||||||
if( isSkip == 0 ){
|
|
||||||
fread(&hit->channel, 1, 1, inFile);
|
|
||||||
fread(&hit->energy, 2, 1, inFile);
|
|
||||||
if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
|
|
||||||
fread(&hit->timestamp, 6, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if( hit->dataType == DataFormat::Raw){
|
|
||||||
fread(&hit->dataSize, 8, 1, inFile);
|
|
||||||
if( isSkip == 0){
|
|
||||||
fread(hit->data, hit->dataSize, 1, inFile);
|
|
||||||
}else{
|
|
||||||
fseek(inFile, hit->dataSize, SEEK_CUR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
numBlock ++;
|
|
||||||
filePos = ftell(inFile);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SolReader::RewindFile(){
|
|
||||||
rewind(inFile);
|
|
||||||
filePos = 0;
|
|
||||||
numBlock = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SolReader::ScanNumBlock(){
|
|
||||||
if( inFile == NULL ) return;
|
|
||||||
if( feof(inFile) ) return;
|
|
||||||
|
|
||||||
numBlock = 0;
|
|
||||||
blockPos.clear();
|
|
||||||
|
|
||||||
blockPos.push_back(0);
|
|
||||||
|
|
||||||
while( ReadNextBlock(1) == 0){
|
|
||||||
blockPos.push_back(filePos);
|
|
||||||
printf("%u, %.2f%% %u/%u\n\033[A\r", numBlock, filePos*100./inFileSize, filePos, inFileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
totNumBlock = numBlock;
|
|
||||||
numBlock = 0;
|
|
||||||
isScanned = true;
|
|
||||||
printf("\nScan complete: number of data Block : %u\n", totNumBlock);
|
|
||||||
rewind(inFile);
|
|
||||||
filePos = 0;
|
|
||||||
|
|
||||||
//for( int i = 0; i < totNumBlock; i++){
|
|
||||||
// printf("%7d | %u \n", i, blockPos[i]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,144 +0,0 @@
|
||||||
#include <TROOT.h>
|
|
||||||
#include <TChain.h>
|
|
||||||
#include <TStyle.h>
|
|
||||||
#include <TSystem.h>
|
|
||||||
#include <TFile.h>
|
|
||||||
#include <TSelector.h>
|
|
||||||
#include <TCanvas.h>
|
|
||||||
#include <TGraph.h>
|
|
||||||
#include <TClonesArray.h>
|
|
||||||
#include <TBenchmark.h>
|
|
||||||
#include <TMath.h>
|
|
||||||
#include <TLatex.h>
|
|
||||||
#include <TF1.h>
|
|
||||||
#include <TLine.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "../working/Mapping.h"
|
|
||||||
|
|
||||||
void readRawTrace(TString fileName, int minDetID = 0, int maxDetID = 1000){
|
|
||||||
|
|
||||||
/**///==============================================================
|
|
||||||
|
|
||||||
TFile * f1 = new TFile (fileName, "read");
|
|
||||||
TTree * tree = (TTree *) f1->Get("tree");
|
|
||||||
|
|
||||||
if( tree == NULL ) {
|
|
||||||
printf("===== Are you using gen_runXXX.root ? please use runXXX.root\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int totnumEntry = tree->GetEntries();
|
|
||||||
printf( "========== total Entry : %d \n", totnumEntry);
|
|
||||||
|
|
||||||
TCanvas * cRead = new TCanvas("cRead", "Read Raw Trace", 0, 1500, 800, 300);
|
|
||||||
cRead->Divide(1,1);
|
|
||||||
for( int i = 1; i <= 2 ; i++){
|
|
||||||
cRead->cd(i)->SetGrid();
|
|
||||||
}
|
|
||||||
cRead->SetGrid();
|
|
||||||
|
|
||||||
gStyle->SetOptFit(0);
|
|
||||||
|
|
||||||
/**///==============================================================
|
|
||||||
Int_t bd[200];
|
|
||||||
Int_t ch[200];
|
|
||||||
Int_t numHit;
|
|
||||||
Int_t trace[200][2500];
|
|
||||||
Int_t traceLength[200];
|
|
||||||
tree->SetBranchAddress("bd", bd);
|
|
||||||
tree->SetBranchAddress("ch", ch);
|
|
||||||
tree->SetBranchAddress("multi", &numHit);
|
|
||||||
tree->SetBranchAddress("trace", trace);
|
|
||||||
tree->SetBranchAddress("tl", traceLength);
|
|
||||||
|
|
||||||
TLatex text ;
|
|
||||||
text.SetNDC();
|
|
||||||
text.SetTextFont(62);
|
|
||||||
text.SetTextSize(0.06);
|
|
||||||
text.SetTextColor(2);
|
|
||||||
|
|
||||||
bool breakFlag = false;
|
|
||||||
bool lastEvFlag = false;
|
|
||||||
std::vector<int> oldEv;
|
|
||||||
int evPointer = 0;
|
|
||||||
|
|
||||||
TGraph * graph = new TGraph();
|
|
||||||
|
|
||||||
for( int ev = 0; ev < totnumEntry; ev++){
|
|
||||||
|
|
||||||
if( lastEvFlag ) {
|
|
||||||
ev = oldEv[evPointer];
|
|
||||||
lastEvFlag = false;
|
|
||||||
}
|
|
||||||
tree->GetEntry(ev);
|
|
||||||
|
|
||||||
int countJ = 0;
|
|
||||||
|
|
||||||
for( int j = 0; j < numHit ; j++){
|
|
||||||
|
|
||||||
int detID = mapping[bd[j]][ch[j]];
|
|
||||||
|
|
||||||
if( !(minDetID <= detID && detID <= maxDetID ) ) continue;
|
|
||||||
|
|
||||||
if( countJ == 0 ) printf("-------------------------------- ev : %d, evPointer : %d| num Trace : %d\n", ev, evPointer, numHit);
|
|
||||||
|
|
||||||
printf("nHit: %d, id : %d, trace Length : %u ( enter = next , q = stop, w = last)\n", j, detID, traceLength[j]);
|
|
||||||
|
|
||||||
graph->Clear();
|
|
||||||
graph->Set(traceLength[j]);
|
|
||||||
for( int k = 0; k < traceLength[j] ; k++){
|
|
||||||
graph->SetPoint(k, k, trace[j][k]);
|
|
||||||
//printf("%4d, %5d |", k, trace[j][k]);
|
|
||||||
//if( k % 10 ==0 ) printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
graph->SetTitle(Form("ev: %d, nHit : %d, id : %d, trace Length : %u\n", ev, j, detID, traceLength[j]));
|
|
||||||
|
|
||||||
cRead->cd(1);
|
|
||||||
cRead->Clear();
|
|
||||||
graph->Draw("Al");
|
|
||||||
//g->GetXaxis()->SetRangeUser(0, g->GetN());
|
|
||||||
//g->GetYaxis()->SetRangeUser(7500, 35000);
|
|
||||||
|
|
||||||
cRead->Update();
|
|
||||||
gSystem->ProcessEvents();
|
|
||||||
|
|
||||||
|
|
||||||
char s[80];
|
|
||||||
fgets(s, sizeof s, stdin);
|
|
||||||
|
|
||||||
if( s[0] == 113 ) { // 'q' = 113
|
|
||||||
breakFlag = true;
|
|
||||||
break;
|
|
||||||
}else if( s[0] == 119 ) { // 'w' = 119
|
|
||||||
|
|
||||||
if( j > 0 || countJ > 0 ) {
|
|
||||||
j = j - 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (j == 0 && (int)oldEv.size() >= 0 && evPointer > 0 ) || countJ == 0 ) {
|
|
||||||
if( evPointer > 0 ) evPointer --;
|
|
||||||
if( evPointer == 0 ) printf(" the first event!!! \n");
|
|
||||||
lastEvFlag = true;
|
|
||||||
//printf(" ev : %d, evPt : %d \n", oldEv[evPointer], evPointer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
countJ ++;
|
|
||||||
|
|
||||||
}
|
|
||||||
if( breakFlag ) break;
|
|
||||||
|
|
||||||
if( lastEvFlag == false && countJ > 0 ){
|
|
||||||
if( oldEv.size() == evPointer ) oldEv.push_back(ev);
|
|
||||||
evPointer ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//gROOT->ProcessLine(".q");
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,171 +0,0 @@
|
||||||
#include <TROOT.h>
|
|
||||||
#include <TChain.h>
|
|
||||||
#include <TStyle.h>
|
|
||||||
#include <TSystem.h>
|
|
||||||
#include <TFile.h>
|
|
||||||
#include <TSelector.h>
|
|
||||||
#include <TCanvas.h>
|
|
||||||
#include <TGraph.h>
|
|
||||||
#include <TClonesArray.h>
|
|
||||||
#include <TBenchmark.h>
|
|
||||||
#include <TMath.h>
|
|
||||||
#include <TLatex.h>
|
|
||||||
#include <TF1.h>
|
|
||||||
#include <TLine.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
void readTrace(TString fileName, int minDetID = 0, int maxDetID = 1000, bool isGoodOnly = false){
|
|
||||||
|
|
||||||
/**///==============================================================
|
|
||||||
|
|
||||||
TFile * f1 = new TFile (fileName, "read");
|
|
||||||
TTree * tree = (TTree *) f1->Get("gen_tree");
|
|
||||||
|
|
||||||
int totnumEntry = tree->GetEntries();
|
|
||||||
printf( "========== total Entry : %d \n", totnumEntry);
|
|
||||||
|
|
||||||
TCanvas * cRead = new TCanvas("cRead", "Read Trace", 0, 1500, 800, 300);
|
|
||||||
cRead->Divide(1,1);
|
|
||||||
for( int i = 1; i <= 2 ; i++){
|
|
||||||
cRead->cd(i)->SetGrid();
|
|
||||||
}
|
|
||||||
cRead->SetGrid();
|
|
||||||
|
|
||||||
gStyle->SetOptFit(0);
|
|
||||||
|
|
||||||
/**///==============================================================
|
|
||||||
TClonesArray * arr = new TClonesArray("TGraph");
|
|
||||||
tree->SetBranchAddress("trace", &arr);
|
|
||||||
|
|
||||||
//TODO UP-Down arrow for pervious-next control
|
|
||||||
TLine timeVLine;
|
|
||||||
|
|
||||||
TLatex text ;
|
|
||||||
text.SetNDC();
|
|
||||||
text.SetTextFont(62);
|
|
||||||
text.SetTextSize(0.06);
|
|
||||||
text.SetTextColor(2);
|
|
||||||
|
|
||||||
bool breakFlag = false;
|
|
||||||
bool lastEvFlag = false;
|
|
||||||
std::vector<int> oldEv;
|
|
||||||
int evPointer = 0;
|
|
||||||
|
|
||||||
for( int ev = 0; ev < totnumEntry; ev++){
|
|
||||||
|
|
||||||
if( lastEvFlag ) {
|
|
||||||
ev = oldEv[evPointer];
|
|
||||||
lastEvFlag = false;
|
|
||||||
}
|
|
||||||
tree->GetEntry(ev);
|
|
||||||
|
|
||||||
int nTrace = arr->GetEntriesFast();
|
|
||||||
|
|
||||||
int countJ = 0;
|
|
||||||
|
|
||||||
for( int j = 0; j < nTrace ; j++){
|
|
||||||
|
|
||||||
TGraph * g = (TGraph*) arr->At(j);
|
|
||||||
|
|
||||||
TString gTitle;
|
|
||||||
gTitle = g->GetTitle();
|
|
||||||
///printf("TGraph Title : %s\n", gTitle.Data());
|
|
||||||
|
|
||||||
int detID = 0;
|
|
||||||
int pos = gTitle.Index("id:");
|
|
||||||
gTitle.Remove(0, pos+3);
|
|
||||||
gTitle.Remove(3);
|
|
||||||
detID = gTitle.Atoi();
|
|
||||||
|
|
||||||
if( !(minDetID <= detID && detID <= maxDetID ) ) continue;
|
|
||||||
|
|
||||||
if( countJ == 0 ) printf("-------------------------------- ev : %d, evPointer : %d| num Trace : %d\n", ev, evPointer, nTrace);
|
|
||||||
|
|
||||||
|
|
||||||
TF1 * gFit = (TF1 *) g->FindObject("gFit");
|
|
||||||
|
|
||||||
TString kTitle;
|
|
||||||
|
|
||||||
if( gFit != NULL ){
|
|
||||||
double base, time = 0, riseTime, energy, chiSq;
|
|
||||||
energy = gFit->GetParameter(0);
|
|
||||||
time = gFit->GetParameter(1);
|
|
||||||
riseTime = gFit->GetParameter(2);
|
|
||||||
base = gFit->GetParameter(3);
|
|
||||||
chiSq = gFit->GetChisquare()/gFit->GetNDF();
|
|
||||||
int kind = gFit->GetLineColor();
|
|
||||||
int det = gFit->GetLineStyle();
|
|
||||||
|
|
||||||
///if( !(minDetID <= det && det <= maxDetID ) ) continue;
|
|
||||||
|
|
||||||
if( isGoodOnly){
|
|
||||||
if( abs(energy) < 1.5* g->GetRMS(2) ) continue;
|
|
||||||
if( time > gFit->GetXmax() || time < gFit->GetXmin()) continue;
|
|
||||||
if( time > 200 || time < 20) continue;
|
|
||||||
if( riseTime > gFit->GetXmax()/7. || riseTime < 0 ) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if( energy < 400 ) continue;
|
|
||||||
|
|
||||||
kTitle = Form("(%3d,%d), base: %8.1f, rise: %6.2f, time: %6.1f, energy: %8.1f | chi2: %8.1f, RMS: %6.1f",
|
|
||||||
det, kind, base, riseTime, time, energy, chiSq, g->GetRMS(2));
|
|
||||||
|
|
||||||
printf("%s |(q = break, w = last one)", kTitle.Data());
|
|
||||||
|
|
||||||
|
|
||||||
timeVLine.SetX1(time);
|
|
||||||
timeVLine.SetX2(time);
|
|
||||||
timeVLine.SetY1(-1000);
|
|
||||||
timeVLine.SetY2(20000);
|
|
||||||
timeVLine.SetLineColor(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
cRead->cd(1);
|
|
||||||
//cRead->Clear();
|
|
||||||
g->Draw("AC");
|
|
||||||
//g->GetXaxis()->SetRangeUser(0, g->GetN());
|
|
||||||
//g->GetYaxis()->SetRangeUser(7500, 35000);
|
|
||||||
timeVLine.Draw("same");
|
|
||||||
if( gFit != NULL ) text.DrawText(0.11, 0.85, kTitle.Data());
|
|
||||||
|
|
||||||
cRead->Update();
|
|
||||||
gSystem->ProcessEvents();
|
|
||||||
|
|
||||||
|
|
||||||
char s[80];
|
|
||||||
fgets(s, sizeof s, stdin);
|
|
||||||
|
|
||||||
if( s[0] == 113 ) { // 'q' = 113
|
|
||||||
breakFlag = true;
|
|
||||||
break;
|
|
||||||
}else if( s[0] == 119 ) { // 'w' = 119
|
|
||||||
|
|
||||||
if( j > 0 || countJ > 0 ) {
|
|
||||||
j = j - 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (j == 0 && (int)oldEv.size() >= 0 && evPointer > 0 ) || countJ == 0 ) {
|
|
||||||
if( evPointer > 0 ) evPointer --;
|
|
||||||
if( evPointer == 0 ) printf(" the first event!!! \n");
|
|
||||||
lastEvFlag = true;
|
|
||||||
//printf(" ev : %d, evPt : %d \n", oldEv[evPointer], evPointer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
countJ ++;
|
|
||||||
|
|
||||||
}
|
|
||||||
if( breakFlag ) break;
|
|
||||||
|
|
||||||
if( lastEvFlag == false && countJ > 0 ){
|
|
||||||
if( oldEv.size() == evPointer ) oldEv.push_back(ev);
|
|
||||||
evPointer ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//gROOT->ProcessLine(".q");
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user