X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliCaloRawAnalyzerPeakFinder.cxx;h=0facb60dfc221f77dcbb8405d88230dbe61d25a2;hb=5bb5611e25d79a8bafbabcc2fa24406d3396f2fc;hp=02ebbe38b29cbeeea97f24ea8bfa4bf29b7be3f4;hpb=168c7b3cf21f0cf36791bbfd1988a02629508615;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx b/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx index 02ebbe38b29..0facb60dfc2 100644 --- a/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx +++ b/EMCAL/AliCaloRawAnalyzerPeakFinder.cxx @@ -36,36 +36,26 @@ #include "TFile.h" #include "AliCaloPeakFinderVectors.h" #include + using namespace std; + ClassImp( AliCaloRawAnalyzerPeakFinder ) AliCaloRawAnalyzerPeakFinder::AliCaloRawAnalyzerPeakFinder() :AliCaloRawAnalyzer("Peak-Finder", "PF"), - fAmp(0), fPeakFinderVectors(0), fRunOnAlien(false), fIsInitialized(false) { //Comment fAlgo= Algo::kPeakFinder; - InitOCDB(fRunOnAlien); fPeakFinderVectors = new AliCaloPeakFinderVectors() ; ResetVectors(); LoadVectorsOCDB(); } - -void -AliCaloRawAnalyzerPeakFinder::InitOCDB(bool alien) const -{ - // Setting the default OCDB pathe depending on wether we work locally or on the GRID. - AliCDBManager::Instance()->SetDefaultStorage( alien == true ? "alien://$ALICE_ROOT/OCDB" : "local://$ALICE_ROOT/OCDB"); - AliCDBManager::Instance()->SetRun(100); -} - - void AliCaloRawAnalyzerPeakFinder::ResetVectors() { @@ -116,6 +106,7 @@ AliCaloRawAnalyzerPeakFinder::ScanCoarse(const Double_t *const array, const int AliCaloFitResults AliCaloRawAnalyzerPeakFinder::Evaluate( const vector &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 ) { + // Evaluation of amplitude and TOF if( fIsInitialized == false ) { cout << __FILE__ << ":" << __LINE__ << "ERROR, peakfinder vectors not loaded" << endl; @@ -146,7 +137,7 @@ AliCaloRawAnalyzerPeakFinder::Evaluate( const vector &bunchvec int first = 0; int last = 0; short maxrev = maxampindex - bunchvector.at(index).GetStartBin(); - SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev, &first, &last); + SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev, &first, &last, fFitArrayCut); int nsamples = last - first; if( ( nsamples ) >= fNsampleCut ) // no if statement needed really; keep for readability @@ -155,11 +146,8 @@ AliCaloRawAnalyzerPeakFinder::Evaluate( const vector &bunchvec int n = last - first; int pfindex = n - fNsampleCut; pfindex = pfindex > PF::SAMPLERANGE ? PF::SAMPLERANGE : pfindex; - int dt = maxampindex - startbin -2; int tmpindex = 0; - - Float_t tmptof = ScanCoarse( &fReversed[dt] , n ); if( tmptof < -1 ) @@ -177,26 +165,24 @@ AliCaloRawAnalyzerPeakFinder::Evaluate( const vector &bunchvec } double tof = 0; - for(int k=0; k < PF::SAMPLERANGE; k++ ) { tof += fPFTofVectors[0][pfindex][k]*fReversed[ dt +k + tmpindex -1 ]; } - for( int i=0; i < PF::SAMPLERANGE; i++ ) { { + fAmp += fPFAmpVectors[0][pfindex][i]*fReversed[ dt +i +tmpindex -1 ]; } } + if( TMath::Abs( (maxf - fAmp )/maxf ) > 0.1 ) { - // cout << __FILE__ << ":" << __LINE__ << "WARNING: amp was" << fAmp <<", but was changed to "<< maxf << endl; fAmp = maxf; } - tof = timebinOffset - 0.01*tof/fAmp; // clock ticks - // use local-array time for chi2 estimate + tof = timebinOffset - 0.01*tof/fAmp - fL1Phase/TIMEBINWITH; // clock Float_t chi2 = CalculateChi2(fAmp, tof-timebinOffset+maxrev, first, last); Int_t ndf = last - first - 1; // nsamples - 2 return AliCaloFitResults( maxamp, ped , Ret::kFitPar, fAmp, tof, @@ -227,7 +213,7 @@ AliCaloRawAnalyzerPeakFinder::CopyVectors( const AliCaloPeakFinderVectors *const for( int j=0; j < PF::SAMPLERANGE; j++) { pfv->GetVector( i, j, fPFAmpVectors[i][j] , fPFTofVectors[i][j], - fPFAmpVectorsCoarse[i][j] , fPFTofVectorsCoarse[i][j] ); + fPFAmpVectorsCoarse[i][j] , fPFTofVectorsCoarse[i][j] ); fPeakFinderVectors->SetVector( i, j, fPFAmpVectors[i][j], fPFTofVectors[i][j], fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] ); @@ -247,86 +233,29 @@ AliCaloRawAnalyzerPeakFinder::LoadVectorsOCDB() //Loading of Peak-Finder vectors from the //Offline Condition Database (OCDB) AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/PeakFinder/"); - cout << __FILE__ << ":" << __LINE__ << ": Printing metadata !! " << endl; - entry->PrintMetaData(); - + if( entry != 0 ) + { + //cout << __FILE__ << ":" << __LINE__ << ": Printing metadata !! " << endl; + //entry->PrintMetaData(); + AliCaloPeakFinderVectors *pfv = (AliCaloPeakFinderVectors *)entry->GetObject(); + if( pfv == 0 ) { - AliCaloPeakFinderVectors *pfv = (AliCaloPeakFinderVectors *)entry->GetObject(); - if( pfv == 0 ) - { - cout << __FILE__ << ":" << __LINE__ << "_ ERRROR " << endl; - } - - CopyVectors( pfv ); - - if( pfv != 0 ) - { - fIsInitialized = true; - } + cout << __FILE__ << ":" << __LINE__ << "_ ERRROR " << endl; } -} - - -void -AliCaloRawAnalyzerPeakFinder::LoadVectorsASCII() -{ - //Read in the Peak finder vecors from ASCI files - fIsInitialized= true; - - for(int i = 0; i < PF::MAXSTART ; i++) + CopyVectors( pfv ); + + if( pfv != 0 ) { - for( int j=0; j < PF::SAMPLERANGE; j++) - { - char filenameCoarse[256]; - char filename[256]; - int n = j+fNsampleCut; - double start = (double)i+0; - - sprintf(filename, "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt1.0.txt", getenv("ALICE_ROOT"), start, n); - sprintf(filenameCoarse, "%s/EMCAL/vectors-emcal/start%.1fN%dtau0.235fs10dt3.0.txt", getenv("ALICE_ROOT"), start, n); - - FILE *fp = fopen(filename, "r"); - FILE *fpc = fopen(filenameCoarse, "r"); - - if( fp == 0 ) - { - AliFatal( Form( "could not open file: %s", filename ) ); - } - if(fpc == 0) - { - AliFatal( Form( "could not open file: %s", filenameCoarse ) ); - } - else - { - for(int m = 0; m < n ; m++ ) - { - fscanf(fp, "%lf\t", &fPFAmpVectors[i][j][m] ); - fscanf(fpc, "%lf\t", &fPFAmpVectorsCoarse[i][j][m] ); - } - fscanf(fp, "\n" ); - fscanf(fpc, "\n" ); - for(int m = 0; m < n ; m++ ) - { - fscanf(fp, "%lf\t", &fPFTofVectors[i][j][m] ); - fscanf(fpc, "%lf\t", &fPFTofVectorsCoarse[i][j][m] ); - } - - fPeakFinderVectors->SetVector( i, j, fPFAmpVectors[i][j], fPFTofVectors[i][j], - fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] ); - - fclose (fp); - fclose (fpc); - } - } + fIsInitialized = true; } + } } void AliCaloRawAnalyzerPeakFinder::WriteRootFile() const -{ - // Utility function to write Peak-Finder vectors to an root file +{ // Utility function to write Peak-Finder vectors to an root file // The output is used to create an OCDB entry. fPeakFinderVectors->PrintVectors(); TFile *f = new TFile("peakfindervectors2.root", "recreate" ); @@ -338,7 +267,7 @@ AliCaloRawAnalyzerPeakFinder::WriteRootFile() const void AliCaloRawAnalyzerPeakFinder::PrintVectors() -{ +{ // Utility function to write Peak-Finder vectors for(int i=0; i < 20; i++) { for( int j = 0; j < PF::MAXSTART; j ++ )