SystematicGains Class Reference

#include <SystematicGains.h>

Inheritance diagram for SystematicGains:
JobCModule

List of all members.

Public Member Functions

 SystematicGains ()
 ~SystematicGains ()
JobCResult Reco (MomNavigator *mom)
void EndJob ()
void BeginJob ()
void Config (const Registry &)
const RegistryDefaultConfig () const

Private Attributes

double allshift
double rndshift
TRandom2 rnd

Static Private Attributes

static int printit = -1

Detailed Description

Definition at line 34 of file SystematicGains.h.


Constructor & Destructor Documentation

SystematicGains::SystematicGains (  ) 

Definition at line 44 of file SystematicGains.cxx.

References allshift, MsgService::Instance(), Msg::kDebug, printit, and rndshift.

00045 {
00046         if(printit<0)
00047         {
00048                 if(MsgService::Instance()->IsActive("SystematicGains",Msg::kDebug))printit=1;
00049                 else printit=0;
00050         }
00051         allshift=0;
00052         rndshift=0;
00053 }

SystematicGains::~SystematicGains (  ) 

Definition at line 57 of file SystematicGains.cxx.

00058 {}


Member Function Documentation

void SystematicGains::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 61 of file SystematicGains.cxx.

00062 {
00063 
00064 }

void SystematicGains::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 175 of file SystematicGains.cxx.

References allshift, Registry::Get(), JobCModule::GetConfig(), Msg::kDebug, Registry::LockValues(), MSG, rndshift, Registry::UnLockValues(), and Registry::ValuesLocked().

00176 {
00177 //======================================================================
00178 // Configure the module given the Registry r
00179 //======================================================================
00180   MSG("SystematicGains",Msg::kDebug)<<"In Trimmer::Config"<<endl;
00181                                                                                
00182   bool islocked = this->GetConfig().ValuesLocked();
00183   if (islocked) this->GetConfig().UnLockValues();
00184  
00185   double valint;
00186   if(r.Get("TotalShift", valint)) 
00187   {
00188     allshift=valint;
00189   }
00190 
00191   if(r.Get("RandomShift", valint)) 
00192   {
00193     rndshift=valint;
00194   }
00195 
00196   if (islocked) this->GetConfig().LockValues();
00197 
00198   cout<< "SystematicGains   TotalShift "<<allshift<<" RandomShift "<<rndshift<<endl;
00199 
00200 }

const Registry & SystematicGains::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 152 of file SystematicGains.cxx.

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

00153 {
00154 //======================================================================
00155 // Supply the default configuration for the module
00156 //======================================================================
00157    MSG("SystematicGains",Msg::kDebug)<<"In Trimmer::DefaultConfig"<<endl;
00158 
00159   
00160   static Registry r;
00161   std::string name = this->JobCModule::GetName();
00162   name += ".config.default";
00163   r.SetName(name.c_str());
00164 
00165   r.UnLockValues();
00166   r.Set("TotalShift",(double)0.);
00167   r.Set("RandomShift",(double)0.);          
00168 
00169   r.LockValues();             
00170                
00171                                                                               
00172   return r;
00173 }

void SystematicGains::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 67 of file SystematicGains.cxx.

00068 {
00069 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 71 of file SystematicGains.cxx.

References allshift, NtpStRecord::evt, NtpStRecord::evthdr, MomNavigator::GetFragmentList(), JobCResult::kPassed, Munits::m, NtpSREventSummary::nevent, NtpSRPulseHeight::pe, NtpSRStrip::ph0, NtpSRStrip::ph1, printit, NtpSRPulseHeight::raw, rnd, rndshift, NtpSRPulseHeight::sigcor, NtpSRPulseHeight::siglin, and NtpStRecord::stp.

00072 {
00073    bool foundST=false;
00074                                                                                
00075 //   VldContext vc;
00076    //first ask mom for a NtpStRecord
00077 
00078 //iterate over all NtpStRecords in MOM
00079 
00080 std::vector<TObject*> records = mom->GetFragmentList("NtpStRecord");
00081 
00082 
00083 for(unsigned int i=0;i<records.size();i++)
00084 {
00085 
00086    NtpStRecord *str=dynamic_cast<NtpStRecord *>(records[i]); //(mom->GetFragment("NtpStRecord","Primary"));
00087    if(str){
00088      foundST=true;
00089   //   vc=str->GetHeader().GetVldContext();
00090    }else{
00091         continue;
00092    }
00093    //cout<<"Running over "<<str->GetName()<<endl;
00094 
00095         NtpSREventSummary * evthdr = dynamic_cast<NtpSREventSummary *>(&str->evthdr);
00096 
00097         for(int ievt=0;ievt<evthdr->nevent;ievt++)
00098         {
00099         
00100 
00101 
00102 
00103                         NtpSREvent* event = dynamic_cast<NtpSREvent*>(str->evt->At(ievt));  
00104                         int nstrips=event->nstrip;
00105 
00106                         for(int m=0;m<nstrips;m++)
00107             {                               
00108                 NtpSRStrip* strip = (NtpSRStrip*)(str->stp->At(event->stp[m]));
00109                                 if(!strip)
00110                 {
00111                         printf("CANT FIND STRIP AT IDX %d\n",event->stp[m]);
00112                         continue;
00113                 }
00114                                 
00115                                         
00116                 double adjfrac0=0;
00117                 double adjfrac1=0;
00118                 if(strip->ph0.pe)
00119                 {
00120                         adjfrac0 = 1. + allshift ;
00121                         if(rndshift)adjfrac0 += rnd.Gaus(0,rndshift);                                   
00122                         strip->ph0.pe*=adjfrac0;
00123                                 strip->ph0.siglin*=adjfrac0;
00124                         strip->ph0.sigcor*=adjfrac0;
00125                                 strip->ph0.raw*=adjfrac0;
00126                 }
00127 
00128                 if(strip->ph1.pe)
00129                 {
00130                         adjfrac1 = 1. - allshift ;
00131                         if(rndshift)adjfrac1 += rnd.Gaus(0,rndshift);
00132                         strip->ph1.pe*=adjfrac1;
00133                                 strip->ph1.siglin*=adjfrac1;
00134                         strip->ph1.sigcor*=adjfrac1;
00135                                 strip->ph1.raw*=adjfrac1;
00136                 }
00137                 if(printit)printf("adjusting size 0 by %f and side 1 by %f\n", adjfrac0, adjfrac1);
00138                                         
00139                                         
00140            }
00141            
00142 
00143         }
00144 }
00145    
00146    return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00147 }


Member Data Documentation

double SystematicGains::allshift [private]

Definition at line 55 of file SystematicGains.h.

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

int SystematicGains::printit = -1 [static, private]

Definition at line 54 of file SystematicGains.h.

Referenced by Reco(), and SystematicGains().

TRandom2 SystematicGains::rnd [private]

Definition at line 57 of file SystematicGains.h.

Referenced by Reco().

double SystematicGains::rndshift [private]

Definition at line 56 of file SystematicGains.h.

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


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1