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

VetoShower.cxx

Go to the documentation of this file.
00001 #include <cassert>
00002 #include <math.h>
00003 #include <vector>
00004 #include <iostream>
00005 
00006 #include "TString.h"
00007 #include "TFile.h"
00008 #include "TMath.h"
00009 
00010 #include "AtNuEvent/AtmosEvent.h"
00011 #include "AtNuEvent/AtmosShower.h"
00012 #include "AtNuEvent/AtmosShieldPlank.h"
00013 #include "MessageService/MsgService.h"
00014 
00015 #include "AtNuUtils/UtilMisc.h"
00016 #include "AtNuUtils/VetoShower.h"
00017 
00018 CVSID("$Id: VetoShower.cxx,v 1.4 2007/01/15 19:52:00 rhatcher Exp $");
00019 
00020 const double WlsFibreN = 1.43;
00021 const double ClearFibreN = 1.6;
00022 const double TimeWin = 100e-9;
00023 
00024 PlankToShw::PlankToShw() {
00025   Plane = 0;
00026   Section = 0;
00027   PlankPE = 0.;
00028   DZ = 0.;
00029   DSteel = 0.;
00030 }
00031 
00032 PlankToShw::PlankToShw(const AtmosShieldPlank *plank, float dz,
00033                        float dsteel) {
00034   Plane = plank->Plane;
00035   Section = plank->Section;
00036   PlankPE = plank->QPE[0] + plank->QPE[1];
00037   DZ = dz;
00038   DSteel = dsteel;
00039 }
00040 
00041 VetoShower::~VetoShower() {
00042   //if(InTimePlanes) delete [] InTimePlanes; InTimePlanes = 0;
00043   //if(SteelToPlanks) delete [] SteelToPlanks; SteelToPlanks = 0;
00044   //if(ZToPlanks) delete [] ZToPlanks; ZToPlanks = 0;
00045   //if(PEPlanks) delete [] PEPlanks; PEPlanks = 0;
00046   delete InTimePlanks;
00047 }
00048 
00049 VetoShower::VetoShower() {
00050   InTimePlanks = new TClonesArray("PlankToShw");
00051   Zero();
00052 }
00053 
00054 VetoShower::VetoShower(const AtmosEvent *event) {
00055   InTimePlanks = new TClonesArray("PlankToShw");
00056   Zero();
00057   Fill(event);
00058 }
00059 
00060 VetoShower::VetoShower(const AtmosShower *shower,
00061                        const TClonesArray *ShieldPlankList) {
00062   InTimePlanks = new TClonesArray("PlankToShw");
00063   Zero();
00064   Fill(shower, ShieldPlankList);
00065 }
00066 
00067 void VetoShower::Zero() {
00068   memset(SectionQInTime, 0, 4*sizeof(double));
00069   memset(SectionQOutTime, 0, 4*sizeof(double));
00070 
00071   VetoQCorrSS = 0;
00072 
00073   //memset(VetoQPlank50cmZ, 0, 10*sizeof(double));
00074   //memset(VetoQPlank10cmSteel, 0, 10*sizeof(double));
00075   for (int i=0; i<1+InTimePlanks->GetLast(); i++){
00076     InTimePlanks->At(i)->Clear();
00077   }
00078   InTimePlanks->Delete();
00079   NInTimePlanks = 0;
00080 }
00081 
00082 void VetoShower::Fill(const AtmosEvent *event) {
00083   //This assumes a single shower over which to find the veto correlation
00084   const AtmosShower* shower =
00085     dynamic_cast<const AtmosShower*>(event->ShowerList->At(0));
00086   if(!shower) return;
00087 
00088   if(event->NShieldPlanks == 0) return;
00089   if(!(event->ShieldPlankList)) return;
00090 
00091   Fill(shower, event->ShieldPlankList);
00092 }
00093 
00094 void VetoShower::Fill(const AtmosShower *shower,
00095                       const TClonesArray *ShieldPlankList) {
00096   assert(shower);
00097   assert(ShieldPlankList);
00098   Zero();
00099 
00100   //vector<int> itp;//Temporary for InTimePlanes
00101   //vector<double> stp;//Temporary for SteelToPlanks
00102   //vector<double> ztp;//Temporary for ZToPlanks
00103   //vector<double> pep;//Temporary for PEPlanks
00104 
00105   const double VtxX = shower->VtxX;
00106   const double VtxY = shower->VtxY;
00107   const double VtxZ = shower->VtxZ;
00108   const double VtxTime = shower->VtxTime;
00109 
00110   //Which sections of the shield do we care about?
00111   int vtx_section(0);
00112   if (VtxZ>0.0 && VtxZ<15) {//sm1
00113     if(VtxZ<8.5) vtx_section|=1;
00114     if(VtxZ>6.9) vtx_section|=2;
00115   }
00116   else if (VtxZ>15.5 && VtxZ<31.0) {//sm2
00117     if(VtxZ<23.9) vtx_section|=4;
00118     if(VtxZ>21.8) vtx_section|=8;
00119   }
00120 
00121   const int nplanks = (int)(ShieldPlankList->GetEntries());
00122   double DTime[2] = {0., 0.};
00123   for (int iplnk=0; iplnk<nplanks; iplnk++) {
00124     const AtmosShieldPlank* plank =
00125       dynamic_cast<const AtmosShieldPlank*>
00126       (ShieldPlankList->At(iplnk));
00127     assert(plank);
00128 
00129     //Delta T Vtx
00130     for (unsigned int iend=0; iend<2; iend++) {
00131       DTime[iend] = plank->Tcal[iend];
00132       DTime[iend] -= plank->WlsPigtail[iend]*WlsFibreN/TMath::C();
00133       DTime[iend] -= plank->ClearFibre[iend]*ClearFibreN/TMath::C();
00134       DTime[iend] -= TMath::Abs(VtxZ-plank->Z[iend])*WlsFibreN/TMath::C();
00135     }
00136 
00137     //Add to veto counts if shield hit is in-time with event
00138     if ((plank->QPE[0]>0 && TMath::Abs(DTime[0]-VtxTime)<TimeWin) ||
00139         (plank->QPE[1]>0 && TMath::Abs(DTime[1]-VtxTime)<TimeWin)) {
00140       SectionQInTime[plank->Section-1] += plank->QPE[0]+plank->QPE[1];
00141 
00142       if ((1<<(plank->Section-1)&(vtx_section))) {
00143         VetoQCorrSS += plank->QPE[0]+plank->QPE[1];
00144       }
00145 
00146       //itp.push_back(plank->Plane);
00147       //pep.push_back(plank->QPE[0]+plank->QPE[1]);
00148 
00149       bool ShwUnderPlank(false);
00150       if(plank->Z[0] < plank->Z[1]) 
00151         ShwUnderPlank =
00152           (plank->Z[0] < VtxZ && VtxZ < plank->Z[1]);
00153       else
00154         ShwUnderPlank =
00155           (plank->Z[1] < VtxZ && VtxZ < plank->Z[0]);
00156 
00157       double DZ(0.);
00158       if(!ShwUnderPlank) DZ = TMath::Min(TMath::Abs(plank->Z[0]-VtxZ),
00159                                          TMath::Abs(plank->Z[1]-VtxZ));
00160       //ztp.push_back(DZ);
00161       
00162       double SteelToPlank(0.);
00163       double RP(0.);
00164       if (!ShwUnderPlank) {
00165         RP = TMath::Sqrt((DZ*DZ) + 
00166                ((plank->X-VtxX)*(plank->X-VtxX)) +
00167                ((plank->X-VtxX)*(plank->X-VtxX)) );
00168         double ShwVtx[3] = {VtxX, VtxY, VtxZ};
00169         double ShwCos[3];
00170         ShwCos[0] = (plank->X-VtxX) / RP;
00171         ShwCos[1] = (plank->Y-VtxY) / RP;
00172         ShwCos[2] = (DZ) / RP;
00173         double DetVtx[3];
00174         int Side = UtilMisc::DetectorWall(ShwVtx, ShwCos, DetVtx);
00175         if (Side==9 || Side==10) {
00176           MSG("VetoShower",Msg::kDebug) << "Cross on SM Gap" << endl;
00177         }
00178         SteelToPlank = TMath::Abs((ShwVtx[2]-DetVtx[2])/ShwCos[2]);
00179         SteelToPlank = SteelToPlank * 2.54 / 5.99;
00180       }
00181       //stp.push_back(SteelToPlank);
00182       new((*InTimePlanks)[NInTimePlanks++]) PlankToShw(plank, DZ, SteelToPlank);
00183 
00184       /*
00185       for (int i=0; i<10; i++) {
00186         if (SteelToPlank <= i*0.1) {
00187           VetoQPlank10cmSteel[i] += plank->QPE[0]+plank->QPE[1];
00188         }
00189       }
00190 
00191       for (int i=0; i<10; i++) {
00192         if (DZ <= i*0.5) {
00193           VetoQPlank50cmZ[i] += plank->QPE[0]+plank->QPE[1];
00194         }
00195       }
00196       */
00197     }
00198     else {
00199       SectionQOutTime[plank->Section-1] += plank->QPE[0]+plank->QPE[1];
00200     }
00201   }
00202 
00203   //Put the itp vector in the C-style array InTimePlanes
00204   /*
00205   NPlanksInTime = itp.size();
00206   if (NPlanksInTime > 0) {
00207     InTimePlanes = new int[NPlanksInTime];
00208     SteelToPlanks = new double[NPlanksInTime];
00209     ZToPlanks = new double[NPlanksInTime];
00210     PEPlanks = new double[NPlanksInTime];
00211     for (int i=0; i<NPlanksInTime; i++) {
00212       InTimePlanes[i] = itp[i];
00213       SteelToPlanks[i] = stp[i];
00214       ZToPlanks[i] = ztp[i];
00215       PEPlanks[i] = pep[i];
00216     }
00217   }
00218   */
00219 }

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