File indexing completed on 2025-08-05 08:14:40
0001
0002 #include <usmData.h>
0003
0004
0005 TH2 * tcs = new TH2F("tcs","Clear side", 11, 0.5, 11.5, 9, 2., 20.);
0006 TH2 * tfs = new TH2F("tfs","Fiber side", 11, 0.5, 11.5, 9, 2., 20.);
0007 TH2 * fcr = new TH2F("fcr","Ratio Fiber-to-Clear", 11, 0.5, 11.5, 9, 2., 20.);
0008 TH1 * AtoB = new TH1F("AtoB","Reproducibility of measurements", 20, -0.5, 0.5);
0009 TH1 * AtoB1cs = new TH1F("AtoB1cs","Ratio of Before-After mesurements in the last(away from SiPM) row (Clear)", 20, 0.5, 1.5);
0010 TH1 * AtoB2cs = new TH1F("AtoB2cs","Ratio of Before-After mesurements in the first(close to SiPM) row (Clear)", 20, 0.5, 1.5);
0011 TH1 * AtoBtcs = new TH1F("AtoBtcs","Ratio of Before-After mesurements in the first&last rows (Clear)", 20, 0.5, 1.5);
0012 TH1 * AtoB1fs = new TH1F("AtoB1fs","Ratio of Before-After mesurements in the last(away from SiPM) row) (Fiber)", 20, 0.5, 1.5);
0013 TH1 * AtoB2fs = new TH1F("AtoB2fs","Ratio of Before-After mesurements in the first(close to SiPM) row (Fiber)", 20, 0.5, 1.5);
0014 TH1 * AtoBtfs = new TH1F("AtoBtfs","Ratio of Before-After mesurements in the first&last rows (Fiber)", 20, 0.5, 1.5);
0015
0016
0017 TH2 * tcsn = new TH2F("tcsn","Normalized A: LED on Clear side", 11, 0.5, 11.5, 9, 2., 20.);
0018
0019 TH2 * tfsn = new TH2F("tfsn","Normalized A: LED on Fiber side", 11, 0.5, 11.5, 9, 2., 20.);
0020
0021 TH2 * fcrn = new TH2F("fcrn","Ratio Fiber-to-Clear (both normalized)", 11, 0.5, 11.5, 9, 2., 20.);
0022
0023
0024 TH1 * cs_all = new TH1F("cs_all","Normalized A: LED on Clear side", 40, 0., 3.);
0025 TH1 * cs_off = new TH1F("cs_off","Off-fiber A: clear(black) & fiber(red) sides", 40, 0., 3.);
0026 TH1 * cs_onf = new TH1F("cs_onf","Norm. amp. on fiber, clear side", 40, 0., 3.);
0027 TH1 * fs_off = new TH1F("fs_off","Norm. amp. off fiber, fiber side", 40, 0., 3.);
0028 TH1 * fs_onf = new TH1F("fs_onf","Norm. amp. on fiber, fiber side", 40, 0., 3.);
0029 TH1 * rfc_off = new TH1F("rfc_off","Norm. amp. Ratio: off fiber", 40, 0., 3.);
0030 TH1 * rfc_onf = new TH1F("rfc_onf","Norm. amp. Ratio: on fiber", 40, 0., 3.);
0031
0032
0033 TProfile * tavsdnfcs = new TProfile("tavsdnfcs","Amp vs Dist from exit - no fiber - clear side", 20,0.,20.,0.,2000.,"");
0034 TProfile * tavsdfcs = new TProfile("tavsdfcs", "Amp vs Dist from exit - fiber - clear side", 20,0.,20.,0.,2000.,"");
0035 TProfile * tavsdnffs = new TProfile("tavsdnffs","Amp vs Dist from exit - no fiber - fiber side", 20,0.,20.,0.,2000.,"");
0036 TProfile * tavsdffs = new TProfile("tavsdffs", "Amp vs Dist from exit - fiber - fiber side", 20,0.,20.,0.,2000.,"");
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 Double_t fiber[11][9];
0054 Int_t tileId;
0055 TString token; TString Item;
0056 TString Tokens[24][20];
0057 Double_t value[24][20];
0058 Double_t tData[2][11][9];
0059 Double_t cData[2][11][2];
0060 Double_t xValue[2][11], yValue[9];
0061 Double_t csNorm(0.), fsNorm(0.);
0062 Int_t X, Y, loc, line, pos;
0063
0064
0065 Double_t tPath(Int_t x, Int_t y){
0066
0067 Double_t dx = abs(x-exitX); Double_t dy = abs(y-exitY);
0068 return sqrt(dx*dx+dy*dy);
0069 }
0070
0071 void init(){
0072 for(Y = 0; Y<9; Y++) {for (X = 0; X<11; X++) fiber[X][Y] = 0.;}
0073 for(Y = 0; Y<20; Y++) {for (X = 0; X<24; X++) value[X][Y] = 0.;}
0074 for(int side =0; side<2; side++) {
0075 for(Y = 0; Y<9; Y++) {for (X = 0; X<11; X++) tData[side][X][Y] = 0.;}
0076 for(Y = 0; Y<2; Y++) {for (X = 0; X<11; X++) cData[side][X][Y] = 0.;}
0077 for(X = 0; X<11; X++) xValue[side][X] = 0.;
0078 }
0079 for (Y = 0; Y<9; Y++) yValue[Y] = 0.;
0080 }
0081
0082
0083
0084 void tile(TString tDcsv){
0085 init();
0086
0087
0088 Int_t from = 0; Int_t nTok = 0; Int_t nCom = 0; Int_t lCom = 0; Int_t lItem = 0;
0089 while ((lCom=tDcsv.Index(",",lItem))>=0||(nCom==0)) {
0090 Int_t cr = tDcsv.Index("\n",lItem);
0091 if(cr>=0&&cr<lCom) lCom = cr;
0092 Item = tDcsv(lItem, lCom-lItem);
0093
0094
0095
0096 line = nCom/20;
0097 pos = nCom%20;
0098 Tokens[line][pos] = Item;
0099
0100 if(Tokens[line][pos].IsFloat()) value[line][pos] = Tokens[line][pos].Atof();
0101
0102 if(cr==lCom) {
0103
0104 nCom = ((nCom/20)+1)*20;
0105 } else nCom++;
0106 lItem = lCom+1;
0107 }
0108 tileId = Tokens[0][0].Atoi();
0109 cout<<"tileID = "<<tileId<<endl;
0110 if(tileId>1) for(loc=0; loc<99; loc++) dam[loc] = 0;
0111
0112 int nEntCs(0), nEntFs(0);
0113 for(Y = 0; Y < 9; Y++) {
0114 pos = Y + 3;
0115 yValue[Y] = value[12][pos];
0116 for (X = 0; X < 11; X++) {
0117
0118 line = 11-X;
0119 loc = Y*11 + X;
0120 tData[0][X][Y] = value[line][pos];
0121 if(Y==0) {
0122 xValue[0][X] = value[line][2];
0123
0124 cData[0][X][0] = value[line][1];
0125 cData[0][X][1] = value[line][12];
0126
0127 if(!fib[loc]&&tData[0][X][0]>0.) {nEntCs++; csNorm += tData[0][X][0];}
0128 }
0129
0130 line = 12+X+1;
0131 loc = Y*11 + X;
0132 tData[1][X][Y] = value[line][pos];
0133 if(Y==0) {
0134 xValue[1][X] = value[line][2];
0135 cData[1][X][0] = value[line][1];
0136 cData[1][X][1] = value[line][12];
0137 if(!fib[loc]&&tData[1][X][0]>0.) {nEntFs++; fsNorm += tData[1][X][0];}
0138 }
0139 }
0140 }
0141 cout<<"Norm cs "<<nEntCs<<"/"<<csNorm<<" Norm fs "<<nEntFs<<"/"<<fsNorm<<endl;
0142 if(nEntCs) csNorm /= Double_t(nEntCs);
0143 csNorm *= tScale[tileId-1];
0144 if(nEntFs) fsNorm /= Double_t(nEntFs);
0145 fsNorm *= tScale[tileId-1];
0146 cout<<"Norm cs "<<nEntCs<<"/"<<csNorm<<" Norm fs "<<nEntFs<<"/"<<fsNorm<<endl;
0147
0148
0149 Double_t xExit = value[3][2];
0150 Double_t yExit = value[12][11];
0151 Double_t dx, dy, d;
0152
0153 for(Y = 0; Y < 9; Y++) {
0154
0155 pos = Y + 3;
0156
0157 for (X = 0; X < 11; X++) {
0158 line = 11-X;
0159 loc = Y*11 + X;
0160 dx = xValue[0][X] - xExit; dy = yValue[Y]- yExit;
0161 Double_t d = sqrt(dx*dx+dy*dy);
0162
0163
0164 if(!dam[loc]) tcs -> Fill(xValue[0][X], yValue[Y], tData[0][X][Y]);
0165 if(!dam[loc]&&csNorm>0.) tcsn -> Fill(xValue[0][X], yValue[Y], tData[0][X][Y]/csNorm);
0166 if(!dam[loc]&&!fib[loc]) tavsdnfcs -> Fill(d, tData[0][X][Y]);
0167 if(!dam[loc]&&fib[loc]) tavsdfcs -> Fill(d, tData[0][X][Y]);
0168 }
0169
0170 for (X = 0; X<11; X++) {
0171 line = 12+X+1;
0172 loc = Y*11 + X;
0173 dx = xValue[1][X] - xExit; dy = yValue[Y]- yExit;
0174 Double_t d = sqrt(dx*dx+dy*dy);
0175
0176 if() tfs -> Fill(xValue[1][X],yValue[Y], tData[1][X][Y]);
0177 if(fsNorm>0.) tfsn -> Fill(xValue[1][X],yValue[Y], tData[1][X][Y]/fsNorm);
0178 if(!dam[loc]&&!fib[loc]) tavsdnffs -> Fill(d, tData[1][X][Y]);
0179 if(!dam[loc]&&fib[loc]) tavsdffs -> Fill(d, tData[1][X][Y]);
0180 }
0181
0182 for (X = 0; X<11; X++) {
0183
0184 loc = Y*11 + X;
0185 if(tData[0][X][Y]>0.&&tData[1][X][Y]>0.) {
0186 Double_t fcrat = tData[1][X][Y]/tData[0][X][Y];
0187 if(!dam[loc]) fcr -> Fill(xValue[1][X],yValue[Y], fcrat);
0188 if(!dam[loc]&&csNorm>0.&&fsNorm>0.) fcrn -> Fill(xValue[1][X],yValue[Y], fcrat/(fsNorm/csNorm));
0189 }
0190 Double_t repr(0);
0191 if(Y==0) {
0192
0193 if(cData[0][X][0]>0.&&tData[0][X][0]>0.) {
0194 repr = 2.*(tData[0][X][0]-cData[0][X][0])/(tData[0][X][0]+cData[0][X][0]);
0195 AtoB -> Fill(repr);
0196 AtoB1cs -> Fill(tData[0][X][0]/cData[0][X][0]);
0197 AtoBtcs -> Fill(tData[0][X][0]/cData[0][X][0]);
0198 }
0199 if(cData[0][X][1]>0.&&tData[0][X][8]>0.) {
0200 repr = 2.*(tData[0][X][8]-cData[0][X][1])/(tData[0][X][8]+cData[0][X][1]);
0201 AtoB -> Fill(repr);
0202 AtoB2cs -> Fill(tData[0][X][8]/cData[0][X][1]);
0203 AtoBtcs -> Fill(tData[0][X][8]/cData[0][X][1]);
0204 }
0205 if(cData[1][X][0]>0.&&tData[1][X][0]>0.) {
0206 repr = 2.*(tData[1][X][0]-cData[1][X][0])/(tData[1][X][0]+cData[1][X][0]);
0207 AtoB -> Fill(repr);
0208 AtoB1fs -> Fill(tData[1][X][0]/cData[1][X][0]);
0209 AtoBtfs -> Fill(tData[1][X][0]/cData[1][X][0]);
0210 }
0211 if(cData[1][X][1]>0.&&tData[1][X][8]>0.) {
0212 repr = 2.*(tData[1][X][8]-cData[1][X][1])/(tData[1][X][8]+cData[1][X][1]);
0213 AtoB -> Fill(repr);
0214 AtoB -> Fill(tData[1][X][8]/cData[1][X][1]);
0215 AtoB2fs -> Fill(tData[1][X][8]/cData[1][X][1]);
0216 AtoBtfs -> Fill(tData[1][X][8]/cData[1][X][1]);
0217 }
0218 }
0219 }
0220 }
0221 for (X = 0; X < 11; X++) {
0222 for (Y = 0; Y < 9; Y++) {
0223 loc = Y*11 + X;
0224 Double_t vacsn = tcsn -> GetBinContent(X, Y);
0225 Double_t vafsn = tfsn -> GetBinContent(X, Y);
0226 Double_t vfcrn = fcrn -> GetBinContent(X, Y);
0227 if(vacsn>0.) cs_all ->Fill(vacsn);
0228 if(fib[loc]) {
0229 if(vacsn>0.) cs_onf ->Fill(vacsn);
0230 if(vafsn>0.) fs_onf ->Fill(vafsn);
0231 if(vfcrn>0.) rfc_onf->Fill(vfcrn);
0232 } else {
0233 if(vacsn>0.) cs_off ->Fill(vacsn);
0234 if(vafsn>0.) fs_off ->Fill(vafsn);
0235 if(vfcrn>0.) rfc_off->Fill(vfcrn);
0236 }
0237
0238 }
0239 }
0240
0241 }
0242
0243 TCanvas *tMap(NULL), * tDQ(NULL);
0244 void plot(){
0245
0246 if((tMap = (TCanvas *)(gROOT->FindObject("tMAP")))) delete tMap;
0247 tMap = new TCanvas("tMap","Tile Response Map",200, 10, 600, 500);
0248
0249 tMap -> Divide(2,2,0.05,0.05,0);
0250 tMap -> cd(1);
0251 gStyle ->SetOptStat(0);
0252 tcsn -> Draw("lego2");
0253 tMap -> cd(2);
0254 tfsn -> Draw("colz");
0255
0256
0257 tMap -> cd(3);
0258
0259 gStyle ->SetOptStat(111);
0260 cs_all -> SetMaximum(20);
0261 cs_all -> SetLineColor(1);
0262 cs_all -> SetLineWidth(2);
0263 cs_all -> Draw();
0264
0265 tMap -> cd(4);
0266 gStyle ->SetOptStat(0);
0267 cs_off -> SetMaximum(20);
0268 cs_off -> SetLineColor(1);
0269 cs_off -> SetLineWidth(2);
0270 cs_off -> Draw();
0271 fs_off -> SetLineColor(2);
0272 fs_off -> SetLineWidth(2);
0273 fs_off -> Draw("same");
0274
0275
0276
0277
0278
0279 if((tDQ = (TCanvas *)(gROOT->FindObject("tDQ")))) delete tDQ;
0280 if(!tDQ) tDQ = new TCanvas("tDQ","Tile Data Quality", 160, 10, 400, 300);
0281 gStyle -> SetOptStat(0);
0282 AtoB -> SetLineWidth(2);
0283 AtoB -> Draw();
0284
0285
0286 }
0287 ;