MSTTemplate Class Reference

#include <MSTTemplate.h>

Inheritance diagram for MSTTemplate:
JobCModule

List of all members.

Public Member Functions

 MSTTemplate ()
 ~MSTTemplate ()
JobCResult Ana (const MomNavigator *mom)
void EndJob ()
void BeginJob ()
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Attributes

int counter
std::string fname
TFile * fout
TProfile2D * nlambdanele
TProfile2D * nlambdanother
TProfile2D * mipdistele
TProfile2D * mipdistother
double * xbins
double * ybins
double * ymbins
double * zbins

Detailed Description

Definition at line 18 of file MSTTemplate.h.


Constructor & Destructor Documentation

MSTTemplate::MSTTemplate (  ) 

Definition at line 35 of file MSTTemplate.cxx.

References NXBINS, NYBINS, NYMBINS, NZBINS, xbins, ybins, ymbins, and zbins.

00035                         :
00036   counter(0),
00037   fname(),
00038   fout(0),
00039   nlambdanele(0),
00040   nlambdanother(0),
00041   mipdistele(0),  
00042   mipdistother(0)
00043 {
00044   //x corresponds to the number of edges in the event
00045   //it goes from 0-30, then all events with 60<=#edges<300
00046   //are grouped together in one bin
00047   xbins=new double[NXBINS];
00048   for(int i=0;i<NXBINS-1;i++){
00049     xbins[i]=1.*i;
00050   }
00051   xbins[NXBINS-1]=300;
00052   
00053   //y corresponds to the values of the weights
00054   //it goes from 0-40, in steps of 5, 40<weights<1000 are
00055   //grouped together in one bin
00056   ybins=new double[NYBINS];
00057   for(int i=0;i<NYBINS-1;i++){
00058     ybins[i]=i*5.;
00059   }
00060   ybins[NYBINS-1]=1000.;
00061   
00062   //ymbins corresponds to the mip distributions, not great yet
00063   ymbins=new double[NYMBINS];
00064   for(int i=0;i<NYMBINS-1;i++){
00065     ymbins[i]=i*5;
00066   }
00067   ymbins[NYMBINS-1]=150;
00068   
00069   //z also corresponds to the number of edges in the event
00070   //it goes from 0-30, then all events with 30<#edges<100
00071   //are grouped together in one bin
00072   zbins=new double[NZBINS];
00073   for(int i=0;i<NZBINS-1;i++){
00074     zbins[i]=i;
00075   }
00076   zbins[NZBINS-1]=100;
00077 
00078 }

MSTTemplate::~MSTTemplate (  ) 

Definition at line 82 of file MSTTemplate.cxx.

References xbins.

00083 {
00084   delete [] xbins;
00085 
00086 }


Member Function Documentation

JobCResult MSTTemplate::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 108 of file MSTTemplate.cxx.

References ANtpEventInfo::begPlane, CALend, counter, MSTCalc::eallm1, MSTCalc::eallw1, ANtpEventInfo::endPlane, MSTCalc::enn1, MomNavigator::FragmentIter(), VldContext::GetDetector(), NueHeader::GetEventNo(), RecRecordImp< T >::GetHeader(), NueHeader::GetTrackLength(), RecHeader::GetVldContext(), ANtpTruthInfo::interactionType, Msg::kDebug, Msg::kError, Detector::kFar, Detector::kNear, JobCResult::kPassed, NueRecord::mctrue, mipdistele, mipdistother, MSG, NueRecord::mstvars, nlambdanele, nlambdanother, ANtpTruthInfo::nuFlavor, NYBINS, NYMBINS, MSTCalc::oallm1, MSTCalc::oallw1, MSTCalc::onn1, ANtpTruthInfoBeam::resonanceCode, SM1end, SM2end, NueRecord::srevent, ANtpEventInfo::vtxX, ANtpEventInfo::vtxY, ANtpEventInfo::vtxZ, ybins, and ymbins.

00109 {
00110   if(counter%1000==0){
00111     cout<<"on entry "<<counter<<endl;
00112   }
00113   counter++;
00114 
00115    //get all NueRecords from mom 
00116    //may have more than one per go since mom reads in a snarl's worth of data
00117    //so, this is a little more complicated than just asking for a NueRecord
00118    TObject *obj=0;
00119    TIter objiter = mom->FragmentIter();
00120    while((obj=objiter.Next())){
00121       NueRecord *nr = static_cast<NueRecord *>(obj);
00122       if(nr){
00123          MSG("MSTTemplate",Msg::kDebug)<<"Found a NueRecord in MOM"<<endl;
00124       }
00125       else{
00126          MSG("MSTTemplate",Msg::kError)<<"Didn't find a NueRecord in MOM"<<endl;
00127          continue;
00128       }
00129       MSG("MSTTemplate",Msg::kDebug)<<"Found a NueRecord "<<nr<<endl;
00130       
00131       //figure out whether event is signal or background
00132       bool signal = false;
00133       bool bg = false;
00134       if(abs(nr->mctrue.nuFlavor)==12&&nr->mctrue.interactionType==1&&
00135          nr->mctrue.resonanceCode==1001){
00136         signal=true;
00137       }
00138       if(nr->mctrue.interactionType==0){
00139         bg=true;
00140       }
00141 
00142       //if it's neither signal or bg, go on
00143       if(!(signal||bg)){
00144         continue;
00145       }
00146 
00147       //need at least 1 sucessfully reconstructed event
00148       if(nr->GetHeader().GetEventNo()<0){
00149         continue;
00150       }
00151       //only look at events for which mst actually gets calculated
00152       if(nr->GetHeader().GetTrackLength()>25){
00153         continue;
00154       }
00155       //only look at contained events (vertex contained, end doesn't go past 
00156       //calorimeter or sm gap
00157       if(nr->GetHeader().GetVldContext().GetDetector()==Detector::kFar){
00158         if(sqrt(pow(nr->srevent.vtxX,2)+pow(nr->srevent.vtxY,2))>3.87){
00159           continue;
00160         }
00161         if(nr->srevent.vtxZ<1||(nr->srevent.vtxZ>14&&nr->srevent.vtxZ<17)||
00162            nr->srevent.vtxZ>20){
00163           continue;
00164         }
00165         if((nr->srevent.begPlane<SM1end&&nr->srevent.endPlane>SM1end-2)||
00166            (nr->srevent.begPlane>SM1end&&nr->srevent.endPlane>SM2end-2)){
00167           continue;
00168         }         
00169       }
00170       else if(nr->GetHeader().GetVldContext().GetDetector()==Detector::kNear){
00171         if(sqrt(pow(nr->srevent.vtxX-1.5,2)+pow(nr->srevent.vtxY,2))>1.0){
00172           continue;
00173         }
00174         if(nr->srevent.vtxZ<4||nr->srevent.vtxZ>6.5){
00175           continue;
00176         }
00177         if(nr->srevent.endPlane>CALend-2){
00178           continue;
00179         }         
00180       }
00181       
00182     
00183       //make some temporary histograms
00184       TH1F ewhist("ewhist","ewhist",NYBINS-1,ybins);
00185       TH1F emhist("emhist","emhist",NYMBINS-1,ymbins);
00186       TH1F owhist("owhist","owhist",NYBINS-1,ybins);
00187       TH1F omhist("omhist","omhist",NYMBINS-1,ymbins);
00188 
00189       //fill the temp hists.
00190       for(int i=0;i<nr->mstvars.enn1;i++){
00191          if(nr->mstvars.eallw1[i]!=0){
00192             ewhist.Fill(nr->mstvars.eallw1[i]);
00193          }
00194          if(nr->mstvars.eallm1[i]!=0){   
00195             emhist.Fill(nr->mstvars.eallm1[i]);     
00196          }
00197       }
00198       for(int i=0;i<nr->mstvars.onn1;i++){
00199          if(nr->mstvars.oallw1[i]!=0){
00200             owhist.Fill(nr->mstvars.oallw1[i]);
00201          }
00202          if(nr->mstvars.oallm1[i]!=0){
00203             omhist.Fill(nr->mstvars.oallm1[i]);     
00204          }
00205       }
00206       
00207 
00208       if(signal){
00209          //fill signal profile hist.
00210          for(int j=1;j<=ewhist.GetNbinsX()+1;j++){
00211             nlambdanele->Fill(nr->mstvars.enn1,
00212                               ewhist.GetBinCenter(j),
00213                               ewhist.GetBinContent(j));
00214          }
00215          for(int j=1;j<=owhist.GetNbinsX()+1;j++){
00216             nlambdanele->Fill(nr->mstvars.onn1,
00217                               owhist.GetBinCenter(j),
00218                               owhist.GetBinContent(j));
00219          }
00220          for(int j=1;j<=emhist.GetNbinsX()+1;j++){
00221             mipdistele->Fill(nr->mstvars.enn1,
00222                              emhist.GetBinCenter(j),
00223                              emhist.GetBinContent(j));
00224          }
00225          for(int j=1;j<=omhist.GetNbinsX()+1;j++){
00226             mipdistele->Fill(nr->mstvars.onn1,
00227                              omhist.GetBinCenter(j),
00228                              omhist.GetBinContent(j));
00229          }
00230 
00231       }
00232       else if(bg){
00233          //fill bg profile hist.
00234          for(int j=1;j<=ewhist.GetNbinsX()+1;j++){
00235             nlambdanother->Fill(nr->mstvars.enn1,
00236                                 ewhist.GetBinCenter(j),
00237                                 ewhist.GetBinContent(j));
00238          }
00239          for(int j=1;j<=owhist.GetNbinsX()+1;j++){
00240             nlambdanother->Fill(nr->mstvars.onn1,
00241                                 owhist.GetBinCenter(j),
00242                                 owhist.GetBinContent(j));
00243          }
00244          for(int j=1;j<=emhist.GetNbinsX()+1;j++){
00245             mipdistother->Fill(nr->mstvars.enn1,
00246                                emhist.GetBinCenter(j),
00247                                emhist.GetBinContent(j));
00248          }
00249          for(int j=1;j<=omhist.GetNbinsX()+1;j++){
00250             mipdistother->Fill(nr->mstvars.onn1,
00251                                omhist.GetBinCenter(j),
00252                                omhist.GetBinContent(j));
00253          }
00254       }
00255 
00256       //reset the temp histograms
00257       ewhist.Reset();
00258       owhist.Reset();
00259       emhist.Reset();
00260       omhist.Reset();
00261    }
00262   
00263    return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00264 }

void MSTTemplate::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 89 of file MSTTemplate.cxx.

References fname, fout, mipdistele, mipdistother, nlambdanele, nlambdanother, NXBINS, NYBINS, NYMBINS, xbins, ybins, and ymbins.

00090 {
00091 
00092   fout=new TFile(fname.c_str(),"RECREATE");
00093   
00094    //create the template hisograms
00095    nlambdanele=new TProfile2D("nlambdanele","nlambdanele",
00096                               NXBINS-1,xbins,NYBINS-1,ybins);
00097    nlambdanother=new TProfile2D("nlambdanother","nlambdanother",
00098                                 NXBINS-1,xbins,NYBINS-1,ybins);
00099    
00100    mipdistele=new TProfile2D("mipdistele","mipdistele",
00101                              NXBINS-1,xbins,NYMBINS-1,ymbins);
00102    mipdistother=new TProfile2D("mipdistother","mipdistother",
00103                                NXBINS-1,xbins,NYMBINS-1,ymbins);
00104 
00105 }

void MSTTemplate::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 303 of file MSTTemplate.cxx.

References fname, Registry::Get(), Msg::kDebug, and MSG.

00304 {
00305 //======================================================================
00306 // Configure the module given the Registry r
00307 //======================================================================
00308   MSG("MSTTemplate",Msg::kDebug)<<"In MSTTemplate::Config"<<endl;
00309 
00310   const char* tmps;
00311 
00312   if(r.Get("MSTTmpltFile",tmps)) { fname = (string)(tmps);}
00313 }

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

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

00280 {
00281 //======================================================================
00282 // Supply the default configuration for the module
00283 //======================================================================
00284    MSG("MSTTemplate",Msg::kDebug)<<"In MSTTemplate::DefaultConfig"<<endl;
00285 
00286   static Registry r; // Default configuration for module
00287 
00288   // Set name of config
00289   std::string name = this->GetName();
00290   name += ".config.default";
00291   r.SetName(name.c_str());
00292 
00293   // Set values in configuration
00294   r.UnLockValues();
00295   r.Set("MSTTmpltFile","templates.root");
00296   r.LockValues();
00297 
00298   return r;
00299 }

void MSTTemplate::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 267 of file MSTTemplate.cxx.

References fout.

00268 {
00269   if(fout!=0){
00270     if(fout->IsOpen()){
00271       fout->Write();
00272       fout->Close();
00273     }
00274   }
00275 }


Member Data Documentation

int MSTTemplate::counter [private]

Definition at line 37 of file MSTTemplate.h.

Referenced by Ana().

std::string MSTTemplate::fname [private]

Definition at line 38 of file MSTTemplate.h.

Referenced by BeginJob(), and Config().

TFile* MSTTemplate::fout [private]

Definition at line 39 of file MSTTemplate.h.

Referenced by BeginJob(), and EndJob().

TProfile2D* MSTTemplate::mipdistele [private]

Definition at line 42 of file MSTTemplate.h.

Referenced by Ana(), and BeginJob().

TProfile2D* MSTTemplate::mipdistother [private]

Definition at line 43 of file MSTTemplate.h.

Referenced by Ana(), and BeginJob().

TProfile2D* MSTTemplate::nlambdanele [private]

Definition at line 40 of file MSTTemplate.h.

Referenced by Ana(), and BeginJob().

TProfile2D* MSTTemplate::nlambdanother [private]

Definition at line 41 of file MSTTemplate.h.

Referenced by Ana(), and BeginJob().

double* MSTTemplate::xbins [private]

Definition at line 44 of file MSTTemplate.h.

Referenced by BeginJob(), MSTTemplate(), and ~MSTTemplate().

double* MSTTemplate::ybins [private]

Definition at line 45 of file MSTTemplate.h.

Referenced by Ana(), BeginJob(), and MSTTemplate().

double* MSTTemplate::ymbins [private]

Definition at line 46 of file MSTTemplate.h.

Referenced by Ana(), BeginJob(), and MSTTemplate().

double* MSTTemplate::zbins [private]

Definition at line 47 of file MSTTemplate.h.

Referenced by MSTTemplate().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1