Commit ab1f3125 authored by J.Dudouet [IPNL/CSNSM]'s avatar J.Dudouet [IPNL/CSNSM]
Browse files

Add light watchers to limit the size of the output trees for online processing,

Adapt the BuildTree in that way


git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@2271 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent f9b9cffa
......@@ -53,15 +53,22 @@ GuiBuildTree::GuiBuildTree(const TGWindow *p, UInt_t w, UInt_t h) :
gClient->GetColorByName("blue", blue);
gClient->GetColorByName("black", black);
//----------------Menu File--------------------
fMenuFile = new TGPopupMenu(gClient->GetRoot());
fMenuFile->AddEntry("Exit", M_Exit);
fMenuFile->Connect("Activated(Int_t)", "GuiBuildTree", this, "HandleMenu(Int_t)");
fMenuMode = new TGPopupMenu(gClient->GetRoot());
fMenuMode->AddEntry("Light mode", M_LightMode);
fMenuMode->Connect("Activated(Int_t)", "GuiBuildTree", this, "HandleMenu(Int_t)");
fLightMode = false;
fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
AddFrame(fMenuBar, new TGLayoutHints(kLHintsExpandX));
fMenuBar->AddPopup("File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuBar->AddPopup("Mode", fMenuMode, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
TGHorizontal3DLine *fline = new TGHorizontal3DLine(this);
AddFrame(fline,new TGLayoutHints(kLHintsExpandX));
......@@ -452,12 +459,26 @@ GuiBuildTree::~GuiBuildTree()
void GuiBuildTree::HandleMenu(Int_t id)
{
// Handle menu items.
switch (id) {
switch (id)
{
case M_Exit:
Emit("DoExit()");
gSystem->Exit(0);
break;
case M_LightMode:
if(fLightMode)
{
fMenuMode->UnCheckEntry(1);
fLightMode = false;
}
else
{
fMenuMode->CheckEntry(1);
fLightMode = true;
}
}
Update();
}
void GuiBuildTree::PrintInListBox(TGListBox *box, TString mess, Int_t Type)
......@@ -587,14 +608,22 @@ void GuiBuildTree::ProcessRun(int RunIndex)
vertex->SetBeta(fVertexBeta);
}
ADTrackTree *trackw = rootmaster->Add<ADTrackTree>("TrackTree","Branch on track");
trackw->SetAgataOffset(fAGATAOffset);
TrackedWatcher *trackw = nullptr;
if(fLightMode)
trackw = rootmaster->Add<ADTrackTreeLight>("ADTrackTreeLight","Branch on track in light version for online pocessing");
else
trackw = rootmaster->Add<ADTrackTree>("TrackTree","Branch on track");
trackw->SetAgataOffset(fAGATAOffset);
}
if(fUsePSAHits)
{
rootmaster->Add<ADHitTree>("HitTree","Branch on hits");
if(fLightMode)
rootmaster->Add<ADHitTreeLight>("ADHitTreeLight","Branch on hits in light version for online pocessing");
else
rootmaster->Add<ADHitTree>("HitTree","Branch on hits");
}
gFile->SetCompressionLevel(0);
......@@ -637,9 +666,12 @@ void GuiBuildTree::ProcessRun(int RunIndex)
fWatch->Stop();
cout<<"GuiBuildTree timer:"<<endl;
fWatch->Print();
cout << " --> Bytes read : " << femulator->GetBytesRead()/1024.*1024. << " MB"<< endl;
cout << " --> Bytes read : " << femulator->GetBytesRead()/ (1024.*1024.) << " MB"<< endl;
cout << " --> Reading rate : " << femulator->GetBytesRead() / (1024.*1024.*fWatch->RealTime()) << " MB/s"<< endl ;
cout << " --> Bytes written: " << gFile->GetBytesWritten() / (1024.*1024.) << " MB"<< endl;
cout << " --> Writing rate : " << gFile->GetBytesWritten() / (1024.*1024.*fWatch->RealTime()) << " MB/s"<< endl ;
delete fd;
......@@ -1022,6 +1054,7 @@ void GuiBuildTree::SaveConfig()
outputfile<<fTTeeTilte<<endl;
outputfile<<fRunMin->GetIntNumber()<<endl;
outputfile<<fRunMax->GetIntNumber()<<endl;
outputfile<<fLightMode<<endl;
outputfile.close();
}
......@@ -1085,6 +1118,10 @@ void GuiBuildTree::LoadConfig()
getline(outputfile,line);fRunMin->SetNumber(atoi(line.c_str()));
getline(outputfile,line);fRunMax->SetNumber(atoi(line.c_str()));
getline(outputfile,line);
if(atoi(line.c_str()))
HandleMenu(M_LightMode);
outputfile.close();
}
}
......
......@@ -47,7 +47,8 @@ using namespace std;
class GuiBuildTree : public TGMainFrame
{
enum ETestCommandIdentifiers {
M_Exit
M_Exit,
M_LightMode
};
RQ_OBJECT("GuiBuildTree")
......@@ -59,6 +60,7 @@ class GuiBuildTree : public TGMainFrame
TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile;
TGPopupMenu *fMenuMode;
TGVSplitter *fVSplitter;
......@@ -121,6 +123,7 @@ class GuiBuildTree : public TGMainFrame
TStopwatch *fWatch;
bool fShowAllADF;
bool fLightMode;
EmulatorPC<RootAFP,FrameDispatcher> *femulator;
bool IsProcessing;
......
......@@ -212,6 +212,80 @@ void ADTrackTree::Exec(Option_t * /*option*/)
//--------------------------------------------------------------------------/
ADTrackTreeLight::ADTrackTreeLight(const char *name, const char *title, TTree *tree) :
TrackedWatcher(name,title),
TTreeBuilder(name,title,tree)
{
if ( GetTree() ) { // just add the branch for that watcher
SetBranches();
}
}
void ADTrackTreeLight::SetBranches()
{
GetTree()->Branch("nbTrack", &nbTrack,"nbTrack/I");
GetTree()->Branch("trackE", trackE, "trackE[nbTrack]/F");
GetTree()->Branch("trackX1", trackX1,"trackX1[nbTrack]/F");
GetTree()->Branch("trackY1", trackY1,"trackY1[nbTrack]/F");
GetTree()->Branch("trackZ1", trackZ1,"trackZ1[nbTrack]/F");
GetTree()->Branch("trackT", trackT, "trackT[nbTrack]/F");
GetTree()->Branch("trackCrystalID", trackCrystalID,"trackCrystalID[nbTrack]/I");
GetTree()->Branch("TStrack", &fTimestamp, "TStrack/l");
}
void ADTrackTreeLight::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1);
nbTrack = 0;
fTimestamp = 0;
return;
}
// to get the data part of the frame
const GammaTrackedInterface *data = GetCstDataPointer<GammaTrackedInterface>(fFrame);
nbTrack = data->GetNbGamma();
if(nbTrack>MaxGamma)
{
SetLastExecStatus(1);
fLog << error << " Number of tracked gamma : " << nbTrack << "Max nbTrack = " << MaxGamma << " event ignored !" << nline;
nbTrack = 0;
fTimestamp = 0;
return;
}
//! get time stamp
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
for (UShort_t i = 0u; i < nbTrack; i++) {
const TrackedHit *gamma1 = data->GetGamma(i);
const Hit *hit1 = gamma1->GetHit();
trackE[i] = gamma1->GetE();
trackT[i] = hit1->GetT();
trackCrystalID[i] = hit1->GetID(1);
trackX1[i] = gamma1->GetX();
trackY1[i] = gamma1->GetY();
trackZ1[i] = gamma1->GetZ();
}
FillTree();
}
//--------------------------------------------------------------------------/
ADHitTree::ADHitTree(const char *name, const char *title, TTree *tree) :
EventPSAWatcher(name,title),
TTreeBuilder(name,title,tree),
......@@ -552,6 +626,126 @@ void ADHitTree::FillSpectraByUser()
//--------------------------------------------------------------------------/
ADHitTreeLight::ADHitTreeLight(const char *name, const char *title, TTree *tree) :
EventPSAWatcher(name,title),
TTreeBuilder(name,title,tree),
fTrans(0x0)
{
fTrans = new AgataGeometryTransformer();
if ( gSystem->AccessPathName("CrystalPositionLookUpTable") ) { // does not exist
if ( gSystem->AccessPathName("CrystalPositionLookUpTable.dat") ) {
fLog << error << " CrystalPositionLookUpTable required " << nline;
}
else {
fLog << info << " Ge positions extracted from CrystalPositionLookUpTable.dat " << nline;
fTrans->ReadTransformations("CrystalPositionLookUpTable.dat");
}
}
else {
fLog << info << " Ge positions extracted from CrystalPositionLookUpTable.dat " << nline;
fTrans->ReadTransformations("CrystalPositionLookUpTable");
}
if ( GetTree() ) { // just add the branch for that watcher
SetBranches();
}
}
void ADHitTreeLight::SetBranches()
{
GetTree()->Branch("nbHits", &nbHits,"nbHits/I");
GetTree()->Branch("hitE", hitE,"hitE[nbHits]/F");
GetTree()->Branch("hitX", hitX,"hitX[nbHits]/F");
GetTree()->Branch("hitY", hitY,"hitY[nbHits]/F");
GetTree()->Branch("hitZ", hitZ,"hitZ[nbHits]/F");
GetTree()->Branch("hitGX", hitGX,"hitGX[nbHits]/F");
GetTree()->Branch("hitGY", hitGY,"hitGY[nbHits]/F");
GetTree()->Branch("hitGZ", hitGZ,"hitGZ[nbHits]/F");
GetTree()->Branch("hitId", hitId,"hitId[nbHits]/I");
GetTree()->Branch("hitSg", hitSg,"hitSg[nbHits]/I");
GetTree()->Branch("nbCores", &nbCores,"nbCores/I");
GetTree()->Branch("coreId", coreId,"coreId[nbCores]/I");
GetTree()->Branch("coreE0", coreE0,"coreE0[nbCores]/F");
GetTree()->Branch("coreTS", coreTS,"coreTS[nbCores]/l");
GetTree()->Branch("TSHit", &fTimestamp, "TSHit/l");
}
void ADHitTreeLight::Exec(Option_t * /*option*/)
{
// be sure the frame has been set properly
if ( fFrame == 0x0 || !fFrame->IsValid() ) {
SetLastExecStatus(1u);
nbHits = 0;
nbCores = 0;
fTimestamp = 0;
return;
}
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
Double_t xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal;
nbCores = GetNbFramePSA();
nbHits=0;
for(Int_t i=0 ; i < nbCores ; i++)
{
PSAInterface *data = GetDataPSA(i);
Int_t nbHitsperCry = data->GetNbHits();
if ( nbHitsperCry == MaxHits )
{
SetLastExecStatus(1u);
fLog << error << " Number of Hits to hit in : " << nbHitsperCry << "Max nbHits = " << MaxHits << nline;
nbHits = 0;
nbCores = 0;
fTimestamp = 0;
return;
}
// Core like branches
coreId[i] = data->GetUID();
coreE0[i] = data->GetE();
coreTS[i] = ((AgataKey *)fPSAFrame->GetKey())->GetTimeStamp();
// Loop on the hit to get over the hits with the max of the energy
for (Int_t j = 0; j < nbHitsperCry; ++j)
{
const PSAHit* pHit = (PSAHit*)data->GetHit(j);
hitE[nbHits+j] = pHit->GetE();
hitX[nbHits+j] = pHit->GetX();
hitY[nbHits+j] = pHit->GetY();
hitZ[nbHits+j] = pHit->GetZ();
hitId[nbHits+j] = data->GetUID() ;
hitSg[nbHits+j] = pHit->GetID();
//Get hit position
pHit->GetXYZ(xLocal, yLocal, zLocal);
//To the AGATA global ref
fTrans->Local2Global(data->GetUID(), xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal);
// Set the Position of the hit in global ref of PRESPEC
hitGX[nbHits+j]= xGlobal; // inversion X-Y and opposite direction
hitGY[nbHits+j]= yGlobal; // inversion Y-X and opposite direction
hitGZ[nbHits+j]= zGlobal; // z
}
nbHits += nbHitsperCry;
}
FillTree();
}
//--------------------------------------------------------------------------/
ADCoincTree::ADCoincTree(const char *name, const char *title, TTree *tree)
: EventWatcher(name,title), TTreeBuilder(name,title,tree)
{
......
......@@ -114,6 +114,38 @@ public:
ClassDef(ADTrackTree,0) // built a root tree for the gamma part
};
//! AD ROOT TTree branches for the tracked part in the light version (for quasi-online processing)
/*!
*/
class ADTrackTreeLight : public TrackedWatcher, TTreeBuilder
{
protected:
ULong64_t fTimestamp;
private:
static const Int_t MaxGamma = 500;
Int_t nbTrack; // Current number of tracked gamma-rays
Float_t trackE[MaxGamma]; // Energies of the tracked gamma
Float_t trackX1[MaxGamma]; // X position of the first interaction point
Float_t trackY1[MaxGamma]; // Y position of the first interaction point
Float_t trackZ1[MaxGamma]; // Z position of the first interaction point
Float_t trackT[MaxGamma]; // time of the track gamma
Int_t trackCrystalID[MaxGamma]; // CrystalID of the first interaction point of the track
protected:
virtual void SetBranches();
public:
ADTrackTreeLight(const char *name, const char *title, TTree *tree = 0x0);
virtual ~ADTrackTreeLight(){;}
//! watch the current frame
virtual void Exec(Option_t *option="");
ClassDef(ADTrackTreeLight,0) // built a root tree for the gamma part
};
//! AD ROOT TTree branches for the hit part
/*!
*/
......@@ -187,6 +219,52 @@ public:
ClassDef(ADHitTree,0) // built a root tree for the gamma part
};
//! AD ROOT TTree branches for the hit part in the light version (for quasi-online processing)
/*!
*/
class ADHitTreeLight : public EventPSAWatcher, public TTreeBuilder
{
protected:
//! Current timestamp
ULong64_t fTimestamp;
//! used to transform local to global [since otherwise done in tracking]
AgataGeometryTransformer *fTrans;
private:
static const Int_t MaxHits = 500; // Max number of hits in one event
static const Int_t MaxCore = 180; // Max number of cores in one event
//
Int_t nbHits; // Number of hits in the array
Float_t hitE[MaxHits]; // Energie of the hit
Float_t hitX[MaxHits]; // X position of the hit in the Crystal Frame
Float_t hitY[MaxHits]; // Y position of the hit in the Crystal Frame
Float_t hitZ[MaxHits]; // Z position of the hit in the Crystal Frame
Float_t hitGX[MaxHits]; // Position x of hit with , in global frame
Float_t hitGY[MaxHits]; // Position y of hit with , in global frame
Float_t hitGZ[MaxHits]; // Position z of hit with , in global frame
Int_t hitId[MaxHits]; // Segment ID in which a hit occurs
Int_t hitSg[MaxHits]; // Crystal ID in which a hit occurs
Int_t nbCores; // for more than 1 frame (built event)
Int_t coreId[MaxCore]; // for each crystal fired its ID
Float_t coreE0[MaxCore]; // Core energie, high gain ... TODO, Should be one !
ULong64_t coreTS[MaxCore]; // timestamp of core
protected:
virtual void SetBranches();
public:
ADHitTreeLight(const char *name, const char *title, TTree *tree = 0x0);
virtual ~ADHitTreeLight(){;}
//! watch the current frame
virtual void Exec(Option_t *option="");
ClassDef(ADHitTreeLight,0) // built a root tree for the gamma part
};
//! built branches for coincidence between agata and ancillary
/*!
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment