00001
00002
00003 #include "TRPCProc.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 #include "roc/Message.h"
00014 #include "roc/Board.h"
00015
00016 #include "TH1.h"
00017 #include "TH2.h"
00018 #include "TProfile.h"
00019
00020 #include "TGo4Analysis.h"
00021
00022 #include <algorithm>
00023
00024
00025 TRPCProc::TRPCProc(const char* name) :
00026 TCBMBeamtimeProc(name),
00027 fRocInputEvent(0),
00028 fCrateInputEvent(0),
00029 fOutputEvent(0),
00030 fBeamEvent(0),
00031 cleanTree(0)
00032 {
00033 TGo4Log::Info("**** TRPCProc: Create instance %s");
00034
00035 fRocPar = (TRocParam*) GetParameter("RocPar");
00036 cout << "ROCPAR = " << fRocPar << endl;
00037
00038 fRpcPar = (TRPCParam*) MakeParameter("RPCPar", "TRPCParam");
00039 cout << "RPCPAR = " << fRpcPar << endl;
00040
00041 if (fRocPar->numRocs > 0) fNumRocs = (UInt_t) fRocPar->numRocs;
00042
00043 for( UInt_t uChip = 0; uChip < 2*fRocPar->uNbFeets; uChip++ )
00044 FECHIP.push_back(TRpcRec());
00045
00046 Int_t iNbBinsRate = 87 ;
00047 Double_t dBinsRates[87+ 1] = { 0.1, 1, 2, 3, 4, 5, 6, 7, 8, 9,
00048 10, 20, 30, 40, 50, 60, 70, 80, 90,
00049 100, 200, 300, 400, 500, 600, 700, 800, 900,
00050 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 6000, 7000, 8000, 9000,
00051 10000, 15000, 20000, 25000, 30000, 40000, 50000, 60000, 70000, 80000, 90000,
00052 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000,
00053 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
00054 10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000,
00055 100000000, 200000000, 300000000, 400000000, 500000000,600000000, 700000000, 800000000, 900000000 };
00056
00057
00058 for( UInt_t uChip = 0; uChip < 2*fRocPar->uNbFeets; uChip++ )
00059 {
00060
00061
00062
00063 (FECHIP[uChip].uEpochStart).resize( fRocPar->uNbBuffers );
00064 (FECHIP[uChip].uCycleStart).resize( fRocPar->uNbBuffers );
00065 for( UInt_t uBuffer = 0; uBuffer < fRocPar->uNbBuffers; uBuffer ++)
00066 {
00067 (FECHIP[uChip].uEpochStart)[uBuffer] = 0;
00068 (FECHIP[uChip].uCycleStart)[uBuffer] = 0;
00069 }
00070
00071 TString sChipFolder = Form("Feet/Get4/Chip%u/",uChip);
00072 TString sChanFolder[NB_CHAN_GET4];
00073 for(Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00074 sChanFolder[iChan] = Form("Channel%d/",NB_CHAN_GET4*uChip + iChan);
00075
00076
00077 if( 1 == fRpcPar->uHitBuildingEnable )
00078 {
00079 FECHIP[uChip].fGet4MessValidEpochs = MakeTH1( 'I',
00080 sChipFolder + Form( "MessValidEpochs%d", uChip),
00081 Form( "Messages in Valid epochs (chips %d synched)", uChip ),
00082 501, -0.5, 500.5, "Mess Nb [1]", "Entries [1]" );
00083 }
00084
00085
00086 for(Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00087 {
00088 Int_t iFullChan = NB_CHAN_GET4*uChip + iChan;
00089
00090
00091 FECHIP[uChip].dInstantRateOld[iChan] = new Double_t[ fRpcPar->uNbHitMeanRate ];
00092 for( UInt_t hitIndex = 0; hitIndex<fRpcPar->uNbHitMeanRate; hitIndex++)
00093 FECHIP[uChip].dInstantRateOld[iChan][hitIndex] = 0.0;
00094
00095
00096 FECHIP[uChip].fGet4FineTimeLE[iChan] = 0;
00097 FECHIP[uChip].fGet4FineTimeTE[iChan] = 0;
00098 FECHIP[uChip].fGet4LeDnl[iChan] = 0;
00099 FECHIP[uChip].fGet4LeDnlSum[iChan] = 0;
00100 FECHIP[uChip].fGet4TeDnl[iChan] = 0;
00101 FECHIP[uChip].fGet4TeDnlSum[iChan] = 0;
00102 FECHIP[uChip].fGet4TOT[iChan] = 0;
00103
00104 FECHIP[uChip].fGet4PulseSpacingClose[iChan]= 0;
00105 FECHIP[uChip].fGet4PulseSpacingMid[iChan] = 0;
00106 FECHIP[uChip].fGet4PulseSpacingFar[iChan] = 0;
00107 FECHIP[uChip].fGet4InstantRate[iChan] = 0;
00108
00109 FECHIP[uChip].fGet4RisEdgesNbEvol[iChan] = 0;
00110 FECHIP[uChip].fGet4FalEdgesNbEvol[iChan] = 0;
00111 FECHIP[uChip].fGet4HitsNbEvolution[iChan] = 0;
00112
00113 FECHIP[uChip].fNbConsecutiveLE[iChan] = 0;
00114 FECHIP[uChip].fNbConsecutiveTE[iChan] = 0;
00115
00116 if( 1 == fRpcPar->uHitBuildingEnable )
00117 {
00118 FECHIP[uChip].fGet4TOT[iChan] = MakeTH1( 'D',
00119 "Feet/Channels/"+ sChanFolder[iChan] + Form("TimeOverThreshold%d",iFullChan),
00120 Form( "Time over Threshold of Channel %d", iFullChan ),
00121 (Int_t)(fRpcPar->fTotSize*10), 0, fRpcPar->fTotSize - 0.1, "ToT [ns]", "Entries [1]" );
00122
00123 FECHIP[uChip].fGet4PulseSpacingClose[iChan] = MakeTH1( 'D',
00124 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/PulseSpacingClose%d", iFullChan),
00125 Form( "Pulse Spacing between Leading Edges of following Pulses Channel %d", iFullChan ),
00126 1000, 0, 99.9, "Pulse Spacing [ns]", "Entries [1]" );
00127
00128 if( 1 == fRocPar->uDebugHistoOn )
00129 {
00130 FECHIP[uChip].fGet4PulseSpacingMid[iChan] = MakeTH1( 'D',
00131 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/PulseSpacingMid%d", iFullChan),
00132 Form( "Pulse Spacing between Leading Edges of following Pulses Channel %d",
00133 iFullChan ),
00134 1000, 0, 99.9, "Pulse Spacing [us]", "Entries [1]" );
00135 FECHIP[uChip].fGet4PulseSpacingFar[iChan] = MakeTH1( 'D',
00136 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/PulseSpacingFar%d", iFullChan),
00137 Form( "Pulse Spacing between Leading Edges of following Pulses Channel %d",
00138 iFullChan ),
00139 1000, 0, 99.9, "Pulse Spacing [s]", "Entries [1]" );
00140
00141 FECHIP[uChip].fGet4FineTimeLE[iChan] = MakeTH1('I',
00142 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/FineTimeL%d", iFullChan),
00143 Form( "Nonlinearity Histogram of Channel %d Leading Edge",iFullChan),
00144 NB_BIN_GET4_FTS,-0.5, NB_BIN_GET4_FTS- 0.5, "Bin [1]","Entries [1]" );
00145
00146 FECHIP[uChip].fGet4FineTimeTE[iChan] = MakeTH1('I',
00147 "Feet/Channels/"+ sChanFolder[iChan] + Form("TrailingEdge/FineTimeT%d", iFullChan),
00148 Form( "Nonlinearity Histogram of Channel %d Trailing Edge",iFullChan),
00149 NB_BIN_GET4_FTS,-0.5, NB_BIN_GET4_FTS - 0.5, "Bin [1]","Entries [1]" );
00150
00151 FECHIP[uChip].fGet4LeDnl[iChan] = MakeTH1('I',
00152 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/DnlL%d", iFullChan),
00153 Form( "DNL of Channel %d Leading Edge",iFullChan),
00154 NB_BIN_GET4_FTS,-0.5,NB_BIN_GET4_FTS - 0.5, "Bin [1]","DNL offset [Bin]" );
00155 FECHIP[uChip].fGet4LeDnlSum[iChan] = MakeTH1('I',
00156 "Feet/Channels/"+ sChanFolder[iChan] + Form("LeadingEdge/DnlIntL%d", iFullChan),
00157 Form( "Dnl Sum of Channel %d Leading Edge",iFullChan),
00158 NB_BIN_GET4_FTS,-0.5,NB_BIN_GET4_FTS - 0.5, "Bin [1]","DNL Sum [Bin]" );
00159
00160 FECHIP[uChip].fGet4TeDnl[iChan] = MakeTH1('I',
00161 "Feet/Channels/"+ sChanFolder[iChan] + Form("TrailingEdge/DnlT%d", iFullChan),
00162 Form( "DNL of Channel %d Trailing Edge",iFullChan),
00163 NB_BIN_GET4_FTS,-0.5,NB_BIN_GET4_FTS - 0.5, "Bin [1]","DNL offset [Bin]" );
00164 FECHIP[uChip].fGet4TeDnlSum[iChan] = MakeTH1('I',
00165 "Feet/Channels/"+ sChanFolder[iChan] + Form("TrailingEdge/DnlIntT%d", iFullChan),
00166 Form( "DNL Sum of Channel %d Trailing Edge",iFullChan),
00167 NB_BIN_GET4_FTS,-0.5,NB_BIN_GET4_FTS - 0.5, "Bin [1]","DNL Sum [Bin]" );
00168
00169 FECHIP[uChip].fNbConsecutiveLE[iChan] = MakeTH1( 'I',
00170 "Feet/debug/"+ sChanFolder[iChan] + Form("ConsLE%d", iFullChan),
00171 Form( "Nb of consecutive Leading edges in Valid epochs (chips %d synched)", uChip ),
00172 15, 0.5, 15.5, "LE Nb [1]", "Entries [1]" );
00173 FECHIP[uChip].fNbConsecutiveTE[iChan] = MakeTH1( 'I',
00174 "Feet/debug/"+ sChanFolder[iChan] + Form("ConsTE%d", iFullChan),
00175 Form( "Nb of consecutive Leading edges in Valid epochs (chips %d synched)", uChip ),
00176 15, 0.5, 15.5, "TE Nb [1]", "Entries [1]" );
00177
00178
00179 FECHIP[uChip].fGet4RisEdgesNbEvol[iChan] = MakeTH1( 'I',
00180 "Feet/debug/"+ sChanFolder[iChan] + Form("RisingNbEvo%d", iFullChan),
00181 Form( "Nb of rising edges per cycle, channel %d ", iFullChan ),
00182 500, 0, 499, "Cycle []", "Edges [1]" );
00183 FECHIP[uChip].fGet4FalEdgesNbEvol[iChan] = MakeTH1( 'I',
00184 "Feet/debug/"+ sChanFolder[iChan] + Form("FallingNbEvo%d", iFullChan),
00185 Form( "Nb of falling edges per cycle, channel %d ", iFullChan ),
00186 500, 0, 499, "Cycle []", "Edges [1]" );
00187 }
00188 }
00189 if( 1 == fRpcPar->uBlockOrderingEnable )
00190 {
00191 FECHIP[uChip].fGet4InstantRate[iChan] = new TH2D( Form("Rate%d",iFullChan),
00192 Form( "Instantaneous rate on channel %d, averaged over %d hits; Rate [Hz]; Cycle []", iFullChan,
00193 fRpcPar->uNbHitMeanRate ), iNbBinsRate, &(dBinsRates[0]), 10, 0, 10 );
00194 AddHistogram(FECHIP[uChip].fGet4InstantRate[iChan], "Feet/Channels/"+ sChanFolder[iChan] );
00195
00196 if( 1 == fRocPar->uDebugHistoOn )
00197 {
00198 FECHIP[uChip].fGet4HitsNbEvolution[iChan] = MakeTH1( 'I',
00199 "Feet/debug/"+ sChanFolder[iChan] + Form("HitsNbEvo%d", iFullChan),
00200 Form( "Nb of matched hits per cycle, channel %d ", iFullChan ),
00201 500, 0, 499, "Cycle []", "Hits [1]" );
00202 }
00203
00204
00205 Int_t iFullChanSec = 0;
00206 for(Int_t iChanSec = iChan + 1; iChanSec < NB_CHAN_GET4; iChanSec++)
00207 {
00208 iFullChanSec = NB_CHAN_GET4*uChip + iChanSec;
00209
00210 FECHIP[uChip].fVGetTimeCorrelation.push_back(
00211 MakeTH1( 'D', Form( "Feet/Correlations/Chan%dChan%d/TimeDifference%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00212 Form( "Time Correlation Between Channel %d and Channel %d", iFullChan,iFullChanSec ),
00213 (Int_t)(4*fRpcPar->fCorrelationCheck), -1*fRpcPar->fCorrelationCheck, fRpcPar->fCorrelationCheck ,
00214 "Time Difference [ns]", "Entries [1]" ) );
00215 if( 1 == fRpcPar->uCorrelationHistoOn )
00216 {
00217 FECHIP[uChip].fVGetTotCorrelation.push_back(
00218 MakeTH2( 'D', Form( "Feet/Correlations/Chan%dChan%d/TotCorr%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00219 Form( "Tot Correlation Between Channel %d and Channel %d", iFullChan,iFullChanSec ),
00220 200, 0, 50, 200, 0, 50,
00221 "Tot 1 [ns]", "Tot 2 [ns]", "Entries [1]" ) );
00222 FECHIP[uChip].fVCheckCorrelation.push_back(
00223 MakeTH1( 'I', Form( "Feet/Correlations/Chan%dChan%d/Check%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00224 Form( "Nb of 3 chan Correlation when ok between Chan %d & Chan %d?", iFullChan,iFullChanSec ),
00225 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00226 "Channel []", "Entries [1]" ) );
00227 FECHIP[uChip].fVCheckCorrelation4.push_back(
00228 MakeTH2( 'I', Form( "Feet/Correlations/Chan%dChan%d/Check4ch%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00229 Form( "Nb of 4 chan Correlation when ok between Chan %d & Chan %d?", iFullChan,iFullChanSec ),
00230 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00231 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00232 "Channel []", "Channel []", "Entries [1]" ) );
00233 }
00234 }
00235
00236 for(Int_t iChipSec = uChip + 1; iChipSec < 2*(Int_t)fRocPar->uNbFeets; iChipSec++)
00237 {
00238 for(Int_t iChanSec = 0; iChanSec < NB_CHAN_GET4; iChanSec++)
00239 {
00240 iFullChanSec = NB_CHAN_GET4*iChipSec + iChanSec;
00241 FECHIP[uChip].fVGetTimeCorrelation.push_back(
00242 MakeTH1( 'D', Form( "Feet/Correlations/Chan%dChan%d/TimeDifference%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00243 Form( "Time Correlation Between Channel %d and Channel %d", iFullChan,iFullChanSec ),
00244 (Int_t)(4*fRpcPar->fCorrelationCheck), -1*fRpcPar->fCorrelationCheck, fRpcPar->fCorrelationCheck ,
00245 "Time Difference [ns]", "Entries [1]" ) );
00246
00247 if( 1 == fRpcPar->uTotCorrelationHistOn )
00248 {
00249 FECHIP[uChip].fVGetTotCorrelation.push_back(
00250 MakeTH2( 'D', Form( "Feet/Correlations/Chan%dChan%d/TotCorr%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00251 Form( "Tot Correlation Between Channel %d and Channel %d", iFullChan,iFullChanSec ),
00252 200, 0, 50, 200, 0, 50,
00253 "Tot 1 [ns]", "Tot 2 [ns]", "Entries [1]" ) );
00254 }
00255 if( 1 == fRpcPar->uCorrelationHistoOn )
00256 {
00257 FECHIP[uChip].fVCheckCorrelation.push_back(
00258 MakeTH1( 'I', Form( "Feet/Correlations/Chan%dChan%d/Check%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00259 Form( "Nb of 3 chan Correlation when ok between Chan %d & Chan %d?", iFullChan,iFullChanSec ),
00260 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00261 "Channel []", "Entries [1]" ) );
00262 FECHIP[uChip].fVCheckCorrelation4.push_back(
00263 MakeTH2( 'I', Form( "Feet/Correlations/Chan%dChan%d/Check4ch%d%d", iFullChan,iFullChanSec, iFullChan,iFullChanSec ),
00264 Form( "Nb of 4 chan Correlation when ok between Chan %d & Chan %d?", iFullChan,iFullChanSec ),
00265 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00266 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00267 "Channel []", "Channel []", "Entries [1]" ) );
00268 }
00269 }
00270 }
00271 }
00272 }
00273 }
00274
00275
00276 uNbEvents = 0;
00277
00278
00279
00280 v_HitUnpBlock.resize( fRocPar->uNbBuffers );
00281 for( UInt_t uBuffer = 0; uBuffer < fRocPar->uNbBuffers; uBuffer ++)
00282 v_HitUnpBlock[uBuffer].clear();
00283 lastHit.ClearHit();
00284 uBlockIndexLast = 0;
00285 uBlockIndex = 0;
00286
00287 uEpochLastBlock = 0;
00288 uLastEpochLastBlock = 0;
00289 uLastCycleLastBlock = 0;
00290
00291 uLastEpochMainClock = 0;
00292 uMainEpochCycle = 0;
00293
00294 uEpochBufferStart = 0 ;
00295 uCycleBufferStart = 0 ;
00296
00297 uCurrentBlockBuffer = 0;
00298
00299
00300 fGet4EdgeMessagePerEvent = MakeTH1('I', "Feet/GET4/EdgePerEvt", "Nb of accepted edge message per event",
00301 2000, -0.5, 2000 -0.5,
00302 "Nb accepted edge message [1]","Nb Events [1]");
00303
00304 if( 1 == fRpcPar->uHitBuildingEnable )
00305 {
00306 fGet4RisEdgesNb = MakeTH1('I', "Feet/Get4EdgesCount/RisingEdgesNb",
00307 "Number of Rising edges per channel",
00308 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00309 "Channel [1]", "Entries [1]" );
00310 fGet4FalEdgesNb = MakeTH1('I', "Feet/Get4EdgesCount/FallingEdgesNb",
00311 "Number of Falling edges per channel",
00312 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00313 "Channel [1]", "Entries [1]" );
00314 fGet4EdgesDiffEvol= MakeTH2('I', "Feet/Get4EdgesCount/EdgesDiffEvol",
00315 "diff ( nb falling - nb rising ) for each cycle/channel",
00316 500, 0, 500, fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00317 "Cycle []", "Chan []", "(Falling - Rising[1]" );
00318 fGet4RisEdgesEvol = MakeTH1('I', "Feet/Get4EdgesCount/RisingEdgesEvol",
00319 "Number of Rising edges per cycle",
00320 500, 0, 500, "Cycle []", "Edges [1]" );
00321 fGet4FalEdgesEvol = MakeTH1('I', "Feet/Get4EdgesCount/FallingEdgesEvol",
00322 "Number of Falling edges per cycle",
00323 500, 0, 500, "Cycle []", "Edges [1]" );
00324 fReconErrLE = MakeTH1( 'I', "Feet/Messages/ReconErrLE",
00325 "Reconstruction Errors on Leading Edge",
00326 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00327 "Channel [1]", "Entries [1]" );
00328
00329 fReconErrTE = MakeTH1( 'I', "Feet/Messages/ReconErrTE",
00330 "Reconstruction Errors on Trailing Edge",
00331 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00332 "Channel [1]", "Entries [1]" );
00333
00334 fReconErrNegToT = MakeTH1( 'I', "Feet/Messages/ReconErrNegToT",
00335 "Reconstruction Errors with Negative ToT",
00336 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00337 "Channel [1]", "Entries [1]" );
00338
00339 fReconErrTimeGate = MakeTH1( 'I', "Feet/Messages/ReconErrTimeGate",
00340 "Reconstruction Errors with too big ToT",
00341 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00342 "Channel [1]", "Entries [1]" );
00343 }
00344 if( 1 == fRpcPar->uBlockOrderingEnable )
00345 {
00346 fBeamProfileHDRPC = MakeTH2('D', "Feet/debug/BeamProfileHD",
00347 "Attempt to get beam profile for HDRPC, Strip map in option file",
00348 fRpcPar->iBeamProfileSize, -(fRpcPar->iBeamProfileSize/2.0) -0.5, (fRpcPar->iBeamProfileSize/2.0) -0.5,
00349 fRpcPar->uNbStrips, -((Double_t)fRpcPar->uNbStrips/2.0), ((Double_t)fRpcPar->uNbStrips/2.0),
00350 "Left right dt [cm]", "Strip index[cm]" );
00351
00352
00353 iIsPadChannelX = new Int_t[fRocPar->uNbFeets * 8];
00354 iIsPadChannelY = new Int_t[fRocPar->uNbFeets * 8];
00355 for(UInt_t uTempChan = 0; uTempChan < fRocPar->uNbFeets * 8; uTempChan++)
00356 {
00357 iIsPadChannelX[uTempChan] = -1;
00358 iIsPadChannelY[uTempChan] = -1;
00359 }
00360 for(UInt_t temp_Yindex = 0; temp_Yindex < fRpcPar->uNbPadsY; temp_Yindex++)
00361 for(UInt_t temp_Xindex = 0; temp_Xindex < fRpcPar->uNbPadsX; temp_Xindex++)
00362 if( fRpcPar->uPadsList[temp_Yindex][temp_Xindex] < fRocPar->uNbFeets * 8 )
00363 {
00364 iIsPadChannelX[ fRpcPar->uPadsList[temp_Yindex][temp_Xindex] ] = temp_Xindex;
00365 iIsPadChannelY[ fRpcPar->uPadsList[temp_Yindex][temp_Xindex] ] = temp_Yindex;
00366 }
00367 fBeamProfilePRPC = MakeTH2('D', "Feet/debug/BeamProfilePrpc",
00368 "Attempt to get beam profile for PRPC, Pad map in option file",
00369 fRpcPar->uNbPadsX, -(fRpcPar->uNbPadsX/2.0), (fRpcPar->uNbPadsX/2.0),
00370 fRpcPar->uNbPadsY, -((Double_t)fRpcPar->uNbPadsY/2.0), ((Double_t)fRpcPar->uNbPadsY/2.0),
00371 "X [cm]", "Y [cm]" );
00372
00373 fGet4HitsNb = MakeTH1('I', "Feet/Get4EdgesCount/HitsNb",
00374 "Number of matched Hits per channel",
00375 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00376 "Channel [1]", "Entries [1]" );
00377 fGet4HitsEvol = MakeTH1('I', "Feet/Get4EdgesCount/HitsEvol",
00378 "Number of matched Hits per cycle",
00379 500, 0, 500, "Cycle []", "Hits [1]" );
00380 fMapOrderErrors= MakeTH2( 'I', "Feet/Messages/MapOrderErrors",
00381 "Map of channels in time order errors",
00382 8*fRocPar->uNbFeets, -0.5, 8*fRocPar->uNbFeets-0.5, 8*fRocPar->uNbFeets, -0.5, 8*fRocPar->uNbFeets-0.5,
00383 "Chan1 []", "Chan2 []" );
00384 fMapOrderErrorsChips= MakeTH2( 'I', "Feet/Messages/MapOrderErrorsChips",
00385 "Map of chips in time order errors",
00386 2*fRocPar->uNbFeets, -0.5, 2*fRocPar->uNbFeets-0.5, 2*fRocPar->uNbFeets, -0.5, 2*fRocPar->uNbFeets-0.5,
00387 "Chip1 []", "Chip2 []" );
00388
00389 if( 1 == fRocPar->uDebugHistoOn )
00390 {
00391 fGet4IncompletHitsEvol = MakeTH1('I', "Feet/Get4EdgesCount/IncompHitsNb",
00392 "Number of incomplet Hits per channel",
00393 fRocPar->uNbFeets * 8, -0.5, fRocPar->uNbFeets * 8 - 0.5,
00394 "Channel [1]", "Hits [1]" );
00395 fGet4BlocksEvol = MakeTH1('I', "Feet/Get4EdgesCount/BlocksEvol",
00396 "Number of blocks analysed per cycle",
00397 500, 0, 500, "Cycle []", "Blocks [1]" );
00398 }
00399 }
00400
00401 printf("RPC Histograms created \n");
00402 fflush ( stdout);
00403 }
00404
00405 TRPCProc::~TRPCProc()
00406 {
00407 for( UInt_t uChip = 0; uChip < 2*fRocPar->uNbFeets; uChip++ )
00408 for(Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00409 {
00410 delete [] FECHIP[uChip].dInstantRateOld[iChan];
00411 FECHIP[uChip].dInstantRateOld[iChan] = 0;
00412 }
00413
00414
00415 delete [] iIsPadChannelX; iIsPadChannelX = 0;
00416 delete [] iIsPadChannelY; iIsPadChannelY = 0;
00417
00418
00419 if( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay)
00420 {
00421 if( 1 == fRpcPar->uCleanOuputEnable )
00422 {
00423 gDirectory->Cd(sOutputFilename);
00424
00425 cleanTree->SetDirectory(gDirectory);
00426
00427 fRootOut->Write("");
00428
00429 fRootOut->Close();
00430
00431 gDirectory->Cd(oldDir->GetPath());
00432 }
00433
00434 if( 1 == fRpcPar->uRootDisplay )
00435 TGo4Analysis::Instance()->RemoveTree(cleanTree);
00436
00437 if( 0 == fRpcPar->uCleanOuputEnable )
00438 delete cleanTree;
00439
00440 if( 1 == fRpcPar->uAddGet4DataInTree )
00441 {
00442 uHitNumber = 0;
00443 vuChannelId->clear();
00444 vuTime->clear();
00445 vuEpochTime->clear();
00446 viTot->clear();
00447
00448 delete vuChannelId;
00449 delete vuTime;
00450 delete vuEpochTime;
00451 delete viTot;
00452 }
00453 if( 1 == fRpcPar->uCleanOuputEnable )
00454 delete fRootOut;
00455 }
00456
00457
00458 Double_t offset = 0;
00459 TGo4Log::Info("********************************************************");
00460 for( UInt_t uBin = 0; uBin < fRpcPar->uNbStrips; uBin++)
00461 {
00462 offset = ( (TProfile*)fBeamProfileHDRPC->ProfileX(Form("_pfx%d", uBin), uBin+1, uBin+1) )->GetMean();
00463 TGo4Log::Info("Offset of HD strip %2u is %3.2f cm", uBin, offset);
00464 }
00465 TGo4Log::Info("********************************************************");
00466
00467 cout << "**** TRPCProc: Delete instance " << endl;
00468 }
00469
00470
00471 void TRPCProc::InitEvent(TGo4EventElement* outevnt)
00472 {
00473
00474
00475
00476 if(fRocInputEvent==0)
00477 {
00478 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00479 if(btevent)
00480 {
00481 fRocInputEvent=dynamic_cast<TRocEvent*>(btevent->GetSubEvent("ROC"));
00482 }
00483 else
00484 {
00485 fRocInputEvent=dynamic_cast<TRocEvent*>(GetInputEvent());
00486
00487 }
00488 if(fRocInputEvent==0) {
00489 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: input event is not a TRocEvent!!! STOP GO4");
00490 }
00491 }
00492
00493
00494
00495
00496 if( 0 == fRocPar->noTrigger)
00497 if(fCrateInputEvent==0)
00498 {
00499 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00500 if(btevent)
00501 {
00502 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00503 }
00504 else
00505 {
00506 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(GetInputEvent());
00507
00508 }
00509 if(fCrateInputEvent==0) {
00510 GO4_STOP_ANALYSIS_MESSAGE("**** TBucharestProc: Fatal error: input event is not a TMbsCrateEvent!!! STOP GO4");
00511 }
00512 }
00513
00514
00515
00516
00517 if(fOutputEvent==0)
00518 {
00519 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00520 if(btevent)
00521 {
00522 fOutputEvent=dynamic_cast<TRPCEvent*>(btevent->GetSubEvent("RPC"));
00523 fBeamEvent=dynamic_cast<TBeamMonitorEvent*>(btevent->GetSubEvent("BEAM"));
00524 }
00525 else
00526 {
00527
00528 fOutputEvent= dynamic_cast<TRPCEvent*>(outevnt);
00529 }
00530 if(fOutputEvent==0) {
00531 GO4_STOP_ANALYSIS_MESSAGE("**** TRPCProc: Fatal error: output event is not a TRPCEvent!!! STOP GO4");
00532 }
00533
00534 }
00535
00536
00537 if( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay)
00538 {
00539 if( 0 == cleanTree)
00540 {
00541 TGo4Log::Info("**** TRPCProc: Create tree ");
00542
00543 if( 1 == fRpcPar->uCleanOuputEnable )
00544 {
00545 oldDir = gDirectory;
00546
00547 sOutputFilename = fRpcPar->sOutputFilename;
00548 fRootOut= new TFile(sOutputFilename, "RECREATE", "TTree file from GET4 and CAEN v1290", 9);
00549 sOutputFilename += ":/";
00550
00551 gDirectory->Cd(sOutputFilename);
00552 }
00553
00554 if( 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ) )
00555 {
00556 cleanTree = new TTree("CosyRpc", "RPC Caen and Get4");
00557 TGo4Log::Info("RPC Tree created in %s", gDirectory->GetPath());
00558 }
00559 else
00560 {
00561 cleanTree = TGo4Analysis::Instance()->GetTree( "CosyRpc" );
00562 TGo4Log::Info("RPC Tree recovered from Go4");
00563 }
00564
00565
00566 if( kFALSE == fRocPar->noTrigger )
00567 {
00568 if( -1 != fRpcPar->iPmtTdc && -1 != fRpcPar->iPmtQdc )
00569 {
00570 cleanTree->Branch("PmtTdc_Leading", (fCrateInputEvent->fMtdc[fRpcPar->iPmtTdc]).lead,
00571 Form("PmtTdc_Leading[%u]/I", 32 ) );
00572 cleanTree->Branch("PmtTdc_Trailing", (fCrateInputEvent->fMtdc[fRpcPar->iPmtTdc]).trail,
00573 Form("PmtTdc_Trailing[%u]/I", 32 ) );
00574 cleanTree->Branch("PmtQdc", fCrateInputEvent->fData1182[fRpcPar->iPmtQdc], Form("PmtQdc[%u]/s", NUM_1182_CH ) );
00575 }
00576 if( -1 != fRpcPar->iRpcTdcLeading && -1 != fRpcPar->iRpcTdcTrailing )
00577 {
00578 cleanTree->Branch("CaenRpc_Leading", (fCrateInputEvent->fMtdc[fRpcPar->iRpcTdcLeading]).lead,
00579 Form("CaenRpc_Leading[%u]/I", 32 ) );
00580 cleanTree->Branch("CaenRpc_Trailing", (fCrateInputEvent->fMtdc[fRpcPar->iRpcTdcTrailing]).trail,
00581 Form("CaenRpc_Trailing[%u]/I", 32 ) );
00582 }
00583 if( -1 != fRpcPar->iReferenceTdc && -1 != fRpcPar->iReferenceChannel1 )
00584 {
00585 cleanTree->Branch("CaenRef1_Leading",
00586 &((fCrateInputEvent->fMtdc[fRpcPar->iReferenceTdc]).lead[fRpcPar->iReferenceChannel1]),
00587 "CaenRef1_Leading/I" );
00588 cleanTree->Branch("CaenRef1_Trailing",
00589 &((fCrateInputEvent->fMtdc[fRpcPar->iReferenceTdc]).trail[fRpcPar->iReferenceChannel1]),
00590 "CaenRef1_Trailing/I" );
00591 }
00592 if( -1 != fRpcPar->iReferenceTdc && -1 != fRpcPar->iReferenceChannel2 )
00593 {
00594 cleanTree->Branch("CaenRef2_Leading",
00595 &((fCrateInputEvent->fMtdc[fRpcPar->iReferenceTdc]).lead[fRpcPar->iReferenceChannel2]),
00596 "CaenRef2_Leading/I" );
00597 cleanTree->Branch("CaenRef2_Trailing",
00598 &((fCrateInputEvent->fMtdc[fRpcPar->iReferenceTdc]).trail[fRpcPar->iReferenceChannel2]),
00599 "CaenRef2_Trailing/I" );
00600 }
00601 }
00602
00603 if( 1 == fRpcPar->uAddGet4DataInTree )
00604 {
00605
00606 vuChannelId = new vector< UInt_t >;
00607 vuTime = new vector< UInt_t >;
00608 vuEpochTime = new vector< UInt_t >;
00609 viTot = new vector< Int_t >;
00610
00611 uHitNumber = 0;
00612 vuChannelId->clear();
00613 vuTime->clear();
00614 vuEpochTime->clear();
00615 viTot->clear();
00616
00617 cleanTree->Branch( "get4_uHitNumber", &uHitNumber );
00618 cleanTree->Bronch( "get4_channelId", "std::vector< UInt_t >", &(vuChannelId) );
00619 cleanTree->Bronch( "get4_time", "std::vector< UInt_t >", &(vuTime) );
00620 cleanTree->Bronch( "get4_epoch_time", "std::vector< UInt_t >", &(vuEpochTime) );
00621 cleanTree->Bronch( "get4_tot", "std::vector< Int_t >", &(viTot) );
00622 }
00623
00624 cleanTree->SetDirectory(gDirectory);
00625
00626 if( 1 == fRpcPar->uRootDisplay && 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ))
00627 {
00628 TGo4Analysis::Instance()->AddTree(cleanTree );
00629 TGo4Log::Info("RPC Tree registered in Go4: %p", TGo4Analysis::Instance()->GetTree( "CosyRpc" ) );
00630 }
00631 }
00632 }
00633
00634 }
00635
00636
00637 void TRPCProc::FinalizeEvent()
00638 {
00639 if(!fRocInputEvent->IsValid()) return;
00640
00641
00642
00643 if( 0 == dynamic_cast<TGo4MbsEvent*>(fRocInputEvent) )
00644 fMbsEventNumber = fRocInputEvent->fMbsEventNumber;
00645 if(uNbEvents == 0)
00646 {
00647 uFirstEventIndex = fMbsEventNumber;
00648 uPrevEventIndex = fMbsEventNumber;
00649
00650 for ( UInt_t uChip = 0; uChip < fRocPar->uNbFeets * 2; uChip++ )
00651 FECHIP[uChip].bFirstEpochBlock = kTRUE;
00652 }
00653 else
00654 {
00655 if( 0 < fRocPar->iEventNbGap &&
00656 (Int_t)uPrevEventIndex + fRocPar->iEventNbGap != fMbsEventNumber )
00657 Message(0, "***** TRPCProc Missing event in file: Event %d, Previous event index %d, Current event Index %d, expected %d",
00658 uNbEvents, uPrevEventIndex, GetEventNumber(), (Int_t)uPrevEventIndex + fRocPar->iEventNbGap);
00659 uPrevEventIndex = fMbsEventNumber;
00660 }
00661
00662 for(Int_t iFeetRoc=0; iFeetRoc < (Int_t)fRocPar->uNbRocsGet4; iFeetRoc ++)
00663 {
00664
00665 Int_t iFeetRocId= fRocPar->uFeetRocsMapping[iFeetRoc];
00666 TRocData* theRoc=dynamic_cast<TRocData*>(fRocInputEvent->getEventElement(iFeetRocId));
00667 if(theRoc==0) continue;
00668
00669 if( kFALSE == BuildHits( theRoc ) )
00670 {
00671 fOutputEvent->SetValid(kFALSE);
00672
00673 if( (1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) && 1 == fRpcPar->uAddGet4DataInTree )
00674 {
00675 uHitNumber = 0;
00676 vuChannelId->clear();
00677 vuTime->clear();
00678 vuEpochTime->clear();
00679 viTot->clear();
00680 }
00681
00682 return;
00683 }
00684 }
00685
00686 uNbEvents++;
00687
00688
00689 if( ( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) )
00690 {
00691 cleanTree->Fill();
00692 if( 1 == fRpcPar->uAddGet4DataInTree )
00693 {
00694 uHitNumber = 0;
00695 vuChannelId->clear();
00696 vuTime->clear();
00697 vuEpochTime->clear();
00698 viTot->clear();
00699 }
00700 }
00701
00702
00703 fOutputEvent->SetValid(kTRUE);
00704 }
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715 Bool_t TRPCProc::BuildHits( TRocData* rocEvent )
00716 {
00717 UInt_t uFirstActiveChip = fRocPar->uNbFeets*2 + 1;
00718
00719 if( kTRUE == fRocPar->noTrigger && 0 == (rocEvent->vMessageEventBuffer).size() )
00720 return kFALSE;
00721 else if( 0 == (rocEvent->fExtMessages).size() )
00722 return kFALSE;
00723
00724
00725 if( kTRUE == fRocPar->noTrigger )
00726 fGet4EdgeMessagePerEvent->Fill( (rocEvent->vMessageEventBuffer).size() );
00727 else fGet4EdgeMessagePerEvent->Fill( (rocEvent->fExtMessages).size() );
00728
00729
00730
00731 if( 0 == fRpcPar->uHitBuildingEnable )
00732 {
00733
00734
00735
00736 for(UInt_t uChip = 0; uChip < fRocPar->uNbFeets*2; uChip++)
00737 if( 1 == fRocPar->uGet4Active[uChip] )
00738 {
00739 if( uFirstActiveChip > fRocPar->uNbFeets*2)
00740 uFirstActiveChip = uChip;
00741 }
00742
00743
00744 if( fRocPar->uNbBuffers - 1 == uCurrentBlockBuffer)
00745 {
00746 if( kFALSE == TimeOrderBlock( 0 ) )
00747 return kFALSE;
00748 }
00749 else
00750 {
00751 if( kFALSE == TimeOrderBlock( uCurrentBlockBuffer + 1) )
00752 return kFALSE;
00753 }
00754
00755
00756 uLastEpochLastBlock = uCurrentEpoch2;
00757 uLastCycleLastBlock = uCurrentCycle2;
00758
00759
00760 uCurrentBlockBuffer = (uCurrentBlockBuffer + 1)%fRocPar->uNbBuffers;
00761
00762 return kTRUE;
00763 }
00764
00765 roc::Message storedData;
00766 UInt_t storedEpoch;
00767 UInt_t storedEpochCycle;
00768 UInt_t storedLocalEpoch;
00769 UInt_t storedLocalEpochCycle;
00770
00771
00772
00773 for(UInt_t uChip = 0; uChip < fRocPar->uNbFeets*2; uChip++)
00774 if( 1 == fRocPar->uGet4Active[uChip] && uFirstActiveChip > fRocPar->uNbFeets*2)
00775 uFirstActiveChip = uChip;
00776
00777 UInt_t epochLocalTemp = 0;
00778 UInt_t cycleLocalTemp = 0;
00779 UInt_t uPrevEpochTest = 0;
00780 UInt_t uPrevPrevEpochTest = 0;
00781
00782
00783
00784 UInt_t uBufferSize = 0;
00785 if( kTRUE == fRocPar->noTrigger )
00786 uBufferSize = (rocEvent->vMessageEventBuffer).size();
00787 else uBufferSize = (rocEvent->fExtMessages).size();
00788
00789 for( UInt_t uMessIndex = 0;
00790 uMessIndex <uBufferSize;
00791 uMessIndex++)
00792 {
00793 if( kTRUE == fRocPar->noTrigger )
00794 {
00795 storedData = ( (rocEvent->vMessageEventBuffer).at(uMessIndex) ).GetRocMessage();
00796 storedEpoch = ( (rocEvent->vMessageEventBuffer).at(uMessIndex) ).GetRocEpoch();
00797 storedEpochCycle = ( (rocEvent->vMessageEventBuffer).at(uMessIndex) ).GetRocCycle();
00798 storedLocalEpoch = ( (rocEvent->vMessageEventBuffer).at(uMessIndex) ).GetLocalEpoch();
00799 storedLocalEpochCycle = ( (rocEvent->vMessageEventBuffer).at(uMessIndex) ).GetLocalCycle();
00800 }
00801 else
00802 {
00803 storedData = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetRocMessage();
00804 if( kTRUE == fRocPar->NoGet4Cleaning)
00805 {
00806 storedEpoch = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetRocEpoch();
00807 storedEpochCycle = 0;
00808 storedLocalEpoch = 0;
00809 storedLocalEpochCycle = 0;
00810 }
00811 else
00812 {
00813 storedEpoch = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetRocEpoch();
00814 storedEpochCycle = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetRocCycle();
00815 storedLocalEpoch = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetLocalEpoch();
00816 storedLocalEpochCycle = ( (rocEvent->fExtMessages).at(uMessIndex) ).GetLocalCycle();
00817 }
00818 }
00819
00820 UInt_t typStored = storedData.getMessageType();
00821 if( typStored == roc::MSG_SYNC )
00822 {
00823 continue;
00824 }
00825
00826 if( kTRUE == fRocPar->noTrigger )
00827 {
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841 mLastFromBuffer = (rocEvent->vMessageEventBuffer).at(uMessIndex);
00842 }
00843
00844 if( 0 == uMessIndex )
00845 {
00846 if( 1 == fRocPar->uUseLocalEpochs)
00847 {
00848 uEpochBufferStart = storedLocalEpoch;
00849 uCycleBufferStart = storedLocalEpochCycle;
00850 }
00851 else
00852 {
00853 uEpochBufferStart = storedEpoch;
00854 uCycleBufferStart = storedEpochCycle;
00855 }
00856 }
00857
00858 if( typStored == roc::MSG_SYS )
00859 {
00860 TGet4HitUnpacked hitChipSync;
00861 hitChipSync.ClearHit();
00862 hitChipSync.SetFullChan( fRocPar->uNbFeets*8 );
00863 if( 1 == fRocPar->uUseLocalEpochs)
00864 hitChipSync.SetEpochLeading( storedLocalEpoch, storedLocalEpochCycle );
00865 else hitChipSync.SetEpochLeading( storedEpoch, storedEpochCycle );
00866 hitChipSync.SetTsLeading( (storedData.getField(23,12))<<7 );
00867 v_HitUnpBlock[ uCurrentBlockBuffer ].push_back( hitChipSync );
00868 uPrevPrevEpochTest = uPrevEpochTest;
00869 uPrevEpochTest = storedLocalEpoch;
00870 continue;
00871 }
00872 else if( typStored != roc::MSG_GET4 )
00873 {
00874 if( kTRUE == fRocPar->noTrigger )
00875 Message(3, "Error 2: this message is not a GET4 data: chip %2u type %2u, start ep. %7d cy. %7d Mess %5u/%5u local ep. %7d %7d %7d",
00876 uFirstActiveChip, typStored, epochLocalTemp, cycleLocalTemp, uMessIndex,
00877 (rocEvent->vMessageEventBuffer).size() - 1,
00878 storedLocalEpoch, uPrevEpochTest, uPrevPrevEpochTest);
00879 else Message(3, "Error 2: this message is not a GET4 data: chip %2u type %2u, start ep. %7d cy. %7d Mess %5u/%5u local ep. %7d %7d %7d",
00880 uFirstActiveChip, typStored, epochLocalTemp, cycleLocalTemp, uMessIndex,
00881 (rocEvent->fExtMessages).size() - 1,
00882 storedLocalEpoch, uPrevEpochTest, uPrevPrevEpochTest);
00883 storedData.printData(roc::msg_print_Hex, storedLocalEpoch);
00884 }
00885 uPrevPrevEpochTest = uPrevEpochTest;
00886 uPrevEpochTest = storedLocalEpoch;
00887
00888
00889 UInt_t uChipStored = storedData.getGet4Number();
00890
00891
00892
00893
00894
00895
00896 UInt_t uChannelStored = storedData.getGet4ChNum();
00897
00898 UInt_t uFullChannelStored = uChipStored * 4 + storedData.getGet4ChNum();
00899
00900
00901
00902 if ( uFullChannelStored >= 0 && uFullChannelStored < fRocPar->uNbFeets * 8 )
00903 {
00904
00905
00906 UInt_t uEdge = storedData.getGet4Edge();
00907
00908
00909 if ( uEdge == 0 )
00910 {
00911 fGet4RisEdgesNb->Fill( uFullChannelStored );
00912 if( 1 == fRocPar->uUseLocalEpochs)
00913 {
00914 fGet4EdgesDiffEvol->Fill( storedLocalEpochCycle, uFullChannelStored, -1);
00915 fGet4RisEdgesEvol->Fill( storedLocalEpochCycle);
00916 }
00917 else
00918 {
00919 fGet4EdgesDiffEvol->Fill( storedEpochCycle, uFullChannelStored, -1);
00920 fGet4RisEdgesEvol->Fill(storedEpochCycle);
00921 }
00922 if( 1 == fRocPar->uDebugHistoOn )
00923 {
00924 (FECHIP[uChipStored].fGet4FineTimeLE)[uChannelStored]->Fill( storedData.getGet4Ts() % NB_BIN_GET4_FTS);
00925 if( 1 == fRocPar->uUseLocalEpochs)
00926 (FECHIP[uChipStored].fGet4RisEdgesNbEvol[uChannelStored])->Fill(storedLocalEpochCycle);
00927 else (FECHIP[uChipStored].fGet4RisEdgesNbEvol[uChannelStored])->Fill(storedEpochCycle);
00928 (FECHIP[uChipStored].u_nbConsLE[uChannelStored])++;
00929 if( (FECHIP[uChipStored].u_nbConsTE[uChannelStored]) )
00930 {
00931 (FECHIP[uChipStored].fNbConsecutiveTE[uChannelStored])->Fill((FECHIP[uChipStored].u_nbConsTE[uChannelStored]));
00932 (FECHIP[uChipStored].u_nbConsTE[uChannelStored]) = 0;
00933 }
00934 }
00935 }
00936 else
00937 {
00938 fGet4FalEdgesNb->Fill( uFullChannelStored );
00939 if( 1 == fRocPar->uUseLocalEpochs)
00940 {
00941 fGet4EdgesDiffEvol->Fill( storedLocalEpochCycle, uFullChannelStored, 1);
00942 fGet4FalEdgesEvol->Fill( storedLocalEpochCycle);
00943 }
00944 else
00945 {
00946 fGet4EdgesDiffEvol->Fill( storedEpochCycle, uFullChannelStored, 1);
00947 fGet4FalEdgesEvol->Fill(storedEpochCycle);
00948 }
00949 if( 1 == fRocPar->uDebugHistoOn )
00950 {
00951 (FECHIP[uChipStored].fGet4FineTimeTE[uChannelStored])->Fill( storedData.getGet4Ts() % NB_BIN_GET4_FTS);
00952 if( 1 == fRocPar->uUseLocalEpochs)
00953 (FECHIP[uChipStored].fGet4FalEdgesNbEvol[uChannelStored])->Fill(storedLocalEpochCycle);
00954 else (FECHIP[uChipStored].fGet4FalEdgesNbEvol[uChannelStored])->Fill(storedEpochCycle);
00955 (FECHIP[uChipStored].u_nbConsTE[uChannelStored])++;
00956 if( (FECHIP[uChipStored].u_nbConsLE[uChannelStored]) )
00957 {
00958 (FECHIP[uChipStored].fNbConsecutiveLE[uChannelStored])->Fill((FECHIP[uChipStored].u_nbConsLE[uChannelStored]));
00959 (FECHIP[uChipStored].u_nbConsLE[uChannelStored]) = 0;
00960 }
00961 }
00962 }
00963
00964 try
00965 {
00966
00967
00968
00969
00970 if( 1 == fRocPar->uUseLocalEpochs)
00971 (FECHIP[uChipStored].hitCurrent[uChannelStored]).SetMessage( storedData,
00972 storedLocalEpoch, storedLocalEpochCycle );
00973 else (FECHIP[uChipStored].hitCurrent[uChannelStored]).SetMessage( storedData,
00974 storedEpoch, storedEpochCycle );
00975
00976
00977
00978 if ( (FECHIP[uChipStored].hitCurrent[uChannelStored]).Complete() )
00979 {
00980
00981
00982 (FECHIP[uChipStored].fGet4TOT[uChannelStored])->Fill(
00983 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTOT() );
00984
00985
00986
00987
00988 if ( (FECHIP[uChipStored].hitLatest[uChannelStored]).Complete() )
00989 {
00990 (FECHIP[uChipStored].fGet4PulseSpacingClose[uChannelStored])->Fill( (-1)*
00991 (FECHIP[uChipStored].hitCurrent[uChannelStored]).Spacing(FECHIP[uChipStored].hitLatest[uChannelStored]));
00992 if( 1 == fRocPar->uDebugHistoOn )
00993 {
00994 (FECHIP[uChipStored].fGet4PulseSpacingMid[uChannelStored])->Fill( (-0.001)*
00995 (FECHIP[uChipStored].hitCurrent[uChannelStored]).Spacing(FECHIP[uChipStored].hitLatest[uChannelStored]));
00996 (FECHIP[uChipStored].fGet4PulseSpacingFar[uChannelStored])->Fill( (-0.000000001)*
00997 (FECHIP[uChipStored].hitCurrent[uChannelStored]).Spacing(FECHIP[uChipStored].hitLatest[uChannelStored]));
00998 }
00999 }
01000
01001
01002
01003
01004
01005
01006 if( ((FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochLeading()
01007 < uEpochBufferStart &&
01008 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleLeading()
01009 == uCycleBufferStart) ||
01010 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleLeading()
01011 < uCycleBufferStart )
01012 {
01013 if( 0 == uCurrentBlockBuffer )
01014 v_HitUnpBlock[ fRocPar->uNbBuffers - 1 ].push_back( FECHIP[uChipStored].hitCurrent[uChannelStored] );
01015 else v_HitUnpBlock[ uCurrentBlockBuffer - 1 ].push_back(
01016 FECHIP[uChipStored].hitCurrent[uChannelStored] );
01017 Message(0, "Shifting this hit back, its falling edge was in this epoch but it started before!");
01018 Message(0, "Chan %2d (Chip %2d) TS = %9d, Epoch = %9d, Cycle = %9d, ToT = %9d, Block = %9d, buffer %d",
01019 FECHIP[uChipStored].hitCurrent[uChannelStored].GetFullChan(),
01020 FECHIP[uChipStored].hitCurrent[uChannelStored].GetGet4Index(),
01021 FECHIP[uChipStored].hitCurrent[uChannelStored].GetTsLeading(),
01022 FECHIP[uChipStored].hitCurrent[uChannelStored].GetEpochLeading(),
01023 FECHIP[uChipStored].hitCurrent[uChannelStored].GetEpochCycleLeading(),
01024 FECHIP[uChipStored].hitCurrent[uChannelStored].GetRawTOT(),
01025 uBlockIndexLast, uCurrentBlockBuffer );
01026 Message(0, "EpochBufferStart %10d, CycleBufferStart %10d", uEpochBufferStart, uCycleBufferStart);
01027 }
01028 else
01029 v_HitUnpBlock[ uCurrentBlockBuffer ].push_back( FECHIP[uChipStored].hitCurrent[uChannelStored] );
01030
01031
01032
01033 (FECHIP[uChipStored].hitLatest[uChannelStored]) = (FECHIP[uChipStored].hitCurrent[uChannelStored]);
01034 (FECHIP[uChipStored].hitCurrent[uChannelStored]).ClearHit();
01035 }
01036 }
01037 catch( CENoGET4DataEvent& error_obj )
01038 {
01039 cout << "Chip " <<uChipStored<<" ";
01040 cout << "Wrong message type!: "<<(UInt_t)error_obj.ucMessType<<" ";
01041 cout << "This is not a GET4 Data Event. ";
01042 cout << "Should not happen..." << endl;
01043 }
01044 catch( CELeadingEdgeAlreadySet )
01045 {
01046
01047
01048 fReconErrLE->Fill( uFullChannelStored );
01049 }
01050 catch( CETrailingEdgeAlreadySet )
01051 {
01052
01053
01054 fReconErrTE->Fill( uFullChannelStored );
01055 }
01056 catch( CEGivesNegativeToT )
01057 {
01058
01059
01060
01061 fReconErrNegToT->Fill( uFullChannelStored );
01062 }
01063 catch( CEOutOfTimeGate )
01064 {
01065
01066
01067
01068 fReconErrTimeGate->Fill( uFullChannelStored );
01069 }
01070 catch( CEOutOfTimeGateDetail& error_obj )
01071 {
01072
01073
01074
01075
01076
01077
01078 fReconErrTimeGate->Fill( uFullChannelStored );
01079
01080 if( 1 == fRpcPar->uManualDebug )
01081 if( 0.0 < error_obj.tot_past && error_obj.tot_past < 50.0 )
01082 {
01083 Message(2,"****** Falling edge delay chip= %2d chan= %2d fc= %5d, %6d %7d %9d, %6d %7d %9d, %2d, %4d, %6d %7d",
01084 uChipStored, uChannelStored, uFullChannelStored,
01085 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleLeading(),
01086 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochLeading(),
01087 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsLeading(),
01088 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleTrailing(),
01089 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochTrailing(),
01090 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsTrailing(),
01091 (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochTrailing()
01092 - (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochLeading(),
01093 (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsTrailing()
01094 -(Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsLeading(),
01095 storedEpochCycle, storedEpoch );
01096 }
01097 }
01098 catch( CEGivesNegativeToTDetail& error_obj )
01099 {
01100
01101
01102
01103
01104
01105
01106 fReconErrNegToT->Fill( uFullChannelStored );
01107
01108 if( 1 == fRpcPar->uManualDebug )
01109 if( 0.0 < error_obj.tot_fut && error_obj.tot_fut < 50.0 )
01110 {
01111 Message(2,"****** Rising edge delay chip= %2d chan= %2d fc= %5d, %6d %7d %9d, %6d %7d %9d, %2d, %4d, %6d %7d",
01112 uChipStored, uChannelStored, uFullChannelStored,
01113 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleLeading(),
01114 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochLeading(),
01115 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsLeading(),
01116 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochCycleTrailing(),
01117 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochTrailing(),
01118 (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsTrailing(),
01119 (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochTrailing()
01120 - (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetEpochLeading(),
01121 (Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsTrailing()
01122 -(Int_t)(FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTsLeading(),
01123 storedEpochCycle, storedEpoch );
01124 }
01125 }
01126 catch( CEHitIsNotComplete )
01127 {
01128 cout << "The Hit data is not complete. ";
01129 cout << "Should not happen..." << endl;
01130 }
01131 }
01132 }
01133
01134
01135
01136 if( fRocPar->uNbBuffers - 1 == uCurrentBlockBuffer )
01137 {
01138 if( kFALSE == TimeOrderBlock( 0 ) )
01139 return kFALSE;
01140 }
01141 else
01142 {
01143 if( kFALSE == TimeOrderBlock( uCurrentBlockBuffer + 1) )
01144 return kFALSE;
01145 }
01146
01147 uLastEpochLastBlock = uCurrentEpoch2;
01148 uLastCycleLastBlock = uCurrentCycle2;
01149
01150
01151
01152 uCurrentBlockBuffer = (uCurrentBlockBuffer + 1)%fRocPar->uNbBuffers;
01153
01154
01155
01156
01157 return kTRUE;
01158 }
01159
01160
01161
01162
01163
01164
01165 Bool_t TRPCProc::TimeOrderBlock(UInt_t bBufferToSort)
01166 {
01167
01168
01169 if( 0 == fRpcPar->uBlockOrderingEnable )
01170 {
01171 v_HitUnpBlock[ bBufferToSort ].clear();
01172
01173 uBlockIndex ++ ;
01174
01175 return kTRUE;
01176 }
01177
01178 std::list< TGet4HitUnpacked > lTempBuffSort;
01179 lTempBuffSort.insert( lTempBuffSort.begin(), (v_HitUnpBlock[ bBufferToSort ]).begin(),
01180 (v_HitUnpBlock[ bBufferToSort ]).end() );
01181 lTempBuffSort.sort( );
01182
01183 for ( UInt_t uChip = 0; uChip < fRocPar->uNbFeets *2; uChip++ )
01184 for ( UInt_t uChan = 0; uChan < NB_CHAN_GET4; uChan++ )
01185 {
01186 (FECHIP[uChip].hitLatestBlock[uChan]).ClearHit();
01187 (FECHIP[uChip].hitCurrentBlock[uChan]).ClearHit();
01188 }
01189
01190 Bool_t bFirstHits = kTRUE;
01191 TGet4HitUnpacked hitTemp;
01192
01193
01194 while( !lTempBuffSort.empty() )
01195 {
01196
01197 hitTemp.ClearHit();
01198 hitTemp = lTempBuffSort.front();
01199
01200 UInt_t uChip = hitTemp.GetGet4Index();
01201 UInt_t uChan = hitTemp.GetChannel();
01202 UInt_t uFullChan = hitTemp.GetFullChan();
01203
01204
01205 if( uFullChan == fRocPar->uNbFeets*8 )
01206 {
01207 (fOutputEvent->fUnpackedHits).push_back(hitTemp);
01208 continue;
01209 }
01210 else
01211 {
01212 (fOutputEvent->fUnpackedHits).push_back(hitTemp);
01213
01214 if( ( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) && 1 == fRpcPar->uAddGet4DataInTree )
01215 {
01216 uHitNumber ++;
01217 vuChannelId->push_back(hitTemp.GetFullChan() );
01218 vuTime->push_back( hitTemp.GetTsLeading() );
01219 vuEpochTime->push_back( hitTemp.GetEpochLeading() );
01220 viTot->push_back( hitTemp.GetRawTOT() );
01221 }
01222 }
01223
01224 if( 0 == fRocPar->uGet4Active[uChip] )
01225 {
01226 lTempBuffSort.pop_front();
01227 continue;
01228 }
01229
01230
01231 if( lastHit.Complete() )
01232 {
01233 if( lastHit.Spacing( hitTemp ) < 0.0 )
01234 {
01235 if( 0 == fRocPar->uSilentMode )
01236 {
01237 Message(3,"****** Block time ordering error: spacing = %9.2f in event %u, ordering buffer %d, First flag %1d ",
01238 lastHit.Spacing( hitTemp ), uNbEvents, bBufferToSort, bFirstHits );
01239 Message(3, "Chan %2d (Chip %2d) TS = %9d, Epoch = %9d, Cycle = %9d, ToT = %9d, Block = %9d before",
01240 lastHit.GetFullChan(), lastHit.GetGet4Index(), lastHit.GetTsLeading(),
01241 lastHit.GetEpochLeading(), lastHit.GetEpochCycleLeading(), lastHit.GetRawTOT(),
01242 uBlockIndexLast );
01243 Message(3, "Chan %2d (Chip %2d) TS = %9d, Epoch = %9d, Cycle = %9d, ToT = %9d, Block = %9d ", uFullChan,
01244 hitTemp.GetGet4Index(),
01245 hitTemp.GetTsLeading(),
01246 hitTemp.GetEpochLeading(),
01247 hitTemp.GetEpochCycleLeading(),
01248 hitTemp.GetRawTOT(),
01249 uBlockIndex );
01250 Message(3, "Switching chip %2d OFF", lastHit.GetGet4Index() );
01251 }
01252 fMapOrderErrors->Fill(lastHit.GetFullChan(), uFullChan);
01253 fMapOrderErrorsChips->Fill( lastHit.GetFullChan()/4, uFullChan/4);
01254
01255 fRocPar->uGet4Active[lastHit.GetGet4Index()] = 0;
01256 cout<<"Get4 Activated: |- ";
01257 for(UInt_t temp_index = 0; temp_index < 2*fRocPar->uNbFeets; temp_index++)
01258 {
01259 cout.width(2);
01260 cout<<temp_index<<" ";
01261 }
01262 cout<<endl<<" |-> ";
01263 for(UInt_t temp_index = 0; temp_index < 2*fRocPar->uNbFeets; temp_index++)
01264 {
01265 cout.width(2);
01266 cout<<fRocPar->uGet4Active[temp_index]<<" ";
01267 }
01268 cout<<endl;
01269
01270 lTempBuffSort.clear();
01271 v_HitUnpBlock[ bBufferToSort ].clear();
01272 lastHit.ClearHit();
01273 lastHit = hitTemp;
01274
01275 uBlockIndex ++ ;
01276
01277 return kFALSE;
01278 }
01279 }
01280
01281 FECHIP[uChip].hitCurrentBlock[uChan] = hitTemp;
01282 if( kTRUE == bFirstHits && 1 == fRocPar->uDebugHistoOn )
01283 {
01284 fGet4BlocksEvol->Fill((FECHIP[uChip].hitCurrentBlock[uChan]).GetEpochCycleLeading());
01285 }
01286 if( uFullChan < fRocPar->uNbFeets*8 && (FECHIP[uChip].hitCurrentBlock[uChan]).Complete())
01287 {
01288 fGet4HitsNb->Fill( uFullChan );
01289 fGet4HitsEvol->Fill((FECHIP[uChip].hitCurrentBlock[uChan]).GetEpochCycleLeading());
01290 if( 1 == fRocPar->uDebugHistoOn )
01291 (FECHIP[uChip].fGet4HitsNbEvolution[uChan])->Fill((FECHIP[uChip].hitCurrentBlock[uChan]).GetEpochCycleLeading());
01292 }
01293 else if( uFullChan < fRocPar->uNbFeets*8 && 1 == fRocPar->uDebugHistoOn)
01294 fGet4IncompletHitsEvol->Fill((FECHIP[uChip].hitCurrentBlock[uChan]).GetEpochCycleLeading());
01295
01296 if( kTRUE == bFirstHits )
01297 bFirstHits = kFALSE;
01298
01299 lastHit.ClearHit();
01300 lastHit = (FECHIP[uChip].hitCurrentBlock[uChan]);
01301 uBlockIndexLast = uBlockIndex;
01302
01303 if( uFullChan < fRocPar->uNbFeets*8 )
01304 {
01305 if( (FECHIP[uChip].hitLatestBlock[uChan]).Complete())
01306 {
01307 if( (FECHIP[uChip].hitLatestBlock[uChan]).Spacing( (FECHIP[uChip].hitCurrentBlock[uChan])) != 0 && 1 != fRpcPar->uNbHitMeanRate)
01308 {
01309 if( FECHIP[uChip].uInstantRateCounter[uChan] < fRpcPar->uNbHitMeanRate )
01310 {
01311 FECHIP[uChip].dInstantRateMean[uChan] +=
01312 ( (FECHIP[uChip].hitLatestBlock[uChan]).Spacing( (FECHIP[uChip].hitCurrentBlock[uChan])) )
01313 / fRpcPar->uNbHitMeanRate;
01314 FECHIP[uChip].dInstantRateOld[uChan][FECHIP[uChip].uInstantRateCounter[uChan]] =
01315 ( (FECHIP[uChip].hitLatestBlock[uChan]).Spacing( (FECHIP[uChip].hitCurrentBlock[uChan])) )
01316 /fRpcPar->uNbHitMeanRate;
01317
01318 FECHIP[uChip].uInstantRateCounter[uChan]++;
01319 }
01320 else
01321 {
01322 FECHIP[uChip].dInstantRateMean[uChan] -= FECHIP[uChip].dInstantRateOld[uChan][FECHIP[uChip].uInstantRateCounter[uChan]
01323 - fRpcPar->uNbHitMeanRate];
01324 FECHIP[uChip].dInstantRateMean[uChan] +=
01325 ( (FECHIP[uChip].hitLatestBlock[uChan]).Spacing( (FECHIP[uChip].hitCurrentBlock[uChan])) )
01326 / fRpcPar->uNbHitMeanRate;
01327 FECHIP[uChip].dInstantRateOld[uChan][FECHIP[uChip].uInstantRateCounter[uChan] - fRpcPar->uNbHitMeanRate] =
01328 ( (FECHIP[uChip].hitLatestBlock[uChan]).Spacing( (FECHIP[uChip].hitCurrentBlock[uChan])) )
01329 /fRpcPar->uNbHitMeanRate;
01330
01331 FECHIP[uChip].uInstantRateCounter[uChan]++;
01332 }
01333 if( (fRpcPar->uNbHitMeanRate - 1) < FECHIP[uChip].uInstantRateCounter[uChan] )
01334 {
01335 (FECHIP[uChip].fGet4InstantRate[uChan])->Fill( 1000000000.0/FECHIP[uChip].dInstantRateMean[uChan],
01336 (FECHIP[uChip].hitCurrentBlock[uChan]).GetEpochCycleLeading() );
01337 }
01338
01339 if( 2*fRpcPar->uNbHitMeanRate == FECHIP[uChip].uInstantRateCounter[uChan] )
01340 FECHIP[uChip].uInstantRateCounter[uChan] = fRpcPar->uNbHitMeanRate;
01341 }
01342 }
01343 }
01344
01345
01346 Double_t dTimeToDistanceFactor = 10.0;
01347
01348
01349 for( UInt_t uChipOne = 0; uChipOne < 2*fRocPar->uNbFeets; uChipOne++ )
01350 {
01351 UInt_t uIndex = 0;
01352 for(Int_t iChanOne = 0; iChanOne < NB_CHAN_GET4; iChanOne++)
01353 {
01354 Int_t iFullChanOne = NB_CHAN_GET4*uChipOne + iChanOne;
01355 Int_t iFullChanSec = 0;
01356
01357
01358 for(Int_t iChanSec = iChanOne + 1; iChanSec < NB_CHAN_GET4; iChanSec++)
01359 {
01360 iFullChanSec = NB_CHAN_GET4*uChipOne + iChanSec;
01361
01362
01363
01364
01365 if ( iFullChanOne == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanSec].Complete() )
01366 {
01367 FillCorrelationHistograms( uIndex, uChipOne, iChanOne, uChipOne, iChanSec);
01368 }
01369 else if ( iFullChanSec == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01370 {
01371 FillCorrelationHistogramsInv( uIndex, uChipOne, iChanOne, uChipOne, iChanSec);
01372 }
01373 uIndex++;
01374 }
01375 for(UInt_t uChipSec = uChipOne + 1; uChipSec < 2*fRocPar->uNbFeets; uChipSec++)
01376 {
01377 for(Int_t iChanSec = 0; iChanSec < NB_CHAN_GET4; iChanSec++)
01378 {
01379 iFullChanSec = NB_CHAN_GET4*uChipSec + iChanSec;
01380
01381
01382
01383
01384 if ( iFullChanOne == (Int_t)uFullChan && FECHIP[uChipSec].hitLatestBlock[iChanSec].Complete() )
01385 {
01386 FillCorrelationHistograms( uIndex, uChipOne, iChanOne, uChipSec, iChanSec);
01387 }
01388 else if ( iFullChanSec == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01389 {
01390 FillCorrelationHistogramsInv( uIndex, uChipOne, iChanOne, uChipSec, iChanSec);
01391 }
01392 uIndex++;
01393 }
01394 }
01395
01396
01397 for( UInt_t uStripIndex = 0; uStripIndex < fRpcPar->uNbStrips; uStripIndex++)
01398 if( iFullChanOne == (Int_t)fRpcPar->uStripLeftList[uStripIndex] )
01399 {
01400 UInt_t uChipSec = fRpcPar->uStripRightList[uStripIndex] / NB_CHAN_GET4;
01401 UInt_t uChanSec = fRpcPar->uStripRightList[uStripIndex] % NB_CHAN_GET4;
01402 if( FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() &&
01403 FECHIP[uChipSec].hitLatestBlock[uChanSec].Complete() )
01404 {
01405 fBeamProfileHDRPC->Fill( dTimeToDistanceFactor *
01406 FECHIP[uChipOne].hitLatestBlock[iChanOne].Spacing( FECHIP[uChipSec].hitLatestBlock[uChanSec] )
01407 - fRpcPar->dOffsetList[uStripIndex],
01408 uStripIndex - ( (Double_t)fRpcPar->uNbStrips / 2.0 ) );
01409 }
01410 }
01411 }
01412 }
01413
01414
01415 if( -1 != iIsPadChannelX[uFullChan] )
01416 fBeamProfilePRPC->Fill( iIsPadChannelX[uFullChan] - (fRpcPar->uNbPadsX/2.0), iIsPadChannelY[uFullChan] - (fRpcPar->uNbPadsY/2.0) );
01417
01418 (FECHIP[uChip].hitLatestBlock[uChan]).ClearHit();
01419 FECHIP[uChip].hitLatestBlock[uChan] = FECHIP[uChip].hitCurrentBlock[uChan];
01420 (FECHIP[uChip].hitCurrentBlock[uChan]).ClearHit();
01421
01422 lTempBuffSort.pop_front();
01423 }
01424
01425 lTempBuffSort.clear();
01426 v_HitUnpBlock[ bBufferToSort ].clear();
01427
01428 uBlockIndex ++ ;
01429
01430 return kTRUE;
01431 }
01432
01433
01434 Bool_t TRPCProc::FillCorrelationHistograms( UInt_t uIndexHisto,
01435 UInt_t uChipOne, Int_t iChanOne, UInt_t uChipSec, Int_t iChanSec)
01436 {
01437 Double_t dCorrValue = FECHIP[uChipOne].hitCurrentBlock[iChanOne].Spacing(
01438 FECHIP[uChipSec].hitLatestBlock[ iChanSec]);
01439 if( -fRpcPar->fCorrelationGate <= dCorrValue && dCorrValue <= fRpcPar->fCorrelationGate)
01440 FECHIP[uChipOne].fVGetTimeCorrelation[uIndexHisto]->Fill( dCorrValue );
01441
01442 if( 1 == fRpcPar->uTotCorrelationHistOn )
01443 {
01444 FECHIP[uChipOne].fVGetTotCorrelation[uIndexHisto]->Fill(FECHIP[uChipOne].hitCurrentBlock[iChanOne].GetTOT(),
01445 FECHIP[uChipSec].hitLatestBlock[ iChanSec].GetTOT());
01446 }
01447 if( 1 == fRpcPar->uCorrelationHistoOn )
01448 {
01449 if( -fRpcPar->fCorrelationCheck <= dCorrValue && dCorrValue <= fRpcPar->fCorrelationCheck)
01450 for( UInt_t uChipTer = 0; uChipTer < 2*fRocPar->uNbFeets; uChipTer++ )
01451 for(Int_t iChanTer = 0; iChanTer < NB_CHAN_GET4; iChanTer++)
01452 if( ( uChipTer != uChipOne || iChanTer != iChanOne ) &&
01453 ( uChipTer != uChipSec || iChanTer != iChanSec ) )
01454 {
01455 if( FECHIP[uChipTer].hitLatestBlock[ iChanTer].Complete() )
01456 {
01457 Double_t dCorrValue2 = FECHIP[uChipOne].hitCurrentBlock[iChanOne].Spacing(
01458 FECHIP[uChipTer].hitLatestBlock[ iChanTer]);
01459 Double_t dCorrValue3 = FECHIP[uChipSec].hitLatestBlock[ iChanSec].Spacing(
01460 FECHIP[uChipTer].hitLatestBlock[ iChanTer]);
01461 if(-fRpcPar->fCorrelationCheck <= dCorrValue2 && dCorrValue2 <= fRpcPar->fCorrelationCheck &&
01462 -fRpcPar->fCorrelationCheck <= dCorrValue3 && dCorrValue3 <= fRpcPar->fCorrelationCheck)
01463 {
01464 FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01465
01466 for( UInt_t uChipQua = 0; uChipQua < 2*fRocPar->uNbFeets; uChipQua++ )
01467 for(Int_t iChanQua = 0; iChanQua < NB_CHAN_GET4; iChanQua++)
01468 if( ( uChipQua != uChipOne || iChanQua != iChanOne ) &&
01469 ( uChipQua != uChipSec || iChanQua != iChanSec ) &&
01470 ( uChipQua != uChipTer || iChanQua != iChanTer ) )
01471 {
01472 if( FECHIP[uChipQua].hitLatestBlock[ iChanQua].Complete() )
01473 {
01474 Double_t dCorrValue4 = FECHIP[uChipOne].hitCurrentBlock[iChanOne].Spacing(
01475 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01476 Double_t dCorrValue5 = FECHIP[uChipSec].hitLatestBlock[ iChanSec].Spacing(
01477 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01478 Double_t dCorrValue6 = FECHIP[uChipTer].hitLatestBlock[ iChanTer].Spacing(
01479 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01480 if(-fRpcPar->fCorrelationCheck <= dCorrValue4 && dCorrValue4 <= fRpcPar->fCorrelationCheck &&
01481 -fRpcPar->fCorrelationCheck <= dCorrValue5 && dCorrValue5 <= fRpcPar->fCorrelationCheck &&
01482 -fRpcPar->fCorrelationCheck <= dCorrValue6 && dCorrValue6 <= fRpcPar->fCorrelationCheck )
01483 FECHIP[uChipOne].fVCheckCorrelation4[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer,
01484 uChipQua*NB_CHAN_GET4 + iChanQua );
01485 }
01486 }
01487 }
01488 }
01489 }
01490 else
01491 FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01492 }
01493
01494 return kTRUE;
01495 }
01496
01497
01498 Bool_t TRPCProc::FillCorrelationHistogramsInv( UInt_t uIndexHisto,
01499 UInt_t uChipOne, Int_t iChanOne, UInt_t uChipSec, Int_t iChanSec)
01500 {
01501 Double_t dCorrValue = FECHIP[uChipOne].hitLatestBlock[ iChanOne].Spacing(
01502 FECHIP[uChipSec].hitCurrentBlock[iChanSec]);
01503 if( -fRpcPar->fCorrelationGate <= dCorrValue && dCorrValue <= fRpcPar->fCorrelationGate)
01504 FECHIP[uChipOne].fVGetTimeCorrelation[uIndexHisto]->Fill( dCorrValue );
01505
01506 if( 1 == fRpcPar->uTotCorrelationHistOn )
01507 {
01508 FECHIP[uChipOne].fVGetTotCorrelation[uIndexHisto]->Fill(FECHIP[uChipOne].hitLatestBlock[ iChanOne].GetTOT(),
01509 FECHIP[uChipSec].hitCurrentBlock[iChanSec].GetTOT());
01510 }
01511 if( 1 == fRpcPar->uCorrelationHistoOn )
01512 {
01513 FECHIP[uChipOne].fVGetTotCorrelation[uIndexHisto]->Fill(FECHIP[uChipOne].hitLatestBlock[ iChanOne].GetTOT(),
01514 FECHIP[uChipSec].hitCurrentBlock[iChanSec].GetTOT());
01515 if( -fRpcPar->fCorrelationCheck <= dCorrValue && dCorrValue <= fRpcPar->fCorrelationCheck)
01516 for( UInt_t uChipTer = 0; uChipTer < 2*fRocPar->uNbFeets; uChipTer++ )
01517 for(Int_t iChanTer = 0; iChanTer < NB_CHAN_GET4; iChanTer++)
01518 if( ( uChipTer != uChipOne || iChanTer != iChanOne ) &&
01519 ( uChipTer != uChipSec || iChanTer != iChanSec ) )
01520 {
01521 if( FECHIP[uChipTer].hitLatestBlock[ iChanTer].Complete() )
01522 {
01523 Double_t dCorrValue2 = FECHIP[uChipOne].hitLatestBlock[ iChanOne].Spacing(
01524 FECHIP[uChipTer].hitLatestBlock[ iChanTer]);
01525 Double_t dCorrValue3 = FECHIP[uChipSec].hitCurrentBlock[iChanSec].Spacing(
01526 FECHIP[uChipTer].hitLatestBlock[ iChanTer]);
01527 if(-fRpcPar->fCorrelationCheck <= dCorrValue2 && dCorrValue2 <= fRpcPar->fCorrelationCheck &&
01528 -fRpcPar->fCorrelationCheck <= dCorrValue3 && dCorrValue3 <= fRpcPar->fCorrelationCheck)
01529 {
01530 FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01531
01532 for( UInt_t uChipQua = 0; uChipQua < 2*fRocPar->uNbFeets; uChipQua++ )
01533 for(Int_t iChanQua = 0; iChanQua < NB_CHAN_GET4; iChanQua++)
01534 if( ( uChipQua != uChipOne || iChanQua != iChanOne ) &&
01535 ( uChipQua != uChipSec || iChanQua != iChanSec ) &&
01536 ( uChipQua != uChipTer || iChanQua != iChanTer ) )
01537 {
01538 if( FECHIP[uChipQua].hitLatestBlock[ iChanQua].Complete() )
01539 {
01540 Double_t dCorrValue4 = FECHIP[uChipOne].hitLatestBlock[ iChanOne].Spacing(
01541 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01542 Double_t dCorrValue5 = FECHIP[uChipSec].hitCurrentBlock[iChanSec].Spacing(
01543 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01544 Double_t dCorrValue6 = FECHIP[uChipTer].hitLatestBlock[ iChanTer].Spacing(
01545 FECHIP[uChipQua].hitLatestBlock[ iChanQua]);
01546 if(-fRpcPar->fCorrelationCheck <= dCorrValue4 && dCorrValue4 <= fRpcPar->fCorrelationCheck &&
01547 -fRpcPar->fCorrelationCheck <= dCorrValue5 && dCorrValue5 <= fRpcPar->fCorrelationCheck &&
01548 -fRpcPar->fCorrelationCheck <= dCorrValue6 && dCorrValue6 <= fRpcPar->fCorrelationCheck )
01549 FECHIP[uChipOne].fVCheckCorrelation4[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer,
01550 uChipQua*NB_CHAN_GET4 + iChanQua );
01551 }
01552 }
01553 }
01554 }
01555 }
01556 else
01557 FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01558 }
01559
01560 return kTRUE;
01561 }
01562