mcr/prean/ZebraAccess/AccessZebra_Appl_1.C

00001 #include "TFile.h"
00002 #include "TTree.h"
00003 
00004 #include "AccessZebra_MultiRun.C"
00005 
00006 
00007 class ZebraAcc_Appl1: public TZebraAccess{
00008   
00009 private:
00010   TTree *fTofTree;
00011 
00012 public:
00013   ZebraAcc_Appl1();
00014   ~ZebraAcc_Appl1();
00015 
00016   void InitTrees();
00017   void SaveTrees(const TString &fnam);
00018 
00019   void Pre_Run_Operation();
00020   void Post_Run_Operation();
00021 
00022   void UseProcessRec_GES();
00023   void UseProcessRec_DST();
00024 
00025   ClassDef(ZebraAcc_Appl1,1)
00026     };
00027 
00028 ClassImp(ZebraAcc_Appl1)
00029 
00030 //_______________________________
00031 ZebraAcc_Appl1::ZebraAcc_Appl1():
00032   fTofTree()
00033 {
00034   
00035   cout << "ZebraAcc_Appl1 constructor called" << endl;
00036  
00037 }
00038 
00039 //_______________________________
00040 ZebraAcc_Appl1::~ZebraAcc_Appl1(){
00041   
00042 }
00043 
00044 //_______________________________
00045 void ZebraAcc_Appl1::InitTrees(){
00046   fTofTree = new TTree("TofTree","TOF tree");
00047 }
00048 
00049 //_______________________________
00050 void ZebraAcc_Appl1::SaveTrees(const TString &fnam){
00051   
00052   TFile fout(fnam,"RECREATE");
00053   fout.cd();
00054   fTofTree->Write();
00055 
00056   fout.Purge();
00057   fout.Close();
00058 }
00059 
00060 //_______________________________
00061 void ZebraAcc_Appl1::Pre_Run_Operation(){
00062 
00063   cout << "Performing pre-run operation for run " << fCurrentRun << endl;
00064   fTofTree->Reset();
00065 
00066 }
00067 
00068 //_______________________________
00069 void ZebraAcc_Appl1::Post_Run_Operation(){
00070 
00071   cout << "Performing post-run operation for run " << fCurrentRun << endl;
00072   
00073   TString fnam;
00074   fnam.Form("%s-%d.test.root",fRunType.Data(),fCurrentRun);
00075   
00076   SaveTrees(fnam);
00077 }
00078 
00079 //_______________________________
00080 void ZebraAcc_Appl1::UseProcessRec_GES(){
00081 
00082   /*
00083   Int_t JFGES = fPrec->GetJFGES();
00084   Int_t trigbit = fPrec->GetIQ(JFGES+3);
00085   Int_t rnum = fPrec->GetIQ(JFGES+1);
00086   Int_t evnum = fPrec->GetIQ(JFGES+2);
00087   cout << "JFGES = " << JFGES 
00088        << " ---> trig: " << trigbit
00089        << "; rnum: " << rnum
00090        << "; evnum: " << evnum << endl;
00091   
00092   Int_t L_DCH1 = fPrec->GetLQ(JFGES-4);
00093   while(L_DCH1){
00094     Int_t dch_num = fPrec->GetIQ(L_DCH1+1);
00095     cout << "dch_num = " << dch_num << endl;
00096     
00097     L_DCH1 = fPrec->GetLQ(L_DCH1);
00098   }
00099   */
00100 }
00101 
00102 //_______________________________
00103 void ZebraAcc_Appl1::UseProcessRec_DST(){
00104 
00105   Int_t JFDST = fPrec->GetJFDST();
00106   if(!JFDST) return;
00107   Int_t trigbit = fPrec->GetIQ(JFDST+3);
00108   Int_t rnum = fPrec->GetIQ(JFDST+1);
00109   Int_t evnum = fPrec->GetIQ(JFDST+2);
00110   cout << "JFDST = " << JFDST 
00111        << " ---> trig: " << trigbit
00112        << "; rnum: " << rnum
00113        << "; evnum: " << evnum << endl;
00114   
00115   // --- eval
00116 
00117   // ---
00118 
00119   fTofTree->Fill();
00120 }
00121 
00122 
00123 //_______________________________
00124 //_______________________________
00125 //_______________________________
00126 void AccessZebra_Appl_1(TString run_type="FINU",Int_t first_run = -1,Int_t last_run = -1,Int_t n_evs_run=-1,Int_t n_evs_tot=-1){
00127   
00128   ZebraAcc_Appl1 *zac = new ZebraAcc_Appl1();
00129   Int_t debug_lev = 0;
00130   //
00131   zac->InitTrees();
00132   zac->SetFillDst(1);
00133   zac->Init("$MSQL_DB_HOST","$RDT",run_type,first_run,last_run,n_evs_run,n_evs_tot,debug_lev);
00134 
00135   zac->RunLoop();
00136 
00137   zac->SaveTrees("test.root");
00138   delete zac;
00139 }

Generated on Tue Oct 16 15:40:47 2007 by  doxygen 1.5.2