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

Implemented ADC to mV conversion

parent 2cc74090
...@@ -62,6 +62,8 @@ class Channel { ...@@ -62,6 +62,8 @@ class Channel {
bool pos_polarity; bool pos_polarity;
/** Gain of the PMT for this channel */ /** Gain of the PMT for this channel */
float gain; float gain;
/** ADC to mV conversion factor */
double adc_mV;
/* /*
* Waveform storage * Waveform storage
*/ */
......
...@@ -229,13 +229,16 @@ void DataReader2021::LoadConfigurationFile(std::string _inFile ){ ...@@ -229,13 +229,16 @@ void DataReader2021::LoadConfigurationFile(std::string _inFile ){
m_XMLparser->getChildValue("channel",i,"is_pos_polarity",buffer_ch->pos_polarity); m_XMLparser->getChildValue("channel",i,"is_pos_polarity",buffer_ch->pos_polarity);
m_XMLparser->getChildValue("channel",i,"is_on",buffer_ch->is_on); m_XMLparser->getChildValue("channel",i,"is_on",buffer_ch->is_on);
m_XMLparser->getChildValue("channel",i,"Vop",buffer_ch->Vop); m_XMLparser->getChildValue("channel",i,"Vop",buffer_ch->Vop);
m_XMLparser->getChildValue("channel",i,"adc_per_mv",buffer_ch->adc_mV);
//Get the voltage vs gain plot for this PMT. If it exists, set the gain value for the channel //Get the voltage vs gain plot for this PMT. If it exists, set the gain value for the channel
TGraph *gainPlot = (TGraph*)gainFile.Get(buffer_ch->PMTcode.c_str()); TGraph *gainPlot = (TGraph*)gainFile.Get(buffer_ch->PMTcode.c_str());
if(!gainPlot){ if(gainPlot){
buffer_ch->gain = gainPlot->Eval(buffer_ch->HV);
}else{
buffer_ch->gain = 0;
std::cout << Form("No gain plot found for %s row %d col %d", buffer_ch->detector.c_str(), buffer_ch->mapping_row, buffer_ch->mapping_column) << std::endl; std::cout << Form("No gain plot found for %s row %d col %d", buffer_ch->detector.c_str(), buffer_ch->mapping_row, buffer_ch->mapping_column) << std::endl;
} }
buffer_ch->gain = (gainPlot) ? gainPlot->Eval(buffer_ch->HV) : 0;
bool isNew(true); bool isNew(true);
for( int k = 0; k < channelEntries.size(); k++){ for( int k = 0; k < channelEntries.size(); k++){
......
...@@ -211,7 +211,7 @@ void WFAnalysis::AnalyzeEvent( const std::vector< Channel* > vCh ){ ...@@ -211,7 +211,7 @@ void WFAnalysis::AnalyzeEvent( const std::vector< Channel* > vCh ){
//Get peak information from the waveform using the hit window //Get peak information from the waveform using the hit window
Ch->Peak_center.push_back( GetMaximumBin( hProcessed, Ch->hit_window.first[hit], Ch->hit_window.second[hit] ) ); Ch->Peak_center.push_back( GetMaximumBin( hProcessed, Ch->hit_window.first[hit], Ch->hit_window.second[hit] ) );
Ch->Peak_max.push_back( hProcessed->GetBinContent( Ch->Peak_center.back() ) ); Ch->Peak_max.push_back( Ch->adc_mV*hProcessed->GetBinContent( Ch->Peak_center.back() ) );
Ch->Peak_time.push_back( Ch->pTimeVec->at( Ch->Peak_center.back() ) ); Ch->Peak_time.push_back( Ch->pTimeVec->at( Ch->Peak_center.back() ) );
//Set the range of the fit function to just around the peak and feed it some starting parameters //Set the range of the fit function to just around the peak and feed it some starting parameters
...@@ -602,7 +602,7 @@ double WFAnalysis::GetCharge( Channel* ch, int start, int end){ ...@@ -602,7 +602,7 @@ double WFAnalysis::GetCharge( Channel* ch, int start, int end){
for(int bin = start; bin < end; bin++){ for(int bin = start; bin < end; bin++){
//Charge for a given time bin = dt*I = (t(bin+1)-t(bin))*V/R //Charge for a given time bin = dt*I = (t(bin+1)-t(bin))*V/R
//Units are Charge(pC), time(ns), Voltage(mV), resistance(ohm), current(Amp = C/s) //Units are Charge(pC), time(ns), Voltage(mV), resistance(ohm), current(Amp = C/s)
charge += (ch->pTimeVec->at(bin+1) - ch->pTimeVec->at(bin)) * ch->PWF_histo->GetBinContent(bin)/Rin; charge += (ch->pTimeVec->at(bin+1) - ch->pTimeVec->at(bin)) * ch->adc_mV * ch->PWF_histo->GetBinContent(bin)/Rin;
}//end hit window }//end hit window
return charge; return charge;
}//end GetCharge }//end GetCharge
......
Supports Markdown
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