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

Emulator : Change bytesread to float (Int not sufficient)

ADTree : Correct an error in the filling of psa hits
ADTree : Adding a branch of addback energy


git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@2269 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent e4b0b7f7
......@@ -610,6 +610,8 @@ void GuiBuildTree::ProcessRun(int RunIndex)
prod->SetProgressBar(fProgressBar);
fProgressBar->Reset();
fWatch->Start();
// loop
femulator->Run();
......@@ -632,6 +634,12 @@ void GuiBuildTree::ProcessRun(int RunIndex)
femulator->GetBaseConsumer()->GetFrameIO().Print();
fWatch->Stop();
cout<<"GuiBuildTree timer:"<<endl;
fWatch->Print();
cout << " --> Bytes read : " << femulator->GetBytesRead()/1024.*1024. << " MB"<< endl;
cout << " --> Reading rate : " << femulator->GetBytesRead() / (1024.*1024.*fWatch->RealTime()) << " MB/s"<< endl ;
delete fd;
......@@ -663,16 +671,7 @@ void GuiBuildTree::Start()
for (uint i=0 ; i<NFiles ; i++)
{
if(IsProcessing)
{
fWatch->Start();
ProcessRun(i);
fWatch->Stop();
cout<<"GuiBuildTree timer:"<<endl;
fWatch->Print();
cout << " --> Reading rate " << femulator->GetBytesRead() / (1024*1024*fWatch->RealTime()) << " MB/s"<< endl ;
}
}
EnableEntries();
......@@ -688,11 +687,6 @@ void GuiBuildTree::Stop()
{
femulator->Stop();
fWatch->Stop();
cout<<"GuiBuildTree timer:"<<endl;
fWatch->Print();
cout << " --> Reading rate " << femulator->GetBytesRead() / (1024*1024*fWatch->RealTime()) << " MB/s"<< endl ;
IsProcessing = false;
gROOT->SetBatch(false);
}
......
......@@ -273,6 +273,13 @@ void ADHitTree::SetBranches()
GetTree()->Branch("hit_per_cryst", hit_per_cryst,"hit_per_cryst[nbCores]/I");
GetTree()->Branch("coreTS", coreTS,"coreTS[nbCores]/l");
GetTree()->Branch("nbAdd", &nbAdd,"nbAdd/I");
GetTree()->Branch("AddE", AddE,"AddE[nbAdd]/F");
GetTree()->Branch("AddX", AddX,"AddX[nbAdd]/F");
GetTree()->Branch("AddY", AddY,"AddY[nbAdd]/F");
GetTree()->Branch("AddZ", AddZ,"AddZ[nbAdd]/F");
GetTree()->Branch("TSHit", &fTimestamp, "TSHit/l");
}
......@@ -291,6 +298,8 @@ void ADHitTree::Exec(Option_t * /*option*/)
return;
}
ESum = 0.;
fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
Double_t max_e0 = 0.0;
......@@ -307,17 +316,18 @@ void ADHitTree::Exec(Option_t * /*option*/)
}
nbCores = GetNbFramePSA();
nbHits=0;
for(Int_t i=0 ; i < nbCores ; i++)
{
PSAInterface *data = GetDataPSA(i);
nbHits = data->GetNbHits();
Int_t nbHitsperCry = data->GetNbHits();
if ( nbHits == MaxHits )
if ( nbHitsperCry == MaxHits )
{
SetLastExecStatus(1u);
fLog << error << " Number of Hits to hit in : " << nbHits << "Max nbHits = " << MaxHits << nline;
fLog << error << " Number of Hits to hit in : " << nbHitsperCry << "Max nbHits = " << MaxHits << nline;
nbHits = 0;
nbCores = 0;
......@@ -334,22 +344,22 @@ void ADHitTree::Exec(Option_t * /*option*/)
coreE1[i] = data->GetE(1u);
coreT0[i] = data->GetT();
coreT1[i] = data->GetT(1u);
hit_per_cryst[i] = nbHits;
hit_per_cryst[i] = nbHitsperCry;
coreTS[i] = ((AgataKey *)fPSAFrame->GetKey())->GetTimeStamp();
// Loop on the hit to get over the hits with the max of the energy
max_e0 = 0.0;
for (Int_t j = 0; j < nbHits; ++j)
for (Int_t j = 0; j < nbHitsperCry; ++j)
{
const PSAHit* pHit = (PSAHit*)data->GetHit(j);
hitE[j] = pHit->GetE();
ESum += hitE[j];
hitX[j] = pHit->GetX();
hitY[j] = pHit->GetY();
hitZ[j] = pHit->GetZ();
hitId[j] = data->GetUID() ;
hitSg[j] = pHit->GetID();
hitE[nbHits+j] = pHit->GetE();
ESum += hitE[nbHits+j];
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);
......@@ -357,9 +367,9 @@ void ADHitTree::Exec(Option_t * /*option*/)
fTrans->Local2Global(data->GetUID(), xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal);
// Set the Position of the hit in global ref of PRESPEC
hitGX[j]= xGlobal; // inversion X-Y and opposite direction
hitGY[j]= yGlobal; // inversion Y-X and opposite direction
hitGZ[j]= zGlobal; // z
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
// Now look for the hit with the highest energy, taken for Doppler correction
// Kind of tracking in crystal
......@@ -369,7 +379,7 @@ void ADHitTree::Exec(Option_t * /*option*/)
//To the AGATA global ref
fTrans->Local2Global(data->GetUID(), xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal);
if ( hitE[j] > max_e0 ) { // gamma contains the position of the interaction with the highest energy in 3D
if ( hitE[nbHits+j] > max_e0 ) { // gamma contains the position of the interaction with the highest energy in 3D
gamma.SetXYZ(xGlobal, yGlobal, zGlobal);
max_e0 = pHit->GetE();
}
......@@ -384,11 +394,121 @@ void ADHitTree::Exec(Option_t * /*option*/)
}
coreDE0[i] = edc0; //if there is no vertex, no energy
coreDE1[i] = edc1; //if there is no vertex, no energy
nbHits += nbHitsperCry;
}
CleverAddback();
FillTree();
}
void ADHitTree::CleverAddback()
{
vector<EHit*> ListOfHits;
for(int i=0 ; i<nbHits ; i++)
{
EHit *a_hit = new EHit();
a_hit->SetX(hitGX[i]);
a_hit->SetY(hitGY[i]);
a_hit->SetZ(hitGZ[i]);
a_hit->SetE(hitE[i]);
a_hit->SetID(hitId[i]);
ListOfHits.push_back(a_hit);
}
vector< vector<EHit*> > ListOfPacks;
while(ListOfHits.size())
{
EHit *MaxHit = 0x0;
UInt_t imax=0;
///Looking for the higher energy hit
for(uint i=0 ; i<ListOfHits.size() ; i++)
{
EHit *a_hit = ListOfHits[i];
if(MaxHit == 0x0) MaxHit = a_hit;
else if(a_hit->GetE() > MaxHit->GetE())
{
MaxHit = a_hit;
imax = i;
}
}
vector<EHit*> Pack;
///Moving the higher energy hit in the list of packed hits
ListOfHits.erase(ListOfHits.begin()+imax);
Pack.push_back(MaxHit);
TVector3 PackedHitPosPond(MaxHit->GetX()*MaxHit->GetE(),MaxHit->GetY()*MaxHit->GetE(),MaxHit->GetZ()*MaxHit->GetE());
double PondFactor = MaxHit->GetE();
TVector3 MeanPos = PackedHitPosPond*(1./PondFactor);
///Looking for hits located at a distance from the high energy hit lower than the selected spatial resolution
for(uint i=0 ; i<ListOfHits.size() ; i++)
{
EHit *a_hit = ListOfHits[i];
TVector3 HitPos(a_hit->GetX(),a_hit->GetY(),a_hit->GetZ());
TVector3 Diff = HitPos-MeanPos;
double distance = Diff.Mag();
// double distance2 = sqrt((a_hit->GetX()-MaxHit->GetX())*(a_hit->GetX()-MaxHit->GetX()) + (a_hit->GetY()-MaxHit->GetY())*(a_hit->GetY()-MaxHit->GetY()) + (a_hit->GetZ()-MaxHit->GetZ())*(a_hit->GetZ()-MaxHit->GetZ()));
// cout<<a_hit->GetX()<<" "<<a_hit->GetY()<<" "<<a_hit->GetZ()<<" "<<a_hit->GetE()<<" "<<a_hit->GetID()<<" "<<distance<<" "<<distance2<<endl;
if(distance<60)
{
TVector3 HitPosPond(a_hit->GetX()*a_hit->GetE(),a_hit->GetY()*a_hit->GetE(),a_hit->GetZ()*a_hit->GetE());
PackedHitPosPond += HitPosPond;
PondFactor += a_hit->GetE();
MeanPos = PackedHitPosPond*(1./PondFactor);
ListOfHits.erase(ListOfHits.begin()+i);
Pack.push_back(a_hit);
i--;
}
}
ListOfPacks.push_back(Pack);
}
nbAdd = ListOfPacks.size();
for(int i=0 ; i<nbAdd ; i++)
{
vector<EHit*> Pack = ListOfPacks[i];
Float_t EMax=0.;
EHit *hitMax = 0x0;
Float_t ETot=0.;
for(uint j=0 ; j<Pack.size() ; j++)
{
EHit *a_hit = Pack[j];
ETot+= a_hit->GetE();
if(a_hit->GetE() > EMax)
{
EMax = a_hit->GetE();
hitMax = a_hit;
}
}
AddX[i] = hitMax->GetX();
AddY[i] = hitMax->GetY();
AddZ[i] = hitMax->GetZ();
AddE[i] = ETot;
}
}
Double_t ADHitTree::DoDopplerCorrection(const TrackedHit *hit, VertexInterface *vertex)
{
Double_t e = hit->GetE(), beta = vertex->GetBeta(), gamma = vertex->GetGamma();
......
......@@ -156,6 +156,12 @@ private:
Float_t coreDE0[MaxCore]; // Doppler with position from Hit with Max E
Float_t coreDE1[MaxCore]; // Doppler with position from Hit with Max E
//
Int_t nbAdd;
Float_t AddE[MaxHits];
Float_t AddX[MaxHits];
Float_t AddY[MaxHits];
Float_t AddZ[MaxHits];
Float_t velDop; // Beta for the doppler correction
Int_t hit_per_cryst[MaxCore]; // Number of hits for each cryst ID i.e. dans each data:psa frames
ULong64_t coreTS[MaxCore]; // timestamp of core
......@@ -176,6 +182,8 @@ public:
//! Filling the spectra
void FillSpectraByUser();
void CleverAddback();
ClassDef(ADHitTree,0) // built a root tree for the gamma part
};
......
......@@ -216,7 +216,7 @@ private:
std::string fPathCons;
bool floopon;
Int_t fBytesRead;
Float_t fBytesRead;
public:
EmulatorPC(const char *path, UInt_t bsize = aMByte);
......@@ -249,7 +249,7 @@ public:
virtual void Stop();
Int_t GetBytesRead(){return fBytesRead;}
Float_t GetBytesRead(){return fBytesRead;}
};
template <typename Prod_actor, typename Cons_actor>
......
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