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

ShieldProj.cxx

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <iostream>
00003 #include "TCanvas.h"
00004 #include "TMath.h"
00005 #include "TMatrixD.h"
00006 #include "TVector3.h"
00007 #include "TH1.h"
00008 #include "TH2.h"
00009 #include "TSystem.h"
00010 #include "TChain.h"
00011 #include "MessageService/MsgService.h"
00012 #include "CandNtupleSR/NtpSRRecord.h"
00013 #include "CandNtupleSR/NtpSRTrack.h"
00014 #include "CandNtupleSR/NtpSRStrip.h"
00015 #include "CandNtupleSR/NtpSRShieldStrip.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 "ShieldProj.h" 
00025 
00026 using std::endl;
00027 using std::cout;
00028 using std::ifstream;
00029 using std::ofstream;
00030 
00031 // ******** STATIC DATA MEMBERS **********
00032 
00033 CVSID("$Id: ShieldProj.cxx,v 1.5 2007/03/01 17:26:07 rhatcher Exp $");
00034 
00035 // **************** CONSTRUCTOR & DESTRUCTOR *********************
00036 
00037 ShieldProj::ShieldProj(Double_t vtx0_in, Double_t vtx1_in, Double_t vtx2_in, Double_t vtxCos0_in, Double_t vtxCos1_in, Double_t vtxCos2_in, Int_t plane_in, Int_t strip0_in, ShieldGeom* sg){
00038   vtx0 = vtx0_in;
00039   vtx1 = vtx1_in;
00040   vtx2 = vtx2_in;
00041   vtxCos0 = vtxCos0_in;
00042   vtxCos1 = vtxCos1_in;
00043   vtxCos2 = vtxCos2_in;
00044   plane = plane_in;
00045   strip0 = strip0_in;
00046   
00047   //Finding intersection and distance
00048   
00049   if(sg->PlankExists(plane,strip0)==true){
00050     planeLineDisFinder(sg->GetPlank_X(plane,strip0),sg->GetPlank_Y(plane,strip0),sg->GetPlank_Z(plane,strip0),sg->GetPlankStrip0_X(plane,strip0),sg->GetPlankStrip0_Y(plane,strip0),sg->GetPlankStrip0_Z(plane,strip0),vtx0,vtx1,vtx2,vtx0+vtxCos0,vtx1+vtxCos1,vtx2+vtxCos2,inter0,inter1,inter2);
00051     
00052     if(specialPlank(plane,strip0)==true && inter1<sg->GetPlank_Y(plane,strip0)){ //<--- for special case of "curved" planks (for instance plane 566, plank 3)  
00053       planeLineDisFinder(sg->GetPlank_X(plane,strip0),sg->GetPlank_Y(plane,strip0),sg->GetPlank_Z(plane,strip0),sg->GetPlank_X(plane-1,15),sg->GetPlank_Y(plane-1,15),sg->GetPlank_Z(plane-1,15),vtx0,vtx1,vtx2,vtx0+vtxCos0,vtx1+vtxCos1,vtx2+vtxCos2,inter0,inter1,inter2);
00054     }
00055     
00056     dpv=distanceFinder(sg->GetPlank_X(plane,strip0),sg->GetPlank_Y(plane,strip0),sg->GetPlank_Z(plane,strip0),inter0,inter1,inter2);
00057   }
00058   
00059   else{
00060     dpv=-1000;
00061     inter0=-1000;
00062     inter1=-1000;
00063     inter2=-1000;
00064     MSG("CandShield",Msg::kWarning) << "Plank given to ShieldProj does not exist in shield!" << endl;
00065   }
00066 
00067   //Projection in plank?
00068   HitInPlank=false;
00069   if(dpv<(sg->GetStripsInPlank(plane,strip0))*0.0205 && fabs(inter2-(sg->GetPlank_Z(plane,strip0)))<4.00){
00070     HitInPlank=true;
00071   } 
00072   
00073 }//end of constructor
00074 
00075 ShieldProj::~ShieldProj() {
00076   
00077 }
00078 
00079 // ************** PRIVATE METHODS **********************************
00080 // -----------------------------------------------------------------------
00081 // method that tells you wether a plank is "special" or not (special planks
00082 // are the ones that are "twisted", or "curved" (half of them is inclined
00083 // and the other half isn't)
00084 
00085 Bool_t ShieldProj::specialPlank(Int_t pl,Int_t pk){
00086   
00087   Bool_t verdict;
00088   
00089   Int_t specialList[8];
00090   specialList[0]=566;
00091   specialList[1]=575;
00092   specialList[2]=630;
00093   specialList[3]=639;
00094   specialList[4]=694;
00095   specialList[5]=703;
00096   specialList[6]=758;
00097   specialList[7]=767;
00098 
00099   verdict=false;
00100   for(int pi=0;pi<8;pi++){
00101     if(pl==specialList[pi] && pk == 3){
00102       verdict = true;
00103     }
00104   }
00105   return verdict;
00106   
00107 }
00108 
00109 //------------------------------------------------------------------------
00110 //Method that calculates the intersection between a plane and a line
00111 
00112 void ShieldProj::planeLineDisFinder(Double_t p10,Double_t p11,Double_t p12,Double_t p30,Double_t p31,Double_t p32,Double_t p40, Double_t p41, Double_t p42,Double_t p50,Double_t p51,Double_t p52,Double_t& inter0,Double_t& inter1,Double_t& inter2){ 
00113   
00114   Double_t p20=p10;
00115   Double_t p21=p11;
00116   Double_t p22=p12+4;
00117   Double_t det_up;
00118   Double_t det_do;  
00119   Double_t t;
00120   
00121   det_up=p20*p31*p42-p20*p41*p32-p21*p30*p42+p21*p40*p32+p22*p30*p41-p22*p40*p31-p10*p31*p42+p10*p41*p32+p10*p21*p42-p10*p21*p32-p10*p22*p41+p10*p22*p31+p11*p30*p42-p11*p40*p32-p11*p20*p42+p11*p20*p32+p11*p22*p40-p11*p22*p30-p12*p30*p41+p12*p40*p31+p12*p20*p41-p12*p20*p31-p12*p21*p40+p12*p21*p30;
00122   
00123   det_do=-p22*p30*p41-p12*p40*p31+p20*p41*p32-p22*p31*p50+p10*p22*p41+p22*p30*p51+p21*p32*p50+p22*p40*p31+p10*p31*p42+p20*p31*p52+p10*p32*p51-p21*p30*p52-p10*p31*p52+p21*p30*p42+p12*p30*p41-p12*p20*p41-p11*p30*p42+p11*p20*p42-p11*p22*p40+p12*p21*p40-p10*p41*p32-p20*p31*p42-p20*p32*p51-p10*p21*p42-p21*p40*p32+p11*p40*p32+p10*p21*p52-p10*p22*p51+p11*p30*p52-p11*p32*p50-p11*p20*p52+p11*p22*p50-p12*p30*p51+p12*p31*p50+p12*p20*p51-p12*p21*p50;
00124   
00125   if(det_do!=0){
00126     t=-det_up/det_do;
00127     inter0=p40+(p50-p40)*t;
00128     inter1=p41+(p51-p41)*t;
00129     inter2=p42+(p52-p42)*t;
00130   }
00131   else{
00132   inter0=-100;
00133   inter1=-100;
00134   inter2=-100;
00135   MSG("CandShield",Msg::kWarning) << "Determinant in PlaneLineDisFinder was 0. Either bad luck (a lot of) or something fishy!" << endl;
00136   }
00137 }
00138 
00139 // ------------------------------------------------------------------------
00140 // method that calculates the distance between a line and a point
00141 
00142 Double_t ShieldProj::distanceFinder(Double_t n0,Double_t n1,Double_t n2,Double_t p0,Double_t p1,Double_t p2){
00143   
00144   Double_t x1[3];
00145   Double_t x2[3];
00146   Double_t xp[3];
00147   Double_t v1[3];
00148   Double_t v2[3];
00149   Double_t v3[3];
00150   Double_t magu;
00151   Double_t magd;
00152 
00153   x1[0]=n0;
00154   x1[1]=n1;
00155   x1[2]=n2;
00156   
00157   x2[0]=n0;
00158   x2[1]=n1;
00159   x2[2]=n2+4;
00160 
00161   xp[0]=p0;
00162   xp[1]=p1;
00163   xp[2]=p2;
00164 
00165   for(int ii=0;ii<3;ii++){
00166     v1[ii]=x2[ii]-x1[ii];
00167     v2[ii]=x1[ii]-xp[ii];   
00168   }
00169 
00170   v3[0]=v1[1]*v2[2]-v1[2]*v2[1];
00171   v3[1]=v1[2]*v2[0]-v1[0]*v2[2];
00172   v3[2]=v1[0]*v2[1]-v1[1]*v2[0];
00173   
00174   magu=sqrt(pow(v3[0],2)+pow(v3[1],2)+pow(v3[2],2));
00175   magd=sqrt(pow(v1[0],2)+pow(v1[1],2)+pow(v1[2],2));
00176   if(magd!=0){  
00177     return magu/magd;
00178   }
00179   else{
00180     return 100;
00181   }
00182 }
00183 
00184 //***************** PUBLIC METHODS ********************************
00185 
00186 // -----------------------------------------------------------------
00187 Int_t ShieldProj::GetProjPlane() const {
00188 
00189     return plane;
00190 
00191 }
00192 
00193 // -----------------------------------------------------------------
00194 Int_t ShieldProj::GetProjStrip0() const {
00195 
00196   return strip0;
00197 
00198 }
00199 
00200 // ----------------------------------------------------------------
00201 Double_t ShieldProj::GetProjInter_X() const{
00202 
00203   return inter0;
00204 
00205 }
00206 
00207 // ----------------------------------------------------------------
00208 Double_t ShieldProj::GetProjInter_Y() const{
00209 
00210   return inter1;
00211 
00212 }
00213 
00214 // ----------------------------------------------------------------
00215 Double_t ShieldProj::GetProjInter_Z() const{
00216 
00217   return inter2;
00218 
00219 }
00220 
00221 // ---------------------------------------------------------------
00222 Double_t ShieldProj::GetProjDis() const{
00223 
00224   return dpv;
00225 
00226 }
00227 
00228 // ---------------------------------------------------------------
00229 Bool_t ShieldProj::ProjHitPlank() const{
00230 
00231   return HitInPlank;
00232 
00233 }
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 

Generated on Mon Feb 15 11:07:37 2010 for loon by  doxygen 1.3.9.1