Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes

WCSimVertexSeedNtuple Class Reference

#include "WCSimVertexSeedNtuple.hh"

Inheritance diagram for WCSimVertexSeedNtuple:
WCSimNtuple

List of all members.

Public Member Functions

 WCSimVertexSeedNtuple ()
 ~WCSimVertexSeedNtuple ()
void Fill (WCSimTrueEvent *trueEvent, WCSimRecoEvent *recoEvent)
void CloseFile ()
void Reset ()
virtual void OpenFile (const char *filename)
void SetFileName (const char *filename)

Protected Attributes

TString fNtpFileName

Private Member Functions

void ResetVariables ()
void WriteVariables (WCSimTrueEvent *trueEvent, WCSimRecoEvent *recoEvent)
void WriteToFile ()

Private Attributes

TFile * fRecoFile
TTree * fRecoTree
TString fRecoFileName
Int_t fRunNum
Int_t fEventNum
Int_t fTriggerNum
Int_t index
Int_t last
Double_t fTrueVtxX
Double_t fTrueVtxY
Double_t fTrueVtxZ
Double_t fTrueDirX
Double_t fTrueDirY
Double_t fTrueDirZ
Double_t fRecoVtxX
Double_t fRecoVtxY
Double_t fRecoVtxZ
Double_t fRecoVtxTime
Double_t fRecoDelta
Double_t fRecoDeltaTrans
Double_t fRecoDeltaLong

Detailed Description

Definition at line 12 of file WCSimVertexSeedNtuple.hh.


Constructor & Destructor Documentation

WCSimVertexSeedNtuple::WCSimVertexSeedNtuple (  ) 
WCSimVertexSeedNtuple::~WCSimVertexSeedNtuple (  ) 

Definition at line 21 of file WCSimVertexSeedNtuple.cc.

{

}


Member Function Documentation

void WCSimVertexSeedNtuple::CloseFile (  )  [virtual]

Reimplemented from WCSimNtuple.

Definition at line 184 of file WCSimVertexSeedNtuple.cc.

References WCSimNtuple::fNtpFileName, fRecoFile, and fRecoTree.

{
  TDirectory* tmpd = 0;

  if( fRecoFile ){
    tmpd = gDirectory;
    std::cout << " *** WCSimVertexSeedNtuple::CloseFile() *** " << std::endl;
    std::cout << "  closing file: " << fNtpFileName.Data() << std::endl;
    fRecoFile->cd();
    fRecoTree->Write();
    fRecoFile->Close();
    gDirectory = tmpd;
  }

  return;
}

void WCSimVertexSeedNtuple::Fill ( WCSimTrueEvent trueEvent,
WCSimRecoEvent recoEvent 
) [virtual]

Reimplemented from WCSimNtuple.

Definition at line 36 of file WCSimVertexSeedNtuple.cc.

References ResetVariables(), and WriteVariables().

{
  this->ResetVariables();
  this->WriteVariables( trueEvent, recoEvent );
}

virtual void WCSimNtuple::OpenFile ( const char *  filename  )  [inline, virtual, inherited]

Definition at line 19 of file WCSimNtuple.hh.

{ }

void WCSimVertexSeedNtuple::Reset (  )  [virtual]

Reimplemented from WCSimNtuple.

Definition at line 26 of file WCSimVertexSeedNtuple.cc.

References fRecoFile, and fRecoTree.

{
  std::cout << " *** WCSimVertexSeedNtuple::Reset() *** " << std::endl;

  fRecoFile = 0;
  fRecoTree = 0;

  return;
}

void WCSimVertexSeedNtuple::ResetVariables (  )  [private]

Definition at line 42 of file WCSimVertexSeedNtuple.cc.

References fEventNum, fRecoDelta, fRecoDeltaLong, fRecoDeltaTrans, fRecoVtxTime, fRecoVtxX, fRecoVtxY, fRecoVtxZ, fRunNum, fTriggerNum, fTrueDirX, fTrueDirY, fTrueDirZ, fTrueVtxX, fTrueVtxY, fTrueVtxZ, index, and last.

Referenced by Fill().

{
 // reset variables
  // ===============
  fRunNum = -1;
  fEventNum = -1;
  fTriggerNum = -1;

  index = -1;
  last = -1;

  fTrueVtxX = 0.0;
  fTrueVtxY = 0.0;
  fTrueVtxZ = 0.0;
  fTrueDirX = 0.0;
  fTrueDirY = 0.0;
  fTrueDirZ = 0.0;

  fRecoVtxX = 0.0;
  fRecoVtxY = 0.0;
  fRecoVtxZ = 0.0;
  fRecoVtxTime = 0.0;

  fRecoDelta = -99999.9;
  fRecoDeltaTrans = -99999.9;
  fRecoDeltaLong = -99999.9;

  return;
}

void WCSimNtuple::SetFileName ( const char *  filename  )  [inline, inherited]

Definition at line 24 of file WCSimNtuple.hh.

References WCSimNtuple::fNtpFileName.

Referenced by WCSimNtupleWriter::BuildNtuple(), and main().

                                         { 
    fNtpFileName = filename; 
  }

void WCSimVertexSeedNtuple::WriteToFile (  )  [private]

Definition at line 143 of file WCSimVertexSeedNtuple.cc.

References fEventNum, WCSimNtuple::fNtpFileName, fRecoDelta, fRecoDeltaLong, fRecoDeltaTrans, fRecoFile, fRecoTree, fRecoVtxTime, fRecoVtxX, fRecoVtxY, fRecoVtxZ, fRunNum, fTriggerNum, fTrueDirX, fTrueDirY, fTrueDirZ, fTrueVtxX, fTrueVtxY, fTrueVtxZ, index, and last.

Referenced by WriteVariables().

{
  TDirectory* tmpd = 0;

  if( fRecoFile==0 ){
    tmpd = gDirectory;
    std::cout << " *** WCSimVertexSeedNtuple::OpenFile(...) *** " << std::endl;
    std::cout << "  opening file: " << fNtpFileName.Data() << std::endl;
    fRecoFile = new TFile(fNtpFileName.Data(),"recreate");
    fRecoTree = new TTree("ntuple","my analysis ntuple");
    fRecoTree->Branch("run",&fRunNum,"run/I");
    fRecoTree->Branch("event",&fEventNum,"event/I");
    fRecoTree->Branch("trigger",&fTriggerNum,"trigger/I");    
    fRecoTree->Branch("index",&index,"index/I");
    fRecoTree->Branch("last",&last,"last/I");
    fRecoTree->Branch("trueVtxX",&fTrueVtxX,"trueVtxX/D");
    fRecoTree->Branch("trueVtxY",&fTrueVtxY,"trueVtxY/D");
    fRecoTree->Branch("trueVtxZ",&fTrueVtxZ,"trueVtxZ/D");   
    fRecoTree->Branch("trueDirX",&fTrueDirX,"trueDirX/D");
    fRecoTree->Branch("trueDirY",&fTrueDirY,"trueDirY/D");
    fRecoTree->Branch("trueDirZ",&fTrueDirZ,"trueDirZ/D");
    fRecoTree->Branch("recoVtxX",&fRecoVtxX,"recoVtxX/D");
    fRecoTree->Branch("recoVtxY",&fRecoVtxY,"recoVtxY/D");
    fRecoTree->Branch("recoVtxZ",&fRecoVtxZ,"recoVtxZ/D"); 
    fRecoTree->Branch("recoVtxTime",&fRecoVtxTime,"recoVtxTime/D");  
    fRecoTree->Branch("recoDelta",&fRecoDelta,"recoDelta/D");
    fRecoTree->Branch("recoDeltaTrans",&fRecoDeltaTrans,"recoDeltaTrans/D");
    fRecoTree->Branch("recoDeltaLong",&fRecoDeltaLong,"recoDeltaLong/D");
    gDirectory = tmpd;
  }

  if( fRecoFile ){
    tmpd = gDirectory;
    fRecoFile->cd();
    fRecoTree->Fill();
    gDirectory = tmpd;
  }

  return;
}

void WCSimVertexSeedNtuple::WriteVariables ( WCSimTrueEvent trueEvent,
WCSimRecoEvent recoEvent 
) [private]

Definition at line 72 of file WCSimVertexSeedNtuple.cc.

References WCSimVertexGeometry::CalcVertexSeeds(), fEventNum, fRecoDelta, fRecoDeltaLong, fRecoDeltaTrans, fRecoVtxTime, fRecoVtxX, fRecoVtxY, fRecoVtxZ, fRunNum, fTriggerNum, fTrueDirX, fTrueDirY, fTrueDirZ, fTrueVtxX, fTrueVtxY, fTrueVtxZ, WCSimTrueEvent::GetDirX(), WCSimTrueEvent::GetDirY(), WCSimTrueEvent::GetDirZ(), WCSimRecoEvent::GetEvent(), WCSimVertexGeometry::GetNSeeds(), WCSimRecoEvent::GetRun(), WCSimVertexGeometry::GetSeedVtxTime(), WCSimVertexGeometry::GetSeedVtxX(), WCSimVertexGeometry::GetSeedVtxY(), WCSimVertexGeometry::GetSeedVtxZ(), WCSimRecoEvent::GetTrigger(), WCSimTrueEvent::GetVtxX(), WCSimTrueEvent::GetVtxY(), WCSimTrueEvent::GetVtxZ(), index, WCSimVertexGeometry::Instance(), last, and WriteToFile().

Referenced by Fill().

{
  std::cout << " *** WCSimVertexSeedNtuple::WriteVariables() *** " << std::endl;

  // number of seeds (try 1000)
  // ==========================
  Int_t fNumSeeds = 1000;

  // calculate vertex seeds
  // ======================
  WCSimVertexGeometry::Instance()->CalcVertexSeeds(fRecoEvent,fNumSeeds);

  // header information
  // ==================
  fRunNum = fRecoEvent->GetRun();
  fEventNum = fRecoEvent->GetEvent();
  fTriggerNum = fRecoEvent->GetTrigger();

  // true vertex position
  // ====================
  fTrueVtxX  = fTrueEvent->GetVtxX();
  fTrueVtxY  = fTrueEvent->GetVtxY();
  fTrueVtxZ  = fTrueEvent->GetVtxZ();
  fTrueDirX  = fTrueEvent->GetDirX();
  fTrueDirY  = fTrueEvent->GetDirY();
  fTrueDirZ  = fTrueEvent->GetDirZ();

  // loop over vertex seeds
  // ======================
  UInt_t nlast = WCSimVertexGeometry::Instance()->GetNSeeds();

  for( UInt_t n=0; n<nlast; n++ ){
    index = (Int_t)n;
    last = (Int_t)nlast;

    fRecoVtxX = WCSimVertexGeometry::Instance()->GetSeedVtxX(n);
    fRecoVtxY = WCSimVertexGeometry::Instance()->GetSeedVtxY(n);
    fRecoVtxZ = WCSimVertexGeometry::Instance()->GetSeedVtxZ(n);
    fRecoVtxTime = WCSimVertexGeometry::Instance()->GetSeedVtxTime(n);

    Double_t dx = fRecoVtxX - fTrueVtxX;
    Double_t dy = fRecoVtxY - fTrueVtxY;
    Double_t dz = fRecoVtxZ - fTrueVtxZ;
    Double_t ds = sqrt( dx*dx + dy*dy + dz*dz );
    Double_t px = fTrueDirX;
    Double_t py = fTrueDirY;
    Double_t pz = fTrueDirZ;

    Double_t epsilon = 1.0e-7;

    if( ds>epsilon ){
      px = dx/ds;
      py = dy/ds;
      pz = dz/ds;
    }

    Double_t costh = px*fTrueDirX+py*fTrueDirY+pz*fTrueDirZ;
    Double_t sinth = 0.0;
    if( costh<1.0-epsilon ) sinth = sqrt(1.0-costh*costh);
    else costh = 1.0;

    fRecoDelta = ds;
    fRecoDeltaTrans = ds*sinth;
    fRecoDeltaLong = ds*costh;

    this->WriteToFile();
  }

  return;
}


Member Data Documentation

Definition at line 39 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 61 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 63 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 62 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 33 of file WCSimVertexSeedNtuple.hh.

Referenced by CloseFile(), Reset(), and WriteToFile().

Definition at line 35 of file WCSimVertexSeedNtuple.hh.

Definition at line 34 of file WCSimVertexSeedNtuple.hh.

Referenced by CloseFile(), Reset(), and WriteToFile().

Definition at line 58 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 55 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 56 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 57 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 38 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 40 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 50 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 51 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 52 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 47 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 48 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 49 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Definition at line 43 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().

Int_t WCSimVertexSeedNtuple::last [private]

Definition at line 44 of file WCSimVertexSeedNtuple.hh.

Referenced by ResetVariables(), WriteToFile(), and WriteVariables().


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