#include "WCSimWrap.h" #include // initialize static values WCSimWrap * WCSimWrap::staticthis = NULL; TFile * WCSimWrap::fIn = NULL; TTree * WCSimWrap::fTIn = NULL; TTree * WCSimWrap::fTGeo = NULL; TTree * WCSimWrap::fTSet = NULL; int WCSimWrap::fNEv = 0; int WCSimWrap::fCurEntry = -1; WCSimRootEvent* WCSimWrap::fEv = NULL; int WCSimWrap::fNSubEv = 0; WCSimRootTrigger * WCSimWrap::fTrig[MAXNSUBEV] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL }; double WCSimWrap::fTOffset[MAXNSUBEV]={ 0.,0.,0.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,0.,0.,0., 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; WCSimRootGeom * WCSimWrap::fGeo = NULL; Int_t WCSimWrap::fNPMT = 0; Float_t ** WCSimWrap::fPMTpos = NULL; Float_t ** WCSimWrap::fPMTdir = NULL; Float_t * WCSimWrap::fPMTQE = NULL; Int_t * WCSimWrap::fPMTtype = NULL; //Float_t * WCSimWrap::fPMTR = NULL; //Float_t * WCSimWrap::fPMTphi = NULL; Int_t * WCSimWrap::fPMTnum = NULL; Int_t * WCSimWrap::fPMTloc = NULL; Float_t WCSimWrap::WCXRotation[3] = {1.,0.,0.}; Float_t WCSimWrap::WCYRotation[3] = {0.,1.,0.}; Float_t WCSimWrap::WCZRotation[3] = {0.,0.,1.}; //============================================================================= // WCSimWrap() Constructor does nothing. // Everything happens when calling Get() method WCSimWrap::WCSimWrap(){ return; } //============================================================================= /// ~WCSimWrap() Destructor closes file, unsets instance and deletes /// saved goemetry info WCSimWrap::~WCSimWrap(){ staticthis = 0; if (fIn!=0){ if (fIn->IsOpen()) fIn->Close(); } fNEv = 0; fNSubEv = 0; if ( fPMTpos != NULL ){ for (int ipmt=0; ipmt "< Unable to open wcsim input file: "<IsOpen()==kFALSE){ std::cout<<" wcsim input file not open: "<Get("wcsimT"); if (!fTIn){ std::cout<<" Unable to find wcsimT TTree in "<Get("wcsimGeoT"); if (!fTGeo){ std::cout<<" Unable to find wcsimGeoT TTree in "<Get("Settings"); if (!fTSet){ std::cout<<" There is no Settings TTree in "<GetBranch("WCXRotation"); if (bWCXRotation) { bWCXRotation->SetAddress(WCXRotation); } else { WCXRotation[0] = 1.; WCXRotation[1] = 0; WCXRotation[2] = 0; } TBranch *bWCYRotation = fTSet->GetBranch("WCYRotation"); if (bWCYRotation) { bWCYRotation->SetAddress(WCYRotation); } else { WCYRotation[0] = 0; WCYRotation[1] = 1.; WCYRotation[2] = 0; } TBranch *bWCZRotation = fTSet->GetBranch("WCZRotation"); if (bWCZRotation) { bWCZRotation->SetAddress(WCZRotation); } else { WCZRotation[0] = 0; WCZRotation[1] = 0; WCZRotation[2] = 1.; } fTSet->GetEntry(0); } // set up event storage fEv = new WCSimRootEvent(); fTIn->SetBranchAddress("wcsimrootevent",&fEv); fTIn->GetBranch("wcsimrootevent")->SetAutoDelete(kTRUE); fNEv = fTIn->GetEntries(); fNSubEv = 0; // set up geometry storage int istat = ReadGeom(); if (istat<0) return istat; // Load first entry return LoadEntry(); } //============================================================================= /// ReadGeom() is a helper method to read in the geometry int WCSimWrap::ReadGeom(){ if (fGeo!=NULL){ std::cout<<" WARNING fGeo!=NULL, Reloading it anyway, but maybe memory leak"<SetBranchAddress("wcsimrootgeom",&fGeo); // first "event" in branch has the geometry fTGeo->GetEntry(0); fNPMT = fGeo->GetWCNumPMT(); // now set up storage fPMTpos = new Float_t * [ fNPMT ]; fPMTdir = new Float_t * [ fNPMT ]; fPMTQE = new Float_t [ fNPMT ]; fPMTtype = new Int_t [ fNPMT ]; // fPMTR = new Float_t [ fNPMT ]; // fPMTphi = new Float_t [ fNPMT ]; fPMTnum = new Int_t [ fNPMT ]; fPMTloc = new Int_t [ fNPMT ]; for (int ipmt=0; ipmtGetPMT(ipmt); //std::cout<<" ipmt="< "<GetHeader()->GetEvtNum()) return 0; for (fCurEntry = 0; fCurEntryGetEntry(fCurEntry); fTrig[0] = fEv->GetTrigger(0); if ( aevent == fTrig[0]->GetHeader()->GetEvtNum() ){ return LoadEntry( fCurEntry ); } } return -7; }