// has to be >= 0.1; if maximum==0 set ratio to 0.1
Double_t maxCorr = max - baseline;
Double_t binRatio = 0.1;
- if(maxCorr != 0) {
+ if(TMath::Abs(maxCorr)>1e-5) {
binRatio = (tempHis->GetBinContent(maxpos+1) - baseline) / maxCorr;
}
// Decision if found pulse is a proper one according to given tresholds
if (max>lowLim && max<upLim && !((last-first)<fPulseLength) && rms<fRMSLim && (intHist/intPulse)<fRatioIntLim && (binRatio >= 0.1) ) {
char hname[100];
- sprintf(hname,"sec%drow%dpad%d",prevSec,prevRow,prevPad);
+ snprintf(hname,100,"sec%drow%dpad%d",prevSec,prevRow,prevPad);
TH1F *his = (TH1F*)fileOut.Get(hname);
TIter next( fileIn.GetListOfKeys() );
char nameFileOut[100];
- sprintf(nameFileOut,"Sec-%s",nameFileIn);
+ snprintf(nameFileOut,100,"Sec-%s",nameFileIn);
TFile fileOut(nameFileOut,"RECREATE");
fileOut.cd();
Int_t sector = (Int_t)hisPad->GetBinContent(2);
char hname[100];
- sprintf(hname,"sector%d",sector);
+ snprintf(hname,100,"sector%d",sector);
TH1F *his = (TH1F*)fileOut.Get(hname);
if (!his ) { // new histogram (new sector)
TIter next( fileIn.GetListOfKeys() );
char nameFileOut[100];
- sprintf(nameFileOut,"TCF-%s",nameFileIn);
+ snprintf(nameFileOut,100,"TCF-%s",nameFileIn);
TFile fileOut(nameFileOut,"RECREATE");
fileOut.cd();
//____________________________________________________________________________
-Int_t AliTPCCalibTCF::AnalyzePulse(TH1F *hisIn, Double_t *coefZ, Double_t *coefP) {
+Int_t AliTPCCalibTCF::AnalyzePulse(TH1F * const hisIn, Double_t *coefZ, Double_t *coefP) {
//
// Performs the analysis on one specific pulse (histogram) by means of fitting
// the pulse and equalization of the pulseheight. The found TCF parameters
}
char nameFileOut[100];
- sprintf(nameFileOut,"Quality_%s_AT_%s",nameFileTCF, nameFileIn);
+ snprintf(nameFileOut,100,"Quality_%s_AT_%s",nameFileTCF, nameFileIn);
TFile fileOut(nameFileOut,"RECREATE");
TNtuple *qualityTuple = new TNtuple("TCFquality","TCF quality Values","sec:row:pad:npulse:heightDev:areaRed:widthRed:undershot:maxUndershot");
// has to be >= 0.1; if maximum==0 set ratio to 0.1
Double_t maxCorr = max - baseline;
Double_t binRatio = 0.1;
- if(maxCorr != 0) {
+ if(TMath::Abs(maxCorr) > 1e-5 ) {
binRatio = (tempHis->GetBinContent(maxpos+1) - baseline) / maxCorr;
}
// note:
// assuming that lowLim is higher than the pedestal value!
char hname[100];
- sprintf(hname,"sec%drow%dpad%d",prevSec,prevRow,prevPad);
+ snprintf(hname,100,"sec%drow%dpad%d",prevSec,prevRow,prevPad);
TH1F *his = new TH1F(hname,hname, fPulseLength+4, 0, fPulseLength+4);
his->SetBinContent(1,1); // pulse counter (1st pulse)
his->SetBinContent(2,prevSec); // sector
if ( (side==0) && (sec%36>=18) ) continue;
if ( (side>0) && (sec%36<18) ) continue;
- if ( (row==-1) && (pad==-1) ) { // summed pulses per sector
+ if ( (row<0) && (pad<0) ) { // row and pad are equal to -1, then -> summed pulses per sector
// fill all pad with this values
for (UInt_t rowi=0; rowi<roc->GetNRows(sec); rowi++) {
for (UInt_t padi=0; padi<roc->GetNPads(sec,rowi); padi++) {
char nameFileOut[100];
- sprintf(nameFileOut,"Occup-%s",nameFile);
+ snprintf(nameFileOut,100,"Occup-%s",nameFile);
TFile fileOut(nameFileOut,"RECREATE");
// fileOut.cd();
Int_t row = (Int_t)his->GetBinContent(3);
Int_t pad = (Int_t)his->GetBinContent(4);
- if ( (row==-1) && (pad==-1) ) { // summed pulses per sector
+ if ( (row<0) && (pad<0) ) { // row and pad are equal to -1, then -> summed pulses per sector
row = 40; pad = 40; // set to approx middle row for better plot
secWise=1;
}
char cSel[100];
if (!side) {
- sprintf(cSel,"z>0&&npulse>=%d",nPulseMin);
+ snprintf(cSel,100,"z>0&&npulse>=%d",nPulseMin);
ntuple->Draw("y:x:npulse",cSel,"colz");
} else {
- sprintf(cSel,"z<0&&npulse>=%d",nPulseMin);
+ snprintf(cSel,100,"z<0&&npulse>=%d",nPulseMin);
ntuple->Draw("y:x:npulse",cSel,"colz");
}
TH2F *his2D = new TH2F(plotSpec,nameFileQuality,11,-10,1,25,1,100);
char plSpec[100];
- sprintf(plSpec,"%s>>%s",plotSpec,plotSpec);
+ snprintf(plSpec,100,"%s>>%s",plotSpec,plotSpec);
qualityTuple->Draw(plSpec,cut,pOpt);
gStyle->SetLabelSize(0.03,"X");
//____________________________________________________________________________
-void AliTPCCalibTCF::FitFcn(Int_t &/*nPar*/, Double_t */*grad*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
+void AliTPCCalibTCF::FitFcn(Int_t &/*nPar*/, Double_t */*grad*/, Double_t &f, Double_t * const par, Int_t /*iflag*/)
{
//
// Minimization function needed for TMinuit with FitFunction included
// to the different stages of the TCF filter
// (e.g. first 2 fit parameters represent the electron signal itself!)
- if (param[3]==param[4]) {param[3]=param[3]+0.0001;}
- if (param[5]==param[4]) {param[5]=param[5]+0.0001;}
+ if ((param[3]-param[4]) <1e-5 ) {param[3]=param[3]+0.0001;} // if equal
+ if ((param[5]-param[4]) <1e-5 ) {param[5]=param[5]+0.0001;} // if equal
if ((param[5]>param[4])&&(param[5]>param[3])) {
if (param[4]>=param[3]) {
// order to restore the original pulse height and adds them to the passed arrays
//
- Double_t *s0 = new Double_t[1000]; // original pulse
- Double_t *s1 = new Double_t[1000]; // pulse after 1st PZ filter
- Double_t *s2 = new Double_t[1000]; // pulse after 2nd PZ filter
-
const Int_t kPulseLength = dataTuple->GetEntries();
-
+
+ if (kPulseLength<2) {
+ // prinft("PulseLength does not make sense\n");
+ return 0;
+ }
+
+ Double_t *s0 = new Double_t[kPulseLength]; // original pulse
+ Double_t *s1 = new Double_t[kPulseLength]; // pulse after 1st PZ filter
+ Double_t *s2 = new Double_t[kPulseLength]; // pulse after 2nd PZ filter
+
for (Int_t ipos=0; ipos<kPulseLength; ipos++) {
dataTuple->GetEntry(ipos);
Float_t *p = dataTuple->GetArgs();
coefZ[2] = 0;
}
- s0->~Double_t();
- s1->~Double_t();
- s2->~Double_t();
+ delete [] s0;
+ delete [] s1;
+ delete [] s2;
// if equalization out of range (<0 or >=1) it failed!
// if ratio of amplitudes of fittet to original pulse < 0.9 it failed!
//____________________________________________________________________________
-Int_t AliTPCCalibTCF::FindCorTCFparam(TH1F *hisIn, const char *nameFileTCF, Double_t *coefZ, Double_t *coefP) {
+Int_t AliTPCCalibTCF::FindCorTCFparam(TH1F * const hisIn, const char *nameFileTCF, Double_t *coefZ, Double_t *coefP) {
//
// This function searches for the correct TCF parameters to the given
// histogram 'hisIn' within the file 'nameFileTCF'
char sel[100];
if ( paramTuple->GetEntries("row==-1&&pad==-1") ) {
// parameters per SECTOR
- sprintf(sel,"sec==%d&&row==-1&&pad==-1",sector);
+ snprintf(sel,100,"sec==%d&&row==-1&&pad==-1",sector);
} else {
// parameters per PAD
- sprintf(sel,"sec==%d&&row==%d&&pad==%d",sector,row,pad);
+ snprintf(sel,100,"sec==%d&&row==%d&&pad==%d",sector,row,pad);
}
// list should contain just ONE entry! ... otherwise there is a mistake!
paramTuple->GetEntry(pos); // get specific TCF parameters
Float_t *p = paramTuple->GetArgs();
// check ...
- if(sector==p[0]) {printf("sector ok ... "); }
- if(row==p[1]) {printf("row ok ... "); }
- if(pad==p[2]) {printf("pad ok ... \n"); }
+ if((sector-p[0])<1e-5) {printf("sector ok ... "); }
+ if((row-p[1])<1e-5) {printf("row ok ... "); }
+ if((pad-p[2])<1e-5) {printf("pad ok ... \n"); }
// number of averaged pulses used to produce TCF params
nPulse = (Int_t)p[3];
}
// Search for maximal undershot (is equal to minimum after the pulse)
- if ( (undershotStart==1)&&(i<(posOfStartTCF+widthTCF+20)) ) {
+ if ( ((undershotStart-1)<1e-7)&&(i<(posOfStartTCF+widthTCF+20)) ) {
if (maxUndershot>sigTCF) { maxUndershot = sigTCF; }
}
//____________________________________________________________________________
-TNtuple *AliTPCCalibTCF::ApplyTCFilter(TH1F *hisIn, Double_t *coefZ, Double_t *coefP, Int_t plotFlag) {
+TNtuple *AliTPCCalibTCF::ApplyTCFilter(TH1F * const hisIn, Double_t * const coefZ, Double_t * const coefP, Int_t plotFlag) {
//
// Applies the given TCF parameters on the given pulse via the ALTRO emulator
// class (discret values) and stores both pulses into a returned TNtuple
if (plotFlag) {
char hname[100];
- sprintf(hname,"sec%drow%dpad%d",sector,row,pad);
+ snprintf(hname,100,"sec%drow%dpad%d",sector,row,pad);
new TCanvas(hname,hname,600,400);
//just plotting non-discret pulses | they look pretties in case of mean sig ;-)
pulseTuple->Draw("sigND:timebin","","L");
delete [] signalIn;
delete [] signalOut;
-
+ delete [] signalInD;
+ delete [] signalOutD;
+
return pulseTuple;
}
TH1F *hisIn;
TKey *key;
TIter next(fileIn.GetListOfKeys());
- TFile *fileOut = 0;
+ // opens a file, although, it might not be uses (see "mode")
+ TFile *fileOut = new TFile(fileNameSum,"UPDATE");
//fileOut.cd();
Int_t nHist=fileIn.GetNkeys();
Int_t secPrev = -1;
char fileNameSumSec[100];
- if (mode==0) {
- fileOut = new TFile(fileNameSum,"UPDATE");
- }
+
while((key=(TKey*)next())) {
const char *hisName = key->GetName();
fileOut->Close();
}
// opening new file
- sprintf(fileNameSumSec,"%s-Sec%d.root",fileNameSum,sec);
+ snprintf(fileNameSumSec,100,"%s-Sec%d.root",fileNameSum,sec);
fileOut = new TFile(fileNameSumSec,"UPDATE");
secPrev = sec;
}
for (Int_t sec=0; sec<72; sec++) { // loop over all possible filenames
- sprintf(nameFileSumSec,"%s-Sec%d.root",nameFileSum,sec);
+ snprintf(nameFileSumSec,100,"%s-Sec%d.root",nameFileSum,sec);
TFile *fileSumSec = new TFile(nameFileSumSec,"READ");
Int_t nHist=fileSumSec->GetNkeys();
// the roc are retreived from nameFileTCFPerSec. If there are parameters for
// a roc missing, then the parameters are set to -1.
- Float_t K0 = -1, K1 = -1, K2 = -1, L0 = -1, L1 = -1, L2 = -1;
+ Float_t k0 = -1, k1 = -1, k2 = -1, l0 = -1, l1 = -1, l2 = -1;
Int_t roc, row, pad, side, sector, rcu, hwAddr;
Int_t entryNum = 0;
Int_t checksum = 0;
// creating outputfile
ofstream fileOut;
char nameFileOut[255];
- sprintf(nameFileOut,"tpcTCFparamPAD.data");
+ snprintf(nameFileOut,255,"tpcTCFparamPAD.data");
fileOut.open(nameFileOut);
// following not used:
// char headerLine[255];
- // sprintf(headerLine,"15\tside\tsector\tRCU\tHWadr\tK0\tK1\tK2\tL0\tL1\tL2\tValidFlag");
+ // snprintf(headerLine,255,"15\tside\tsector\tRCU\tHWadr\tk0\tk1\tk2\tl0\tl1\tl2\tValidFlag");
// fileOut << headerLine << std::endl;
fileOut << "15" << std::endl;
sector = Int_t(mapping->GetSectorFromRoc(roc));
rcu = Int_t(mapping->GetRcu(roc,row,pad));
hwAddr = Int_t(mapping->GetHWAddress(roc,row,pad));
- K0 = TMath::Nint(paramArgs[7] * (TMath::Power(2,16) - 1));
- K1 = TMath::Nint(paramArgs[8] * (TMath::Power(2,16) - 1));
- K2 = TMath::Nint(paramArgs[9] * (TMath::Power(2,16) - 1));
- L0 = TMath::Nint(paramArgs[4] * (TMath::Power(2,16) - 1));
- L1 = TMath::Nint(paramArgs[5] * (TMath::Power(2,16) - 1));
- L2 = TMath::Nint(paramArgs[6] * (TMath::Power(2,16) - 1));
+ k0 = TMath::Nint(paramArgs[7] * (TMath::Power(2,16) - 1));
+ k1 = TMath::Nint(paramArgs[8] * (TMath::Power(2,16) - 1));
+ k2 = TMath::Nint(paramArgs[9] * (TMath::Power(2,16) - 1));
+ l0 = TMath::Nint(paramArgs[4] * (TMath::Power(2,16) - 1));
+ l1 = TMath::Nint(paramArgs[5] * (TMath::Power(2,16) - 1));
+ l2 = TMath::Nint(paramArgs[6] * (TMath::Power(2,16) - 1));
if (entryNum%10000==0) {
printf("assigned pad %i / %i\n",entryNum,tpcPadNum);
}
fileOut << entryNum++ << "\t" << side << "\t" << sector << "\t" << rcu << "\t" << hwAddr << "\t";
- fileOut << K0 << "\t" << K1 << "\t" << K2 << "\t" << L0 << "\t" << L1 << "\t" << L2 << "\t" << validFlag << std::endl;
+ fileOut << k0 << "\t" << k1 << "\t" << k2 << "\t" << l0 << "\t" << l1 << "\t" << l2 << "\t" << validFlag << std::endl;
entryID[roc*100000 + row*1000 + pad] = 1;
}
for (Int_t iParamSec = 0; iParamSec < paramTupleSec->GetEntries(); iParamSec++) {
paramTupleSec->GetEntry(iParamSec);
Float_t *paramArgsSec = paramTupleSec->GetArgs();
- if (paramArgsSec[0] == roc) {
- K0 = TMath::Nint(paramArgsSec[7] * (TMath::Power(2,16) - 1));
- K1 = TMath::Nint(paramArgsSec[8] * (TMath::Power(2,16) - 1));
- K2 = TMath::Nint(paramArgsSec[9] * (TMath::Power(2,16) - 1));
- L0 = TMath::Nint(paramArgsSec[4] * (TMath::Power(2,16) - 1));
- L1 = TMath::Nint(paramArgsSec[5] * (TMath::Power(2,16) - 1));
- L2 = TMath::Nint(paramArgsSec[6] * (TMath::Power(2,16) - 1));
+ if ((paramArgsSec[0]-roc)<1e-7) { // if roc is found
+ k0 = TMath::Nint(paramArgsSec[7] * (TMath::Power(2,16) - 1));
+ k1 = TMath::Nint(paramArgsSec[8] * (TMath::Power(2,16) - 1));
+ k2 = TMath::Nint(paramArgsSec[9] * (TMath::Power(2,16) - 1));
+ l0 = TMath::Nint(paramArgsSec[4] * (TMath::Power(2,16) - 1));
+ l1 = TMath::Nint(paramArgsSec[5] * (TMath::Power(2,16) - 1));
+ l2 = TMath::Nint(paramArgsSec[6] * (TMath::Power(2,16) - 1));
break;
} else {
- K0 = K1 = K2 = L0 = L1 = L2 = -1;
+ k0 = k1 = k2 = l0 = l1 = l2 = -1;
}
}
for (row = 0; row<mapping->GetNpadrows(roc); row++) {
}
fileOut << entryNum++ << "\t" << side << "\t" << sector << "\t" << rcu << "\t" << hwAddr << "\t";
- fileOut << K0 << "\t" << K1 << "\t" << K2 << "\t" << L0 << "\t" << L1 << "\t" << L2 << "\t" << validFlag << std::endl;
+ fileOut << k0 << "\t" << k1 << "\t" << k2 << "\t" << l0 << "\t" << l1 << "\t" << l2 << "\t" << validFlag << std::endl;
}
}
}
fileOut.close();
fileTCFparam.Close();
fileSecTCFparam.Close();
- entryID->~Bool_t();
+ delete [] entryID;
printf("output written to file: %s\n",nameFileOut);
return 0;
}
//
// If there are parameters for a roc missing, then the parameters are set to -1
- Float_t K0 = -1, K1 = -1, K2 = -1, L0 = -1, L1 = -1, L2 = -1;
+ Float_t k0 = -1, k1 = -1, k2 = -1, l0 = -1, l1 = -1, l2 = -1;
Int_t entryNum = 0;
Int_t validFlag = 0; // 1 if parameters for roc exist
ofstream fileOut;
char nameFileOut[255];
- sprintf(nameFileOut,"tpcTCFparamSector.data");
+ snprintf(nameFileOut,255,"tpcTCFparamSector.data");
fileOut.open(nameFileOut);
// following not used:
// char headerLine[255];
- // sprintf(headerLine,"16\tside\tsector\tRCU\tHWadr\tK0\tK1\tK2\tL0\tL1\tL2\tValidFlag");
+ // snprintf(headerLine,255,"16\tside\tsector\tRCU\tHWadr\tk0\tk1\tk2\tl0\tl1\tl2\tValidFlag");
// fileOut << headerLine << std::endl;
fileOut << "16" << std::endl;
for (Int_t iParam = 0; iParam < paramTupleSec->GetEntries(); iParam++) {
paramTupleSec->GetEntry(iParam);
Float_t *paramArgs = paramTupleSec->GetArgs();
- if (paramArgs[0] == roc) {
+ if ((paramArgs[0]-roc)<1e-7) { // if roc is found
validFlag = 1;
- K0 = TMath::Nint(paramArgs[7] * (TMath::Power(2,16) - 1));
- K1 = TMath::Nint(paramArgs[8] * (TMath::Power(2,16) - 1));
- K2 = TMath::Nint(paramArgs[9] * (TMath::Power(2,16) - 1));
- L0 = TMath::Nint(paramArgs[4] * (TMath::Power(2,16) - 1));
- L1 = TMath::Nint(paramArgs[5] * (TMath::Power(2,16) - 1));
- L2 = TMath::Nint(paramArgs[6] * (TMath::Power(2,16) - 1));
+ k0 = TMath::Nint(paramArgs[7] * (TMath::Power(2,16) - 1));
+ k1 = TMath::Nint(paramArgs[8] * (TMath::Power(2,16) - 1));
+ k2 = TMath::Nint(paramArgs[9] * (TMath::Power(2,16) - 1));
+ l0 = TMath::Nint(paramArgs[4] * (TMath::Power(2,16) - 1));
+ l1 = TMath::Nint(paramArgs[5] * (TMath::Power(2,16) - 1));
+ l2 = TMath::Nint(paramArgs[6] * (TMath::Power(2,16) - 1));
break;
}
}
if (!validFlag) { // No TCF parameters found for this roc
- K0 = K1 = K2 = L0 = L1 = L2 = -1;
+ k0 = k1 = k2 = l0 = l1 = l2 = -1;
}
fileOut << entryNum++ << "\t" << side << "\t" << sector << "\t" << rcu << "\t" << -1 << "\t";
- fileOut << K0 << "\t" << K1 << "\t" << K2 << "\t" << L0 << "\t" << L1 << "\t" << L2 << "\t" << validFlag << std::endl;
+ fileOut << k0 << "\t" << k1 << "\t" << k2 << "\t" << l0 << "\t" << l1 << "\t" << l2 << "\t" << validFlag << std::endl;
}
}
}