Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CandShieldSR.cxx

Go to the documentation of this file.
00001 #include <iostream>
00002 #include "TCanvas.h"
00003 #include "TMath.h"
00004 #include "TMatrixD.h"
00005 #include "TVector3.h"
00006 #include "TH1.h"
00007 #include "TH2.h"
00008 #include "TSystem.h"
00009 #include "TChain.h"
00010 #include "MessageService/MsgService.h"
00011 #include "CandNtupleSR/NtpSRRecord.h"
00012 #include "CandNtupleSR/NtpSRTrack.h"
00013 #include "CandNtupleSR/NtpSRStrip.h"
00014 #include "CandNtupleSR/NtpSRShieldStrip.h"
00015 #include "CandNtupleSR/NtpSRVertex.h"
00016 #include "UgliGeometry/UgliGeomHandle.h"
00017 #include "Plex/PlexHandle.h"
00018 #include "Plex/PlexSEIdAltL.h"
00019 #include "Plex/PlexStripEndId.h"
00020 #include "Plex/PlexPlaneId.h"
00021 #include <fstream>
00022 #include "Validity/VldTimeStamp.h"
00023 #include "CandShield/ShieldGeom.h"
00024 #include "CandShield/ShieldProj.h"
00025 #include "CandShieldSR.h" 
00026 
00027 using std::endl;
00028 using std::cout;
00029 using std::ifstream;
00030 using std::ofstream;
00031 
00032 // ******** STATIC DATA MEMBERS **********
00033 
00034 CVSID("$Id: CandShieldSR.cxx,v 1.11 2009/05/09 22:55:24 jpochoa Exp $");
00035 
00036 // **************** CONSTRUCTOR & DESTRUCTOR *********************
00037 
00038 CandShieldSR::CandShieldSR(Double_t vtx0_in, Double_t vtx1_in, Double_t vtx2_in, Double_t vtxCos0_in, Double_t vtxCos1_in, Double_t vtxCos2_in, ShieldGeom* sg){
00039   vtx0 = vtx0_in;
00040   vtx1 = vtx1_in;
00041   vtx2 = vtx2_in;
00042   vtxCos0 = vtxCos0_in;
00043   vtxCos1 = vtxCos1_in;
00044   vtxCos2 = vtxCos2_in;
00045 
00046   //Plane Array
00047   for(int sec=0;sec<=3;sec++){  
00048     for(int ii=0;ii<=31;ii++){
00049       PlaneArray[ii+sec*42]=528+ii+sec*64;
00050     }
00051     for(int ii=0;ii<=5;ii++){
00052       PlaneArray[ii+32+sec*42]=563+ii+sec*64;
00053     }
00054     for(int ii=0;ii<=3;ii++){
00055       PlaneArray[ii+38+sec*42]=572+ii+sec*64;
00056     }
00057   }
00058     
00059   //What Plank?
00060 
00061   //Initialising variables
00062   Int_t pln=0;
00063   Double_t dpv=0;
00064   Double_t dis_min=20000;
00065   hit_closest=0;
00066   Int_t list_plane=0;
00067   Int_t list_strip=0;
00068   Double_t list_dist=0;
00069   Double_t list_dist_max=1000;
00070   for(int ii=0;ii<12;ii++){
00071     min_dpv[ii]=10000; //has to be smaller than default value for dis_min
00072     proj_plane[ii]=-1;  
00073     proj_plank[ii]=-1;
00074     inter0_chosen[ii]=-100;
00075     inter1_chosen[ii]=-100;
00076     inter2_chosen[ii]=-100;
00077     st_strip_chosen[ii]=-1;
00078     st_plane_chosen[ii]=-1;
00079   }
00080   hit_cont=0;
00081   MSG("CandShield",Msg::kDebug) << "About to find shield intersections." << endl; 
00082   for(int pl=0;pl<168;pl++){
00083     for(int st=0;st<20;st++){
00084       if(sg->PlankExists(PlaneArray[pl],st)==true && sg->IsPlaneActive(PlaneArray[pl])){
00085         pln=PlaneArray[pl];
00086         
00087         ShieldProj sp(vtx0,vtx1,vtx2,vtxCos0,vtxCos1,vtxCos2,pln,st,sg);
00088         dpv=sp.GetProjDis();
00089         inter0=sp.GetProjInter_X();
00090         inter1=sp.GetProjInter_Y();
00091         inter2=sp.GetProjInter_Z();
00092         
00093         if(sp.ProjHitPlank()==true){
00094           hit_cont+=1;
00095           if(hit_cont<13){
00096             min_dpv[hit_cont-1] = dpv;
00097             proj_plane[hit_cont-1]=pl;
00098             proj_plank[hit_cont-1]=st;          
00099             inter0_chosen[hit_cont-1]=inter0;
00100             inter1_chosen[hit_cont-1]=inter1;
00101             inter2_chosen[hit_cont-1]=inter2;
00102           }
00103           else {
00104             MSG("CandShield",Msg::kDebug) << "Finding more than 12 hits in the shield for this track!" << endl; 
00105           }
00106         }
00107       }
00108     }
00109   }
00110   
00111   MSG("CandShield",Msg::kDebug) << "Finding hit strip in plank." << endl; 
00112   //What strip
00113   for(int incr=0;incr<hit_cont;incr++){
00114     if(incr<12){
00115       list_dist_max=1000; 
00116       for(int ls=0;ls<sg->GetStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr]);ls++){
00117         list_plane=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,0);
00118         list_strip=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,1);
00119         list_dist=sqrt(pow((sg->GetStrip_X(list_plane,list_strip)-inter0_chosen[incr]),2)+pow((sg->GetStrip_Y(list_plane,list_strip)-inter1_chosen[incr]),2));    
00120         if(list_dist<list_dist_max){
00121           list_dist_max=list_dist;
00122           st_strip_chosen[incr]=list_strip;
00123           st_plane_chosen[incr]=list_plane;
00124         }
00125       }
00126     }
00127   }
00128   
00129   
00130   //Determining the closest to center hit
00131   for(int ii=0;ii<12;ii++){
00132     if(min_dpv[ii]<dis_min){
00133       dis_min=min_dpv[ii];
00134       hit_closest=ii;
00135     }
00136   }
00137   
00138 }//end of first constructor
00139 
00140 CandShieldSR::CandShieldSR(NtpSRTrack* ntpTrack,ShieldGeom* sg){
00141 
00142   //Definitions
00143   Double_t vtx[3];
00144   Double_t dcosVtx[3];
00145   Double_t end[3];
00146   Double_t dcosEnd[3];
00147   Double_t min_dpv_vtx[12];
00148   Double_t inter0_chosen_vtx[12];
00149   Double_t inter1_chosen_vtx[12];
00150   Double_t inter2_chosen_vtx[12];
00151   Int_t proj_plane_vtx[12];
00152   Int_t proj_plank_vtx[12];
00153   Double_t min_dpv_end[12];
00154   Double_t inter0_chosen_end[12];
00155   Double_t inter1_chosen_end[12];
00156   Double_t inter2_chosen_end[12];
00157   Int_t proj_plane_end[12];
00158   Int_t proj_plank_end[12];
00159   Int_t hit_cont_vtx;
00160   Int_t hit_cont_end;
00161   Double_t dist_vtx;
00162   Double_t dist_end;
00163 
00164   //Getting vertex & end information
00165   vtx[0] = ntpTrack->vtx.x; 
00166   vtx[1] = ntpTrack->vtx.y; 
00167   vtx[2] = ntpTrack->vtx.z; 
00168   dcosVtx[0] = ntpTrack->vtx.dcosx;
00169   dcosVtx[1] = ntpTrack->vtx.dcosy;
00170   dcosVtx[2] = ntpTrack->vtx.dcosz;
00171   end[0] = ntpTrack->end.x; 
00172   end[1] = ntpTrack->end.y; 
00173   end[2] = ntpTrack->end.z; 
00174   dcosEnd[0] = ntpTrack->end.dcosx;
00175   dcosEnd[1] = ntpTrack->end.dcosy;
00176   dcosEnd[2] = ntpTrack->end.dcosz;
00177     
00178   //Plane Array
00179   for(int sec=0;sec<=3;sec++){  
00180     for(int ii=0;ii<=31;ii++){
00181       PlaneArray[ii+sec*42]=528+ii+sec*64;
00182     }
00183     for(int ii=0;ii<=5;ii++){
00184       PlaneArray[ii+32+sec*42]=563+ii+sec*64;
00185     }
00186     for(int ii=0;ii<=3;ii++){
00187       PlaneArray[ii+38+sec*42]=572+ii+sec*64;
00188     }
00189   }
00190     
00191   //Finding intersected planks
00192   //--------------------------
00193 
00194   //Initialising variables
00195   Double_t dis_min=20000;
00196   hit_closest=0;
00197   Int_t list_plane=0;
00198   Int_t list_strip=0;
00199   Double_t list_dist=0;
00200   Double_t list_dist_max=1000;
00201   for(int ii=0;ii<12;ii++){
00202     min_dpv[ii]=10000; //has to be smaller than default value for dis_min
00203     proj_plane[ii]=-1;  
00204     proj_plank[ii]=-1;
00205     inter0_chosen[ii]=-100;
00206     inter1_chosen[ii]=-100;
00207     inter2_chosen[ii]=-100;
00208     st_strip_chosen[ii]=-1;
00209     st_plane_chosen[ii]=-1;
00210   }
00211 
00212   //Intersections using vtx and end separately
00213   Int_t pln=0;
00214   Double_t dpv=0;
00215   hit_cont_vtx=0;
00216   hit_cont_end=0;
00217   MSG("CandShield",Msg::kDebug) << "About to find shield intersections." << endl; 
00218   for(int pl=0;pl<168;pl++){
00219     for(int st=0;st<20;st++){
00220       if(sg->PlankExists(PlaneArray[pl],st)==true){
00221         pln=PlaneArray[pl];
00222         
00223         ShieldProj sp_vtx(vtx[0],vtx[1],vtx[2],dcosVtx[0],dcosVtx[1],dcosVtx[2],pln,st,sg);
00224         dpv=sp_vtx.GetProjDis();
00225         inter0=sp_vtx.GetProjInter_X();
00226         inter1=sp_vtx.GetProjInter_Y();
00227         inter2=sp_vtx.GetProjInter_Z();
00228         
00229         if(sp_vtx.ProjHitPlank()==true){
00230           hit_cont_vtx+=1;
00231           if(hit_cont_vtx<13){
00232             min_dpv_vtx[hit_cont_vtx-1] = dpv;
00233             proj_plane_vtx[hit_cont_vtx-1]=pl;
00234             proj_plank_vtx[hit_cont_vtx-1]=st;          
00235             inter0_chosen_vtx[hit_cont_vtx-1]=inter0;
00236             inter1_chosen_vtx[hit_cont_vtx-1]=inter1;
00237             inter2_chosen_vtx[hit_cont_vtx-1]=inter2;       
00238           }      
00239         }
00240 
00241         
00242         ShieldProj sp_end(end[0],end[1],end[2],dcosEnd[0],dcosEnd[1],dcosEnd[2],pln,st,sg);
00243         dpv=sp_end.GetProjDis();
00244         inter0=sp_end.GetProjInter_X();
00245         inter1=sp_end.GetProjInter_Y();
00246         inter2=sp_end.GetProjInter_Z();
00247         
00248         if(sp_end.ProjHitPlank()==true){
00249           hit_cont_end+=1;
00250           if(hit_cont_end<13){
00251             min_dpv_end[hit_cont_end-1] = dpv;
00252             proj_plane_end[hit_cont_end-1]=pl;
00253             proj_plank_end[hit_cont_end-1]=st;          
00254             inter0_chosen_end[hit_cont_end-1]=inter0;
00255             inter1_chosen_end[hit_cont_end-1]=inter1;
00256             inter2_chosen_end[hit_cont_end-1]=inter2;       
00257           }      
00258           else {
00259             MSG("CandShield",Msg::kDebug) << "Found more than 12 hits in the shield for this track!" << endl; 
00260           }
00261         }
00262       }
00263     }
00264   }
00265   
00266   //looping over separate vtx and end hits and keeping the good ones
00267   hit_cont=0;
00268   for(int ht=0;ht<hit_cont_vtx;ht++){
00269     dist_vtx=sqrt(pow(vtx[0]-inter0_chosen_vtx[ht],2)+pow(vtx[1]-inter1_chosen_vtx[ht],2)+pow(vtx[2]-inter2_chosen_vtx[ht],2));
00270     dist_end=sqrt(pow(end[0]-inter0_chosen_vtx[ht],2)+pow(end[1]-inter1_chosen_vtx[ht],2)+pow(end[2]-inter2_chosen_vtx[ht],2));
00271     if(dist_vtx<dist_end && hit_cont<13 && ht<12){ 
00272       hit_cont+=1;
00273       min_dpv[hit_cont-1]=min_dpv_vtx[ht];
00274       proj_plane[hit_cont-1]=proj_plane_vtx[ht];
00275       proj_plank[hit_cont-1]=proj_plank_vtx[ht];
00276       inter0_chosen[hit_cont-1]=inter0_chosen_vtx[ht];
00277       inter1_chosen[hit_cont-1]=inter1_chosen_vtx[ht];
00278       inter2_chosen[hit_cont-1]=inter2_chosen_vtx[ht];
00279     }
00280   }
00281   for(int ht=0;ht<hit_cont_end;ht++){
00282     dist_vtx=sqrt(pow(vtx[0]-inter0_chosen_end[ht],2)+pow(vtx[1]-inter1_chosen_end[ht],2)+pow(vtx[2]-inter2_chosen_end[ht],2));
00283     dist_end=sqrt(pow(end[0]-inter0_chosen_end[ht],2)+pow(end[1]-inter1_chosen_end[ht],2)+pow(end[2]-inter2_chosen_end[ht],2));
00284     if(dist_end<dist_vtx && hit_cont<13 && ht<12){
00285       hit_cont+=1;
00286       min_dpv[hit_cont-1]=min_dpv_end[ht];
00287       proj_plane[hit_cont-1]=proj_plane_end[ht];
00288       proj_plank[hit_cont-1]=proj_plank_end[ht];
00289       inter0_chosen[hit_cont-1]=inter0_chosen_end[ht];
00290       inter1_chosen[hit_cont-1]=inter1_chosen_end[ht];
00291       inter2_chosen[hit_cont-1]=inter2_chosen_end[ht];  
00292     }
00293   }
00294 
00295   //What strip
00296   MSG("CandShield",Msg::kDebug) << "Finding hit strip in plank." << endl; 
00297   for(int incr=0;incr<hit_cont;incr++){
00298     if(incr<12){
00299       list_dist_max=1000; 
00300       for(int ls=0;ls<sg->GetStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr]);ls++){
00301         list_plane=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,0);
00302         list_strip=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,1);
00303         list_dist=sqrt(pow((sg->GetStrip_X(list_plane,list_strip)-inter0_chosen[incr]),2)+pow((sg->GetStrip_Y(list_plane,list_strip)-inter1_chosen[incr]),2));    
00304         if(list_dist<list_dist_max){
00305           list_dist_max=list_dist;
00306           st_strip_chosen[incr]=list_strip;
00307           st_plane_chosen[incr]=list_plane;
00308         }
00309       }
00310     }
00311   }
00312   
00313   //Determining the closest to center hit
00314   for(int ii=0;ii<12;ii++){
00315     if(min_dpv[ii]<dis_min){
00316       dis_min=min_dpv[ii];
00317       hit_closest=ii;
00318     }
00319   }
00320 
00321 }//end of constructor
00322 
00323 CandShieldSR::CandShieldSR(const NtpSRVertex& ntpVtx, const NtpSRVertex& ntpEnd, ShieldGeom* sg){
00324 
00325   //Definitions
00326   Double_t vtx[3];
00327   Double_t dcosVtx[3];
00328   Double_t end[3];
00329   Double_t dcosEnd[3];
00330   Double_t min_dpv_vtx[12];
00331   Double_t inter0_chosen_vtx[12];
00332   Double_t inter1_chosen_vtx[12];
00333   Double_t inter2_chosen_vtx[12];
00334   Int_t proj_plane_vtx[12];
00335   Int_t proj_plank_vtx[12];
00336   Double_t min_dpv_end[12];
00337   Double_t inter0_chosen_end[12];
00338   Double_t inter1_chosen_end[12];
00339   Double_t inter2_chosen_end[12];
00340   Int_t proj_plane_end[12];
00341   Int_t proj_plank_end[12];
00342   Int_t hit_cont_vtx;
00343   Int_t hit_cont_end;
00344   Double_t dist_vtx;
00345   Double_t dist_end;
00346 
00347   //Getting vertex & end information    
00348   vtx[0] = ntpVtx.x;
00349   vtx[1] = ntpVtx.y;
00350   vtx[2] = ntpVtx.z;
00351   dcosVtx[0] = ntpVtx.dcosx;
00352   dcosVtx[1] = ntpVtx.dcosy;
00353   dcosVtx[2] = ntpVtx.dcosz;
00354   end[0] = ntpEnd.x;
00355   end[1] = ntpEnd.y;
00356   end[2] = ntpEnd.z;
00357   dcosEnd[0] = ntpEnd.dcosx;
00358   dcosEnd[1] = ntpEnd.dcosy;
00359   dcosEnd[2] = ntpEnd.dcosz;
00360 
00361   //Plane Array
00362   for(int sec=0;sec<=3;sec++){  
00363     for(int ii=0;ii<=31;ii++){
00364       PlaneArray[ii+sec*42]=528+ii+sec*64;
00365     }
00366     for(int ii=0;ii<=5;ii++){
00367       PlaneArray[ii+32+sec*42]=563+ii+sec*64;
00368     }
00369     for(int ii=0;ii<=3;ii++){
00370       PlaneArray[ii+38+sec*42]=572+ii+sec*64;
00371     }
00372   }
00373     
00374   //Finding intersected planks
00375   //--------------------------
00376 
00377   //Initialising variables
00378   Double_t dis_min=20000;
00379   hit_closest=0;
00380   Int_t list_plane=0;
00381   Int_t list_strip=0;
00382   Double_t list_dist=0;
00383   Double_t list_dist_max=1000;
00384   for(int ii=0;ii<12;ii++){
00385     min_dpv[ii]=10000; //has to be smaller than default value for dis_min
00386     proj_plane[ii]=-1;  
00387     proj_plank[ii]=-1;
00388     inter0_chosen[ii]=-100;
00389     inter1_chosen[ii]=-100;
00390     inter2_chosen[ii]=-100;
00391     st_strip_chosen[ii]=-1;
00392     st_plane_chosen[ii]=-1;
00393   }
00394 
00395   //Intersections using vtx and end separately
00396   Int_t pln=0;
00397   Double_t dpv=0;
00398   hit_cont_vtx=0;
00399   hit_cont_end=0;
00400   MSG("CandShield",Msg::kDebug) << "About to find shield intersections." << endl; 
00401   for(int pl=0;pl<168;pl++){
00402     for(int st=0;st<20;st++){
00403       if(sg->PlankExists(PlaneArray[pl],st)==true){
00404         pln=PlaneArray[pl];
00405         
00406         ShieldProj sp_vtx(vtx[0],vtx[1],vtx[2],dcosVtx[0],dcosVtx[1],dcosVtx[2],pln,st,sg);
00407         dpv=sp_vtx.GetProjDis();
00408         inter0=sp_vtx.GetProjInter_X();
00409         inter1=sp_vtx.GetProjInter_Y();
00410         inter2=sp_vtx.GetProjInter_Z();
00411         
00412         if(sp_vtx.ProjHitPlank()==true){
00413           hit_cont_vtx+=1;
00414           if(hit_cont_vtx<13){
00415             min_dpv_vtx[hit_cont_vtx-1] = dpv;
00416             proj_plane_vtx[hit_cont_vtx-1]=pl;
00417             proj_plank_vtx[hit_cont_vtx-1]=st;          
00418             inter0_chosen_vtx[hit_cont_vtx-1]=inter0;
00419             inter1_chosen_vtx[hit_cont_vtx-1]=inter1;
00420             inter2_chosen_vtx[hit_cont_vtx-1]=inter2;       
00421           }     
00422           else {
00423             MSG("CandShield",Msg::kDebug) << "Found more than 12 hits in the shield for this track!" << endl; 
00424           }
00425         }
00426 
00427         
00428         ShieldProj sp_end(end[0],end[1],end[2],dcosEnd[0],dcosEnd[1],dcosEnd[2],pln,st,sg);
00429         dpv=sp_end.GetProjDis();
00430         inter0=sp_end.GetProjInter_X();
00431         inter1=sp_end.GetProjInter_Y();
00432         inter2=sp_end.GetProjInter_Z();
00433         
00434         if(sp_end.ProjHitPlank()==true){
00435           hit_cont_end+=1;
00436           if(hit_cont_end<13){
00437             min_dpv_end[hit_cont_end-1] = dpv;
00438             proj_plane_end[hit_cont_end-1]=pl;
00439             proj_plank_end[hit_cont_end-1]=st;          
00440             inter0_chosen_end[hit_cont_end-1]=inter0;
00441             inter1_chosen_end[hit_cont_end-1]=inter1;
00442             inter2_chosen_end[hit_cont_end-1]=inter2;       
00443           }      
00444         }
00445       }
00446     }
00447   }
00448   
00449   //looping over separate vtx and end hits and keeping the good ones
00450   hit_cont=0;
00451   for(int ht=0;ht<hit_cont_vtx;ht++){
00452     dist_vtx=sqrt(pow(vtx[0]-inter0_chosen_vtx[ht],2)+pow(vtx[1]-inter1_chosen_vtx[ht],2)+pow(vtx[2]-inter2_chosen_vtx[ht],2));
00453     dist_end=sqrt(pow(end[0]-inter0_chosen_vtx[ht],2)+pow(end[1]-inter1_chosen_vtx[ht],2)+pow(end[2]-inter2_chosen_vtx[ht],2));
00454     if(dist_vtx<dist_end && hit_cont<13 && ht<12){ 
00455       hit_cont+=1;
00456       min_dpv[hit_cont-1]=min_dpv_vtx[ht];
00457       proj_plane[hit_cont-1]=proj_plane_vtx[ht];
00458       proj_plank[hit_cont-1]=proj_plank_vtx[ht];
00459       inter0_chosen[hit_cont-1]=inter0_chosen_vtx[ht];
00460       inter1_chosen[hit_cont-1]=inter1_chosen_vtx[ht];
00461       inter2_chosen[hit_cont-1]=inter2_chosen_vtx[ht];
00462     }
00463   }
00464   for(int ht=0;ht<hit_cont_end;ht++){
00465     dist_vtx=sqrt(pow(vtx[0]-inter0_chosen_end[ht],2)+pow(vtx[1]-inter1_chosen_end[ht],2)+pow(vtx[2]-inter2_chosen_end[ht],2));
00466     dist_end=sqrt(pow(end[0]-inter0_chosen_end[ht],2)+pow(end[1]-inter1_chosen_end[ht],2)+pow(end[2]-inter2_chosen_end[ht],2));
00467     if(dist_end<dist_vtx && hit_cont<13 && ht<12){
00468       hit_cont+=1;
00469       min_dpv[hit_cont-1]=min_dpv_end[ht];
00470       proj_plane[hit_cont-1]=proj_plane_end[ht];
00471       proj_plank[hit_cont-1]=proj_plank_end[ht];
00472       inter0_chosen[hit_cont-1]=inter0_chosen_end[ht];
00473       inter1_chosen[hit_cont-1]=inter1_chosen_end[ht];
00474       inter2_chosen[hit_cont-1]=inter2_chosen_end[ht];  
00475     }
00476   }
00477 
00478   //What strip
00479   MSG("CandShield",Msg::kDebug) << "Finding hit strip in plank." << endl; 
00480   for(int incr=0;incr<hit_cont;incr++){
00481     if(incr<12){
00482       list_dist_max=1000; 
00483       for(int ls=0;ls<sg->GetStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr]);ls++){
00484         list_plane=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,0);
00485         list_strip=sg->GetListStripsInPlank(PlaneArray[proj_plane[incr]],proj_plank[incr],ls,1);
00486         list_dist=sqrt(pow((sg->GetStrip_X(list_plane,list_strip)-inter0_chosen[incr]),2)+pow((sg->GetStrip_Y(list_plane,list_strip)-inter1_chosen[incr]),2));    
00487         if(list_dist<list_dist_max){
00488           list_dist_max=list_dist;
00489           st_strip_chosen[incr]=list_strip;
00490           st_plane_chosen[incr]=list_plane;
00491         }
00492       }
00493     }
00494   }
00495   
00496   //Determining the closest to center hit
00497   for(int ii=0;ii<12;ii++){
00498     if(min_dpv[ii]<dis_min){
00499       dis_min=min_dpv[ii];
00500       hit_closest=ii;
00501     }
00502   }
00503 
00504 }//end of constructor
00505 
00506 CandShieldSR::~CandShieldSR() {
00507  
00508 }
00509 
00510 // ************** PRIVATE METHODS **********************************
00511 // -----------------------------------------------------------------------
00512 // method that tells you wether a plank is "special" or not (special planks
00513 // are the ones that are "twisted", or "curved" (half of them is inclined
00514 // and the other half isn't)
00515 
00516 Bool_t CandShieldSR::specialPlank(Int_t pl,Int_t pk){
00517   
00518   Bool_t verdict;
00519   
00520   Int_t specialList[8];
00521   specialList[0]=566;
00522   specialList[1]=575;
00523   specialList[2]=630;
00524   specialList[3]=639;
00525   specialList[4]=694;
00526   specialList[5]=703;
00527   specialList[6]=758;
00528   specialList[7]=767;
00529 
00530   verdict=false;
00531   for(int pi=0;pi<8;pi++){
00532     if(pl==specialList[pi] && pk == 3){
00533       verdict = true;
00534     }
00535   }
00536   return verdict;
00537   
00538 }
00539 
00540 //***************** PUBLIC METHODS ********************************
00541 
00542 // -----------------------------------------------------------------
00543 Int_t CandShieldSR::GetCandShieldPlane(Int_t id) const {
00544   if(id>0 && id<=hit_cont){
00545     if(proj_plane[id-1]!=-1){
00546       return PlaneArray[proj_plane[id-1]];
00547     } else{
00548       return -1;
00549     }
00550   } else {
00551     MSG("CandShield",Msg::kWarning) << "GetCandShieldPlane:Input is out of bounds;Check HitsInShield" << endl; 
00552     return -1;
00553   }
00554 
00555 }
00556 
00557 // -----------------------------------------------------------------
00558 Int_t CandShieldSR::GetCandShieldStrip0(Int_t id) const {
00559   if(id>0 && id<=hit_cont){
00560     return proj_plank[id-1];
00561   } else {
00562     MSG("CandShield",Msg::kWarning) << "GetCandShieldStrip0:Input is out of bounds;Check HitsInShield" << endl; 
00563     return -1;
00564   }  
00565 
00566 }
00567 
00568 // ----------------------------------------------------------------
00569 Double_t CandShieldSR::GetCandShieldInter_X(Int_t id) const{
00570   if(id>0 && id<=hit_cont){
00571     return inter0_chosen[id-1];
00572   } else {
00573     MSG("CandShield",Msg::kWarning) << "GetCandShieldInter_X:Input is out of bounds;Check HitsInShield" << endl; 
00574     return -100;
00575   }   
00576 
00577 }
00578 
00579 // ----------------------------------------------------------------
00580 Double_t CandShieldSR::GetCandShieldInter_Y(Int_t id) const{  
00581   if(id>0 && id<=hit_cont){
00582     return inter1_chosen[id-1];
00583   } else {
00584     MSG("CandShield",Msg::kWarning) << "GetCandShieldInter_Y:Input is out of bounds;Check HitsInShield" << endl; 
00585     return -100;
00586   } 
00587   
00588 }
00589 
00590 // ----------------------------------------------------------------
00591 Double_t CandShieldSR::GetCandShieldInter_Z(Int_t id) const{
00592   if(id>0 && id<=hit_cont){
00593     return inter2_chosen[id-1];
00594   } else {
00595     MSG("CandShield",Msg::kWarning) << "GetCandShieldInter_Z:Input is out of bounds;Check HitsInShield" << endl; 
00596     return -100;
00597   }  
00598   
00599 }
00600 
00601 // ---------------------------------------------------------------
00602 Double_t CandShieldSR::GetInterCenterDis(Int_t id) const{
00603   if(id>0 && id<=hit_cont){
00604     return min_dpv[id-1];
00605   } else {
00606     MSG("CandShield",Msg::kWarning) << "GetInterCenterDis:Input is out of bounds;Check HitsInShield" << endl; 
00607     return 10000;
00608   }  
00609   
00610 }
00611 
00612 // ----------------------------------------------------------------
00613 Int_t CandShieldSR::GetStripInPlank(Int_t id, Int_t plorst) const{
00614  if(id>0 && id<=hit_cont){ 
00615    if(plorst==0){
00616      return st_plane_chosen[id-1];
00617    }
00618    else if(plorst==1){
00619      return st_strip_chosen[id-1];
00620    }
00621    else{
00622      MSG("CandShield",Msg::kWarning) << "GetStripInPlank:Value in second field must be 0 or 1" << endl;
00623      return -1;
00624    }
00625  } else {
00626    MSG("CandShield",Msg::kWarning) << "GetStripInPlank:Value in first field is out of bounds;Check HitsInShield" << endl; 
00627    return -1;
00628  } 
00629 }
00630 
00631 // -----------------------------------------------------------------
00632 Int_t CandShieldSR::GetCandShieldPlane() const {
00633   
00634   if(proj_plane[0]!=-1){
00635     return PlaneArray[proj_plane[hit_closest]];
00636   } else{
00637     return -1;
00638   }
00639 
00640 }
00641 
00642 // -----------------------------------------------------------------
00643 Int_t CandShieldSR::GetCandShieldStrip0() const {
00644 
00645   return proj_plank[hit_closest];
00646 
00647 }
00648 
00649 // ----------------------------------------------------------------
00650 Double_t CandShieldSR::GetCandShieldInter_X() const{
00651 
00652   return inter0_chosen[hit_closest];
00653 
00654 }
00655 
00656 // ----------------------------------------------------------------
00657 Double_t CandShieldSR::GetCandShieldInter_Y() const{
00658 
00659   return inter1_chosen[hit_closest];
00660 
00661 }
00662 
00663 // ----------------------------------------------------------------
00664 Double_t CandShieldSR::GetCandShieldInter_Z() const{
00665 
00666   return inter2_chosen[hit_closest];
00667 
00668 }
00669 
00670 // ---------------------------------------------------------------
00671 Double_t CandShieldSR::GetInterCenterDis() const{
00672 
00673   return min_dpv[hit_closest];
00674 
00675 }
00676 
00677 // ---------------------------------------------------------------
00678 Int_t CandShieldSR::GetStripInPlank(Int_t plorst) const{
00679 
00680  if(plorst==0){
00681     return st_plane_chosen[hit_closest];
00682   }
00683   else if(plorst==1){
00684     return st_strip_chosen[hit_closest];
00685   }
00686   else{
00687     MSG("CandShield",Msg::kWarning) << "GetStripInPlank:Value in first field must be 0 or 1" << endl;
00688     return -1;
00689   }    
00690 }
00691 
00692 // ---------------------------------------------------------------
00693 Bool_t CandShieldSR::IsVetoHit() const{
00694 
00695   if(hit_cont!=0){
00696     return true;
00697   }
00698   else {
00699     return false;
00700   }
00701 
00702 }
00703 
00704 // ---------------------------------------------------------------
00705 Int_t CandShieldSR::HitsInShield() const{
00706 
00707   if(hit_cont<=12){
00708     return hit_cont;
00709   }
00710   else {
00711     MSG("CandShield",Msg::kWarning) << "HitsInShield:Found more than 12 intersections for this track. Only retained 12" << endl;
00712     return 12;
00713   }
00714 
00715 }

Generated on Mon Feb 15 11:06:29 2010 for loon by  doxygen 1.3.9.1