modifly to2root.cpp for smaller tree
This commit is contained in:
parent
6b7f165ac2
commit
044ad47bd8
19
Analyzer.C
19
Analyzer.C
|
@ -32,12 +32,14 @@ TH2F * hgg[NCRYSTAL][NCRYSTAL];
|
||||||
|
|
||||||
TH2F * hcoin;
|
TH2F * hcoin;
|
||||||
|
|
||||||
|
TH2F * hcrystalBGO;
|
||||||
|
|
||||||
///----- after calibration and BGO veto
|
///----- after calibration and BGO veto
|
||||||
TH2F * heCalVID;
|
TH2F * heCalVID;
|
||||||
TH1F * heCal[NCRYSTAL];
|
TH1F * heCal[NCRYSTAL];
|
||||||
TH2F * hcoinBGO;
|
TH2F * hcoinBGO;
|
||||||
|
|
||||||
TH2F * hcrystalBGO;
|
TH2F * hcrystalBGO_G;
|
||||||
|
|
||||||
//############################################ BEGIN
|
//############################################ BEGIN
|
||||||
void Analyzer::Begin(TTree * tree){
|
void Analyzer::Begin(TTree * tree){
|
||||||
|
@ -76,6 +78,7 @@ void Analyzer::Begin(TTree * tree){
|
||||||
|
|
||||||
hcoinBGO = new TH2F("hcoinBGO", Form("detector coin. (BGO veto > %.1f); det ID; det ID", BGO_threshold), NCRYSTAL, 0, NCRYSTAL, NCRYSTAL, 0 , NCRYSTAL);
|
hcoinBGO = new TH2F("hcoinBGO", Form("detector coin. (BGO veto > %.1f); det ID; det ID", BGO_threshold), NCRYSTAL, 0, NCRYSTAL, NCRYSTAL, 0 , NCRYSTAL);
|
||||||
hcrystalBGO = new TH2F("hcrystalBGO", Form("crystal vs BGO ; det ID; BGO ID"), NCRYSTAL, 0, NCRYSTAL, NBGO, 0 , NBGO);
|
hcrystalBGO = new TH2F("hcrystalBGO", Form("crystal vs BGO ; det ID; BGO ID"), NCRYSTAL, 0, NCRYSTAL, NBGO, 0 , NBGO);
|
||||||
|
hcrystalBGO_G = new TH2F("hcrystalBGO_G", Form("crystal vs BGO (BGO veto); det ID; BGO ID"), NCRYSTAL, 0, NCRYSTAL, NBGO, 0 , NBGO);
|
||||||
|
|
||||||
printf("======================== Load parameters.\n");
|
printf("======================== Load parameters.\n");
|
||||||
|
|
||||||
|
@ -158,6 +161,11 @@ Bool_t Analyzer::Process(Long64_t entry){
|
||||||
|
|
||||||
heCalVID->Fill( detID[i], eCal[detID[i]]);
|
heCalVID->Fill( detID[i], eCal[detID[i]]);
|
||||||
heCal[detID[i]]->Fill(eCal[detID[i]]);
|
heCal[detID[i]]->Fill(eCal[detID[i]]);
|
||||||
|
|
||||||
|
for ( int j = i + 1; j < multi; j++){
|
||||||
|
if( 100 <= detID[j] && detID[j] < 200 ) hcrystalBGO_G->Fill(detID[i], detID[j]-100); /// crystal - BGO coincident
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +204,11 @@ void Analyzer::Terminate(){
|
||||||
hcrystalBGO->Draw("colz");
|
hcrystalBGO->Draw("colz");
|
||||||
|
|
||||||
cCanvas->cd(4);
|
cCanvas->cd(4);
|
||||||
//cCanvas->cd(4)->SetLogz(1);
|
cCanvas->cd(4)->SetLogz(1);
|
||||||
he[0]->SetLineColor(2);
|
hcrystalBGO_G->Draw("colz");
|
||||||
he[0]->Draw();
|
//he[0]->SetLineColor(2);
|
||||||
heCal[0]->Draw("same");
|
//he[0]->Draw();
|
||||||
|
//heCal[0]->Draw("same");
|
||||||
//hcoinBGO->Draw("colz");
|
//hcoinBGO->Draw("colz");
|
||||||
|
|
||||||
printf("=============== loaded AutoFit.C, try showFitMethos()\n");
|
printf("=============== loaded AutoFit.C, try showFitMethos()\n");
|
||||||
|
|
|
@ -75,17 +75,18 @@ int main(int argn, char **argv){
|
||||||
outFileName.Append(".root");
|
outFileName.Append(".root");
|
||||||
if( argn >=4 ) outFileName = argv[3];
|
if( argn >=4 ) outFileName = argv[3];
|
||||||
|
|
||||||
printf(">>> out File name : \033[1,31m%s\033[m\n", outFileName.Data());
|
printf(">>> out File name : \033[1;31m%s\033[m\n", outFileName.Data());
|
||||||
|
|
||||||
printf(">>> Create output tree\n");
|
printf(">>> Create output tree\n");
|
||||||
TFile * saveFile = new TFile(outFileName, "recreate");
|
TFile * saveFile = new TFile(outFileName, "recreate");
|
||||||
saveFile->cd();
|
saveFile->cd();
|
||||||
TTree * newtree = new TTree("tree", "tree");
|
TTree * newtree = new TTree("tree", "tree");
|
||||||
|
|
||||||
|
Int_t eventID = 0 ;
|
||||||
Int_t multi = 0; /// this is total multipicilty for all detectors
|
Int_t multi = 0; /// this is total multipicilty for all detectors
|
||||||
newtree->Branch("multi", &multi, "multi/I");
|
newtree->Branch("multi", &multi, "multi/I");
|
||||||
|
|
||||||
Int_t eventID = 0 ;
|
|
||||||
newtree->Branch("evID", &eventID, "event_ID/l");
|
newtree->Branch("evID", &eventID, "event_ID/l");
|
||||||
|
|
||||||
Int_t multiCry = 0 ; /// thi is total multiplicity for all crystal
|
Int_t multiCry = 0 ; /// thi is total multiplicity for all crystal
|
||||||
|
@ -99,7 +100,7 @@ int main(int argn, char **argv){
|
||||||
newtree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
newtree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
||||||
|
|
||||||
printf("================== Start processing....\n");
|
printf("================== Start processing....\n");
|
||||||
Float_t Frac = 0.1; ///Progress bar
|
Float_t Frac = 0.05; ///Progress bar
|
||||||
TStopwatch StpWatch;
|
TStopwatch StpWatch;
|
||||||
StpWatch.Start();
|
StpWatch.Start();
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#define RAWE_REBIN_FACTOR 2.0 // Rebin 32k pixie16 spectra to something smaller to fit better into 8k.
|
#define RAWE_REBIN_FACTOR 2.0 // Rebin 32k pixie16 spectra to something smaller to fit better into 8k.
|
||||||
|
|
||||||
|
#define MAXMULTI 100
|
||||||
|
|
||||||
#include "../mapping.h"
|
#include "../mapping.h"
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
@ -58,7 +60,6 @@ struct measurement
|
||||||
};
|
};
|
||||||
struct measurement data = {0};
|
struct measurement data = {0};
|
||||||
|
|
||||||
int sevtmult=0;
|
|
||||||
unsigned long long int dataCount=0;
|
unsigned long long int dataCount=0;
|
||||||
unsigned long long int pileUpCount=0;
|
unsigned long long int pileUpCount=0;
|
||||||
unsigned long long int evtCount=0;
|
unsigned long long int evtCount=0;
|
||||||
|
@ -106,35 +107,22 @@ int main(int argc, char **argv) {
|
||||||
outRootFile->cd();
|
outRootFile->cd();
|
||||||
TTree * tree = new TTree("tree", "tree");
|
TTree * tree = new TTree("tree", "tree");
|
||||||
|
|
||||||
unsigned long long evID = -1;
|
unsigned long long evID = 0;
|
||||||
|
int multi = 0;
|
||||||
double e[NCRYSTAL];
|
int id[MAXMULTI] = {0};
|
||||||
unsigned long long e_t[NCRYSTAL];
|
double e[MAXMULTI] = {TMath::QuietNaN()};
|
||||||
unsigned short pileup[NCRYSTAL];
|
unsigned long long e_t[MAXMULTI] = {0};
|
||||||
unsigned short hit[NCRYSTAL]; // number of hit in an event
|
Int_t multiCry = 0 ; /// this is total multiplicity for all crystal
|
||||||
|
|
||||||
double bgo[NBGO];
|
//unsigned short pileup[MAXMULTI];
|
||||||
unsigned long long bgo_t[NBGO];
|
//unsigned short hit[MAXMULTI]; // number of hit in an event
|
||||||
|
|
||||||
double other[NOTHER];
|
|
||||||
|
|
||||||
int multi; //sum of all crystal hit in an event
|
|
||||||
|
|
||||||
tree->Branch("evID", &evID, "event_ID/l");
|
tree->Branch("evID", &evID, "event_ID/l");
|
||||||
|
tree->Branch("multi", &multi, "multi/I");
|
||||||
//TODO: use TCloneArray to save measurement struc, that can save space and possibly time.
|
tree->Branch("id", id, "id[multi]/I");
|
||||||
///tree->Branch("detID", detID, Form("det ID[%d]/B", NCRYSTAL));
|
tree->Branch("e", e, "e[multi]/D");
|
||||||
tree->Branch("e", e, Form("e[%d]/D", NCRYSTAL));
|
tree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
||||||
tree->Branch("e_t", e_t, Form("e_timestamp[%d]/l", NCRYSTAL));
|
tree->Branch("multiCry", &multiCry, "multiplicity_crystal/I");
|
||||||
tree->Branch("p", pileup, Form("pile_up_flag[%d]/s", NCRYSTAL));
|
|
||||||
tree->Branch("hit", hit, Form("hit[%d]/s", NCRYSTAL));
|
|
||||||
|
|
||||||
tree->Branch("bgo", bgo, Form("BGO_e[%d]/D", NBGO));
|
|
||||||
tree->Branch("bgo_t", bgo_t, Form("BGO_timestamp[%d]/l", NBGO));
|
|
||||||
|
|
||||||
tree->Branch("other", other, Form("other_e[%d]/D", NOTHER));
|
|
||||||
|
|
||||||
tree->Branch("multi", &multi, "multiplicity_crystal/I");
|
|
||||||
|
|
||||||
//open list-mode data file from PXI digitizer
|
//open list-mode data file from PXI digitizer
|
||||||
FILE *fpr = fopen(argv[1], "r");
|
FILE *fpr = fopen(argv[1], "r");
|
||||||
|
@ -153,8 +141,6 @@ int main(int argc, char **argv) {
|
||||||
gClock.Reset();
|
gClock.Reset();
|
||||||
gClock.Start("timer");
|
gClock.Start("timer");
|
||||||
|
|
||||||
int hitcrystal[NCRYSTAL] = {0};
|
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// MAIN WHILE LOOP //
|
// MAIN WHILE LOOP //
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
@ -164,25 +150,8 @@ int main(int argc, char **argv) {
|
||||||
// UNPACK DATA AND EVENT BUILD //
|
// UNPACK DATA AND EVENT BUILD //
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
//data clear
|
long long int etime = -1;
|
||||||
for( int i = 0; i < NCRYSTAL; i++){
|
long long int tdif = -1;
|
||||||
e[i] = TMath::QuietNaN();
|
|
||||||
e_t[i] = 0;
|
|
||||||
pileup[i] = 0;
|
|
||||||
hit[i] = 0;
|
|
||||||
}
|
|
||||||
for( int i = 0; i < NBGO; i++) {
|
|
||||||
bgo[i] = TMath::QuietNaN();
|
|
||||||
bgo_t[i] = 0 ;
|
|
||||||
}
|
|
||||||
for( int i = 0; i < NOTHER; i++) {
|
|
||||||
other[i] = TMath::QuietNaN();
|
|
||||||
}
|
|
||||||
multi = 0;
|
|
||||||
evID++;
|
|
||||||
|
|
||||||
long long int etime=-1;
|
|
||||||
long long int tdif=-1;
|
|
||||||
int sevtmult=0;
|
int sevtmult=0;
|
||||||
|
|
||||||
while (1) { //get subevents and event build for one "event"
|
while (1) { //get subevents and event build for one "event"
|
||||||
|
@ -206,25 +175,13 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
tempf = (float)data.e/RAWE_REBIN_FACTOR;// + RAND;
|
tempf = (float)data.e/RAWE_REBIN_FACTOR;// + RAND;
|
||||||
data.e = (int)tempf;
|
data.e = (int)tempf;
|
||||||
|
|
||||||
//check lengths (sometimes all of the bits for trace length are turned on ...)
|
|
||||||
/**if (dataBlock[sevtmult].elen - dataBlock[sevtmult].hlen != dataBlock[sevtmult].trwlen) {
|
|
||||||
printf("SEVERE ERROR: event, header, and trace length inconsistencies found\n");
|
|
||||||
printf("event length = %d\n", dataBlock[sevtmult].elen);
|
|
||||||
printf("header length = %d\n", dataBlock[sevtmult].hlen);
|
|
||||||
printf("trace length = %d\n", dataBlock[sevtmult].trwlen);
|
|
||||||
printf("Extra = %d\n", dataBlock[sevtmult].extra);
|
|
||||||
printf("fcode = %d\n", dataBlock[sevtmult].fcode);
|
|
||||||
//sleep(1);
|
|
||||||
//return 0;
|
|
||||||
} */
|
|
||||||
|
|
||||||
//Set reference time for event building
|
//Set reference time for event building
|
||||||
if (etime == -1) {
|
if (etime == -1) {
|
||||||
etime = data.time;
|
etime = data.time;
|
||||||
tdif = 0;
|
tdif = 0;
|
||||||
}
|
multi = 0;
|
||||||
else {
|
}else {
|
||||||
tdif = data.time - etime;
|
tdif = data.time - etime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,21 +191,12 @@ int main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
//if within time window, fill array;
|
//if within time window, fill array;
|
||||||
int detID = mapping[data.id];
|
int detID = mapping[data.id];
|
||||||
if ( 0 <= detID && detID < NCRYSTAL ){
|
id[multi] = detID;
|
||||||
e[detID] = data.e;
|
e[multi] = data.e;
|
||||||
e_t[detID] = data.time;
|
e_t[multi] = data.time;
|
||||||
pileup[detID] = data.fcode;
|
multi++ ;
|
||||||
hit[detID] ++;
|
if( detID < 100 ) multiCry ++;
|
||||||
multi++;
|
|
||||||
}
|
|
||||||
if ( 100 <= detID && detID < 100 + NBGO ){
|
|
||||||
bgo[detID-100] = data.e;
|
|
||||||
bgo_t[detID-100] = data.time;
|
|
||||||
}
|
|
||||||
if ( 200 <= detID && detID < 200 + NOTHER){
|
|
||||||
other[detID-200] = data.e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// total pileups
|
// total pileups
|
||||||
|
@ -300,48 +248,25 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
sevtmult++;
|
|
||||||
|
|
||||||
} //end while loop for unpacking sub events and event building for one "event"
|
} //end while loop for unpacking sub events and event building for one "event"
|
||||||
if (sevtmult==0) break; //end main WHILE LOOP when out of events
|
if (multi==0) break; //end main WHILE LOOP when out of events
|
||||||
dataCount += sevtmult;
|
dataCount += multi;
|
||||||
evtCount++; //event-built number
|
evID ++;
|
||||||
|
|
||||||
|
|
||||||
int hit_add = 0;
|
|
||||||
for ( int i = 0; i < NCRYSTAL; i++){
|
|
||||||
if( hit[i] > 1 ) {
|
|
||||||
hit_add = 1;
|
|
||||||
hitcrystal[i] ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///if( hit_add == 1 ){
|
|
||||||
/// for ( int i = 0; i < NCRYSTAL; i++){ printf("%d", hit[i]); }
|
|
||||||
/// printf("------------%d\n", hitcrystal);
|
|
||||||
///}
|
|
||||||
|
|
||||||
///if( evtCount < 40 ) {
|
|
||||||
/// printf("------------------------------------- %lld \n", evtCount);
|
|
||||||
/// for( int i = 0; i < NCRYSTAL; i++){
|
|
||||||
/// if(e[i] > 0 )printf("%2d %6.0f %10llu\n", i, e[i], e_t[i]);
|
|
||||||
/// }
|
|
||||||
///
|
|
||||||
///}
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// END UNPACK DATA AND EVENT BUILD //
|
// END UNPACK DATA AND EVENT BUILD //
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
//event stats, print status every 10000 events
|
//event stats, print status every 10000 events
|
||||||
if ( evtCount % 10000 == 0 ) {
|
if ( evID % 10000 == 0 ) {
|
||||||
fprpos = ftell(fpr);
|
fprpos = ftell(fpr);
|
||||||
tempf = (float)fprsize/(1024.*1024.*1024.);
|
tempf = (float)fprsize/(1024.*1024.*1024.);
|
||||||
gClock.Stop("timer");
|
gClock.Stop("timer");
|
||||||
double time = gClock.GetRealTime("timer");
|
double time = gClock.GetRealTime("timer");
|
||||||
gClock.Start("timer");
|
gClock.Start("timer");
|
||||||
printf("Total dataBlock: \x1B[32m%llu \x1B[31m(%d%% pileup)\x1B[0m\nTotal Events: \x1B[32m%llu (%.1f <mult>)\x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[3A\r",
|
printf("Total dataBlock: \x1B[32m%llu \x1B[31m(%d%% pileup)\x1B[0m\nTotal Events: \x1B[32m%llu (%.1f <mult>)\x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[3A\r",
|
||||||
dataCount, (int)((100*pileUpCount)/dataCount), evtCount, (float)dataCount/(float)evtCount, (100*fprpos/fprsize), tempf, TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
dataCount, (int)((100*pileUpCount)/dataCount), evID+1, (float)dataCount/((float)evID+1), (100*fprpos/fprsize), tempf, TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,7 +281,7 @@ int main(int argc, char **argv) {
|
||||||
fprpos = ftell(fpr);
|
fprpos = ftell(fpr);
|
||||||
tempf = (float)fprsize/(1024.*1024.*1024.);
|
tempf = (float)fprsize/(1024.*1024.*1024.);
|
||||||
printf("Total SubEvents: \x1B[32m%llu \x1B[31m(%d%% pileup)\x1B[0m\nTotal Events: \x1B[32m%llu (%.1f <mult>)\x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\n\033[3A\n",
|
printf("Total SubEvents: \x1B[32m%llu \x1B[31m(%d%% pileup)\x1B[0m\nTotal Events: \x1B[32m%llu (%.1f <mult>)\x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\n\033[3A\n",
|
||||||
dataCount, (int)((100*pileUpCount)/dataCount), evtCount, (float)dataCount/(float)evtCount, (100*fprpos/fprsize), tempf);
|
dataCount, (int)((100*pileUpCount)/dataCount), evID+1, (float)dataCount/((float)evID+1), (100*fprpos/fprsize), tempf);
|
||||||
|
|
||||||
|
|
||||||
outRootFile->cd();
|
outRootFile->cd();
|
||||||
|
@ -369,11 +294,7 @@ int main(int argc, char **argv) {
|
||||||
double time = gClock.GetRealTime("timer");
|
double time = gClock.GetRealTime("timer");
|
||||||
printf("\n\n==================== finished.\r\n");
|
printf("\n\n==================== finished.\r\n");
|
||||||
printf("Total time spend : %3.0f min %5.2f sec\n", TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
printf("Total time spend : %3.0f min %5.2f sec\n", TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
||||||
|
|
||||||
printf("number of hit per crystal per event:\n");
|
|
||||||
for( int i = 0; i < NCRYSTAL ; i++){
|
|
||||||
printf("%2d -- %d \n", i, hitcrystal[i]);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#1/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DIR=$(pwd)
|
DIR=$(pwd)
|
||||||
DATA_DIR=data
|
DATA_DIR=data
|
||||||
|
|
Loading…
Reference in New Issue
Block a user