analyzer_example.cxx

Go to the documentation of this file.
00001 // Simple example of how to define a class that derives from 
00002 // TRootanaEventLoop, thereby abstracting a way a lot of the 
00003 // default stuff associated with analyzer.cxx
00004 
00005 #include <stdio.h>
00006 #include <iostream>
00007 
00008 #include "TRootanaEventLoop.hxx"
00009 #include "TH1D.h"
00010 #include "TV1190Data.hxx"
00011 #include "TV792Data.hxx"
00012 
00013 class MyTestLoop: public TRootanaEventLoop {
00014 
00015   int nnn ;
00016 
00017 public:
00018 
00019   MyTestLoop() {
00020     nnn = 0;
00021   };
00022 
00023   virtual ~MyTestLoop() {};
00024 
00025   void BeginRun(int transition,int run,int time){
00026     std::cout << "Custom: begin run " << run << std::endl;
00027   }
00028 
00029   void EndRun(int transition,int run,int time){
00030     std::cout << "Custom end run " << run <<std::endl;
00031   }
00032 
00033   bool ProcessMidasEvent(TDataContainer& dataContainer){
00034 
00035 
00036     void *ptr;
00037     int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr);
00038     if (ptr){
00039       nnn++;
00040       if(nnn%100 == 0){
00041         std::cout << "Current run :  " << GetCurrentRunNumber() << std::endl;
00042         std::cout << "Trying to handle this event... " << size << " " << nnn << std::endl;
00043       }
00044 
00045       fOnlineHistDir->cd();
00046       char sname[256];
00047       sprintf(sname, "size%d", 0);
00048       TH1D* hsize = (TH1D*)fOnlineHistDir->Get(sname);
00049       if (!hsize){
00050         printf("Create [%s]\n", sname);
00051         hsize = new TH1D(sname, sname, 600, 0, 6000);
00052       }      
00053       hsize->Fill(size);
00054     }
00055 
00056 
00057     TV1190Data *v1190 = dataContainer.GetEventData<TV1190Data>("TDC0");
00058     if(v1190){ 
00059 
00060       std::cout << "TDC measurements for V1190" << std::endl;
00061       std::vector<TDCMeasurement>& measurements = v1190->GetMeasurements();
00062       for(unsigned int i = 0; i < measurements.size(); i++){
00063         TDCMeasurement tdcmeas = measurements[i];
00064         
00065         std::cout << "Measurement: " <<    tdcmeas.GetMeasurement() << " for tdc/chan "  <<
00066           tdcmeas.GetTDCNumber() << "/"<< tdcmeas.GetChannel() << std::endl;
00067 
00068       }   
00069       
00070     }
00071 
00072     TV792Data *v792 = dataContainer.GetEventData<TV792Data>("ADC0");
00073     if(v792 ){ 
00074  
00075       v792->Print();
00076       
00077     }
00078  
00079     return true;
00080   }
00081 
00082 
00083   // Describe some other command line argument
00084   void Usage(void){
00085     std::cout << "\t-D option: this is a fun new option " << std::endl;
00086   }
00087 
00088   // Define some other command line argument
00089   bool CheckOption(std::string option){
00090     const char* arg = option.c_str();
00091     if (strncmp(arg,"-D",2)==0){
00092       std::cout << arg+2 << std::endl;
00093       std::cout << "I'm happy with this flag!" << std::endl;
00094       return true;
00095     }
00096 
00097     return false;
00098   }
00099 
00100 }; 
00101 
00102 
00103 
00104 
00105 
00106 
00107 int main(int argc, char *argv[])
00108 {
00109 
00110   MyTestLoop::CreateSingleton<MyTestLoop>();
00111   return MyTestLoop::Get().ExecuteLoop(argc, argv);
00112 
00113 }
00114 

Generated on 5 May 2014 for ROOT Analyzer by  doxygen 1.6.1