Commit fd6ad38d authored by Georg Auzinger's avatar Georg Auzinger
Browse files

added easylogging to tools

parent 5334efd4
......@@ -185,14 +185,14 @@ void CMTester::Initialize()
// initializeHists();
std::cout << "Histograms and Settings initialised." << std::endl;
LOG (INFO) << "Histograms and Settings initialised." ;
}
void CMTester::ScanNoiseChannels()
{
std::cout << "Scanning for noisy channels! " << std::endl;
LOG (INFO) << "Scanning for noisy channels! " ;
uint32_t cTotalEvents = 500;
for ( BeBoard* pBoard : fBoardVector )
......@@ -231,7 +231,7 @@ void CMTester::ScanNoiseChannels()
if ( cN % 100 == 0 )
// updateHists();
std::cout << "Acquired " << cN << " Events for Noise Strip Scan!" << std::endl;
LOG (INFO) << "Acquired " << cN << " Events for Noise Strip Scan!" ;
cN++;
}
......@@ -250,13 +250,13 @@ void CMTester::ScanNoiseChannels()
auto cNoiseSet = fNoiseStripMap.find ( cCbc.first );
if ( cNoiseSet == std::end ( fNoiseStripMap ) ) std::cerr << " Error: Could not find noisy strip container for CBC " << int ( cCbc.first->getCbcId() ) << std::endl;
if ( cNoiseSet == std::end ( fNoiseStripMap ) ) LOG (ERROR) << " Error: Could not find noisy strip container for CBC " << int ( cCbc.first->getCbcId() ) ;
else
{
double cMean = cNoiseStrips->GetMean ( 2 );
double cNoise = cNoiseStrips->GetRMS ( 2 );
std::cout << "Found average Occupancy of " << cMean << std::endl;
LOG (INFO) << "Found average Occupancy of " << cMean ;
for ( int cBin = 0; cBin < cNoiseStrips->GetNbinsX(); cBin++ )
{
......@@ -265,7 +265,7 @@ void CMTester::ScanNoiseChannels()
if ( fabs ( cStripOccupancy - cMean ) > cMean / 2 )
{
cNoiseSet->second.insert ( cNoiseStrips->GetBinCenter ( cBin ) );
std::cout << "Found noisy Strip on CBC " << int ( cCbc.first->getCbcId() ) << " : " << cNoiseStrips->GetBinCenter ( cBin ) << std::endl;
LOG (INFO) << "Found noisy Strip on CBC " << int ( cCbc.first->getCbcId() ) << " : " << cNoiseStrips->GetBinCenter ( cBin ) ;
}
}
}
......@@ -302,7 +302,7 @@ void CMTester::TakeData()
if ( cN % 100 == 0 )
{
std::cout << cN << " Events recorded!" << std::endl;
LOG (INFO) << cN << " Events recorded!" ;
updateHists();
}
......@@ -323,9 +323,9 @@ void CMTester::TakeData()
void CMTester::FinishRun()
{
// Iterate through maps, pick histogram that I need and the other one
std::cout << "Fitting and computing aditional histograms ... " << std::endl;
LOG (INFO) << "Fitting and computing aditional histograms ... " ;
// first CBCs
std::cout << "per CBC ..";
LOG (INFO) << "per CBC ..";
for ( auto cCbc : fCbcHistMap )
{
......@@ -371,8 +371,8 @@ void CMTester::FinishRun()
}
}
std::cout << " done!" << std::endl;
std::cout << "per module ... ";
LOG (INFO) << " done!" ;
LOG (INFO) << "per module ... ";
// now module wise
for ( auto& cFe : fModuleHistMap )
......@@ -407,7 +407,7 @@ void CMTester::FinishRun()
}
}
std::cout << " done!" << std::endl;
LOG (INFO) << " done!" ;
// Not drawing anything yet
updateHists ( true );
}
......@@ -535,7 +535,7 @@ void CMTester::updateHists ( bool pFinal )
{
auto cCanvas = fCanvasMap.find ( cCbc.first );
if ( cCanvas == fCanvasMap.end() ) std::cout << "Error: could not find the canvas for Cbc " << int ( cCbc.first->getCbcId() ) << std::endl;
if ( cCanvas == fCanvasMap.end() ) LOG (INFO) << "Error: could not find the canvas for Cbc " << int ( cCbc.first->getCbcId() ) ;
else
{
TH1F* cTmpNHits = dynamic_cast<TH1F*> ( getHist ( cCbc.first, "nhits" ) );
......@@ -623,7 +623,7 @@ bool CMTester::isMasked ( Cbc* pCbc, int pChannel )
if ( cNoiseStripSet == std::end ( fNoiseStripMap ) )
{
std::cerr << "Error: could not find the set of noisy strips for CBC " << int ( cNoiseStripSet->first->getCbcId() ) << std::endl;
LOG (ERROR) << "Error: could not find the set of noisy strips for CBC " << int ( cNoiseStripSet->first->getCbcId() ) ;
return false;
}
else
......@@ -683,9 +683,9 @@ void CMTester::parseSettings()
if ( cSetting != std::end ( fSettingsMap ) ) fSimOccupancy = cSetting->second;
else fSimOccupancy = 50;
std::cout << "Parsed the following settings:" << std::endl;
std::cout << " Nevents = " << fNevents << std::endl;
std::cout << " simulate = " << int ( fDoSimulate ) << std::endl;
std::cout << " sim. Occupancy (%) = " << int ( fSimOccupancy ) << std::endl;
LOG (INFO) << "Parsed the following settings:" ;
LOG (INFO) << " Nevents = " << fNevents ;
LOG (INFO) << " simulate = " << int ( fDoSimulate ) ;
LOG (INFO) << " sim. Occupancy (%) = " << int ( fSimOccupancy ) ;
}
......@@ -95,12 +95,12 @@ void Calibration::Initialise ( bool pAllChan )
fOccupancyCanvas->DivideSquare ( cPads );
std::cout << "Created Object Maps and parsed settings:" << std::endl;
std::cout << " Hole Mode = " << fHoleMode << std::endl;
std::cout << " Nevents = " << fEventsPerPoint << std::endl;
std::cout << " TargetVcth = " << int ( fTargetVcth ) << std::endl;
std::cout << " TargetOffset = " << int ( fTargetOffset ) << std::endl;
std::cout << " TestPulseAmplitude = " << int ( fTestPulseAmplitude ) << std::endl;
LOG (INFO) << "Created Object Maps and parsed settings:" ;
LOG (INFO) << " Hole Mode = " << fHoleMode ;
LOG (INFO) << " Nevents = " << fEventsPerPoint ;
LOG (INFO) << " TargetVcth = " << int ( fTargetVcth ) ;
LOG (INFO) << " TargetOffset = " << int ( fTargetOffset ) ;
LOG (INFO) << " TestPulseAmplitude = " << int ( fTestPulseAmplitude ) ;
}
void Calibration::MakeTestGroups ( bool pAllChan )
......@@ -156,7 +156,7 @@ void Calibration::FindVplus()
// now all offsets are either off (0x00 in holes mode, 0xFF in electrons mode)
// next a group needs to be enabled - therefore now the group loop
std::cout << BOLDBLUE << "Extracting Vplus ..." << RESET << std::endl;
LOG (INFO) << BOLDBLUE << "Extracting Vplus ..." << RESET ;
for ( auto& cTGroup : fTestGroupChannelMap )
{
......@@ -166,13 +166,13 @@ void Calibration::FindVplus()
clearVPlusMap();
// looping over the test groups, enable it
std::cout << GREEN << "Enabling Test Group...." << cTGroup.first << RESET << std::endl;
LOG (INFO) << GREEN << "Enabling Test Group...." << cTGroup.first << RESET ;
setOffset ( fTargetOffset, cTGroup.first, true ); // takes the group ID
//updateHists ( "Offsets" );
bitwiseVplus ( cTGroup.first );
std::cout << RED << "Disabling Test Group...." << cTGroup.first << RESET << std::endl << std::endl;
LOG (INFO) << RED << "Disabling Test Group...." << cTGroup.first << RESET ;
uint8_t cOffset = ( fHoleMode ) ? 0x00 : 0xFF;
setOffset ( cOffset, cTGroup.first, true );
......@@ -196,7 +196,7 @@ void Calibration::FindVplus()
cCbc.second = cTmpProfile->GetMean ( 2 );
fCbcInterface->WriteCbcReg ( cCbc.first, "Vplus", cCbc.second );
std::cout << BOLDGREEN << "Mean Vplus value for FE " << +cCbc.first->getFeId() << " CBC " << +cCbc.first->getCbcId() << " is " << BOLDRED << +cCbc.second << RESET << std::endl;
LOG (INFO) << BOLDGREEN << "Mean Vplus value for FE " << +cCbc.first->getFeId() << " CBC " << +cCbc.first->getCbcId() << " is " << BOLDRED << +cCbc.second << RESET ;
}
}
......@@ -210,7 +210,7 @@ void Calibration::bitwiseVplus ( int pTGroup )
{
toggleRegBit ( cCbc.second, iBit );
fCbcInterface->WriteCbcReg ( cCbc.first, "Vplus", cCbc.second );
// std::cout << "IBIT " << +iBit << " DEBUG Setting Vplus for CBC " << +cCbc.first->getCbcId() << " to " << +cCbc.second << " (= 0b" << std::bitset<8>( cCbc.second ) << ")" << std::endl;
// LOG(INFO) << "IBIT " << +iBit << " DEBUG Setting Vplus for CBC " << +cCbc.first->getCbcId() << " to " << +cCbc.second << " (= 0b" << std::bitset<8>( cCbc.second ) << ")" ;
}
// now each CBC has the MSB Vplus Bit written
......@@ -224,7 +224,7 @@ void Calibration::bitwiseVplus ( int pTGroup )
// if the occupancy is larger than 0.5 I need to flip the bit back to 0, else leave it
float cOccupancy = findCbcOccupancy ( cCbc.first, pTGroup, fEventsPerPoint );
//std::cout << "VPlus " << +cCbc.second << " = 0b" << std::bitset<8>( cCbc.second ) << " on CBC " << +cCbc.first->getCbcId() << " Occupancy : " << cOccupancy << std::endl;
//LOG(INFO) << "VPlus " << +cCbc.second << " = 0b" << std::bitset<8>( cCbc.second ) << " on CBC " << +cCbc.first->getCbcId() << " Occupancy : " << cOccupancy ;
if ( fHoleMode && cOccupancy > 0.56 )
{
......@@ -251,7 +251,7 @@ void Calibration::bitwiseVplus ( int pTGroup )
for ( auto& cCbc : fVplusMap )
{
float cOccupancy = findCbcOccupancy ( cCbc.first, pTGroup, fEventsPerPoint );
std::cout << BOLDBLUE << "Found Occupancy of " << BOLDRED << cOccupancy << BOLDBLUE << " for CBC " << +cCbc.first->getCbcId() << " , test Group " << pTGroup << " using VPlus " << BOLDRED << +cCbc.second << BOLDBLUE << " (= 0x" << std::hex << +cCbc.second << std::dec << "; 0b" << std::bitset<8> ( cCbc.second ) << ")" << RESET << std::endl;
LOG (INFO) << BOLDBLUE << "Found Occupancy of " << BOLDRED << cOccupancy << BOLDBLUE << " for CBC " << +cCbc.first->getCbcId() << " , test Group " << pTGroup << " using VPlus " << BOLDRED << +cCbc.second << BOLDBLUE << " (= 0x" << std::hex << +cCbc.second << std::dec << "; 0b" << std::bitset<8> ( cCbc.second ) << ")" << RESET ;
clearOccupancyHists ( cCbc.first );
}
}
......@@ -272,7 +272,7 @@ void Calibration::FindOffsets()
{
if (cTGroup.first != -1)
{
std::cout << GREEN << "Enabling Test Group...." << cTGroup.first << RESET << std::endl;
LOG (INFO) << GREEN << "Enabling Test Group...." << cTGroup.first << RESET ;
bitwiseOffset ( cTGroup.first );
......@@ -280,7 +280,7 @@ void Calibration::FindOffsets()
{
// now all the bits are toggled or not, I still want to verify that the occupancy is ok
int cMultiple = 3;
std::cout << "Verifying Occupancy with final offsets by taking " << fEventsPerPoint* cMultiple << " Triggers!" << std::endl;
LOG (INFO) << "Verifying Occupancy with final offsets by taking " << fEventsPerPoint* cMultiple << " Triggers!" ;
measureOccupancy ( fEventsPerPoint * cMultiple, cTGroup.first );
// now find the occupancy for each channel and update the TProfile
}
......@@ -288,7 +288,7 @@ void Calibration::FindOffsets()
updateHists ( "Occupancy" );
uint8_t cOffset = ( fHoleMode ) ? 0x00 : 0xFF;
setOffset ( cOffset, cTGroup.first );
std::cout << RED << "Disabling Test Group...." << cTGroup.first << RESET << std::endl << std::endl;
LOG (INFO) << RED << "Disabling Test Group...." << cTGroup.first << RESET ;
}
}
......@@ -301,7 +301,7 @@ void Calibration::bitwiseOffset ( int pTGroup )
// loop over the bits
for ( int iBit = 7; iBit >= 0; iBit-- )
{
std::cout << "Searching for the correct offsets by flipping bit " << iBit << std::endl;
LOG (INFO) << "Searching for the correct offsets by flipping bit " << iBit ;
// now, for all the channels in the group and for each cbc, toggle the MSB of the offset from the map
toggleOffset ( pTGroup, iBit, true );
......@@ -396,7 +396,7 @@ void Calibration::clearVPlusMap()
void Calibration::setOffset ( uint8_t pOffset, int pGroup, bool pVPlus )
{
// std::cout << "Setting offsets of Test Group " << pGroup << " to 0x" << std::hex << +pOffset << std::dec << std::endl;
// LOG(INFO) << "Setting offsets of Test Group " << pGroup << " to 0x" << std::hex << +pOffset << std::dec ;
for ( auto cBoard : fBoardVector )
{
for ( auto cFe : cBoard->fModuleVector )
......@@ -529,7 +529,7 @@ void Calibration::updateHists ( std::string pHistname )
fOccupancyCanvas->Update();
}
}
else std::cout << "Error, could not find Histogram with name " << pHistname << std::endl;
else LOG (INFO) << "Error, could not find Histogram with name " << pHistname ;
}
#ifdef __HTTP__
......@@ -556,7 +556,7 @@ void Calibration::setRegValues()
{
uint8_t cOffset = cOffsetHist->GetBinContent ( iChan );
cCbc->setReg ( Form ( "Channel%03d", iChan + 1 ), cOffset );
//std::cout << GREEN << "Offset for CBC " << cCbcId << " Channel " << iChan << " : 0x" << std::hex << +cOffset << std::dec << RESET << std::endl;
//LOG(INFO) << GREEN << "Offset for CBC " << cCbcId << " Channel " << iChan << " : 0x" << std::hex << +cOffset << std::dec << RESET ;
}
}
......
......@@ -4,11 +4,11 @@
Channel::Channel( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pChannelId ) :
fBeId( pBeId ),
fFeId( pFeId ),
fCbcId( pCbcId ),
fChannelId( pChannelId )
Channel::Channel ( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pChannelId ) :
fBeId ( pBeId ),
fFeId ( pFeId ),
fCbcId ( pCbcId ),
fChannelId ( pChannelId )
{
}
......@@ -19,252 +19,279 @@ Channel::~Channel()
double Channel::getPedestal() const
{
if ( fFitted )
{
if ( fFit != nullptr )
return fabs( fFit->GetParameter( 0 ) );
else return -1;
}
else
{
if ( fDerivative != nullptr )
return fabs( fDerivative->GetMean() );
else return -1;
}
if ( fFitted )
{
if ( fFit != nullptr )
return fabs ( fFit->GetParameter ( 0 ) );
else return -1;
}
else
{
if ( fDerivative != nullptr )
return fabs ( fDerivative->GetMean() );
else return -1;
}
}
double Channel::getNoise() const
{
if ( fFitted )
{
if ( fFit != nullptr )
return fabs( fFit->GetParameter( 1 ) );
else
return -1;
}
else
{
if ( fDerivative != nullptr )
return fabs( fDerivative->GetRMS() );
else
return -1;
}
if ( fFitted )
{
if ( fFit != nullptr )
return fabs ( fFit->GetParameter ( 1 ) );
else
return -1;
}
else
{
if ( fDerivative != nullptr )
return fabs ( fDerivative->GetRMS() );
else
return -1;
}
}
void Channel::setOffset( uint8_t pOffset )
void Channel::setOffset ( uint8_t pOffset )
{
fOffset = pOffset;
fOffset = pOffset;
}
void Channel::initializePulse( TString pName )
void Channel::initializePulse ( TString pName )
{
TObject* cObj = gROOT->FindObject( pName );
if ( cObj ) delete cObj;
fPulse = new TGraph();
fPulse->SetName( pName );
fPulse->SetMarkerStyle( 3 );
fPulse->GetXaxis()->SetTitle( "TestPulseDelay [ns]" );
fPulse->GetYaxis()->SetTitle( "TestPulseAmplitue [VCth]" );
// fPulse->GetYaxis()->SetRangeUser( 0, 255 );
// fPulse->GetHistogram()->SetMaximum( 255. );
// fPulse->GetHistogram()->SetMinimum( 0. );
fPulse->GetYaxis()->SetLimits( 0, 255 );
TObject* cObj = gROOT->FindObject ( pName );
if ( cObj ) delete cObj;
fPulse = new TGraph();
fPulse->SetName ( pName );
fPulse->SetMarkerStyle ( 3 );
fPulse->GetXaxis()->SetTitle ( "TestPulseDelay [ns]" );
fPulse->GetYaxis()->SetTitle ( "TestPulseAmplitue [VCth]" );
// fPulse->GetYaxis()->SetRangeUser( 0, 255 );
// fPulse->GetHistogram()->SetMaximum( 255. );
// fPulse->GetHistogram()->SetMinimum( 0. );
fPulse->GetYaxis()->SetLimits ( 0, 255 );
}
void Channel::initializeHist( uint8_t pValue, TString pParameter )
void Channel::initializeHist ( uint8_t pValue, TString pParameter )
{
TString histname;
TString fitname;
TString graphname;
pParameter += Form( "%d", pValue );
histname = Form( "Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
histname += pParameter;
fitname = Form( "Fit_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
fitname += pParameter;
graphname = Form( "fDerivative_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
graphname += pParameter;
fScurve = dynamic_cast<TH1F*>( gROOT->FindObject( histname ) );
if ( fScurve ) delete fScurve;
fScurve = new TH1F( histname, Form( "Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId ), 256, -0.5, 255.5 );
fScurve->GetXaxis()->SetTitle( pParameter );
fScurve->GetYaxis()->SetTitle( "Occupancy" );
fDerivative = dynamic_cast<TH1F*>( gROOT->FindObject( graphname ) );
if ( fDerivative ) delete fDerivative;
fDerivative = new TH1F( graphname, Form( "Derivative_Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId ), 255, 0, 255 );
fDerivative->GetXaxis()->SetTitle( pParameter );
fDerivative->GetYaxis()->SetTitle( "Slope" );
fScurve->SetMarkerStyle( 7 );
fScurve->SetMarkerSize( 2 );
fFit = dynamic_cast< TF1* >( gROOT->FindObject( fitname ) );
if ( fFit ) delete fFit;
// TF1 *f1=gROOT->GetFunction("myfunc");
fFit = new TF1( fitname, MyErf, 0, 255, 2 );
TString histname;
TString fitname;
TString graphname;
pParameter += Form ( "%d", pValue );
histname = Form ( "Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
histname += pParameter;
fitname = Form ( "Fit_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
fitname += pParameter;
graphname = Form ( "fDerivative_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId );
graphname += pParameter;
fScurve = dynamic_cast<TH1F*> ( gROOT->FindObject ( histname ) );
if ( fScurve ) delete fScurve;
fScurve = new TH1F ( histname, Form ( "Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId ), 256, -0.5, 255.5 );
fScurve->GetXaxis()->SetTitle ( pParameter );
fScurve->GetYaxis()->SetTitle ( "Occupancy" );
fDerivative = dynamic_cast<TH1F*> ( gROOT->FindObject ( graphname ) );
if ( fDerivative ) delete fDerivative;
fDerivative = new TH1F ( graphname, Form ( "Derivative_Scurve_Be%d_Fe%d_Cbc%d_Channel%d", fBeId, fFeId, fCbcId, fChannelId ), 255, 0, 255 );
fDerivative->GetXaxis()->SetTitle ( pParameter );
fDerivative->GetYaxis()->SetTitle ( "Slope" );
fScurve->SetMarkerStyle ( 7 );
fScurve->SetMarkerSize ( 2 );
fFit = dynamic_cast< TF1* > ( gROOT->FindObject ( fitname ) );
if ( fFit ) delete fFit;
// TF1 *f1=gROOT->GetFunction("myfunc");
fFit = new TF1 ( fitname, MyErf, 0, 255, 2 );
}
void Channel::fillHist( uint8_t pVcth )
void Channel::fillHist ( uint8_t pVcth )
{
fScurve->Fill( float( pVcth ) );
fScurve->Fill ( float ( pVcth ) );
}
void Channel::fitHist( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile )
void Channel::fitHist ( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile )
{
fFitted = true;
if ( fScurve != nullptr && fFit != nullptr )
{
// Normalize first
// fScurve->Sumw2();
fScurve->Scale( 1 / double_t( pEventsperVcth ) );
// Get first non 0 and first 1
double cFirstNon0( 0 );
double cFirst1( 0 );
// Not Hole Mode
if ( !pHole )
{
for ( Int_t cBin = 1; cBin <= fScurve->GetNbinsX(); cBin++ )
{
double cContent = fScurve->GetBinContent( cBin );
if ( !cFirstNon0 )
{
if ( cContent ) cFirstNon0 = fScurve->GetBinCenter( cBin );
}
else if ( cContent > 0.85 )
{
cFirst1 = fScurve->GetBinCenter( cBin );
break;
}
}
}
// Hole mode
else
{
for ( Int_t cBin = fScurve->GetNbinsX(); cBin >= 1; cBin-- )
{
double cContent = fScurve->GetBinContent( cBin );
if ( !cFirstNon0 )
{
if ( cContent ) cFirstNon0 = fScurve->GetBinCenter( cBin );
}
else if ( cContent > 0.85 )
{
cFirst1 = fScurve->GetBinCenter( cBin );
break;
}
}
}
// Get rough midpoint & width
double cMid = ( cFirst1 + cFirstNon0 ) * 0.5;
double cWidth = ( cFirst1 - cFirstNon0 ) * 0.5;
fFit->SetParameter( 0, cMid );
fFit->SetParameter( 1, cWidth );
// Fit
fScurve->Fit( fFit, "RNQ+" );
// Eventually add TFitResultPointer
// create a Directory in the file for the current Offset and save the channel Data
TString cDirName;
cDirName = pParameter + Form( "%d", pValue );
TDirectory* cDir = dynamic_cast< TDirectory* >( gROOT->FindObject( cDirName ) );
if ( !cDir ) cDir = pResultfile->mkdir( cDirName );
pResultfile->cd( cDirName );
fScurve->SetDirectory( cDir );
// fFit->SetDirectory( cDir );
fFit->Write( fFit->GetName(), TObject::kOverwrite );
// pResultfile->Flush();
pResultfile->cd();
}
else std::cout << "Historgram Empty for Fe " << fFeId << " Cbc " << fCbcId << " Channel " << fChannelId << std::endl;
fFitted = true;
if ( fScurve != nullptr && fFit != nullptr )
{
// Normalize first
// fScurve->Sumw2();
fScurve->Scale ( 1 / double_t ( pEventsperVcth ) );
// Get first non 0 and first 1
double cFirstNon0 ( 0 );
double cFirst1 ( 0 );
// Not Hole Mode
if ( !pHole )
{
for ( Int_t cBin = 1; cBin <= fScurve->GetNbinsX(); cBin++ )
{
double cContent = fScurve->GetBinContent ( cBin );
if ( !cFirstNon0 )
{
if ( cContent ) cFirstNon0 = fScurve->GetBinCenter ( cBin );
}
else if ( cContent > 0.85 )
{
cFirst1 = fScurve->GetBinCenter ( cBin );
break;
}
}
}
// Hole mode
else
{
for ( Int_t cBin = fScurve->GetNbinsX(); cBin >= 1; cBin-- )
{
double cContent = fScurve->GetBinContent ( cBin );
if ( !cFirstNon0 )
{
if ( cContent ) cFirstNon0 = fScurve->GetBinCenter ( cBin );
}
else if ( cContent > 0.85 )
{
cFirst1 = fScurve->GetBinCenter ( cBin );
break;
}
}
}
// Get rough midpoint & width
double cMid = ( cFirst1 + cFirstNon0 ) * 0.5;
double cWidth = ( cFirst1 - cFirstNon0 ) * 0.5;
fFit->SetParameter ( 0, cMid );
fFit->SetParameter ( 1, cWidth );
// Fit
fScurve->Fit ( fFit, "RNQ+" );
// Eventually add TFitResultPointer
// create a Directory in the file for the current Offset and save the channel Data
TString cDirName;
cDirName = pParameter + Form ( "%d", pValue );
TDirectory* cDir = dynamic_cast< TDirectory* > ( gROOT->FindObject ( cDirName ) );