@@ -285,6 +285,66 @@ Int_t StTpcRTSHitMaker::InitRun(Int_t runnumber) {
285285 }
286286#endif /* __TFG__VERSION__ */
287287 PrintAttr ();
288+
289+ // ////////////////////////////////////
290+ // XD: restore hit occupancy protection code to avoid long-hung of production jobs
291+ // ////////////////////////////////////
292+ // Prepare scaled hit maxima
293+ // No hit maxima if these DB params are 0
294+ Int_t maxHitsPerSector = St_tpcMaxHitsC::instance ()->maxSectorHits ();
295+ Int_t maxBinZeroHits = St_tpcMaxHitsC::instance ()->maxBinZeroHits ();
296+ if ( !(maxHitsPerSector > 0 || maxBinZeroHits > 0 ) ) return kStOK ;
297+ Int_t livePads = 0 ;
298+ Int_t totalPads = 0 ;
299+ Float_t liveFrac = 1 ;
300+ for (Int_t sector=1 ;sector<=24 ;sector++) {
301+ Int_t liveSecPads = 0 ;
302+ Int_t totalSecPads = 0 ;
303+
304+ // Tpx
305+ Int_t rowMin = 1 ;
306+ if (St_tpcPadConfigC::instance ()->iTPC (sector)) rowMin = 14 ;
307+ for (Int_t row = rowMin; row <= 45 ; row++) {
308+ Int_t Npads = St_tpcPadPlanesC::instance ()->padsPerRow (row);
309+ totalSecPads += Npads;
310+ if (StDetectorDbTpcRDOMasks::instance ()->isRowOn (sector,row) &&
311+ St_tpcAnodeHVavgC::instance ()->livePadrow (sector,row))
312+ liveSecPads += Npads;
313+ }
314+
315+ // iTPC
316+ if (St_tpcPadConfigC::instance ()->iTPC (sector)) {
317+ for (Int_t row = 1 ; row <= 40 ; row++) {
318+ Int_t Npads = St_itpcPadPlanesC::instance ()->padsPerRow (row);
319+ totalSecPads += Npads;
320+ if (StDetectorDbTpcRDOMasks::instance ()->isRowOn (sector,row) &&
321+ St_tpcAnodeHVavgC::instance ()->livePadrow (sector,row))
322+ liveSecPads += Npads;
323+ }
324+ }
325+
326+ livePads += liveSecPads;
327+ totalPads += totalSecPads;
328+ if (maxHitsPerSector > 0 ) {
329+ liveFrac = TMath::Max (0 .1f , ((Float_t) liveSecPads) / (1e-15f + (Float_t) totalSecPads));
330+ maxHits[sector-1 ] = (Int_t) (liveFrac * maxHitsPerSector);
331+ if (Debug ()) {LOG_INFO << " maxHits in sector " << sector << " = " << maxHits[sector-1 ] << endm;}
332+ } else {
333+ maxHits[sector-1 ] = 0 ;
334+ if (Debug ()) {LOG_INFO << " No maxHits in sector " << sector << endm;}
335+ }
336+ } // end for(sector)
337+ if (maxBinZeroHits > 0 ) {
338+ liveFrac = TMath::Max (0 .1f , ((Float_t) livePads) / (1e-15f + (Float_t) totalPads));
339+ maxBin0Hits = (Int_t) (liveFrac * maxBinZeroHits);
340+ if (Debug ()) {LOG_INFO << " maxBinZeroHits " << maxBin0Hits << endm;}
341+ } else {
342+ maxBin0Hits = 0 ;
343+ if (Debug ()) {LOG_INFO << " No maxBinZeroHits" << endm;}
344+ }
345+ // ///////
346+ // ///////
347+
288348 return kStOK ;
289349}
290350// ________________________________________________________________________________
0 commit comments