00001 #ifndef NtpTools_h
00002 #define NtpTools_h
00003
00004 #include <vector>
00005
00006 #include "TClonesArray.h"
00007 #include "TCanvas.h"
00008 #include "TH2F.h"
00009 #include "TMarker.h"
00010 #include "TMath.h"
00011
00012 #include "MessageService/MsgService.h"
00013 #include "BeamDataNtuple/NtpBDLiteRecord.h"
00014 #include "CandNtupleSR/NtpSREvent.h"
00015 #include "CandNtupleSR/NtpSRTrack.h"
00016 #include "CandNtupleSR/NtpSRShower.h"
00017 #include "CandNtupleSR/NtpSRSlice.h"
00018 #include "CandNtupleSR/NtpSRStrip.h"
00019 #include "StandardNtuple/NtpStRecord.h"
00020 #include "MCNtuple/NtpMCTruth.h"
00021
00022 #include "NtpConstants.h"
00023 #include "RecoE.h"
00024 #include "MyShwInfo.h"
00025
00026
00027
00028
00029 class Zfluk;
00030
00031 class NtpTools{
00032 public:
00033
00034 typedef enum EBeamType{
00035 kAny = -1,
00036 kUnknown = 0,
00037 kLE10 = 1,
00038 kME = 2,
00039 kHE = 3,
00040 kpME = 4,
00041 pHE = 5
00042 }BeamType_t;
00043
00044
00045 NtpTools();
00046 ~NtpTools();
00047 static const NtpSREvent* GetEvent(const NtpStRecord* record, const int eventno);
00048 static VldContext GetVldContext(const NtpStRecord* record);
00049 static Detector::Detector_t GetDetector(const NtpStRecord* record);
00050
00051
00052 static bool VtxIsContained(const NtpStRecord* record, const int eventno);
00053 static bool IsInFidVolumeNear(const float x, const float y, const float z);
00054 static bool IsInFidVolumeFar(const float x, const float y, const float z);
00055 static bool PassBeamCuts(const BeamType_t beamtype, const NtpBDLiteRecord* beamntp, float& pot , bool isMC=false);
00056 static float RadialDistFromBeam(const float x, const float y);
00057
00058
00059 static const NtpSRTrack* GetPrimaryTrack(const NtpStRecord* record, const int eventno);
00060 static bool FillRecoEInfo(const NtpStRecord* record, const int eventno, RecoE* recoe);
00061 static Int_t GetPittContainmentFlag(const NtpSREvent* evt);
00062
00063 static bool FillMyShwInfo(const NtpStRecord* record, const int eventno, MyShwInfo* shwinfo);
00064
00065 static bool GetTrueEnergy(const NtpStRecord* record, const int eventno, float& mceneu);
00066
00067 static const NtpMCTruth* GetTruth(const NtpStRecord* record, const int eventno);
00068
00069 static int GetNEventsPerSlice(const NtpStRecord* record, const int eventno);
00070
00071 float GetMCEventWeight(const NtpStRecord* record, const int eventno);
00072
00073 static float GetTotHadPt(const NtpStRecord* record, const NtpMCTruth* truth);
00074
00075
00076 bool MakeEventPict(const char* title, const NtpStRecord* record, const int eventno);
00077 private:
00078 Zfluk* fFluxModel;
00079
00080 TCanvas* fCanvas;
00081 TH2F* fUZAxis;
00082 TH2F* fVZAxis;
00083 std::vector<TMarker> fUZMarkers;
00084 std::vector<TMarker> fVZMarkers;
00085 bool ResetCanvas(Detector::Detector_t det);
00086 bool PrintCanvas(const char* title);
00087
00088 };
00089
00090 inline const NtpSREvent* NtpTools::GetEvent(const NtpStRecord* record, const int eventno){
00091 return (dynamic_cast<const NtpSREvent*>(record->evt->At(eventno)));
00092 }
00093
00094 inline const VldContext GetVldContext(const NtpStRecord* record){
00095 return(record->GetHeader().GetVldContext());
00096 }
00097
00098 inline Detector::Detector_t NtpTools::GetDetector(const NtpStRecord* record){
00099 return(record->GetHeader().GetVldContext().GetDetector());
00100 }
00101
00102 inline bool NtpTools::VtxIsContained(const NtpStRecord* record, const int eventno){
00103 if(!record) return false;
00104 const NtpSREvent* event = GetEvent(record, eventno);
00105 if(!event) return false;
00106 if(GetDetector(record)==Detector::kNear){
00107 return (IsInFidVolumeNear(event->vtx.x, event->vtx.y, event->vtx.z) );
00108 }else{
00109 return (IsInFidVolumeFar(event->vtx.x, event->vtx.y, event->vtx.z) );
00110 }
00111 }
00112
00113 inline float NtpTools::RadialDistFromBeam(const float x, const float y){
00114 float radius = sqrt((x - NtpConstants::kNearBeamCentreX)*
00115 (x - NtpConstants::kNearBeamCentreX) +
00116 (y - NtpConstants::kNearBeamCentreY)*
00117 (y - NtpConstants::kNearBeamCentreY)
00118 );
00119
00120 return radius;
00121
00122 }
00123
00124
00125 inline bool NtpTools::IsInFidVolumeNear(const float x, const float y, const float z){
00126 float radius = RadialDistFromBeam(x, y);
00127 if( z>1. &&
00128 z<5. &&
00129 radius<1. ) return true;
00130 else return false;
00131 }
00132
00133 inline bool NtpTools::IsInFidVolumeFar(const float , const float , const float ){
00134 return true;
00135 }
00136
00137
00138
00139 #endif
00140