Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-12 09:14:01

0001 // $Id$
0002 //
0003 //    File: JEventProcessor_janaroot.h
0004 // Created: Fri Jul 11 03:39:49 EDT 2008
0005 // Creator: davidl (on Darwin Amelia.local 8.11.1 i386)
0006 //
0007 
0008 #ifndef _JEventProcessor_janaroot_
0009 #define _JEventProcessor_janaroot_
0010 
0011 #include <map>
0012 #include <string>
0013 
0014 #include <TFile.h>
0015 #include <TTree.h>
0016 
0017 #include <JANA/JEventProcessor.h>
0018 #include <JANA/JFactory.h>
0019 #include <JANA/Services/JLockService.h>
0020 #include <JANA/JApplication.h>
0021 
0022 class JEventProcessor_janaroot:public JEventProcessor{
0023     public:
0024         JEventProcessor_janaroot();
0025         ~JEventProcessor_janaroot(){};
0026         const char* className(void){return "JEventProcessor_janaroot";}
0027         
0028         enum data_type_t{
0029             type_unknown,
0030             type_short,
0031             type_ushort,
0032             type_int,
0033             type_uint,
0034             type_long,
0035             type_ulong,
0036             type_float,
0037             type_double,
0038             type_string
0039         };
0040         
0041         class TreeInfo{
0042             public:
0043                 TTree *tree;
0044                 vector<TBranch*> branches;
0045                 int Nmax;
0046                 unsigned long buff_size;
0047                 void *buff;
0048                 unsigned long obj_size; // size of one object
0049                 vector<unsigned long> item_sizes;
0050                 vector<data_type_t> types;
0051                 int *Nptr;
0052                 unsigned long Bptr;
0053             map<int, vector<std::string> > StringMap;
0054                 
0055                 void Print(void){
0056                     cout<<"    tree name:"<<tree->GetName()<<endl;
0057                     cout<<"Num. branches:"<<branches.size()<<endl;
0058                     cout<<"         Nmax:"<<Nmax<<endl;
0059                     cout<<"    buff_size:"<<buff_size<<endl;
0060                     cout<<"         buff:0x"<<hex<<(unsigned long)buff<<dec<<endl;
0061                     cout<<"     obj_size:"<<obj_size<<endl;
0062                     cout<<"        items:";
0063                     for(unsigned int i=0; i<item_sizes.size(); i++){
0064                         if(i!=0)cout<<"              ";
0065                         cout<<"size="<<item_sizes[i]<<"  type="<<types[i]<<endl;
0066                     }
0067                     cout<<"        Nptr:0x"<<hex<<(unsigned long)Nptr<<dec<<endl;
0068                     cout<<"        Bptr:0x"<<hex<<(unsigned long)Bptr<<dec<<endl;
0069                 }
0070         };
0071         
0072     private:
0073         void Init(void) override;                       ///< Called once at program start.
0074         void BeginRun(const std::shared_ptr<const JEvent>& event) override; ///< Called everytime a new run number is detected.
0075         void Process(const std::shared_ptr<const JEvent>& event) override;  ///< Called every event.
0076         void EndRun(void) override;                     ///< Called everytime run number changes, provided brun has been called.
0077         void Finish(void) override;                     ///< Called after last event of last event source has been processed.
0078 
0079         std::shared_ptr<JLockService> lock_svc;
0080 
0081         unsigned int Nevents;
0082         
0083         unsigned int Nwarnings;
0084         unsigned int MaxWarnings;
0085         
0086         int JANAROOT_VERBOSE;
0087         vector<string> nametags_to_write_out;
0088 
0089         TFile *file;
0090         std::map<std::string, TreeInfo*> trees;
0091         int Nmax; ///< maximum number of objects of a given type in the event
0092         
0093         TreeInfo* GetTreeInfo(JFactory *fac);
0094         void FillTree(JFactory *fac, TreeInfo *binfo);
0095 };
0096 
0097 #endif // _JEventProcessor_janaroot_
0098