00001
00002
00003 #include "TSTSProc.h"
00004 #include "TCBMBeamtimeEvent.h"
00005 #include "TRocParam.h"
00006 #include "TSTSTopology.h"
00007
00008 #include "TGo4Version.h"
00009 #if __GO4BUILDVERSION__ > 40502
00010 #include "go4iostream.h"
00011 #else
00012 #include "Riostream.h"
00013 #endif
00014 #include "TSystem.h"
00015 #include "TGo4UserException.h"
00016
00017 #include "roc/Message.h"
00018 #include "roc/Board.h"
00019 #include <vector>
00020
00021
00022 TSTSProc::TSTSProc(const char* name) : TCBMBeamtimeProc(name),
00023 fRocInputEvent(0),
00024 fEpicsInputEvent(0),
00025 fOutputEvent(0)
00026
00027 {
00028 cout << "**** TSTSProc: Create instance " << name << endl;
00029
00030
00031
00032 fPar = (TSTSParam*) MakeParameter("STSPar", "TSTSParam");
00033
00034 fRocParam = dynamic_cast< TRocParam * >( GetParameter( "RocPar" ) );
00035 if( ! fRocParam ) {
00036 GO4_STOP_ANALYSIS_MESSAGE("**** TSTSProc: Error: RocPar parameter not found! check your setup! STOP GO4\n");
00037
00038 }
00039
00040
00041
00042 fRocMessageBuffer= new TRocEvent("STSbuffer",42);
00043 for(int n=0;n<MAX_ROC;++n)
00044 {
00045 fOffScanpoint[n]=kFALSE;
00046 fInScanpoint[n] =kFALSE;
00047 fNextScanId[n]=0;
00048 fEventClosed[n]=kFALSE;
00049 }
00050 fReplayBuffers=kFALSE;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 fLaserPosition=MakeTH2( 'I', "STS/LaserPosition", "Current laser table coordinates", 100, -50,50 , 100, -50, 50 );
00076 for(int n=0;n<MAX_ROC;++n)
00077 {
00078 char folder[30];
00079 sprintf(folder,"STS/ROC%u/",n);
00080 for(unsigned nx=0;nx<MAX_NX;nx++) {
00081
00082 char nxfolder[30], nxinfo[30];
00083 sprintf(nxfolder,"%sNX%u/Roc%u_nx%u_", folder, nx, n, nx);
00084 sprintf(nxinfo,"ROC = %u NXYTER = %u", n, nx);
00085
00086 fNxChannelVsLaserX[n][nx]=MakeTH2('I', Form("%schannels_LaserX", nxfolder), Form("Channels from %s vs laser X", nxinfo), 128, 0., 128.,100,-50,50, "ch","Xpos");
00087 fNxChannelVsLaserY[n][nx]=MakeTH2('I', Form("%schannels_LaserY", nxfolder), Form("Channels from %s vs laser Y", nxinfo), 128, 0., 128.,100,-50,50, "ch","Ypos");
00088 }
00089 }
00090
00091
00092 fSTSDigiPos.resize( fSTSTopology.GetNDetectors() );
00093 fSTSDigiPosLaserX.resize( fSTSTopology.GetNDetectors() );
00094 fSTSDigiPosLaserY.resize( fSTSTopology.GetNDetectors() );
00095 fSTSDigiAmp.resize( fSTSTopology.GetNDetectors() );
00096 fSTSDigiTime.resize( fSTSTopology.GetNDetectors() );
00097 fSTSDigiAmpVsPos.resize( fSTSTopology.GetNDetectors() );
00098 fSTSClustPos.resize( fSTSTopology.GetNDetectors() );
00099 fSTSClustAmp.resize( fSTSTopology.GetNDetectors() );
00100 fSTSClustAmpVsPos.resize( fSTSTopology.GetNDetectors() );
00101 fSTSClustAmpVsTime.resize( fSTSTopology.GetNDetectors() );
00102 fSTSHitXY.resize( fSTSTopology.GetNDetectors() );
00103 fSTSHitXYBinned.resize( fSTSTopology.GetNDetectors() );
00104 for( Int_t iDet=0; iDet < fSTSTopology.GetNDetectors(); iDet++) {
00105 fSTSDigiPos.at( iDet ).resize( fSTSTopology.GetNSides() );
00106 fSTSDigiAmp.at( iDet ).resize( fSTSTopology.GetNSides() );
00107 fSTSDigiTime.at( iDet ).resize( fSTSTopology.GetNSides() );
00108 fSTSDigiAmpVsPos.at( iDet ).resize( fSTSTopology.GetNSides() );
00109 fSTSDigiPosLaserX.at( iDet ).resize( fSTSTopology.GetNSides() );
00110 fSTSDigiPosLaserY.at( iDet ).resize( fSTSTopology.GetNSides() );
00111
00112
00113 fSTSDigiPos.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH1( 'D', Form( "STS/DigiPos%dp", iDet ), Form("Digi position on STS station %d, p-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ) );
00114 fSTSDigiPos.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH1( 'D', Form( "STS/DigiPos%dn", iDet ), Form("Digi position on STS station %d, n-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ) );
00115 fSTSDigiAmp.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH1( 'D', Form( "STS/DigiAmp%dp", iDet ), Form("Digi amplitude on STS station %d, p-side", iDet), 500, 0, 500 );
00116 fSTSDigiAmp.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH1( 'D', Form( "STS/DigiAmp%dn", iDet ), Form("Digi amplitude on STS station %d, n-side", iDet), 500, 0, 500 );
00117 fSTSDigiTime.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH1( 'D', Form( "STS/DigiTime%dp", iDet ), Form("Digi time w.r.t. trigger on STS station %d, p-side", iDet), 1000, -2000, 2000 );
00118 fSTSDigiTime.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH1( 'D', Form( "STS/DigiTime%dn", iDet ), Form("Digi time w.r.t. trigger on STS station %d, n-side", iDet), 1000, -2000, 2000 );
00119 fSTSDigiAmpVsPos.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH2( 'D', Form( "STS/DigiAmpVsPos%dp", iDet ), Form("Digi amplitude on STS station %d, p-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 125, 0, 500 );
00120 fSTSDigiAmpVsPos.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH2( 'D', Form( "STS/DigiAmpVsPos%dn", iDet ), Form("Digi amplitude on STS station %d, n-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 125, 0, 500 );
00121
00122 fSTSDigiPosLaserX.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH2( 'I', Form( "STS/DigiPosLaserX%dp", iDet ), Form("Digi position on STS station %d, p-side, vs Laser table X", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 100, -50, 50 );
00123 fSTSDigiPosLaserX.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH2( 'I', Form( "STS/DigiPosLaserX%dn", iDet ), Form("Digi position on STS station %d, n-side, vs Laser table X", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 100, -50, 50 );
00124 fSTSDigiPosLaserY.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH2( 'I', Form( "STS/DigiPosLaserY%dp", iDet ), Form("Digi position on STS station %d, p-side, vs Laser table Y", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 100, -50, 50 );
00125 fSTSDigiPosLaserY.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH2( 'I', Form( "STS/DigiPosLaserY%dn", iDet ), Form("Digi position on STS station %d, n-side, vs Laser table Y", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 100, -50, 50 );
00126
00127
00128
00129 fSTSClustPos.at( iDet ).resize( fSTSTopology.GetNSides() );
00130 fSTSClustAmp.at( iDet ).resize( fSTSTopology.GetNSides() );
00131 fSTSClustAmpVsPos.at( iDet ).resize( fSTSTopology.GetNSides() );
00132 fSTSClustAmpVsTime.at( iDet ).resize( fSTSTopology.GetNSides() );
00133
00134 fSTSClustPos.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH1( 'D', Form( "STS/ClustPos%dp", iDet ), Form("Cluster position on STS station %d, p-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ) );
00135 fSTSClustPos.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH1( 'D', Form( "STS/ClustPos%dn", iDet ), Form("Cluster position on STS station %d, n-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ) );
00136 fSTSClustAmp.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH1( 'D', Form( "STS/ClustAmp%dp", iDet ), Form("Cluster amplitude on STS station %d, p-side", iDet), 500, 0, 500 );
00137 fSTSClustAmp.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH1( 'D', Form( "STS/ClustAmp%dn", iDet ), Form("Cluster amplitude on STS station %d, n-side", iDet), 500, 0, 500 );
00138 fSTSClustAmpVsPos.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH2( 'D', Form( "STS/ClustAmpVsPos%dp", iDet ), Form("Cluster amplitude on STS station %d, p-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 125, 0, 500 );
00139 fSTSClustAmpVsPos.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH2( 'D', Form( "STS/ClustAmpVsPos%dn", iDet ), Form("Cluster amplitude on STS station %d, n-side", iDet), fSTSTopology.GetNStrips( iDet ), 0, fSTSTopology.GetNStrips( iDet ), 125, 0, 500 );
00140 fSTSClustAmpVsTime.at( iDet ).at( TSTSTopology::kPSide ) = MakeTH2( 'D', Form( "STS/ClustAmpVsTime%dp", iDet ), Form("Cluster amplitude vs. time w.r.t. trigger on STS station %d, p-side", iDet), 100, -1000, 1000, 100, 0, 500 );
00141 fSTSClustAmpVsTime.at( iDet ).at( TSTSTopology::kNSide ) = MakeTH2( 'D', Form( "STS/ClustAmpVsTime%dn", iDet ), Form("Cluster amplitude vs. time w.r.t. trigger on STS station %d, n-side", iDet), 100, -1000, 1000, 100, 0, 500 );
00142
00143
00144
00145
00146 fSTSHitXY.at( iDet ) = MakeTH2( 'D', Form("STS/HitXY%d", iDet), Form("Hit position in STS station %d", iDet), fSTSTopology.GetNStrips( iDet ), -6.4, 6.4, fSTSTopology.GetNStrips( iDet ), -6.4, 6.4 );
00147 fSTSHitXY.at( iDet )->GetXaxis()->SetTitle( "X pos" );
00148 fSTSHitXY.at( iDet )->GetYaxis()->SetTitle( "Y pos" );
00149 fSTSHitXYBinned.at( iDet ) = MakeTH2( 'D', Form("STS/HitXYBinned%d", iDet), Form("Hit position in STS station (binned) %d", iDet), fSTSTopology.GetNStrips( iDet ) / 8, -6.4, 6.4, fSTSTopology.GetNStrips( iDet )/8, -6.4, 6.4 );
00150 fSTSHitXYBinned.at( iDet )->GetXaxis()->SetTitle( "X pos" );
00151 fSTSHitXYBinned.at( iDet )->GetYaxis()->SetTitle( "Y pos" );
00152 }
00153
00154 fClusterizers.resize( fSTSTopology.GetNDetectors() );
00155 fHiterizers.resize( fSTSTopology.GetNDetectors() );
00156 for( Int_t iDet=0; iDet<fSTSTopology.GetNDetectors(); iDet++) {
00157 fClusterizers.at( iDet ).resize( fSTSTopology.GetNSides() );
00158 fHiterizers.at( iDet ) = new TSTSHiterizer( iDet );
00159 for( Int_t iSide = 0; iSide < fSTSTopology.GetNSides(); iSide++ ) {
00160 fClusterizers.at( iDet ).at( iSide ) = new TSTSClusterizer( iDet, iSide );
00161 }
00162 }
00163
00164 if( fSTSTopology.GetNDetectors() == 3 ) {
00165 printf("In TSTSProc: clusterization space tolerance on STS01,p-side is set to 2!\n");
00166 fClusterizers.at( 1 ).at( TSTSTopology::kPSide )->SetSpaceTolerance( 2 );
00167 }
00168
00169 printf("STS Histograms created \n");
00170 fflush ( stdout);
00171
00172 }
00173
00174
00175
00176 TSTSProc::~TSTSProc()
00177 {
00178 for( Int_t iDet=0; iDet<fSTSTopology.GetNDetectors(); iDet++) {
00179 for( Int_t iSide = 0; iSide < fSTSTopology.GetNSides(); iSide++ ) {
00180 delete fClusterizers.at( iDet ).at( iSide );
00181 fClusterizers.at( iDet ).at( iSide ) = 0;
00182 }
00183 }
00184
00185 delete fRocMessageBuffer;
00186 }
00187
00188
00189
00190
00191 void TSTSProc::FinalizeEvent()
00192 {
00193
00194
00195
00196 if(fEpicsInputEvent && fEpicsInputEvent->IsValid())
00197 {
00198
00199 printf(" ------ TSTSProc found new epics input event!\n");
00200 fEpicsInputEvent->PrintEvent();
00201 cout << ""<< endl;
00202 Long64_t id=fEpicsInputEvent->GetLong("CBM:TABLE:run");
00203 Double_t x=fEpicsInputEvent->GetDouble("CBM:TABLE:xpos");
00204 Double_t y=fEpicsInputEvent->GetDouble("CBM:TABLE:ypos");
00205 Double_t u=fEpicsInputEvent->GetDouble("CBM:KEITHLEY0:GETVOLTS");
00206 UInt_t t=fEpicsInputEvent->GetUpdateTimeSeconds();
00207 if(id==0)
00208 {
00209
00210 }
00211 else
00212 {
00213 fLaserSetupBuffer.push_back(TSTSEvent::lasersetup_t(id,x,y,u,t));
00214 }
00215 }
00216
00217
00218
00219
00220 if(!fRocInputEvent->IsValid())
00221 {
00222 cout <<"Skip incomplete input event---" << endl;
00223 return;
00224 }
00225
00226 if(AllRocsHaveEventClosed())
00227 {
00228
00229 if(fOutputEvent->GetLaserSetup().ScanId!=0)
00230 printf(" ------ TSTSProc provides cleared output event after scan :%d. \n",
00231 fOutputEvent->GetLaserSetup().ScanId);
00232 fOutputEvent->SetValid(kFALSE);
00233 if(fFullOutputEvent) fFullOutputEvent->SetValid(kFALSE);
00234 fOutputEvent->ClearLaserSetup();
00235 for(int rid=0; rid<MAX_ROC;++rid) {
00236 fNextScanId[rid]=0;
00237 fEventClosed[rid]=kFALSE;
00238 }
00239 fReplayBuffers=kTRUE;
00240
00241
00242 }
00243
00244
00245
00246
00247
00248
00249
00250 for( Int_t rocId = 0; rocId < fSTSTopology.GetRocArrSize(); rocId++) {
00251 if( fSTSTopology.IsValidRoc( rocId ) ) {
00252 TRocData* theRoc=dynamic_cast<TRocData*>(fRocInputEvent->getEventElement(rocId));
00253 if(theRoc==0) continue;
00254 TRocData* bufferRoc=dynamic_cast<TRocData*>(fRocMessageBuffer->getEventElement(rocId));
00255 if(bufferRoc==0)
00256 {
00257 GO4_STOP_ANALYSIS_MESSAGE("**** TSTSProc: NEVER COME HERE: ROC buffer has no component for rocid %d, but input event has!!! STOP GO4",rocId);
00258 }
00259
00260
00261 if(fNextScanId[rocId])
00262 CheckScanSetup(fNextScanId[rocId],rocId);
00263
00264
00265
00266 if(fReplayBuffers)
00267 {
00268
00269
00270
00271 if(bufferRoc->fExtMessages.size())
00272 {
00273 printf(" ------ TSTSProc inserting %d old messages for rocid %d!\n",bufferRoc->fExtMessages.size(), rocId);
00274 theRoc->fExtMessages.insert (theRoc->fExtMessages.begin(),bufferRoc->fExtMessages.begin(),bufferRoc->fExtMessages.end());
00275 bufferRoc->fExtMessages.clear();
00276 cout << ""<< endl;
00277 }
00278 }
00279
00280 for (unsigned iMsg = 0; iMsg < theRoc->fExtMessages.size(); iMsg++) {
00281 TRocMessageExtended msg = theRoc->fExtMessages.at(iMsg);
00282
00283
00284
00285
00286 if (msg.GetMessageType() == roc::MSG_SYS) {
00287
00288 roc::Message rmsg = msg.GetRocMessage();
00289
00290 if (rmsg.getSysMesType() == roc::SYSMSG_USER) {
00291 uint32_t value = rmsg.getSysMesData() - LASERSCANIDOFF;
00292
00293
00294
00295
00296 if(value==0 && !fInScanpoint[rocId])
00297 bufferRoc->fExtMessages.push_back(msg);
00298
00299 CheckScanSetup(value,rocId);
00300
00301 }
00302 }
00303
00304 if(fOffScanpoint[rocId]) continue;
00305 if(!fInScanpoint[rocId]){
00306
00307 bufferRoc->fExtMessages.push_back(msg);
00308 continue;
00309
00310
00311
00312 }
00313
00314
00315
00316 if(msg.GetMessageType() != roc::MSG_HIT) continue;
00317 ProcessValidMessage(msg);
00318
00319 }
00320 }
00321 }
00322
00323
00324 fReplayBuffers=kFALSE;
00325
00326
00327
00328
00329
00330
00331
00332
00333 }
00334
00335
00336
00337 Bool_t TSTSProc::CheckScanSetup( uint32_t value , Int_t rocId)
00338 {
00339
00340 if (value == 0) {
00341
00342 if(fInScanpoint[rocId]) fEventClosed[rocId] = kTRUE;
00343 fOffScanpoint[rocId] = kTRUE;
00344 fInScanpoint[rocId] = kFALSE;
00345
00346 } else {
00347
00348
00349 uint32_t currentscan=fOutputEvent->GetLaserSetup().ScanId;
00350 if (currentscan) {
00351
00352 if (currentscan == value) {
00353
00354 if(!fInScanpoint[rocId]) {
00355 printf(" ------ TSTSProc set current scan %d for rocid %d\n",
00356 currentscan,rocId);cout << ""<< endl;
00357 }
00358 fInScanpoint[rocId] = kTRUE;
00359 fOffScanpoint[rocId] = kFALSE;
00360 } else if(currentscan> value){
00361
00362 fInScanpoint[rocId] = kFALSE;
00363 fOffScanpoint[rocId] = kTRUE;
00364 printf(" ------ TSTSProc never come here: data in rocid:%d belongs to old scanid %d, but current scanid:%d, ignored! \n",
00365 rocId, value,currentscan); cout << ""<< endl;
00366 } else {
00367
00368 fInScanpoint[rocId] = kFALSE;
00369 fOffScanpoint[rocId] = kFALSE;
00370
00371
00372 }
00373
00374 } else {
00375 fOffScanpoint[rocId] = kFALSE;
00376 fInScanpoint[rocId] = kFALSE;
00377
00378 for (unsigned epi = 0; epi < fLaserSetupBuffer.size();
00379 epi++) {
00380 TSTSEvent::lasersetup_t lset = fLaserSetupBuffer.at(
00381 epi);
00382 if (lset.ScanId == value) {
00383 printf(
00384 " ------ TSTSProc found current laser setup with id:%d for rocid %d\n",
00385 lset.ScanId, rocId); cout << ""<< endl;
00386 fOutputEvent->SetLaserSetup(lset);
00387 fLaserSetupBuffer.erase(
00388 fLaserSetupBuffer.begin() + epi);
00389 fInScanpoint[rocId] = kTRUE;
00390 fOffScanpoint[rocId] = kFALSE;
00391
00392 fLaserPosition->Fill(lset.Xpos, lset.Ypos);
00393 epi = -1;
00394
00395 } else if (lset.ScanId < value) {
00396 printf(
00397 " ------ TSTSProc NEVER COME HERE: removing old laser setup with id:%d\n",
00398 lset.ScanId); cout << ""<< endl;
00399 fLaserSetupBuffer.erase(
00400 fLaserSetupBuffer.begin() + epi);
00401 epi = -1;
00402 } else {
00403
00404
00405
00406
00407 }
00408 }
00409
00410 }
00411 }
00412
00413
00414 if(!fInScanpoint[rocId] && !fOffScanpoint[rocId] && fNextScanId[rocId]!=0)
00415 {
00416 fNextScanId[rocId]=value;
00417 }
00418
00419 if(AllRocsHaveEventClosed())
00420 {
00421 printf(" ------ TSTSProc sees that all rocs have finished current scanpoint , enable output event for scan :%d. \n",
00422 fOutputEvent->GetLaserSetup().ScanId);
00423 cout << endl;
00424 fOutputEvent->SetValid(kTRUE);
00425 if(fFullOutputEvent) fFullOutputEvent->SetValid(kTRUE);
00426 }
00427
00428
00429 return kTRUE;
00430 }
00431
00432
00433
00434 void TSTSProc::ProcessValidMessage( TRocMessageExtended& msg)
00435 {
00436
00437 #ifdef CLEARCLUSTERS
00438
00439 for( Int_t iDet=0; iDet<fSTSTopology.GetNDetectors(); iDet++) {
00440 fHiterizers.at( iDet )->Clear();
00441 for( Int_t iSide = 0; iSide < fSTSTopology.GetNSides(); iSide++ ) {
00442 fClusterizers.at( iDet ).at( iSide )->Clear();
00443 }
00444 }
00445 #endif
00446
00447
00448
00449
00450 Int_t rocId=msg.GetRocNumber();
00451 Int_t nxId=msg.GetNxNumber();
00452 Int_t nxChannel=msg.GetNxChNum();
00453 Float_t timedist=msg.GetTriggerDeltaT();
00454
00455 Double_t nxadc_corr=msg.GetCorrectedNxADC();
00456
00457
00458
00459
00460 fNxChannelVsLaserX[rocId][nxId]->Fill(nxChannel,fOutputEvent->GetLaserSetup().Xpos);
00461 fNxChannelVsLaserY[rocId][nxId]->Fill(nxChannel,fOutputEvent->GetLaserSetup().Ypos);
00462
00463
00464 Int_t det = fSTSTopology.GetDetector( rocId );
00465 TSTSTopology::ESTSSide side = fSTSTopology.GetSide( rocId );
00466 Int_t strip = fSTSTopology.GetStrip( rocId, nxId, nxChannel );
00467
00468 fSTSDigiPos.at( det ).at( side )->Fill( strip );
00469 fSTSDigiAmp.at( det ).at( side )->Fill( nxadc_corr );
00470 fSTSDigiTime.at( det ).at( side )->Fill( timedist );
00471 fSTSDigiAmpVsPos.at( det ).at( side )->Fill( strip, nxadc_corr );
00472
00473
00474 fSTSDigiPosLaserX.at( det ).at( side )->Fill( strip, fOutputEvent->GetLaserSetup().Xpos);
00475 fSTSDigiPosLaserY.at( det ).at( side )->Fill( strip, fOutputEvent->GetLaserSetup().Ypos);
00476
00477
00478 TSTSDigi digi( strip, msg.GetFullTime(), nxadc_corr );
00479
00480 if( ! fRocParam->ttriMode[rocId][nxId] || nxadc_corr >= fPar->fTtriGlobalThr ) {
00481 fClusterizers.at( det ).at( side )->FeedDigi( digi );
00482 }
00483
00484 fOutputEvent->AddDigi( det, side, digi );
00485 }
00486
00487 void TSTSProc::EvaluateHits()
00488 {
00489 printf(" ------ TSTSProc does EvaluateHits() before writing event... \n");
00490 cout << endl;
00491 for( Int_t iDet = 0; iDet < fSTSTopology.GetNDetectors(); iDet++ ) {
00492 for( Int_t iSide = 0; iSide < fSTSTopology.GetNSides(); iSide++ ) {
00493 TSTSCluster * clust = 0;
00494 while( ( clust = fClusterizers.at( iDet ).at( iSide )->FetchCluster( fRocParam->noTrigger ) ) != 0 ) {
00495 fSTSClustPos.at( iDet ).at( iSide )->Fill( clust->GetMainStrip() );
00496 fSTSClustAmp.at( iDet ).at( iSide )->Fill( clust->GetAmplitude() );
00497 fSTSClustAmpVsPos.at( iDet ).at( iSide )->Fill( clust->GetMainStrip(), clust->GetAmplitude() );
00498
00499 fHiterizers.at( iDet )->FeedCluster( clust, (TSTSTopology::ESTSSide) iSide );
00500
00501
00502 }
00503 }
00504 }
00505
00506 for( Int_t iDet = 0; iDet < fSTSTopology.GetNDetectors(); iDet++ ) {
00507 TSTSHit * hit = 0;
00508 while( ( hit = fHiterizers.at( iDet )->FetchHit( fRocParam->noTrigger ) ) ) {
00509
00510 TSpacepoint point;
00511 fSTSGeometry.MakeSpacepoint( hit, iDet, point );
00512 delete hit;
00513 hit = 0;
00514
00515 fSTSHitXY.at( iDet )->Fill( point.GetX(), point.GetY() );
00516 fSTSHitXYBinned.at( iDet )->Fill( point.GetX(), point.GetY() );
00517 fOutputEvent->AddPoint( iDet, point );
00518 }
00519 }
00520 }
00521
00522
00523
00524 void TSTSProc::InitEvent(TGo4EventElement* outevnt)
00525 {
00526
00527
00528
00529 if(fRocInputEvent==0)
00530 {
00531 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00532 if(btevent)
00533 {
00534 fRocInputEvent=dynamic_cast<TRocEvent*>(btevent->GetSubEvent("ROC"));
00535 fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00536
00537 }
00538 else
00539 {
00540 fRocInputEvent=dynamic_cast<TRocEvent*>(GetInputEvent());
00541
00542 }
00543 if(fRocInputEvent==0) {
00544 GO4_STOP_ANALYSIS_MESSAGE("**** TSTSProc: Fatal error: input event is not a TRocEvent!!! STOP GO4");
00545 }
00546
00547 if(fEpicsInputEvent==0) {
00548 Message(2,"**** TSTSProc: could not find TEpicsEvent!");
00549 }
00550
00551 }
00552
00553
00554
00555
00556 if(fOutputEvent==0)
00557 {
00558 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00559 if(btevent)
00560 {
00561 fOutputEvent=dynamic_cast<TSTSEvent*>(btevent->GetSubEvent("STS"));
00562 fFullOutputEvent=btevent;
00563 }
00564 else
00565 {
00566
00567 fOutputEvent= dynamic_cast<TSTSEvent*>(outevnt);
00568 }
00569 if(fOutputEvent==0) {
00570 GO4_STOP_ANALYSIS_MESSAGE("**** TSTSProc: Fatal error: output event is not a TSTSEvent!!! STOP GO4");
00571 }
00572
00573
00574 fOutputEvent->SetValid(kFALSE);
00575 if(fFullOutputEvent) fFullOutputEvent->SetValid(kFALSE);
00576
00577 }
00578
00579 }
00580