#include <CDBeamMuTracker.h>
Inheritance diagram for CDBeamMuTracker:
Public Member Functions | |
| CDBeamMuTracker () | |
| CDBeamMuTracker (std::map< int, CandStripHandle >, CDTrackerOptions *) | |
| ~CDBeamMuTracker () | |
Protected Member Functions | |
| int | FindStripTrack (int) |
|
|
Definition at line 24 of file CDBeamMuTracker.h. 00024 {fevenresult=0;foddresult=0;};
|
|
||||||||||||
|
Definition at line 32 of file CDBeamMuTracker.cxx. References MSG, and CDTracker::SetTrackOptions(). 00034 {
00035 fevenresult = -1; //horizontal strips
00036 foddresult = -1; //vertical strips
00037 fnum_cc_hits = -1;
00038 fStripMap = stripmap;
00039 if(!this->SetTrackOptions(cdto))
00040 MSG("CDBeamMuTracker", Msg::kWarning)
00041 << "CDTracker Error: No Options" << std::endl;
00042 }
|
|
|
Definition at line 26 of file CDBeamMuTracker.h. 00026 {};
|
|
|
Definition at line 46 of file CDBeamMuTracker.cxx. References PlexStripEndId::Build18BitPlnStripKey(), CDTrackerOptions::GetAcceptance(), CDTrackerOptions::GetHitsPerPlane(), CDTrackerOptions::GetMaxHotPlanes(), PlexPlaneId::GetPlane(), CDTrackerOptions::GetTrkLenCut(), and MSG. 00047 {
00048
00049 MSG("CDBeamMuTracker", Msg::kDebug) << "Offset " << offset << std::endl;
00050
00051 int trk_len_cut = fcd_to->GetTrkLenCut();
00052 int acceptance = fcd_to->GetAcceptance();
00053 int hits_per_plane = fcd_to->GetHitsPerPlane();
00054 int max_hot_planes = fcd_to->GetMaxHotPlanes();
00055
00056 // offset => even(0) or odd(1) planes...
00057 // trk_len_cut == minimum track length allowed, typically 4 (each orient.)
00058 // acceptance == hit finding range, typically 2 for beam, 8 for cosmics
00059 // hits_per_plane == max number of hit strips allowed within
00060 // acceptance range per plane, typically 3
00061 // max_hot_planes == max consecutive plns with >2 && <="hits_per_plane" hits,
00062 // typically 2
00063
00064 int stripPosition[60] = {0};
00065 int numStrips[60] = {0};
00066 for(int i=0;i<PLANECONST;i++) {
00067 stripPosition[i] = -1;
00068 numStrips[i] = 0;
00069 }
00070 bool firstTime = true;
00071
00072 int gotone = 1; //flag for valid track (1==valid; 0==invalid)
00073 int firsthit = -1; //first hit plane
00074 int lasthit = 0; //last hit plane
00075 int pi_shower_flag = 0; // if plane has 2 or more hits in tracking window
00076 // increment pi_shower_flag
00077
00078 int firstValidPlane = -1; //help pick up missing hits from front of track
00079
00080 while(acceptance>0&&gotone==1&&pi_shower_flag<=max_hot_planes) {
00081
00082 MSG("CDBeamMuTracker", Msg::kDebug) << "Acceptance " << acceptance
00083 << std::endl;
00084
00085 if(offset==0) fEvenPlStrips.clear();
00086 else fOddPlStrips.clear();
00087
00088 map<int,CandStripHandle> pre_tracked; //temporary map to hold test strips
00089 map<int,CandStripHandle> tracked; //map for holding definite track hits
00090
00091 gotone = 1; //flag for valid track (1==valid; 0==invalid)
00092 firsthit = -1;
00093 lasthit = 0;
00094
00095 //following parameters used during tracking:
00096
00097 int numhit; // number of hits in track portion
00098 int numhitplns; // number of hit planes in current portion
00099 int strip; // current expected track centroid
00100 int pln; // number of planes tracked in current
00101 // portion (count in 2's)
00102 int still; // 0==continue tracking ; 1==veto event
00103 int numconmiss; // remembers how many consecutive planes have had no
00104 // hits in the tracking window
00105 bool outOfDet; // out of detector flag
00106
00107 StripEnd::EStripEnd dum_strip_end_crate = StripEnd::kWhole;
00108
00109 int badSeedPln = -1;
00110
00111 for(int j=0;j<PLANECONST/2;j++){
00112 for(int i=0;i<STRIPCONST && j<PLANECONST/2;i++){
00113
00114 numhit=0;
00115 numhitplns=0;
00116 pln=0;
00117 strip=0;
00118 still=0;
00119 outOfDet = false;
00120 pre_tracked.clear();
00121
00122 bool isAStartHit = false;
00123
00124 //if on second time round, force tracker to start at expected strip
00125 if(!firstTime){
00126 if(stripPosition[(2*j)+offset]!=-1) {
00127 i = stripPosition[(2*j)+offset];
00128 strip = stripPosition[(2*j)+offset];
00129 isAStartHit = true;
00130 MSG("CDBeamMuTracker", Msg::kDebug) << "2nd time around: is A Start Hit" << std::endl;
00131 }
00132 else if((2*j)+offset<firstValidPlane){
00133 i = stripPosition[firstValidPlane];
00134 strip = stripPosition[firstValidPlane];
00135 isAStartHit = true;
00136 MSG("CDBeamMuTracker", Msg::kDebug) << "2nd time around: _Fake_ is A Start Hit to find missing hits at beginning of track" << std::endl;
00137 }
00138 }
00139
00140 PlexStripEndId dummyplex(Detector::kCalDet,(2*j)+offset,i,
00141 dum_strip_end_crate);
00142 int theKey = dummyplex.Build18BitPlnStripKey();
00143
00144 if(fStripMap.find(theKey)!=fStripMap.end()) {
00145 isAStartHit = true;
00146 MSG("CDBeamMuTracker", Msg::kDebug) << "Found a start hit" << std::endl;
00147 }
00148
00149 float firstplnstrip = 0.;
00150 float firstplnstripweight = 0.;
00151
00152 if(isAStartHit){
00153
00154 MSG("CDBeamMuTracker", Msg::kDebug) << "In isastarthit code" << std::endl;
00155
00156 if(j==PLANECONST/2-1) {
00157 outOfDet=true; //must go out of the detector
00158 //if we're starting here!
00159 MSG("CDBeamMuTracker", Msg::kDebug) << "out of detector: plane "
00160 << j << std::endl;
00161 }
00162
00163 //if first time around find seed for tracker
00164 if(firstTime){
00165
00166 MSG("CDBeamMuTracker", Msg::kDebug) << "FIRST TIME" << std::endl;
00167
00168 int firstCentre = i;
00169 float largestCharge = 0;
00170
00171 if(i>STRIPCONST-(2*acceptance+1)) i=STRIPCONST-(2*acceptance+1);
00172
00173 for(int fl=0;i+fl<=STRIPCONST-(2*acceptance+1);fl++){
00174
00175 float sumCharge = 0;
00176
00177 for(int sc=0;sc<2*acceptance+1;sc++){
00178
00179 PlexStripEndId dummyplexfT(Detector::kCalDet,
00180 (2*j)+offset,i+fl+sc,
00181 dum_strip_end_crate);
00182 int theKeyfT = dummyplexfT.Build18BitPlnStripKey();
00183
00184 if(fStripMap.find(theKeyfT)!=fStripMap.end())
00185 sumCharge+=fStripMap[theKeyfT].GetCharge(CalDigitType::kSigCorr);
00186 }
00187
00188 if(largestCharge<sumCharge) {
00189 largestCharge=sumCharge;
00190 firstCentre=i+fl+acceptance;
00191 }
00192
00193 }
00194
00195 i=firstCentre;
00196 MSG("CDBeamMuTracker", Msg::kDebug) << "First centre is "
00197 << firstCentre << std::endl;
00198
00199 }
00200
00201 PlexStripEndId dummyplex1(Detector::kCalDet,(2*j)+offset,i,
00202 dum_strip_end_crate);
00203 int theKey1 = dummyplex1.Build18BitPlnStripKey();
00204
00205 if(fStripMap.find(theKey1)!=fStripMap.end()){
00206 numhit+=1;
00207 numhitplns+=1;
00208 pre_tracked[theKey1]=fStripMap[theKey1];
00209 firstplnstrip+=
00210 i*pre_tracked[theKey1].GetCharge(CalDigitType::kSigCorr);
00211 firstplnstripweight+=
00212 pre_tracked[theKey1].GetCharge(CalDigitType::kSigCorr);
00213 }
00214
00215 for(int fl=1;fl<=acceptance;fl++){
00216
00217 bool isAnotherStartHit = false;
00218
00219 if(i+fl<STRIPCONST){
00220
00221 PlexStripEndId dummyplex2(Detector::kCalDet,
00222 (2*j)+offset,i+fl,
00223 dum_strip_end_crate);
00224 int theKey2 = dummyplex2.Build18BitPlnStripKey();
00225
00226 if(fStripMap.find(theKey2)!=fStripMap.end()){
00227 pre_tracked[theKey2] = fStripMap[theKey2];
00228 firstplnstrip+=
00229 (i+fl)*pre_tracked[theKey2].GetCharge(CalDigitType::kSigCorr);
00230 firstplnstripweight+=
00231 pre_tracked[theKey2].GetCharge(CalDigitType::kSigCorr);
00232 isAnotherStartHit = true;
00233 }
00234 }
00235
00236 if(isAnotherStartHit) {
00237 numhit+=1;
00238 MSG("CDBeamMuTracker", Msg::kDebug) << "isanotherstarthit"
00239 << std::endl;
00240 }
00241 isAnotherStartHit=false;
00242
00243 if(i-fl>=0){
00244
00245 PlexStripEndId dummyplex2(Detector::kCalDet,
00246 (2*j)+offset,i-fl,
00247 dum_strip_end_crate);
00248 int theKey2 = dummyplex2.Build18BitPlnStripKey();
00249
00250 if(fStripMap.find(theKey2)!=fStripMap.end()){
00251 pre_tracked[theKey2] = fStripMap[theKey2];
00252 firstplnstrip+=
00253 (i-fl)*pre_tracked[theKey2].GetCharge(CalDigitType::kSigCorr);
00254 firstplnstripweight+=
00255 pre_tracked[theKey2].GetCharge(CalDigitType::kSigCorr);
00256 isAnotherStartHit = true;
00257 }
00258 }
00259
00260 if(isAnotherStartHit) {
00261 numhit+=1;
00262 MSG("CDBeamMuTracker", Msg::kDebug) << "isanotherstarthit"
00263 << std::endl;
00264 }
00265 }
00266
00267 pi_shower_flag=0;
00268 if(numhit>=2 && numhit<=hits_per_plane) pi_shower_flag+=1;
00269 else if(numhit>hits_per_plane) pi_shower_flag=max_hot_planes+1;
00270 else pi_shower_flag=0;
00271 if(pi_shower_flag>max_hot_planes) still=1;
00272
00273 MSG("CDBeamMuTracker", Msg::kDebug) << "PiShowerFlag "
00274 << pi_shower_flag
00275 << " still "
00276 << still << std::endl;
00277
00278 if(firstplnstripweight>0) {
00279 strip=int((firstplnstrip/firstplnstripweight) + 0.5);
00280 MSG("CDBeamMuTracker", Msg::kDebug) << "strip "
00281 << strip << std::endl;
00282 }
00283
00284 stripPosition[(2*j)+offset]=strip;
00285 numStrips[(2*j)+offset]=numhit;
00286 pln=2;
00287 if(!firstTime){
00288 if((2*j)+offset+pln<PLANECONST) {
00289 MSG("CDBeamMuTracker", Msg::kDebug)<<"not firsttime"<<std::endl;
00290 strip = stripPosition[(2*j)+offset+pln];
00291 if(strip==-1) strip=stripPosition[(2*j)+offset];
00292 MSG("CDBeamMuTracker", Msg::kDebug) << "strip "
00293 << strip << std::endl;
00294 }
00295 }
00296 else if(badSeedPln!=-1) {
00297 MSG("CDBeamMuTracker", Msg::kDebug) << "Bad Seed Plane: "
00298 << badSeedPln
00299 << " setting it to "
00300 << strip << std::endl;
00301 stripPosition[2*badSeedPln+offset] = strip;
00302 badSeedPln=-1;
00303 }
00304
00305 numconmiss=0;
00306 int lastValidpln = 0; //last plane (pln) with a valid track hit
00307
00308 while(still==0 && (2*j)+offset+pln<PLANECONST){
00309
00310 int numHitsThisPlane=0; // to check for multiple hits in
00311 //strip range given by acceptance
00312 bool isAHit = false;
00313
00314 numconmiss+=1;
00315
00316
00317 PlexStripEndId dummyplex3(Detector::kCalDet,
00318 (2*j)+offset+pln,
00319 strip,dum_strip_end_crate);
00320 int theKey3 = dummyplex3.Build18BitPlnStripKey();
00321
00322 float stripoffset = 0;
00323 float stripoffsetweight = 0;
00324
00325 if(fStripMap.find(theKey3)!=fStripMap.end()){
00326 pre_tracked[theKey3] = fStripMap[theKey3];
00327 stripoffsetweight+=
00328 pre_tracked[theKey3].GetCharge(CalDigitType::kSigCorr);
00329 isAHit = true;
00330 }
00331
00332 if(isAHit){
00333 numhit += 1;
00334 numHitsThisPlane += 1;
00335 numconmiss = 0;
00336 MSG("CDBeamMuTracker", Msg::kDebug)
00337 << "Is a Hit " << numhit << std::endl;
00338 }
00339
00340 for(int fl=1;fl<=acceptance;fl++){
00341
00342 if(strip+fl<STRIPCONST){
00343
00344 isAHit = false;
00345
00346 PlexStripEndId
00347 dummyplex4(Detector::kCalDet,(2*j)+offset+pln,
00348 strip+fl,dum_strip_end_crate);
00349 int theKey4 = dummyplex4.Build18BitPlnStripKey();
00350
00351 if(fStripMap.find(theKey4)!=fStripMap.end()){
00352 pre_tracked[theKey4] = fStripMap[theKey4];
00353 stripoffsetweight+=
00354 pre_tracked[theKey4].GetCharge(CalDigitType::kSigCorr);
00355 stripoffset+=
00356 fl*pre_tracked[theKey4].GetCharge(CalDigitType::kSigCorr);
00357 isAHit=true;
00358 }
00359
00360 if(isAHit){
00361 numhit +=1;
00362 numHitsThisPlane+=1;
00363 numconmiss = 0;
00364 MSG("CDBeamMuTracker", Msg::kDebug)
00365 << "Is a Hit " << numhit << std::endl;
00366 }
00367
00368 }
00369
00370 if(strip-fl>=0){
00371
00372 isAHit = false;
00373
00374 PlexStripEndId
00375 dummyplex5(Detector::kCalDet,
00376 (2*j)+offset+pln,strip-fl,dum_strip_end_crate);
00377 int theKey5 = dummyplex5.Build18BitPlnStripKey();
00378
00379 if(fStripMap.find(theKey5)!=fStripMap.end()){
00380 pre_tracked[theKey5] = fStripMap[theKey5];
00381 stripoffsetweight+=
00382 pre_tracked[theKey5].GetCharge(CalDigitType::kSigCorr);
00383 stripoffset-=
00384 fl*pre_tracked[theKey5].GetCharge(CalDigitType::kSigCorr);
00385 isAHit=true;
00386 }
00387
00388 if(isAHit){
00389 numhit+=1;
00390 numHitsThisPlane+=1;
00391 numconmiss = 0;
00392 MSG("CDBeamMuTracker", Msg::kDebug)
00393 << "Is a Hit " << numhit << std::endl;
00394 }
00395 }
00396 }
00397
00398 //decide where the expected track centre is for the next pln
00399 if(numHitsThisPlane!=0 && stripoffset>0)
00400 strip+=int((stripoffset/stripoffsetweight)+0.5);
00401 if(numHitsThisPlane!=0 && stripoffset<0)
00402 strip+=int((stripoffset/stripoffsetweight)-0.5);
00403 stripPosition[(2*j)+pln+offset] = strip;
00404 numStrips[(2*j)+pln+offset] = numHitsThisPlane;
00405
00406 MSG("CDBeamMuTracker", Msg::kDebug) << "strip "
00407 << strip << std::endl;
00408
00409
00410 //if numconmiss is re-zeroed, there's at least one hit in this pln
00411 if(numconmiss==0) {
00412 numhitplns+=1;
00413 MSG("CDBeamMuTracker", Msg::kDebug) << "numhitplns "
00414 << numhitplns <<std::endl;
00415 lastValidpln = pln;
00416 }
00417
00418 //look for signs of showering:
00419 if(numHitsThisPlane>=2 && numHitsThisPlane<=hits_per_plane)
00420 pi_shower_flag+=1;
00421 else if(numHitsThisPlane>hits_per_plane)
00422 pi_shower_flag=max_hot_planes+1;
00423 else pi_shower_flag=0;
00424 if(pi_shower_flag>max_hot_planes) still=1;
00425
00426 MSG("CDBeamMuTracker", Msg::kDebug) << "PiShowerFlag "
00427 << pi_shower_flag << std::endl;
00428
00429 //look for ends of tracks:
00430 if(numHitsThisPlane==0 && numconmiss>1) still=1; //end of track
00431 if((2*j)+pln+offset>=PLANECONST-2) {
00432 still=1; //end of detector
00433 outOfDet = true;
00434 }
00435 if(((i>strip && strip==0) || (i<strip && strip==STRIPCONST-1))
00436 && numconmiss>1) {
00437 still=1; //out of sides of detector
00438 outOfDet = true;
00439 }
00440
00441 if(outOfDet) MSG("CDBeamMuTracker", Msg::kDebug) << "Out of Det"
00442 << std::endl;
00443
00444 //increment pln counter (+2 => next pln of same orientation)
00445 pln+=2;
00446 if(!firstTime&&(2*j)+offset+pln<PLANECONST) {
00447 strip = stripPosition[(2*j)+offset+pln];
00448 if(strip==-1) strip=stripPosition[(2*j)+offset+lastValidpln];
00449 //if(strip==-1) strip=stripPosition[(2*j)+offset];
00450
00451 MSG("CDBeamMuTracker", Msg::kDebug) << "Expected Plane "
00452 << 2*j+offset+pln
00453 << " Expected Strip "
00454 << strip << std::endl;
00455 }
00456 }
00457
00458 if(pi_shower_flag>max_hot_planes) gotone=0; // possible shower
00459 // => veto event
00460
00461 else if (numhit>=3 && numhitplns>=3) { //appears to be a plausible
00462 //track portion...
00463
00464 MSG("CDBeamMuTracker", Msg::kDebug) << "Appears to be a plausible track portion" << std::endl;
00465 map<int,CandStripHandle>::iterator pre_startIter =
00466 pre_tracked.begin();
00467 map<int,CandStripHandle>::iterator pre_endIter =
00468 pre_tracked.end();
00469
00470 if(firsthit==-1) firsthit=pre_startIter->second.GetPlane();
00471
00472 while(pre_startIter!=pre_endIter){
00473 tracked[pre_startIter->first] = pre_startIter->second;
00474 pre_startIter++;
00475 }
00476
00477 pre_startIter--;
00478 j = pre_startIter->second.GetPlane()/2;
00479 lasthit=j;
00480 i=STRIPCONST;
00481 }
00482
00483 //nothing for 2 planes or out of detector, and no plausible
00484 //track portion... probably a cross-talk hit
00485 else if(numconmiss>1||outOfDet) {
00486
00487 MSG("CDBeamMuTracker", Msg::kDebug) << "not plausible track portion" << std::endl;
00488
00489 //if first time around and tracked map has no entries
00490 //looks like we picked up a bad seed, use hits in next hit plane
00491 //to guess track centroid for this plane
00492 if(firstTime&&tracked.size()==0) {
00493 badSeedPln = j;
00494 i=STRIPCONST;
00495 MSG("CDBeamMuTracker", Msg::kDebug) <<"bad seed!" << std::endl;
00496 }
00497 //now check for x-talk being picked up at the end of the track
00498 //remove any signs of it from the stripPosition array
00499 else if(firstTime) {
00500 map<int,CandStripHandle>::iterator pre_startIter =
00501 pre_tracked.begin();
00502 map<int,CandStripHandle>::iterator pre_endIter =
00503 pre_tracked.end();
00504
00505 while(pre_startIter!=pre_endIter){
00506 int tmpPlane = pre_startIter->second.GetPlane();
00507 MSG("CDBeamMuTracker", Msg::kDebug) << "Removing plane "
00508 << tmpPlane << std::endl;
00509 stripPosition[tmpPlane] = -1;
00510 numStrips[tmpPlane] = 0;
00511 pre_startIter++;
00512 }
00513 }
00514 i=STRIPCONST;
00515 MSG("CDBeamMuTracker", Msg::kDebug) << "Current i " << i <<std::endl;
00516 }
00517 else if(!firstTime) j+=1;
00518 MSG("CDBeamMuTracker", Msg::kDebug) << "Current j " << j << std::endl;
00519 }
00520 if(gotone==0) break;
00521 }
00522 if(gotone==0) break;
00523 }
00524
00525 //check track lengths
00526 if(gotone==1 && lasthit-firsthit<trk_len_cut-1) gotone=0;
00527
00528 firstValidPlane = firsthit; //set firstValidPlane to be the first
00529 //track hit found in this loop
00530 //any track hits missing from planes before
00531 //this may be picked up next time round
00532
00533 map<int,CandStripHandle>::iterator tracked_startIter =
00534 tracked.begin();
00535 map<int,CandStripHandle>::iterator tracked_endIter =
00536 tracked.end();
00537
00538 while(tracked_startIter!=tracked_endIter){
00539 if(offset==0)
00540 fEvenPlStrips[tracked_startIter->first]=
00541 tracked_startIter->second;
00542 else fOddPlStrips[tracked_startIter->first]=
00543 tracked_startIter->second;
00544 MSG("CDBeamMuTracker", Msg::kDebug) << "Plane num of tracked hits: " << tracked_startIter->second.GetPlane() << std::endl;
00545 tracked_startIter++;
00546 }
00547 acceptance-=1;
00548 firstTime=false;
00549 }
00550
00551 if(gotone==1) return 1; //reasonable track found
00552 else if(pi_shower_flag>max_hot_planes) return 2; //probable shower
00553 else return 0; //none of the above
00554
00555 }
|
1.3.9.1