Commit d6779df4 authored by Chad Lantz's avatar Chad Lantz
Browse files

Added multiple hit detection and modified dependent functions accordingly

parent 87d19364
......@@ -32,7 +32,10 @@ class Channel {
* [4,4] [4,3] [4,2] [4,1]
* 2021 mapping will come with the dedicated classes
*/
/** Type of detector - ZDC or RPD **/
/*
* Hardware channel information
*/
/** Type of detector - ZDC or RPD **/
std::string detector;
/** Channel name - CXX with XX in [1,20] */
std::string name;
......@@ -52,6 +55,11 @@ class Channel {
int Vop;
/** PMT reference code **/
std::string PMTcode;
/** Polarity of the channel */
bool pos_polarity;
/*
* Waveform storage
*/
/** Raw waveform for a particular event */
std::vector < float > WF;
/** First derivative of the waveform for a particular event */
......@@ -68,43 +76,9 @@ class Channel {
TH1D* FirstDerivative;
/** Fitting function for the PMT pulse **/
TF1* FitFunc;
/** RMS value of the first derrivative of the waveform **/
double FirstDerivativeRMS;
/** Bin number of the peak center*/
int Peak_center;
/** Bin number of the derivative peak */
int Diff_Peak_center;
/** Calibrated time of the peak center in ns*/
double Peak_time;
/** Calibrated time of max slope in ns*/
double Diff_Peak_time;
/** Height of the peak */
double Peak_max;
/** Max value of the derivative */
double Diff_max;
/** Bin number of 1/3 peak value on the rising edge*/
int DiscriminatorTime;
/** Start and end of the hit window*/
std::pair< int, int > hit_window;
/** Flag if the channel was hit */
bool was_hit;
/** Flag if the waveform saturated */
bool saturated;
/** Polarity of the channel */
bool pos_polarity;
/** Flag if the waveform has a DRS4 spike present */
bool spike;
/** Pedestal of raw waveform */
double PedMean;
/** Pedestal RMS of raw waveform */
double PedRMS;
/** Integral of PWF_histo in the hit window in pC */
double Charge;
/** Crossing zero points - dummy - to be checked by Sheng **/
std::vector < int > CrossZeroPoints;
/*
* Waveform processing variables
*/
* Waveform processing variables
*/
/** Flag if the low pass filtering is to be performed on this channel */
bool doLPF;
/** Flag if DRS4 non-linearity compensation is to be performed on this channel */
......@@ -119,6 +93,37 @@ class Channel {
int LPFfreq;
/** Median filtering half window size */
int medFiltHalfWindow;
/*
* Variables produced by WFAnalysis
*/
/** Flag if the channel was hit */
bool was_hit;
/** Number of hits detected in a single event */
int nHits;
/** Pair of vectors containing the start and end of each hit window*/
std::pair< std::vector< int >, std::vector< int > > hit_window;
/** RMS value of the first derrivative of the waveform **/
double FirstDerivativeRMS;
/** Vector of bin number of the peak location*/
std::vector< int > Peak_center;
/** Vector of bin number of the derivative peaks */
std::vector< int > Diff_Peak_center;
/** Vector of calibrated time of the peak in ns*/
std::vector< double > Peak_time;
/** Vector of calibrated time of max slope for each hit in ns*/
std::vector< double > Diff_Peak_time;
/** Vector of height of the peaks */
std::vector< double > Peak_max;
/** Vector of max value of the derivative in each hit window */
std::vector< double > Diff_max;
/** Vector of integral of PWF_histo in each hit window in pC */
std::vector< double > Charge;
/** Pedestal of raw waveform */
double PedMean;
/** Pedestal RMS of raw waveform */
double PedRMS;
/** Flag if the waveform saturated */
bool saturated;
};
......
......@@ -42,13 +42,12 @@ class WFAnalysis : public Analysis{
virtual void AnalyzeEvent ( const std::vector< std::vector< float > >& );
virtual void AnalyzeEvent ( const std::vector< Channel* > vCh );
virtual int GetMaximumBin ( TH1* h, int _start, int _end );
virtual double GetCharge ( Channel* ch, int start, int end );
virtual void GetDifferential ( Channel* Ch );
virtual double GetRMS ( Channel* Ch );
virtual void GetPedestal ( Channel* ch );
virtual void SubtractPedestal( Channel* ch );
virtual void GetCharge ( Channel* ch );
virtual void FindHitWindow ( Channel* ch );
virtual void FindHitWindowNew( Channel* ch );
virtual void ZeroSuppress ( Channel* ch );
virtual void MedianFilter ( Channel* ch );
virtual void LowPassFilter ( Channel* ch, TH1D* hIn = 0 );
......
......@@ -127,7 +127,6 @@ void Detector::FillHistograms(){
m_Element.at(ch)->FirstDerivative->Reset();
m_Element.at(ch)->vDiff.clear();
m_Element.at(ch)->FirstDerivativeRMS = 0;
m_Element.at(ch)->CrossZeroPoints.clear();
m_Element.at(ch)->FitFunc->SetParameters(25000,0.5,2,500);
// Loop over samples in each channel
for( uint samp = 0; samp < m_nSamp; samp++ ){
......@@ -163,14 +162,16 @@ void Detector::PlotWF( int eventNum ){
if(m_Element[ch]->is_on){
m_Element[ch]->WF_histo->ResetStats();
if(m_Element[ch]->was_hit){
//Draw vertical red lines around the hit window
hMarksFront->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first, m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.first, m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(ch)->back())->SetLineColor(kRed);
hMarksFront->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second, m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.second, m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(ch)->back())->SetLineColor(kRed);
hMarksFront->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center, m_Element[ch]->Peak_max + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksFront->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksFront->at(ch)->back())->SetMarkerSize(3);
for(int hit = 0; hit < m_Element[ch]->nHits; hit++){
//Draw vertical red lines around the hit window
hMarksFront->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first[hit], m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.first[hit], m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(ch)->back())->SetLineColor(kRed);
hMarksFront->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second[hit], m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.second[hit], m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(ch)->back())->SetLineColor(kRed);
hMarksFront->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center[hit], m_Element[ch]->Peak_max[hit] + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksFront->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksFront->at(ch)->back())->SetMarkerSize(3);
}//end hit loop
}//end if channel was hit
}//end if channel is on
}//end channels loop
......@@ -223,16 +224,18 @@ void Detector::PlotWFandDerivative( int eventNum, double _yMin1, double _yMax1,
m_Element[ch]->WF_histo->ResetStats();
if(m_Element[ch]->was_hit){
//Draw vertical red lines around the hit window
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first, -2950, m_Element[ch]->hit_window.first, -2600) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second, -2950, m_Element[ch]->hit_window.second, -2600) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
//Draw an X on the peak
hMarksBack->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center, m_Element[ch]->Peak_max + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerSize(3);
for(int hit = 0; hit < m_Element[ch]->nHits; hit++){
//Draw vertical red lines around the hit window
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first[hit], -2950, m_Element[ch]->hit_window.first[hit], -2600) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second[hit], -2950, m_Element[ch]->hit_window.second[hit], -2600) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
//Draw an X on the peak
hMarksBack->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center[hit], m_Element[ch]->Peak_max[hit] + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerSize(3);
}//end hit loop
}//end if channel was hit
}//end if channel is on
}//end channel loop
......@@ -279,17 +282,19 @@ void Detector::PlotWFandPWF( int eventNum, double _yMin1, double _yMax1, double
if(m_Element[ch]->is_on){
m_Element[ch]->WF_histo->ResetStats();
if(m_Element[ch]->was_hit){
//Draw vertical red lines around the hit window
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first, m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.first, m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second,m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.second, m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center, m_Element[ch]->Peak_max + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerSize(3);
hMarksFront->at(ch)->push_back( m_Element[ch]->FitFunc );
((TF1*)hMarksFront->at(ch)->back())->SetRange(m_Element[ch]->hit_window.first, m_Element[ch]->hit_window.second);
((TF1*)hMarksFront->at(ch)->back())->SetLineColor(kCyan);
for(int hit = 0; hit < m_Element[ch]->nHits; hit++){
//Draw vertical red lines around the hit window
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.first[hit], m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.first[hit], m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TLine( m_Element[ch]->hit_window.second[hit],m_Element[ch]->WF_histo->GetMinimum(), m_Element[ch]->hit_window.second[hit], m_Element[ch]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(ch)->back())->SetLineColor(kRed);
hMarksBack->at(ch)->push_back( new TMarker( m_Element[ch]->Peak_center[hit], m_Element[ch]->Peak_max[hit] + m_Element[ch]->PedMean, 5) );
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(ch)->back())->SetMarkerSize(3);
// hMarksFront->at(ch)->push_back( m_Element[ch]->FitFunc );
// ((TF1*)hMarksFront->at(ch)->back())->SetRange(m_Element[ch]->hit_window.first, m_Element[ch]->hit_window.second);
// ((TF1*)hMarksFront->at(ch)->back())->SetLineColor(kCyan);
}//end hit loop
}//end if channel was hit
}//end if channel is on
}//end channel loop
......
......@@ -113,17 +113,17 @@ void EMAnalysis::SetBranches( TTree* _tree ){
for(int row = 0; row < m_numRows; row++){
for(int col = 0; col < m_numCols; col++){
m_AnalysisTree->Branch( Form("em%d_%d_Charge", row, col), &em[row][col]->Charge, Form("em%d_%d_Charge/D", row, col) );
m_AnalysisTree->Branch( Form("em%d_%d_Peak_max", row, col), &em[row][col]->Peak_max, Form("em%d_%d_Peak_max/D", row, col) );
m_AnalysisTree->Branch( Form("em%d_%d_Diff_max", row, col), &em[row][col]->Diff_max, Form("em%d_%d_Diff_max/D", row, col) );
m_AnalysisTree->Branch( Form("em%d_%d_Peak_center", row, col), &em[row][col]->Peak_center, Form("em%d_%d_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("em%d_%d_Diff_Peak_center", row, col), &em[row][col]->Diff_Peak_center, Form("em%d_%d_Diff_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("em%d_%d_Charge", row, col), "std::vector<double>", &em[row][col]->Charge );
m_AnalysisTree->Branch( Form("em%d_%d_Peak_max", row, col), "std::vector<double>", &em[row][col]->Peak_max );
m_AnalysisTree->Branch( Form("em%d_%d_Diff_max", row, col), "std::vector<double>", &em[row][col]->Diff_max );
m_AnalysisTree->Branch( Form("em%d_%d_Peak_center", row, col), "std::vector<int>", &em[row][col]->Peak_center );
m_AnalysisTree->Branch( Form("em%d_%d_Diff_Peak_center", row, col), "std::vector<int>", &em[row][col]->Diff_Peak_center );
}
}
m_AnalysisTree->Branch("em_Charge_sum", &ChargeSum, "ChargeSum/D" );
m_AnalysisTree->Branch("em_Peak_sum", &PeakSum, "PeakSum/D" );
m_AnalysisTree->Branch("em_Diff_Peak_sum", &DiffPeakSum, "DiffPeakSum/D" );
m_AnalysisTree->Branch("em_Charge_sum", &ChargeSum, "ChargeSum/D" );
m_AnalysisTree->Branch("em_Peak_sum", &PeakSum, "PeakSum/D" );
m_AnalysisTree->Branch("em_Diff_Peak_sum",&DiffPeakSum,"DiffPeakSum/D" );
}
......@@ -140,16 +140,18 @@ void EMAnalysis::AnalyzeEvent( ){
for(int row = 0; row < m_numRows; row++){
for(int col = 0; col < m_numCols; col++){
if( em[row][col]->is_on ){
ChargeSum += em[row][col]->Charge;
PeakSum += em[row][col]->Peak_max;
DiffPeakSum += em[row][col]->Diff_max;
hChargeArr[row][col]->Fill(em[row][col]->Charge);
hPeakArr[row][col]->Fill(em[row][col]->Peak_max);
hDPeakArr[row][col]->Fill(em[row][col]->Diff_max);
}
}
}
for(int hit = 0; hit < em[row][col]->nHits; hit++){
ChargeSum += em[row][col]->Charge[hit];
PeakSum += em[row][col]->Peak_max[hit];
DiffPeakSum += em[row][col]->Diff_max[hit];
hChargeArr[row][col]->Fill(em[row][col]->Charge[hit]);
hPeakArr[row][col]->Fill(em[row][col]->Peak_max[hit]);
hDPeakArr[row][col]->Fill(em[row][col]->Diff_max[hit]);
}//end hits loop
}//end if channel is on
}//end column loop
}//end row loop
//This loop finds the center of mass per event (should probably be it's own function)
......@@ -159,9 +161,11 @@ void EMAnalysis::AnalyzeEvent( ){
for(int i = 0; i < m_numRows; i++){
for(int j = 0; j < m_numCols; j++){
if( em[i][j]->is_on && em[i][j]->was_hit ){
totalCharge += em[i][j]->Charge;
weightedRow += em[i][j]->Charge * zPos[i];
weightedCol += em[i][j]->Charge * xPos[j];
for(int hit = 0; hit < em[i][j]->nHits; hit++){
totalCharge += em[i][j]->Charge[hit];
weightedRow += em[i][j]->Charge[hit] * zPos[i];
weightedCol += em[i][j]->Charge[hit] * xPos[j];
}
}
}
}
......
......@@ -117,11 +117,11 @@ void RPDAnalysis::SetBranches( TTree* _tree ){
for(int row = 0; row < 4; row++){
for(int col = 0; col < 4; col++){
m_AnalysisTree->Branch( Form("rpd%d_%d_Charge", row, col), &rpd[row][col]->Charge, Form("rpd%d_%d_Charge/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_max", row, col), &rpd[row][col]->Peak_max, Form("rpd%d_%d_Peak_max/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_max", row, col), &rpd[row][col]->Diff_max, Form("rpd%d_%d_Diff_max/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_center", row, col), &rpd[row][col]->Peak_center, Form("rpd%d_%d_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_Peak_center", row, col), &rpd[row][col]->Diff_Peak_center, Form("rpd%d_%d_Diff_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Charge", row, col), "std::vector<double>", &rpd[row][col]->Charge );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_max", row, col), "std::vector<double>", &rpd[row][col]->Peak_max );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_max", row, col), "std::vector<double>", &rpd[row][col]->Diff_max );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_center", row, col), "std::vector<int>", &rpd[row][col]->Peak_center );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_Peak_center", row, col), "std::vector<int>", &rpd[row][col]->Diff_Peak_center );
}
}
......@@ -146,16 +146,18 @@ void RPDAnalysis::AnalyzeEvent( ){
for(int row = 0; row < 4; row++){
for(int col = 0; col < 4; col++){
if( rpd[row][col]->is_on ){
ChargeSum += rpd[row][col]->Charge;
PeakSum += rpd[row][col]->Peak_max;
DiffPeakSum += rpd[row][col]->Diff_max;
hChargeArr[row][col]->Fill(rpd[row][col]->Charge);
hPeakArr[row][col]->Fill(rpd[row][col]->Peak_max);
hDPeakArr[row][col]->Fill(rpd[row][col]->Diff_max);
}
}
}
for(int hit = 0; hit < rpd[row][col]->nHits; hit++){
ChargeSum += rpd[row][col]->Charge[hit];
PeakSum += rpd[row][col]->Peak_max[hit];
DiffPeakSum += rpd[row][col]->Diff_max[hit];
hChargeArr[row][col]->Fill(rpd[row][col]->Charge[hit]);
hPeakArr[row][col]->Fill(rpd[row][col]->Peak_max[hit]);
hDPeakArr[row][col]->Fill(rpd[row][col]->Diff_max[hit]);
}//end hit loop
}//end if channel is on
}//end column loop
}//end row loop
//This loop finds the center of mass per event (should probably be it's own function)
......@@ -165,12 +167,14 @@ void RPDAnalysis::AnalyzeEvent( ){
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if( rpd[i][j]->is_on && rpd[i][j]->was_hit ){
totalCharge += rpd[i][j]->Charge;
weightedRow += rpd[i][j]->Charge * yPos[i];
weightedCol += rpd[i][j]->Charge * xPos[j];
}
}
}
for(int hit = 0; hit < rpd[i][j]->nHits; hit++){
totalCharge += rpd[i][j]->Charge[hit];
weightedRow += rpd[i][j]->Charge[hit] * yPos[i];
weightedCol += rpd[i][j]->Charge[hit] * xPos[j];
}//end hit loop
}//end if channel is on
}//end column loop
}//end row loop
xCoM = weightedCol/totalCharge;
yCoM = weightedRow/totalCharge;
hCenter->Fill(xCoM,yCoM);
......
......@@ -131,11 +131,11 @@ void RPDAnalysis2021::SetBranches( TTree* _tree ){
for(int row = 0; row < 4; row++){
for(int col = 0; col < 4; col++){
m_AnalysisTree->Branch( Form("rpd%d_%d_Charge", row, col), &rpd[row][col]->Charge, Form("rpd%d_%d_Charge/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_max", row, col), &rpd[row][col]->Peak_max, Form("rpd%d_%d_Peak_max/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_max", row, col), &rpd[row][col]->Diff_max, Form("rpd%d_%d_Diff_max/D", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_center", row, col), &rpd[row][col]->Peak_center, Form("rpd%d_%d_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_Peak_center", row, col), &rpd[row][col]->Diff_Peak_center, Form("rpd%d_%d_Diff_Peak_center/I", row, col) );
m_AnalysisTree->Branch( Form("rpd%d_%d_Charge", row, col), "std::vector<double>", &rpd[row][col]->Charge );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_max", row, col), "std::vector<double>", &rpd[row][col]->Peak_max );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_max", row, col), "std::vector<double>", &rpd[row][col]->Diff_max );
m_AnalysisTree->Branch( Form("rpd%d_%d_Peak_center", row, col), "std::vector<int>", &rpd[row][col]->Peak_center );
m_AnalysisTree->Branch( Form("rpd%d_%d_Diff_Peak_center", row, col), "std::vector<int>", &rpd[row][col]->Diff_Peak_center );
}
}
......@@ -160,16 +160,18 @@ void RPDAnalysis2021::AnalyzeEvent( ){
for(int row = 0; row < 4; row++){
for(int col = 0; col < 4; col++){
if( rpd[row][col]->is_on ){
ChargeSum += rpd[row][col]->Charge;
PeakSum += rpd[row][col]->Peak_max;
DiffPeakSum += rpd[row][col]->Diff_max;
hChargeArr[row][col]->Fill(rpd[row][col]->Charge);
hPeakArr[row][col]->Fill(rpd[row][col]->Peak_max);
hDPeakArr[row][col]->Fill(rpd[row][col]->Diff_max);
}
}
}
for(int hit = 0; hit < rpd[row][col]->nHits; hit++){
ChargeSum += rpd[row][col]->Charge[hit];
PeakSum += rpd[row][col]->Peak_max[hit];
DiffPeakSum += rpd[row][col]->Diff_max[hit];
hChargeArr[row][col]->Fill(rpd[row][col]->Charge[hit]);
hPeakArr[row][col]->Fill(rpd[row][col]->Peak_max[hit]);
hDPeakArr[row][col]->Fill(rpd[row][col]->Diff_max[hit]);
}//end hit loop
}//end if channel is on
}//end column loop
}//end row loop
//This loop finds the center of mass per event (should probably be it's own function)
......@@ -179,12 +181,14 @@ void RPDAnalysis2021::AnalyzeEvent( ){
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if( rpd[i][j]->is_on && rpd[i][j]->was_hit ){
totalCharge += rpd[i][j]->Charge;
weightedRow += rpd[i][j]->Charge * yPos[i];
weightedCol += rpd[i][j]->Charge * xPos[j];
}
}
}
for(int hit = 0; hit < rpd[i][j]->nHits; hit++){
totalCharge += rpd[i][j]->Charge[hit];
weightedRow += rpd[i][j]->Charge[hit] * yPos[i];
weightedCol += rpd[i][j]->Charge[hit] * xPos[j];
}//end hit loop
}//end if channel is on
}//end column loop
}//end row loop
//To draw low level plots of the waveforms primarily for validation of the WFAnalysis
// PlotWF( m_counter );
......@@ -225,21 +229,22 @@ void RPDAnalysis2021::PlotWF(int eventNum){
if(rpd[row][col]->was_hit){
//Hit window start
hMarksFront->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksFront->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksFront->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center, rpd[row][col]->Peak_max + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksFront->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksFront->at(tile)->back())->SetMarkerSize(3);
}
for(int hit = 0; hit < rpd[row][col]->nHits; hit++){
//Hit window start
hMarksFront->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksFront->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksFront->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksFront->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center[hit], rpd[row][col]->Peak_max[hit] + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksFront->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksFront->at(tile)->back())->SetMarkerSize(3);
}//end hit loop
}//end if was hit
tile++;
}
}
}//end column loop
}//end row loop
if(m_viz == NULL){
m_viz = new Visualizer( "ATLAS" );
......@@ -283,24 +288,26 @@ void RPDAnalysis2021::PlotWFandPWF(int eventNum){
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kGreen);
if(rpd[row][col]->was_hit){
//Hit window start
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksBack->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center, rpd[row][col]->Peak_max + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerSize(3);
//Plot the fit function on the processed waveform
hMarksFront->at(tile)->push_back( rpd[row][col]->FitFunc );
((TF1*)hMarksFront->at(tile)->back())->SetRange(rpd[row][col]->hit_window.first, rpd[row][col]->hit_window.second);
((TF1*)hMarksFront->at(tile)->back())->SetLineColor(kCyan);
}
for(int hit = 0; hit < rpd[row][col]->nHits; hit++){
//Hit window start
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksBack->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center[hit], rpd[row][col]->Peak_max[hit] + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerSize(3);
//Plot the fit function on the processed waveform
// hMarksFront->at(tile)->push_back( rpd[row][col]->FitFunc );
// ((TF1*)hMarksFront->at(tile)->back())->SetRange(rpd[row][col]->hit_window.first[hit], rpd[row][col]->hit_window.second[hit]);
// ((TF1*)hMarksFront->at(tile)->back())->SetLineColor(kCyan);
}//end hit loop
}//end if channel was hit
tile++;
}
}
}//end column loop
}//end row loop
if(m_viz == NULL){
m_viz = new Visualizer( "ATLAS" );
......@@ -353,21 +360,22 @@ void RPDAnalysis2021::PlotWFandDerivative(int eventNum){
((TLine*)hMarksFront->at(tile)->back())->SetLineColor(kMagenta);
if(rpd[row][col]->was_hit){
//Hit window start
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second, rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksBack->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center, rpd[row][col]->Peak_max + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerSize(3);
}
for(int hit = 0; hit < rpd[row][col]->nHits; hit++){
//Hit window start
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.first[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Hit window end
hMarksBack->at(tile)->push_back( new TLine( rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMinimum(), rpd[row][col]->hit_window.second[hit], rpd[row][col]->WF_histo->GetMaximum()) );
((TLine*)hMarksBack->at(tile)->back())->SetLineColor(kRed);
//Place an X on the peak
hMarksBack->at(tile)->push_back( new TMarker( rpd[row][col]->Peak_center[hit], rpd[row][col]->Peak_max[hit] + rpd[row][col]->PedMean, 5) );
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerColor(kMagenta+2);
((TMarker*)hMarksBack->at(tile)->back())->SetMarkerSize(3);
}//end hit loop
}//end if channel was hit
tile++;
}
}
}//end column loop
}//end row loop
if(m_viz == NULL){
m_viz = new Visualizer( "ATLAS" );
......
......@@ -132,6 +132,20 @@ void WFAnalysis::AnalyzeEvent( const std::vector< std::vector< float > >& vWF ){
void WFAnalysis::AnalyzeEvent( const std::vector< Channel* > vCh ){
for( Channel* Ch : vCh ){
if( !Ch->is_on ) continue;
//Clear old hits
Ch->was_hit = false;
Ch->nHits = 0;
Ch->hit_window.first.clear();
Ch->