Skip to content

Commit

Permalink
Adding new intwindow method to TRestDetectorSignalToHitsProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
juanangp committed Jan 29, 2022
1 parent 0400979 commit 59881d1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
11 changes: 10 additions & 1 deletion inc/TRestDetectorSignalToHitsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {
/// The method used to transform the signal points to hits.
TString fMethod = "tripleMax";

//Time window to integrate in case intwindow method is requested
Int_t fIntWindow=5;

//Threshold value for in case intwindow method is requested
Double_t fThreshold = 100.;

public:
any GetInputEvent() { return fSignalEvent; }
any GetOutputEvent() { return fHitsEvent; }
Expand All @@ -80,8 +86,11 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {
metadata << "Electric field : " << fElectricField * units("V/cm") << " V/cm" << endl;
metadata << "Gas pressure : " << fGasPressure << " atm" << endl;
metadata << "Drift velocity : " << fDriftVelocity << " mm/us" << endl;

metadata << "Signal to hits method : " << fMethod << endl;
if(fMethod=="intwindow"){
metadata << "Threshold : " << fThreshold <<" ADC" <<endl;
metadata << "Integral window : " << fIntWindow << endl;
}

EndPrintProcess();
}
Expand Down
37 changes: 34 additions & 3 deletions src/TRestDetectorSignalToHitsProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
/// averaged on all points (Perhaps this is not the most appropiate?).
/// * **all**: It will simply transport all points found at the TRestSignal
/// to the TRestDetetorHitsEvent.
/// * **intwindow**: Splits the time into a window defined by fIntwindow
/// while performing the average of the data points. Every point corresponds
/// to a Hit
///
/// \htmlonly <style>div.image img[src="signalToHits.png"]{width:800px;}</style> \endhtmlonly
///
Expand All @@ -98,6 +101,9 @@
/// 2016-January: First concept and implementation.
/// \author Javier Galan
///
/// 2022-January: Implementing new method intwindod
/// \author JuanAn Garcia
///
/// \class TRestDetectorSignalToHitsProcess
///
/// <hr>
Expand Down Expand Up @@ -213,10 +219,12 @@ TRestEvent* TRestDetectorSignalToHitsProcess::ProcessEvent(TRestEvent* evInput)
fHitsEvent->SetSubEventTag(fSignalEvent->GetSubEventTag());

debug << "TRestDetectorSignalToHitsProcess. Event id : " << fHitsEvent->GetID() << endl;
if (GetVerboseLevel() >= REST_Debug) fSignalEvent->PrintEvent();
if (GetVerboseLevel() >= REST_Extreme) fSignalEvent->PrintEvent();

Int_t numberOfSignals = fSignalEvent->GetNumberOfSignals();

if(numberOfSignals==0)return nullptr;

Int_t planeID, readoutChannel = -1, readoutModule;
for (int i = 0; i < numberOfSignals; i++) {
TRestDetectorSignal* sgnl = fSignalEvent->GetSignal(i);
Expand Down Expand Up @@ -336,8 +344,31 @@ TRestEvent* TRestDetectorSignalToHitsProcess::ProcessEvent(TRestEvent* evInput)

fHitsEvent->AddHit(x, y, z, energy, 0, type);
}
}
else
} else if (fMethod == "intwindow" ) {
Int_t nPoints = sgnl->GetNumberOfPoints();
for(int j= 0; j<nPoints-fIntWindow;j+=fIntWindow){
double energy =0;
double time =0;
for(int p=0;p<fIntWindow;p++){
energy += (double)sgnl->GetData(j+p);
time += (double)sgnl->GetTime(j+p);
}
if(fIntWindow>0){
energy /= (double)fIntWindow;
time /= (double)fIntWindow;
}
if(energy < fThreshold ) continue;
debug<<"TimeBin "<<j<<"-"<<j+(fIntWindow -1)<<" Time "<<time<<" Charge: "<<energy <<" Thr: " <<(fThreshold)<<endl;
Double_t distanceToPlane = time * fDriftVelocity;
Double_t z = zPosition + fieldZDirection * distanceToPlane;

debug << "Time : " << time << " Drift velocity : " << fDriftVelocity << "\nDistance to plane : " << distanceToPlane << endl;
debug << "Adding hit. Time : " << time << " x : " << x << " y : " << y << " z : " << z <<" type "<<type<<endl;

fHitsEvent->AddHit(x, y, z, energy, 0, type);
}

} else
{
string errMsg = "The method " + (string) fMethod + " is not implemented!";
SetError( errMsg );
Expand Down

0 comments on commit 59881d1

Please sign in to comment.