fix GeneralSort in Mac

This commit is contained in:
Ryan Tang 2023-04-04 16:59:11 -04:00
parent 982cda8be6
commit fc3a73cd6c
4 changed files with 36 additions and 21 deletions

View File

@ -4,7 +4,7 @@
"name": "Mac", "name": "Mac",
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"/Applications/root-6.28.00/include/**" "/Applications/root_v6.28.02/include/**"
], ],
"defines": [], "defines": [],
"macFrameworkPath": [ "macFrameworkPath": [
@ -13,7 +13,7 @@
"compilerPath": "/usr/bin/g++", "compilerPath": "/usr/bin/g++",
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "c++17", "cppStandard": "c++17",
"intelliSenseMode": "macos-gcc-arm64" "intelliSenseMode": "macos-clang-arm64"
}, },
{ {
"name": "Linux", "name": "Linux",

View File

@ -50,7 +50,6 @@ Bool_t GeneralSort::Process(Long64_t entry){
} }
if( isTraceExist && traceMethod >= 0 ){ if( isTraceExist && traceMethod >= 0 ){
b_tl->GetEntry(entry); b_tl->GetEntry(entry);
@ -88,7 +87,7 @@ Bool_t GeneralSort::Process(Long64_t entry){
} }
} }
newTree->Fill(); newSaveTree->Fill();
return kTRUE; return kTRUE;
} }
@ -101,9 +100,9 @@ void GeneralSort::Terminate(){
DecodeOption(); DecodeOption();
if( !isParallel){ if( !isParallel){
printf("%s::SaveTree %p, %p\n", __func__, saveFile, newTree);
saveFile->cd(); saveFile->cd();
newTree->Write(); newSaveTree->Print();
newSaveTree->Write();
saveFile->Close(); saveFile->Close();
} }
@ -148,7 +147,7 @@ void GeneralSort::SlaveTerminate(){
if( isParallel){ if( isParallel){
printf("%s::SaveTree\n", __func__); printf("%s::SaveTree\n", __func__);
saveFile->cd(); saveFile->cd();
newTree->Write(); newSaveTree->Write();
fOutput->Add(proofFile); fOutput->Add(proofFile);
saveFile->Close(); saveFile->Close();
} }

View File

@ -3,6 +3,7 @@
#include <TROOT.h> #include <TROOT.h>
#include <TChain.h> #include <TChain.h>
#include <TTree.h>
#include <TFile.h> #include <TFile.h>
#include <TSelector.h> #include <TSelector.h>
#include <TObjString.h> #include <TObjString.h>
@ -85,6 +86,22 @@ public :
isParallel = false; isParallel = false;
detNum.clear(); detNum.clear();
nDetType = 0; nDetType = 0;
saveFile = nullptr;
newSaveTree = nullptr;
eE = nullptr;
eT = nullptr;
arr = nullptr;
gTrace = nullptr;
arrTrapezoid = nullptr;
gTrapezoid = nullptr;
teE = nullptr;
teT = nullptr;
teR = nullptr;
} }
virtual ~GeneralSort() { } virtual ~GeneralSort() { }
virtual Int_t Version() const { return 2; } virtual Int_t Version() const { return 2; }
@ -121,7 +138,7 @@ public :
TString saveFileName; TString saveFileName;
TFile * saveFile; //! TFile * saveFile; //!
TProofOutputFile * proofFile; //! TProofOutputFile * proofFile; //!
TTree * newTree; //! TTree * newSaveTree; //!
Float_t ** eE; //! Float_t ** eE; //!
ULong64_t ** eT; //! ULong64_t ** eT; //!
@ -155,9 +172,9 @@ void GeneralSort::SetUpTree(){
saveFile = new TFile(saveFileName,"RECREATE"); saveFile = new TFile(saveFileName,"RECREATE");
} }
newTree = new TTree("gen_tree", "Tree After GeneralSort"); newSaveTree = new TTree("gen_tree", "Tree After GeneralSort");
newTree->SetDirectory(saveFile); newSaveTree->SetDirectory(saveFile);
newTree->AutoSave(); newSaveTree->AutoSave();
detNum = ExtractDetNum(mapping, detTypeName, detMaxID); detNum = ExtractDetNum(mapping, detTypeName, detMaxID);
@ -175,8 +192,8 @@ void GeneralSort::SetUpTree(){
eT[i][j] = 0; eT[i][j] = 0;
} }
newTree->Branch( detTypeName[i].c_str(), eE[i], Form("%s[%d]/F", detTypeName[i].c_str(), detNum[i])); newSaveTree->Branch( detTypeName[i].c_str(), eE[i], Form("%s[%d]/F", detTypeName[i].c_str(), detNum[i]));
newTree->Branch( (detTypeName[i]+"_t").c_str(), eT[i], Form("%s_Timestamp[%d]/l", detTypeName[i].c_str(), detNum[i])); newSaveTree->Branch( (detTypeName[i]+"_t").c_str(), eT[i], Form("%s_Timestamp[%d]/l", detTypeName[i].c_str(), detNum[i]));
} }
@ -184,7 +201,7 @@ void GeneralSort::SetUpTree(){
arr = new TClonesArray("TGraph"); arr = new TClonesArray("TGraph");
newTree->Branch("trace", arr, 256000); newSaveTree->Branch("trace", arr, 256000);
arr->BypassStreamer(); arr->BypassStreamer();
if( traceMethod > 0 ){ if( traceMethod > 0 ){
@ -204,15 +221,15 @@ void GeneralSort::SetUpTree(){
teR[i][j] = TMath::QuietNaN(); teR[i][j] = TMath::QuietNaN();
} }
newTree->Branch( ("t" + detTypeName[i]).c_str(), teE[i], Form("trace_%s[%d]/F", detTypeName[i].c_str(), detNum[i])); newSaveTree->Branch( ("t" + detTypeName[i]).c_str(), teE[i], Form("trace_%s[%d]/F", detTypeName[i].c_str(), detNum[i]));
newTree->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]+"_t").c_str(), teT[i], Form("trace_%s_time[%d]/l", detTypeName[i].c_str(), detNum[i]));
newTree->Branch( ("t" + detTypeName[i]+"_r").c_str(), teR[i], Form("trace_%s_rise[%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->Print(); //very important, otherwise the mac will blow up.
} }
//^############################################################## //^##############################################################
@ -298,5 +315,4 @@ void GeneralSort::PrintTraceMethod(){
printf(" Trace method ? %s \n", traceMethodStr); printf(" Trace method ? %s \n", traceMethodStr);
} }
#endif // #ifdef GeneralSort_cxx #endif // #ifdef GeneralSort_cxx

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -l
if [ -z $SOLARISANADIR ]; then if [ -z $SOLARISANADIR ]; then
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh." echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."