00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014 #include <iostream>
00015
00016 #include "TClonesArray.h"
00017
00018 #include "Calibrator/Calibrator.h"
00019 #include "Plex/PlexSEIdAltL.h"
00020 #include "Plex/PlexStripEndId.h"
00021 #include "Plex/PlexHandle.h"
00022 #include "Plex/PlexPixelSpotId.h"
00023 #include "RawData/RawChannelId.h"
00024 #include "Conventions/CalDigitType.h"
00025 #include "MessageService/MsgService.h"
00026 #include "Validity/VldContext.h"
00027
00028 #include "CalDetTracker/CDCrossTalker.h"
00029 #include "CalDetTracker/CDXTalkHitInfo.h"
00030
00031 using std::cout;
00032 using std::endl;
00033 using std::map;
00034
00035 CVSID("$Id: CDCrossTalker.cxx,v 1.13 2005/08/28 01:41:37 rhatcher Exp $");
00036
00037
00038
00039 CDCrossTalker::CDCrossTalker(std::map<Int_t,CandStripHandle> stripmap,
00040 Float_t opt,Int_t cosmic)
00041 {
00042 this->SetMap(stripmap);
00043 this->SetOption(opt);
00044 fnum_xtalk_hits = -1;
00045 fcosmic = cosmic;
00046 }
00047
00048
00049
00050 Int_t CDCrossTalker::SetMap(std::map<Int_t,CandStripHandle> stripMap)
00051 {
00052 fAllStrips=stripMap;
00053 return 1;
00054 }
00055
00056
00057
00058 Int_t CDCrossTalker::SetOption(Float_t opt)
00059 {
00060 fopt = opt;
00061 return 1;
00062 }
00063
00064
00065
00066 std::map<int,CandStripHandle> CDCrossTalker::GetCleanStripMap()
00067 {
00068 if(fnum_xtalk_hits!=-1) return fCleanedStrips;
00069
00070 if(fAllStrips.empty()){
00071 MSG("CDCrossTalker",Msg::kWarning)
00072 <<"CDCrossTalker: No StripMap Set"<<endl;
00073 return fCleanedStrips;
00074 }
00075
00076 if(fopt==-1) {
00077 MSG("CDCrossTalker",Msg::kWarning)
00078 << "CDCrossTalker: No Options Set" << endl;
00079 return fCleanedStrips;
00080 }
00081
00082 fnum_xtalk_hits = 0;
00083
00084 float event[60][48];
00085 float crosstalkhits[60][48];
00086 int crosstalkhitssourceplane[60][48];
00087 int crosstalkhitssourcestrip[60][48];
00088 int crosstalkhitssourcepixelone[60][48];
00089 int crosstalkhitssourcepixeltwo[60][48];
00090 int crosstalkhitssourcepixel[60][48];
00091 int crosstalkhitspixel[60][48];
00092 int crosstalkhitssourcespot[60][48];
00093 int crosstalknumxhits[60][48];
00094 int otubematrix[60][48];
00095 int opixelmatrix[60][48];
00096
00097 int ospotmatrix[60][48];
00098 double otimematrix[60][48];
00099
00100
00101 for (int ij=0;ij<60;ij++){
00102 for (int jk=0;jk<48;jk++){
00103
00104 event[ij][jk]=0;
00105 crosstalkhits[ij][jk]=0;
00106 crosstalkhitssourceplane[ij][jk]=-1;
00107 crosstalkhitssourcestrip[ij][jk]=-1;
00108 crosstalkhitssourcepixelone[ij][jk]=-1;
00109 crosstalkhitssourcepixeltwo[ij][jk]=-1;
00110 crosstalkhitssourcepixel[ij][jk]=-1;
00111 crosstalkhitspixel[ij][jk]=-1;
00112 crosstalkhitssourcespot[ij][jk]=-1;
00113 crosstalknumxhits[ij][jk]=-1;
00114 otubematrix[ij][jk]=0;
00115 opixelmatrix[ij][jk]=-10;
00116 ospotmatrix[ij][jk]=0;
00117 otimematrix[ij][jk]=0;
00118 }
00119 }
00120
00121 map<int,CandStripHandle>::iterator stripIter = fAllStrips.begin();
00122 map<int,CandStripHandle>::iterator stripEnd = fAllStrips.end();
00123
00124
00125 Calibrator& calibrator=Calibrator::Instance();
00126
00127 const VldContext *vc = stripIter->second.GetVldContext();
00128 if(stripIter!=stripEnd) calibrator.Reset(*vc);
00129 PlexHandle plexHand(*vc);
00130
00131 while(stripIter!=stripEnd){
00132
00133 bool IsQIE[2] = {false,false};
00134 TIter cdhIter(stripIter->second.GetDaughterIterator());
00135 while(CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhIter())){
00136 if(cdh->GetPlexSEIdAltL().GetBestSEId().GetEnd()==StripEnd::kNegative
00137 &&cdh->GetChannelId().GetElecType()==ElecType::kQIE) IsQIE[0]=true;
00138 if(cdh->GetPlexSEIdAltL().GetBestSEId().GetEnd()==StripEnd::kPositive
00139 &&cdh->GetChannelId().GetElecType()==ElecType::kQIE) IsQIE[1]=true;
00140 }
00141
00142 if(IsQIE[0]) MSG("CDCrossTalker",Msg::kDebug) <<"QIE digit end 1" << endl;
00143 if(IsQIE[1]) MSG("CDCrossTalker",Msg::kDebug) <<"QIE digit end 2" << endl;
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 PlexPixelSpotId spotIdNeg = plexHand.GetPixelSpotId(stripIter->second.GetStripEndId(StripEnd::kNegative));
00160 PlexPixelSpotId spotIdPos = plexHand.GetPixelSpotId(stripIter->second.GetStripEndId(StripEnd::kPositive));
00161
00162 int plane = stripIter->second.GetPlane();
00163 int strip = stripIter->second.GetStrip();
00164
00165 if(plane<=59){
00166
00167 if(stripIter->second.GetNDigit(StripEnd::kNegative)>0&&!IsQIE[0]){
00168
00169 int end = StripEnd::kNegative;
00170 float pe = stripIter->second.GetCharge(CalDigitType::kPE,
00171 StripEnd::kNegative);
00172 int tube = spotIdNeg.GetTube();
00173 int pixel = spotIdNeg.GetPixel();
00174 int spot = spotIdNeg.GetSpot();
00175 double time = stripIter->second.GetTime(StripEnd::kNegative);
00176
00177 event[plane][(end-1)*24 + strip] = pe;
00178 otubematrix[plane][(end-1)*24 + strip] = tube;
00179 opixelmatrix[plane][(end-1)*24 + strip] = pixel;
00180 ospotmatrix[plane][(end-1)*24 + strip] = spot;
00181 otimematrix[plane][(end-1)*24 + strip] = time;
00182 }
00183
00184 if(stripIter->second.GetNDigit(StripEnd::kPositive)>0&&!IsQIE[1]){
00185 int end = StripEnd::kPositive;
00186 float pe = stripIter->second.GetCharge(CalDigitType::kPE,
00187 StripEnd::kPositive);
00188 int tube = spotIdPos.GetTube();
00189 int pixel = spotIdPos.GetPixel();
00190 int spot = spotIdPos.GetSpot();
00191 double time = stripIter->second.GetTime(StripEnd::kPositive);
00192
00193 event[plane][(end-1)*24 + strip] = pe;
00194 otubematrix[plane][(end-1)*24 + strip] = tube;
00195 opixelmatrix[plane][(end-1)*24 + strip] = pixel;
00196 ospotmatrix[plane][(end-1)*24 + strip] = spot;
00197 otimematrix[plane][(end-1)*24 + strip] = time;
00198 }
00199 }
00200
00201 stripIter++;
00202
00203 }
00204
00205 int backplaneflag[200];
00206 int largestbutwrongpixelflag[200];
00207 int refpixel[200];
00208
00209 int pottube[200];
00210 int potpixelone[200];
00211 int potpixeltwo[200];
00212 int potspotone[200];
00213 int potspottwo[200];
00214 int hitnum=0;
00215 int sider[200];
00216 int planeseq[200];
00217 int hitplane[200];
00218 int hitstrip[200];
00219 double timersq[200];
00220
00221 float sumadconeplone;
00222 float sumadconepltwo;
00223 int sourcelocplaneonesidetwo;
00224 int sourcelocplaneonesideone;
00225 int sourcelocstriponesideone;
00226 int sourcelocstriponesidetwo;
00227 float sourceone[200];
00228
00229 float sourceadconeplone;
00230 float sourceadconepltwo;
00231 float sourceadctwoplone;
00232 float sourceadctwopltwo;
00233 float sumadctwoplone;
00234 float sumadctwopltwo;
00235
00236 float sourcetwo[200];
00237 int sourcelocplanetwosidetwo;
00238 int sourcelocplanetwosideone;
00239 int sourcelocstriptwosideone;
00240 int sourcelocstriptwosidetwo;
00241 int sourcespotonepltwo;
00242 int sourcespotoneplone;
00243 int sourcespottwopltwo;
00244 int sourcespottwoplone;
00245 float surroundsumone;
00246 float surroundsumtwo;
00247 int topplaneone;
00248 int topstripone;
00249 float topeventone;
00250 int topplanetwo;
00251 int topstriptwo;
00252 float topeventtwo;
00253
00254
00255
00256 int buggered;
00257
00258 for(int k=2;k<4;k++) {
00259 for(int i=k;i<60;i=i+4) {
00260
00261
00262
00263 hitnum=0;
00264
00265
00266
00267 for (int resetter=0;resetter<200;resetter++){
00268 backplaneflag[resetter]=-1;
00269 largestbutwrongpixelflag[resetter]=-1;
00270 refpixel[resetter]=-1;
00271 potpixelone[resetter]=-1;
00272 potpixeltwo[resetter]=-1;
00273 potspotone[resetter]=-1;
00274 potspottwo[resetter]=-1;
00275 pottube[resetter]=-1;
00276 sider[resetter]=-1;
00277 planeseq[resetter]=-1;
00278 sourceadconeplone=-1;
00279 sourceadconepltwo=-1;
00280 sourceone[resetter]=-1;
00281 sourceadctwopltwo=-1;
00282 sourceadctwoplone=-1;
00283 sourcetwo[resetter]=-1;
00284
00285
00286 sumadconepltwo=0;
00287 sumadconeplone=0;
00288 sumadctwoplone=0;
00289 sumadctwopltwo=0;
00290 sourcelocplaneonesideone=-1;
00291 sourcelocplaneonesidetwo=-1;
00292 sourcelocstriponesideone=-1;
00293 sourcelocstriponesidetwo=-1;
00294 sourcelocplanetwosidetwo=-1;
00295 sourcelocplanetwosideone=-1;
00296 sourcelocstriptwosidetwo=-1;
00297 sourcelocstriptwosideone=-1;
00298 sourcespotoneplone=-1;
00299 sourcespotonepltwo=-1;
00300 sourcespottwoplone=-1;
00301 sourcespottwopltwo=-1;
00302 timersq[resetter]=-1;
00303 buggered=-1;
00304 surroundsumone=0;
00305 surroundsumtwo=0;
00306 topplaneone=-1;
00307 topstripone=-1;
00308 topplanetwo=-1;
00309 topstriptwo=-1;
00310 topeventone=0;
00311 topeventtwo=0;
00312 }
00313
00314 for (int dbleplaner=0;dbleplaner<4;dbleplaner=dbleplaner+2) {
00315
00316 for(int j=0;j<48;j++) {
00317
00318
00319
00320 if (event[i-dbleplaner][j]!=0) {
00321
00322 pottube[hitnum]=otubematrix[i-dbleplaner][j];
00323
00324
00325 hitstrip[hitnum]=j;
00326 hitplane[hitnum]=(i-dbleplaner);
00327 timersq[hitnum]=otimematrix[i-dbleplaner][j];
00328
00329
00330 if (j<24) {
00331 sider[hitnum]=1;
00332 potspotone[hitnum]=ospotmatrix[i-dbleplaner][j];
00333 potpixelone[hitnum]=opixelmatrix[i-dbleplaner][j];
00334 }
00335
00336 else {
00337 sider[hitnum]=2;
00338 potspottwo[hitnum]=ospotmatrix[i-dbleplaner][j];
00339 potpixeltwo[hitnum]=opixelmatrix[i-dbleplaner][j];
00340 }
00341
00342
00343
00344
00345 MSG("CDCrossTalker",Msg::kDebug)
00346 << "Pl: " <<hitplane[hitnum]
00347 << " Str: " << hitstrip[hitnum]
00348 << " Tu: " << pottube[hitnum]
00349 << " P1: " << potpixelone[hitnum]
00350 <<" P2: " << potpixeltwo[hitnum]
00351 << " ADC: " << event[i-dbleplaner][j]
00352 << " S1: " << potspotone[hitnum]
00353 << " S2: " << potspottwo[hitnum] << endl;
00354
00355 hitnum++;
00356 }
00357 }
00358 }
00359
00360 if (hitnum>=14 ) {
00361 buggered=1;
00362 hitnum=0;
00363 }
00364
00365 if(hitnum>1 && buggered!=1) {
00366
00367
00368
00369
00370
00371
00372
00373 for (int f=0;f<hitnum;f++) {
00374
00375 int matrixseqplane=hitplane[f];
00376 int matrixseqstrip=hitstrip[f];
00377 int hitser=0;
00378
00379
00380 for (int d=0;d<hitnum;d++) {
00381
00382 int matrixseqcheckeeplane=hitplane[d];
00383 int matrixseqcheckeestrip=hitstrip[d];
00384
00385
00386
00387 if ((pottube[f] == pottube[d])&&
00388 (f!=d)&&(sider[f]==sider[d])&&
00389 (pottube[f]!=-1)&&(pottube[d]!=-1)&&
00390 (potpixelone[d]!=0) && (potpixeltwo[d]!=0) ) {
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 if(((potpixelone[f]==((potpixelone[d])-4)) &&
00405 ((potpixelone[d])-4)>0)){
00406 if(sider[f]==1) {
00407 surroundsumone=surroundsumone+
00408 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00409 hitser++;
00410
00411 if (event[matrixseqcheckeeplane]
00412 [matrixseqcheckeestrip]>topeventone) {
00413 topeventone=event[matrixseqcheckeeplane]
00414 [matrixseqcheckeestrip];
00415 topplaneone=matrixseqcheckeeplane;
00416 topstripone=matrixseqcheckeestrip;
00417 crosstalkhitssourcepixelone[matrixseqplane]
00418 [matrixseqstrip] = potpixelone[d];
00419 crosstalkhitssourcespot[matrixseqplane]
00420 [matrixseqstrip] = potspotone[d];
00421 }
00422 }
00423 }
00424
00425 if(((potpixeltwo[f]==((potpixeltwo[d])-4)) &&
00426 ((potpixeltwo[d])-4)>0)){
00427 if(sider[f]==2) {
00428 surroundsumtwo=surroundsumtwo+
00429 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00430 hitser++;
00431 if (event[matrixseqcheckeeplane]
00432 [matrixseqcheckeestrip]>topeventtwo) {
00433 topeventtwo=event[matrixseqcheckeeplane]
00434 [matrixseqcheckeestrip];
00435 topplanetwo=matrixseqcheckeeplane;
00436 topstriptwo=matrixseqcheckeestrip;
00437 crosstalkhitssourcepixeltwo[matrixseqplane]
00438 [matrixseqstrip] = potpixeltwo[d];
00439 crosstalkhitssourcespot[matrixseqplane]
00440 [matrixseqstrip] = potspottwo[d];
00441 }
00442 }
00443 }
00444
00445
00446
00447 if((potpixelone[f]==((potpixelone[d])+4)) &&
00448 ((potpixelone[d])+4)<17){
00449 if(sider[f]==1) {
00450 surroundsumone=surroundsumone+
00451 event[matrixseqcheckeeplane]
00452 [matrixseqcheckeestrip];
00453 hitser++;
00454
00455 if (event[matrixseqcheckeeplane]
00456 [matrixseqcheckeestrip]>topeventone) {
00457 topeventone=event[matrixseqcheckeeplane]
00458 [matrixseqcheckeestrip];
00459 topplaneone=matrixseqcheckeeplane;
00460 topstripone=matrixseqcheckeestrip;
00461 crosstalkhitssourcepixelone[matrixseqplane]
00462 [matrixseqstrip] = potpixelone[d];
00463 crosstalkhitssourcespot[matrixseqplane]
00464 [matrixseqstrip] = potspotone[d];
00465 }
00466 }
00467 }
00468 if((potpixeltwo[f]==((potpixeltwo[d])+4)) &&
00469 ((potpixeltwo[d])+4)<17){
00470 if(sider[f]==2) {
00471 surroundsumtwo=surroundsumtwo+
00472 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00473 hitser++;
00474 if (event[matrixseqcheckeeplane]
00475 [matrixseqcheckeestrip]>topeventtwo) {
00476 topeventtwo=event[matrixseqcheckeeplane]
00477 [matrixseqcheckeestrip];
00478 topplanetwo=matrixseqcheckeeplane;
00479 topstriptwo=matrixseqcheckeestrip;
00480 crosstalkhitssourcepixeltwo[matrixseqplane]
00481 [matrixseqstrip] = potpixeltwo[d];
00482 crosstalkhitssourcespot[matrixseqplane]
00483 [matrixseqstrip] = potspottwo[d];
00484 }
00485 }
00486 }
00487
00488
00489
00490
00491 if((potpixelone[f]==((potpixelone[d])+1)) &&
00492 (((potpixelone[d])+1)<17) &&
00493 (((potpixelone[d])+1)!=5) &&
00494 (((potpixelone[d])+1)!=9) &&
00495 (((potpixelone[d])+1)!=13)){
00496 if(sider[f]==1) {
00497 surroundsumone=surroundsumone+
00498 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00499 hitser++;
00500 if (event[matrixseqcheckeeplane]
00501 [matrixseqcheckeestrip]>topeventone) {
00502 topeventone=event[matrixseqcheckeeplane]
00503 [matrixseqcheckeestrip];
00504 topplaneone=matrixseqcheckeeplane;
00505 topstripone=matrixseqcheckeestrip;
00506 crosstalkhitssourcepixelone[matrixseqplane]
00507 [matrixseqstrip] = potpixelone[d];
00508 crosstalkhitssourcespot[matrixseqplane]
00509 [matrixseqstrip] = potspotone[d];
00510 }
00511 }
00512 }
00513 if((potpixeltwo[f]==((potpixeltwo[d])+1)) &&
00514 (((potpixeltwo[d])+1)<17) &&
00515 (((potpixeltwo[d])+1)!=5) &&
00516 (((potpixeltwo[d])+1)!=9) &&
00517 (((potpixeltwo[d])+1)!=13)){
00518 if(sider[f]==2) {
00519 surroundsumtwo=surroundsumtwo+
00520 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00521 hitser++;
00522 if (event[matrixseqcheckeeplane]
00523 [matrixseqcheckeestrip]>topeventtwo){
00524 topeventtwo=event[matrixseqcheckeeplane]
00525 [matrixseqcheckeestrip];
00526 topplanetwo=matrixseqcheckeeplane;
00527 topstriptwo=matrixseqcheckeestrip;
00528 crosstalkhitssourcepixeltwo[matrixseqplane]
00529 [matrixseqstrip] = potpixeltwo[d];
00530 crosstalkhitssourcespot[matrixseqplane]
00531 [matrixseqstrip] = potspottwo[d];
00532 }
00533 }
00534 }
00535
00536
00537
00538 if((potpixelone[f]==((potpixelone[d])-1)) &&
00539 (((potpixelone[d])-1)>0) &&
00540 (((potpixelone[d])-1)!=4) &&
00541 (((potpixelone[d])-1)!=8) &&
00542 (((potpixelone[d])-1)!=12)){
00543 if(sider[f]==1) {
00544 surroundsumone=surroundsumone+
00545 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00546 hitser++;
00547 if (event[matrixseqcheckeeplane]
00548 [matrixseqcheckeestrip]>topeventone) {
00549 topeventone=event[matrixseqcheckeeplane]
00550 [matrixseqcheckeestrip];
00551 topplaneone=matrixseqcheckeeplane;
00552 topstripone=matrixseqcheckeestrip;
00553 crosstalkhitssourcepixelone[matrixseqplane]
00554 [matrixseqstrip] = potpixelone[d];
00555 crosstalkhitssourcespot[matrixseqplane]
00556 [matrixseqstrip] = potspotone[d];
00557 }
00558 }
00559 }
00560 if((potpixeltwo[f]==((potpixeltwo[d])-1)) &&
00561 (((potpixeltwo[d])-1)>0) &&
00562 (((potpixeltwo[d])-1)!=4) &&
00563 (((potpixeltwo[d])-1)!=8) &&
00564 (((potpixeltwo[d])-1)!=12)){
00565 if(sider[f]==2) {
00566 surroundsumtwo=surroundsumtwo+
00567 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00568 hitser++;
00569 if (event[matrixseqcheckeeplane]
00570 [matrixseqcheckeestrip]>topeventtwo) {
00571 topeventtwo=event[matrixseqcheckeeplane]
00572 [matrixseqcheckeestrip];
00573 topplanetwo=matrixseqcheckeeplane;
00574 topstriptwo=matrixseqcheckeestrip;
00575 crosstalkhitssourcepixeltwo[matrixseqplane]
00576 [matrixseqstrip] = potpixeltwo[d];
00577 crosstalkhitssourcespot[matrixseqplane]
00578 [matrixseqstrip] = potspottwo[d];
00579 }
00580 }
00581 }
00582
00583
00584
00585 if((potpixelone[f]==((potpixelone[d])-5)) &&
00586 (((potpixelone[d])-5)>0) &&
00587 (((potpixelone[d])-5)!=4) &&
00588 (((potpixelone[d])-5)!=8)){
00589 if(sider[f]==1) {
00590 surroundsumone=surroundsumone+
00591 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00592 hitser++;
00593 if (event[matrixseqcheckeeplane]
00594 [matrixseqcheckeestrip]>topeventone) {
00595 topeventone=event[matrixseqcheckeeplane]
00596 [matrixseqcheckeestrip];
00597 topplaneone=matrixseqcheckeeplane;
00598 topstripone=matrixseqcheckeestrip;
00599 crosstalkhitssourcepixelone[matrixseqplane]
00600 [matrixseqstrip] = potpixelone[d];
00601 crosstalkhitssourcespot[matrixseqplane]
00602 [matrixseqstrip] = potspotone[d];
00603 }
00604 }
00605 }
00606 if((potpixeltwo[f]==((potpixeltwo[d])-5)) &&
00607 (((potpixeltwo[d])-5)>0) &&
00608 (((potpixeltwo[d])-5)!=4) &&
00609 (((potpixeltwo[d])-5)!=8)){
00610 if(sider[f]==2) {
00611 surroundsumtwo=surroundsumtwo+
00612 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00613 hitser++;
00614 if (event[matrixseqcheckeeplane]
00615 [matrixseqcheckeestrip]>topeventtwo) {
00616 topeventtwo=event[matrixseqcheckeeplane]
00617 [matrixseqcheckeestrip];
00618 topplanetwo=matrixseqcheckeeplane;
00619 topstriptwo=matrixseqcheckeestrip;
00620 crosstalkhitssourcepixeltwo[matrixseqplane]
00621 [matrixseqstrip] = potpixeltwo[d];
00622 crosstalkhitssourcespot[matrixseqplane]
00623 [matrixseqstrip] = potspottwo[d];
00624 }
00625 }
00626 }
00627
00628
00629
00630 if((potpixelone[f]==((potpixelone[d])+5)) &&
00631 (((potpixelone[d])+5)<17) &&
00632 (((potpixelone[d])+5)!=9) &&
00633 (((potpixelone[d])+5)!=13)){
00634 if(sider[f]==1) {
00635 surroundsumone=surroundsumone+
00636 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00637 hitser++;
00638 if (event[matrixseqcheckeeplane]
00639 [matrixseqcheckeestrip]>topeventone) {
00640 topeventone=event[matrixseqcheckeeplane]
00641 [matrixseqcheckeestrip];
00642 topplaneone=matrixseqcheckeeplane;
00643 topstripone=matrixseqcheckeestrip;
00644 crosstalkhitssourcepixelone[matrixseqplane]
00645 [matrixseqstrip] = potpixelone[d];
00646 crosstalkhitssourcespot[matrixseqplane]
00647 [matrixseqstrip] = potspotone[d];
00648 }
00649 }
00650 }
00651 if((potpixeltwo[f]==((potpixeltwo[d])+5)) &&
00652 (((potpixeltwo[d])+5)<17) &&
00653 (((potpixeltwo[d])+5)!=9) &&
00654 (((potpixeltwo[d])+5)!=13)){
00655 if(sider[f]==2) {
00656 surroundsumtwo=surroundsumtwo+
00657 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00658 hitser++;
00659 if (event[matrixseqcheckeeplane]
00660 [matrixseqcheckeestrip]>topeventtwo) {
00661 topeventtwo=event[matrixseqcheckeeplane]
00662 [matrixseqcheckeestrip];
00663 topplanetwo=matrixseqcheckeeplane;
00664 topstriptwo=matrixseqcheckeestrip;
00665 crosstalkhitssourcepixeltwo[matrixseqplane]
00666 [matrixseqstrip] = potpixeltwo[d];
00667 crosstalkhitssourcespot[matrixseqplane]
00668 [matrixseqstrip] = potspottwo[d];
00669 }
00670 }
00671 }
00672
00673
00674
00675 if((potpixelone[f]==((potpixelone[d])-3)) &&
00676 (((potpixelone[d])-3)>0) &&
00677 (((potpixelone[d])-3)!=1) &&
00678 (((potpixelone[d])-3)!=5) &&
00679 (((potpixelone[d])-3)!=9) &&
00680 (((potpixelone[d])-3)!=13)){
00681 if(sider[f]==1) {
00682 surroundsumone=surroundsumone+
00683 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00684 hitser++;
00685 if (event[matrixseqcheckeeplane]
00686 [matrixseqcheckeestrip]>topeventone) {
00687 topeventone=event[matrixseqcheckeeplane]
00688 [matrixseqcheckeestrip];
00689 topplaneone=matrixseqcheckeeplane;
00690 topstripone=matrixseqcheckeestrip;
00691 crosstalkhitssourcepixelone[matrixseqplane]
00692 [matrixseqstrip] = potpixelone[d];
00693 crosstalkhitssourcespot[matrixseqplane]
00694 [matrixseqstrip] = potspotone[d];
00695 }
00696 }
00697 }
00698 if((potpixeltwo[f]==((potpixeltwo[d])-3)) &&
00699 (((potpixeltwo[d])-3)>0) &&
00700 (((potpixeltwo[d])-3)!=1) &&
00701 (((potpixeltwo[d])-3)!=5) &&
00702 (((potpixeltwo[d])-3)!=9) &&
00703 (((potpixeltwo[d])-3)!=13)){
00704 if(sider[f]==2) {
00705 surroundsumtwo=surroundsumtwo+
00706 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00707 hitser++;
00708 if (event[matrixseqcheckeeplane]
00709 [matrixseqcheckeestrip]>topeventtwo) {
00710 topeventtwo=event[matrixseqcheckeeplane]
00711 [matrixseqcheckeestrip];
00712 topplanetwo=matrixseqcheckeeplane;
00713 topstriptwo=matrixseqcheckeestrip;
00714 crosstalkhitssourcepixeltwo[matrixseqplane]
00715 [matrixseqstrip] = potpixeltwo[d];
00716 crosstalkhitssourcespot[matrixseqplane]
00717 [matrixseqstrip] = potspottwo[d];
00718 }
00719 }
00720 }
00721
00722
00723
00724 if((potpixelone[f]==((potpixelone[d])+3)) &&
00725 (((potpixelone[d])+3)<17) &&
00726 (((potpixelone[d])+3)!=4) &&
00727 (((potpixelone[d])+3)!=8) &&
00728 (((potpixelone[d])+3)!=12) &&
00729 (((potpixelone[d])+3)!=16)){
00730 if(sider[f]==1) {
00731 surroundsumone=surroundsumone+
00732 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00733 hitser++;
00734 if (event[matrixseqcheckeeplane]
00735 [matrixseqcheckeestrip]>topeventone) {
00736 topeventone=event[matrixseqcheckeeplane]
00737 [matrixseqcheckeestrip];
00738 topplaneone=matrixseqcheckeeplane;
00739 topstripone=matrixseqcheckeestrip;
00740 crosstalkhitssourcepixelone[matrixseqplane]
00741 [matrixseqstrip] = potpixelone[d];
00742 crosstalkhitssourcespot[matrixseqplane]
00743 [matrixseqstrip] = potspotone[d];
00744 }
00745 }
00746 }
00747 if((potpixeltwo[f]==((potpixeltwo[d])+3)) &&
00748 (((potpixeltwo[d])+3)<17) &&
00749 (((potpixeltwo[d])+3)!=4) &&
00750 (((potpixeltwo[d])+3)!=8) &&
00751 (((potpixeltwo[d])+3)!=12) &&
00752 (((potpixeltwo[d])+3)!=16)){
00753 if(sider[f]==2) {
00754 surroundsumtwo=surroundsumtwo+
00755 event[matrixseqcheckeeplane][matrixseqcheckeestrip];
00756 hitser++;
00757 if (event[matrixseqcheckeeplane]
00758 [matrixseqcheckeestrip]>topeventtwo) {
00759 topeventtwo=event[matrixseqcheckeeplane]
00760 [matrixseqcheckeestrip];
00761 topplanetwo=matrixseqcheckeeplane;
00762 topstriptwo=matrixseqcheckeestrip;
00763 crosstalkhitssourcepixeltwo[matrixseqplane]
00764 [matrixseqstrip] = potpixeltwo[d];
00765 crosstalkhitssourcespot[matrixseqplane]
00766 [matrixseqstrip] = potspottwo[d];
00767 }
00768 }
00769 }
00770
00771 }
00772
00773
00774 }
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 if (sider[f]==1 &&
00799 event[matrixseqplane][matrixseqstrip]<
00800 fopt*surroundsumone &&
00801 !(matrixseqstrip==topstripone &&
00802 matrixseqplane==topplaneone) &&
00803 crosstalkhitssourcepixelone[matrixseqplane]
00804 [matrixseqstrip]!=0 &&
00805 event[matrixseqplane][(matrixseqstrip-1)]==0 &&
00806 event[matrixseqplane][(matrixseqstrip+1)]==0 &&
00807 event[(matrixseqplane-2)][matrixseqstrip]==0 &&
00808 event[(matrixseqplane+2)][matrixseqstrip]==0 &&
00809 event[(matrixseqplane-2)][(matrixseqstrip-1)]==0 &&
00810 event[(matrixseqplane+2)][(matrixseqstrip-1)]==0 &&
00811 event[(matrixseqplane-2)][(matrixseqstrip+1)]==0 &&
00812 event[(matrixseqplane+2)][(matrixseqstrip+1)]==0 &&
00813 event[(matrixseqplane-2)][(matrixseqstrip-1-fcosmic)]==0&&
00814 event[(matrixseqplane+2)][(matrixseqstrip-1-fcosmic)]==0&&
00815 event[(matrixseqplane-2)][(matrixseqstrip+1+fcosmic)]==0&&
00816 event[(matrixseqplane+2)][(matrixseqstrip+1+fcosmic)]==0){
00817
00818 crosstalkhits[matrixseqplane][matrixseqstrip] =
00819 event[matrixseqplane][matrixseqstrip];
00820 crosstalkhitssourceplane[matrixseqplane][matrixseqstrip] =
00821 topplaneone;
00822 crosstalkhitssourcestrip[matrixseqplane][matrixseqstrip] =
00823 topstripone;
00824 crosstalkhitspixel[matrixseqplane][matrixseqstrip] =
00825 potpixelone[f];
00826 crosstalknumxhits[matrixseqplane][matrixseqstrip] = hitser;
00827 crosstalkhitssourcepixel[matrixseqplane][matrixseqstrip] =
00828 crosstalkhitssourcepixelone[matrixseqplane]
00829 [matrixseqstrip];
00830
00831 MSG("CDCrossTalker",Msg::kDebug)
00832 <<"Crosstalk of "
00833 <<crosstalkhits[matrixseqplane][matrixseqstrip]
00834 << " at " << matrixseqplane
00835 << "," << matrixseqstrip
00836 << " pixel: " << potpixelone[f]
00837 << " from " << topplaneone
00838 << "," << topstripone
00839 << ",pixel: "
00840 << crosstalkhitssourcepixelone[matrixseqplane]
00841 [matrixseqstrip]
00842 << " " << topeventone << endl;
00843 }
00844
00845 if (sider[f]==2 &&
00846 event[matrixseqplane][matrixseqstrip]<
00847 fopt*surroundsumtwo &&
00848 !(matrixseqstrip==topstriptwo &&
00849 matrixseqplane==topplanetwo) &&
00850 crosstalkhitssourcepixeltwo[matrixseqplane]
00851 [matrixseqstrip] &&
00852 event[matrixseqplane][(matrixseqstrip-1)]==0 &&
00853 event[matrixseqplane][(matrixseqstrip+1)]==0 &&
00854 event[(matrixseqplane-2)][matrixseqstrip]==0 &&
00855 event[(matrixseqplane+2)][matrixseqstrip]==0 &&
00856 event[(matrixseqplane-2)][(matrixseqstrip-1)]==0 &&
00857 event[(matrixseqplane+2)][(matrixseqstrip-1)]==0 &&
00858 event[(matrixseqplane-2)][(matrixseqstrip+1)]==0 &&
00859 event[(matrixseqplane+2)][(matrixseqstrip+1)]==0 &&
00860 event[(matrixseqplane-2)][(matrixseqstrip-1-fcosmic)]==0 &&
00861 event[(matrixseqplane+2)][(matrixseqstrip-1-fcosmic)]==0 &&
00862 event[(matrixseqplane-2)][(matrixseqstrip+1+fcosmic)]==0 &&
00863 event[(matrixseqplane+2)][(matrixseqstrip+1+fcosmic)]==0) {
00864
00865
00866
00867
00868 crosstalkhits[matrixseqplane][matrixseqstrip] =
00869 event[matrixseqplane][matrixseqstrip];
00870 crosstalkhitssourceplane[matrixseqplane][matrixseqstrip] =
00871 topplanetwo;
00872 crosstalkhitssourcestrip[matrixseqplane][matrixseqstrip] =
00873 topstriptwo;
00874 crosstalkhitspixel[matrixseqplane][matrixseqstrip] =
00875 potpixeltwo[f];
00876 crosstalknumxhits[matrixseqplane][matrixseqstrip] = hitser;
00877
00878 crosstalkhitssourcepixel[matrixseqplane][matrixseqstrip] =
00879 crosstalkhitssourcepixeltwo[matrixseqplane]
00880 [matrixseqstrip];
00881 MSG("CDCrossTalker",Msg::kDebug)
00882 << "Crosstalk of "
00883 << crosstalkhits[matrixseqplane][matrixseqstrip]
00884 << " at " << matrixseqplane
00885 << "," << matrixseqstrip
00886 << " pixel: " << potpixeltwo[f]
00887 << " from " << topplanetwo
00888 << "," << topstriptwo
00889 << " ,pixel: "
00890 << crosstalkhitssourcepixeltwo[matrixseqplane]
00891 [matrixseqstrip]
00892 << " " << topeventtwo << endl;
00893 }
00894 }
00895 }
00896 }
00897 }
00898
00899 stripIter = fAllStrips.begin();
00900
00901 while(stripIter!=stripEnd){
00902
00903 int plane = stripIter->second.GetPlane();
00904 int strip = stripIter->second.GetStrip();
00905
00906 if(plane<=59){
00907
00908 if(stripIter->second.GetNDigit(StripEnd::kNegative)>0){
00909 int end = StripEnd::kNegative;
00910 int sourceplane=crosstalkhitssourceplane[plane][strip+(end-1)*24];
00911 int sourcestrip=(crosstalkhitssourcestrip[plane]
00912 [(strip+(end-1)*24)])%24;
00913 int sourceend=int(crosstalkhitssourcestrip[plane]
00914 [strip+(end-1)*24]/24.)+1;
00915 int numxhits=crosstalknumxhits[plane][strip+(end-1)*24];
00916
00917 if(crosstalkhits[plane][24*(end-1)+strip]<=0) {
00918 fCleanedStrips[stripIter->first] = stripIter->second;
00919 }
00920 else {
00921 fXTalkStrips[stripIter->first] = stripIter->second;
00922 fNumSurround[stripIter->first] = numxhits;
00923 fnum_xtalk_hits+=1;
00924 MSG("CDCrossTalker",Msg::kDebug)<<fnum_xtalk_hits<<endl;
00925 MSG("CDCrossTalker",Msg::kDebug)
00926 <<crosstalkhits[plane][24*(end-1)+strip] << endl;
00927 MSG("CDCrossTalker",Msg::kDebug)
00928 <<sourceend<<" "<<sourcestrip<<" "<<sourceplane<<endl;
00929
00930 StripEnd::EStripEnd dum_strip_end;
00931 if(sourceend==1) dum_strip_end = StripEnd::kNegative;
00932 else dum_strip_end = StripEnd::kPositive;
00933 PlexStripEndId dummyplex(Detector::kCalDet,sourceplane,
00934 sourcestrip,dum_strip_end);
00935 int theKey = dummyplex.Build18BitPlnStripKey();
00936 fXTalkSource[stripIter->first] = theKey;
00937 }
00938 }
00939
00940 if(stripIter->second.GetNDigit(StripEnd::kPositive)>0){
00941 int end = StripEnd::kPositive;
00942 int sourceplane=crosstalkhitssourceplane[plane][strip+(end-1)*24];
00943 int sourcestrip=(crosstalkhitssourcestrip[plane]
00944 [(strip+(end-1)*24)])%24;
00945 int sourceend=int(crosstalkhitssourcestrip[plane]
00946 [strip+(end-1)*24]/24.)+1;
00947 int numxhits=crosstalknumxhits[plane][strip+(end-1)*24];
00948
00949 if(crosstalkhits[plane][24*(end-1)+strip]<=0) {
00950 fCleanedStrips[stripIter->first] = stripIter->second;
00951 }
00952 else {
00953 fXTalkStrips[stripIter->first] = stripIter->second;
00954 fNumSurround[stripIter->first] = numxhits;
00955 fnum_xtalk_hits+=1;
00956 MSG("CDCrossTalker",Msg::kDebug)<<fnum_xtalk_hits<<endl;
00957 MSG("CDCrossTalker",Msg::kDebug)
00958 <<crosstalkhits[plane][24*(end-1)+strip] << endl;
00959 MSG("CDCrossTalker",Msg::kDebug)
00960 <<sourceend<<" "<<sourcestrip<<" "<<sourceplane<<endl;
00961
00962 StripEnd::EStripEnd dum_strip_end;
00963 if(sourceend==1) dum_strip_end = StripEnd::kNegative;
00964 else dum_strip_end = StripEnd::kPositive;
00965 PlexStripEndId dummyplex(Detector::kCalDet,sourceplane,
00966 sourcestrip,dum_strip_end);
00967 int theKey = dummyplex.Build18BitPlnStripKey();
00968 fXTalkSource[stripIter->first] = theKey;
00969 }
00970 }
00971
00972 }
00973
00974 else fCleanedStrips[stripIter->first] = stripIter->second;
00975
00976 stripIter++;
00977 }
00978 return fCleanedStrips;
00979 }
00980
00981
00982
00983 std::map<int,CandStripHandle> CDCrossTalker::GetXTalkStripMap()
00984 {
00985 if(fnum_xtalk_hits==-1) this->GetCleanStripMap();
00986 return fXTalkStrips;
00987 }
00988
00989
00990
00991 std::map<int,int> CDCrossTalker::GetXTalkSourceStrips()
00992 {
00993 if(fnum_xtalk_hits==-1) this->GetCleanStripMap();
00994 return fXTalkSource;
00995 }
00996
00997
00998
00999 void CDCrossTalker::GetXTalkStripInfo(TClonesArray *infoarray)
01000 {
01001 if(fnum_xtalk_hits==-1) this->GetCleanStripMap();
01002
01003 TClonesArray &infar = *infoarray;
01004
01005 int cnt=0;
01006
01007 map<int,CandStripHandle>::iterator XTalkIt = fXTalkStrips.begin();
01008 map<int,CandStripHandle>::iterator XTalkEnd = fXTalkStrips.end();
01009
01010 if(XTalkIt==XTalkEnd) return;
01011 const VldContext *vc = XTalkIt->second.GetVldContext();
01012 PlexHandle plexHand(*vc);
01013
01014
01015 Calibrator& calibrator=Calibrator::Instance();
01016 calibrator.Reset(*vc);
01017
01018 while(XTalkIt!=XTalkEnd){
01019 MSG("CDCrossTalker",Msg::kDebug)
01020 << XTalkIt->first << " " << fXTalkSource[XTalkIt->first] << endl;
01021
01022 map<int,CandStripHandle>::iterator sorsIt =
01023 fAllStrips.find(fXTalkSource[XTalkIt->first]);
01024
01025 CandStripHandle& csh = XTalkIt->second;
01026 CandStripHandle& sors_csh = sorsIt->second;
01027
01028 if(csh.GetNDigit(StripEnd::kNegative)>0){
01029
01030 PlexPixelSpotId spotId = plexHand.GetPixelSpotId(csh.GetStripEndId(StripEnd::kNegative));
01031 PlexPixelSpotId sors_spotId = plexHand.GetPixelSpotId(sors_csh.GetStripEndId(StripEnd::kNegative));
01032
01033 new(infar[cnt])
01034 CDXTalkHitInfo
01035 (StripEnd::kNegative,
01036 csh.GetPlane(),
01037 csh.GetStrip(),
01038 spotId.GetPixel(),
01039 fNumSurround[XTalkIt->first],
01040 csh.GetCharge(CalDigitType::kNone,StripEnd::kNegative),
01041 csh.GetCharge(CalDigitType::kSigLin,StripEnd::kNegative),
01042 csh.GetCharge(CalDigitType::kSigCorr,StripEnd::kNegative),
01043 csh.GetCharge(CalDigitType::kPE,StripEnd::kNegative),
01044 calibrator.GetMIP(csh.GetCharge(CalDigitType::kSigCorr,
01045 StripEnd::kNegative)),
01046 StripEnd::kNegative,
01047 sors_csh.GetPlane(),
01048 sors_csh.GetStrip(),
01049 sors_spotId.GetPixel(),
01050 sors_spotId.GetSpot(),
01051 sors_csh.GetCharge(CalDigitType::kNone,StripEnd::kNegative),
01052 csh.GetTime(StripEnd::kNegative));
01053 cnt+=1;
01054 }
01055
01056 if(csh.GetNDigit(StripEnd::kPositive)>0){
01057
01058 PlexPixelSpotId spotId = plexHand.GetPixelSpotId(csh.GetStripEndId(StripEnd::kPositive));
01059 PlexPixelSpotId sors_spotId = plexHand.GetPixelSpotId(sors_csh.GetStripEndId(StripEnd::kPositive));
01060
01061 new(infar[cnt])
01062 CDXTalkHitInfo
01063 (StripEnd::kPositive,
01064 csh.GetPlane(),
01065 csh.GetStrip(),
01066 spotId.GetPixel(),
01067 fNumSurround[XTalkIt->first],
01068 csh.GetCharge(CalDigitType::kNone,StripEnd::kPositive),
01069 csh.GetCharge(CalDigitType::kSigLin,StripEnd::kPositive),
01070 csh.GetCharge(CalDigitType::kSigCorr,StripEnd::kPositive),
01071 csh.GetCharge(CalDigitType::kPE,StripEnd::kPositive),
01072 calibrator.GetMIP(csh.GetCharge(CalDigitType::kSigCorr,
01073 StripEnd::kPositive)),
01074 StripEnd::kPositive,
01075 sors_csh.GetPlane(),
01076 sors_csh.GetStrip(),
01077 sors_spotId.GetPixel(),
01078 sors_spotId.GetSpot(),
01079 sors_csh.GetCharge(CalDigitType::kNone,StripEnd::kPositive),
01080 csh.GetTime(StripEnd::kPositive));
01081 cnt+=1;
01082 }
01083
01084 XTalkIt++;
01085 }
01086 infar.Compress();
01087 }
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117