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

SystematicGains.cxx

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <fstream>
00003 #include <map>
00004 #include <sstream>
00005 #include <string>
00006 
00007 #include "TH1F.h"
00008 #include "TFile.h"
00009 
00010 
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "MessageService/MsgService.h"
00014 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00015 
00016 #include "TClass.h"
00017 #include "TDataType.h"
00018 #include "TDataMember.h"
00019 #include "TRealData.h"
00020 #include "NueAna/ParticlePID/ParticleFinder/Systematic/SystematicGains.h"
00021 #include "StandardNtuple/NtpStRecord.h"
00022 #include "CandNtupleSR/NtpSRRecord.h"
00023 
00024 #include "TClonesArray.h"
00025 
00026 #include "CandNtupleSR/NtpSRStrip.h"  
00027 #include "CandNtupleSR/NtpSREvent.h" 
00028 #include "CandNtupleSR/NtpSRShower.h" 
00029 #include "CandNtupleSR/NtpSRTrack.h" 
00030 
00031 #include "TObject.h"
00032 
00033 
00034 JOBMODULE(SystematicGains, "SystematicGains",
00035           "Adjust strip energies for a given gain adjustment");
00036           
00037 CVSID("$Id: SystematicGains.cxx,v 1.1 2009/06/19 14:32:40 scavan Exp $");
00038 
00039 
00040 int SystematicGains::printit=-1;
00041 
00042 //......................................................................
00043 
00044 SystematicGains::SystematicGains()
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 }
00054 
00055 //......................................................................
00056 
00057 SystematicGains::~SystematicGains()
00058 {}
00059 
00060 //......................................................................
00061 void SystematicGains::BeginJob()
00062 {
00063 
00064 }
00065 
00066 
00067 void SystematicGains::EndJob()
00068 {
00069 }
00070 
00071 JobCResult SystematicGains::Reco(MomNavigator* mom)
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 }
00148 
00149 
00150 
00151 
00152 const Registry& SystematicGains::DefaultConfig() const
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 }
00174 
00175 void SystematicGains::Config(const Registry& r)
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 }
00201 
00202 
00203 
00204 
00205 

Generated on Mon Feb 15 11:07:40 2010 for loon by  doxygen 1.3.9.1