create namespace for Mapping.h, move all mapping related function to mapping.h
This commit is contained in:
parent
b8d4f5875a
commit
63fd4687a4
|
@ -5,64 +5,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#include <TMacro.h>
|
#include <TMacro.h>
|
||||||
|
#include <TList.h>
|
||||||
|
|
||||||
int FindDetType(int detID, std::vector<int> detMaxID){
|
|
||||||
for( int k = 0; k < (int) detMaxID.size(); k++){
|
|
||||||
int low = (k == 0 ? 0 : detMaxID[k-1]);
|
|
||||||
int high = detMaxID[k];
|
|
||||||
if( low <= detID && detID < high ) {
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> ExtractDetNum(std::vector<std::vector<int>> mapping, std::vector<std::string> detTypeName, std::vector<int> detMaxID){
|
|
||||||
std::vector<int> detTypeNum;
|
|
||||||
for( int i = 0; i < (int) detTypeName.size(); i ++) detTypeNum.push_back(0);
|
|
||||||
for( int i = 0; i < (int) mapping.size(); i ++){
|
|
||||||
for( int j = 0; j < (int) mapping[i].size(); j++){
|
|
||||||
if( mapping[i][j] < 0) continue;
|
|
||||||
for( int k = 0; k < (int) detTypeName.size() ; k ++ ){
|
|
||||||
int low = (k == 0 ? 0 : detMaxID[k-1]);
|
|
||||||
int high = detMaxID[k];
|
|
||||||
if( low <= mapping[i][j] && mapping[i][j] < high ) {
|
|
||||||
detTypeNum[k]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return detTypeNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintMapping(std::vector<std::vector<int>> mapping, std::vector<std::string> detTypeName, std::vector<int> detMaxID){
|
|
||||||
|
|
||||||
//------------ Red Green Yellow Cyan blue Magenta Gray
|
|
||||||
std::vector<const char* > Color = {"\033[31m", "\033[32m", "\033[33m", "\033[36m", "\033[34m", "\033[35m", "\033[37m"};
|
|
||||||
|
|
||||||
printf("==================================== Mapping ===================================\n");
|
|
||||||
std::vector<int> detTypeNum = ExtractDetNum(mapping, detTypeName, detMaxID);
|
|
||||||
for(int i = 0 ; i < (int) detTypeName.size(); i++) {
|
|
||||||
printf(" %2d | %7s | %3d | %3d - %3d\n", i, detTypeName[i].c_str(), detTypeNum[i], (i == 0 ? 0 : detMaxID[i-1]), detMaxID[i]);
|
|
||||||
}
|
|
||||||
for( int i = 0; i < (int) mapping.size(); i++){
|
|
||||||
printf("Digi-%d ------------------------------------------------------------------------ \n", i);
|
|
||||||
for( int j = 0; j < (int) mapping[i].size(); j++){
|
|
||||||
if( mapping[i][j] < 0 ){
|
|
||||||
printf("%4d,", mapping[i][j]);
|
|
||||||
}else{
|
|
||||||
int colorIndex = FindDetType(mapping[i][j], detMaxID);
|
|
||||||
printf("%s%4d\033[0m,", Color[colorIndex], mapping[i][j]);
|
|
||||||
}
|
|
||||||
if( j % 16 == 15 ) printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("================================================================================\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct DetGeo{
|
struct DetGeo{
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ void printEvent(){
|
||||||
//^##################################################################################
|
//^##################################################################################
|
||||||
int main(int argc, char ** argv){
|
int main(int argc, char ** argv){
|
||||||
|
|
||||||
printf("=====================================\n");
|
printf("=======================================================\n");
|
||||||
printf("=== sol --> root ===\n");
|
printf("=== SOLARIS Event Builder sol --> root ===\n");
|
||||||
printf("=====================================\n");
|
printf("=======================================================\n");
|
||||||
|
|
||||||
if( argc <= 3){
|
if( argc <= 3){
|
||||||
printf("%s [outfile] [timeWindow] [saveTrace] [sol-1] [sol-2] ... \n", argv[0]);
|
printf("%s [outfile] [timeWindow] [saveTrace] [sol-1] [sol-2] ... \n", argv[0]);
|
||||||
|
@ -318,11 +318,10 @@ int main(int argc, char ** argv){
|
||||||
|
|
||||||
unsigned int numBlock = 0;
|
unsigned int numBlock = 0;
|
||||||
for( int i = 0; i < nFile; i++){
|
for( int i = 0; i < nFile; i++){
|
||||||
printf("%d | %8ld | %10u/%10u\n", i, reader[i]->GetBlockID() + 1, reader[i]->GetFilePos(), reader[i]->GetFileSize());
|
//printf("%d | %8ld | %10u/%10u\n", i, reader[i]->GetBlockID() + 1, reader[i]->GetFilePos(), reader[i]->GetFileSize());
|
||||||
numBlock += reader[i]->GetBlockID() + 1;
|
numBlock += reader[i]->GetBlockID() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("===================================== done. \n");
|
printf("===================================== done. \n");
|
||||||
printf("Number of Block Scanned : %u\n", numBlock);
|
printf("Number of Block Scanned : %u\n", numBlock);
|
||||||
printf(" Number of Event Built : %lld\n", evID);
|
printf(" Number of Event Built : %lld\n", evID);
|
||||||
|
|
|
@ -21,8 +21,8 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
||||||
if( entry < 1 ) printf("============================== start processing data\n");
|
if( entry < 1 ) printf("============================== start processing data\n");
|
||||||
|
|
||||||
///initialization
|
///initialization
|
||||||
for( int i = 0; i < nDetType; i++){
|
for( int i = 0; i < mapping::nDetType; i++){
|
||||||
for( int j = 0; j < detNum[i]; j++){
|
for( int j = 0; j < mapping::detNum[i]; j++){
|
||||||
eE[i][j] = TMath::QuietNaN();
|
eE[i][j] = TMath::QuietNaN();
|
||||||
eT[i][j] = 0;
|
eT[i][j] = 0;
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
||||||
b_e_t->GetEntry(entry);
|
b_e_t->GetEntry(entry);
|
||||||
|
|
||||||
for( int i = 0 ; i < multi; i++){
|
for( int i = 0 ; i < multi; i++){
|
||||||
int detID = mapping[bd[i]][ch[i]];
|
int detID = mapping::map[bd[i]][ch[i]];
|
||||||
int detType = FindDetType(detID, detMaxID);
|
int detType = mapping::FindDetTypeIndex(detID);
|
||||||
int low = (i == 0 ? 0 : detMaxID[detType-1]);
|
int low = (i == 0 ? 0 : mapping::detMaxID[detType-1]);
|
||||||
int reducedDetID = detID - low;
|
int reducedDetID = detID - low;
|
||||||
|
|
||||||
eE[detType][reducedDetID] = e[i] * detParity[detType];
|
eE[detType][reducedDetID] = e[i] * mapping::detParity[detType];
|
||||||
eT[detType][reducedDetID] = e_t[i];
|
eT[detType][reducedDetID] = e_t[i];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
||||||
arr->Clear("C");
|
arr->Clear("C");
|
||||||
|
|
||||||
for( int i = 0; i < multi; i++){
|
for( int i = 0; i < multi; i++){
|
||||||
int detID = mapping[bd[i]][ch[i]];
|
int detID = mapping::map[bd[i]][ch[i]];
|
||||||
|
|
||||||
|
|
||||||
int traceLength = tl[i];
|
int traceLength = tl[i];
|
||||||
gTrace = (TGraph*) arr->ConstructedAt(countTrace, "C");
|
gTrace = (TGraph*) arr->ConstructedAt(countTrace, "C");
|
||||||
|
@ -80,6 +81,12 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
||||||
|
|
||||||
//***=================== fit
|
//***=================== fit
|
||||||
if( traceMethod == 1){
|
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 = new TF1("gFit", fitFunc, 0, traceLength, numPara);
|
||||||
gFit->SetLineColor(6);
|
gFit->SetLineColor(6);
|
||||||
gFit->SetRange(0, traceLength);
|
gFit->SetRange(0, traceLength);
|
||||||
|
@ -96,9 +103,7 @@ Bool_t GeneralSort::Process(Long64_t entry){
|
||||||
|
|
||||||
gTrace->Fit("gFit", "QR", "", 0, traceLength);
|
gTrace->Fit("gFit", "QR", "", 0, traceLength);
|
||||||
|
|
||||||
|
int low = (i == 0 ? 0 : mapping::detMaxID[detType-1]);
|
||||||
int detType = FindDetType(detID, detMaxID);
|
|
||||||
int low = (i == 0 ? 0 : detMaxID[detType-1]);
|
|
||||||
int reducedDetID = detID - low;
|
int reducedDetID = detID - low;
|
||||||
|
|
||||||
teE[detType][reducedDetID] = gFit->GetParameter(0);
|
teE[detType][reducedDetID] = gFit->GetParameter(0);
|
||||||
|
@ -174,7 +179,7 @@ void GeneralSort::Begin(TTree * tree){
|
||||||
printf( "===================== SOLARIS GeneralSort.C =================\n");
|
printf( "===================== SOLARIS GeneralSort.C =================\n");
|
||||||
printf( "=================================================================\n");
|
printf( "=================================================================\n");
|
||||||
|
|
||||||
PrintMapping(mapping, detTypeName, detMaxID);
|
mapping::PrintMapping();
|
||||||
|
|
||||||
DecodeOption();
|
DecodeOption();
|
||||||
if(!isParallel) {
|
if(!isParallel) {
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include <TStopwatch.h>
|
#include <TStopwatch.h>
|
||||||
#include <TProofOutputFile.h>
|
#include <TProofOutputFile.h>
|
||||||
|
|
||||||
|
//^######################################### Skip list for trace fitting
|
||||||
|
//TODO
|
||||||
|
|
||||||
/*********************************=======
|
/*********************************=======
|
||||||
|
|
||||||
the sequence of each method
|
the sequence of each method
|
||||||
|
@ -29,9 +32,8 @@ the sequence of each method
|
||||||
|
|
||||||
******************************************/
|
******************************************/
|
||||||
|
|
||||||
/// in Process_Sort, copy the GeneralSortMapping.h to ~/.proof/working/
|
/// in Process_Sort, copy the Mapping.h to ~/.proof/working/
|
||||||
#include "../working/Mapping.h"
|
#include "../working/Mapping.h"
|
||||||
#include "../armory/AnalysisLib.h"
|
|
||||||
|
|
||||||
//^######################################### FIT FUNCTION
|
//^######################################### FIT FUNCTION
|
||||||
const int numPara = 6;
|
const int numPara = 6;
|
||||||
|
@ -132,8 +134,6 @@ public :
|
||||||
traceMethod = 0; // -1 = ignore trace, 0 = no trace fit, 1 = fit, 2 = trapezoid
|
traceMethod = 0; // -1 = ignore trace, 0 = no trace fit, 1 = fit, 2 = trapezoid
|
||||||
|
|
||||||
isParallel = false;
|
isParallel = false;
|
||||||
detNum.clear();
|
|
||||||
nDetType = 0;
|
|
||||||
|
|
||||||
saveFile = nullptr;
|
saveFile = nullptr;
|
||||||
newSaveTree = nullptr;
|
newSaveTree = nullptr;
|
||||||
|
@ -175,9 +175,6 @@ public :
|
||||||
void SetTraceMethod(int methodID) {traceMethod = methodID;}
|
void SetTraceMethod(int methodID) {traceMethod = methodID;}
|
||||||
void PrintTraceMethod();
|
void PrintTraceMethod();
|
||||||
|
|
||||||
std::vector<int> detNum;
|
|
||||||
int nDetType;
|
|
||||||
|
|
||||||
void SetUpTree();
|
void SetUpTree();
|
||||||
void DecodeOption();
|
void DecodeOption();
|
||||||
bool isParallel;
|
bool isParallel;
|
||||||
|
@ -226,24 +223,22 @@ void GeneralSort::SetUpTree(){
|
||||||
newSaveTree->SetDirectory(saveFile);
|
newSaveTree->SetDirectory(saveFile);
|
||||||
newSaveTree->AutoSave();
|
newSaveTree->AutoSave();
|
||||||
|
|
||||||
detNum = ExtractDetNum(mapping, detTypeName, detMaxID);
|
newSaveTree->Branch( "evID", &evID, "EventID/l"); // simply copy
|
||||||
|
|
||||||
nDetType = (int) detTypeName.size();
|
eE = new Float_t * [mapping::nDetType];
|
||||||
|
eT = new ULong64_t * [mapping::nDetType];
|
||||||
|
|
||||||
eE = new Float_t * [nDetType];
|
for( int i = 0 ; i < mapping::nDetType; i++){
|
||||||
eT = new ULong64_t * [nDetType];
|
eE[i] = new Float_t[mapping::detNum[i]];
|
||||||
|
eT[i] = new ULong64_t[mapping::detNum[i]];
|
||||||
|
|
||||||
for( int i = 0 ; i < nDetType; i++){
|
for( int j = 0; j < mapping::detNum[i]; j++){
|
||||||
eE[i] = new Float_t[detNum[i]];
|
|
||||||
eT[i] = new ULong64_t[detNum[i]];
|
|
||||||
|
|
||||||
for( int j = 0; j < detNum[i]; j++){
|
|
||||||
eE[i][j] = TMath::QuietNaN();
|
eE[i][j] = TMath::QuietNaN();
|
||||||
eT[i][j] = 0;
|
eT[i][j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
newSaveTree->Branch( detTypeName[i].c_str(), eE[i], Form("%s[%d]/F", detTypeName[i].c_str(), detNum[i]));
|
newSaveTree->Branch( mapping::detTypeName[i].c_str(), eE[i], Form("%s[%d]/F", mapping::detTypeName[i].c_str(), mapping::detNum[i]));
|
||||||
newSaveTree->Branch( (detTypeName[i]+"_t").c_str(), eT[i], Form("%s_Timestamp[%d]/l", detTypeName[i].c_str(), 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]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,24 +251,26 @@ void GeneralSort::SetUpTree(){
|
||||||
|
|
||||||
if( traceMethod > 0 ){
|
if( traceMethod > 0 ){
|
||||||
|
|
||||||
teE = new Float_t * [nDetType];
|
teE = new Float_t * [mapping::nDetType];
|
||||||
teT = new Float_t * [nDetType];
|
teT = new Float_t * [mapping::nDetType];
|
||||||
teR = new Float_t * [nDetType];
|
teR = new Float_t * [mapping::nDetType];
|
||||||
|
|
||||||
for( int i = 0 ; i < nDetType; i++){
|
for( int i = 0 ; i < mapping::nDetType; i++){
|
||||||
teE[i] = new Float_t[detNum[i]];
|
teE[i] = new Float_t[mapping::detNum[i]];
|
||||||
teT[i] = new Float_t[detNum[i]];
|
teT[i] = new Float_t[mapping::detNum[i]];
|
||||||
teR[i] = new Float_t[detNum[i]];
|
teR[i] = new Float_t[mapping::detNum[i]];
|
||||||
|
|
||||||
for( int j = 0; j < detNum[i]; j++){
|
for( int j = 0; j <mapping::detNum[i]; j++){
|
||||||
teE[i][j] = TMath::QuietNaN();
|
teE[i][j] = TMath::QuietNaN();
|
||||||
teT[i][j] = TMath::QuietNaN();
|
teT[i][j] = TMath::QuietNaN();
|
||||||
teR[i][j] = TMath::QuietNaN();
|
teR[i][j] = TMath::QuietNaN();
|
||||||
}
|
}
|
||||||
|
|
||||||
newSaveTree->Branch( ("t" + detTypeName[i]).c_str(), teE[i], Form("trace_%s[%d]/F", detTypeName[i].c_str(), detNum[i]));
|
//TODO use a blackList to skip some trace
|
||||||
newSaveTree->Branch( ("t" + detTypeName[i]+"_t").c_str(), teT[i], Form("trace_%s_time[%d]/l", detTypeName[i].c_str(), detNum[i]));
|
|
||||||
newSaveTree->Branch( ("t" + detTypeName[i]+"_r").c_str(), teR[i], Form("trace_%s_rise[%d]/l", detTypeName[i].c_str(), detNum[i]));
|
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]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include "TTree.h"
|
#include "TTree.h"
|
||||||
#include "TProof.h"
|
#include "TProof.h"
|
||||||
#include "TChain.h"
|
#include "TChain.h"
|
||||||
|
#include "TMacro.h"
|
||||||
|
#include "TFile.h"
|
||||||
|
|
||||||
void GeneralSortAgent(Int_t runNum, int nWorker = 1, int traceMethod = -1){
|
void GeneralSortAgent(Int_t runNum, int nWorker = 1, int traceMethod = -1){
|
||||||
|
|
||||||
|
@ -34,5 +36,18 @@ void GeneralSortAgent(Int_t runNum, int nWorker = 1, int traceMethod = -1){
|
||||||
chain->Process("../armory/GeneralSort.C+", option);
|
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();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,15 +11,16 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
||||||
echo "$ Process_Run [RunNum] [EventBuild] [GeneralSort] [TraceMethod] [Monitor]"
|
echo "$ Process_Run [RunNum] [EventBuild] [GeneralSort] [TraceMethod] [DataHoSei]"
|
||||||
echo " RunNum = run number / \"lastRun\" "
|
echo " RunNum = run number / \"lastRun\" "
|
||||||
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
||||||
echo " GeneralSort = n/0/-n || n = number of worker"
|
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 " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid(not implemented)"
|
||||||
echo " Monitors = 2/1/0 || 1 = single run, 2 = using the list in ChainMonitors.C"
|
echo " DataHoSei = 2/1/0 || 1 = single run, 2 = using the list in ChainMonitors.C"
|
||||||
echo " 10 = single run and post to websrv, 20 = list runs and post to websrv"
|
echo " 10 = single run and post to websrv, 20 = list runs and post to websrv"
|
||||||
echo ""
|
echo ""
|
||||||
echo " * negative option = force (except for TraceMethod)"
|
echo " * negative option = force (except for TraceMethod)."
|
||||||
|
echo " * Defult timeWindow for Event builder is 100 tick = 800 ns."
|
||||||
echo ""
|
echo ""
|
||||||
exit 1
|
exit 1
|
||||||
fi;
|
fi;
|
||||||
|
|
|
@ -65,8 +65,6 @@ else
|
||||||
|
|
||||||
mkdir -p ~/.proof/working
|
mkdir -p ~/.proof/working
|
||||||
cp ${SOLARISANADIR}/working/Mapping.h ~/.proof/working/.
|
cp ${SOLARISANADIR}/working/Mapping.h ~/.proof/working/.
|
||||||
mkdir -p ~/.proof/armory
|
|
||||||
cp ${SOLARISANADIR}/armory/AnalysisLib.h ~/.proof/armory/.
|
|
||||||
|
|
||||||
if [ $nWorker -le -1 ]; then
|
if [ $nWorker -le -1 ]; then
|
||||||
echo -e "${LRED}>>>>>>>>>>>>>>> Force GeneralSort $(date) ${NC}"
|
echo -e "${LRED}>>>>>>>>>>>>>>> Force GeneralSort $(date) ${NC}"
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace mapping{
|
||||||
|
|
||||||
const std::vector<std::string> detTypeName = { "e", "xf", "xn", "rdt"}; //C= The comment "//C=" is an indicator DON't Remove
|
const std::vector<std::string> detTypeName = { "e", "xf", "xn", "rdt"}; //C= The comment "//C=" is an indicator DON't Remove
|
||||||
const std::vector<int> detGroupID = { 0, 0, 0, 1}; //C& The comment "//C&" is an indicator DON't Remove
|
const std::vector<int> detGroupID = { 0, 0, 0, 1}; //C& The comment "//C&" is an indicator DON't Remove
|
||||||
const std::vector<int> detMaxID = { 100, 200, 300, 400}; //C# The comment "//C#" is an indicator DON't Remove
|
const std::vector<int> detMaxID = { 100, 200, 300, 400}; //C# The comment "//C#" is an indicator DON't Remove
|
||||||
|
@ -28,7 +30,7 @@ const std::vector<std::string> groupName = { "Array", "Recoil"}; //C% The commen
|
||||||
|
|
||||||
//!The mapping[i] must match as the IP setting in the DAQ
|
//!The mapping[i] must match as the IP setting in the DAQ
|
||||||
|
|
||||||
const std::vector<std::vector<int>> mapping = {
|
const std::vector<std::vector<int>> map = {
|
||||||
{
|
{
|
||||||
//C 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // this line is an indicator DON'T Remove "//C " is an indcator
|
//C 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // this line is an indicator DON'T Remove "//C " is an indcator
|
||||||
0, 100, 200, 1, 101, 201, 2, 102, 202, 3, 103, 203, 4, 104, 204, -1, /// 0 - 15
|
0, 100, 200, 1, 101, 201, 2, 102, 202, 3, 103, 203, 4, 104, 204, -1, /// 0 - 15
|
||||||
|
@ -63,4 +65,63 @@ const std::vector<std::vector<int>> mapping = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//^===============================================================================
|
||||||
|
int FindDetTypeIndex(int detID){
|
||||||
|
for( int k = 0; k < (int) detMaxID.size(); k++){
|
||||||
|
int low = (k == 0 ? 0 : detMaxID[k-1]);
|
||||||
|
int high = detMaxID[k];
|
||||||
|
if( low <= detID && detID < high ) {
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> ExtractDetNum(){
|
||||||
|
std::vector<int> detTypeNum;
|
||||||
|
for( int i = 0; i < (int) detTypeName.size(); i ++) detTypeNum.push_back(0);
|
||||||
|
for( int i = 0; i < (int) map.size(); i ++){
|
||||||
|
for( int j = 0; j < (int) map[i].size(); j++){
|
||||||
|
if( map[i][j] < 0) continue;
|
||||||
|
for( int k = 0; k < (int) detTypeName.size() ; k ++ ){
|
||||||
|
int low = (k == 0 ? 0 : detMaxID[k-1]);
|
||||||
|
int high = detMaxID[k];
|
||||||
|
if( low <= map[i][j] && map[i][j] < high ) {
|
||||||
|
detTypeNum[k]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return detTypeNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintMapping(){
|
||||||
|
|
||||||
|
//------------ Red Green Yellow Cyan blue Magenta Gray
|
||||||
|
std::vector<const char* > Color = {"\033[31m", "\033[32m", "\033[33m", "\033[36m", "\033[34m", "\033[35m", "\033[37m"};
|
||||||
|
|
||||||
|
printf("==================================== Mapping ===================================\n");
|
||||||
|
std::vector<int> detTypeNum = ExtractDetNum();
|
||||||
|
for(int i = 0 ; i < (int) detTypeName.size(); i++) {
|
||||||
|
printf(" %2d | %7s | %3d | %3d - %3d\n", i, detTypeName[i].c_str(), detTypeNum[i], (i == 0 ? 0 : detMaxID[i-1]), detMaxID[i]);
|
||||||
|
}
|
||||||
|
for( int i = 0; i < (int) map.size(); i++){
|
||||||
|
printf("Digi-%d ------------------------------------------------------------------------ \n", i);
|
||||||
|
for( int j = 0; j < (int) map[i].size(); j++){
|
||||||
|
if( map[i][j] < 0 ){
|
||||||
|
printf("%4d,", map[i][j]);
|
||||||
|
}else{
|
||||||
|
int colorIndex = FindDetTypeIndex(map[i][j]);
|
||||||
|
printf("%s%4d\033[0m,", Color[colorIndex], map[i][j]);
|
||||||
|
}
|
||||||
|
if( j % 16 == 15 ) printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("================================================================================\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<int> detNum = ExtractDetNum();
|
||||||
|
const int nDetType = detNum.size();
|
||||||
|
|
||||||
|
} // namespace solarismap
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user