TNeAnalysis.cxx 5.6 KB
Newer Older
Pavel Sharov's avatar
Pavel Sharov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//===================================================================
//== TNeAnalysis.cxx:	exp0211
//== Version:	2011-02-01
//===================================================================

using namespace std;

#include "TNeAnalysis.h"

#include <stdlib.h>
#include "Riostream.h"

#include "Go4EventServer.h"
#include "TGo4StepFactory.h"
#include "TGo4AnalysisStep.h"
#include "TNeDet16.h"
//#include "TNeH1Parms.h"
//#include "TNeH2Parms.h"
#include "TNeMParms.h"
#include "TNeSel.h"

#include "TGo4Version.h"
#include "TGo4MbsEventServer.h"

//***********************************************************
TNeAnalysis::TNeAnalysis()
:fMbsEvent(0)
	,fEvents(0)
	,fLastEvent(0)
30 31 32 33 34 35 36 37 38
	,p_Lxa(0)
	,p_Lya(0)
	,p_Rxa(0)
	,p_Rya(0)
	,p_RVa(0)
	,p_R60a(0)
	,p_AnSa(0)
	,p_AnRa(0)
	,p_AnVa(0)
Pavel Sharov's avatar
Pavel Sharov committed
39 40 41 42 43 44 45 46 47 48
{
}
//***********************************************************

// this constructor is called by go4analysis executable
TNeAnalysis::TNeAnalysis(int argc, char** argv)
   :TGo4Analysis(argc, argv)
	,fMbsEvent(0)
	,fEvents(0)
	,fLastEvent(0)
49 50 51 52 53 54 55 56 57
	,p_Lxa(0)
	,p_Lya(0)
	,p_Rxa(0)
	,p_Rya(0)
	,p_RVa(0)
	,p_R60a(0)
	,p_AnSa(0)
	,p_AnRa(0)
	,p_AnVa(0)
Pavel Sharov's avatar
Pavel Sharov committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

{
   cout << "**** Create TNeAnalysis name: " << argv[0] << endl;

   if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) {
      cout << "****  Go4 version mismatch" << endl;
      exit(-1);
   }

   TGo4StepFactory* factory = new TGo4StepFactory("Factory");
   factory->DefEventProcessor("NeProc","TNeProc");// object name, class name
   factory->DefOutputEvent("NeEvent","TNeEvent"); // object name, class name

//   TGo4EventSourceParameter* sourcepar = new TGo4MbsEventServerParameter("rio3");
   TGo4EventSourceParameter* sourcepar = new TGo4MbsStreamParameter("rio3-2");

    //TGo4EventSourceParameter* sourcepar = new TGo4MbsTransportParameter("rio3");

 //  TGo4EventSourceParameter* sourcepar = 
 //      new TGo4MbsFileParameter("/LynxOS/RIO3_3.1/mbsusr/user1/mbsrun/flnr/wrk3a/aa*.lmd");

   TGo4FileStoreParameter* storepar = new TGo4FileStoreParameter(Form("%sOutput", argv[0]),99,320000,5);
   storepar->SetOverwriteMode(kTRUE);

   TGo4AnalysisStep* step = new TGo4AnalysisStep("Analysis", factory, sourcepar, storepar);

   step->SetSourceEnabled(kTRUE);
   //step->SetStoreEnabled(kTRUE);
   step->SetProcessEnabled(kTRUE);
   step->SetErrorStopEnabled(kTRUE);

    // Now the first analysis step is set up.
   // Other steps could be created here
   AddAnalysisStep(step);

   // uncomment following line to define custom passwords for analysis server
   // DefineServerPasswords("Neadmin", "Nectrl", "Neview");
   DefineServerPasswords("Acu0La0", "Acu0La0",  "go4view");

   //////////////// Parameter //////////////////////////
   // At this point, autosave file has not yet been read!
   // Therefore parameter values set here will be overwritten
   // if an autosave file is there.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
   p_Lxa = new TNeDet16("Lxa");
   p_Lya = new TNeDet16("Lya");
   p_Rxa = new TNeDet16("Rxa");
   p_Rya = new TNeDet16("Rya");
   p_RVa = new TNeDet16("RVa");
   p_R60a = new TNeDet16("R60a");
   p_AnSa = new TNeDet16("AnSa");
   p_AnRa = new TNeDet16("AnRa");
   p_AnVa = new TNeDet16("AnVa");
   AddParameter(p_Lxa);
   AddParameter(p_Lya);
   AddParameter(p_Rxa);
   AddParameter(p_Rya);
   AddParameter(p_RVa);
   AddParameter(p_R60a);
   AddParameter(p_AnSa);
   AddParameter(p_AnRa);
   AddParameter(p_AnVa);
Pavel Sharov's avatar
Pavel Sharov committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
//   pMTracks = new TNeMParms("MTRACKS");
//   AddParameter(pMTracks);

}

//***********************************************************
TNeAnalysis::~TNeAnalysis()
{
   cout << "**** TNeAnalysis: Delete instance" << endl;
}

//-----------------------------------------------------------
Int_t TNeAnalysis::UserPreLoop()
{
   // all this is optional:
   cout << "**** TNeAnalysis: PreLoop" << endl;
   // get pointer to input event (used in postloop and event function):
   fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Analysis"));   // of step "Analysis"
   if(fMbsEvent) {
      // fileheader structure (lmd file only):
      s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
      if(fileheader)
      {
         cout <<"\nInput file: "<<fileheader->filhe_file << endl;
         cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
         cout <<"UserName:\t" << fileheader->filhe_user<<endl;
         cout <<"RunID:\t" << fileheader->filhe_run<<endl;
         cout <<"Explanation: "<<fileheader->filhe_exp <<endl;
         cout <<"Comments: "<<endl;
         Int_t numlines=fileheader->filhe_lines;
         for(Int_t i=0; i<numlines;++i)
         {
            cout<<"\t"<<fileheader->s_strings[i].string << endl;
         }
      }
   }
   fEvents=0; // event counter
   fLastEvent=0; // number of last event processed
157 158 159 160 161 162 163 164 165
	p_Lxa->ReadData();
	p_Lya->ReadData();
	p_Rxa->ReadData();
	p_Rya->ReadData();
	p_RVa->ReadData();
	p_R60a->ReadData();
	p_AnSa->ReadData();
	p_AnRa->ReadData();
	p_AnVa->ReadData();
Pavel Sharov's avatar
Pavel Sharov committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195


   return 0;
}
//-----------------------------------------------------------
Int_t TNeAnalysis::UserPostLoop()
{
   // all this is optional:
   cout << "**** TNeAnalysis: PostLoop" << endl;
   cout << "Last event  #: " << fLastEvent << " Total events: " << fEvents << endl;
   fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
   fEvents=0;
   return 0;
}

//-----------------------------------------------------------
Int_t TNeAnalysis::UserEventFunc()
{
   // all this is optional:
   // This function is called once for each event after all steps.
   if(fMbsEvent) {
      fEvents++;
      fLastEvent=fMbsEvent->GetCount();
   }
   if(fEvents == 1 || IsNewInputFile()) {
      cout << "First event #: " << fLastEvent  << endl;
      SetNewInputFile(kFALSE); // we have to reset the newfile flag
   }
   return 0;
}