Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

Constructor & Destructor Documentation

NtpMCModule::NtpMCModule  )  [inline]
 

Definition at line 38 of file NtpMCModule.h.

References fRecordName, fRecordTitle, fSimSnarlRecordName, fStdHepRange, fUseStandard, and fWriteDigiHit.

NtpMCModule::~NtpMCModule  )  [inline]
 

Definition at line 40 of file NtpMCModule.h.

00040 {}


Member Function Documentation

bool NtpMCModule::BuildMCToStdHep const TClonesArray *  ,
const TClonesArray * 
[private]
 

Definition at line 581 of file NtpMCModule.cxx.

References fStdHepRange, and MSG.

Referenced by FillNtpMCTruth().

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

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

Definition at line 653 of file NtpMCModule.cxx.

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

Referenced by FillNtpMCStdHep().

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

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 109 of file NtpMCModule.cxx.

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

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

const Registry & NtpMCModule::DefaultConfig  )  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 79 of file NtpMCModule.cxx.

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

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

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

Definition at line 892 of file NtpMCModule.cxx.

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

Referenced by FillNtpMCTruth().

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

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

Definition at line 972 of file NtpMCModule.cxx.

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

Referenced by FillNtpMCTruth().

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

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

Definition at line 833 of file NtpMCModule.cxx.

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

Referenced by Reco().

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

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

Definition at line 708 of file NtpMCModule.cxx.

References DigiScintHit::DE(), NtpMCDigiScintHit::dE, DigiScintHit::DS(), NtpMCDigiScintHit::dS, PlexPlaneId::GetPlaneView(), UgliGeomHandle::GetStripHandle(), DataUtil::GetVldContext(), NtpMCDigiScintHit::index, UgliStripHandle::LocalToGlobal(), MSG, NtpMCSummary::ndigihit, DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), NtpMCDigiScintHit::pE, NtpMCDigiScintHit::pId, DigiScintHit::Plane(), NtpMCDigiScintHit::plane, NtpMCDigiScintHit::planeview, DigiScintHit::Strip(), NtpMCDigiScintHit::strip, DigiScintHit::StripEndId(), NtpMCDigiScintHit::t0, NtpMCDigiScintHit::t1, DigiScintHit::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, NtpMCDigiScintHit::z1, DigiScintHit::Z1(), and DigiScintHit::Z2().

Referenced by Reco().

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

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

Definition at line 783 of file NtpMCModule.cxx.

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

Referenced by Reco().

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

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

Definition at line 453 of file NtpMCModule.cxx.

References BuildStdHepToDigiHit(), NtpMCStdHep::child, NtpMCStdHep::dethit, fStdHepRange, fStdHepToDigiHitMap, MsgStream::GetLogLevel(), PlexPlaneId::GetPlaneView(), MsgService::GetStream(), UgliGeomHandle::GetStripHandle(), DataUtil::GetVldContext(), NtpMCStdHep::IdHEP, NtpMCStdHep::index, MsgService::Instance(), NtpMCStdHep::IstHEP, 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(), DigiScintHit::Strip(), NtpMCStdHepHit::strip, DigiScintHit::StripEndId(), DigiScintHit::T1(), NtpMCStdHepHit::vtx, NtpMCStdHep::vtx, DigiScintHit::X1(), DigiScintHit::Y1(), and DigiScintHit::Z1().

Referenced by Reco().

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

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

Definition at line 241 of file NtpMCModule.cxx.

References REROOT_NeuKin::A(), NtpMCTruth::a, abs(), BuildMCToStdHep(), compareP4(), REROOT_NeuKin::EMFrac(), NtpMCTruth::emfrac, NtpMCSummary::error, FillNtpFluxInfo(), FillNtpFluxWgt(), RecDataRecord< T >::FindComponent(), NtpMCTruth::flux, NtpMCTruth::fluxwgt, fStdHepRange, RawDigit::GetADC(), RawDigit::GetChannel(), RawChannelId::GetElecType(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), PlexPlaneId::GetPlaneView(), Truthifier::GetSignal(), REROOT_NeuKin::IAction(), NtpMCTruth::iaction, REROOT_NeuKin::IBoson(), NtpMCTruth::iboson, REROOT_NeuKin::IFlags(), NtpMCTruth::iflags, NtpMCTruth::index, Truthifier::Instance(), REROOT_NeuKin::INu(), NtpMCTruth::inu, REROOT_NeuKin::INuNoOsc(), NtpMCTruth::inunoosc, REROOT_NeuKin::IResonance(), NtpMCTruth::iresonance, TruthHelper::IsDocStatus(), TruthHelper::IsNeutrino(), REROOT_NeuKin::IStruckQ(), NtpMCTruth::istruckq, REROOT_NeuKin::ITg(), NtpMCTruth::itg, MAXMSG, MSG, NtpMCTruth::ndigu, NtpMCTruth::ndigv, NtpMCSummary::nmc, REROOT_NeuKin::P4El1(), NtpMCTruth::p4el1, REROOT_NeuKin::P4El2(), NtpMCTruth::p4el2, REROOT_NeuKin::P4Mu1(), NtpMCTruth::p4mu1, REROOT_NeuKin::P4Mu2(), NtpMCTruth::p4mu2, REROOT_NeuKin::P4Neu(), NtpMCTruth::p4neu, REROOT_NeuKin::P4NeuNoOsc(), NtpMCTruth::p4neunoosc, REROOT_NeuKin::P4Shw(), NtpMCTruth::p4shw, REROOT_NeuKin::P4Tau(), NtpMCTruth::p4tau, REROOT_NeuKin::P4Tgt(), NtpMCTruth::p4tgt, REROOT_NeuKin::Q2(), NtpMCTruth::q2, REROOT_NeuKin::Sigma(), NtpMCTruth::sigma, REROOT_NeuKin::SigmaDiff(), NtpMCTruth::sigmadiff, NtpMCTruth::stdhep, DigiScintHit::StripEndId(), 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().

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

JobCResult NtpMCModule::Reco MomNavigator mom  )  [virtual]
 

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 133 of file NtpMCModule.cxx.

References RecJobHistory::Append(), NtpMCGenInfo::codename, RecJobHistory::CreateJobRecord(), NtpMCRecord::detsim, NtpStRecord::detsim, NtpMCRecord::digihit, NtpStRecord::digihit, FillNtpMCDetSimResult(), FillNtpMCDigiScintHit(), FillNtpMCPhotonResult(), FillNtpMCStdHep(), FillNtpMCTruth(), fRecordName, fRecordTitle, fSimSnarlRecordName, fStdHepRange, 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, NtpMCRecord::mc, NtpStRecord::mc, NtpMCRecord::mchdr, NtpStRecord::mchdr, MSG, NtpMCRecord::photon, NtpStRecord::photon, JobCResult::SetFailed(), JobCResult::SetWarning(), NtpMCRecord::stdhep, NtpStRecord::stdhep, and NtpMCGenInfo::time.

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


Member Data Documentation

string NtpMCModule::fRecordName [private]
 

Definition at line 76 of file NtpMCModule.h.

Referenced by Config(), NtpMCModule(), and Reco().

string NtpMCModule::fRecordTitle [private]
 

Definition at line 77 of file NtpMCModule.h.

Referenced by Config(), NtpMCModule(), and Reco().

string NtpMCModule::fSimSnarlRecordName [private]
 

Definition at line 75 of file NtpMCModule.h.

Referenced by Config(), NtpMCModule(), and Reco().

Int_t* NtpMCModule::fStdHepRange [private]
 

Definition at line 74 of file NtpMCModule.h.

Referenced by BuildMCToStdHep(), FillNtpMCStdHep(), FillNtpMCTruth(), NtpMCModule(), 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 NtpMCModule().

Int_t NtpMCModule::fWriteDigiHit [private]
 

Definition at line 72 of file NtpMCModule.h.

Referenced by Config(), and NtpMCModule().


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:02:24 2008 for loon by  doxygen 1.3.9.1