CDCosmicTracker Class Reference

#include <CDCosmicTracker.h>

Inheritance diagram for CDCosmicTracker:
CDTracker

List of all members.

Public Member Functions

 CDCosmicTracker ()
 CDCosmicTracker (std::map< int, CandStripHandle >, CDTrackerOptions *)
 ~CDCosmicTracker ()

Protected Member Functions

int FindStripTrack (int)

Detailed Description

Definition at line 17 of file CDCosmicTracker.h.


Constructor & Destructor Documentation

CDCosmicTracker::CDCosmicTracker (  ) 

Definition at line 34 of file CDCosmicTracker.cxx.

References CDTracker::fevenresult, CDTracker::foddresult, Msg::kVerbose, and MSG.

00035 {
00036   MSG("CDCosmicTracker",Msg::kVerbose)
00037     <<"Running default CDCosmicTracker constructor..."<<endl;
00038 
00039   fevenresult=0;
00040   foddresult=0;
00041 
00042   MSG("CDCosmicTracker",Msg::kVerbose)
00043     <<"Finished default CDCosmicTracker constructor"<<endl;
00044 }

CDCosmicTracker::CDCosmicTracker ( std::map< int, CandStripHandle ,
CDTrackerOptions  
)
CDCosmicTracker::~CDCosmicTracker (  )  [inline]

Definition at line 23 of file CDCosmicTracker.h.

00023 {};


Member Function Documentation

int CDCosmicTracker::FindStripTrack ( int  offset  )  [protected]

Definition at line 68 of file CDCosmicTracker.cxx.

References PlexStripEndId::Build18BitPlnStripKey(), CDTracker::fcd_to, CDTracker::fEvenPlStrips, CDTracker::fOddPlStrips, CDTracker::fStripMap, CDTrackerOptions::GetAcceptance(), OscFit::GetCharge(), CDTrackerOptions::GetHitsPerPlane(), CDTrackerOptions::GetMaxHotPlanes(), CDTrackerOptions::GetTrkLenCut(), Detector::kCalDet, Msg::kDebug, StripEnd::kNegative, CalDigitType::kPE, StripEnd::kPositive, StripEnd::kWhole, and MSG.

00069 {
00070   MSG("CDCosmicTracker", Msg::kDebug)  
00071     << "FindTrack( " << offset << ")"<<endl;
00072   
00073   if(fStripMap.size()>300) return 2;
00074 
00075   // Get some tracking parameters from the TrackerOptions object  
00076   int trk_len_cut = fcd_to->GetTrkLenCut();
00077   int acceptance = fcd_to->GetAcceptance();
00078   int hits_per_plane = fcd_to->GetHitsPerPlane();
00079   int max_hot_planes = fcd_to->GetMaxHotPlanes();
00080   MSG("CDCosmicTracker", Msg::kDebug)  
00081     << "Track length cut: "<< trk_len_cut << endl;
00082   
00083   //temporary map for holding test strips
00084   map<int,CandStripHandle> pre_tracked;
00085   //map for holding definite track hits
00086   map<int,CandStripHandle> tracked; 
00087   
00088   StripEnd::EStripEnd dum_strip_end_crate = StripEnd::kWhole;
00089 
00090   //Set up some large arrays to make TGraphs
00091   float planeHits[500] = {};
00092   float stripHits[500] = {};
00093   float planeErrs[500] = {};
00094   float stripErrs[500] = {};
00095   
00096   float planeHits2[500] = {};
00097   float stripHits2[500] = {};
00098   float planeErrs2[500] = {};
00099   float stripErrs2[500] = {};
00100 
00101   //Some tracking variables
00102   int numHitsInSection2=0;
00103   int hitNum=0;
00104   int lastPlaneHit=-1;
00105   int numHitsInSection=0;
00106 
00107   //Fill arrays:
00108   for(int i=0;i<60;i++){
00109     for(int j=0;j<24;j++){
00110 
00111       if(i%2==offset) {
00112         PlexStripEndId dummyplex(Detector::kCalDet,
00113                                  i,j,dum_strip_end_crate);
00114         int theKey = dummyplex.Build18BitPlnStripKey(); 
00115         if(fStripMap.find(theKey)!=fStripMap.end()){
00116           
00117           MSG("CDCosmicTracker", Msg::kDebug)  
00118             << "Really Before: "<< i << " " << j << endl;
00119           
00120           if(lastPlaneHit>-1 && i-lastPlaneHit>6) {
00121             MSG("CDCosmicTracker", Msg::kDebug)  
00122               << "New Section" << endl;
00123             
00124             //This is a new section.
00125             if(numHitsInSection>2*(trk_len_cut-1)) {
00126               MSG("CDCosmicTracker", Msg::kDebug)  
00127                 << "With: " << numHitsInSection << " or " << hitNum 
00128                 << " hits" << endl;
00129               
00130               //Then we will consider it a valid section for now.
00131               for(int index=0;index<hitNum;index++) {
00132                 planeHits2[index]=planeHits[index];
00133                 planeErrs2[index]=planeErrs[index];
00134                 stripHits2[index]=stripHits[index];
00135                 stripErrs2[index]=stripErrs[index];
00136                 
00137                 MSG("CDCosmicTracker", Msg::kDebug)  
00138                   << "In between: " << planeHits2[index] << " "
00139                   << stripHits2[index] << endl;
00140                 
00141                 planeHits[index]=0;
00142                 planeErrs[index]=0;
00143                 stripHits[index]=0;
00144                 stripErrs[index]=0;
00145               }
00146               numHitsInSection2=numHitsInSection;
00147               numHitsInSection=0;
00148               hitNum=0;
00149             }
00150             else {
00151               for(int index=0;index<hitNum;index++) {
00152                 planeHits[index]=0;
00153                 planeErrs[index]=0;
00154                 stripHits[index]=0;
00155                 stripErrs[index]=0;
00156               } 
00157               numHitsInSection=0;
00158               hitNum=0;
00159             }
00160           }
00161           
00162 
00163 
00164           if(fStripMap[theKey].GetCharge(CalDigitType::kPE,
00165                                          StripEnd::kPositive)>0){
00166             planeHits[hitNum]=i;  // z position in units of "plane"
00167             planeErrs[hitNum]=0.; // set error on z position to be zero
00168             stripHits[hitNum]=j;  // transverse position in units of "strip"
00169             //** error on transverse position set to be 1./sqrt(adc)
00170             stripErrs[hitNum]= 1.00/
00171               sqrt(fStripMap[theKey].GetCharge(CalDigitType::kPE,
00172                                                StripEnd::kPositive));
00173             
00174             hitNum++;
00175             numHitsInSection++;
00176             lastPlaneHit=i;
00177           }
00178           
00179           if(fStripMap[theKey].GetCharge(CalDigitType::kPE,
00180                                          StripEnd::kNegative)>0){
00181             planeHits[hitNum]=i;  // z position in units of "plane"
00182             planeErrs[hitNum]=0.; // set error on z position to be zero
00183             stripHits[hitNum]=j;  // transverse position in units of "strip"
00184             //** error on transverse position set to be 1./sqrt(adc)
00185             stripErrs[hitNum]= 1.00/
00186               sqrt(fStripMap[theKey].GetCharge(CalDigitType::kPE,
00187                                                StripEnd::kNegative));
00188             
00189             hitNum++;
00190             numHitsInSection++; 
00191             lastPlaneHit=i;
00192           }
00193         }
00194       }
00195     }
00196   }
00197   
00198   int whichPlanes[60]={0};
00199   int whichPlanes2[60]={0};
00200   for(int index=0;index<numHitsInSection;index++) {
00201     whichPlanes[int(planeHits[index])]++;
00202   }
00203   
00204   for(int index=0;index<numHitsInSection2;index++) {
00205     whichPlanes2[int(planeHits2[index])]++;
00206   }
00207 
00208   int numPlanes=0;
00209   int numPlanes2=0;
00210   for(int index=0;index<60;index++) {
00211     if(whichPlanes[index]) {
00212       numPlanes++;
00213       MSG("CDCosmicTracker", Msg::kDebug) 
00214         <<"Got Plane: "<<index<<" with "<<whichPlanes[index]<<endl;
00215     }
00216     if(whichPlanes2[index]) {
00217       numPlanes2++;
00218       MSG("CDCosmicTracker", Msg::kDebug) 
00219         <<"Got Plane2: "<<index<<" with "<<whichPlanes2[index] << endl;
00220     }
00221   }
00222   
00223   if(numPlanes2>numPlanes) { 
00224     MSG("CDCosmicTracker", Msg::kDebug)  
00225       <<"There are: " << numHitsInSection << " hits & " 
00226       << numHitsInSection2 << " other hits" <<  endl;
00227     
00228     //Simple definition but will do for now.
00229     for(int index=0;index<numHitsInSection2;index++) {
00230       MSG("CDCosmicTracker", Msg::kDebug)  
00231         << "Middle: " << planeHits2[index] << " " 
00232         << stripHits2[index] << endl;
00233       
00234       planeHits[index]=planeHits2[index];
00235       planeErrs[index]=planeErrs2[index];
00236       stripHits[index]=stripHits2[index];
00237       stripErrs[index]=stripErrs2[index];
00238     }
00239     numHitsInSection=numHitsInSection2;
00240     hitNum=numHitsInSection2;  
00241   }
00242   
00243   if(hitNum<=3) return 0;
00244   
00245   TGraphErrors gr(hitNum,planeHits,stripHits,planeErrs,stripErrs);
00246   TF1 fitty("fitty","pol1",-1,60);
00247   gROOT->SetBatch(1);
00248   gr.Fit("fitty","QR");
00249   gROOT->SetBatch(0);
00250   
00251   int tempLastHits=hitNum;
00252   int newTempNumHits=0;
00253   float newPlaneHits[500]={};
00254   float newStripHits[500]={};
00255   float newPlaneErrs[500]={};
00256   float newStripErrs[500]={};
00257   float tempPlaneHits[500]={};
00258   float tempStripHits[500]={};
00259   float tempPlaneErrs[500]={};
00260   float tempStripErrs[500]={};
00261   
00262   for(int i=0;i<tempLastHits;i++) {
00263     MSG("CDCosmicTracker", Msg::kDebug)  << "Before: " << planeHits[i] << " " 
00264                                          << stripHits[i] << endl;
00265     tempPlaneHits[i]=planeHits[i];
00266     tempPlaneErrs[i]=planeErrs[i];
00267     tempStripHits[i]=stripHits[i];
00268     tempStripErrs[i]=stripErrs[i];
00269   }
00270   
00271   while(newTempNumHits!=tempLastHits) {
00272     newTempNumHits=0;     
00273     
00274     for(int i=0;i<tempLastHits;i++) {
00275       float diffFromLine=fabs(fitty.Eval(tempPlaneHits[i])
00276                               -tempStripHits[i]);
00277       if(diffFromLine<3) {
00278         newPlaneHits[newTempNumHits]=tempPlaneHits[i];
00279         newPlaneErrs[newTempNumHits]=tempPlaneErrs[i];
00280         newStripHits[newTempNumHits]=tempStripHits[i];
00281         newStripErrs[newTempNumHits]=tempStripErrs[i];
00282         newTempNumHits++;
00283       }
00284     }
00285     
00286     if(newTempNumHits<=3) break;
00287     
00288     tempLastHits=newTempNumHits;
00289     
00290     for(int i=0;i<tempLastHits;i++) {
00291       tempPlaneHits[i]=newPlaneHits[i];
00292       tempPlaneErrs[i]=newPlaneErrs[i];
00293       tempStripHits[i]=newStripHits[i];
00294       tempStripErrs[i]=newStripErrs[i];
00295     }
00296     
00297     TGraphErrors gr2(newTempNumHits,newPlaneHits,
00298                      newStripHits, newPlaneErrs,
00299                      newStripErrs);
00300     gROOT->SetBatch(1);
00301     gr2.Fit("fitty","QR");
00302     gROOT->SetBatch(0);
00303     
00304   }
00305   
00306   if(newTempNumHits<=3) return 0;
00307     
00308   int piShowerFlag=0;  // if plane has more than 2 hits in tracking 
00309                        // window increment pi_shower_flag
00310   int isAMuon=1;
00311   int firstHit=-1;
00312   int lastHit=-1;
00313   
00314   int numTrackedHits=0;
00315   
00316   for(int i=0;i<60;i++){
00317     
00318     int planeNumHits=0;
00319     int gotThisPlane=0;
00320     
00321     for(int index=0;index<hitNum;index++) {
00322 
00323       if(i==planeHits[index]) {
00324         gotThisPlane=1;
00325         break;
00326       }
00327       
00328     }
00329     
00330     if(!gotThisPlane) continue;
00331     
00332     for(int j=0;j<24;j++){
00333       
00334       if(i%2==offset) {
00335         
00336         PlexStripEndId dummyplex3(Detector::kCalDet,i,
00337                                     j,dum_strip_end_crate);
00338         int theKey3 = dummyplex3.Build18BitPlnStripKey();       
00339         
00340         if(fStripMap.find(theKey3)!=fStripMap.end()){
00341           
00342           if(firstHit==-1) firstHit=i;
00343           
00344           if((j>fitty.Eval(i)-acceptance) && (j<fitty.Eval(i)+acceptance))
00345             planeNumHits++;
00346           
00347           if((j>fitty.Eval(i)-1.5) && (j<fitty.Eval(i)+1.5)) {
00348             if(offset==0) fEvenPlStrips[theKey3] = fStripMap[theKey3];
00349             else fOddPlStrips[theKey3] = fStripMap[theKey3];
00350             lastHit=i;
00351             if(fStripMap[theKey3].
00352                GetCharge(CalDigitType::kPE,StripEnd::kNegative)>0) 
00353               numTrackedHits++;
00354             if(fStripMap[theKey3].
00355                GetCharge(CalDigitType::kPE,StripEnd::kPositive)>0) 
00356               numTrackedHits++;
00357           }  
00358         }
00359       }
00360     }
00361     
00362     if(planeNumHits >= (hits_per_plane*2)) isAMuon=2;
00363     else if(planeNumHits>4) piShowerFlag++;
00364     else piShowerFlag = 0;
00365     
00366     if(piShowerFlag>max_hot_planes) isAMuon=2;   
00367   }
00368   
00369   if(lastHit-firstHit<(2*(trk_len_cut-1))) isAMuon=0;
00370   if(hitNum>1.7*numTrackedHits) isAMuon=4;
00371   
00372   MSG("CDCosmicTracker", Msg::kDebug)  
00373     << "Last and First for offset: " 
00374     << offset << " " << lastHit 
00375     <<" "<< firstHit <<endl;
00376   return isAMuon;
00377 
00378 }


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1