Skip to content
Snippets Groups Projects
Commit 2a0974b2 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Fixing MUST2 simulation

        - The mask file were having only 124 strips due to rounding
        error
        - the mask now have the correct number of strip
        - the macro has been modified
parent e36378e8
No related branches found
No related tags found
No related merge requests found
void Mask(){
unsigned int strips = 128 ;
double dimension = 100.42;
double active = 97.30;
double pitch = 97.30/128;
double active = 97.22;
double pitch = active/strips;
double width = 0.7;
//
// double dimension = 100;
......@@ -11,25 +12,24 @@ void Mask(){
// double width = 0.5;
// mm per pixel
double scale = 0.005;
double scale = 97.22/12800;
//pitch in pixel
unsigned int spitch = pitch/scale;
unsigned int swidth = width/scale;
unsigned int sinter = (spitch - swidth)/2;
unsigned int sinter = (pitch - width)/(scale);
cout << spitch << " " << swidth << " " << sinter << endl;
// image size
unsigned int size = dimension/scale;
cout << "Image size: " << size << "x" << size<< endl ;
double* zargb = new double[size*size];
TASImage* zero = new TASImage("zero",zargb,size,size,0);
zero->WriteImage("mask.png");
TASImage* mask = new TASImage("mask.png");
delete[] zargb;
TASImage* mask = new TASImage("mask",zargb,size,size,0);
unsigned int* argb = mask->GetArgbArray();
unsigned int* argb2 = mask->GetArgbArray();
unsigned int index = 0;
double border1 = (dimension-active)/scale;
double border2 = (active)/scale;
double border1 = 0.5*(dimension-active);
double border2 = (border1+strips*pitch); //(active)/scale+border1;
unsigned int sborder1=border1/scale;
unsigned int sborder2=border2/scale;
for(unsigned int px = 0 ; px < size ; px++){
for(unsigned int py = 0 ; py < size ; py++){
......@@ -38,21 +38,24 @@ void Mask(){
// Compute array index
index = px * size + py;
// Inactive sides
if(px < border1|| py < border1 || px>border2 || py>border2)
if(px < sborder1|| py < sborder1 || px > sborder2 || py > sborder2)
argb[index] = 0xffff0000;
else{ // strips
unsigned int coord = px-border1;
unsigned int nbr = coord/spitch;
// cout << coord << " " << nbr*spitch+sinter << " " << spitch << " " << sinter << " " << spitch << " " << sinter << endl;
if(coord<(nbr*spitch+sinter) || coord >(((nbr+1)*spitch-sinter))){// interstrip
argb[index] = 0xffff0000+(((nbr+1))<<8)+nbr;
}
if(coord<(nbr*spitch+sinter))
// interstrip
argb[index] = 0xffff0000+(((nbr-1))<<8)+nbr-2;
else if (nbr-1 < strips+1)
argb[index] = 0xff000000 + nbr-1;
else
argb[index] = 0xff000000 + nbr;
argb[index] = 0xffff0000;
}
}
}
mask->WriteImage("mask.png");
delete[] zargb;
//mask->Draw();
}
NPLib/Detectors/MUST2/ressources/maskBack.png

318 KiB | W: | H:

NPLib/Detectors/MUST2/ressources/maskBack.png

539 KiB | W: | H:

NPLib/Detectors/MUST2/ressources/maskBack.png
NPLib/Detectors/MUST2/ressources/maskBack.png
NPLib/Detectors/MUST2/ressources/maskBack.png
NPLib/Detectors/MUST2/ressources/maskBack.png
  • 2-up
  • Swipe
  • Onion skin
NPLib/Detectors/MUST2/ressources/maskFront.png

313 KiB | W: | H:

NPLib/Detectors/MUST2/ressources/maskFront.png

527 KiB | W: | H:

NPLib/Detectors/MUST2/ressources/maskFront.png
NPLib/Detectors/MUST2/ressources/maskFront.png
NPLib/Detectors/MUST2/ressources/maskFront.png
NPLib/Detectors/MUST2/ressources/maskFront.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -834,8 +834,8 @@ void MUST2Array::ReadSensitive(const G4Event*) {
unsigned int a, r, g, b;
// pixel
SiScorer->GetARGBFront(i, a, r, g, b);
b = b + 2;
g = g + 2;
b = b ;
g = g ;
if (r == 0) {
mapFront[b+detectorNbr*1e6].first+=energy;
mapFront[b+detectorNbr*1e6].second=time;
......@@ -887,8 +887,8 @@ void MUST2Array::ReadSensitive(const G4Event*) {
unsigned int a, r, g, b;
// pixel
SiScorer->GetARGBBack(i, a, r, g, b);
b = b + 2;
g = g + 2;
b = b ;
g = g ;
if (r == 0) {
mapBack[b+detectorNbr*1e6].first+=energy;
mapBack[b+detectorNbr*1e6].second=time;
......@@ -975,7 +975,7 @@ void MUST2Array::InitializeScorers() {
string nptool = getenv("NPTOOL");
G4VPrimitiveScorer* SiScorer = new DSSDScorers::PS_Images(
"SiScorer", nptool + "/NPLib/Detectors/MUST2/ressources/maskFront.png",
nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 0.01, 0.01, 0,
nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 97.22/12800, 97.22/12800, 0,
0, 0xffff0000, 0);
G4VPrimitiveScorer* InterScorer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment