#include "INRooTrackerVtxModule.hxx" #include "IG4PrimaryParticle.hxx" #include "IG4PrimaryVertex.hxx" #include "IGeomInfo.hxx" #include "IP0DGeom.hxx" #include "IOADatabase.hxx" #include "ICOMETLog.hxx" ClassImp(COMET::INRooTrackerVtxModule); // //------------------------------------------------------------------------------ COMET::INRooTrackerVtxModule::INRooTrackerVtxModule(const char *name, const char *title){ fVtx = new TClonesArray("COMET::INRooTrackerVtx", 100); SetNameTitle(name, title); // Enable this module by default: fIsEnabled = kTRUE; fDescription = "Neut specific module which fills mc-truth vertex info"; fCurrNeutVtx = new INRooTrackerVtx(); //COMET::ICOMETLog::Configure(); } // //------------------------------------------------------------------------------ COMET::INRooTrackerVtxModule::~INRooTrackerVtxModule() {} // //------------------------------------------------------------------------------ Bool_t COMET::INRooTrackerVtxModule::IsKnownGenerator(const char * name){ std::string name2compare(name); bool is_neut1 = (name2compare.find("neut") != name2compare.npos); bool is_neut2 = (name2compare.find("nRooTracker") != name2compare.npos); bool is_neut = (is_neut1 || is_neut2); COMETDebug("Returning is generator = "<< is_neut << " for generator name = "<< name); return is_neut; } // //------------------------------------------------------------------------------ Bool_t COMET::INRooTrackerVtxModule::CheckMismatch(COMET::IG4PrimaryVertex vtx){ if(fCurrNeutVtx == NULL){ return false; } // Compare the event codes. bool evtcode = (fCurrNeutVtx->EvtCode->GetString().CompareTo(vtx.GetReaction()) == 0); COMETDebug("Comparing "<< fCurrNeutVtx->EvtCode->GetString().Data() << " and " << vtx.GetReaction()); // And the vertex position. double smallnum = 0.000001; bool position = (std::abs(fCurrNeutVtx->EvtVtx[0] - vtx.GetPosition().X()) < smallnum) && (std::abs(fCurrNeutVtx->EvtVtx[1] - vtx.GetPosition().Y()) < smallnum) && (std::abs(fCurrNeutVtx->EvtVtx[2] - vtx.GetPosition().Z()) < smallnum); // In future can add more but for now this should suffice along // with the validation scripts. if(position && evtcode){ COMETDebug("Pass-through vertex passed mismatch test!"); return true; } COMETError("SEVERE ERROR! Mismatch between G4Vertex and pass-through info!"); return false; } // //------------------------------------------------------------------------------ void COMET::INRooTrackerVtxModule::FillVtx(int entry){ fCurrNeutVtx->Reset(); fRooTrackerTree->GetEntry(entry); // first fill up all the book-keeping info fCurrNeutVtx->OrigFileName->SetString(fOrigInputFileName.c_str()); fCurrNeutVtx->OrigTreeName->SetString(fInputTreeName.c_str()); fCurrNeutVtx->OrigEvtNum = fOrigTreeEntryNumber; fCurrNeutVtx->OrigTreePOT = fOrigInputTreePOT; fCurrNeutVtx->OrigTreeEntries = fOrigInputTreeEntries; fCurrNeutVtx->TimeInSpill = fTimeInSpill; fCurrNeutVtx->TruthVertexID = fTruthVertexID; // Need to convert to the comet length units fCurrNeutVtx->EvtVtx[0] *= 1000.0; fCurrNeutVtx->EvtVtx[1] *= 1000.0; fCurrNeutVtx->EvtVtx[2] *= 1000.0; ///< Fill in the geometry path for the current vertex. gGeoManager->FindNode(fCurrNeutVtx->EvtVtx[0], fCurrNeutVtx->EvtVtx[1], fCurrNeutVtx->EvtVtx[2]); ///< Get the name of the generator that generated this event. fCurrNeutVtx->GeneratorName->SetString(fGeneratorName.c_str()); ///< Get the geometry path for this event. fCurrNeutVtx->GeomPath->SetString(gGeoManager->GetPath()); ///< Now create another fRooTracker vtx to add to the vertex ///< container. INRooTrackerVtx * fNRooTrackerVtx; fNRooTrackerVtx = new((*fVtx)[fNVtx++]) INRooTrackerVtx(); /// Copy the current neut event. Make sure this is done last so we copy a /// complete event. fNRooTrackerVtx->Copy(fCurrNeutVtx); } // //------------------------------------------------------------------------------ void COMET::INRooTrackerVtxModule::SetGeneratorTreeAddresses(){ // Set the flux branch addresses common to both generators COMET::IJNuBeamFlux * flux = (COMET::IJNuBeamFlux *) fCurrNeutVtx; COMET::IRooTrackerVtxModuleBase::SetFluxTreeAddresses(flux); // Now set the tree branch addresses fRooTrackerTree->SetBranchAddress("EvtCode", &(fCurrNeutVtx->EvtCode) ); fRooTrackerTree->SetBranchAddress("EvtNum", &(fCurrNeutVtx->EvtNum) ); fRooTrackerTree->SetBranchAddress("EvtXSec", &(fCurrNeutVtx->EvtXSec) ); fRooTrackerTree->SetBranchAddress("EvtDXSec", &(fCurrNeutVtx->EvtDXSec) ); fRooTrackerTree->SetBranchAddress("EvtWght", &(fCurrNeutVtx->EvtWght) ); fRooTrackerTree->SetBranchAddress("EvtProb", &(fCurrNeutVtx->EvtProb) ); fRooTrackerTree->SetBranchAddress("EvtVtx", (fCurrNeutVtx->EvtVtx) ); fRooTrackerTree->SetBranchAddress("StdHepN", &(fCurrNeutVtx->StdHepN) ); fRooTrackerTree->SetBranchAddress("StdHepPdg", &(fCurrNeutVtx->StdHepPdg) ); fRooTrackerTree->SetBranchAddress("StdHepStatus", &(fCurrNeutVtx->StdHepStatus) ); fRooTrackerTree->SetBranchAddress("StdHepX4", (fCurrNeutVtx->StdHepX4) ); fRooTrackerTree->SetBranchAddress("StdHepP4", (fCurrNeutVtx->StdHepP4) ); fRooTrackerTree->SetBranchAddress("StdHepPolz", (fCurrNeutVtx->StdHepPolz) ); fRooTrackerTree->SetBranchAddress("StdHepFd", (fCurrNeutVtx->StdHepFd) ); fRooTrackerTree->SetBranchAddress("StdHepLd", (fCurrNeutVtx->StdHepLd) ); fRooTrackerTree->SetBranchAddress("StdHepFm", (fCurrNeutVtx->StdHepFm) ); fRooTrackerTree->SetBranchAddress("StdHepLm", (fCurrNeutVtx->StdHepLm) ); // NEUT > v5.0.7 && MCP > 1 (>10a) fRooTrackerTree->SetBranchAddress("NEnvc", &(fCurrNeutVtx->NEnvc) ); fRooTrackerTree->SetBranchAddress("NEipvc", (fCurrNeutVtx->NEipvc) ); fRooTrackerTree->SetBranchAddress("NEpvc", (fCurrNeutVtx->NEpvc) ); fRooTrackerTree->SetBranchAddress("NEiorgvc", (fCurrNeutVtx->NEiorgvc) ); fRooTrackerTree->SetBranchAddress("NEiflgvc", (fCurrNeutVtx->NEiflgvc) ); fRooTrackerTree->SetBranchAddress("NEicrnvc", (fCurrNeutVtx->NEicrnvc) ); fRooTrackerTree->SetBranchAddress("NEnvert", &(fCurrNeutVtx->NEnvert) ); fRooTrackerTree->SetBranchAddress("NEposvert", (fCurrNeutVtx->NEposvert) ); fRooTrackerTree->SetBranchAddress("NEiflgvert", (fCurrNeutVtx->NEiflgvert) ); fRooTrackerTree->SetBranchAddress("NEnvcvert", &(fCurrNeutVtx->NEnvcvert) ); fRooTrackerTree->SetBranchAddress("NEdirvert", (fCurrNeutVtx->NEdirvert) ); fRooTrackerTree->SetBranchAddress("NEabspvert", (fCurrNeutVtx->NEabspvert) ); fRooTrackerTree->SetBranchAddress("NEabstpvert", (fCurrNeutVtx->NEabstpvert) ); fRooTrackerTree->SetBranchAddress("NEipvert", (fCurrNeutVtx->NEipvert) ); fRooTrackerTree->SetBranchAddress("NEiverti", (fCurrNeutVtx->NEiverti) ); fRooTrackerTree->SetBranchAddress("NEivertf", (fCurrNeutVtx->NEivertf) ); // end NEUT > v5.0.7 && MCP > 1 (>10a) // NEUT > v5.1.2 && MCP >= 5 fRooTrackerTree->SetBranchAddress("NEcrsx", &(fCurrNeutVtx->NEcrsx) ); fRooTrackerTree->SetBranchAddress("NEcrsy", &(fCurrNeutVtx->NEcrsy) ); fRooTrackerTree->SetBranchAddress("NEcrsz", &(fCurrNeutVtx->NEcrsz) ); fRooTrackerTree->SetBranchAddress("NEcrsphi", &(fCurrNeutVtx->NEcrsphi) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuNorm", &(fCurrNeutVtx->NuNorm) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentPdg", &(fCurrNeutVtx->NuParentPdg) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentDecMode",&(fCurrNeutVtx->NuParentDecMode) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentDecP4", (fCurrNeutVtx->NuParentDecP4) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentDecX4", (fCurrNeutVtx->NuParentDecX4) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentProP4", (fCurrNeutVtx->NuParentProP4) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentProX4", (fCurrNeutVtx->NuParentProX4) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuParentProNVtx",&(fCurrNeutVtx->NuParentProNVtx) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuPlanePos", (fCurrNeutVtx->NuPlanePos) ); /////JDRM /////JDRM fRooTrackerTree->SetBranchAddress("NuGipart", &(fCurrNeutVtx->NuGipart) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGamom0", &(fCurrNeutVtx->NuGamom0) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGpos0", (fCurrNeutVtx->NuGpos0) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGvec0", (fCurrNeutVtx->NuGvec0) ); /////JDRM /////JDRM // jnubeam >= 2010d && MCP > 1 (>10a) /////JDRM fRooTrackerTree->SetBranchAddress("NuNg", &(fCurrNeutVtx->NuNg) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGpid", (fCurrNeutVtx->NuGpid) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGmec", (fCurrNeutVtx->NuGmec) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGv", (fCurrNeutVtx->NuGv) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuGp", (fCurrNeutVtx->NuGp) ); /////JDRM /////JDRM fRooTrackerTree->SetBranchAddress("NuEnusk", &(fCurrNeutVtx->NuEnusk) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuNormsk", &(fCurrNeutVtx->NuNormsk) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuAnorm", &(fCurrNeutVtx->NuAnorm) ); /////JDRM /////JDRM fRooTrackerTree->SetBranchAddress("NuVersion", &(fCurrNeutVtx->NuVersion) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuTuneid", &(fCurrNeutVtx->NuTuneid) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuPint", &(fCurrNeutVtx->NuPint) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuBpos", (fCurrNeutVtx->NuBpos) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuBtilt", (fCurrNeutVtx->NuBtilt) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuBrms", (fCurrNeutVtx->NuBrms) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuEmit", (fCurrNeutVtx->NuEmit) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuAlpha", (fCurrNeutVtx->NuAlpha) ); /////JDRM fRooTrackerTree->SetBranchAddress("NuHcur", (fCurrNeutVtx->NuHcur) ); /////JDRM // end jnubeam >= 2010d && MCP > 1 (>10a) } // //------------------------------------------------------------------------------