Commit 1bc0c756 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Order in time the hits before tracking

Re-define the hitT value according to the real time from the first hit of the event
parent 3c3703b9
......@@ -717,6 +717,16 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
fTrackEvents[0]++;
fTrackEvents[1] += number_of_hits;
}
if(fVerbose) {
cout<<endl<<endl;
cout<<"List of hits raw:"<<endl;
for(ushort t=0 ; t<number_of_hits ; t++){
cout<<" DetId: "<<pEXYZ[t].Ind<<" - hitE: "<<pEXYZ[t].E<<" - hitT: "<<pEXYZ[t].T<<endl;
}
cout<<endl;
}
if(fExcludeTracking) {
errStatus = 0; // OK if tracking excluded
}
......@@ -731,43 +741,39 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
int saved_number_of_hits = number_of_hits;
memcpy(saved_pEXYZ,pEXYZ,saved_number_of_hits*sizeof(exyzHit));
// sorting of hits in time
for(ushort t=1 ; t<number_of_hits ; t++)
for(int i=0 ; i<number_of_hits-1 ; i++)
if(pEXYZ[i].T > pEXYZ[i+1].T){
swap(pEXYZ[i],pEXYZ[i+1]);
}
uint index=0; // position in the initial array of hits
int tot_number_of_gammas=0; // cumulative number of tracked gamma rays
first_hit = 0; // position of the first hit of a block, to be set in the active Tracking class
int NBlocks=0; // Number of blocks of hits
// cout<<"List of hits:"<<endl;
// for(ushort t=0 ; t<number_of_hits ; t++){
// cout<<pEXYZ[t].Ind<<" "<<pEXYZ[t].Ind<<" "<<pEXYZ[t].E<<" "<<pEXYZ[t].T<<endl;
// }
// cout<<endl;
// loop on all the hits
while(index<saved_number_of_hits) {
// reference time for the next builded block
uint index=0;
int tot_number_of_gammas=0;
first_hit = 0;
if(fVerbose) cout<<"New block (TrackingTimeWindow="<<fTrackTimeWindow<<"):"<<endl;
// Float_t GlobRefTime = pEXYZ[index].T;
NBlocks++;
while(index<saved_number_of_hits) {
// reference time for the next builded block
// reference time of the current block
Float_t RefTime = pEXYZ[index].T;
// value sent to the tracking
// number of hits in the current block
number_of_hits=0;
// cout<<"New block (TrackingTimeWindow="<<fTrackTimeWindow<<"):"<<endl;
// loop on all the hits within the tracking time window
while(pEXYZ[index].T-RefTime<=fTrackTimeWindow && index<saved_number_of_hits){
pEXYZ[number_of_hits] = pEXYZ[index];
// cout<<setw(2)<<pEXYZ[number_of_hits].Det<<" (seg "<<setw(2)<<pEXYZ[number_of_hits].Seg<<") dt in block="<<setw(8)<<pEXYZ[number_of_hits].T-RefTime<<" ; dT Global="<<setw(8)<<pEXYZ[number_of_hits].T-GlobRefTime<<" E="<<setw(8)<<pEXYZ[number_of_hits].E<<endl;
number_of_hits++;
index++;
if(fVerbose) {
cout<<"DetId:"<<setw(2)<<pEXYZ[number_of_hits].Det<<" (seg "<<setw(2)<<pEXYZ[number_of_hits].Seg<<")";
cout<<" - hiT:"<<setw(7)<<pEXYZ[number_of_hits].T;
cout<<" - dt in block="<<setw(8)<<pEXYZ[number_of_hits].T-RefTime;
cout<<" - dt Global="<<setw(8)<<pEXYZ[number_of_hits].T-pEXYZ[0].T;
cout<<" - hitE="<<setw(8)<<pEXYZ[number_of_hits].E<<endl;
}
}
// cout<<"nhits in block: "<<number_of_hits<<endl;
if(fVerbose) cout<<"nhits in block: "<<number_of_hits<<endl;
//Process tracking for the selected block of gammas
Process();
......@@ -782,12 +788,14 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
memcpy(&saved_pGams[tot_number_of_gammas],pGams,number_of_gammas*sizeof(trGamma));
tot_number_of_gammas += number_of_gammas;
// cout<<number_of_gammas<<" tracked gammas"<<endl;
// for(int ii=0 ; ii<number_of_gammas ; ii++){
// cout<<pGams[ii].E<<" "<<pGams[ii].nH<<"(";
// for(int iii=0 ; iii<pGams[ii].nH ; iii++) cout<<pGams[ii].iH[iii]<<" ";
// cout<<")"<<endl;
// }
if(fVerbose) {
cout<<number_of_gammas<<" tracked gammas"<<endl;
for(int ii=0 ; ii<number_of_gammas ; ii++){
cout<<pGams[ii].E<<" "<<pGams[ii].nH<<"(";
for(int iii=0 ; iii<pGams[ii].nH ; iii++) cout<<pGams[ii].iH[iii]<<" ";
cout<<")"<<endl;
}
}
}
// recover the real total number of hits
......@@ -798,19 +806,22 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
number_of_gammas = tot_number_of_gammas;
memcpy(pGams,saved_pGams,number_of_gammas*sizeof(trGamma));
// cout<<"Final traked result:"<<endl;
// cout<<number_of_gammas<<" tracked gammas"<<endl;
// for(int ii=0 ; ii<number_of_gammas ; ii++){
// cout<<pGams[ii].E<<" "<<pGams[ii].nH<<"(";
// for(int iii=0 ; iii<pGams[ii].nH ; iii++) {
// exyzHit *pP = &pEXYZ[pGams[ii].iH[iii]];
// cout<<pGams[ii].iH[iii]<<":"<<pP->E;
// }
// cout<<")"<<endl;
// }
if(fVerbose) {
cout<<"Final traked result:"<<endl;
cout<<number_of_gammas<<" tracked gammas"<<endl;
for(int ii=0 ; ii<number_of_gammas ; ii++){
cout<<pGams[ii].E<<" "<<pGams[ii].nH<<"(";
for(int iii=0 ; iii<pGams[ii].nH ; iii++) {
exyzHit *pP = &pEXYZ[pGams[ii].iH[iii]];
cout<<pGams[ii].iH[iii]<<":"<<pP->E<<" ";
}
cout<<")"<<endl;
}
}
}
else
else {
errStatus = Process(); // normal daughter::Process()
}
}
if( errStatus ) {
error_code = 2;
......@@ -945,7 +956,7 @@ Int_t TrackingFilter::SetInput()
return 18; // ??
}
else {
trigType[nTriggerEventData_10]++; // event:data:psa WITHOUT data:rancN
trigType[nTriggerEventData_10]++; // eve]nt:data:psa WITHOUT data:rancN
}
}
......@@ -1034,6 +1045,13 @@ Int_t TrackingFilter::SetInput()
for(UShort_t nh = 0; nh < number_of_hits; nh++, pt++) {
pt->T += cryst[pt->Ind].tstamp - timestampEvt;
}
// ordering the hist in time rather than in detector id
for(ushort t=1 ; t<number_of_hits ; t++)
for(int i=0 ; i<number_of_hits-1 ; i++)
if(pEXYZ[i].T > pEXYZ[i+1].T){
swap(pEXYZ[i],pEXYZ[i+1]);
}
}
if(hasAncillary)
timestampAnc += timestampAnc-timestampEvt;
......@@ -1270,34 +1288,41 @@ Int_t TrackingFilter::SetOutput()
number_of_tracked_gammas += number_of_gammas;
Float_t sum1=0.;
Float_t sum2=0.;
if(fVerbose) cout<<"Number of tracked gammas: "<<number_of_gammas<<endl;
// loop on the tracked gammas
trGamma *pG = pGams;
int numUsed = 0;
for (Int_t ii = 0; ii < number_of_gammas; ii++, pG++) {
TrackedHit *ahit = trackdata->NewGamma();
sum1+=pG->E;
ahit->SetStatus(0);
ahit->SetE(pG->E); // energy, passed over in units of keV
ahit->SetXYZ(pG->X1, pG->Y1, pG->Z1); // 3D position of the tracked gamma is the first hit
ahit->SetT(pG->T); // time of the tracked gamma
ahit->SetType((UShort_t)pG->type);
ahit->SetFOM((Double_t)pG->FOM);
Float_t ESum=0.;
if(fVerbose) cout<<"gamma "<<ii<<": "<<pG->T<<" E: "<<pG->E<<endl;
// the interaction points of the gamma; still writing only first 2 for compton and only one for pair-production
for (Int_t nh = 0; nh < pG->nH; nh++) { // Decision on how many hits to write taken later in (pG-type!=2) and if(nh==1)
exyzHit *pP = pEXYZ + pG->iH[nh]; // Original hit of this interaction point; all info taken from here
Hit *pH = ahit->NewHit();
pH->SetE(pP->E);
pH->SetXYZ(pP->X, pP->Y, pP->Z);
pH->SetT(pP->T);
pH->SetT(pP->T-pEXYZ[0].T); // Hit T related to the first hit time value
pH->SetID(pP->Seg, 0);
pH->SetID(pP->Det, 1);
sum2+=pP->E;
ESum+=pP->E;
//if(pG->type != 2) break; // pair-production writes only one point (like photo, of course)
//if(nh == 1) break; // limit compton scattering to firse two points
if(fVerbose) cout<<"hit "<<nh<<": "<<pP->T<<" E:"<<pP->E<<endl;
}
if(fVerbose) cout<<" ==> ESum= "<<ESum<<endl;
numUsed += pG->nH;
}
......
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