MeuSummaryWriter Class Reference

#include <MeuSummaryWriter.h>

List of all members.

Public Member Functions

 MeuSummaryWriter ()
 ~MeuSummaryWriter ()
void SummaryTreeSetup (Int_t run, Int_t subrun)
void SummaryTreeFinish ()
MeuSummaryGetMeuSummaryToFill ()
void SummaryTreeFill (const std::map< Int_t, MeuHitInfo > &plInfo)

Private Member Functions

TFile * OpenFile (Int_t run, Int_t subrun, std::string prefix) const
void FillMeuHitInfo (const std::map< Int_t, MeuHitInfo > &plInfo)

Private Attributes

MeuSummaryfMeuSummary
TFile * fSummaryFile
TTree * fSummaryTree

Detailed Description

Definition at line 19 of file MeuSummaryWriter.h.


Constructor & Destructor Documentation

MeuSummaryWriter::MeuSummaryWriter (  ) 

Definition at line 31 of file MeuSummaryWriter.cxx.

References Msg::kDebug, and MSG.

00032 {
00033   MSG("MeuSummaryWriter",Msg::kDebug)
00034       <<"Running MeuSummaryWriter Constructor..."<<endl;
00035 
00036   MSG("MeuSummaryWriter",Msg::kDebug)
00037       <<"Finished MeuSummaryWriter Constructor"<<endl;
00038 }

MeuSummaryWriter::~MeuSummaryWriter (  ) 

Definition at line 42 of file MeuSummaryWriter.cxx.

References Msg::kDebug, and MSG.

00043 {
00044   MSG("MeuSummaryWriter",Msg::kDebug)
00045       <<"Running MeuSummaryWriter Destructor..."<<endl;
00046   
00047 
00048   MSG("MeuSummaryWriter",Msg::kDebug)
00049       <<"Finished MeuSummaryWriter Destructor"<<endl;
00050 }


Member Function Documentation

void MeuSummaryWriter::FillMeuHitInfo ( const std::map< Int_t, MeuHitInfo > &  plInfo  )  [private]

Definition at line 186 of file MeuSummaryWriter.cxx.

References MeuSummary::Detector, it, Msg::kDebug, Detector::kNear, Msg::kVerbose, MAXMSG, MeuSummary::MeuHitInfo, MSG, MeuHitInfo::Plane, MeuHitInfo::SigMap, MeuSummary::WinSigCor, MeuSummary::WinStopSidePl, and MeuSummary::WinVtxSidePl.

00187 {
00188   MSG("MeuSummaryWriter",Msg::kDebug)<<"   filling calibPos..."<<endl; 
00189   
00190   MeuSummary& s=*fMeuSummary;
00191   
00192   //only fill if a window was found
00193   if (s.WinSigCor<=0) return;
00194   
00195   //get a reference to the MeuHitInfo object in MeuSummary
00196   TClonesArray& calibPos = *(s.MeuHitInfo);
00197 
00198   //counter for TClonesArray
00199   Int_t i=0;
00200   
00201   for (map<Int_t,MeuHitInfo>::const_iterator it=plInfo.begin();
00202        it!=plInfo.end();++it){
00203 
00204     Int_t plane=it->second.Plane;
00205     if (plane<0) continue;
00206 
00207     //check if plane is in window
00208     if ((plane>=s.WinVtxSidePl && plane<=s.WinStopSidePl) ||
00209         (plane<=s.WinVtxSidePl && plane>=s.WinStopSidePl)) {
00210       
00211       if (plane>120 && s.Detector==Detector::kNear) cout
00212         <<"plane>120!!!!!!!, pl="<<plane<<endl;
00213       
00214       MeuHitInfo* cp=new(calibPos[i++]) MeuHitInfo();
00215       *cp=it->second;
00216       
00217       MAXMSG("MeuSummaryWriter",Msg::kVerbose,1000)
00218         <<"Filling MeuHitInfo: pl="<<cp->Plane
00219         <<", sigMap="<<cp->SigMap<<endl;
00220     }
00221   }
00222 }

MeuSummary & MeuSummaryWriter::GetMeuSummaryToFill (  ) 
TFile * MeuSummaryWriter::OpenFile ( Int_t  run,
Int_t  subrun,
std::string  prefix 
) const [private]

Definition at line 101 of file MeuSummaryWriter.cxx.

References Form(), Msg::kInfo, and MSG.

Referenced by SummaryTreeSetup().

00103 {
00104   //create the tfile pointer to be returned
00105   TFile* outputFile=0;
00106   
00107   //get the environmental variable
00108   char *anaDir=getenv("MEUANA_DIR");
00109   
00110   //use a string to hold env instead 
00111   string sAnaDir="";
00112   
00113   if (anaDir!=NULL) {
00114     sAnaDir=anaDir;
00115   }
00116   else {
00117     MSG("MeuSummaryWriter",Msg::kInfo) 
00118       <<"Environmental variable $MEUANA_DIR not set." 
00119       <<" Writing file(s) to current directory"<<endl;
00120     sAnaDir=".";
00121   }
00122   
00123   //convert variables to string
00124   string sRunNumber=Form("%d",run);
00125   string sSubrunNumber=Form("%d",subrun);
00126   //string sDetector="C";
00127   string sDetector="";
00128   //string sPrefix="h";//default
00129   string sPrefix="";//default
00130   if (prefix!="") sPrefix+=prefix;
00131   string sBase=sAnaDir+"/"+sPrefix+sDetector+sRunNumber;
00132   sBase+="_"+sSubrunNumber;
00133   string sFileName=sBase+".root";
00134   
00135   //test if file already exists
00136   ifstream Test(sFileName.c_str());
00137   
00138   //open the appropriate file
00139   if(!Test){
00140     outputFile=new TFile(sFileName.c_str(),"RECREATE");
00141   }
00142   else {
00143     //Need new filename
00144     Int_t fred=1;
00145     while(Test) {
00146       Test.close();
00147       string sAppendage=Form("%d",fred);
00148       sFileName=sBase+"_"+sAppendage+".root";
00149       Test.open(sFileName.c_str());
00150       fred++;
00151     }
00152     outputFile=new TFile(sFileName.c_str(),"NEW");
00153     outputFile->SetCompressionLevel(9);
00154   }
00155   
00156   string sTmp="No File!";
00157   if (outputFile) sTmp=outputFile->GetName();
00158 
00159   MSG("MeuSummaryWriter",Msg::kInfo) 
00160     <<"Output file opened: "<<sTmp<<endl;
00161   return outputFile;
00162 }

void MeuSummaryWriter::SummaryTreeFill ( const std::map< Int_t, MeuHitInfo > &  plInfo  ) 

Definition at line 167 of file MeuSummaryWriter.cxx.

References Msg::kDebug, and MSG.

Referenced by MeuAnalysis::BasicReco(), MeuAnalysis::MakeSummaryTreeWithAtNu(), and MeuAnalysis::MakeSummaryTreeWithNtpStOneSnarl().

00168 {
00169   if (!fMeuSummary) cout<<"Ahhhhh no fMeuSummary object to put in tree"<<endl;
00170 
00171   MSG("MeuSummaryWriter",Msg::kDebug)<<"Filling summaryTree..."<<endl; 
00172 
00173   static Int_t counter=0;
00174   fMeuSummary->Count=counter;//a counter
00175   counter++;//count the number of entries
00176 
00177   this->FillMeuHitInfo(plInfo);
00178   
00179   //fill the tree
00180   fSummaryTree->Fill();
00181 }

void MeuSummaryWriter::SummaryTreeFinish (  ) 

Definition at line 65 of file MeuSummaryWriter.cxx.

References fSummaryFile, Msg::kInfo, and MSG.

Referenced by MeuAnalysis::BasicReco(), MeuAnalysis::MakeSummaryTreeWithAtNu(), and MeuAnalysis::StoreOrFinishSummaryTree().

00066 {
00067   MSG("MeuSummaryWriter",Msg::kInfo)
00068     <<"Running MeuSummaryWriter::SummaryTreeFinish..."<<endl;
00069 
00070   MSG("MeuSummaryWriter",Msg::kInfo)
00071     <<"Changing directory to fSummaryFile..."<<endl;
00072   //cd to file
00073   fSummaryFile->cd();
00074 
00075   MSG("MeuSummaryWriter",Msg::kInfo)<<"Writing tree..."<<endl;
00076   //write tree
00077   //fSummaryTree->Write();//use file->Write below instead
00078 
00079   //write data to 
00080   fSummaryFile->Write();//this should pick up any histograms as well
00081 
00082   MSG("MeuSummaryWriter",Msg::kInfo)
00083     <<"Closing file "<<fSummaryFile->GetName()<<" ..."<<endl;
00084   //close the file
00085   fSummaryFile->Close();
00086 
00087   MSG("MeuSummaryWriter",Msg::kInfo)
00088     <<"Completed MeuSummaryWriter::SummaryTreeFinish"<<endl;
00089 }

void MeuSummaryWriter::SummaryTreeSetup ( Int_t  run,
Int_t  subrun 
)

Definition at line 54 of file MeuSummaryWriter.cxx.

References fMeuSummary, fSummaryFile, fSummaryTree, and OpenFile().

Referenced by MeuAnalysis::MakeSummaryTreeWithAtNu(), and MeuAnalysis::MakeSummaryTreeWithNtpStOneSnarl().

00055 {
00056   fSummaryFile=this->OpenFile(run,subrun,"MeuSummary");
00057   fSummaryTree=new TTree("s","s");
00058   cout<<"Creating new MeuSummary for output to tree"<<endl;
00059   fMeuSummary=new MeuSummary();
00060   fSummaryTree->Branch("s","MeuSummary",&fMeuSummary,32000,2);
00061 }


Member Data Documentation

Definition at line 40 of file MeuSummaryWriter.h.

Referenced by GetMeuSummaryToFill(), and SummaryTreeSetup().

Definition at line 41 of file MeuSummaryWriter.h.

Referenced by SummaryTreeFinish(), and SummaryTreeSetup().

Definition at line 42 of file MeuSummaryWriter.h.

Referenced by SummaryTreeSetup().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1