• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/gsi-aug12/get4v10/go4/ROOTCONV/TRootConverterProc.cxx (r4864/r3846)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TRootConverterProc.h"
00004 #include "TCBMBeamtimeEvent.h"
00005 #include "TGo4Version.h"
00006 #if __GO4BUILDVERSION__ > 40502
00007    #include "go4iostream.h"
00008 #else
00009    #include "Riostream.h"
00010 #endif
00011 #include "TGo4UserException.h"
00012 #include "TGo4MbsEvent.h"
00013 
00014 #include "TH1.h"
00015 #include "TH2.h"
00016 #include "TH3.h"
00017 #include "TProfile.h"
00018 
00019 #include "TGo4Analysis.h"
00020 
00021 #include <algorithm>
00022 
00023 //***********************************************************
00024 TRootConverterProc::TRootConverterProc(const char* name) :
00025 TCBMBeamtimeProc(name), 
00026 fVftxInputEvent(0),
00027 fCrateInputEvent(0),
00028 fTriglogInputEvent(0),
00029 fEpicsInputEvent(0),
00030 fRpcHdInputEvent(0),
00031 fRpcBucInputEvent(0),
00032 fMatchingInputEvent(0),
00033 fOutputEvent(0),
00034 cleanTree(0)
00035 {
00036    TGo4Log::Info("**** TRootConverterProc: Create instance %s", name);
00037 
00038    fRootConvPar = (TRootConverterParam*) MakeParameter("RootConvPar", "TRootConverterParam");
00039    cout << "RootConvPar = " << fRootConvPar << endl;
00040 
00041 
00042    // ROC general variables
00043    uNbEvents = 0;
00044    
00045    //~ TString path = GetName();
00046    //~ path += "/";
00047    //~ path += GetName();
00048    if( 1 == fRootConvPar->uSlowControlInTree )
00049    {
00050       hTimeEpicsUpdates = MakeTH1('I', "RootConv/RC_TimeEpicsUpdate","Timing of epics updates; Time [s]",
00051             7200, 0, 7200);
00052    } // if( 1 == fRootConvPar->uSlowControlInTree )
00053    uEpicsTimeOrigin = 0;
00054       
00055    //printf("RPC Histograms created \n");
00056    fflush ( stdout);
00057 }
00058 
00059 TRootConverterProc::~TRootConverterProc()
00060 {
00061 //   TGo4Log::Info("Proc  %p", this);
00062    if( (1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay)
00063          && 0 != cleanTree )
00064       {
00065           if( 1 == fRootConvPar->uRootDisplay )
00066              TGo4Analysis::Instance()->RemoveTree(cleanTree);
00067           if( 1 == fRootConvPar->uCleanOuputEnable )
00068           {
00069              fRootOut->Write("",TObject::kOverwrite);
00070              //~ gDirectory->Cd(sOutputFilename);
00071 //~ 
00072              //~ cleanTree->SetDirectory(gDirectory);
00073              //~ cleanTree->Write(0,TObject::kOverwrite); // to avoid double trees in file: cf http://root.cern.ch/root/roottalk/roottalk01/0842.html
00074              //~ gDirectory->Cd(oldDir->GetPath());
00075              fRootOut->Close();
00076           } // if( 1 == fRootConvPar->uCleanOuputEnable )
00077 
00078           if( 0 == fRootConvPar->uCleanOuputEnable )
00079              delete cleanTree;
00080 
00081           if( 1 == fRootConvPar->uSlowControlInTree )
00082           {
00083              vdPositiveHvI.clear();
00084              vdPositiveHvU.clear();
00085              vdNegativeHvI.clear();
00086              vdNegativeHvU.clear();
00087           }
00088 
00089 //          if( 1 == fRootConvPar->uCleanOuputEnable )
00090 //             delete fRootOut;
00091       }
00092 
00093    cout << "**** TRootConverterProc: Delete instance " << endl;
00094 }
00095 //***********************************************************
00096 
00097 void TRootConverterProc::InitEvent(TGo4EventElement* outevnt)
00098 {
00099    // first assign input event:
00100    // since input event object is never discarded within processor lifetime,
00101    // we just search for subevent by name once to speed up processing
00102    if( 0 ==fVftxInputEvent && 1 == fRootConvPar->uVftxInTree)
00103    {
00104       TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Detector"));
00105       if(btevent)
00106       {
00107          fVftxInputEvent=dynamic_cast<TVftxEvent*>(btevent->GetSubEvent("VFTX"));
00108       }
00109 
00110       if(fVftxInputEvent==0) {
00111          GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TVftxEvent!!! STOP GO4");
00112       }
00113    } // if( 0 == fVftxInputEvent && 1 == fRootConvPar->uVftxInTree)
00114 
00115    // Optional: if triggered mode and tree, look for the VME crate data
00116    // since input event object is never discarded within processor lifetime,
00117    // we just search for subevent by name once to speed up processing
00118    if( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay )
00119    {
00120       TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Calibration"));
00121       if(fCrateInputEvent==0)
00122       {
00123          if(btevent)
00124          {
00125             fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00126          }
00127 
00128          if(fCrateInputEvent==0) {
00129             GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TMbsCrateEvent!!! STOP GO4");
00130          }
00131       } // if(fCrateInputEvent==0)
00132       if( 1 == fRootConvPar->uTriglogInputInTree )
00133       {
00134          if(fTriglogInputEvent==0)
00135          {
00136             if(btevent)
00137             {
00138                fTriglogInputEvent=dynamic_cast<TTriglogEvent*>(btevent->GetSubEvent("TRIGLOG"));
00139             }
00140 
00141             if(fTriglogInputEvent==0) {
00142                GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TTriglogEvent!!! STOP GO4");
00143             }
00144          } // if(fTriglogInputEvent==0)
00145       } // if( 1 == fRootConvPar->uTriglogInputInTree )
00146       if( 1 == fRootConvPar->uSlowControlInTree )
00147       {
00148          if(fEpicsInputEvent==0)
00149          {
00150             if(btevent)
00151             {
00152                fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00153             }
00154 
00155             if(fEpicsInputEvent==0) {
00156                GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TEpicsEvent!!! STOP GO4");
00157             }
00158          } // if(fEpicsInputEvent==0)
00159       } // if( 1 == fRootConvPar->uSlowControlInTree )
00160 
00161       // Param need to be done!!!!
00162       /*
00163       if( ( 1 == fRootConvPar->uRpcHdInTree  && fRpcHdInputEvent  ==0 ) ||
00164           ( 1 == fRootConvPar->uRpcBucInTree && fRpcBucInputEvent ==0 ) )
00165       {
00166          TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Tracking"));
00167          if(btevent)
00168          {
00169             if( 1 == fRootConvPar->uRpcHdInTree )
00170                fRpcHdInputEvent  =dynamic_cast<TRpcEvent*>(btevent->GetSubEvent("RPC_HD"));
00171             if( 1 == fRootConvPar->uRpcBucInTree )
00172                fRpcBucInputEvent =dynamic_cast<TRpcEvent*>(btevent->GetSubEvent("RPC_BUC"));
00173          }
00174 
00175          if( 1 == fRootConvPar->uRpcHdInTree  && fRpcHdInputEvent ==0) {
00176             GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TRpcEvent for HD!!! STOP GO4");
00177          }
00178          if( 1 == fRootConvPar->uRpcBucInTree && fRpcBucInputEvent==0) {
00179             GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TRpcEvent for Buc!!! STOP GO4");
00180          }
00181       } // if(fRpcHdInputEvent==0 || fRpcBucInputEvent==0 || fScalersInputEvent==0)
00182       if( 1 == fRootConvPar->uMatchingInTree )
00183       {
00184          if(fMatchingInputEvent==0)
00185          {
00186             TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00187             if(btevent)
00188             {
00189                fMatchingInputEvent=dynamic_cast<TMatchingEvent*>(btevent->GetSubEvent("MATCHING"));
00190             }
00191 
00192             if(fMatchingInputEvent==0) {
00193                GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TMatchingEvent!!! STOP GO4");
00194             }
00195          } // if(fMatchingInputEvent==0)
00196       } // if( 1 == fRootConvPar->uMatchingInTree )
00197       */
00198    } // if( kFALSE == fRocPar->noTrigger && ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) )
00199       else if( 1 == fRootConvPar->uSlowControlInTree )
00200       {
00201          TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Calibration"));
00202          if(fEpicsInputEvent==0)
00203          {
00204             if(btevent)
00205             {
00206                fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00207             }
00208 
00209             if(fEpicsInputEvent==0) {
00210                GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event is/has not a TEpicsEvent!!! STOP GO4");
00211             }
00212          } // if(fEpicsInputEvent==0)
00213       } //  else if( 1 == fRootConvPar->uSlowControlInTree )
00214 
00215    // then assign output event
00216    // since output event object is never discarded within processor lifetime,
00217    // we just search for subevent by name once to speed up processing
00218    if(fOutputEvent==0)
00219    {
00220       TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00221       if(btevent)
00222       {
00223          fOutputEvent=dynamic_cast<TRootConverterEvent*>(btevent->GetSubEvent("ROOTCONV"));
00224       }
00225       else
00226       {
00227 
00228             fOutputEvent= dynamic_cast<TRootConverterEvent*>(outevnt);
00229       }
00230       if(fOutputEvent==0) {
00231       GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: output event is not a TRootConverterEvent!!! STOP GO4");
00232       }
00233 
00234    }
00235 
00236    // Prepare root tree and tree output file
00237    if( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay)
00238    {
00239       if( 0 == cleanTree)
00240       {
00241          TGo4Log::Info("**** TRootConverter: Create tree ");
00242 
00243          if( 1 == fRootConvPar->uCleanOuputEnable )
00244          {
00245             oldDir = gDirectory;
00246 
00247             sOutputFilename = fRootConvPar->sOutputFilename;
00248             fRootOut= new TFile(sOutputFilename, "RECREATE", "TTree file from GET4 and CAEN v1290", 9);
00249             sOutputFilename += ":/";
00250             if (fRootOut->IsZombie()) {
00251                cout << "Error opening file for TTree output in TRootConverter" << endl;
00252             }
00253 
00254             gDirectory->Cd(sOutputFilename);
00255          }
00256 
00257          if( 0 == TGo4Analysis::Instance()->GetTree( "GsiAug12" ) )
00258          {
00259             cleanTree = new TTree("GsiAug12", "GSI August 2012 data");
00260             TGo4Log::Info("Output Tree created in %s", gDirectory->GetPath());
00261          } // if( 0 == TGo4Analysis::Instance()->GetTree( "GsiAug12" ) )
00262             else
00263             {
00264                cleanTree = TGo4Analysis::Instance()->GetTree( "GsiAug12" );
00265                TGo4Log::Info("Output Tree recovered from Go4");
00266             } // else of if( 0 == TGo4Analysis::Instance()->GetTree( "GsiAug12" ) )
00267 
00268          // To prevent having multiple trees when opening the file with Go4 -> Not right solution
00269 //         cleanTree->SetAutoFlush(0);
00270 
00271          // Data from CAEN v1290 & Lecroy QDC VME boards (triggered)
00272          {
00273             if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel1 && 1 == fRootConvPar->uAddGet4DataInTree )
00274             {
00275                cleanTree->Branch("CaenRef1_Leading",
00276                                  &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).lead[fRootConvPar->iReferenceChannel1]),
00277                                  "CaenRef1_Leading/I" );
00278                cleanTree->Branch("CaenRef1_Trailing",
00279                                  &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).trail[fRootConvPar->iReferenceChannel1]),
00280                                  "CaenRef1_Trailing/I" );
00281             } // if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel && 1 == fRootConvPar->uAddGet4DataInTree )
00282             if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel2 && 1 == fRootConvPar->uAddGet4DataInTree )
00283             {
00284                cleanTree->Branch("CaenRef2_Leading",
00285                                  &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).lead[fRootConvPar->iReferenceChannel2]),
00286                                  "CaenRef2_Leading/I" );
00287                cleanTree->Branch("CaenRef2_Trailing",
00288                                  &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).trail[fRootConvPar->iReferenceChannel2]),
00289                                  "CaenRef2_Trailing/I" );
00290             } // if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel && 1 == fRootConvPar->uAddGet4DataInTree )
00291             
00292             if( 1 == fRootConvPar->uCaenMode )
00293             {
00294                for( Int_t iCaenBoard = 0; iCaenBoard<MAX_1290; iCaenBoard ++)
00295                   if( 1 == fRootConvPar->uGeneralCaenTdcEnabled[iCaenBoard])
00296                   {
00297                      cleanTree->Branch(Form("Caen%d_TriggerTime", iCaenBoard),  
00298                                        &( (fCrateInputEvent->fMtdc[iCaenBoard]).extended_trigger_time ),
00299                                        Form("Caen%d_TriggerTime/I", iCaenBoard )  );
00300                                        
00301                      // The multiple hits array for CAEN v1290 now also include first hit
00302                      // => either add to tree the first hit or add to tree only the multiple hit array
00303                      if( 1 == fRootConvPar->uCaenMulti )
00304                      {
00305                cleanTree->Branch(Form("Caen%d_Leading_NbHit", iCaenBoard), 
00306                                  (fCrateInputEvent->fMtdc[iCaenBoard]).hit_lead,
00307                                  Form("Caen%d_Leading_NbHit[%u]/I", iCaenBoard, T1290Data::NumChan ) );
00308                cleanTree->Branch(Form("Caen%d_Trailing_NbHit", iCaenBoard), 
00309                                  (fCrateInputEvent->fMtdc[iCaenBoard]).hit_trail,
00310                                  Form("Caen%d_Trailing_NbHit[%u]/I", iCaenBoard, T1290Data::NumChan ) );
00311                cleanTree->Branch(Form("Caen%d_Leading_multi", iCaenBoard),  
00312                                  (fCrateInputEvent->fMtdc[iCaenBoard]).lead_multi,
00313                                  Form("Caen%d_Leading_multi[%u][%u]/I", iCaenBoard, T1290Data::NumChan, T1290Data::MaxHits )  );
00314                cleanTree->Branch(Form("Caen%d_Trailing_multi", iCaenBoard), 
00315                                  (fCrateInputEvent->fMtdc[iCaenBoard]).trail_multi,
00316                                  Form("Caen%d_Trailing_multi[%u][%u]/I", iCaenBoard, T1290Data::NumChan, T1290Data::MaxHits ) );
00317                      } // if( 1 == fRootConvPar->uCaenMulti )
00318                         else
00319                         {
00320                      cleanTree->Branch(Form("Caen%d_Leading", iCaenBoard),  
00321                                        (fCrateInputEvent->fMtdc[iCaenBoard]).lead,
00322                                        Form("Caen%d_Leading[%u]/I", iCaenBoard, T1290Data::NumChan )  );
00323                      cleanTree->Branch(Form("Caen%d_Trailing", iCaenBoard), 
00324                                        (fCrateInputEvent->fMtdc[iCaenBoard]).trail,
00325                                        Form("Caen%d_Trailing[%u]/I", iCaenBoard, T1290Data::NumChan ) );
00326                         } // else of if( 1 == fRootConvPar->uCaenMulti )
00327                   } // if( 1 == fRootConvPar->uGeneralCaenTdcEnabled[iCaenBoard])
00328             } // if( 1 == fRootConvPar->uCaenMode )
00329             
00330             if( -1 != fRootConvPar->iPmtTdc && 0 == fRootConvPar->uCaenMode)
00331             {
00332                cleanTree->Branch("PmtTdc_Leading",  (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).lead,
00333                                  Form("PmtTdc_Leading[%u]/I", T1290Data::NumChan )  );
00334                cleanTree->Branch("PmtTdc_Trailing", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).trail,
00335                                  Form("PmtTdc_Trailing[%u]/I", T1290Data::NumChan ) );
00336                cleanTree->Branch("PmtTdc_Leading_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).hit_lead,
00337                                     Form("PmtTdc_Leading_NbHit[%u]/I", T1290Data::NumChan ) );
00338                cleanTree->Branch("PmtTdc_Trailing_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).hit_trail,
00339                                  Form("PmtTdc_Trailing_NbHit[%u]/I", T1290Data::NumChan ) );
00340                cleanTree->Branch("PmtTdc_Leading_multi",  (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).lead_multi,
00341                                  Form("PmtTdc_Leading_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits )  );
00342                cleanTree->Branch("PmtTdc_Trailing_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).trail_multi,
00343                                  Form("PmtTdc_Trailing_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00344             } // if( -1 != fRootConvPar->iPmtTdc )
00345             if( -1 != fRootConvPar->iRpcTdcLeading && -1 != fRootConvPar->iRpcTdcTrailing && 0 == fRootConvPar->uCaenMode )
00346             {
00347                cleanTree->Branch("CaenRpc_Leading",  (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).lead,
00348                                  Form("CaenRpc_Leading[%u]/I", T1290Data::NumChan )  );
00349                cleanTree->Branch("CaenRpc_Trailing", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).trail,
00350                                  Form("CaenRpc_Trailing[%u]/I", T1290Data::NumChan ) );
00351                cleanTree->Branch("CaenRpc_Leading_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).hit_lead,
00352                                     Form("CaenRpc_Leading_NbHit[%u]/I", T1290Data::NumChan ) );
00353                cleanTree->Branch("CaenRpc_Trailing_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).hit_trail,
00354                                  Form("CaenRpc_Trailing_NbHit[%u]/I", T1290Data::NumChan ) );
00355                cleanTree->Branch("CaenRpc_Leading_multi",  (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).lead_multi,
00356                                  Form("CaenRpc_Leading_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits )  );
00357                cleanTree->Branch("CaenRpc_Trailing_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).trail_multi,
00358                                  Form("CaenRpc_Trailing_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00359             } // if( -1 != fRootConvPar->iRpcTdcLeading && -1 != fRootConvPar->iRpcTdcTrailing && 0 == fRootConvPar->uCaenMode )
00360             
00361             if( -1 != fRootConvPar->iPmtQdc )
00362             {
00363                cleanTree->Branch("PmtQdc", fCrateInputEvent->fData1182[fRootConvPar->iPmtQdc], Form("PmtQdc[%u]/s", NUM_1182_CH ) );
00364             } // if( -1 != fRootConvPar->iPmtQdc )
00365 
00366             if( 1 == fRootConvPar->uTriglogInputInTree)
00367             {
00368                cleanTree->Branch("TriglogSyncNb",  &(fTriglogInputEvent->fVulomSyncNumber),
00369                                  "TriglogSyncNb/i"  );
00370                cleanTree->Branch("TriglogPattern",  &(fTriglogInputEvent->fVulomTriggerPattern),
00371                                  "TriglogPattern/i"  );
00372                cleanTree->Branch("TriglogTimeSec",  &(fTriglogInputEvent->fMbsTimeSecs),
00373                                  "TriglogTimeSec/i"  );
00374                cleanTree->Branch("TriglogTimeMilsec",  &(fTriglogInputEvent->fMbsTimeMillisec),
00375                                  "TriglogTimeMilsec/i"  );
00376                cleanTree->Branch("TriglogScalers1",  (fTriglogInputEvent->fVulomScaler[0]),
00377                                  Form("TriglogScalers1[%u]/i", N_SCALERS_CH )  );
00378                cleanTree->Branch("TriglogScalers2",  (fTriglogInputEvent->fVulomScaler[1]),
00379                                  Form("TriglogScalers2[%u]/i", N_SCALERS_CH )  );
00380                cleanTree->Branch("TriglogScalers3",  (fTriglogInputEvent->fVulomScaler[2]),
00381                                  Form("TriglogScalers3[%u]/i", N_SCALERS_CH )  );
00382             } // if( 1 == fRootConvPar->uTriglogInputInTree)
00383             if( 1 == fRootConvPar->uVftxInTree)
00384             {
00385                for( Int_t iVftxBoard = 0; iVftxBoard<MAX_FPGA_TDC; iVftxBoard ++)
00386                   if( 1 == fRootConvPar->uVftxEnabled[iVftxBoard])
00387                   {
00388                      TString sBrNameTrigg  = Form("Vftx%dTriggerTime", iVftxBoard);
00389                      TString sBrNameMulti  = Form("Vftx%dMultiplicity", iVftxBoard);
00390                      TString sBrNameFineT  = Form("Vftx%dFineTime", iVftxBoard);
00391                      TString sBrNameCoarT  = Form("Vftx%dCoarseTime", iVftxBoard);
00392                      TString sBrNameFutuB  = Form("Vftx%dFutureBit", iVftxBoard);
00393                      TString sBrNameTimeC  = Form("Vftx%dTimeCorr", iVftxBoard);
00394                      TString sBrNameFtCorr = Form("Vftx%dFineTimeCorr", iVftxBoard);
00395 
00396                cleanTree->Branch( sBrNameTrigg,  &((fVftxInputEvent->fVftxBoards[iVftxBoard]).iTriggerTime),
00397                                   sBrNameTrigg + "/I" );
00398                cleanTree->Branch( sBrNameMulti,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).iMultiplicity),
00399                                   sBrNameMulti + Form("[%u]/I", FPGA_TDC_NBCHAN )  );
00400                      if( 1 == fRootConvPar->uVftxFullDataMode )
00401                      {
00402                cleanTree->Branch( sBrNameFineT,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).iFineTime),
00403                                   sBrNameFineT + Form("[%u][%u]/I", FPGA_TDC_NBCHAN, TVftxBoardData::MaxMult )  );
00404                cleanTree->Branch( sBrNameCoarT,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).iCoarseTime),
00405                                   sBrNameCoarT + Form("[%u][%u]/I", FPGA_TDC_NBCHAN, TVftxBoardData::MaxMult )  );
00406                cleanTree->Branch( sBrNameFutuB,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).uFutureBit),
00407                                   sBrNameFutuB + Form("[%u][%u]/i", FPGA_TDC_NBCHAN, TVftxBoardData::MaxMult )  );
00408                cleanTree->Branch( sBrNameFtCorr,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).dFineTimeCorr),
00409                                   sBrNameFtCorr + Form("[%u][%u]/D", FPGA_TDC_NBCHAN, TVftxBoardData::MaxMult )  );
00410                      } //if( 1 == fRootConvPar->uVftxFullDataMode )
00411 
00412                cleanTree->Branch( sBrNameTimeC,  ((fVftxInputEvent->fVftxBoards[iVftxBoard]).dTimeCorr),
00413                                   sBrNameTimeC + Form("[%u][%u]/D", FPGA_TDC_NBCHAN, TVftxBoardData::MaxMult )  );
00414                   } // if( 1 == fRootConvPar->uVftxEnabled[iVftxBoard])
00415             } // if( 1 == fRootConvPar->uVftxInTree)
00416             if( 1 == fRootConvPar->uScalOrMuInTree)
00417             {
00418                cleanTree->Branch("ScalOrMuScalers",  (fCrateInputEvent->fScalOrMu).uScaler,
00419                                  Form("ScalOrMuScalers[%u]/i", SCALORMU_NB_SCAL )  );
00420             } // if( 1 == fRootConvPar->uVftxInTree)
00421          } // if( kFALSE == fRocPar->noTrigger )
00422 
00423          if( 1 == fRootConvPar->uSlowControlInTree )
00424          {
00425             uSlowControlUpdateTime = 0;
00426             cleanTree->Branch( "TimeEpicsUpdate", &(uSlowControlUpdateTime),
00427                                "TimeEpicsUpdate/i"  );
00428             vdPositiveHvI.clear();
00429             vdPositiveHvU.clear();
00430             vdNegativeHvI.clear();
00431             vdNegativeHvU.clear();
00432             vdPositiveHvI.resize(fRootConvPar->uNbSlowControlChan);
00433             vdPositiveHvU.resize(fRootConvPar->uNbSlowControlChan);
00434             vdNegativeHvI.resize(fRootConvPar->uNbSlowControlChan);
00435             vdNegativeHvU.resize(fRootConvPar->uNbSlowControlChan);
00436             for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00437             {
00438                cleanTree->Branch( fRootConvPar->sScOutputNamePosI[uChannelHV], &(vdPositiveHvI.at(uChannelHV)),
00439                                  fRootConvPar->sScOutputNamePosI[uChannelHV] + Form("/D" )  );
00440                cleanTree->Branch( fRootConvPar->sScOutputNamePosU[uChannelHV], &(vdPositiveHvU.at(uChannelHV)),
00441                                  fRootConvPar->sScOutputNamePosU[uChannelHV] + Form("/D" )  );
00442                cleanTree->Branch( fRootConvPar->sScOutputNameNegI[uChannelHV], &(vdNegativeHvI.at(uChannelHV)),
00443                                  fRootConvPar->sScOutputNameNegI[uChannelHV] + Form("/D" )  );
00444                cleanTree->Branch( fRootConvPar->sScOutputNameNegU[uChannelHV], &(vdNegativeHvU.at(uChannelHV)),
00445                                  fRootConvPar->sScOutputNameNegU[uChannelHV] + Form("/D" )  );
00446                vdPositiveHvI.at(uChannelHV) = 0;
00447                vdPositiveHvU.at(uChannelHV) = 0;
00448                vdNegativeHvI.at(uChannelHV) = 0;
00449                vdNegativeHvU.at(uChannelHV) = 0;
00450             } // for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00451          } // if( 1 == fRootConvPar->uSlowControlInTree )
00452 
00453          cleanTree->SetDirectory(gDirectory);
00454 
00455          if( 1 == fRootConvPar->uRootDisplay && 0 == TGo4Analysis::Instance()->GetTree( "GsiAug12" ))
00456          {
00457             TGo4Analysis::Instance()->AddTree(cleanTree );
00458             TGo4Log::Info("Root Tree registered in Go4: %p", TGo4Analysis::Instance()->GetTree( "GsiAug12" ) );
00459          }
00460       } // if( 0 == cleanTree)
00461    } // if( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay)
00462 }
00463 
00464 
00465 void TRootConverterProc::FinalizeEvent()
00466 {
00467    if( 0 == fRootConvPar->uCleanOuputEnable && 0 == fRootConvPar->uRootDisplay)
00468          return;
00469    if( 0 == fRootConvPar->uCleanOuputEnable && 1 == fRootConvPar->uRootDisplay &&
00470        fRootConvPar->uEventsUntilReset <= cleanTree->GetEntries())
00471       cleanTree->Reset("");
00472         //if(!fRpcInputEvent->IsValid() &&  1 == fRootConvPar->uAddGet4DataInTree) return; // skip incomplete rpc events from second step
00473    if(!fCrateInputEvent->IsValid() ) return; // skip incomplete mbs events from first step
00474    if( 1 == fRootConvPar->uTriglogInputInTree )
00475       if( !fTriglogInputEvent->IsValid() )
00476          return; // skip incomplete triglog events from first step
00477    if( 1 == fRootConvPar->uVftxInTree )
00478       if( !fVftxInputEvent->IsValid() )
00479          cout<<"Invalid VFTX event! event "<<uNbEvents<<endl;
00480 
00481    uNbEvents++;
00482 
00483    // Fill the tree
00484    if( ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) )
00485    {
00486       if( 1 == fRootConvPar->uSlowControlInTree )
00487       {
00488          if( kTRUE == fEpicsInputEvent->IsValid() )
00489          {
00490             TString sVariableName = "";
00491             if( 0 == uEpicsTimeOrigin )
00492                uEpicsTimeOrigin = fEpicsInputEvent->fUTimeSeconds;
00493             hTimeEpicsUpdates->Fill( (fEpicsInputEvent->fUTimeSeconds )% 1000);
00494             uSlowControlUpdateTime = fEpicsInputEvent->fUTimeSeconds;
00495             for(UInt_t uEpicsVariableIndex = 0; uEpicsVariableIndex < fEpicsInputEvent->GetNumDoubles(); uEpicsVariableIndex++ )
00496             {
00497                sVariableName = fEpicsInputEvent->GetDoubleName( uEpicsVariableIndex );
00498                for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00499                {
00500                   if( sVariableName == fRootConvPar->sScInputNamePosI[uChannelHV])
00501                   {
00502                      vdPositiveHvI.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00503                      break;
00504                   }
00505                   if( sVariableName == fRootConvPar->sScInputNamePosU[uChannelHV])
00506                   {
00507                      vdPositiveHvU.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00508                      break;
00509                   }
00510                   if( sVariableName == fRootConvPar->sScInputNameNegI[uChannelHV])
00511                   {
00512                      vdNegativeHvI.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00513                      break;
00514                   }
00515                   if( sVariableName == fRootConvPar->sScInputNameNegU[uChannelHV])
00516                   {
00517                      vdNegativeHvU.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00518                      break;
00519                   }
00520                } //  for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00521             } // for(UInt_t uEpicsVariableIndex = 0; uEpicsVariableIndex < fEpicsInputEvent->GetNumDoubles(); uEpicsVariableIndex++ )
00522          } // if( kTRUE == fEpicsInputEvent->IsValid() )
00523       } // if( 1 == fRootConvPar->uSlowControlInTree )
00524 
00525       cleanTree->Fill();
00526    } // if( ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) )
00527 
00528    fOutputEvent->SetValid(kTRUE);
00529 }
00530 

Generated on Tue Dec 10 2013 04:52:18 for ROCsoft by  doxygen 1.7.1