NtpMCModule Class Reference

#include <NtpMCModule.h>

Inheritance diagram for NtpMCModule:
JobCModule

List of all members.

Public Member Functions

 NtpMCModule ()
 ~NtpMCModule ()
const RegistryDefaultConfig () const
void Config (const Registry &r)
JobCResult Reco (MomNavigator *mom)

Private Member Functions

bool BuildMCToStdHep (const TClonesArray *, const TClonesArray *)
bool BuildStdHepToDigiHit (const TClonesArray *stdheparray, const TClonesArray *simdigihitarray)
void FillNtpMCTruth (TClonesArray &ntpmc, NtpMCSummary &ntpmcsummary, const SimSnarlRecord *simrec, const MomNavigator *mom)
void FillNtpMCStdHep (TClonesArray &ntpstdhep, NtpMCSummary &ntpmcsummary, const SimSnarlRecord *simrec)
void FillNtpMCDigiScintHit (TClonesArray &ntpdigihit, NtpMCSummary &ntpmcsummary, const SimSnarlRecord *simrec)
void FillNtpMCPhotonResult (NtpMCPhotonResult &ntpmcphoton, const SimSnarlRecord *simrec)
void FillNtpMCDetSimResult (NtpMCDetSimResult &ntpmcdetsim, const SimSnarlRecord *simrec)
void FillNtpFluxInfo (NtpMCFluxInfo &ntpfinfo, const REROOT_FluxInfo *rrfinfo)
void FillNtpFluxWgt (NtpMCFluxWgt &ntpfwgt, const REROOT_FluxWgt *rrfwgt)

Private Attributes

Int_t fWriteDigiHit
bool fUseStandard
Int_t * fStdHepRange
string fSimSnarlRecordName
string fRecordName
string fRecordTitle
std::map< Int_t, std::vector
< DigiScintHit * > > 
fStdHepToDigiHitMap

Detailed Description

Definition at line 35 of file NtpMCModule.h.


Constructor & Destructor Documentation

NtpMCModule::NtpMCModule (  )  [inline]

Definition at line 38 of file NtpMCModule.h.

NtpMCModule::~NtpMCModule (  )  [inline]

Definition at line 40 of file NtpMCModule.h.

00040 {}


Member Function Documentation

bool NtpMCModule::BuildMCToStdHep ( const TClonesArray *  neukinarray,
const TClonesArray *  stdheparray 
) [private]

Definition at line 584 of file NtpMCModule.cxx.

References fStdHepRange, Msg::kDebug, Msg::kError, and MSG.

Referenced by FillNtpMCTruth().

00585                                                                    {
00586 //
00587 //  Purpose:  Private method used to build mc to stdhep map
00588 //
00589 //  Return: false if build failed (an error message is also printed), else true
00590 //
00591 
00592    MSG("NtpMC",Msg::kDebug) << "NtpMCModule::BuildMCToStdHep()"
00593                             << endl;
00594  
00595    if ( fStdHepRange ) delete [] fStdHepRange; fStdHepRange = 0;
00596    
00597    Int_t nneukin = neukinarray->GetLast()+1;
00598    if ( nneukin <= 0 ) return true; // nothing to build
00599    
00600    Int_t nstdhep = stdheparray->GetLast()+1;
00601    fStdHepRange = new Int_t[nneukin*2];
00602    for ( int ineu = 0; ineu < nneukin; ineu++ ) {
00603      fStdHepRange[ineu*2+0] = -1;
00604      fStdHepRange[ineu*2+1] = -1;
00605    }
00606    
00607    Int_t mcindex = -1;
00608    Int_t nprim = 0;
00609    bool  prevchild = true;
00610    for ( Int_t istd = 0; istd < nstdhep; istd++ ) {
00611      TParticle* simstdhep = dynamic_cast<TParticle*>(stdheparray->At(istd));
00612      if ( simstdhep->GetMother(0) == -1 && simstdhep->GetMother(1) == -1 ) {
00613        // primary, check to make sure its new
00614        nprim++;
00615        if ( nprim > 2 || prevchild ) { 
00616          mcindex++; 
00617          nprim = 1; 
00618          if ( mcindex < nneukin ) {
00619            fStdHepRange[mcindex*2+0] = istd; // range min
00620          }
00621          else {
00622            MSG("NtpMC",Msg::kError) 
00623            << "FillNtpMCTruth:\nBreakdown in procedure to match stdhep to "
00624            << "associated mc entry.\nmc to stdhep indexing will not be done!"
00625            << endl;
00626            if ( fStdHepRange ) delete [] fStdHepRange; fStdHepRange = 0;
00627            return false;
00628          }
00629        }
00630        prevchild = false; 
00631      }
00632      else {
00633        prevchild = true;
00634        nprim = 0;
00635      }
00636       
00637      fStdHepRange[mcindex*2+1] = istd; // range max
00638      
00639    }   
00640 
00641    // At end, check grand total
00642    if ( mcindex != nneukin - 1  ) {
00643      MSG("NtpMC",Msg::kError) 
00644       << "FillNtpMCTruth:\nBreakdown in procedure to match stdhep to " 
00645       << "associated mc entry.\nFound " << mcindex + 1 << " primaries "
00646       << "in stdhep array, but nneukin = " << nneukin << ".\n"
00647       << "mc to stdhep indexing will not be done!" << endl;
00648      if ( fStdHepRange ) delete [] fStdHepRange; fStdHepRange = 0;
00649      return false;
00650    }
00651 
00652    return true;
00653    
00654 }

bool NtpMCModule::BuildStdHepToDigiHit ( const TClonesArray *  stdheparray,
const TClonesArray *  simdigihitarray 
) [private]

Definition at line 656 of file NtpMCModule.cxx.

References fStdHepToDigiHitMap, Msg::kDebug, Msg::kWarning, MSG, DigiScintHit::ParticleId(), DigiScintHit::StripEndId(), and DigiScintHit::TrackId().

Referenced by FillNtpMCStdHep().

00657                                                                             {
00658 //
00659 //  Purpose:  Private method to fill fStdHepToDigiHitMap with
00660 //            <stdhep particle index, vector of digiscinthits> pairs.
00661 //            Only those digihits directly generated by the stdhep particle
00662 //            are stored in the list of digihits associated with the
00663 //            particle.  Veto shield hits are excluded.
00664 //
00665 //  Return: false if build failed (an error message is also printed), else true
00666 //
00667 
00668    MSG("NtpMC",Msg::kDebug) << "NtpMCModule::BuildStdHepToDigiHit()"
00669                             << endl;
00670  
00671    fStdHepToDigiHitMap.clear(); 
00672    
00673    if ( !simstdheparray ) {
00674      MSG("NtpMC",Msg::kWarning)
00675      << "NtpMCModule::BuildStdHepToDigiHit received null stdheparray." 
00676      << endl;
00677      return false;
00678    }
00679    if ( !simdigihitarray ) {
00680      MSG("NtpMC",Msg::kWarning)
00681      << "NtpMCModule::BuildStdHepToDigiHit received null digihitarray." 
00682      << endl;
00683      return false;
00684    }
00685 
00686    Int_t ndigihit = simdigihitarray->GetLast()+1;
00687    for ( Int_t ihit = 0; ihit < ndigihit; ihit++ ) {
00688      DigiScintHit* simdigihit
00689      = dynamic_cast<DigiScintHit*>(simdigihitarray->At(ihit));
00690      Int_t trkId = simdigihit->TrackId(); //id of trk that produced hit
00691      if ( trkId < 0 ) continue; // track not present in stdhep array
00692      if ( (simdigihit->StripEndId()).IsVetoShield() ) continue; // skip VS hits
00693 
00694      // Because cosmic reroot files place the primary muon in the 0th slot 
00695      // in stdhep array, such that hits off the secondaries produced by
00696      // the muon will have trkId's 0 instead of a negative trkId, check
00697      // to make sure particleId in this slot is that of primary.
00698      const TParticle* stdhep = dynamic_cast<const TParticle*>
00699                                (simstdheparray->At(trkId));
00700      if ( stdhep->GetPdgCode() != simdigihit->ParticleId() ) continue;
00701 
00702      // The following will create an entry in map if not present already
00703      std::vector<DigiScintHit*>& hitlist = fStdHepToDigiHitMap[trkId];
00704      hitlist.push_back(simdigihit);
00705    }
00706 
00707    return true;
00708    
00709 }

void NtpMCModule::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 112 of file NtpMCModule.cxx.

References fRecordName, fRecordTitle, fSimSnarlRecordName, fUseStandard, fWriteDigiHit, Registry::Get(), Msg::kDebug, and MSG.

00112                                           {
00113   //
00114   // Purpose: Configure the module given a registry.
00115   //
00116   // Arguments: Registry to use to configure the module.
00117   //
00118   // Return: none.
00119   //
00120 
00121   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::Config" << endl;
00122   
00123   Int_t tmpi;
00124   //  Double_t tmpd;
00125   const Char_t* tmps;
00126   if ( r.Get("WriteDigiHit",tmpi) ) fWriteDigiHit = tmpi;
00127   if ( r.Get("UseStandard",tmpi) ) fUseStandard = tmpi;
00128   if ( r.Get("SimSnarlRecordName",tmps) ) fSimSnarlRecordName = tmps;
00129   if ( r.Get("RecordName", tmps) )  fRecordName = tmps;
00130   if ( r.Get("RecordTitle", tmps) ) fRecordTitle = tmps;
00131 
00132 }

const Registry & NtpMCModule::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 82 of file NtpMCModule.cxx.

References JobCModule::GetName(), Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00082                                                  {
00083   //
00084   // Purpose: Method to return default configuration.
00085   // 
00086   // Arguments: none.
00087   //
00088   // Return: Registry containing default configuration
00089   //
00090 
00091   MSG("NtpMC",Msg::kDebug) << 
00092     "NtpMCModule::DefaultConfig" << endl;
00093 
00094   static Registry r; 
00095   std::string name = this->JobCModule::GetName();
00096   name += ".config.default";
00097   r.SetName(name.c_str());
00098 
00099   r.UnLockValues();
00100   r.Set("WriteDigiHit",0);
00101   r.Set("UseStandard",0);
00102   r.Set("SimSnarlRecordName", "");
00103   r.Set("RecordName", "Primary");
00104   r.Set("RecordTitle", "Created by NtpMCModule");
00105   r.LockValues();
00106 
00107   return r;
00108 }

void NtpMCModule::FillNtpFluxInfo ( NtpMCFluxInfo ntpfinfo,
const REROOT_FluxInfo rrfinfo 
) [private]

Definition at line 897 of file NtpMCModule.cxx.

References NtpMCFluxInfo::beampx, REROOT_FluxInfo::beampx(), NtpMCFluxInfo::beampy, REROOT_FluxInfo::beampy(), NtpMCFluxInfo::beampz, REROOT_FluxInfo::beampz(), NtpMCFluxInfo::beamx, REROOT_FluxInfo::beamx(), NtpMCFluxInfo::beamy, REROOT_FluxInfo::beamy(), NtpMCFluxInfo::beamz, REROOT_FluxInfo::beamz(), NtpMCFluxInfo::fluxevtno, REROOT_FluxInfo::FluxEvtNo(), NtpMCFluxInfo::fluxrun, REROOT_FluxInfo::FluxRun(), REROOT_FluxInfo::ID(), NtpMCFluxInfo::index, Msg::kDebug, Msg::kWarning, MAXMSG, MSG, NtpMCFluxInfo::mupare, REROOT_FluxInfo::mupare(), NtpMCFluxInfo::muparpx, REROOT_FluxInfo::muparpx(), NtpMCFluxInfo::muparpy, REROOT_FluxInfo::muparpy(), NtpMCFluxInfo::muparpz, REROOT_FluxInfo::muparpz(), NtpMCFluxInfo::ndecay, REROOT_FluxInfo::Ndecay(), REROOT_FluxInfo::Ndxdz(), NtpMCFluxInfo::ndxdz, NtpMCFluxInfo::ndxdzfar, REROOT_FluxInfo::NdxdzFar(), NtpMCFluxInfo::ndxdznear, REROOT_FluxInfo::NdxdzNear(), REROOT_FluxInfo::Ndydz(), NtpMCFluxInfo::ndydz, NtpMCFluxInfo::ndydzfar, REROOT_FluxInfo::NdydzFar(), REROOT_FluxInfo::NdydzNear(), NtpMCFluxInfo::ndydznear, NtpMCFluxInfo::necm, REROOT_FluxInfo::Necm(), REROOT_FluxInfo::Nenergy(), NtpMCFluxInfo::nenergy, REROOT_FluxInfo::NenergyF(), NtpMCFluxInfo::nenergyfar, REROOT_FluxInfo::NenergyN(), NtpMCFluxInfo::nenergynear, NtpMCFluxInfo::nimpwt, REROOT_FluxInfo::Nimpwt(), NtpMCFluxInfo::norig, REROOT_FluxInfo::Norig(), REROOT_FluxInfo::Npz(), NtpMCFluxInfo::npz, NtpMCFluxInfo::ntype, REROOT_FluxInfo::Ntype(), NtpMCFluxInfo::nwtfar, REROOT_FluxInfo::NWtFar(), NtpMCFluxInfo::nwtnear, REROOT_FluxInfo::NWtNear(), REROOT_FluxInfo::pdPx(), NtpMCFluxInfo::pdpx, REROOT_FluxInfo::pdPy(), NtpMCFluxInfo::pdpy, REROOT_FluxInfo::pdPz(), NtpMCFluxInfo::pdpz, NtpMCFluxInfo::ppdxdz, REROOT_FluxInfo::ppdxdz(), NtpMCFluxInfo::ppdydz, REROOT_FluxInfo::ppdydz(), REROOT_FluxInfo::ppenergy(), NtpMCFluxInfo::ppenergy, NtpMCFluxInfo::ppmedium, REROOT_FluxInfo::ppmedium(), REROOT_FluxInfo::pppz(), NtpMCFluxInfo::pppz, NtpMCFluxInfo::ppvx, REROOT_FluxInfo::ppvx(), NtpMCFluxInfo::ppvy, REROOT_FluxInfo::ppvy(), NtpMCFluxInfo::ppvz, REROOT_FluxInfo::ppvz(), NtpMCFluxInfo::ptype, REROOT_FluxInfo::ptype(), NtpMCFluxInfo::tgen, REROOT_FluxInfo::tgen(), REROOT_FluxInfo::tgppx(), NtpMCFluxInfo::tgppx, REROOT_FluxInfo::tgppy(), NtpMCFluxInfo::tgppy, REROOT_FluxInfo::tgppz(), NtpMCFluxInfo::tgppz, NtpMCFluxInfo::tgptype, REROOT_FluxInfo::tgptype(), NtpMCFluxInfo::tprivx, REROOT_FluxInfo::tprivx(), NtpMCFluxInfo::tprivy, REROOT_FluxInfo::tprivy(), REROOT_FluxInfo::tprivz(), NtpMCFluxInfo::tprivz, REROOT_FluxInfo::tptype(), NtpMCFluxInfo::tptype, NtpMCFluxInfo::tpx, REROOT_FluxInfo::tpx(), NtpMCFluxInfo::tpy, REROOT_FluxInfo::tpy(), NtpMCFluxInfo::tpz, REROOT_FluxInfo::tpz(), REROOT_FluxInfo::tvx(), NtpMCFluxInfo::tvx, REROOT_FluxInfo::tvy(), NtpMCFluxInfo::tvy, REROOT_FluxInfo::tvz(), NtpMCFluxInfo::tvz, REROOT_FluxInfo::Vx(), NtpMCFluxInfo::vx, REROOT_FluxInfo::Vy(), NtpMCFluxInfo::vy, REROOT_FluxInfo::Vz(), NtpMCFluxInfo::vz, NtpMCFluxInfo::xpoint, REROOT_FluxInfo::xpoint(), NtpMCFluxInfo::ypoint, REROOT_FluxInfo::ypoint(), NtpMCFluxInfo::zpoint, and REROOT_FluxInfo::zpoint().

Referenced by FillNtpMCTruth().

00899 {
00900   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpFlux" << endl;
00901 
00902   if ( !rrfinfo ) {
00903     MAXMSG("NtpMC",Msg::kWarning,5) 
00904     << "NtpMCModule::FillNtpFlux called with null argument pointer." 
00905     << endl;
00906     return;
00907   }
00908 
00909   ntpfinfo.index = rrfinfo->ID();
00910   ntpfinfo.fluxrun = rrfinfo->FluxRun();
00911   ntpfinfo.fluxevtno = rrfinfo->FluxEvtNo();
00912   ntpfinfo.ndxdz = rrfinfo->Ndxdz();
00913   ntpfinfo.ndydz = rrfinfo->Ndydz();
00914   ntpfinfo.npz = rrfinfo->Npz();
00915   ntpfinfo.nenergy = rrfinfo->Nenergy();
00916   ntpfinfo.ndxdznear = rrfinfo->NdxdzNear();
00917   ntpfinfo.ndydznear = rrfinfo->NdydzNear();
00918   ntpfinfo.nenergynear = rrfinfo->NenergyN();
00919   ntpfinfo.nwtnear = rrfinfo->NWtNear();
00920   ntpfinfo.ndxdzfar = rrfinfo->NdxdzFar();
00921   ntpfinfo.ndydzfar = rrfinfo->NdydzFar();
00922   ntpfinfo.nenergyfar = rrfinfo->NenergyF();
00923   ntpfinfo.nwtfar = rrfinfo->NWtFar();
00924   ntpfinfo.norig = rrfinfo->Norig();
00925   ntpfinfo.ndecay = rrfinfo->Ndecay();
00926   ntpfinfo.ntype = rrfinfo->Ntype();
00927   ntpfinfo.vx = rrfinfo->Vx();
00928   ntpfinfo.vy = rrfinfo->Vy();
00929   ntpfinfo.vz = rrfinfo->Vz();
00930   ntpfinfo.pdpx = rrfinfo->pdPx();
00931   ntpfinfo.pdpy = rrfinfo->pdPy();
00932   ntpfinfo.pdpz = rrfinfo->pdPz();
00933   ntpfinfo.ppdxdz = rrfinfo->ppdxdz();
00934   ntpfinfo.ppdydz = rrfinfo->ppdydz();
00935   ntpfinfo.pppz = rrfinfo->pppz();
00936   ntpfinfo.ppenergy = rrfinfo->ppenergy();
00937   ntpfinfo.ppmedium = rrfinfo->ppmedium();
00938   ntpfinfo.ptype = rrfinfo->ptype();
00939   ntpfinfo.ppvx = rrfinfo->ppvx();
00940   ntpfinfo.ppvy = rrfinfo->ppvy();
00941   ntpfinfo.ppvz = rrfinfo->ppvz();
00942   ntpfinfo.muparpx = rrfinfo->muparpx();
00943   ntpfinfo.muparpy = rrfinfo->muparpy();
00944   ntpfinfo.muparpz = rrfinfo->muparpz();
00945   ntpfinfo.mupare = rrfinfo->mupare();
00946   ntpfinfo.necm = rrfinfo->Necm();
00947   ntpfinfo.nimpwt = rrfinfo->Nimpwt();
00948   ntpfinfo.xpoint = rrfinfo->xpoint();
00949   ntpfinfo.ypoint = rrfinfo->ypoint();
00950   ntpfinfo.zpoint = rrfinfo->zpoint();
00951   ntpfinfo.tvx = rrfinfo->tvx();
00952   ntpfinfo.tvy = rrfinfo->tvy();
00953   ntpfinfo.tvz = rrfinfo->tvz();
00954   ntpfinfo.tpx = rrfinfo->tpx();
00955   ntpfinfo.tpy = rrfinfo->tpy();
00956   ntpfinfo.tpz = rrfinfo->tpz();
00957   ntpfinfo.tptype = rrfinfo->tptype();
00958   ntpfinfo.tgen = rrfinfo->tgen();
00959   // NUGPINFO data
00960   ntpfinfo.tgptype = rrfinfo->tgptype();
00961   ntpfinfo.tgppx = rrfinfo->tgppx();
00962   ntpfinfo.tgppy = rrfinfo->tgppy();
00963   ntpfinfo.tgppz = rrfinfo->tgppz();
00964   ntpfinfo.tprivx = rrfinfo->tprivx();
00965   ntpfinfo.tprivy = rrfinfo->tprivy();
00966   ntpfinfo.tprivz = rrfinfo->tprivz();
00967   ntpfinfo.beamx = rrfinfo->beamx();
00968   ntpfinfo.beamy = rrfinfo->beamy();
00969   ntpfinfo.beamz = rrfinfo->beamz();
00970   ntpfinfo.beampx = rrfinfo->beampx();
00971   ntpfinfo.beampy = rrfinfo->beampy();
00972   ntpfinfo.beampz = rrfinfo->beampz();
00973 
00974   return;
00975 }

void NtpMCModule::FillNtpFluxWgt ( NtpMCFluxWgt ntpfwgt,
const REROOT_FluxWgt rrfwgt 
) [private]

Definition at line 977 of file NtpMCModule.cxx.

References NtpMCFluxWgt::beam, REROOT_FluxWgt::Beam(), REROOT_FluxWgt::ID(), NtpMCFluxWgt::index, Msg::kDebug, Msg::kWarning, MAXMSG, MSG, NtpMCFluxWgt::version, REROOT_FluxWgt::Version(), REROOT_FluxWgt::Weight(), NtpMCFluxWgt::weight, NtpMCFluxWgt::weighterr, and REROOT_FluxWgt::WeightErr().

Referenced by FillNtpMCTruth().

00979 {
00980   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpFluxWgt" << endl;
00981 
00982   if ( !rrfwgt ) {
00983     MAXMSG("NtpMC",Msg::kWarning,5) 
00984     << "NtpMCModule::FillNtpFluxWgt called with null argument pointer." 
00985     << endl;
00986     return;
00987   }
00988 
00989   ntpfwgt.index = rrfwgt->ID();
00990   ntpfwgt.version = rrfwgt->Version();
00991   ntpfwgt.weight = rrfwgt->Weight();
00992   ntpfwgt.weighterr = rrfwgt->WeightErr();
00993   strcpy(ntpfwgt.beam,rrfwgt->Beam());  
00994 
00995   return;
00996 }

void NtpMCModule::FillNtpMCDetSimResult ( NtpMCDetSimResult ntpmcdetsim,
const SimSnarlRecord simrec 
) [private]

Definition at line 837 of file NtpMCModule.cxx.

References NtpMCDetSimResult::adcsAfterDaqTrigger, SimEventResult::adcsAfterDaqTrigger, SimEventResult::adcsAfterFETrigger, NtpMCDetSimResult::adcsAfterFETrigger, NtpMCDetSimResult::adcsAfterSpars, SimEventResult::adcsAfterSpars, SimEventResult::bigSnarl, NtpMCDetSimResult::bigSnarl, det, NtpMCDetSimResult::digitsAfterDaqTrigger, SimEventResult::digitsAfterDaqTrigger, NtpMCDetSimResult::digitsAfterFETrigger, SimEventResult::digitsAfterFETrigger, NtpMCDetSimResult::digitsAfterSpars, SimEventResult::digitsAfterSpars, RecDataRecord< T >::FindComponent(), NtpMCDetSimResult::hitPixels, SimEventResult::hitPixels, SimEventResult::hitPixelsWithXtalk, NtpMCDetSimResult::hitPixelsWithXtalk, Msg::kDebug, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, SimEventResult::npe, NtpMCDetSimResult::nPE, SimEventResult::snarl_adcs, SimEventResult::snarl_digits, SimEventResult::snarl_trigger, NtpMCDetSimResult::snarlAdcs, NtpMCDetSimResult::snarlDigits, NtpMCDetSimResult::snarls, SimEventResult::snarls, NtpMCDetSimResult::snarlTrigger, NtpMCDetSimResult::timeShift, SimEventResult::timeShift, NtpMCDetSimResult::totalCharge, SimEventResult::totalCharge, SimEventResult::totalPe, and NtpMCDetSimResult::totalPE.

Referenced by Reco().

00838                                                                       {
00839 //
00840 //  Purpose:  Private method used to fill detsim result portion of ntuple
00841 //            record.
00842 //
00843 //  Arguments: reference to detsim result and SimSnarlRecord
00844 //
00845 //  Return: none.
00846 //
00847 
00848    MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpMCDetSimResult"
00849                             << endl;
00850 
00851    if ( !simrec ) {
00852      MSG("NtpMC",Msg::kWarning)
00853      << "NtpMCModule::FillNtpMCDetSimResult called with null argument pointer."
00854      << endl;
00855      return;
00856    }
00857 
00858    const SimEventResult* det = dynamic_cast<const SimEventResult*>
00859                             (simrec->FindComponent("SimEventResult"));
00860    if ( !det ) {
00861      MAXMSG("NtpMC",Msg::kWarning,1) 
00862       << "No SimEventResult component in SimSnarlRecord.\n"
00863       << "NtpMC detsim data member will not be filled." << endl;
00864       return;
00865    }
00866  
00867    ntpmcdetsim.timeShift             = det->timeShift;
00868    ntpmcdetsim.nPE                   = det->npe;
00869    ntpmcdetsim.hitPixels             = det->hitPixels;
00870    ntpmcdetsim.hitPixelsWithXtalk    = det->hitPixelsWithXtalk;
00871    ntpmcdetsim.digitsAfterFETrigger  = det->digitsAfterFETrigger;
00872    ntpmcdetsim.digitsAfterSpars      = det->digitsAfterSpars;
00873    ntpmcdetsim.digitsAfterDaqTrigger = det->digitsAfterDaqTrigger;
00874    ntpmcdetsim.totalPE               = det->totalPe;
00875    ntpmcdetsim.totalCharge           = det->totalCharge;
00876    ntpmcdetsim.adcsAfterFETrigger    = det->adcsAfterFETrigger;
00877    ntpmcdetsim.adcsAfterSpars        = det->adcsAfterSpars;
00878    ntpmcdetsim.adcsAfterDaqTrigger   = det->adcsAfterDaqTrigger;
00879    ntpmcdetsim.bigSnarl              = det->bigSnarl;
00880    ntpmcdetsim.snarls                = det->snarls;
00881    ntpmcdetsim.snarlDigits           = new UInt_t[ntpmcdetsim.snarls];
00882    ntpmcdetsim.snarlTrigger          = new UInt_t[ntpmcdetsim.snarls];
00883    ntpmcdetsim.snarlAdcs             = new Float_t[ntpmcdetsim.snarls];
00884    
00885    for (int is = 0; is < ntpmcdetsim.snarls; is++ ) {
00886      ntpmcdetsim.snarlDigits[is]  = det->snarl_digits[is];
00887      ntpmcdetsim.snarlTrigger[is] = det->snarl_trigger[is];
00888      ntpmcdetsim.snarlAdcs[is]    = det->snarl_adcs[is];
00889    }
00890 
00891    MSG("NtpMC",Msg::kVerbose) << ntpmcdetsim << endl;
00892 
00893    return;
00894 
00895 }

void NtpMCModule::FillNtpMCDigiScintHit ( TClonesArray &  ntpdigihit,
NtpMCSummary ntpmcsummary,
const SimSnarlRecord simrec 
) [private]

Definition at line 711 of file NtpMCModule.cxx.

References NtpMCDigiScintHit::dE, DigiScintHit::DE(), NtpMCDigiScintHit::dS, DigiScintHit::DS(), DigiScintHit::FailBits(), NtpMCDigiScintHit::failbits, PlexPlaneId::GetPlaneView(), UgliGeomHandle::GetStripHandle(), GetVldContext(), NtpMCDigiScintHit::index, Msg::kDebug, Msg::kVerbose, Msg::kWarning, UgliStripHandle::LocalToGlobal(), MSG, NtpMCSummary::ndigihit, DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), NtpMCDigiScintHit::pE, NtpMCDigiScintHit::pId, DigiScintHit::Plane(), NtpMCDigiScintHit::plane, NtpMCDigiScintHit::planeview, NtpMCDigiScintHit::strip, DigiScintHit::Strip(), DigiScintHit::StripEndId(), NtpMCDigiScintHit::t0, DigiScintHit::T1(), NtpMCDigiScintHit::t1, DigiScintHit::T2(), DigiScintHit::TrackId(), NtpMCDigiScintHit::trkId, NtpMCDigiScintHit::x0, NtpMCDigiScintHit::x1, DigiScintHit::X1(), DigiScintHit::X2(), NtpMCDigiScintHit::y0, NtpMCDigiScintHit::y1, DigiScintHit::Y1(), DigiScintHit::Y2(), NtpMCDigiScintHit::z0, DigiScintHit::Z1(), NtpMCDigiScintHit::z1, and DigiScintHit::Z2().

Referenced by Reco().

00713                                                                       {
00714 //
00715 //  Purpose:  Private method used to fill DigiScintHit portion of ntuple
00716 //            record.
00717 //
00718 //  Arguments: TClonesArray of digihits and SimSnarlRecord
00719 //
00720 //  Return: status.
00721 //
00722 
00723    MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpMCDigiScintHit"
00724                                                              << endl;
00725 
00726    if ( !simrec ) {
00727      MSG("NtpMC",Msg::kWarning)
00728      << "NtpMCModule::FillNtpMCDigiScintHit called with null argument pointer."
00729      << endl;
00730      return;
00731    }
00732 
00733    // Extract vldcontext and create an UgliGeomHandle
00734    const VldContext& vldc = *(simrec -> GetVldContext());
00735    
00736    UgliGeomHandle geom(vldc);
00737 
00738    const TClonesArray* simdigihitarray = dynamic_cast<const TClonesArray*>
00739                     (simrec -> FindComponent("TClonesArray","DigiScintHits"));
00740    if ( !simdigihitarray ) {
00741      MSG("NtpMC",Msg::kWarning)
00742      << "No DigiScintHit array in SimSnarlRecord." << endl;
00743      return;
00744    }
00745 
00746    Int_t ndigihit = simdigihitarray->GetLast()+1;
00747    ntpmcsummary.ndigihit = ndigihit;
00748    for ( Int_t ihit = 0; ihit < ndigihit; ihit++ ) {
00749      NtpMCDigiScintHit* ntpdigihit
00750      = new(ntpdigihitarray[ihit])NtpMCDigiScintHit();
00751      ntpdigihit->index = ihit;
00752      DigiScintHit* simdigihit
00753      = dynamic_cast<DigiScintHit*>(simdigihitarray->At(ihit));
00754      if ( simdigihit ) {
00755        ntpdigihit->planeview = simdigihit->StripEndId().GetPlaneView();
00756        ntpdigihit->strip = simdigihit->Strip();
00757        ntpdigihit->plane = simdigihit->Plane();
00758        ntpdigihit->t0 = simdigihit->T1(); // time at start of segment
00759        ntpdigihit->t1 = simdigihit->T2(); // time at end of segment
00760        ntpdigihit->dS = simdigihit->DS(); // total path length
00761        ntpdigihit->dE = simdigihit->DE(); // total energy deposited
00762        ntpdigihit->pE = simdigihit->ParticleEnergy(); // parent particle energy
00763        ntpdigihit->pId = simdigihit->ParticleId(); // parent particle Id
00764        ntpdigihit->trkId = simdigihit->TrackId(); //id of trk that produced hit
00765        ntpdigihit->failbits = simdigihit->FailBits();
00766 
00767        const UgliStripHandle& uglistp
00768         = geom.GetStripHandle(simdigihit->StripEndId());
00769        TVector3 vlocal0(simdigihit->X1(),simdigihit->Y1(),simdigihit->Z1());
00770        const TVector3& vglobal0 = uglistp.LocalToGlobal(vlocal0);
00771        ntpdigihit->x0 = vglobal0.X();
00772        ntpdigihit->y0 = vglobal0.Y();
00773        ntpdigihit->z0 = vglobal0.Z();
00774        TVector3 vlocal1(simdigihit->X2(),simdigihit->Y2(),simdigihit->Z2());
00775        const TVector3& vglobal1 = uglistp.LocalToGlobal(vlocal1);
00776        ntpdigihit->x1 = vglobal1.X();
00777        ntpdigihit->y1 = vglobal1.Y();
00778        ntpdigihit->z1 = vglobal1.Z();
00779      }
00780      MSG("NtpMC",Msg::kVerbose) << *ntpdigihit << endl;
00781    }
00782 
00783    return;
00784 
00785 }

void NtpMCModule::FillNtpMCPhotonResult ( NtpMCPhotonResult ntpmcphoton,
const SimSnarlRecord simrec 
) [private]

Definition at line 787 of file NtpMCModule.cxx.

References PhotonEventResult::bluePhotons, NtpMCPhotonResult::bluePhotons, NtpMCPhotonResult::bluePhotons_nonprescaled, PhotonEventResult::bluePhotons_nonprescaled, NtpMCPhotonResult::energyDiscardedBad, PhotonEventResult::energyDiscardedBad, NtpMCPhotonResult::energyDiscardedGeom, PhotonEventResult::energyDiscardedGeom, RecDataRecord< T >::FindComponent(), NtpMCPhotonResult::greenPhotons, PhotonEventResult::greenPhotons, NtpMCPhotonResult::greenPhotons_nonprescaled, PhotonEventResult::greenPhotons_nonprescaled, NtpMCPhotonResult::hitsDiscardedBad, PhotonEventResult::hitsDiscardedBad, PhotonEventResult::hitsDiscardedGeom, NtpMCPhotonResult::hitsDiscardedGeom, Msg::kDebug, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, NtpMCPhotonResult::totalHitEnergy, PhotonEventResult::totalHitEnergy, PhotonEventResult::totalHits, NtpMCPhotonResult::totalHits, PhotonEventResult::totalPE, NtpMCPhotonResult::totalPE, PhotonEventResult::totalPixels, NtpMCPhotonResult::totalPixels, PhotonEventResult::totalStripsHit, and NtpMCPhotonResult::totalStripsHit.

Referenced by Reco().

00788                                                                       {
00789 //
00790 //  Purpose:  Private method used to fill photon result portion of ntuple
00791 //            record.
00792 //
00793 //  Arguments: reference to photon result and SimSnarlRecord
00794 //
00795 //  Return: none.
00796 //
00797 
00798    MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpMCPhotonResult"
00799                             << endl;
00800 
00801    if ( !simrec ) {
00802      MSG("NtpMC",Msg::kWarning)
00803      << "NtpMCModule::FillNtpMCPhotonResult called with null argument pointer."
00804      << endl;
00805      return;
00806    }
00807 
00808    const PhotonEventResult* per = dynamic_cast<const PhotonEventResult*>
00809                               (simrec->FindComponent("PhotonEventResult"));
00810    if ( !per ) {
00811      MAXMSG("NtpMC",Msg::kWarning,1) 
00812       << "No PhotonEventResult component in SimSnarlRecord.\n"
00813       << "NtpMC photon data member will not be filled." << endl;
00814       return;
00815    }
00816  
00817    ntpmcphoton.hitsDiscardedGeom   = per->hitsDiscardedGeom;
00818    ntpmcphoton.hitsDiscardedBad    = per->hitsDiscardedBad;
00819    ntpmcphoton.totalHits           = per->totalHits;
00820    ntpmcphoton.totalStripsHit      = per->totalStripsHit;
00821    ntpmcphoton.bluePhotons         = per->bluePhotons;
00822    ntpmcphoton.greenPhotons        = per->greenPhotons;
00823    ntpmcphoton.bluePhotons_nonprescaled = per->bluePhotons_nonprescaled;
00824    ntpmcphoton.greenPhotons_nonprescaled = per->greenPhotons_nonprescaled;
00825    ntpmcphoton.totalPE             = per->totalPE;
00826    ntpmcphoton.totalPixels         = per->totalPixels;
00827    ntpmcphoton.totalHitEnergy      = per->totalHitEnergy;
00828    ntpmcphoton.energyDiscardedGeom = per->energyDiscardedGeom;
00829    ntpmcphoton.energyDiscardedBad  = per->energyDiscardedBad;
00830 
00831    MSG("NtpMC",Msg::kVerbose) << ntpmcphoton << endl;
00832 
00833    return;
00834 
00835 }

void NtpMCModule::FillNtpMCStdHep ( TClonesArray &  ntpstdhep,
NtpMCSummary ntpmcsummary,
const SimSnarlRecord simrec 
) [private]

Definition at line 456 of file NtpMCModule.cxx.

References BuildStdHepToDigiHit(), NtpMCStdHep::child, NtpMCStdHep::dethit, fStdHepRange, fStdHepToDigiHitMap, MsgStream::GetLogLevel(), PlexPlaneId::GetPlaneView(), MsgService::GetStream(), UgliGeomHandle::GetStripHandle(), GetVldContext(), NtpMCStdHep::IdHEP, NtpMCStdHep::index, MsgService::Instance(), NtpMCStdHep::IstHEP, Msg::kDebug, Msg::kWarning, UgliStripHandle::LocalToGlobal(), NtpMCStdHep::mass, NtpMCStdHep::mc, NtpMCStdHepHit::mom, MSG, NtpMCStdHep::ndethit, NtpMCSummary::nstdhep, NtpMCStdHep::p4, NtpMCStdHep::parent, DigiScintHit::ParticleEnergy(), DigiScintHit::ParticlePX1(), DigiScintHit::ParticlePY1(), DigiScintHit::ParticlePZ1(), DigiScintHit::Plane(), NtpMCStdHepHit::plane, NtpMCStdHepHit::planeview, NtpMCStdHep::Print(), NtpMCStdHepHit::strip, DigiScintHit::Strip(), DigiScintHit::StripEndId(), DigiScintHit::T1(), NtpMCStdHep::vtx, NtpMCStdHepHit::vtx, DigiScintHit::X1(), DigiScintHit::Y1(), and DigiScintHit::Z1().

Referenced by Reco().

00458                                                                 {
00459   //
00460   //  Purpose:  Private method used to fill shield strip portion of ntuple 
00461   //            record.
00462   //
00463   //  Arguments: TClonesArray of NtpMCStdHep and SimSnarlRecord
00464   //  
00465   //  Return: status.
00466   // 
00467 
00468   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpMCStdHep" << endl;
00469 
00470   if ( !simrec ) {
00471     MSG("NtpMC",Msg::kWarning) 
00472     << "NtpMCModule::FillNtpMCStdHep called with null argument pointer." 
00473     << endl;
00474     return;
00475   }
00476 
00477   const TClonesArray* simstdheparray = dynamic_cast<const TClonesArray*>
00478                            (simrec -> FindComponent("TClonesArray","StdHep"));
00479   if ( !simstdheparray ) {
00480     MSG("NtpMC",Msg::kWarning) << "No StdHep array in SimSnarlRecord." << endl;
00481     return;
00482   }
00483   const TClonesArray* simdigihitarray = dynamic_cast<const TClonesArray*>
00484                     (simrec -> FindComponent("TClonesArray","DigiScintHits"));
00485   if ( !simdigihitarray ) {
00486     MSG("NtpMC",Msg::kWarning) << "No DigiScintHits array in SimSnarlRecord." 
00487                                << endl;
00488     return;
00489   }
00490 
00491   // Extract vldcontext and create an UgliGeomHandle
00492   const VldContext& vldc = *(simrec -> GetVldContext()); 
00493   UgliGeomHandle geom(vldc);
00494 
00495   // Fill fStdHepToDigiHitMap with particle associated digihits
00496   BuildStdHepToDigiHit(simstdheparray,simdigihitarray);  
00497 
00498   Int_t nstdhep = simstdheparray->GetLast()+1;
00499   ntpmcsummary.nstdhep = nstdhep;
00500   Int_t mcindex = 0;
00501   for ( Int_t istd = 0; istd < nstdhep; istd++ ) {
00502     NtpMCStdHep* ntpstdhep = new(ntpstdheparray[istd])NtpMCStdHep();
00503     ntpstdhep->index = istd;
00504     TParticle* simstdhep = dynamic_cast<TParticle*>(simstdheparray->At(istd));
00505     if ( simstdhep ) {
00506       ntpstdhep->parent[0] = simstdhep->GetMother(0);
00507       ntpstdhep->parent[1] = simstdhep->GetMother(1);
00508       ntpstdhep->child[0] = simstdhep->GetDaughter(0);
00509       ntpstdhep->child[1] = simstdhep->GetDaughter(1);
00510       ntpstdhep->IdHEP  = simstdhep->GetPdgCode(); 
00511       ntpstdhep->IstHEP = simstdhep->GetStatusCode();
00512       ntpstdhep->mass   = simstdhep->GetCalcMass();
00513       ntpstdhep->p4[0]  = simstdhep->Px(); // GeV
00514       ntpstdhep->p4[1]  = simstdhep->Py(); // GeV
00515       ntpstdhep->p4[2]  = simstdhep->Pz(); // GeV
00516       ntpstdhep->p4[3]  = simstdhep->Energy();  // GeV
00517       ntpstdhep->vtx[0] = simstdhep->Vx(); // Meter 
00518       ntpstdhep->vtx[1] = simstdhep->Vy(); // Meter 
00519       ntpstdhep->vtx[2] = simstdhep->Vz(); // Meter 
00520       ntpstdhep->vtx[3] = simstdhep->T(); // Sec (previously mm/c)
00521       if ( fStdHepRange ) {
00522         if ( istd > fStdHepRange[mcindex*2+1] ) mcindex++;
00523         ntpstdhep->mc = mcindex;
00524       }
00525 
00526       // Add digiscinthit information for first/last hit in the detector
00527       std::map<Int_t,std::vector<DigiScintHit*> >::iterator mapItr 
00528                                          = fStdHepToDigiHitMap.find(istd);
00529       if ( mapItr != fStdHepToDigiHitMap.end() ) {
00530         std::vector<DigiScintHit*>& hitList = mapItr->second;
00531         ntpstdhep->ndethit = hitList.size();
00532         for ( int iend=0; iend < 2; iend++ ) {
00533           const DigiScintHit* simdigihit = 0;
00534           if ( iend == 0 ) simdigihit = hitList[iend];
00535           else simdigihit = hitList[hitList.size()-1];
00536           
00537           NtpMCStdHepHit& ntpstdhephit = ntpstdhep->dethit[iend];
00538 
00539           ntpstdhephit.planeview = simdigihit->StripEndId().GetPlaneView();
00540           ntpstdhephit.plane = simdigihit->Plane();
00541           ntpstdhephit.strip = simdigihit->Strip();
00542 
00543           const UgliStripHandle& uglistp
00544                      = geom.GetStripHandle(simdigihit->StripEndId());
00545           // DigiScintHit stores X1/X2 instead of X0/X1
00546           TVector3 vlocal0(simdigihit->X1(),simdigihit->Y1(),simdigihit->Z1());
00547 
00548           const TVector3& vglobal0 = uglistp.LocalToGlobal(vlocal0);
00549           ntpstdhephit.vtx[0] = vglobal0.X();
00550           ntpstdhephit.vtx[1] = vglobal0.Y();
00551           ntpstdhephit.vtx[2] = vglobal0.Z();
00552           ntpstdhephit.vtx[3] = simdigihit->T1(); // DigiScintHit stores T1/T2
00553           ntpstdhephit.mom[0] = simdigihit->ParticlePX1();
00554           ntpstdhephit.mom[1] = simdigihit->ParticlePY1();
00555           ntpstdhephit.mom[2] = simdigihit->ParticlePZ1();
00556           ntpstdhephit.mom[3] = simdigihit->ParticleEnergy();
00557         }
00558       }
00559     }
00560   }
00561 
00562   Int_t logLevel = MsgService::Instance()->GetStream("NtpMC")->GetLogLevel();
00563   if ( logLevel <= Msg::kDebug ) {
00564     std::string entrystr = " entries:";
00565     if ( nstdhep == 1 ) entrystr = " entry:";
00566     MSG("NtpMC",Msg::kDebug) << "\nPrint stdhep array of NtpMCStdHep w/" 
00567                              << nstdhep << entrystr.c_str() << endl;
00568     for ( Int_t istd = 0; istd < nstdhep; istd++ ) {
00569       const NtpMCStdHep* ntpstdhep 
00570       = dynamic_cast<const NtpMCStdHep*>(ntpstdheparray.At(istd));
00571       if ( ntpstdhep->parent[0] == -1 ) 
00572          ntpstdhep->Print(std::cout,"","",&ntpstdheparray);
00573       
00574     }
00575   }
00576 
00577   fStdHepToDigiHitMap.clear();
00578   
00579   return;
00580 
00581 }

void NtpMCModule::FillNtpMCTruth ( TClonesArray &  ntpmc,
NtpMCSummary ntpmcsummary,
const SimSnarlRecord simrec,
const MomNavigator mom 
) [private]

Definition at line 244 of file NtpMCModule.cxx.

References REROOT_NeuKin::A(), NtpMCTruth::a, BuildMCToStdHep(), compareP4(), NtpMCTruth::emfrac, REROOT_NeuKin::EMFrac(), NtpMCSummary::error, FillNtpFluxInfo(), FillNtpFluxWgt(), RecDataRecord< T >::FindComponent(), NtpMCTruth::flux, NtpMCTruth::fluxwgt, fStdHepRange, RawChannelId::GetElecType(), MomNavigator::GetFragment(), PlexPlaneId::GetPlaneView(), Truthifier::GetSignal(), REROOT_NeuKin::IAction(), NtpMCTruth::iaction, NtpMCTruth::iboson, REROOT_NeuKin::IBoson(), NtpMCTruth::iflags, REROOT_NeuKin::IFlags(), NtpMCTruth::index, Truthifier::Instance(), NtpMCTruth::inu, REROOT_NeuKin::INu(), NtpMCTruth::inunoosc, REROOT_NeuKin::INuNoOsc(), REROOT_NeuKin::IResonance(), NtpMCTruth::iresonance, TruthHelper::IsDocStatus(), TruthHelper::IsNeutrino(), NtpMCTruth::istruckq, REROOT_NeuKin::IStruckQ(), REROOT_NeuKin::ITg(), NtpMCTruth::itg, Msg::kDebug, ElecType::kQIE, PlaneView::kU, PlaneView::kV, Msg::kWarning, MAXMSG, MSG, NtpMCTruth::ndigu, NtpMCTruth::ndigv, NtpMCSummary::nmc, NtpMCTruth::p4el1, REROOT_NeuKin::P4El1(), NtpMCTruth::p4el2, REROOT_NeuKin::P4El2(), REROOT_NeuKin::P4Mu1(), NtpMCTruth::p4mu1, REROOT_NeuKin::P4Mu2(), NtpMCTruth::p4mu2, REROOT_NeuKin::P4Neu(), NtpMCTruth::p4neu, NtpMCTruth::p4neunoosc, REROOT_NeuKin::P4NeuNoOsc(), REROOT_NeuKin::P4Shw(), NtpMCTruth::p4shw, REROOT_NeuKin::P4Tau(), NtpMCTruth::p4tau, NtpMCTruth::p4tgt, REROOT_NeuKin::P4Tgt(), NtpMCTruth::q2, REROOT_NeuKin::Q2(), REROOT_NeuKin::Sigma(), NtpMCTruth::sigma, REROOT_NeuKin::SigmaDiff(), NtpMCTruth::sigmadiff, NtpMCTruth::stdhep, DigiScintHit::StripEndId(), th(), NtpMCTruth::tphu, NtpMCTruth::tphv, DigiScintHit::TrackId(), NtpMCTruth::vtxx, NtpMCTruth::vtxy, NtpMCTruth::vtxz, REROOT_NeuKin::W2(), NtpMCTruth::w2, REROOT_NeuKin::X(), NtpMCTruth::x, REROOT_NeuKin::Y(), NtpMCTruth::y, REROOT_NeuKin::Z(), and NtpMCTruth::z.

Referenced by Reco().

00247                                                           {
00248   //
00249   //  Purpose:  Private method used to fill mc truth portion of ntuple record.
00250   //
00251   //  Arguments: NtpMCTruth, SimSnarlRecord and Mom for Truthifier (for filling
00252   //             ndigu(v)/tphu(v) per true event
00253   //  
00254   //  Return: status.
00255   // 
00256 
00257   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::FillNtpMCTruth" << endl;
00258 
00259   if ( !simrec ) {
00260     MSG("NtpMC",Msg::kWarning) 
00261     << "NtpMCModule::FillNtpMCTruth called with null argument pointer." 
00262     << endl;
00263     return;
00264   }
00265 
00266   // SimSnarlRecord does *NOT* have REROOT_NeuVtx objects
00267   // (these rely on gMINFast to give correct z offset)
00268   // so we must retrieve the vertex info from the StdHep array
00269 
00270   const TClonesArray* neukinarray = dynamic_cast<const TClonesArray*>
00271                           (simrec->FindComponent("TClonesArray","NeuKinList"));
00272   const TClonesArray* stdheparray = dynamic_cast<const TClonesArray*>
00273                           (simrec->FindComponent("TClonesArray","StdHep"));
00274   const TClonesArray* finfoarray = dynamic_cast<const TClonesArray *>
00275     (simrec->FindComponent("TClonesArray","FluxInfoList"));
00276   const TClonesArray* fwgtarray = dynamic_cast<const TClonesArray *>
00277     (simrec->FindComponent("TClonesArray","FluxWgtList"));
00278   
00279   if ( neukinarray && neukinarray->GetEntriesFast() != 0 ) {
00280     REROOT_NeuKin* rneukin 
00281         = dynamic_cast<REROOT_NeuKin*>(neukinarray->At(0));
00282     if ( rneukin -> INu() != 0 ) {
00283       // Only complain if not a dummy NeuKin entry, such is generated
00284       // when user uses KINE card to set particle initial state
00285       if ( !finfoarray || finfoarray->GetEntriesFast() == 0 ) {
00286         MAXMSG("NtpMC",Msg::kWarning,1) << "FluxInfoList is empty.\n"
00287           << "mc.flux will not be properly filled!" << endl;
00288       }
00289       if ( !fwgtarray || fwgtarray->GetEntriesFast() == 0 ) {
00290         MAXMSG("NtpMC",Msg::kWarning,1) << "FluxWgtList is empty.\n"
00291           << "mc.fluxwgt will not be properly filled!" << endl;
00292       }
00293     }
00294   }
00295 
00296 
00297   if ( neukinarray && stdheparray ) {
00298     Int_t nneukin = neukinarray->GetLast()+1;
00299     ntpmcsummary.nmc = nneukin;
00300     // Set error bit if build failed
00301     if ( !BuildMCToStdHep(neukinarray,stdheparray) ) ntpmcsummary.error = 1;
00302     
00303     for ( Int_t ineu = 0; ineu < nneukin; ineu++ ) {
00304       NtpMCTruth* ntpmctruth = new(ntpmctrutharray[ineu])NtpMCTruth();
00305       ntpmctruth->index = ineu;
00306       if ( fStdHepRange ) {
00307         ntpmctruth->stdhep[0] = fStdHepRange[ineu*2+0];
00308         ntpmctruth->stdhep[1] = fStdHepRange[ineu*2+1];
00309       }
00310       
00311       REROOT_NeuKin* rneukin 
00312         = dynamic_cast<REROOT_NeuKin*>(neukinarray->At(ineu));
00313       if ( rneukin ) {
00314         ntpmctruth->inu        = rneukin->INu();
00315         ntpmctruth->inunoosc   = rneukin->INuNoOsc();
00316         ntpmctruth->itg        = rneukin->ITg();
00317         ntpmctruth->iboson     = rneukin->IBoson();
00318         ntpmctruth->iresonance = rneukin->IResonance();
00319         ntpmctruth->iaction    = rneukin->IAction();
00320         ntpmctruth->istruckq   = rneukin->IStruckQ();
00321         ntpmctruth->iflags     = rneukin->IFlags();
00322         ntpmctruth->a          = rneukin->A();
00323         ntpmctruth->z          = rneukin->Z();
00324         ntpmctruth->sigma      = rneukin->Sigma();
00325         ntpmctruth->sigmadiff  = rneukin->SigmaDiff();
00326         for (int i = 0; i < 4; i++) {
00327           ntpmctruth->p4neu[i] = rneukin->P4Neu()[i];
00328           ntpmctruth->p4neunoosc[i] = rneukin->P4NeuNoOsc()[i];
00329           ntpmctruth->p4tgt[i] = rneukin->P4Tgt()[i];
00330           ntpmctruth->p4shw[i] = rneukin->P4Shw()[i];
00331           ntpmctruth->p4mu1[i] = rneukin->P4Mu1()[i];
00332           ntpmctruth->p4mu2[i] = rneukin->P4Mu2()[i];
00333           ntpmctruth->p4el1[i] = rneukin->P4El1()[i];
00334           ntpmctruth->p4el2[i] = rneukin->P4El2()[i];
00335           ntpmctruth->p4tau[i] = rneukin->P4Tau()[i];
00336         }
00337         ntpmctruth->x  = rneukin->X();
00338         ntpmctruth->y  = rneukin->Y();
00339         ntpmctruth->q2 = rneukin->Q2();
00340         ntpmctruth->w2 = rneukin->W2();
00341         ntpmctruth->emfrac = rneukin->EMFrac();
00342       }
00343     
00344       RawRecord* rawrec = dynamic_cast<RawRecord*>
00345        (mom->GetFragment("RawRecord","","DaqSnarl"));
00346 
00347       if ( rawrec && ntpmctruth->stdhep[0] >= 0 ) {
00348         const Truthifier& truth = Truthifier::Instance(mom);
00349         TIter itr = rawrec -> GetRawBlockIter();
00350         while (RawDataBlock* rawblk=dynamic_cast<RawDataBlock*>(itr.Next())){
00351           RawDigitDataBlock* rddb = dynamic_cast<RawDigitDataBlock*>(rawblk);
00352           if ( rddb ) {
00353             TIter diter = rddb -> GetDatumIter();
00354             while (RawDigit* rawdigit=dynamic_cast<RawDigit*>(diter.Next())) {
00355               RawChannelId digitRCId = rawdigit->GetChannel();
00356               Double_t adc_offset = 0;
00357               if ( digitRCId.GetElecType() == ElecType::kQIE ) adc_offset=50;
00358               Bool_t digfound = false;
00359               Bool_t inu = false;
00360               Bool_t inv = false;
00361               if ( const DigiSignal* signal = truth.GetSignal(rawdigit) ) {
00362                 if ( signal ) {
00363                   for(UInt_t ihit=0; ihit<signal->GetNumberOfHits(); ihit++) {
00364                     const DigiScintHit* hit = signal->GetHit(ihit);
00365                     if ( hit ) {
00366                       Int_t trkid = abs(hit->TrackId());
00367                       if ( trkid >= ntpmctruth->stdhep[0] && 
00368                            trkid <= ntpmctruth->stdhep[1] ) {
00369                         digfound = true;
00370                         PlexStripEndId seid = hit->StripEndId();
00371                         if ( seid.GetPlaneView()==PlaneView::kU )inu = true;
00372                         if ( seid.GetPlaneView()==PlaneView::kV )inv = true;
00373                       }
00374                     }
00375                   }
00376                 }
00377               }
00378               if ( digfound ) {
00379                 if ( inu ) {
00380                   ntpmctruth->ndigu += 1;
00381                   ntpmctruth->tphu += (rawdigit->GetADC()-adc_offset);
00382                 }
00383                 else if ( inv ) {
00384                   ntpmctruth->ndigv += 1;
00385                   ntpmctruth->tphv += (rawdigit->GetADC()-adc_offset);
00386                 }
00387               }
00388             }
00389           }
00390         }         
00391       }
00392 
00393       TruthHelper th;  // used to access methos IsNeutrino & IsDocStatus
00394       // look for the neutrino vector in StdHep that matches NeuKin
00395       for (int ihep=0; ihep<= stdheparray->GetLast(); ++ihep) {
00396         TParticle* part = 
00397           dynamic_cast<TParticle*>(stdheparray->At(ihep));
00398         if ( !part || !th.IsNeutrino(part) || !th.IsDocStatus(part) ) continue;
00399         if ( !compareP4(ntpmctruth->p4neu,part) ) continue;
00400         // this should be the matching entry for neutrino
00401         
00402         // take the vertex from the primary lepton origin 
00403         // should be first daughter of neutrino
00404         int ihep_lepton_out = part->GetFirstDaughter();
00405         TParticle* outlep = 
00406           dynamic_cast<TParticle*>(stdheparray->At(ihep_lepton_out));
00407         ntpmctruth->vtxx = outlep->Vx();
00408         ntpmctruth->vtxy = outlep->Vy();
00409         ntpmctruth->vtxz = outlep->Vz();
00410       }
00411 
00412       //Fill gnumi flux info.  Added by TV, 10-31-2005
00413       if(finfoarray && finfoarray->GetEntriesFast() != 0){
00414         if(finfoarray->GetEntriesFast()<=ineu) {
00415           MAXMSG("NtpMC",Msg::kWarning,5)
00416             <<"Can not get "<<ineu<<" entry from FluxInfo Array "
00417             <<" which only has "<<finfoarray->GetEntriesFast()<<endl;
00418         }
00419         else {
00420           const REROOT_FluxInfo *rrfi = dynamic_cast<const REROOT_FluxInfo*>
00421             (finfoarray->At(ineu));
00422           FillNtpFluxInfo(ntpmctruth->flux,rrfi);
00423         }
00424       }
00425       if(fwgtarray && fwgtarray->GetEntriesFast() != 0){
00426         if(fwgtarray->GetEntriesFast()<=ineu){
00427           MAXMSG("NtpMC",Msg::kWarning,5)
00428             <<"Can not get "<<ineu<<" entry from FluxWgt Array "
00429             <<" which only has "<<fwgtarray->GetEntriesFast()<<endl;
00430         }
00431         else{
00432           const REROOT_FluxWgt *rrfw = dynamic_cast<const REROOT_FluxWgt*>
00433             (fwgtarray->At(ineu));
00434           FillNtpFluxWgt(ntpmctruth->fluxwgt,rrfw);
00435         }
00436       }
00437       
00438       MSG("NtpMC",Msg::kDebug) << *ntpmctruth << endl;
00439     }
00440     
00441 
00442   }
00443   else {
00444     MSG("NtpMC",Msg::kWarning) 
00445      << "Either NeuKin list " << neukinarray 
00446      << " or StdHep list " << stdheparray
00447      << " is missing in SimSnarlRecord.\nNtpMCTruth array will not be filled."
00448      << endl;
00449     return;
00450   }
00451 
00452   return;
00453 
00454 }

JobCResult NtpMCModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 136 of file NtpMCModule.cxx.

References NtpMCGenInfo::codename, NtpStRecord::detsim, NtpStRecord::digihit, FillNtpMCDetSimResult(), FillNtpMCDigiScintHit(), FillNtpMCPhotonResult(), FillNtpMCStdHep(), FillNtpMCTruth(), fRecordName, fRecordTitle, fSimSnarlRecordName, fStdHepRange, fUseStandard, fWriteDigiHit, NtpMCSummary::geninfo, RecDataHeader::GetErrorCode(), MomNavigator::GetFragment(), RecRecordImp< T >::GetJobHistory(), SimSnarlHeader::GetMcGenCodename(), SimSnarlHeader::GetMcGenHostname(), SimSnarlHeader::GetMcGenTime(), RecPhysicsHeader::GetRemoteSpillType(), RecDataHeader::GetRun(), RecDataHeader::GetRunType(), SimSnarlRecord::GetSimSnarlHeader(), RecPhysicsHeader::GetSnarl(), RecDataHeader::GetSubRun(), RecPhysicsHeader::GetTimeFrame(), RecPhysicsHeader::GetTrigSrc(), RecHeader::GetVldContext(), NtpMCGenInfo::hostname, Msg::kDebug, RecJobHistory::kNtpMC, JobCResult::kPassed, Msg::kWarning, NtpStRecord::mc, NtpStRecord::mchdr, MSG, NtpStRecord::photon, JobCResult::SetFailed(), JobCResult::SetWarning(), NtpStRecord::stdhep, and NtpMCGenInfo::time.

00136                                               {
00137   //
00138   //  Purpose:  Create and fill ntuple record.
00139   //
00140   //  Arguments: mom.
00141   //  
00142   //  Return: status.
00143   // 
00144 
00145   JobCResult result(JobCResult::kPassed);  
00146   MSG("NtpMC",Msg::kDebug) << "NtpMCModule::Reco" << endl;
00147 
00148   // Check that mom exists.
00149   assert(mom);
00150   
00151   SimSnarlRecord* simrec = dynamic_cast<SimSnarlRecord*>
00152             (mom->GetFragment("SimSnarlRecord",fSimSnarlRecordName.c_str()));
00153   if ( !simrec ) {
00154     MSG("NtpMC",Msg::kWarning) << "No SimSnarlRecord of name "
00155                  << fSimSnarlRecordName.c_str() << " in Mom." << endl;
00156     result.SetWarning().SetFailed();
00157     return result;
00158   }
00159 
00160   const SimSnarlHeader* simhdr = simrec->GetSimSnarlHeader();
00161 
00162   if ( fStdHepRange ) delete [] fStdHepRange; fStdHepRange=0;
00163   
00164   TClonesArray* ntpmcarrptr = 0;
00165   TClonesArray* ntpstdheparrptr = 0;
00166   TClonesArray* ntpdigihitarrptr = 0;
00167   
00168   NtpStRecord* ntpstrec = 0;
00169   NtpMCRecord* ntpmcrec = 0;
00170   NtpMCSummary* ntpmcsummaryptr = 0;
00171   NtpMCPhotonResult* ntpmcphotonptr = 0;
00172   NtpMCDetSimResult* ntpmcdetsimptr = 0;
00173   
00174   if ( fUseStandard ) {
00175     ntpstrec = dynamic_cast<NtpStRecord*>(mom->GetFragment("NtpStRecord",
00176                                                 fRecordName.c_str()));
00177     if ( !ntpstrec) {
00178       MSG("NtpMC",Msg::kWarning) << "No NtpStRecord in Mom of name "
00179                         << fRecordName.c_str() << " and UseStandard."
00180                         << "\nMust call NtpStModule::Get() first." << endl;
00181       result.SetWarning().SetFailed();
00182       return result;
00183     }
00184     ntpmcarrptr = ntpstrec->mc;
00185     ntpstdheparrptr = ntpstrec->stdhep;
00186     ntpdigihitarrptr = ntpstrec->digihit;
00187     ntpmcsummaryptr = &(ntpstrec->mchdr);
00188     ntpmcphotonptr = &(ntpstrec->photon);
00189     ntpmcdetsimptr = &(ntpstrec->detsim);
00190   }
00191   else {
00192     // Create a NtpMCRecord
00193     RecCandHeader ntphdr(simhdr->GetVldContext(),simhdr->GetRun(),
00194            simhdr->GetSubRun(),simhdr->GetRunType(),simhdr->GetErrorCode(),
00195            simhdr->GetSnarl(),simhdr->GetTrigSrc(),simhdr->GetTimeFrame(),
00196            simhdr->GetRemoteSpillType(),-1);
00197     ntpmcrec = new NtpMCRecord(ntphdr);
00198     ntpmcrec -> SetName(fRecordName.c_str());
00199     ntpmcrec -> SetTitle(fRecordTitle.c_str());
00200 
00201     RecJobHistory& jobhist 
00202           = const_cast<RecJobHistory&>(ntpmcrec->GetJobHistory());
00203     jobhist.Append(simrec->GetJobHistory());
00204     jobhist.CreateJobRecord(RecJobHistory::kNtpMC);
00205     
00206     ntpmcarrptr = ntpmcrec->mc;
00207     ntpstdheparrptr = ntpmcrec->stdhep;
00208     ntpdigihitarrptr = ntpmcrec->digihit;
00209     ntpmcsummaryptr = &(ntpmcrec->mchdr);
00210     ntpmcphotonptr = &(ntpmcrec->photon);
00211     ntpmcdetsimptr = &(ntpmcrec->detsim);
00212   }
00213   
00214   TClonesArray& ntpmctrutharray = *(ntpmcarrptr);
00215   TClonesArray& ntpstdheparray  = *(ntpstdheparrptr);
00216   NtpMCSummary& ntpmcsummary = *(ntpmcsummaryptr);
00217   NtpMCPhotonResult& ntpmcphoton = *(ntpmcphotonptr);
00218   NtpMCDetSimResult& ntpmcdetsim = *(ntpmcdetsimptr);
00219   
00220   ntpmcsummary.geninfo.time  = simhdr->GetMcGenTime();
00221   ntpmcsummary.geninfo.codename = simhdr->GetMcGenCodename();
00222   ntpmcsummary.geninfo.hostname = simhdr->GetMcGenHostname();
00223 
00224   this -> FillNtpMCTruth(ntpmctrutharray,ntpmcsummary,simrec,mom);
00225 
00226   this -> FillNtpMCStdHep(ntpstdheparray,ntpmcsummary,simrec);
00227   if ( fWriteDigiHit ) {
00228     TClonesArray& ntpdigihitarray = *(ntpdigihitarrptr);
00229     this -> FillNtpMCDigiScintHit(ntpdigihitarray,ntpmcsummary,simrec);
00230   }
00231 
00232   this -> FillNtpMCPhotonResult(ntpmcphoton,simrec);
00233   this -> FillNtpMCDetSimResult(ntpmcdetsim,simrec);
00234 
00235   // pass record to mom to own
00236   MSG("NtpMC",Msg::kDebug) << ntpmcsummary << endl;
00237   
00238   if ( !fUseStandard)  mom -> AdoptFragment(ntpmcrec);
00239   
00240   return result;
00241 
00242 }


Member Data Documentation

string NtpMCModule::fRecordName [private]

Definition at line 76 of file NtpMCModule.h.

Referenced by Config(), and Reco().

string NtpMCModule::fRecordTitle [private]

Definition at line 77 of file NtpMCModule.h.

Referenced by Config(), and Reco().

Definition at line 75 of file NtpMCModule.h.

Referenced by Config(), and Reco().

Int_t* NtpMCModule::fStdHepRange [private]

Definition at line 74 of file NtpMCModule.h.

Referenced by BuildMCToStdHep(), FillNtpMCStdHep(), FillNtpMCTruth(), and Reco().

std::map<Int_t,std::vector<DigiScintHit*> > NtpMCModule::fStdHepToDigiHitMap [private]

Definition at line 78 of file NtpMCModule.h.

Referenced by BuildStdHepToDigiHit(), and FillNtpMCStdHep().

bool NtpMCModule::fUseStandard [private]

Definition at line 73 of file NtpMCModule.h.

Referenced by Config(), and Reco().

Int_t NtpMCModule::fWriteDigiHit [private]

Definition at line 72 of file NtpMCModule.h.

Referenced by Config(), and Reco().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1