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

NCAnalysisCutsNC.cxx

Go to the documentation of this file.
00001 
00002 //$Id: NCAnalysisCutsNC.cxx,v 1.13 2009/11/23 16:54:04 rodriges Exp $
00003 //
00004 //NCAnalysisCutsNC.cxx
00005 //
00006 //utility holding analysis cut algorithms
00007 //
00008 //B. Rebel 10/2005
00010 
00011 #include "NCUtils/Cuts/NCAnalysisCutsNC.h"
00012 #include "NCUtils/NCType.h"
00013 #include "NCUtils/NCUtility.h"
00014 #include "AnalysisNtuples/ANtpEventInfoNC.h"
00015 #include "AnalysisNtuples/ANtpShowerInfoNC.h"
00016 #include "AnalysisNtuples/ANtpBeamInfo.h"
00017 #include "AnalysisNtuples/ANtpHeaderInfo.h"
00018 #include "AnalysisNtuples/ANtpTrackInfoNC.h"
00019 #include "AnalysisNtuples/ANtpTruthInfoBeam.h"
00020 #include "AnalysisNtuples/ANtpRecoInfo.h"
00021 #include "MessageService/MsgService.h"
00022 #include "Conventions/Detector.h"
00023 #include "Conventions/Munits.h"
00024 #include "Conventions/SimFlag.h"
00025 #include "Conventions/PlaneView.h"
00026 #include "Conventions/PlaneCoverage.h"
00027 #include "DataUtil/PlaneOutline.h"
00028 
00029 #include "TMath.h"
00030 
00031 using namespace BeamType;
00032 using std::vector;
00033 using NC::Utility::SQR;
00034 
00035 CVSID("$Id: NCAnalysisCutsNC.cxx,v 1.13 2009/11/23 16:54:04 rodriges Exp $");
00036 // modified on 10 Nov,2009 by J. de Jong for FD cleaning
00037 //----------------------------------------------------------------------
00038 NCAnalysisCutsNC::NCAnalysisCutsNC() :
00039   NCAnalysisCuts()
00040 {
00041 }
00042 
00043 //----------------------------------------------------------------------
00044 NCAnalysisCutsNC::~NCAnalysisCutsNC()
00045 {
00046 }
00047 
00048 //----------------------------------------------------------------------
00049 bool NCAnalysisCutsNC::IsGoodBeamEvent()
00050 {
00051   // Note: Fiducial cut is done seperatly, but data will not be 
00052   // clean without it
00053 
00054   // Find out if this is MC or data, and the software versions
00055   ReleaseType::Release_t softType( NCAnalysisCuts::GetReleaseType() );
00056   Bool_t isMC( ReleaseType::IsMC(softType) );
00057 
00058   //near detector cleaning is done in the filling of the uDST
00059   //by a separate call to IsCleanHighMultSnarl
00060   if ( fEventInfo.header->detector == Detector::kNear ) return true;
00061 
00062   /*
00063   if ( ReleaseType::IsBirch(softType) ){  
00064     // R1.18.2 style mainEvt cut done here. 
00065     // Need to tweak MC to fix the lack of noise problem. Not ideal.
00066     // (Note: to be consistent we should technically tweak the snarlPE
00067     // variable as well, to adjust the LI PE cut but the effect on the
00068     // efficiency there is negligble)
00069     UInt_t tweakedEvents(0);
00070     Double_t tweakedPH(0.);
00071     if ( isMC )  NCAnalysisCuts::RollBirchMCSnarlNoise(tweakedEvents, tweakedPH);
00072     
00073     // `overlay' (...after a fashion...)  the event onto the noise.
00074     tweakedEvents += fEventInfo.header->events;
00075     tweakedPH += fEventInfo.header->snarlPulseHeight;
00076     
00077     // now do mainEvt cut. also remove zero (real) event snarls
00078     if (fEventInfo.header->events == 0) return false;
00079     if ( ( tweakedEvents == 2 
00080            && tweakedPH - fEventInfo.event->pulseHeight > 1e4 )
00081          || tweakedEvents > 2 ) return false;  
00082     // [now wash your hands]
00083     
00084   }  // if (birch/R1.18.2)
00085   else*/ {
00086     //Cedar Style mainevt cut  also remove 0 event snarls.
00087     if (fEventInfo.header->events == 0) return false;
00088     //check for div by 0. hould'nt happen with >0 evt snarls, but hey. 
00089     if (fEventInfo.header->snarlPulseHeight==0.)  return false;
00090     Float_t evtPHfrac(fEventInfo.event->pulseHeight
00091                       / fEventInfo.header->snarlPulseHeight);
00092     if ( ( fEventInfo.header->events == 2 && evtPHfrac < 0.75)
00093          || fEventInfo.header->events > 2 ) return false;
00094   }  // if ( !birch )
00095     
00096   // Normal background cuts
00097   if(IsCosmicInSpillOx()) return false;
00098 
00099   if(IsFibreNoiseInSpillOx()) return false;
00100 
00101   if(IsLIInSpillOx()) return false;
00102   
00103   // Timing cut. Data only
00104   if(!isMC){
00105     double dt_spill = fEventInfo.event->stripTime1st * Munits::s;
00106     dt_spill -= fEventInfo.beam->nearestNSToSpill * Munits::ns;
00107     
00108     if ( dt_spill < -2. * Munits::microsecond 
00109          || dt_spill > 12. * Munits::microsecond ){
00110       return false;
00111     } 
00112   }
00113 
00114   // Survived all cuts
00115   return true;
00116 }
00117 
00118 //----------------------------------------------------------------------
00119 bool NCAnalysisCutsNC::IsStoppingBeamMuon()
00120 {
00121   bool stoppingMuon = false;
00122 
00123   bool endZOK = false;
00124   bool xyOK = false;
00125 
00126   if(fEventInfo.header->detector==(int)Detector::kFar){
00127     if((fEventInfo.track->endZ > 0.5
00128         && fEventInfo.track->endZ < 12.)
00129        || (fEventInfo.track->endZ > 16.5
00130            && fEventInfo.track->endZ < 28.))
00131       endZOK = true;
00132 
00133     if(TMath::Sqrt(fEventInfo.track->endX*fEventInfo.track->endX
00134                    +fEventInfo.track->endY*fEventInfo.track->endY) < 3.5)
00135       xyOK = true;
00136 
00137     if(TMath::Abs(fEventInfo.track->traceEndZ) > 0.5 && xyOK && endZOK)
00138       stoppingMuon = true;
00139   }
00140   else if(fEventInfo.header->detector==(int)Detector::kNear){
00141 
00142     //see position paper on ND flux by Kordosky and Dorman in DocDB for
00143     //definition of the fiducial volume
00144 
00145     double u = TMath::Sqrt(0.5)*(fEventInfo.track->endX+fEventInfo.track->endY);
00146     double v = TMath::Sqrt(0.5)*(fEventInfo.track->endY-fEventInfo.track->endX);
00147 
00148     if(0.3 < u && u < 1.8
00149        && -1.8 < v && v < -0.3
00150        && fEventInfo.track->endX < 2.4
00151        && TMath::Sqrt(u*u + v*v) > 0.8
00152        && fEventInfo.track->endZ < 15. ) stoppingMuon = true;
00153 
00154   }
00155 
00156   return stoppingMuon;
00157 }
00158 
00159 //---------------------------------------------------------------------
00160 bool NCAnalysisCutsNC::InBeamFiducialVolume()
00161 {
00162   // only in FD FidVol if at FD
00163   if (fEventInfo.header->detector  == (int)Detector::kFar){
00164 
00165     // Get distance to edge, distance to center & vertex z.
00166     // Use track if available and longer than the shower
00167     // RPL 16/11/06: Adjust track vertices to be consistent with event
00168     // vertices, see MINOS-doc-2409
00169 
00170     Float_t dist_edge(fEventInfo.event->vtxMetersToCloseEdge);
00171     Float_t dist_coil(fEventInfo.event->vtxMetersToCoil);
00172     Float_t vtxZ(fEventInfo.event->vtxZ);
00173     if ( (fEventInfo.event->tracks > 0)
00174          && ( (fEventInfo.track->planes - fEventInfo.shower->planes)>0)) {
00175       dist_edge = fEventInfo.track->vtxMetersToCloseEdge;
00176       dist_coil = fEventInfo.track->vtxMetersToCoil;
00177       vtxZ = fEventInfo.track->vtxZ - NCType::kTrackVtxAdjustment;
00178     }
00179 
00180     // RPL 16/11/06 Adjust cut values by -3.92 cm to be constent with
00181     // vertex definition.
00182 
00183     // Longitudinal cuts: > 4 Scint planes from SM fronts...
00184     //  \-> vZ > 0.2328m (SM1),  vZ > 16.1408m (SM2)
00185     // ...and >1m from SM ends...
00186     //  \-> vZ < 13.6208m (SM1),  vZ < 28.8608m (SM2)
00187     // ...adjusted (tightened) to be at center of an air gap
00188     if ( vtxZ < 0.2328 * Munits::m || vtxZ > (28.8608+0.119) * Munits::m ) return false;
00189     if ( vtxZ > (13.6208+0.119) * Munits::m && vtxZ < 16.1408 * Munits::m ) return false;
00190 
00191     // Transverse cuts: 50cm from edge => 7m (edge2edge) octagon
00192 //    if ( dist_edge < 0.5 * Munits::m ) return false;
00193     if ( dist_edge < 0.4 * Munits::m ) return false;
00194 
00195     // Coil hole cut: > 0.45m radius around center
00196 //    if ( dist_coil < 0.45 * Munits::m ) return false;
00197     if ( dist_coil < 0.6 * Munits::m ) return false;
00198   } //end if far
00199 
00200   //only in ND FidVol if at ND
00201   else if(fEventInfo.header->detector  == (int)Detector::kNear){
00202 
00203     //Get distance to edge & vertex z.
00204     // Use track if available and longer than the shower
00205     // RPL 08/03/07: Adjust track vertices to be consistent with event
00206     // vertices, as in FD. see MINOS-doc-2409
00207     Float_t dist_edge(fEventInfo.event->vtxMetersToCloseEdge);
00208     Float_t vtxZ(fEventInfo.event->vtxZ);
00209     if ( (fEventInfo.event->tracks > 0)
00210          && ( (fEventInfo.track->planes - fEventInfo.shower->planes)>0) ) {
00211       dist_edge = fEventInfo.track->vtxMetersToCloseEdge;
00212       vtxZ = fEventInfo.track->vtxZ - NCType::kTrackVtxAdjustment;
00213     }
00214 
00215     // Longitudinal cuts: slightly smaller than golden region,
00216     // to reduce # of showers getting into the spectrometer
00217     // Start  1/2 way between reco planes 30 & 31
00218     // Finish 1/2 way between reco planes 80 & 81
00219     if ( vtxZ > 4.7368 * Munits::m || vtxZ < 1.7 * Munits::m ) return false;
00220 
00221     // Transverse cuts:
00222     // Use a Detector-oriented set of cuts, since beam oriented cuts
00223     // are only apropriate for much smaller fiducial regions
00224     if ( dist_edge < 0.5 * Munits::m ) return false;
00225 
00226     //No coil hole cut since transvers cuts are based on partial plane
00227   }// end if near
00228 
00229   // All cuts were passed.
00230   return true;
00231 }
00232 
00233 //---------------------------------------------------------------------
00234 bool NCAnalysisCutsNC::InFiducialVolumeTrue()
00235 {
00236   Detector::Detector_t det = Detector::kFar;
00237   PlaneCoverage::PlaneCoverage_t outline = PlaneCoverage::kComplete;
00238   if(fEventInfo.header->detector == (int)Detector::kNear){
00239     det = Detector::kNear;
00240     outline = PlaneCoverage::kNearPartial;
00241   }
00242 
00243   PlaneOutline po;
00244   float distU = 0.;
00245   float distV = 0.;
00246   float xedge = 0.;
00247   float yedge = 0.;
00248   float x = fEventInfo.truth->nuVtxX;
00249   float y = fEventInfo.truth->nuVtxY;
00250   float z = fEventInfo.truth->nuVtxZ;
00251 
00252   po.DistanceToOuterEdge(x, y, PlaneView::kU, 
00253                          outline, distU, xedge, yedge);
00254   po.DistanceToOuterEdge(x, y, PlaneView::kV, 
00255                          outline, distV, xedge, yedge);
00256 
00257   bool insideU = false;
00258 
00259   if ( outline != PlaneCoverage::kNearPartial ) {
00260     // circle of radius 1/sqrt(2) will enclose the coilHole, 
00261     // but is itself enclosed by the outer edges
00262     insideU = ( (x*x + y*y) < 0.5 * Munits::m2 );
00263     //cout << "X: " << x << ";   Y: " 
00264     //     << y << ";   inside:" << insideU << endl;
00265   }
00266     
00267   bool insideV = insideU;
00268   if ( !insideU ){ 
00269     insideU = po.IsInside(x, y, PlaneView::kU, outline);
00270     insideV = po.IsInside(x, y, PlaneView::kV, outline);
00271   }
00272   distU *= ( insideU ? 1. : -1. );
00273   distV *= ( insideV ? 1. : -1. );
00274 
00275   float vtxMetersToCloseEdge = 0.5*(distU + distV);
00276   float vtxMetersToCoil = TMath::Sqrt(x*x + y*y);
00277 
00278   //based on oxford fiducial volume.
00279   // only in FD FidVol if at FD  
00280   if(det == Detector::kFar){
00281     
00282     // Longitudinal cuts: > 4 Scint planes from SM fronts...
00283     //  \-> vZ > 0.2328m (SM1),  vZ > 16.1408m (SM2)
00284     // ...and >1m from SM ends...
00285     //  \-> vZ < 13.6208m (SM1),  vZ < 28.8608m (SM2)
00286     // ...adjusted (tightened) to be at center of an air gap
00287     // decrease end of SM by ~2 planes
00288     if ( z < 0.2328*Munits::m || z > (28.8608+0.119) * Munits::m ) return false;
00289     if ( z > (13.6208+0.119)*Munits::m && z < 16.1408 * Munits::m ) return false;
00290     
00291     // Transverse cuts: 50cm from edge => 7m (edge2edge) octagon 
00292 //    if ( vtxMetersToCloseEdge < 0.5 * Munits::m ) return false;
00293     if ( vtxMetersToCloseEdge < 0.4 * Munits::m ) return false;
00294     
00295     // Coil hole cut: > 0.45m radius around center
00296 //    if ( vtxMetersToCoil < 0.45 * Munits::m ) return false; 
00297     if ( vtxMetersToCoil < 0.6 * Munits::m ) return false; 
00298   } //end if far
00299   
00300   //only in ND FidVol if at ND  
00301   else if(det == Detector::kNear){
00302       
00303     // Longitudinal cuts: slightly smaller than golden region,
00304     // to reduce # of showers getting into the spectrometer
00305     // Start  1/2 way between reco planes 30 & 31
00306     // Finish 1/2 way between reco planes 80 & 81
00307     if ( z > 4.7368 * Munits::m || z < 1.728 * Munits::m ) return false;
00308     
00309     // Transverse cuts:
00310     // Use a Detector-oriented set of cuts, since beam oriented cuts 
00311     // are only apropriate for much smaller fiducial regions
00312     if ( vtxMetersToCloseEdge < 0.5 * Munits::m ) return false;
00313     
00314     //No coil hole cut since transvers cuts are based on partial plane    
00315   }// end if near
00316   
00317   return true;
00318 }
00319 
00320 //----------------------------------------------------------------------
00321 bool NCAnalysisCutsNC::PassesFinalSelection()
00322 {
00323   if(!InBeamFiducialVolume()) return false;
00324   return true;
00325 }
00326 
00327 //----------------------------------------------------------------------
00328 bool NCAnalysisCutsNC::PassesFinalSelection(ANtpRecoInfo *recoInfo)
00329 {
00330   if(recoInfo->inFiducialVolume < 1)  return false;
00331   return true;
00332 }
00333 
00334 //----------------------------------------------------------------------
00335 bool NCAnalysisCutsNC::IsFibreNoiseInSpillOx()
00336 {
00337   ReleaseType::Release_t softType(GetReleaseType());
00338 
00339   // New cuts based on dogwood data
00340   if(ReleaseType::IsCedar(softType))
00341     {
00342       
00343       if(fEventInfo.event->pulseHeight < 2500 &&
00344          fEventInfo.event->totalStrips <= 8) return true;
00345       
00346       //Expand the cut area in chopped data
00347       //      ReleaseType::Release_t softType(GetReleaseType());
00348       if(!ReleaseType::IsBirch(softType))
00349       {
00350         if(fEventInfo.event->pulseHeight < 5000 &&
00351            fEventInfo.event->totalStrips <= 4) return true;
00352       }
00353     }
00354   else
00355     {
00356       if(fEventInfo.event->pulseHeight < 3750 &&
00357          fEventInfo.event->totalStrips <= 8) return true;
00358       if(fEventInfo.event->pulseHeight < 2000 &&
00359          fEventInfo.event->totalStrips > 8) return true;
00360 
00361     }
00362   return false;
00363 }
00364 
00365 
00366 //----------------------------------------------------------------------
00367 bool NCAnalysisCutsNC::IsCosmicInSpillOx()
00368 {
00369   //Ultra-steep showers
00370   Float_t strips_f(fEventInfo.event->totalStrips);
00371   Float_t planes_f(fEventInfo.event->planes);
00372   if ( planes_f == 0.0 || strips_f/(planes_f*planes_f) >= 1 ) return true;
00373 
00374 
00375   //Steep showers
00376   if ( fEventInfo.event->showers > 0 ){
00377     Float_t tRMS2 = SQR(fEventInfo.shower->transverseRMSU);
00378     tRMS2          += SQR(fEventInfo.shower->transverseRMSV);
00379     Float_t tRMS = TMath::Sqrt( tRMS2 );
00380     if ( ( 0.3 + 0.1901*TMath::Log10(planes_f) ) < tRMS ) return true;
00381   } //event.showers > 0
00382 
00383 
00384   if ( fEventInfo.event->tracks > 0 ){
00385     //Track angle
00386     if ( fEventInfo.track->dcosZVtx < 0.4 ) return true;
00387 
00388     //Stopping muons
00389     Bool_t upExitTrack(false);
00390     if ( ( fEventInfo.track->endZ > 28.78
00391            || fEventInfo.track->endMetersToCloseEdge < 0.5 )
00392          && fEventInfo.track->endY > -1.657 ) upExitTrack = true;
00393 
00394     if ( upExitTrack
00395          && fEventInfo.track->dtdz < -0.5
00396          && -fEventInfo.track->dcosYVtx < -0.4 ) return true;
00397 
00398   } // event.tracks > 0
00399 
00400   // Got here => is not a cosmic.
00401   return false;
00402 }
00403 
00404 //----------------------------------------------------------------------
00405 bool NCAnalysisCutsNC::IsLIInSpillOx()
00406 {
00407   //RPL 11/07/07:
00408   // removed snarlPE > 8000 cut as it is not really necessary.
00409   ReleaseType::Release_t softType(GetReleaseType());
00410 
00411   // New cuts based on dogwood data
00412   if(ReleaseType::IsCedar(softType))
00413    {
00414       return fEventInfo.header->isLIold || fEventInfo.header->triggerPMTTime > 0;
00415     }
00416    else // new cuts based on dogwood
00417     {
00418        return fEventInfo.header->isLI || fEventInfo.header->triggerPMTTime > 0;
00419     }
00420 }

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