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

BeamSummary Class Reference

The base class for the beam monitoring summary ntuple. More...

#include <BeamSummary.h>

List of all members.

Public Member Functions

 BeamSummary ()
 BeamSummary (TTree *btree)
 Sets branch address and keeps pointer to TTree as private member.
void SetTree (TTree *btree)
 Set the private member fChain.
void clear ()
 Set the public members to zero.
Int_t MatchSpillWithTime (Int_t tsec, Int_t tnanosec)

Public Attributes

Double_t beamIntensity
Double_t hBeamWidth
Double_t vBeamWidth
Double_t hPosatTargetPM
Double_t vPosatTargetPM
Double_t hPosatTargetBPM
Double_t vPosatTargetBPM
Double_t tanHoriz
Double_t tanVert
Double_t hornPeakCurrent
Double_t nuTarZ
Double_t hadTotalPH
Double_t hadMeanX
Double_t hadMeanY
Double_t mu1TotalPH
Double_t mu1MeanX
Double_t mu1MeanY
Double_t mu2TotalPH
Double_t mu2MeanX
Double_t mu2MeanY
Double_t mu3TotalPH
Double_t mu3MeanX
Double_t mu3MeanY
Double_t timeStampD
Long_t timeStampSec

Private Attributes

TTree * fChain


Detailed Description

The base class for the beam monitoring summary ntuple.

Id
BeamSummary.h,v 1.1 2005/03/30 20:38:32 mdier Exp

BeamSummary

The base class for the beam monitoring summary ntuples. See the header file for the definition of its members.

Contact: mdier@bnl.gov

Created on: Tue Mar 29 14:47:25 2005

Definition at line 27 of file BeamSummary.h.


Constructor & Destructor Documentation

BeamSummary::BeamSummary  ) 
 

Definition at line 14 of file BeamSummary.cxx.

References clear(), and fChain.

00014                         {
00015     clear();
00016     fChain=0;
00017 }

BeamSummary::BeamSummary TTree *  btree  ) 
 

Sets branch address and keeps pointer to TTree as private member.

Definition at line 19 of file BeamSummary.cxx.

References clear(), fChain, and SetTree().

00020 {
00021     clear();
00022     SetTree(btree);
00023     fChain->SetBranchAddress("Beaminfo",this);
00024 }


Member Function Documentation

void BeamSummary::clear  ) 
 

Set the public members to zero.

Definition at line 31 of file BeamSummary.cxx.

References beamIntensity, hadMeanX, hadMeanY, hadTotalPH, hBeamWidth, hornPeakCurrent, hPosatTargetBPM, hPosatTargetPM, mu1MeanX, mu1MeanY, mu1TotalPH, mu2MeanX, mu2MeanY, mu2TotalPH, mu3MeanX, mu3MeanY, mu3TotalPH, nuTarZ, tanHoriz, tanVert, timeStampD, timeStampSec, vBeamWidth, vPosatTargetBPM, and vPosatTargetPM.

Referenced by BeamSummary(), and MatchSpillWithTime().

00032 {
00033     beamIntensity = 0.0;    
00034     hBeamWidth = vBeamWidth = 0.0;       
00035     hPosatTargetPM = vPosatTargetPM = 0.0;
00036     hPosatTargetBPM = vPosatTargetBPM = 0.0;  
00037     tanHoriz = tanVert = 0.0;          
00038     hornPeakCurrent = nuTarZ = 0.0;           
00039     hadTotalPH = hadMeanX = hadMeanY = 0.0;         
00040     mu1TotalPH = mu1MeanX = mu1MeanY = 0.0;         
00041     mu2TotalPH = mu2MeanX = mu2MeanY = 0.0;         
00042     mu3TotalPH = mu3MeanX = mu3MeanY = 0.0;         
00043     timeStampD = 0.0;       
00044     timeStampSec = 0;
00045 }

Int_t BeamSummary::MatchSpillWithTime Int_t  tsec,
Int_t  tnanosec
 

Look up the beam spill that matches the time given as an argument to the method in seconds and nanoseconds. Giving only the seconds will only work if the repetition rate is larger than 2 secs.

Definition at line 47 of file BeamSummary.cxx.

References abs(), clear(), fChain, and MSG.

Referenced by BeamMonAna::Analyze().

00048 {
00049     static Long64_t lastindex=0;
00050     Long64_t index=0;
00051     Int_t found=0;
00052 
00053    // Get the total number of entries in the ntuple
00054     Long64_t nentries = fChain->GetEntries();
00055     if (nentries<1) {
00056         MSG("BeamSummary", Msg::kWarning) << "No entries in the beam ntuple" << endl;
00057     }
00058     // First set the index to the position of the previous call
00059     index = lastindex;
00060     // Check if this index is not larger than the number of
00061     // entries in the ntuple. If so, put it to the last entry in the
00062     // tree
00063     while (index>=nentries) {
00064         --index;
00065     }        
00066     // the search process can put the lastindex to a negative value
00067     // if so, put the index to 0
00068     if (index<0) index=0;
00069 
00070     // The ntuple is supposed to be order in time, so it is assumed here...
00071     // Read in the previous entry and determine whether this occured earlier
00072     // in time, if not change position to the left, else proceed to the right.
00073     
00074     clear();
00075     Long64_t ientry = fChain->LoadTree(index);
00076     if (ientry < 0) {
00077         MSG("BeamSummary",Msg::kWarning) << "Error reading beam ntuple" << endl;
00078         return found;
00079     }
00080     Int_t nb = fChain->GetEntry(index);
00081     if (nb<0) {
00082         MSG("BeamSummary",Msg::kWarning) << "No byte read in" << endl;
00083         return found;
00084     }
00085     Int_t timedif = tsec-timeStampSec;
00086     if (abs(timedif)<2) {
00087         // hey, we are already at the right spot
00088         found =1;
00089     }
00090     else if (timedif<=-2) {
00091         // time to look up is earlier than current entry, proceed left
00092         index--;
00093         for (Long64_t ient=index; ient>=0; ient--) {
00094             index = ient;
00095             fChain->GetEntry(index);
00096             timedif = tsec-timeStampSec;
00097             if (abs(timedif)<2) {
00098                 found = 1;
00099                 break;
00100             }
00101         }
00102     }
00103     else if (timedif>=2) {
00104         // time to look up is later than current entry, proceed right
00105         index++;
00106         for (Long64_t ient=index; ient<nentries; ient++) {
00107             index = ient;
00108             fChain->GetEntry(index);
00109             timedif = tsec-timeStampSec;
00110             if (abs(timedif)<2) {
00111                 found = 1;
00112                 break;
00113             } 
00114         }
00115     }
00116     else {
00117         MSG("BeamSummary",Msg::kDebug) << "This is not supposed to happen!" << endl;
00118     }
00119     
00120     if (found==0) {
00121         clear();
00122         MSG("BeamSummary",Msg::kWarning)
00123             << "No entry found in Beam ntuple corresponding to time stamp:"
00124             << " " << tsec << " seconds " << tnanosec << " nanoseconds" << endl; 
00125     } else {
00126         // Matching with seconds does not guarantee it is the closest
00127         // spill. This can happen when the repitition rate of the
00128         // spills is smaller than 2 secs.
00129         Double_t dtime = tsec + (tnanosec/1e9);
00130         // Look up the actual time from this, previous and next spill
00131         Double_t time_this =  timeStampD;
00132         Double_t time_prev = 0.0; 
00133         Double_t time_next = 0.0;
00134         if (index<nentries-1) {
00135             fChain->GetEntry(index+1);
00136             time_next = timeStampD;
00137         }    
00138         if (index>0) {
00139             fChain->GetEntry(index-1);
00140             time_prev = timeStampD;
00141         }    
00142         Double_t Deltat_this = fabs(time_this - dtime);
00143         Double_t Deltat_prev = fabs(time_prev - dtime);
00144         Double_t Deltat_next = fabs(time_next - dtime);
00145         MSG("BeamSummary",Msg::kDebug) << "Time difference i = " << Deltat_this<< endl;
00146         MSG("BeamSummary",Msg::kDebug) << "Time difference i-1 = " << Deltat_prev<< endl;
00147         MSG("BeamSummary",Msg::kDebug) << "Time difference i+1 = " << Deltat_next<< endl;
00148         if (Deltat_this>Deltat_prev) index--;
00149         else if (Deltat_this>Deltat_next) index++;
00150         fChain->GetEntry(index);
00151     }
00152     lastindex=index;
00153     return found;
00154 }

void BeamSummary::SetTree TTree *  btree  ) 
 

Set the private member fChain.

Definition at line 26 of file BeamSummary.cxx.

References fChain.

Referenced by BeamSummary().

00027 {
00028     fChain = btree;
00029 }


Member Data Documentation

Double_t BeamSummary::beamIntensity
 

Definition at line 32 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

TTree* BeamSummary::fChain [private]
 

Definition at line 75 of file BeamSummary.h.

Referenced by BeamSummary(), MatchSpillWithTime(), and SetTree().

Double_t BeamSummary::hadMeanX
 

Definition at line 44 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::hadMeanY
 

Definition at line 45 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::hadTotalPH
 

Definition at line 43 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::hBeamWidth
 

Definition at line 33 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::hornPeakCurrent
 

Definition at line 41 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::hPosatTargetBPM
 

Definition at line 37 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::hPosatTargetPM
 

Definition at line 35 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), and clear().

Double_t BeamSummary::mu1MeanX
 

Definition at line 47 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu1MeanY
 

Definition at line 48 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu1TotalPH
 

Definition at line 46 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu2MeanX
 

Definition at line 50 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu2MeanY
 

Definition at line 51 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu2TotalPH
 

Definition at line 49 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu3MeanX
 

Definition at line 53 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu3MeanY
 

Definition at line 54 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::mu3TotalPH
 

Definition at line 52 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::nuTarZ
 

Definition at line 42 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::tanHoriz
 

Definition at line 39 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), and clear().

Double_t BeamSummary::tanVert
 

Definition at line 40 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), and clear().

Double_t BeamSummary::timeStampD
 

Definition at line 55 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), and clear().

Long_t BeamSummary::timeStampSec
 

Definition at line 56 of file BeamSummary.h.

Referenced by clear().

Double_t BeamSummary::vBeamWidth
 

Definition at line 34 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::vPosatTargetBPM
 

Definition at line 38 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), clear(), and BeamSummaryAna::SimpleBeamCut().

Double_t BeamSummary::vPosatTargetPM
 

Definition at line 36 of file BeamSummary.h.

Referenced by BeamMonAna::Analyze(), and clear().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:08:47 2010 for loon by  doxygen 1.3.9.1