00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "NCUtils/Cuts/NCAnalysisCuts.h"
00012 #include "NCUtils/NCType.h"
00013 #include "NCUtils/NCUtility.h"
00014 #include "AnalysisNtuples/ANtpDefaultValue.h"
00015 #include "AnalysisNtuples/ANtpEventInfoNC.h"
00016 #include "AnalysisNtuples/ANtpShowerInfoNC.h"
00017 #include "AnalysisNtuples/ANtpBeamInfo.h"
00018 #include "AnalysisNtuples/ANtpHeaderInfo.h"
00019 #include "AnalysisNtuples/ANtpTrackInfoNC.h"
00020 #include "AnalysisNtuples/ANtpTruthInfoBeam.h"
00021 #include "AnalysisNtuples/ANtpRecoInfo.h"
00022 #include "MessageService/MsgService.h"
00023 #include "Conventions/Detector.h"
00024 #include "Conventions/Munits.h"
00025 #include "Conventions/SimFlag.h"
00026 #include "Conventions/PlaneView.h"
00027 #include "Conventions/PlaneCoverage.h"
00028 #include "DataUtil/PlaneOutline.h"
00029 #include "DataUtil/EnergyCorrections.h"
00030
00031 #include "TMath.h"
00032
00033 #include <cassert>
00034
00035 using namespace EnergyCorrections;
00036 using NC::Utility::SQR;
00037
00038 CVSID("$Id: NCAnalysisCuts.cxx,v 1.27 2009/12/02 14:21:12 tinti Exp $");
00039
00040
00041 NCAnalysisCuts::NCAnalysisCuts() :
00042 fBeamType(BeamType::kUnknown),
00043 fCurrentRun(-1),
00044 fCurrentSnarl(-1),
00045 fCurrentSubRun(-1)
00046 {
00047 }
00048
00049
00050 NCAnalysisCuts::~NCAnalysisCuts()
00051 {
00052 }
00053
00054
00055
00056
00057
00058 bool NCAnalysisCuts::IsGoodTarget()
00059 {
00060 bool goodTarget = false;
00061
00062 BeamType::BeamType_t bt = (BeamType::BeamType_t)(fEventInfo.beam->beamType);
00063
00064 bool is185i = (bt == BeamType::kL010z185i
00065 || bt == BeamType::kL010z185i_lowintensity);
00066 bool isL010z = (bt == BeamType::kL010z185i
00067 || bt == BeamType::kL010z185i_lowintensity
00068 || bt == BeamType::kL010z000i
00069 || bt == BeamType::kL010z170i
00070 || bt == BeamType::kL010z200i);
00071
00072
00073
00074 if(fUseAllBeams)
00075 goodTarget = true;
00076 else if(fBeamType == BeamType::kL100z200i && bt == fBeamType)
00077 goodTarget = true;
00078 else if(fBeamType == BeamType::kL250z200i && bt == fBeamType)
00079 goodTarget = true;
00080 else if(fBeamType == BeamType::kL010z185i
00081 && !fUseAll185i && !fUseAllL010z && bt == fBeamType)
00082 goodTarget = true;
00083 else if(fBeamType == BeamType::kL010z170i
00084 && !fUseAllL010z && bt == fBeamType)
00085 goodTarget = true;
00086 else if(fBeamType == BeamType::kL010z200i
00087 && !fUseAllL010z && bt == fBeamType)
00088 goodTarget = true;
00089 else if(fBeamType == BeamType::kL010z185i_lowintensity
00090 && !fUseAll185i && !fUseAllL010z && bt == fBeamType)
00091 goodTarget = true;
00092 else if(fBeamType == BeamType::kL010z000i
00093 && !fUseAllL010z && bt == fBeamType)
00094 goodTarget = true;
00095 else if(fUseAllL010z && isL010z)
00096 goodTarget = true;
00097 else if(fUseAll185i && is185i)
00098 goodTarget = true;
00099
00100
00101 MAXMSG("NCAnalysisCuts", Msg::kDebug, 10) << fEventInfo.beam->beamType << " "
00102 << BeamType::AsString(bt) << " "
00103 << goodTarget << " "
00104 << (int)fUseAllBeams << " "
00105 << is185i << " " << isL010z << endl;
00106
00107
00108 return goodTarget;
00109 }
00110
00111
00112 bool NCAnalysisCuts::IsNewSnarl()
00113 {
00114 bool newSnarl = false;
00115
00116 if(fEventInfo.header->run != fCurrentRun){
00117 newSnarl = true;
00118 fCurrentRun = fEventInfo.header->run;
00119 fCurrentSubRun = fEventInfo.header->subRun;
00120 fCurrentSnarl = fEventInfo.header->snarl;
00121 }
00122 else if(fEventInfo.header->run == fCurrentRun &&
00123 fEventInfo.header->subRun != fCurrentSubRun){
00124 newSnarl = true;
00125 fCurrentRun = fEventInfo.header->run;
00126 fCurrentSubRun = fEventInfo.header->subRun;
00127 fCurrentSnarl = fEventInfo.header->snarl;
00128 }
00129 else if(fEventInfo.header->run == fCurrentRun &&
00130 fEventInfo.header->subRun == fCurrentSubRun &&
00131 fEventInfo.header->snarl != fCurrentSnarl){
00132 newSnarl = true;
00133 fCurrentRun = fEventInfo.header->run;
00134 fCurrentSubRun = fEventInfo.header->subRun;
00135 fCurrentSnarl = fEventInfo.header->snarl;
00136 }
00137
00138 return newSnarl;
00139 }
00140
00141
00142
00143 bool NCAnalysisCuts::IsMultiCutsClean()
00144 {
00145
00146 if(TMath::Abs(fEventInfo.event->minTimeSeparation) < 35e-9) return false;
00147
00148
00149 if(fEventInfo.event->totalStrips < 5) return false;
00150
00151
00152 if(fEventInfo.event->totalStrips/SQR(fEventInfo.event->planes)>1.15)
00153 return false;
00154
00155
00156
00157 if(fEventInfo.event->edgeActivityStrips > 2 &&
00158 fEventInfo.event->edgeActivityPH > 1000 &&
00159 fEventInfo.event->energyGeV < 5.0 &&
00160 fEventInfo.shower->planes > fEventInfo.track->planes)
00161 return false;
00162
00163
00164 if(fEventInfo.event->oppEdgeStrips > 2 &&
00165 fEventInfo.event->energyGeV < 5.0 &&
00166 fEventInfo.shower->planes > fEventInfo.track->planes)
00167 return false;
00168
00169
00170 if(TMath::Abs(fEventInfo.event->closeTimeDeltaZ) < 1.0 &&
00171 TMath::Abs(fEventInfo.event->minTimeSeparation) < 175e-9)
00172 return false;
00173
00174
00175 return true;
00176 }
00177
00178
00179 bool NCAnalysisCuts::IsSimpleCutsClean()
00180 {
00181
00182 if(TMath::Abs(fEventInfo.event->minTimeSeparation) < 155e-9)
00183 return false;
00184
00185
00186 if(fEventInfo.event->slicePHFraction<0.9) return false;
00187
00188
00189
00190
00191 if(fEventInfo.event->sharedStripFraction>0.3 &&
00192 ((-fEventInfo.shower->planes + fEventInfo.track->planes)<=5.))
00193 return false;
00194
00195
00196 return true;
00197 }
00198
00199
00200 bool NCAnalysisCuts::IsCleanLowMultSnarl()
00201 {
00202 return fEventInfo.header->events == 1 ||
00203 (fEventInfo.header->events == 2 &&
00204 TMath::Abs(fEventInfo.event->minTimeSeparation*1e6) > 0.2);
00205 }
00206
00207
00208 void NCAnalysisCuts::SetInfoObjects(ANtpHeaderInfo* headerInfo,
00209 ANtpBeamInfo* beamInfo,
00210 ANtpEventInfoNC* eventInfo,
00211 ANtpTrackInfoNC* trackInfo,
00212 ANtpShowerInfoNC* showerInfo,
00213 ANtpTruthInfoBeam* truthInfo)
00214 {
00215 fEventInfo.header = headerInfo;
00216 fEventInfo.beam = beamInfo;
00217 fEventInfo.event = eventInfo;
00218 fEventInfo.track = trackInfo;
00219 fEventInfo.shower = showerInfo;
00220 fEventInfo.truth = truthInfo;
00221 }
00222
00223
00224 void NCAnalysisCuts::SetBeamType(BeamType::BeamType_t type)
00225 {
00226 fBeamType = type;
00227 }
00228
00229
00230 void NCAnalysisCuts::SetUseAllBeams(bool useAll)
00231 {
00232 fUseAllBeams = useAll;
00233 }
00234
00235
00236 void NCAnalysisCuts::SetUseAllL010z(bool useAll)
00237 {
00238 fUseAllL010z = useAll;
00239 }
00240
00241
00242 void NCAnalysisCuts::SetUseAll185i(bool useAll)
00243 {
00244 fUseAll185i = useAll;
00245 }
00246
00247
00248 bool NCAnalysisCuts::IsGoodSpill()
00249 {
00250
00251
00252
00253 if(fEventInfo.header->dataType == int(SimFlag::kMC)) return true;
00254
00255 if(!IsGoodTarget()) return false;
00256
00257
00258
00259
00260 if(fEventInfo.beam->goodSpill < 1 ||
00261 (fEventInfo.header->detector == int(Detector::kFar) &&
00262 fEventInfo.beam->deltaSecToSpillGPS < 360 &&
00263 fEventInfo.beam->gpsError > 1000) ||
00264 fEventInfo.header->spillType == 3)
00265 return false;
00266
00267 return true;
00268 }
00269
00270
00271 bool NCAnalysisCuts::IsGoodBeamSnarl()
00272 {
00273
00274 if(fEventInfo.header->dataType == int(SimFlag::kMC)) return true;
00275
00276
00277
00278 if(fEventInfo.header->coilStatus < 1 ||
00279 (fEventInfo.header->detector == int(Detector::kFar) &&
00280 fEventInfo.header->isGoodData < 1))
00281 return false;
00282
00283
00284 if(!IsGoodSpill()) return false;
00285
00286 if(fEventInfo.header->detector == int(Detector::kNear) &&
00287 (fEventInfo.header->coilCurrent > -1000 ||
00288 fEventInfo.header->isGoodData < 1))
00289 return false;
00290
00291 return true;
00292 }
00293
00294
00295
00296
00297
00298 bool NCAnalysisCuts::IsGoodShower()
00299 {
00300
00301
00302 if( fEventInfo.header->softVersion.Contains("Cedar") ){
00303 const EnergyCorrections::CorrectionVersion_t ver = EnergyCorrections::kCedar;
00304 SetCorrectionVersion(ver);
00305 }
00306 else if( fEventInfo.header->softVersion.Contains("Birch") ){
00307 const EnergyCorrections::CorrectionVersion_t ver = EnergyCorrections::kBirch;
00308 SetCorrectionVersion(ver);
00309 }
00310
00311
00312 bool isdata = true;
00313 if(fEventInfo.header->dataType == (int)SimFlag::kMC) isdata = false;
00314
00315 Detector::Detector_t det = Detector::kNear;
00316 if(fEventInfo.header->detector == (int)Detector::kFar)
00317 det = Detector::kFar;
00318
00319 double showerEnergy;
00320
00321 if(fEventInfo.shower->linearCCGeV > 0.){
00322 showerEnergy = CorrectShowerEnergy(fEventInfo.shower->linearCCGeV,
00323 det,
00324 CandShowerHandle::kCC,
00325 1, isdata);
00326 }
00327 else showerEnergy = ANtpDefaultValue::kDouble;
00328
00329 if(fEventInfo.event->tracks < 1
00330 || TMath::Abs(fEventInfo.shower->vtxZ - fEventInfo.track->aTrkvtx_ns) < 0.5
00331 || showerEnergy > 2. )
00332 return true;
00333
00334 return false;
00335 }
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 Int_t NCAnalysisCuts::GetReleaseType()
00383 {
00384
00385
00386
00387 ReleaseType::Release_t softType =
00388 ReleaseType::StringToType(fEventInfo.header->softVersion);
00389
00390 assert(softType != -1);
00391
00392 return softType;
00393 }