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

ShieldGeom.cxx

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <iostream>
00003 #include <fstream>
00004 #include "TSystem.h"
00005 #include "TVector3.h"
00006 #include "MessageService/MsgService.h"
00007 #include "UgliGeometry/UgliGeomHandle.h"
00008 #include "Plex/PlexHandle.h"
00009 #include "Plex/PlexSEIdAltL.h"
00010 #include "Plex/PlexStripEndId.h"
00011 #include "Plex/PlexPlaneId.h"
00012 #include "Validity/VldContext.h"
00013 #include "ShieldGeom.h"
00014 using std::endl;
00015 using std::cout;
00016 
00017 // ******** STATIC DATA MEMBERS **********
00018 
00019 CVSID("$Id: ShieldGeom.cxx,v 1.20 2008/01/04 22:27:10 bspeak Exp $");
00020 
00021 
00022 // ************ CONSTRUCTOR **************
00023 ShieldGeom::ShieldGeom(const VldContext& vldc){
00024 
00025   // Plane Array
00026   
00027   for(int sec=0;sec<=3;sec++){  
00028     for(int ii=0;ii<=31;ii++){
00029       PlaneArray[ii+sec*42]=528+ii+sec*64;
00030     }
00031     for(int ii=0;ii<=5;ii++){
00032       PlaneArray[ii+32+sec*42]=563+ii+sec*64;
00033     }
00034     for(int ii=0;ii<=3;ii++){
00035       PlaneArray[ii+38+sec*42]=572+ii+sec*64;
00036     }
00037   }
00038 
00039   //Resetting the existence of planks
00040   for(int pl=0;pl<=167;pl++){
00041     for(int st=0;st<20;st++){
00042       VetoGeomPlank_exist[pl][st]=0;
00043       VetoGeomAlreadyFilled[pl][st]=0;
00044     }
00045   }
00046   
00047   if(vldc.GetDetector()==2){
00048     SetupShieldGeom(vldc);    
00049   } else{
00050     MSG("CandShield",Msg::kWarning) << "ShieldGeom only applies to the far detector; will not load shield geometry" << endl; 
00051   }
00052 
00053 }
00054 
00055 // ************ DESTRUCTOR ***************
00056 ShieldGeom::~ShieldGeom(){}
00057 
00058 // ************ PRIVATE METHODS ************
00059 //------------------------------------------------------------------------
00060 //method that fills the ShieldGeom object
00061 
00062 void ShieldGeom::SetupShieldGeom(const VldContext& vldc){
00063 
00064   // Definitions
00065   Int_t vetoplane=0;
00066   TVector3 stripPos(0,0,0);
00067   Int_t ini_plank=0;
00068   Int_t ini_plane=0;  
00069   Int_t ini_plane_pnf=0;
00070   valid_planes=0;
00071 
00072   //Reading from database; Getting VldRanges
00073   UgliGeomHandle ugh(vldc);  
00074   fughVldRange=ugh.GetVldRange();
00075   PlexHandle ph(vldc);
00076   fphVldRange=ph.GetVldRange();
00077 
00078   //PlaneArray restructuration
00079   for(int pl=0;pl<=167;pl++){
00080     PlexPlaneId *planeid = new PlexPlaneId(Detector::kFar,PlaneArray[pl]);
00081     UgliPlnHandle ugp = ugh.GetScintPlnHandle(*planeid);
00082     delete planeid;
00083     if(ugp.IsValid()==true){
00084       PlaneValidity[pl]=true;
00085       valid_planes+=1;
00086     } 
00087     else {
00088       PlaneValidity[pl]=false;
00089     }
00090   }
00091     
00092   // 1) Planes
00093 
00094   MSG("CandShield",Msg::kDebug) << "Doing strips and planes in SetupShieldGeom" << endl; 
00095   for(int pl=0;pl<valid_planes;pl++){
00096     if(PlaneValidity[pl]==true){
00097     
00098       vetoplane=PlaneArray[pl];  
00099       PlexPlaneId *pid = new PlexPlaneId(Detector::kFar,vetoplane);    
00100       UgliPlnHandle ugp = ugh.GetScintPlnHandle(*pid);
00101       VetoGeom_x[pl]=ugp.GetX0();    
00102       VetoGeom_y[pl]=ugp.GetY0();
00103       VetoGeom_z[pl]=ugp.GetZ0();   
00104       VetoGeomSection[pl]=pid->GetVetoSection();
00105       delete pid;
00106       
00107       //get the position of the 19th strip of each plane
00108       PlexPlaneId plnid(Detector::kFar,vetoplane,false);
00109       PlexStripEndId *seid = new PlexStripEndId(plnid,19,StripEnd::kUnknown);
00110       UgliStripHandle ugs = ugh.GetStripHandle(*seid);
00111       delete seid;
00112       stripPos=ugs.GlobalPos(0);
00113       VetoGeom_x_s19[pl]=stripPos[0];
00114       VetoGeom_y_s19[pl]=stripPos[1];
00115       VetoGeom_z_s19[pl]=stripPos[2];        
00116     }
00117   }
00118   
00119   //Individual strip positions
00120   for(int pl=0;pl<valid_planes;pl++){
00121     if(PlaneValidity[pl]==true){
00122       vetoplane=PlaneArray[pl];
00123       PlexPlaneId pid(Detector::kFar,vetoplane);
00124       for(int st=0;st<20;st++){      
00125         PlexStripEndId *seid = new PlexStripEndId(pid,st,StripEnd::kUnknown);
00126         UgliStripHandle ugs = ugh.GetStripHandle(*seid);      
00127         delete seid;
00128         if(st==0){
00129           VetoPlaneClearFiber[pl][0]=ugs.ClearFiber(StripEnd::kSouth);
00130           VetoPlaneClearFiber[pl][1]=ugs.ClearFiber(StripEnd::kNorth);
00131         }
00132         stripPos=ugs.GlobalPos(0);
00133         VetoStrip_x[pl][st]=stripPos[0];
00134         VetoStrip_y[pl][st]=stripPos[1];
00135         VetoStrip_z[pl][st]=stripPos[2];
00136         VetoStripWls[pl][st][0]=ugs.WlsPigtail(StripEnd::kSouth);      
00137         VetoStripWls[pl][st][1]=ugs.WlsPigtail(StripEnd::kNorth);
00138       }    
00139     }
00140   }
00141   
00142   //2) Planks
00143   MSG("CandShield",Msg::kDebug) << "Doing planks in SetupShieldGeom" << endl;  
00144   for(int pl=0;pl<valid_planes;pl++){
00145     if(PlaneValidity[pl]==true){
00146       PlexPlaneId plnid(Detector::kFar,PlaneArray[pl],false);
00147       for(int st=0;st<=19;st++){
00148         PlexStripEndId pseid(plnid,st,StripEnd::kNorth);
00149         RawChannelId rcid = ph.GetRawChannelId(pseid);
00150         
00151         PlexStripEndId pseid_op = pseid.GetOppositeSEId();
00152         RawChannelId rcid_op = ph.GetRawChannelId(pseid_op);
00153         
00154         PlexSEIdAltL altlist = ph.GetSEIdAltL(rcid);
00155         
00156         //Iterate through the alt list to find the SEId with the smallest
00157         //plane/strip combo, and the average X, Y, and Z positions
00158         double MeanPlankXYZ[3] = {0.0};
00159         altlist.SetFirst();
00160         PlexStripEndId IndexSEId = altlist.GetCurrentSEId();
00161         while (altlist.IsValid()) {
00162           PlexStripEndId ThisSEId = altlist.GetCurrentSEId();
00163           if(ThisSEId.GetPlane() < IndexSEId.GetPlane() ||
00164              (ThisSEId.GetStrip() < IndexSEId.GetStrip() &&
00165               ThisSEId.GetPlane() == IndexSEId.GetPlane())) IndexSEId=ThisSEId;
00166 
00167           UgliStripHandle ugs = ugh.GetStripHandle(ThisSEId);
00168           stripPos = ugs.GlobalPos(0);
00169 
00170           MeanPlankXYZ[0] += stripPos[0];
00171           MeanPlankXYZ[1] += stripPos[1];
00172           MeanPlankXYZ[2] += stripPos[2];
00173 
00174           altlist.Next();
00175         }
00176 
00177         ini_plane = IndexSEId.GetPlane();
00178         ini_plank = IndexSEId.GetStrip();
00179 
00180         ini_plane_pnf = planeNumberFinder(ini_plane);
00181         if(ini_plane_pnf==-1){
00182           MSG("CandShield",Msg::kWarning) << "WARNING: Plane number returned by PlexSEIdAltL is not valid veto shield plane !! ---- Will not calculate variables for it" << endl;
00183           break;              
00184         }
00185             
00186         MeanPlankXYZ[0] = MeanPlankXYZ[0] / altlist.GetSize();
00187         MeanPlankXYZ[1] = MeanPlankXYZ[1] / altlist.GetSize();
00188         MeanPlankXYZ[2] = MeanPlankXYZ[2] / altlist.GetSize();
00189 
00190         VetoGeomPlank_x[ini_plane_pnf][ini_plank] = MeanPlankXYZ[0]; 
00191         VetoGeomPlank_y[ini_plane_pnf][ini_plank] = MeanPlankXYZ[1];
00192         VetoGeomPlank_z[ini_plane_pnf][ini_plank] = MeanPlankXYZ[2];
00193 
00194         VetoChipIndex[ini_plane_pnf][ini_plank][1]=rcid.GetCrate()*108 + rcid.GetVarcId()*36+rcid.GetVmm()*6 + rcid.GetVaAdcSel()*3+rcid.GetVaChip();
00195         VetoChipIndex[ini_plane_pnf][ini_plank][0]=rcid_op.GetCrate()*108 + rcid_op.GetVarcId()*36+rcid_op.GetVmm()*6 + rcid_op.GetVaAdcSel()*3+rcid_op.GetVaChip();
00196         VetoGeomPlank_exist[ini_plane_pnf][ini_plank]=1;
00197         VetoGeomPlank_strips[ini_plane_pnf][ini_plank]=altlist.GetSize();
00198             
00199         if(VetoGeomAlreadyFilled[ini_plane_pnf][ini_plank]!=1){
00200           PlexPlaneId plnid2(Detector::kFar,ini_plane,false);
00201           PlexStripEndId *pseid2 = new PlexStripEndId(plnid2,ini_plank,StripEnd::kUnknown);
00202           UgliStripHandle ugs = ugh.GetStripHandle(*pseid2);
00203           delete pseid2;
00204           stripPos=ugs.GlobalPos(0);
00205           VetoGeomPlank_x_s0[ini_plane_pnf][ini_plank]=stripPos[0];
00206           VetoGeomPlank_y_s0[ini_plane_pnf][ini_plank]=stripPos[1];
00207           VetoGeomPlank_z_s0[ini_plane_pnf][ini_plank]=stripPos[2];
00208         }
00209 
00210         altlist.SetFirst();
00211         Int_t contlist=0;
00212         while (altlist.IsValid()) {
00213           PlexStripEndId sebest = altlist.GetCurrentSEId();
00214           ListStripsInPlank[ini_plane_pnf][ini_plank][contlist][0] = sebest.GetPlane();
00215           ListStripsInPlank[ini_plane_pnf][ini_plank][contlist][1] = sebest.GetStrip(); 
00216           AssociatedPlank[planeNumberFinder(sebest.GetPlane())][sebest.GetStrip()][0]=ini_plane;
00217           AssociatedPlank[planeNumberFinder(sebest.GetPlane())][sebest.GetStrip()][1]=ini_plank;
00218           
00219           altlist.Next();
00220           contlist=contlist+1;
00221         }  
00222         VetoGeomAlreadyFilled[ini_plane_pnf][ini_plank]=1;
00223       }//end of strip loop
00224       
00225     }//plane validity check
00226     
00227   }//end of planes loop  
00228   
00229   //Other stuff
00230   AlreadyDidChipNumbers=false;
00231 
00232   //Planks that cease to exist and are replaced by others
00233   for(int sect=1;sect<5;sect++){
00234     VetoGeomPlank_x[8+42*(sect-1)][12]+=-0.492;
00235     VetoGeomPlank_x[8+42*(sect-1)][4]+=0.164;
00236     VetoGeomPlank_x[9+42*(sect-1)][0]+=0.492;
00237     VetoGeomPlank_x[9+42*(sect-1)][8]+=-0.164;  
00238   }
00239 }//end of SetupShieldGeom method
00240 
00241 //------------------------------------------------------------------------
00242 //method that assigns a number between 0 and 167 for each veto plane. 
00243 
00244 Int_t ShieldGeom::planeNumberFinder(Int_t pln)
00245 {
00246   Int_t planeNum=-1;
00247   
00248   for(int ii=0;ii<168;ii++){
00249     if(PlaneArray[ii]==pln){
00250       planeNum = ii; 
00251       continue;
00252     }    
00253   }
00254   return planeNum;
00255   
00256 }
00257 
00258 // -----------------------------------------------------------------------
00259 // method that tells you wether a plank is "special" or not (special planks
00260 // are the ones that are "twisted", or "curved" (half of them is inclined
00261 // and the other half isn't)
00262 
00263 Bool_t ShieldGeom::specialPlank(Int_t pl,Int_t pk){
00264   
00265   Bool_t verdict;
00266   
00267   static Int_t specialList[8] = {
00268     565, 574,  /*Section 1*/
00269     629, 638,  /*Section 2*/
00270     693, 702,  /*Section 3*/
00271     757, 766}; /*Section 4*/
00272 
00273   verdict=false;
00274   for(int pi=0;pi<8;pi++){
00275     if(pl==specialList[pi] && pk == 16){
00276       verdict = true;
00277     }
00278   }
00279   return verdict;
00280   
00281 } 
00282 
00283 // *********** PUBLIC METHODS ******************
00284 
00285 //--------------------------------------------------------
00286 Bool_t ShieldGeom::Reinitialize(const VldContext& vldc){
00287 
00288   if(fughVldRange.IsCompatible(vldc) && fphVldRange.IsCompatible(vldc)){
00289     return false;
00290   }
00291   else{
00292     //Resetting the existence of planks
00293     for(int pl=0;pl<=167;pl++){
00294       for(int st=0;st<20;st++){
00295         VetoGeomPlank_exist[pl][st]=0;
00296         VetoGeomAlreadyFilled[pl][st]=0;
00297       }
00298     }
00299     SetupShieldGeom(vldc);
00300     return true;
00301   }
00302 
00303 }
00304 
00305 //--------------------------------------------------------
00306 Double_t ShieldGeom::GetPlank_X(Int_t pl, Int_t pk){
00307   if(planeNumberFinder(pl)!=-1){
00308     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00309       return VetoGeomPlank_x[planeNumberFinder(pl)][pk];
00310     } else{
00311       MSG("CandShield",Msg::kWarning) << "GetPlank_X:Plank " << pl << "," << pk << " does not exist!" << endl; 
00312       return -100;
00313     }
00314   } else {
00315     MSG("CandShield",Msg::kWarning) << "GetPlank_X:Plank " << pl << "," << pk << " does not exist!" << endl;
00316     return -100;
00317   }
00318 }
00319 
00320 // -------------------------------------------------------
00321 Double_t ShieldGeom::GetPlank_Y(Int_t pl, Int_t pk){
00322   if(planeNumberFinder(pl)!=-1){
00323    if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00324      return VetoGeomPlank_y[planeNumberFinder(pl)][pk];
00325    } else{
00326      MSG("CandShield",Msg::kWarning) << "GetPlank_Y:Plank " << pl << "," << pk << " does not exist!" << endl;
00327      return -100;
00328    } 
00329   }else {
00330     MSG("CandShield",Msg::kWarning) << "GetPlank_Y:Plank " << pl << "," << pk << " does not exist!" << endl;
00331     return -100;
00332   }
00333 }
00334 
00335 // -------------------------------------------------------
00336 Double_t ShieldGeom::GetPlank_Z(Int_t pl, Int_t pk){
00337   if(planeNumberFinder(pl)!=-1){
00338     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00339       return VetoGeomPlank_z[planeNumberFinder(pl)][pk];
00340     } else{
00341       MSG("CandShield",Msg::kWarning) << "GetPlank_Z:Plank " << pl << "," << pk << " does not exist!" << endl;
00342       return -100;
00343     }
00344   } else {
00345     MSG("CandShield",Msg::kWarning) << "GetPlank_Z:Plank " << pl << "," << pk << " does not exist!" << endl;
00346     return -100;
00347   }
00348   
00349 }
00350 // -------------------------------------------------------
00351 Bool_t ShieldGeom::PlankExists(Int_t pl, Int_t pk) {
00352   if(planeNumberFinder(pl)!=-1){
00353     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00354       return true;
00355     }
00356     else {return false;
00357     }
00358   }else{    
00359     return false;
00360   }
00361 
00362 }
00363  
00364 //--------------------------------------------------------
00365 Double_t ShieldGeom::GetPlankStrip0_X(Int_t pl, Int_t pk){
00366   if(planeNumberFinder(pl)!=-1){
00367     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00368       return VetoGeomPlank_x_s0[planeNumberFinder(pl)][pk];
00369     } else{
00370       MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_X:Plank " << pl << "," << pk << " does not exist!" << endl;
00371       return -100;
00372     }
00373   }else {
00374     MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_X:Plank " << pl << "," << pk << " does not exist!" << endl;
00375     return -100;
00376   }
00377 }
00378 
00379 // -------------------------------------------------------
00380 Double_t ShieldGeom::GetPlankStrip0_Y(Int_t pl, Int_t pk){
00381   if(planeNumberFinder(pl)!=-1){
00382    if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00383      return VetoGeomPlank_y_s0[planeNumberFinder(pl)][pk];
00384    } else{
00385      MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_Y:Plank " << pl << "," << pk << " does not exist!" << endl;
00386      return -100;
00387    }   
00388   }else{
00389     MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_Y:Plank " << pl << "," << pk << " does not exist!" << endl;
00390     return -100;
00391   }
00392 }
00393 
00394 // -------------------------------------------------------
00395 Double_t ShieldGeom::GetPlankStrip0_Z(Int_t pl, Int_t pk){
00396   if(planeNumberFinder(pl)!=-1){
00397     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00398       return VetoGeomPlank_z_s0[planeNumberFinder(pl)][pk];
00399     } else{
00400       MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_Z:Plank " << pl << "," << pk << " does not exist!" << endl;
00401       return -100;
00402     }  
00403   } else{
00404     MSG("CandShield",Msg::kWarning) << "GetPlankStrip0_Z:Plank " << pl << "," << pk << " does not exist!" << endl;
00405     return -100; 
00406   }
00407 }
00408 
00409 // -------------------------------------------------------
00410 Int_t ShieldGeom::GetStripsInPlank(Int_t pl, Int_t pk){
00411   if(planeNumberFinder(pl)!=-1){
00412     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00413       return VetoGeomPlank_strips[planeNumberFinder(pl)][pk];
00414     }
00415     else{
00416       MSG("CandShield",Msg::kWarning) << "GetStripsInPlank:Plank " << pl << "," << pk << " does not exist!" << endl;
00417       return -1;
00418     }
00419   }else{
00420     MSG("CandShield",Msg::kWarning) << "GetStripsInPlank:Plank " << pl << "," << pk << " does not exist!" << endl;
00421     return -1;
00422   }
00423 }
00424 
00425 // ------------------------------------------------------
00426 Int_t ShieldGeom::GetListStripsInPlank(Int_t pl, Int_t pk, Int_t entry, Int_t plorst){
00427   if(planeNumberFinder(pl)!=-1){
00428     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && plorst<2 && plorst>-1 && entry<VetoGeomPlank_strips[planeNumberFinder(pl)][pk] && PlaneValidity[planeNumberFinder(pl)]==true){        
00429       return ListStripsInPlank[planeNumberFinder(pl)][pk][entry][plorst];
00430     }
00431     else {
00432       MSG("CandShield",Msg::kWarning) << "GetListStripsInPlank:Either supplied plank does not exist, or third and/or fourth fields are out of range, or supplied plane is not valid"<< endl;
00433       return -1;
00434     }
00435   }else {
00436     MSG("CandShield",Msg::kWarning) << "GetListStripsInPlank:Plane " << pl << " does not exist!" << endl;
00437     return -1;
00438   }
00439 
00440 }
00441 
00442 // -----------------------------------------------------
00443 Int_t ShieldGeom::GetAssociatedPlank(Int_t pl, Int_t st, Int_t plorst){
00444   if(planeNumberFinder(pl)!=-1){
00445     if(plorst<2 && plorst>-1 && PlaneValidity[planeNumberFinder(pl)]==true && st<20 && st>-1){
00446       return AssociatedPlank[planeNumberFinder(pl)][st][plorst];
00447     }else {
00448       MSG("CandShield",Msg::kWarning) << "GetAssociatedPlank:Either second and/or third fields out of range, or supplied plane is not valid." << endl;
00449       return -1;
00450     }
00451   }else {
00452     MSG("CandShield",Msg::kWarning) << "GetAssociatedPlank:Plane " << pl << " does not exist in veto!" << endl;
00453     return -1;
00454   }
00455 
00456 }
00457 
00458 // ------------------------------------------------------
00459 Int_t ShieldGeom::GetChipIndex(Int_t pl, Int_t pk, Int_t noorso){
00460   if(planeNumberFinder(pl)!=-1){
00461     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00462       return VetoChipIndex[planeNumberFinder(pl)][pk][noorso];
00463     }
00464     else {
00465       MSG("CandShield",Msg::kWarning) << "GetChipIndex:Plank " << pl << "," << pk << " does not exist!" << endl;
00466       return -1;
00467     }
00468   }else {
00469     MSG("CandShield",Msg::kWarning) << "GetChipIndex:Plank " << pl << "," << pk << " does not exist!" << endl;
00470     return -1;
00471   }
00472   
00473 }
00474 
00475 // ------------------------------------------------------
00476 Int_t ShieldGeom::GetChipNumber(Int_t pl, Int_t pk, Int_t noorso){
00477    
00478   if(AlreadyDidChipNumbers==false){    
00479     
00480     Int_t AlreadyChip[100]={0};
00481     Int_t found_ll;
00482     Int_t main_cont=-1;
00483     
00484     for(int pln=0;pln<168;pln++){   
00485       for(int st=0;st<20;st++){
00486         if(VetoGeomPlank_exist[pln][st]==1){
00487           
00488           found_ll=-1;
00489           for(int ll=0;ll<64;ll++){
00490             if(AlreadyChip[ll]==VetoChipIndex[pln][st][1]){
00491               found_ll=ll;
00492             }
00493           }
00494           if(found_ll==-1){
00495             main_cont+=1;
00496             AlreadyChip[main_cont]=VetoChipIndex[pln][st][1];
00497             VetoChipNumber[pln][st][1]=main_cont;
00498           }
00499           else {
00500             VetoChipNumber[pln][st][1]=found_ll;
00501           }
00502           
00503           found_ll=-1;
00504           for(int ll=0;ll<64;ll++){
00505             if(AlreadyChip[ll]==VetoChipIndex[pln][st][0]){
00506               found_ll=ll;
00507             }
00508           }
00509           if(found_ll==-1){
00510             main_cont+=1;
00511             AlreadyChip[main_cont]=VetoChipIndex[pln][st][0];
00512             VetoChipNumber[pln][st][0]=main_cont;
00513           }
00514           else VetoChipNumber[pln][st][0]=found_ll;
00515         }
00516         else{
00517           VetoChipNumber[pln][st][0]=-1;
00518           VetoChipNumber[pln][st][1]=-1;
00519         }
00520       }
00521     } 
00522     if(valid_planes==168){
00523       AlreadyDidChipNumbers=true;
00524     }
00525   }
00526   if(planeNumberFinder(pl)!=-1){
00527     if(VetoGeomPlank_exist[planeNumberFinder(pl)][pk]==1 && PlaneValidity[planeNumberFinder(pl)]==true){
00528       return VetoChipNumber[planeNumberFinder(pl)][pk][noorso];
00529     }else {
00530       MSG("CandShield",Msg::kWarning) << "GetChipNumber:Plank " << pl << "," << pk << " does not exist!" << endl;
00531       return -1; 
00532     }  
00533   }else {
00534     MSG("CandShield",Msg::kWarning) << "GetChipNumber:Plank " << pl << "," << pk << " does not exist!" << endl;
00535     return -1;  
00536   }
00537 }
00538 
00539 // ------------------------------------------------------
00540 Bool_t ShieldGeom::IsVertical(Int_t pl){
00541   
00542   Bool_t verticality=false;
00543 
00544   Int_t VerticalList[10]={0};
00545   VerticalList[0]=558;
00546   VerticalList[1]=559;
00547   VerticalList[2]=563;
00548   VerticalList[3]=564;
00549   VerticalList[4]=565;
00550   VerticalList[5]=567;
00551   VerticalList[6]=568;
00552   VerticalList[7]=572;
00553   VerticalList[8]=573;
00554   VerticalList[9]=574;
00555   
00556   for(int sect=0;sect<4;sect++){
00557     for(int ii=0;ii<10;ii++){
00558       if(VerticalList[ii]+sect*64==pl){
00559         verticality = true;
00560       }
00561     }
00562   }
00563 
00564   return verticality;
00565 
00566 }
00567 
00568 // ------------------------------------------------------
00569 Bool_t ShieldGeom::IsLowerSide(Int_t pl){
00570 
00571   Bool_t lsidity=false;
00572 
00573   Int_t LowerSideList[10]={0};
00574   LowerSideList[0]=558;
00575   LowerSideList[1]=559;
00576   LowerSideList[2]=567;
00577   LowerSideList[3]=568;
00578   
00579   for(int sect=0;sect<4;sect++){
00580     for(int ii=0;ii<10;ii++){
00581       if(LowerSideList[ii]+sect*64==pl){
00582         lsidity = true;
00583       }
00584     }
00585   }
00586 
00587   return lsidity;
00588 
00589 }
00590 
00591 // -------------------------------------------------------
00592 Double_t ShieldGeom::GetPlane_X(Int_t pl) {
00593   if(planeNumberFinder(pl)!=-1){
00594     if(PlaneValidity[planeNumberFinder(pl)]==true){
00595       return VetoGeom_x[planeNumberFinder(pl)];
00596     } else{
00597       MSG("CandShield",Msg::kWarning) << "GetPlane_X:Plane " << pl << " is not valid!" << endl;
00598       return -100;
00599     }
00600   }else {
00601     MSG("CandShield",Msg::kWarning) << "GetPlane_X:Plane " << pl << " does not exist in the shield!" << endl;
00602     return -100;
00603   }
00604 }
00605 
00606 // -------------------------------------------------------
00607 Double_t ShieldGeom::GetPlane_Y(Int_t pl) {
00608   if(planeNumberFinder(pl)!=-1){
00609     if(PlaneValidity[planeNumberFinder(pl)]==true){
00610       return VetoGeom_y[planeNumberFinder(pl)];
00611     } else{
00612       MSG("CandShield",Msg::kWarning) << "GetPlane_Y:Plane " << pl << " is not valid!" << endl;
00613       return -100;
00614     }
00615   }else {
00616     MSG("CandShield",Msg::kWarning) << "GetPlane_Y:Plane " << pl << " does not exist in the shield!" << endl;
00617       return -100;
00618   }
00619 }
00620 
00621 // -------------------------------------------------------
00622 Double_t ShieldGeom::GetPlane_Z(Int_t pl) {
00623   if(planeNumberFinder(pl)!=-1){
00624     if(PlaneValidity[planeNumberFinder(pl)]==true){
00625       return VetoGeom_z[planeNumberFinder(pl)];
00626     } else{
00627       MSG("CandShield",Msg::kWarning) << "GetPlane_Z:Plane " << pl << " is not valid!" << endl;
00628       return -100;
00629     }
00630   }else {
00631     MSG("CandShield",Msg::kWarning) << "GetPlane_Z:Plane " << pl << " does not exist in the shield!" << endl;
00632     return -100;
00633   }
00634 }
00635 
00636 // -------------------------------------------------------
00637 Double_t ShieldGeom::GetPlaneClearFiber(Int_t pl, Int_t noorso){
00638   if(planeNumberFinder(pl)!=-1){
00639     if(noorso<2 && noorso > -1 && PlaneValidity[planeNumberFinder(pl)]==true){
00640       return VetoPlaneClearFiber[planeNumberFinder(pl)][noorso];
00641     } else {
00642       MSG("CandShield",Msg::kWarning) << "GetPlaneClearFiber:Plane " << pl << " is not valid and/or value in 2nd field is out of bounds" << endl;
00643       return -100;
00644     }    
00645   }else {
00646     MSG("CandShield",Msg::kWarning) << "GetPlaneClearFiber:Plane " << pl << " does not exist in the shield!" << endl;
00647     return -100;
00648   }
00649 }
00650 
00651 // ------------------------------------------------------
00652 Bool_t ShieldGeom::PlaneExistsInVeto(Int_t pl) {
00653   if(planeNumberFinder(pl)!=-1){
00654     if(PlaneValidity[planeNumberFinder(pl)]==true){
00655       return true;
00656     }
00657     else {
00658       return false;
00659     }
00660   }else {
00661     return false;
00662   }
00663 }
00664 
00665 // -------------------------------------------------------
00666 Int_t ShieldGeom::WhatSection(Int_t pl){
00667   if(planeNumberFinder(pl)!=-1){
00668     if(PlaneValidity[planeNumberFinder(pl)]==true){
00669       return VetoGeomSection[planeNumberFinder(pl)];
00670     } else{    
00671       MSG("CandShield",Msg::kWarning) << "WhatSection:Plane " << pl << " is not valid!" << endl;
00672       return -1;
00673     }
00674   }else {
00675     MSG("CandShield",Msg::kWarning) << "WhatSection:Plane " << pl << " does not exist in the shield!" << endl;
00676     return -1;
00677   }
00678 }
00679 
00680 // ------------------------------------------------------
00681 Bool_t ShieldGeom::IsPlaneActive(Int_t pl) {
00682   if(planeNumberFinder(pl)!=-1){
00683     return PlaneValidity[planeNumberFinder(pl)];
00684   }
00685   else {
00686     return false;
00687   }    
00688 }
00689 
00690 // ------------------------------------------------------
00691 Int_t ShieldGeom::ValidVetoPlanes() {
00692   
00693   return valid_planes;
00694   
00695 }
00696 
00697 
00698 // -------------------------------------------------------
00699 Double_t ShieldGeom::GetPlaneStrip19_X(Int_t pl) {
00700   if(planeNumberFinder(pl)!=-1){
00701     if(PlaneValidity[planeNumberFinder(pl)]==true){
00702       return VetoGeom_x_s19[planeNumberFinder(pl)];
00703     } else{
00704       MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_X:Plane " << pl << " is not valid!" << endl;
00705       return -100;
00706     }
00707   }else {
00708     MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_X:Plane " << pl << " does not exist in the shield!" << endl;
00709     return -100;
00710   }
00711 }
00712 
00713 // -------------------------------------------------------
00714 Double_t ShieldGeom::GetPlaneStrip19_Y(Int_t pl) {
00715   if(planeNumberFinder(pl)!=-1){
00716     if(PlaneValidity[planeNumberFinder(pl)]==true){
00717       return VetoGeom_y_s19[planeNumberFinder(pl)];
00718     } else{
00719       MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_Y:Plane " << pl << " is not valid!" << endl;
00720       return -100;
00721     }
00722   } else {
00723     MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_Y:Plane " << pl << " does not exist in the shield!" << endl;
00724     return -100;
00725   }
00726 }
00727 
00728 // -------------------------------------------------------
00729 Double_t ShieldGeom::GetPlaneStrip19_Z(Int_t pl) {
00730   if(planeNumberFinder(pl)!=-1){
00731     if(PlaneValidity[planeNumberFinder(pl)]==true){
00732       return VetoGeom_z_s19[planeNumberFinder(pl)];
00733     } else{
00734       MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_Z:Plane " << pl << " is not valid!" << endl;
00735       return -100;
00736     }
00737   } else {
00738     MSG("CandShield",Msg::kWarning) << "GetPlaneStrip19_Z:Plane " << pl << " does not exist in the shield!" << endl;
00739     return -100;
00740   }
00741 }
00742 
00743 // -------------------------------------------------------
00744 Double_t ShieldGeom::GetStrip_X(Int_t pl, Int_t pk){
00745   if(planeNumberFinder(pl)!=-1){
00746     if(PlaneValidity[planeNumberFinder(pl)]==true && pk<20 && pk>=0){
00747       return VetoStrip_x[planeNumberFinder(pl)][pk];
00748     } else {
00749       MSG("CandShield",Msg::kWarning) << "GetStrip_X:Plane " << pl << " is not valid and/or value in 2nd field is out of bounds" << endl;
00750       return -100;
00751     }  
00752   } else {
00753     MSG("CandShield",Msg::kWarning) << "GetStrip_X:Plane " << pl << " does not exist in the shield!" << endl;
00754     return -100;
00755   }
00756 }
00757 
00758 // -------------------------------------------------------
00759 Double_t ShieldGeom::GetStrip_Y(Int_t pl, Int_t pk){  
00760   if(planeNumberFinder(pl)!=-1){
00761     if(PlaneValidity[planeNumberFinder(pl)]==true && pk<20 && pk>=0){
00762       return VetoStrip_y[planeNumberFinder(pl)][pk];
00763     } else {
00764       MSG("CandShield",Msg::kWarning) << "GetStrip_Y:Plane " << pl << " is not valid and/or value in 2nd field is out of bounds" << endl;
00765       return -100;
00766     }    
00767   }else {
00768     MSG("CandShield",Msg::kWarning) << "GetStrip_Y:Plane " << pl << " does not exist in the shield!" << endl;
00769     return -100;
00770   }
00771 }
00772 
00773 // -------------------------------------------------------
00774 Double_t ShieldGeom::GetStrip_Z(Int_t pl, Int_t pk){
00775   if(planeNumberFinder(pl)!=-1){
00776     if(PlaneValidity[planeNumberFinder(pl)]==true && pk<20 && pk>=20){
00777       return VetoStrip_z[planeNumberFinder(pl)][pk];
00778     } else {
00779       MSG("CandShield",Msg::kWarning) << "GetStrip_Z:Plane " << pl << " is not valid and/or value in 2nd field is out of bounds" << endl;
00780       return -100;
00781     }    
00782   } else {
00783     MSG("CandShield",Msg::kWarning) << "GetStrip_Z:Plane " << pl << " does not exist in the shield!" << endl;
00784     return -100;
00785   }
00786 }
00787 
00788 // -------------------------------------------------------
00789 Double_t ShieldGeom::GetStripWls(Int_t pl, Int_t pk, Int_t noorso){
00790   if(planeNumberFinder(pl)!=-1){
00791     if(noorso<2 && noorso > -1 && PlaneValidity[planeNumberFinder(pl)]==true && pk<20 && pk>=0){
00792       return VetoStripWls[planeNumberFinder(pl)][pk][noorso];
00793     } else {
00794       MSG("CandShield",Msg::kWarning) << "GetStripWls:Plane " << pl << " is not valid and/or value in 2nd/3rd fields is/are out of bounds" << endl;
00795       return -100;
00796     }    
00797   } else {
00798     MSG("CandShield",Msg::kWarning) << "GetStripWls:Plane " << pl << " does not exist in the shield!" << endl;
00799     return -100;
00800   }
00801 }
00802 
00803 // ----------------------------------------------------------
00804 Int_t ShieldGeom::WhatSectionAbove(Double_t zpos, Int_t cont){ 
00805   Int_t sectAbove[2]={0};
00806   sectAbove[0]=-1;
00807   sectAbove[1]=-1;
00808   Int_t contsect=0;
00809   for(int sect=0;sect<4;sect++){
00810     if(fabs(zpos-VetoGeom_z[planeNumberFinder(535+sect*64)])<4.){
00811       sectAbove[contsect]=sect+1;
00812       ++contsect;
00813     }
00814   }
00815   if(cont==0 || cont==1){
00816     return sectAbove[cont];
00817   }else {        
00818     MSG("CandShield",Msg::kWarning) << "WhatSectionAbove:Value in second field must be 0 or 1; Only 2 sections can overlap." << endl;
00819     return -1;
00820   }
00821   
00822 }
00823 
00824 // ----------------------------------------------------------
00825 Int_t ShieldGeom::ClosestTwoSections(Double_t zpos, Int_t cont){ 
00826   Int_t sectClosest[2]={0};
00827   sectClosest[0]=-1;
00828   sectClosest[1]=-1;
00829   Int_t contsect=0;
00830   for(int sect=0;sect<4;sect++){
00831     if(fabs(zpos-VetoGeom_z[planeNumberFinder(535+sect*64)])<8.&& contsect<2){
00832       sectClosest[contsect]=sect+1;
00833       ++contsect;
00834     }
00835   }
00836   if(cont==0 || cont==1){
00837     return sectClosest[cont];
00838   }else {        
00839     MSG("CandShield",Msg::kWarning) << "ClosestTwoSections:Value in second field must be 0 or 1." << endl;
00840     return -1;
00841   }
00842   
00843 }

Generated on Sat Nov 21 22:47:43 2009 for loon by  doxygen 1.3.9.1