// cout << endl;
//Check seeds (whether highest entry in cluster):
- for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO
- {
- if ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) ) {
- CHANCE=0;
-// cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
- 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, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl;
- CHANCE=0; //NOTE: potential error source
- break;
- }
- else {
- CHANCE=100;
- if(i%5==3) {
- i+=2;
- };
- }
- }
+ if(fOrderCode=="FSBB")
+ {
+ for(Int_t i=0; i<25; i++) // why not over full cluster? (I=0 i<25 TODO
+ {
+ if ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) ) {
+ CHANCE=0;
+ // cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
+ 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, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl;
+ CHANCE=0; //NOTE: potential error source
+ break;
+ }
+ else {
+ CHANCE=100;
+ }
+ }
+ }
+ else
+ {
+ for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO
+ {
+ if ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) ) {
+ CHANCE=0;
+ // cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
+ 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, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << 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)
{
+ //cout<<"CLUSTER ACCEPTED"<<Hitlist[hit]<< " with ADC: " << pixelchargeincluster[12]<<endl;
if(fOrderCode=="FSBB")
{
if (B < 2 || B > fColumns-3 || A < 1 || A > fRows-2)
else
bordercluster = false;
}
- for(Int_t row=0; row<5; row++)
- {
- for(Int_t column=0; column<5; column++)
- {
- if ( (row==0) && (A<2) ) { }
- else if ( (row==1) && (A<1) ) { }
- else if ( (row==3) && (A>= (fRows-1)) ) { }
- else if ( (row==4) && (A>= (fRows-2)) ) { }
- else
- {
- if ( (column==0) && (B<2) ) { }
- else if ( (column==1) && (B==0) ) { }
- else if ( (column==3) && (B==fColumns-1)) { }
- else if ( (column==4) && (B>fColumns-3)) { }
- else {
- fHittedPixel[Hitlist[hit]+(row-2)*fColumns+(column-2)] = bordercluster?-1:1;
- }
- }
- }
- }
+ for(Int_t row=0; row<5; row++)
+ {
+ for(Int_t column=0; column<5; column++)
+ {
+ if ( (row==0) && (A<2) ) { }
+ else if ( (row==1) && (A<1) ) { }
+ else if ( (row==3) && (A>= (fRows-1)) ) { }
+ else if ( (row==4) && (A>= (fRows-2)) ) { }
+ else
+ {
+ if ( (column==0) && (B<2) ) { }
+ else if ( (column==1) && (B==0) ) { }
+ else if ( (column==3) && (B==fColumns-1)) { }
+ else if ( (column==4) && (B>fColumns-3)) { }
+ else {
+ fHittedPixel[Hitlist[hit]+(row-2)*fColumns+(column-2)] = bordercluster?-1:1;
+ }
+ }
+ }
+ }
// cout<<"Hitted pixel discriminator matrix:"<<endl;
// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
if (bordercluster)
// if cluster charge > clusternoise * const
if(fOrderCode=="FSBB")
{
- if (1.0*chargesumincluster4 > noisesumincluster4*6.0)
+ if (1.0*chargesumincluster4 > noisesumincluster4*5.0)
fFrameInfo.pixelthreshold[fHits] = Hitlist[hit];
else
fFrameInfo.pixelthreshold[fHits] = 0;
cout<<"Frame could not be loaded!"<<endl;
}
else {
+
cout <<endl <<endl << colorwhite << "---------------- FRAME " << fFrameNumber << " ----------------" << colorreset << endl << endl;
cout<<"CDS matrix:"<<endl;
- debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39);
+ // debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39);
Float_t cdsmatrixCorrPed[fPixels];
for(Int_t i=0; i<fPixels; i++)
{
cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
}
- debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
+ // debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
// cout<<fCdsmatrix[0]<<","<<fCdsmatrix[1]<<","<<fCdsmatrix[2]<<","<<fCdsmatrix[3]<<","<<fCdsmatrix[4]<<","<<fCdsmatrix[5]<<","<<fCdsmatrix[6]<<endl;
- cout<<"Hitted pixel discriminator matrix:"<<endl;
- debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
-
+ //cout<<"Hitted pixel discriminator matrix:"<<endl;
+ //debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+
+ cout << colorred <<"Accepted hit cluster:"<<endlr;
+ for (Int_t hiti = 0; hiti < fHits; hiti++)
+ {
+ for(Int_t row=0; row<5; row++)
+ {
+ for(Int_t column=0; column<5; column++)
+ {
+ std::cout.width(10);
+ std::cout << std::fixed;
+ std::cout << std::left << std::setprecision(2) << fFrameInfo.p[row*5+column][hiti];
+ }
+ cout << endl;
+ }
+ cout << endl;
+ }
+ /*
TCanvas* cm1 = new TCanvas(Form("Frame %d",FrameNumber),Form("Frame %d",FrameNumber),50,100,1200,800);
cm1->Divide(2,3);
gStyle->SetOptFit(1011);
cm1->Update();
cout<<"\rPIXELMATRIX plotted! "<<endl;
cout<<"-------------------"<<endl;
+ */
}
}
}
}
}
-
//####################################################################
-void MAPS::reorderFSBB() {
+void MAPS::reorderFSBB2() {
+ //fCdsMatrix from datastream: from 0,1,2,3,4,5
+ // Mean in electronic channels:
+ // 0 1 2 3 4 5 6 7
+ // 8 9 10 11 12 13 14 15
+ //...
+ // In real:
+ // 0 1 2 3
+ // 4 5 6 7
+ //8 9 10 11
+ // So data stream looks like: 0 4 8... 1 5 9
+
+
Float_t CDSMATRIX [fPixels];
Int_t F0MATRIX [fPixels];
fRows = 4;
fColumns = 416;
fPixels = fRows*fColumns;
- // debugStream(CDSMATRIX, fPixels, 208, 0, 39);
+ // debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
Int_t subRows = 4;
Int_t subColumns = 208;
Int_t a0[subRows][subColumns];
Int_t a1[subRows][subColumns];
Int_t aMerge[fRows][fColumns];
-
+ // cout<<"CDS matrix:"<<endl;
+ // debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+ //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+ // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ // {
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+ // a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+iPixelInZeile*subRows*2];
+ // a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ // }
+ // }
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
//Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+ a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+iPixelInZeile*8];
+ a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)+iPixelInZeile*8];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ }
+
+
+ // Start Filter CommonMode
+ /*Float_t CommonModeInRow = 0;
+ bool warning=false;
+ CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+ if (CommonModeInRow < 0)
+ plus++;
+ else
+ minus++;
+
+ if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+ {
+ warning = true;
+ }
+ if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow << " --> Common Mode suspiciously high! "<<endl;
+ debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+ }
+
+ for(int column=0; column<subColumns; column++ )
+ {
+ a0[iOutChannel][column ] -= CommonModeInRow;
+ }
+ // End Filter CommonMode*/
+ }
+
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a1[3][i]<<",";
+ // }
+ // cout<<endl;
+
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ // {
+ // Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ // }
+ // }
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ {
+ //Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ }
+ }
+
+ for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+ {
+ for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+ {
+ fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard)
+
+ }
+ }
+ for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ {
+ // cout<<fCdsmatrix[iPixel]<<",";
+
+ }
+
+}
+//####################################################################
+void MAPS::reorderFSBB3() {
+
+ Float_t CDSMATRIX [fPixels];
+ Int_t F0MATRIX [fPixels];
+ Int_t F1MATRIX [fPixels];
+ for(Int_t i=0; i<fPixels; i++)
{
+ CDSMATRIX [i] = fCdsmatrix[i];
+ F0MATRIX [i] = fF0matrix [i];
+ F1MATRIX [i] = fF1matrix [i];
+ }
+ fRows = 4;
+ fColumns = 416;
+ fPixels = fRows*fColumns;
+ // debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
+
+ Int_t subRows = 4;
+ Int_t subColumns = 208;
+ Int_t a0[subRows][subColumns];
+ Int_t a1[subRows][subColumns];
+ Int_t aMerge[fRows][fColumns];
+ // cout<<"CDS matrix:"<<endl;
+ // debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+ //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+ // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ // {
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+ // a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+iPixelInZeile*subRows*2];
+ // a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ // }
+ // }
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
{
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel*subColumns+iPixelInZeile];
a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
}
+
+
+ // Start Filter CommonMode
+ /*Float_t CommonModeInRow = 0;
+ bool warning=false;
+ CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+ if (CommonModeInRow < 0)
+ plus++;
+ else
+ minus++;
+
+ if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+ {
+ warning = true;
+ }
+ if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow << " --> Common Mode suspiciously high! "<<endl;
+ debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+ }
+
+ for(int column=0; column<subColumns; column++ )
+ {
+ a0[iOutChannel][column ] -= CommonModeInRow;
+ }
+ // End Filter CommonMode*/
}
+
// for(Int_t i=0; i<208; i++)
// {
- // cout<< a0[3][i]<<",";
+ // cout<< a0[0][i]<<",";
// }
// cout<<endl;
// for(Int_t i=0; i<208; i++)
// }
// cout<<endl;
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ // {
+ // Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ // }
+ // }
for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
{
for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
}
}
+
for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
{
for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
{
fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard)
+
}
}
+ for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ {
+ // cout<<fCdsmatrix[iPixel]<<",";
+
+ }
+ //exit(0);
+}
+
+//####################################################################
+
+//####################################################################
+void MAPS::reorderFSBB() {
+
+ Float_t CDSMATRIX [fPixels];
+ Int_t F0MATRIX [fPixels];
+ Int_t F1MATRIX [fPixels];
+ for(Int_t i=0; i<fPixels; i++)
+ {
+ CDSMATRIX [i] = fCdsmatrix[i];
+ F0MATRIX [i] = fF0matrix [i];
+ F1MATRIX [i] = fF1matrix [i];
+ }
+ fRows = 4;
+ fColumns = 416;
+ fPixels = fRows*fColumns;
+ // debugStream(CDSMATRIX, fPixels, 208, 0, 2000);
+
+ Int_t subRows = 4;
+ Int_t subColumns = 208;
+ Int_t a0[subRows][subColumns];
+ Int_t a1[subRows][subColumns];
+ Int_t aMerge[fRows][fColumns];
+ // cout<<"CDS matrix:"<<endl;
+ // debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+ //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+ // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ // {
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+ // a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+iPixelInZeile*subRows*2];
+ // a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ // }
+ // }
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+ a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel*subColumns+iPixelInZeile];
+ a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ }
+
+
+ // Start Filter CommonMode
+ /*Float_t CommonModeInRow = 0;
+ bool warning=false;
+ CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+ if (CommonModeInRow < 0)
+ plus++;
+ else
+ minus++;
+
+ if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+ {
+ warning = true;
+ }
+ if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow << " --> Common Mode suspiciously high! "<<endl;
+ debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+ }
+ for(int column=0; column<subColumns; column++ )
+ {
+ a0[iOutChannel][column ] -= CommonModeInRow;
+ }
+ // End Filter CommonMode*/
+ }
+
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a1[3][i]<<",";
+ // }
+ // cout<<endl;
+
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ // {
+ // Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ // }
+ // }
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ {
+ //Merge A0-0, then A1-0 in one line, then A0-1 and A1-1 in one line...
+ aMerge[iOutChannel][iMerge2channels]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ aMerge[iOutChannel][iMerge2channels+subColumns]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ }
+ }
+
+ for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+ {
+ for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+ {
+ fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard)
+
+ }
+ }
+ //debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ {
+ // cout<<fCdsmatrix[iPixel]<<",";
+
+ }
+ //exit(0);
+}
+
+//####################################################################
+//####################################################################
+void MAPS::reorderFSBB_B() {
+ // War: A0-0, A1-0, A0-1, A1-1
+ //0,1,...,415
+ //416,...,
+ //Ist Blödsinn, deshalb wird zuerst A0 ausgelesen, und dann A1
+ Float_t CDSMATRIX [fPixels];
+ Int_t F0MATRIX [fPixels];
+ Int_t F1MATRIX [fPixels];
+ for(Int_t i=0; i<fPixels; i++)
+ {
+ CDSMATRIX [i] = i;
+ F0MATRIX [i] = fF0matrix [i];
+ F1MATRIX [i] = fF1matrix [i];
+ }
+ fRows = 4;
+ fColumns = 416;
+ fPixels = fRows*fColumns;
+ // debugStream(CDSMATRIX, fPixels, 416, 0, 2000);
+
+ Int_t subRows = 4;
+ Int_t subColumns = 2*208;
+ Int_t a0[subRows][subColumns];
+ Int_t a1[subRows][subColumns];
+ Int_t aMerge[fRows][fColumns];
+ // cout<<"CDS matrix:"<<endl;
+ // debugStream<>(fCdsmatrix, fPixels, 4*416, 0, 39);
+ //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then...
+ // for(Int_t iPixelInZeile=0; iPixelInZeile<subColumns; iPixelInZeile++)
+ // {
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)+iPixelInZeile*subRows*2<<endl;
+ // a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel+iPixelInZeile*subRows*2];
+ // a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)+iPixelInZeile*subRows*2];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ // }
+ // }
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ //Divide CDSMATRIX in the channels. First 208 pixels are from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iPixelInZeile=0; iPixelInZeile<fColumns; iPixelInZeile++)
+ {
+ // cout<<iPixelInZeile<<":"<<(4+iOutChannel)*subColumns+iPixelInZeile<<"-";
+ a0[iOutChannel][iPixelInZeile]=CDSMATRIX [iOutChannel*fColumns+iPixelInZeile];
+ // a1[iOutChannel][iPixelInZeile]=CDSMATRIX [(4+iOutChannel)*subColumns+iPixelInZeile];//4+iOutChannel, because this is A1, which is shifted by four channels of A0
+ }
+
+
+ // Start Filter CommonMode
+ /*Float_t CommonModeInRow = 0;
+ bool warning=false;
+ CommonModeInRow = TMath::Median(subColumns, a0[iOutChannel]); // Don't use mean, consider hitted pixel !
+ if (CommonModeInRow < 0)
+ plus++;
+ else
+ minus++;
+
+ if(TMath::Abs(CommonModeInRow)>0) // TODO better warning criteria
+ {
+ warning = true;
+ }
+ if(warning) { cout<<"\rFrame: "<<fFrameNumber<< " row: " << iOutChannel << " Median of row: " << CommonModeInRow << " --> Common Mode suspiciously high! "<<endl;
+ debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ debugStream<>(a0[iOutChannel], subColumns, subColumns, 1, 20);
+ }
+
+ for(int column=0; column<subColumns; column++ )
+ {
+ a0[iOutChannel][column ] -= CommonModeInRow;
+ }
+ // End Filter CommonMode*/
+ }
+
+ // for(Int_t i=0; i<208*2; i++)
+ // {
+ // cout<< a0[0][i]<<",";
+ // }
+ // cout<<endl;
+ // for(Int_t i=0; i<208; i++)
+ // {
+ // cout<< a1[3][i]<<",";
+ // }
+ // cout<<endl;
+
+ // for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ // {
+ // for(Int_t iMerge2channels=0; iMerge2channels<subColumns;iMerge2channels++)
+ // {
+ // Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ // aMerge[iOutChannel][iMerge2channels*2]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ // aMerge[iOutChannel][iMerge2channels*2+1]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ // }
+ // }
+ for(Int_t iOutChannel=0; iOutChannel<subRows; iOutChannel++)
+ {
+ for(Int_t iMerge2channels=0; iMerge2channels<fColumns;iMerge2channels++)
+ {
+ //Merge A0-0[0],A1-0[0],A0-0[1],A1-0[1],A0-0[2],A1-0[2],... output is an array of 4 geometrically columns
+ aMerge[iOutChannel][iMerge2channels]=a0[iOutChannel][iMerge2channels];//A0-iOutChannel[iMerge2channels]
+ // aMerge[iOutChannel][iMerge2channels+subColumns]=a1[iOutChannel][iMerge2channels];//A1-iOutChannel[iMerge2channels]
+ }
+ }
+
+ for(Int_t iOutChannel=0; iOutChannel<fRows; iOutChannel++)
+ {
+ for(Int_t iPixel=0; iPixel<fColumns;iPixel++)
+ {
+ fCdsmatrix[iOutChannel*fColumns+iPixel]=aMerge[iOutChannel][iPixel];//Write the merged data in fCdsmatrix, which is 1dim array (standard)
+
+ }
+ }
+ debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20);
+ for(Int_t iPixel=0; iPixel<fPixels;iPixel++)
+ {
+ // cout<<fCdsmatrix[iPixel]<<",";
+
+ }
+ //exit(0);
}
//####################################################################