00001
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 fRpcInputEvent(0),
00027 fCrateInputEvent(0),
00028 fTriglogInputEvent(0),
00029 fEpicsInputEvent(0),
00030 fOutputEvent(0),
00031 fBeamEvent(0),
00032 cleanTree(0)
00033 {
00034 TGo4Log::Info("**** TRootConverterProc: Create instance %s");
00035
00036 fRocPar = (TRocParam*) GetParameter("RocPar");
00037 cout << "ROCPAR = " << fRocPar << endl;
00038
00039 fRpcPar = (TRPCParam*) GetParameter("RPCPar");
00040 cout << "RPCPAR = " << fRpcPar << endl;
00041
00042 fRootConvPar = (TRootConverterParam*) MakeParameter("RootConvPar", "TRootConverterParam");
00043 cout << "RootConvPar = " << fRootConvPar << endl;
00044
00045 if (fRocPar->numRocs > 0) fNumRocs = (UInt_t) fRocPar->numRocs;
00046
00047
00048 uNbEvents = 0;
00049
00050 if(1 == fRootConvPar->uHodoDebugHisto)
00051 {
00052 TString path = GetName();
00053 path += "/";
00054 path += GetName();
00055
00056
00057 hNbClustersPerEventHodoscope = MakeTH1('I', path+"_NbClustersPerEventHodoscope","Nb hosdoscope clusters per event",
00058 16,-0.5,15.5);
00059
00060 hHitXvsMilliSecondsInSpill = MakeTH2('I', path+"_HitPosXVsTimeMilSecInSpill",
00061 "Hodoscope hit position versus time in Spill; Time in spill [ms]; X [mm]; Counts [mm]",
00062 8000,-50, 79950, 32,-14.5,15.5 );
00063 hHitYvsMilliSecondsInSpill = MakeTH2('I', path+"_HitPosYVsTimeMilSecInSpill",
00064 "Hodoscope hit position versus time in Spill; Time in spill [ms]; Y [mm]; Counts [mm]",
00065 8000,-50, 79950, 32,-14.5,15.5 );
00066
00067
00068 path = GetName();
00069 path += "/";
00070 TString sName = GetName();
00071 hHit2DvsSeconds = (TH3*)GetHistogram( path+ sName +"_HitPosVsTimeSec" );
00072 if( 0 == hHit2DvsSeconds )
00073 {
00074 hHit2DvsSeconds = new TH3I( sName +"_HitPosVsTimeSec",
00075 "Hodoscope hit position versus time; Time [s]; X [mm]; Y [mm]",
00076 1000,-0.5, 1999.5, 32,-14.5,15.5, 32,-14.5,15.5 );
00077 AddHistogram( hHit2DvsSeconds, path );
00078 }
00079 hHit2DvsSecondsInSpill = (TH3*)GetHistogram( path + sName +"_HitPosVsTimeSecInSpill" );
00080 if( 0 == hHit2DvsSecondsInSpill )
00081 {
00082 hHit2DvsSecondsInSpill = new TH3I( sName +"_HitPosVsTimeSecInSpill",
00083 "Hodoscope hit position versus time in Spill; Time in spill [s]; X [mm]; Y [mm]",
00084 80,-0.5, 79.5, 32,-14.5,15.5, 32,-14.5,15.5 );
00085 AddHistogram( hHit2DvsSecondsInSpill, path );
00086 }
00087 hHit2DvsMilliSecondsInSpill = (TH3*)GetHistogram( path + sName +"_HitPosVsTimeMilSecInSpill" );
00088 if( 0 == hHit2DvsMilliSecondsInSpill )
00089 {
00090 hHit2DvsMilliSecondsInSpill = new TH3I( sName +"_HitPosVsTimeMilSecInSpill",
00091 "Hodoscope hit position versus time in Spill; Time in spill [ms]; X [mm]; Y [mm]",
00092 8000,-50, 79950, 32,-14.5,15.5, 32,-14.5,15.5 );
00093 AddHistogram( hHit2DvsMilliSecondsInSpill, path );
00094 }
00095
00096 uFirstMbsTime = 0;
00097 uSpillStartMbsTime = 0;
00098 uLastMbsTime = 0;
00099
00100 uFirstMbsTimeMs = 0;
00101 uSpillStartMbsTimeMs = 0;
00102 }
00103
00104 TString path = GetName();
00105 path += "/";
00106 path += GetName();
00107 hTimeEpicsUpdates = MakeTH1('I', path+"_TimeEpicsUpdate","Timing of epics updates; Time [s]",
00108 7200, 0, 7200);
00109 uEpicsTimeOrigin = 0;
00110
00111
00112 fflush ( stdout);
00113 }
00114
00115 TRootConverterProc::~TRootConverterProc()
00116 {
00117 if( (1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay)
00118 && 0 != cleanTree )
00119 {
00120 if( 1 == fRootConvPar->uRootDisplay )
00121 TGo4Analysis::Instance()->RemoveTree(cleanTree);
00122 if( 1 == fRootConvPar->uCleanOuputEnable )
00123 {
00124 fRootOut->Write("");
00125 fRootOut->Close();
00126 }
00127
00128 if( 0 == fRootConvPar->uCleanOuputEnable )
00129 delete cleanTree;
00130
00131 if( 1 == fRootConvPar->uAddGet4DataInTree )
00132 {
00133 for( UInt_t uChannelTemp = 0; uChannelTemp < fRocPar->uNbFeets*8; uChannelTemp++)
00134 {
00135 (*vuHitNumber)[uChannelTemp] = 0;
00136 (*vuTime)[uChannelTemp].clear();
00137 (*vuEpochTime)[uChannelTemp].clear();
00138 (*viTot)[uChannelTemp].clear();
00139 }
00140
00141 delete vuHitNumber;
00142 delete vuTime;
00143 delete vuEpochTime;
00144 delete viTot;
00145 }
00146
00147 if( 1 == fRootConvPar->uSlowControlInTree )
00148 {
00149 vdPositiveHvI.clear();
00150 vdPositiveHvU.clear();
00151 vdNegativeHvI.clear();
00152 vdNegativeHvU.clear();
00153 }
00154
00155
00156
00157 }
00158
00159 cout << "**** TRootConverterProc: Delete instance " << endl;
00160 }
00161
00162
00163 void TRootConverterProc::InitEvent(TGo4EventElement* outevnt)
00164 {
00165
00166
00167
00168 if(fRpcInputEvent==0 || (0==fHodoInputEvent && 1 == fRootConvPar->uHodoInputInTree) )
00169 {
00170 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00171
00172 if(btevent)
00173 {
00174 fRpcInputEvent=dynamic_cast<TRPCEvent*>(btevent->GetSubEvent("RPC"));
00175 fBeamEvent=dynamic_cast<TBeamMonitorEvent*>(btevent->GetSubEvent("BEAM"));
00176 if( 1 == fRootConvPar->uHodoInputInTree )
00177 fHodoInputEvent=dynamic_cast<TFiberHodEvent*>(btevent->GetSubEvent("Hodo1"));
00178 }
00179
00180 if(fRpcInputEvent==0) {
00181 GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event has no TRPCEvent!!! STOP GO4");
00182 }
00183 if(0==fHodoInputEvent && 1 == fRootConvPar->uHodoInputInTree) {
00184 GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: input event has no TFiberHodEvent!!! STOP GO4");
00185 }
00186 }
00187
00188
00189
00190
00191 if( kFALSE == fRocPar->noTrigger && ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) )
00192 {
00193 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Detector"));
00194 if(fCrateInputEvent==0)
00195 {
00196 if(btevent)
00197 {
00198 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00199 }
00200
00201 if(fCrateInputEvent==0) {
00202 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: input event is/has not a TMbsCrateEvent!!! STOP GO4");
00203 }
00204 }
00205 if( 1 == fRootConvPar->uTriglogInputInTree )
00206 {
00207 if(fTriglogInputEvent==0)
00208 {
00209
00210 if(btevent)
00211 {
00212 fTriglogInputEvent=dynamic_cast<TTriglogEvent*>(btevent->GetSubEvent("TRIGLOG"));
00213 }
00214
00215 if(fTriglogInputEvent==0) {
00216 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: input event is/has not a TTriglogEvent!!! STOP GO4");
00217 }
00218 }
00219 }
00220 if( 1 == fRootConvPar->uSlowControlInTree )
00221 {
00222 if(fEpicsInputEvent==0)
00223 {
00224 if(btevent)
00225 {
00226 fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00227 }
00228
00229 if(fEpicsInputEvent==0) {
00230 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: input event is/has not a TEpicsEvent!!! STOP GO4");
00231 }
00232 }
00233 }
00234 }
00235 else if( 1 == fRootConvPar->uSlowControlInTree )
00236 {
00237 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent("Detector"));
00238 if(fEpicsInputEvent==0)
00239 {
00240 if(btevent)
00241 {
00242 fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00243 }
00244
00245 if(fEpicsInputEvent==0) {
00246 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: input event is/has not a TEpicsEvent!!! STOP GO4");
00247 }
00248 }
00249 }
00250
00251
00252
00253
00254 if(fOutputEvent==0)
00255 {
00256 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00257 if(btevent)
00258 {
00259 fOutputEvent=dynamic_cast<TRootConverterEvent*>(btevent->GetSubEvent("ROOTCONV"));
00260 }
00261 else
00262 {
00263
00264 fOutputEvent= dynamic_cast<TRootConverterEvent*>(outevnt);
00265 }
00266 if(fOutputEvent==0) {
00267 GO4_STOP_ANALYSIS_MESSAGE("**** TRootConverterProc: Fatal error: output event is not a TRootConverterEvent!!! STOP GO4");
00268 }
00269
00270 }
00271
00272
00273 if( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay)
00274 {
00275 if( 0 == cleanTree)
00276 {
00277 TGo4Log::Info("**** TRootConverter: Create tree ");
00278
00279 if( 1 == fRootConvPar->uCleanOuputEnable )
00280 {
00281 oldDir = gDirectory;
00282
00283 sOutputFilename = fRootConvPar->sOutputFilename;
00284 fRootOut= new TFile(sOutputFilename, "RECREATE", "TTree file from GET4 and CAEN v1290", 9);
00285 sOutputFilename += ":/";
00286 if (fRootOut->IsZombie()) {
00287 cout << "Error opening file for TTree output in TRootConverter" << endl;
00288 }
00289
00290 gDirectory->Cd(sOutputFilename);
00291 }
00292
00293 if( 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ) )
00294 {
00295 cleanTree = new TTree("CosyRpc", "RPC Caen and Get4");
00296 TGo4Log::Info("RPC Tree created in %s", gDirectory->GetPath());
00297 }
00298 else
00299 {
00300 cleanTree = TGo4Analysis::Instance()->GetTree( "CosyRpc" );
00301 TGo4Log::Info("RPC Tree recovered from Go4");
00302 }
00303
00304
00305 cleanTree->SetAutoFlush(0);
00306
00307
00308 if( kFALSE == fRocPar->noTrigger )
00309 {
00310 if( -1 != fRootConvPar->iPmtTdc && -1 != fRootConvPar->iPmtQdc )
00311 {
00312 cleanTree->Branch("PmtTdc_Leading", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).lead,
00313 Form("PmtTdc_Leading[%u]/I", T1290Data::NumChan ) );
00314 cleanTree->Branch("PmtTdc_Trailing", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).trail,
00315 Form("PmtTdc_Trailing[%u]/I", T1290Data::NumChan ) );
00316 cleanTree->Branch("PmtTdc_Leading_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).hit_lead,
00317 Form("PmtTdc_Leading_NbHit[%u]/I", T1290Data::NumChan ) );
00318 cleanTree->Branch("PmtTdc_Trailing_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).hit_trail,
00319 Form("PmtTdc_Trailing_NbHit[%u]/I", T1290Data::NumChan ) );
00320 cleanTree->Branch("PmtTdc_Leading_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).lead_multi,
00321 Form("PmtTdc_Leading_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00322 cleanTree->Branch("PmtTdc_Trailing_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iPmtTdc]).trail_multi,
00323 Form("PmtTdc_Trailing_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00324 cleanTree->Branch("PmtQdc", fCrateInputEvent->fData1182[fRootConvPar->iPmtQdc], Form("PmtQdc[%u]/s", NUM_1182_CH ) );
00325 }
00326 if( -1 != fRootConvPar->iRpcTdcLeading && -1 != fRootConvPar->iRpcTdcTrailing )
00327 {
00328 cleanTree->Branch("CaenRpc_Leading", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).lead,
00329 Form("CaenRpc_Leading[%u]/I", T1290Data::NumChan ) );
00330 cleanTree->Branch("CaenRpc_Trailing", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).trail,
00331 Form("CaenRpc_Trailing[%u]/I", T1290Data::NumChan ) );
00332 cleanTree->Branch("CaenRpc_Leading_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).hit_lead,
00333 Form("CaenRpc_Leading_NbHit[%u]/I", T1290Data::NumChan ) );
00334 cleanTree->Branch("CaenRpc_Trailing_NbHit", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).hit_trail,
00335 Form("CaenRpc_Trailing_NbHit[%u]/I", T1290Data::NumChan ) );
00336 cleanTree->Branch("CaenRpc_Leading_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcLeading]).lead_multi,
00337 Form("CaenRpc_Leading_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00338 cleanTree->Branch("CaenRpc_Trailing_multi", (fCrateInputEvent->fMtdc[fRootConvPar->iRpcTdcTrailing]).trail_multi,
00339 Form("CaenRpc_Trailing_multi[%u][%u]/I", T1290Data::NumChan, T1290Data::MaxHits ) );
00340 }
00341 if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel1 )
00342 {
00343 cleanTree->Branch("CaenRef1_Leading",
00344 &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).lead[fRootConvPar->iReferenceChannel1]),
00345 "CaenRef1_Leading/I" );
00346 cleanTree->Branch("CaenRef1_Trailing",
00347 &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).trail[fRootConvPar->iReferenceChannel1]),
00348 "CaenRef1_Trailing/I" );
00349 }
00350 if( -1 != fRootConvPar->iReferenceTdc && -1 != fRootConvPar->iReferenceChannel2 )
00351 {
00352 cleanTree->Branch("CaenRef2_Leading",
00353 &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).lead[fRootConvPar->iReferenceChannel2]),
00354 "CaenRef2_Leading/I" );
00355 cleanTree->Branch("CaenRef2_Trailing",
00356 &((fCrateInputEvent->fMtdc[fRootConvPar->iReferenceTdc]).trail[fRootConvPar->iReferenceChannel2]),
00357 "CaenRef2_Trailing/I" );
00358 }
00359
00360 if( 1 == fRootConvPar->uTriglogInputInTree)
00361 {
00362 cleanTree->Branch("TriglogSyncNb", &(fTriglogInputEvent->fVulomSyncNumber),
00363 "TriglogSyncNb/i" );
00364 cleanTree->Branch("TriglogPattern", &(fTriglogInputEvent->fVulomTriggerPattern),
00365 "TriglogPattern/i" );
00366 cleanTree->Branch("TriglogTimeSec", &(fTriglogInputEvent->fMbsTimeSecs),
00367 "TriglogTimeSec/i" );
00368 cleanTree->Branch("TriglogTimeMilsec", &(fTriglogInputEvent->fMbsTimeMillisec),
00369 "TriglogTimeMilsec/i" );
00370 cleanTree->Branch("TriglogScalers1", (fTriglogInputEvent->fVulomScaler[0]),
00371 Form("TriglogScalers1[%u]/i", N_SCALERS_CH ) );
00372 cleanTree->Branch("TriglogScalers2", (fTriglogInputEvent->fVulomScaler[1]),
00373 Form("TriglogScalers2[%u]/i", N_SCALERS_CH ) );
00374 cleanTree->Branch("TriglogScalers3", (fTriglogInputEvent->fVulomScaler[2]),
00375 Form("TriglogScalers3[%u]/i", N_SCALERS_CH ) );
00376 }
00377 }
00378 if( 1 == fRootConvPar->uHodoInputInTree )
00379 {
00380 cleanTree->Branch("HodoscopeX", &(hitHodoscope.X),"HodoscopeX/D");
00381 cleanTree->Branch("HodoscopeY", &(hitHodoscope.Y),"HodoscopeY/D");
00382 }
00383
00384 if( 1 == fRootConvPar->uSlowControlInTree )
00385 {
00386 uSlowControlUpdateTime = 0;
00387 cleanTree->Branch( "TimeEpicsUpdate", &(uSlowControlUpdateTime),
00388 "TimeEpicsUpdate/i" );
00389 vdPositiveHvI.clear();
00390 vdPositiveHvU.clear();
00391 vdNegativeHvI.clear();
00392 vdNegativeHvU.clear();
00393 vdPositiveHvI.resize(fRootConvPar->uNbSlowControlChan);
00394 vdPositiveHvU.resize(fRootConvPar->uNbSlowControlChan);
00395 vdNegativeHvI.resize(fRootConvPar->uNbSlowControlChan);
00396 vdNegativeHvU.resize(fRootConvPar->uNbSlowControlChan);
00397 for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00398 {
00399 cleanTree->Branch( fRootConvPar->sScOutputNamePosI[uChannelHV], &(vdPositiveHvI.at(uChannelHV)),
00400 fRootConvPar->sScOutputNamePosI[uChannelHV] + Form("/D" ) );
00401 cleanTree->Branch( fRootConvPar->sScOutputNamePosU[uChannelHV], &(vdPositiveHvU.at(uChannelHV)),
00402 fRootConvPar->sScOutputNamePosU[uChannelHV] + Form("/D" ) );
00403 cleanTree->Branch( fRootConvPar->sScOutputNameNegI[uChannelHV], &(vdNegativeHvI.at(uChannelHV)),
00404 fRootConvPar->sScOutputNameNegI[uChannelHV] + Form("/D" ) );
00405 cleanTree->Branch( fRootConvPar->sScOutputNameNegU[uChannelHV], &(vdNegativeHvU.at(uChannelHV)),
00406 fRootConvPar->sScOutputNameNegU[uChannelHV] + Form("/D" ) );
00407 vdPositiveHvI.at(uChannelHV) = 0;
00408 vdPositiveHvU.at(uChannelHV) = 0;
00409 vdNegativeHvI.at(uChannelHV) = 0;
00410 vdNegativeHvU.at(uChannelHV) = 0;
00411 }
00412 }
00413
00414 if( 1 == fRootConvPar->uAddGet4DataInTree )
00415 {
00416
00417 vuHitNumber = new std::vector< UInt_t >;
00418 vuHitNumber->resize( fRocPar->uNbFeets*8 );
00419
00420 vuTime = new std::vector< std::vector< UInt_t > >;
00421 vuEpochTime = new std::vector< std::vector< UInt_t > >;
00422 viTot = new std::vector< std::vector< Int_t > >;
00423
00424 vuTime->resize( fRocPar->uNbFeets*8 );
00425 vuEpochTime->resize( fRocPar->uNbFeets*8 );
00426 viTot->resize( fRocPar->uNbFeets*8 );
00427
00428 for( UInt_t uChannelTemp = 0; uChannelTemp < fRocPar->uNbFeets*8; uChannelTemp++)
00429 {
00430 (*vuHitNumber)[uChannelTemp] = 0;
00431 (*vuTime)[uChannelTemp].clear();
00432 (*vuEpochTime)[uChannelTemp].clear();
00433 (*viTot)[uChannelTemp].clear();
00434 }
00435
00436 cleanTree->Bronch( "vuHitNumber", "std::vector< UInt_t >", &vuHitNumber );
00437 cleanTree->Bronch( "get4_time", "std::vector< std::vector< UInt_t > >", &(vuTime) );
00438 cleanTree->Bronch( "get4_epoch_time", "std::vector< std::vector< UInt_t > >", &(vuEpochTime) );
00439 cleanTree->Bronch( "get4_tot", "std::vector< std::vector< Int_t > >", &(viTot) );
00440 }
00441
00442 cleanTree->SetDirectory(gDirectory);
00443
00444 if( 1 == fRootConvPar->uRootDisplay && 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ))
00445 {
00446 TGo4Analysis::Instance()->AddTree(cleanTree );
00447 TGo4Log::Info("Root Tree registered in Go4: %p", TGo4Analysis::Instance()->GetTree( "CosyRpc" ) );
00448 }
00449 }
00450 }
00451 }
00452
00453
00454 void TRootConverterProc::FinalizeEvent()
00455 {
00456 if( 0 == fRootConvPar->uCleanOuputEnable && 0 == fRootConvPar->uRootDisplay)
00457 return;
00458
00459 if(!fCrateInputEvent->IsValid() ) return;
00460 if( 1 == fRootConvPar->uTriglogInputInTree )
00461 if( !fTriglogInputEvent->IsValid() )
00462 return;
00463
00464
00465
00466
00467 Bool_t bTestAllValid = kTRUE;
00468 for(Int_t iFeetRoc=0; iFeetRoc < (Int_t)fRocPar->uNbRocsGet4; iFeetRoc ++)
00469 {
00470 if( kFALSE == FillHitsFromRoc( ) )
00471 {
00472 bTestAllValid = kFALSE;
00473
00474 if( (1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) && 1 == fRootConvPar->uAddGet4DataInTree )
00475 {
00476 for( UInt_t uChannelTemp = 0; uChannelTemp < fRocPar->uNbFeets*8; uChannelTemp++)
00477 {
00478 (*vuHitNumber)[uChannelTemp] = 0;
00479 (*vuTime)[uChannelTemp].clear();
00480 (*vuEpochTime)[uChannelTemp].clear();
00481 (*viTot)[uChannelTemp].clear();
00482 }
00483 }
00484 }
00485 }
00486
00487 uNbEvents++;
00488
00489
00490 if( ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) )
00491 {
00492 if( 1 == fRootConvPar->uHodoInputInTree )
00493 {
00494 if( 1 == fRootConvPar->uHodoDebugHisto)
00495 hNbClustersPerEventHodoscope->Fill( fHodoInputEvent->NumHits() );
00496
00497 if( 0 < fHodoInputEvent->NumHits() )
00498 {
00499 hitHodoscope = fHodoInputEvent->Hit(0);
00500 if( 1 == fRootConvPar->uTriglogInputInTree && 1 == fRootConvPar->uHodoDebugHisto )
00501 {
00502 if( 0 == uFirstMbsTime)
00503 {
00504 uFirstMbsTime = fTriglogInputEvent->fMbsTimeSecs;
00505 uSpillStartMbsTime = fTriglogInputEvent->fMbsTimeSecs- uFirstMbsTime;
00506 uLastMbsTime = fTriglogInputEvent->fMbsTimeSecs;
00507
00508 uFirstMbsTimeMs = fTriglogInputEvent->fMbsTimeMillisec;
00509 uSpillStartMbsTimeMs = fTriglogInputEvent->fMbsTimeMillisec- uFirstMbsTimeMs;
00510 }
00511
00512 hHit2DvsSeconds->Fill( fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime,
00513 fHodoInputEvent->Hit(0).X, fHodoInputEvent->Hit(0).Y);
00514
00515 if( 20 < fTriglogInputEvent->fMbsTimeSecs - uLastMbsTime )
00516 {
00517 uSpillStartMbsTime = fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime;
00518 uSpillStartMbsTimeMs = fTriglogInputEvent->fMbsTimeMillisec - uFirstMbsTimeMs;
00519 }
00520
00521 hHit2DvsSecondsInSpill->Fill(
00522 fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime - uSpillStartMbsTime,
00523 fHodoInputEvent->Hit(0).X, fHodoInputEvent->Hit(0).Y);
00524
00525 hHit2DvsMilliSecondsInSpill->Fill(
00526 (fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime - uSpillStartMbsTime)*1000 +
00527 fTriglogInputEvent->fMbsTimeMillisec - uFirstMbsTimeMs - uSpillStartMbsTimeMs,
00528 fHodoInputEvent->Hit(0).X, fHodoInputEvent->Hit(0).Y);
00529
00530 hHitXvsMilliSecondsInSpill->Fill(
00531 (fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime - uSpillStartMbsTime)*1000 +
00532 fTriglogInputEvent->fMbsTimeMillisec - uFirstMbsTimeMs - uSpillStartMbsTimeMs,
00533 fHodoInputEvent->Hit(0).X );
00534 hHitYvsMilliSecondsInSpill->Fill(
00535 (fTriglogInputEvent->fMbsTimeSecs - uFirstMbsTime - uSpillStartMbsTime)*1000 +
00536 fTriglogInputEvent->fMbsTimeMillisec - uFirstMbsTimeMs - uSpillStartMbsTimeMs,
00537 fHodoInputEvent->Hit(0).Y );
00538
00539 uLastMbsTime = fTriglogInputEvent->fMbsTimeSecs;
00540
00541 }
00542 }
00543 }
00544
00545 if( 1 == fRootConvPar->uSlowControlInTree )
00546 {
00547 if( kTRUE == fEpicsInputEvent->IsValid() )
00548 {
00549 TString sVariableName = "";
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 if( 0 == uEpicsTimeOrigin )
00569 uEpicsTimeOrigin = fEpicsInputEvent->fUTimeSeconds;
00570
00571 hTimeEpicsUpdates->Fill( (fEpicsInputEvent->fUTimeSeconds )% 1000);
00572 uSlowControlUpdateTime = fEpicsInputEvent->fUTimeSeconds;
00573 for(UInt_t uEpicsVariableIndex = 0; uEpicsVariableIndex < fEpicsInputEvent->GetNumDoubles(); uEpicsVariableIndex++ )
00574 {
00575
00576 sVariableName = fEpicsInputEvent->GetDoubleName( uEpicsVariableIndex );
00577
00578 for( UInt_t uChannelHV = 0; uChannelHV < fRootConvPar->uNbSlowControlChan; uChannelHV++)
00579 {
00580 if( sVariableName == fRootConvPar->sScInputNamePosI[uChannelHV])
00581 {
00582
00583 vdPositiveHvI.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00584
00585 break;
00586 }
00587 if( sVariableName == fRootConvPar->sScInputNamePosU[uChannelHV])
00588 {
00589
00590 vdPositiveHvU.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00591
00592
00593 break;
00594 }
00595 if( sVariableName == fRootConvPar->sScInputNameNegI[uChannelHV])
00596 {
00597
00598 vdNegativeHvI.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00599
00600 break;
00601 }
00602 if( sVariableName == fRootConvPar->sScInputNameNegU[uChannelHV])
00603 {
00604
00605 vdNegativeHvU.at(uChannelHV) = fEpicsInputEvent->GetDouble(uEpicsVariableIndex);
00606
00607 break;
00608 }
00609 }
00610 }
00611
00612 }
00613 }
00614
00615 cleanTree->Fill();
00616 if( 1 == fRootConvPar->uAddGet4DataInTree )
00617 {
00618 for( UInt_t uChannelTemp = 0; uChannelTemp < fRocPar->uNbFeets*8; uChannelTemp++)
00619 {
00620 (*vuHitNumber)[uChannelTemp] = 0;
00621 (*vuTime)[uChannelTemp].clear();
00622 (*vuEpochTime)[uChannelTemp].clear();
00623 (*viTot)[uChannelTemp].clear();
00624 }
00625 }
00626 }
00627
00628 fOutputEvent->SetValid(kTRUE);
00629 }
00630
00631 Bool_t TRootConverterProc::FillHitsFromRoc()
00632 {
00633 TGet4HitUnpacked hitTemp;
00634
00635 for( Int_t iHitIndex = 0; iHitIndex < (Int_t)((fRpcInputEvent->fUnpackedHits).size()); iHitIndex ++)
00636 {
00637 hitTemp = (fRpcInputEvent->fUnpackedHits).at(iHitIndex);
00638
00639 if( ( 1 == fRootConvPar->uCleanOuputEnable || 1 == fRootConvPar->uRootDisplay) && 1 == fRootConvPar->uAddGet4DataInTree )
00640 {
00641 UInt_t uFullChan = hitTemp.GetFullChan();
00642 (*vuHitNumber)[uFullChan] ++;
00643 (*vuTime)[uFullChan].push_back( hitTemp.GetTsLeading() );
00644 (*vuEpochTime)[uFullChan].push_back( hitTemp.GetEpochLeading() );
00645 (*viTot)[uFullChan].push_back( hitTemp.GetRawTOT() );
00646 }
00647 }
00648
00649 return kTRUE;
00650 }