cout<<" Ordering according to : "<<fOrderCode<<endl;
cout<<" Save/Overwrite data : "<<fSave<<endl;
cout<<" System specified : "<<fSystem<<endl;
- cout<<" Dynamic noise calc : ";
- if (useexponentialdecayingnoisewindow)
- cout << "Modified moving average (MMA)" << endl;
- else
- cout << "Simple moving average (SMA)" << endl;
// loadNoise();
fSystem = "PXI";
}
}
- else if( (NrAdcBoards == 2 && fSystem != "USB") || (NrAdcBoards == 4 && fSystem != "PXI") )
+ else if( ( (NrAdcBoards == 2 && fSystem != "Pegasus") && (NrAdcBoards == 2 && fSystem != "USB") ) || (NrAdcBoards == 4 && fSystem != "PXI") )
{
cout<<"---------"<<endl;
cout<<"System specification ( "<<fSystem<<" ) might be incorrect!"<<endl;
fSystem = "PXI";
}
}
- else if( (NrAdcBoards == 2 && fSystem != "USB") || (NrAdcBoards == 4 && fSystem != "PXI") )
+ else if( ( (NrAdcBoards == 2 && fSystem != "Pegasus") && (NrAdcBoards == 2 && fSystem != "USB") ) || (NrAdcBoards == 4 && fSystem != "PXI") )
{
cout<<"---------"<<endl;
cout<<"System specification ( "<<fSystem<<" ) might be incorrect!"<<endl;
if (Frames != FileEvNbInConfig && Frames >= 20000)
cout << colorred << "Run could be corrupted, number of events in file doesn't match configuration! ("<< Frames << " != " << FileEvNbInConfig << ")" << endlr;
// cout<<setw(15)<<left<<Form("%7i Pixels",Pixels);
- cout<<endl;
+// cout<<endl;
//-----------------------------------------------
return true;
}
fF0matrix[i]+=1; // Correction to error in DAQ code
}
}
- else if ( fSystem == "USB" )
+ else if ( fSystem == "USB" || fSystem == "Pegasus" )
{
fF0matrix [i] = value1 [(UChar_t)RAWDATA[4*i+1]] [(UChar_t)RAWDATA[4*i+2]];
fF1matrix [i] = value2 [(UChar_t)RAWDATA[4*i]] [(UChar_t)RAWDATA[4*i+1]];
{
if (abs(a[i]) > highlightabove)
std::cout << colorred;
- std::cout.width(precision+4);
+ std::cout.width(precision+6);
std::cout << std::fixed;
std::cout << std::left << std::setprecision(precision);
std::cout << a[i] << colorreset;
{
if (useexponentialdecayingnoisewindow)
{
- fNoise[pixeli] = ( (Frames-1)*fNoise[pixeli] + TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2) )/(Frames);
+ fNoise[pixeli] = TMath::Sqrt(( (Frames-2)*TMath::Power(fNoise[pixeli],2) + TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2) )/(Frames-1));
fPedestals[pixeli] = ( (Frames-1)*fPedestals[pixeli] + fCdsmatrix[pixeli] )/Frames;
}
else
fPedestals[pixeli] -= (CDSlastframes[pixeli].front()-fCdsmatrix[pixeli])/CDSlastframes[pixeli].size();
CDSlastframes[pixeli].pop();
CDSlastframes[pixeli].push(fCdsmatrix[pixeli]);
- if (abs(fPedestals[pixeli])>20)
- {
- fPedestalhighPixel++;
- if (!pedestalhighinthisframe) {
- fPedestalhighFrames++;
- pedestalhighinthisframe=true;
- }
-// cout<<"\rFrame: "<<fFrameNumber<< " row: " << (Int_t)pixeli/fColumns << " Pedestial of pixel: " << fPedestals[pixeli] << " --> Pedestal suspiciously high!"<<endl;
-// cout<<" CDS signal of sensor: ";
-// debugStream<>(fCdsmatrix , fPixels, fColumns, 1, 20);
-// cout<<" Pedestial of sensor: ";
-// debugStream<>(fPedestals , fPixels, fColumns, 1, 20);
-// cout<<" Hitted Pixel discriminator matrix: ";
-// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
-// exit(1);
+ }
+ if (abs(fPedestals[pixeli])>20)
+ {
+ fPedestalhighPixel++;
+ if (!pedestalhighinthisframe) {
+ fPedestalhighFrames++;
+ pedestalhighinthisframe=true;
}
- if (abs(fNoise[pixeli])>20)
- {
- fNoiseHighPixel++;
- if (!noisehighinthisframe) {
- fNoiseHighFrames++;
- noisehighinthisframe=true;
- }
+ // cout<<"\rFrame: "<<fFrameNumber<< " row: " << (Int_t)pixeli/fColumns << " Pedestial of pixel: " << fPedestals[pixeli] << " --> Pedestal suspiciously high!"<<endl;
+ // cout<<" CDS signal of sensor: ";
+ // debugStream<>(fCdsmatrix , fPixels, fColumns, 1, 20);
+ // cout<<" Pedestial of sensor: ";
+ // debugStream<>(fPedestals , fPixels, fColumns, 1, 20);
+ // cout<<" Hitted Pixel discriminator matrix: ";
+ // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+ // exit(1);
+ }
+ if (abs(fNoise[pixeli])>20)
+ {
+ fNoiseHighPixel++;
+ if (!noisehighinthisframe) {
+ fNoiseHighFrames++;
+ noisehighinthisframe=true;
+ }
+ // cout << colorred << fFrameNumber << endlr;
+// if (fFrameNumber==15683 || fFrameNumber==15684)
+// {
// cout <<"\rFrame: "<<fFrameNumber<< " row: " << (Int_t)pixeli/fColumns << " Noise of pixel: " << fNoise[pixeli] << " --> Noise suspiciously high! "<<endl;
// cout<<" CDS signal of sensor: ";
-// debugStream<>(fCdsmatrix , fPixels, fColumns, 1, 20);
+// debugStream<>(fCdsmatrix , fPixels, fColumns, 0, 20);
// cout<<" Noise of sensor: ";
-// debugStream<>(fNoise , fPixels, fColumns, 1, 20);
+// debugStream<>(fNoise , fPixels, fColumns, 0, 20);
// cout<<" Hitted Pixel discriminator matrix: ";
-// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
-// exit(1);
- }
+// debugStream<>(fHittedPixel, fPixels, fColumns, 0, 1);
+// }
}
}
else
{
-// cout << "Skipped pixel " << pixeli << " for noise calc" << endl;
+// cout << "Skipped pixel " << pixeli << " for noise calc in frame " << fFrameNumber << ", because fHittedPixel: " << fHittedPixel[pixeli] << endl;
}
}
if (pedestalhighinthisframe)
cout<<"\rFrame: "<<fFrameNumber<< " --> Noise suspiciously high!"<<endl;
if (fFrameNumber%Frames == 0 && RefillNoiseBranch)
{
+ cout << fNoise[0] << " ";
if(fSave)
{
Float_t PEDESTAL;
Int_t HITNR = 0;
/// Array which holds the hit pixels indices, in other words: it holds the pixel number of the fired pixels
Int_t *Hitlist;
+ /// Array which holds the recharging pixel indices, in other words: it holds the pixel number of the pixels with highly negative CDS
+ std::vector<int> rechargePixellist;
Int_t A;
Int_t B;
+ Int_t seedrow;
+ Int_t seedcolumn;
Int_t DUMMY=0;
/// F0 - F1 of specific pixel in cluster
Float_t pixelchargeincluster[25]={ 0 };
Bool_t bordercluster=false;
Float_t noisesumincluster=0;
Float_t chargesumincluster=0;
-
+
for(Int_t i=0; i<fPixels; i++)
{
fHittedPixel[i] = 0;
{
HITNR++;
HITS.Set(HITNR);
- HITS.AddAt(i,(HITNR-1));
-// cout << "Frame: " << fFrameNumber << " Candidate at pixel: " << i << " with ADC: " << (1.*fCdsmatrix[i]-fPedestals[i]) << endl;
-
+ HITS.AddAt(i,(HITNR-1));
if(fSave) {
hint2->Fill(i%fColumns+0.1, (int)(i/fColumns)+0.1); // counts up in 2dimensional pixel matrix
}
}
+
+ if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) < (-5.*fNoise[i]) ) // loop to find pixel with highly negative CDS
+ {
+ rechargePixellist.push_back(i);
+ }
}
//Rewrite HITS to fHitlist array (why?)
Hitlist[i]=HITS.At(i);
}
+// Begin loop over all negative CDS pixel
+// Determine clusters around them
+ for(Int_t rechargingpixeli=0; rechargingpixeli<rechargePixellist.size(); rechargingpixeli++)
+ {
+ seedrow = (rechargePixellist[rechargingpixeli])/fColumns; // row of seed
+ seedcolumn = (rechargePixellist[rechargingpixeli])%fColumns; // column of seed
+
+ //Provide 5x5 clusters with CDS - content:
+ for(Int_t row=0; row<5; row++)
+ {
+ for(Int_t column=0; column<5; column++)
+ {
+ // wenn erste Reihe des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in erster oder zweiten Reihe des Matrix liegt
+ if ( (row==0) && (seedrow<2) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn zweite Reihe des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in erster Reihe des Matrix liegt
+ else if ( (row==1) && (seedrow<1) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn vierte Reihe des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in letzter Reihe des Matrix liegt
+ else if ( (row==3) && (seedrow>= (fRows-1)) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn vierte Reihe des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in vorletzter Reihe des Matrix liegt
+ else if ( (row==4) && (seedrow>= (fRows-2)) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ else
+ {
+ // wenn erste Spalte des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in erster oder zweiten Spalte des Matrix liegt
+ if ( (column==0) && (seedcolumn<2) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn zweite Spalte des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in erster Spalte der Matrix liegt
+ else if ( (column==1) && (seedcolumn==0) ) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn dritte Spalte des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in letzter Spalte der Matrix liegt
+ else if ( (column==3) && (seedcolumn==fColumns-1)) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ // wenn letzte Spalte des Clusters gefüllt werden soll
+ // und das Seed Pixel am Rand - in vorletzter Spalte der Matrix liegt
+ else if ( (column==4) && (seedcolumn>fColumns-3)) {
+ // cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
+ pixelchargeincluster[(row*5)+column]=DUMMY;
+ }
+ else {
+ pixelchargeincluster[(row*5)+column] = 1.*fCdsmatrix [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)] - fPedestals [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)];
+ }
+ }
+ }
+ }
+
+ //Check seeds (whether lowest entry in cluster):
+ for(Int_t i=6; i<19; i++)
+ {
+ if ( (i!=12) && (pixelchargeincluster[i] < pixelchargeincluster[12]) ) {
+ CHANCE=0;
+ break;
+ }
+ // maybe this is unnecessary, if upper if clause is a >= comparison
+ else if ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 ) {
+ cout << "WARNING: next pixel value identical to precessor" << endl;
+ CHANCE=0; //NOTE: potential error source
+ break;
+ }
+ else {
+ CHANCE=100;
+ if(i%5==3) {
+ i+=2;
+ };
+ }
+ }
+
+ //Begin: loop evaluate true seeds:
+ if(CHANCE==100)
+ {
+ if (seedcolumn < 2 || seedcolumn > fColumns-3 || seedrow < 2 || seedrow > fRows-3)
+ bordercluster = true;
+ else
+ bordercluster = false;
+ for(Int_t row=0; row<5; row++)
+ {
+ for(Int_t column=0; column<5; column++)
+ {
+ if ( (row==0) && (seedrow<2) ) { }
+ else if ( (row==1) && (seedrow<1) ) { }
+ else if ( (row==3) && (seedrow>= (fRows-1)) ) { }
+ else if ( (row==4) && (seedrow>= (fRows-2)) ) { }
+ else
+ {
+ if ( (column==0) && (seedcolumn<2) ) { }
+ else if ( (column==1) && (seedcolumn==0) ) { }
+ else if ( (column==3) && (seedcolumn==fColumns-1)) { }
+ else if ( (column==4) && (seedcolumn>fColumns-3)) { }
+ else {
+ fHittedPixel[rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)] = -3;
+ }
+ }
+ }
+ }
+ // cout<<"Hitted pixel discriminator matrix:"<<endl;
+ // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+ fHittedPixel[rechargePixellist[rechargingpixeli]] = -4;
+
+ }
+
+ }
+
//Begin: loop over all potential seed pixels:
//Determine 'hit-vicinity':
fHits = 0;
}
}
+
+
+
+
//Begin: loop evaluate true seeds:
if(CHANCE==100)
{
cout<<"Hitted pixel discriminator matrix:"<<endl;
debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
- TCanvas* cm1;
- cm1 = new TCanvas("cm1","Matrix",50,100,1200,800);
+ TCanvas* cm1 = new TCanvas(TString(FrameNumber),TString(FrameNumber),50,100,1200,800);
cm1->Divide(2,3);
gStyle->SetOptFit(1011);
gStyle->SetPalette(1);
storepathRAWLinux = labbook.storepath;
// storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/jspc53_H");
// storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/jspc53_H");
- storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/d/jspc53_H");
- storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/d/jspc53_H");
+ storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/d/garlic");
+ storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/d/garlic");
if (TString(hostname).EqualTo("jspc48"))
{
storepathRAWLinux = storepathRAWLinux.ReplaceAll("U:","/d/jspc28/jspc53_U");
cout << colorwhite << "initHistograms():" << endlr;
initHistograms(&histogram);
initHistograms(&histogramthreshold, " threshold");
- runexistsinDB = 1;
debugDBreadout();
}
else
return 0;
}
-Bool_t Run::analyzeRun(Bool_t force)
+Bool_t Run::setDynamicalNoiseMode(TString mode)
+{
+ cout<<" Dynamic noise calc : ";
+ if (mode.Contains("exponential", TString::kIgnoreCase) || mode.Contains("MMA", TString::kIgnoreCase))
+ {
+ cout << "Modified moving average (MMA)" << endl;
+ processed->useexponentialdecayingnoisewindow = 1;
+ return 0;
+ }
+ else if (mode.Contains("simple", TString::kIgnoreCase) || mode.Contains("SMA", TString::kIgnoreCase))
+ {
+ cout << "Simple moving average (SMA)" << endl;
+ processed->useexponentialdecayingnoisewindow = 0;
+ return 0;
+ }
+ return 1;
+}
+
+Bool_t Run::initRun()
{
- if (runexistsinDB)
+ if (!error)
{
cout << colorwhite << "instatiate MAPS(this)" << endlr;
processed = new MAPS(this);
error = processed->error;
- if (!error)
- {
- if (!runAllreadyAnalyzed() || force)
- {
- if (processed->initNewRootFile()) return 1;
- /// progress meter, temporal variable
- ULong_t progress_tmp=-1;
- /// progress meter
- Float_t progress;
- processed->InitialDynNoise();
- int start = 0;
- int nframes = processed->GetNumberFrames();
- for(int i=0; i<nframes;i++) // TODO remove 100000
- {
- // cout << "getframe " << i << endl;
- processed->getFrame(i);
- // processed->filterCommonMode();
- // cout << "hitana " << endl;
- processed->hitana();
- // cout << "regetDynNoise " << endl;
- if (dynamicalNoise)
- processed->regetDynNoise();
- progress = (Int_t)(((i-start)*100)/(nframes-1)*10);
- if (progress!=progress_tmp) { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;}
- }
- // cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl;
+ return 0;
+ }
+ return 1;
+}
- // print a dummy file to indicate, that a root file was created once
- fstream* fout = new fstream(storepathRAWLinux + "/rootfilecreated",std::ios::out);
- *fout << "" << endl;
- fout->close();
- processed->save();
- }
- else
+
+Bool_t Run::analyzeRun(Bool_t force)
+{
+ if (!error)
+ {
+ if (!runAllreadyAnalyzed() || force)
+ {
+ if (processed->initNewRootFile()) return 1;
+ /// progress meter, temporal variable
+ ULong_t progress_tmp=-1;
+ /// progress meter
+ Float_t progress;
+ processed->InitialDynNoise();
+ int start = 0;
+ int nframes = processed->GetNumberFrames();
+ // for(int i=15580; i<15685;i++) // TODO remove 100000 run 342272
+ for(int i=0; i<nframes/2;i++) // TODO remove 100000 run 342272
{
- cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
- cout << colorwhite << "initOldRootFile():" << endlr;
+// cout << "getframe " << i << endl;
+ processed->getFrame(i);
+ // processed->filterCommonMode();
+// cout << "hitana " << i << endl;
+ processed->hitana();
+// cout << "regetDynNoise " << endl;
+ if (dynamicalNoise)
+ processed->regetDynNoise();
+ progress = (Int_t)(((i-start)*100)/(nframes-1)*10);
+ if (progress!=progress_tmp) { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;}
}
+// cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl;
+
+ // print a dummy file to indicate, that a root file was created once
+ fstream* fout = new fstream(storepathRAWLinux + "/rootfilecreated",std::ios::out);
+ *fout << "" << endl;
+ fout->close();
+ processed->save();
}
- if (!error)
+ else
{
- if (processed->initOldRootFile()) return 1;
- cout << colorwhite << "binNoise():" << endlr;
- binNoise();
- cout << colorwhite << "binSeedSumVeto():" << endlr;
- binSeedSumVeto();
- cout << colorwhite << "rescaleHistograms():" << endlr;
- histogramCalibrated.calibrated = rescaleHistograms();
- histogramthresholdCalibrated.calibrated = histogramCalibrated.calibrated;
- cout << colorwhite << "calculateCCE():" << endlr;
- calculteCCE();
- cout << colorwhite << "updateDatabase():" << endlr;
- updateDatabase();
- cout << colorwhite << "delete MAPS class:" << endlr;
- delete processed;
- return 0;
+ cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
+ cout << colorwhite << "initOldRootFile():" << endlr;
}
+ if (processed->initOldRootFile()) return 1;
+ cout << colorwhite << "binNoise():" << endlr;
+ binNoise();
+ cout << colorwhite << "binSeedSumVeto():" << endlr;
+ binSeedSumVeto();
+ cout << colorwhite << "rescaleHistograms():" << endlr;
+ histogramCalibrated.calibrated = rescaleHistograms();
+ histogramthresholdCalibrated.calibrated = histogramCalibrated.calibrated;
+ cout << colorwhite << "calculateCCE():" << endlr;
+ calculteCCE();
+ cout << colorwhite << "updateDatabase():" << endlr;
+ updateDatabase();
+ cout << colorwhite << "delete MAPS class:" << endlr;
delete processed;
+ return 0;
}
+ delete processed;
return 1;
}
Bool_t Run::analyzeFrame(Int_t frame)
{
- if (runexistsinDB)
+ if (!error)
{
processed = new MAPS(this);
processed->initNewRootFile();
{
processed->InitialDynNoise(100);
processed->getFrame(frame);
- processed->filterCommonMode();
+// processed->filterCommonMode();
processed->hitana();
processed->plotFrame(frame);
delete processed;
systemparamcur = systemparamUSB;
else if (labbook.system.EqualTo("PXI")) // && labbook.chipGen.EqualTo("34") )
systemparamcur = systemparamPXI;
+ else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") )
+ systemparamcur = systemparamPegasus;
setSensorInSystemParam();
}
{
sensorinfostruct sensorinfoMi34USB( 8, 64 );
sensorinfostruct sensorinfoMi34PXI( 16, /* rows */ 64 /* columns */ );
+ sensorinfostruct sensorinfoPegasus( 8, 56 );
if (labbook.system.EqualTo("USB")) // && labbook.chipGen.EqualTo("34") )
sensorinfocur=sensorinfoMi34USB;
else if (labbook.system.EqualTo("PXI")) // && labbook.chipGen.EqualTo("34") )
sensorinfocur=sensorinfoMi34PXI;
+ else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") )
+ sensorinfocur=sensorinfoPegasus;
}
template <typename T>
Float_t posMax = 0;
Float_t posMax2 = 0;
Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
- Float_t noiseborder = posMaxValHist/10; // for USB system, the value is 90
+ Float_t noiseborder = 90; // posMaxValHist/10 for USB system, the value is 90
if (doFits)
{