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

beamtime/cosy-nov11/go4/RPC/TRPCProc.cxx (r4864/r3159)

Go to the documentation of this file.
00001 /* Generated by Together */
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    // Rate test histogram
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    // GET4 chip specific initialization
00058    for( UInt_t uChip = 0; uChip < 2*fRocPar->uNbFeets; uChip++ )
00059    {
00060       //~ FECHIP[uChip].fIsEventComplete=kFALSE;
00061       
00062       // Multiple buffers solution
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       // Chip Related histograms
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       // Channels related Histograms
00086       for(Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00087       {
00088          Int_t iFullChan = NB_CHAN_GET4*uChip + iChan;
00089             
00090          // Variable
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          // Histos  
00096          FECHIP[uChip].fGet4FineTimeLE[iChan]       = 0; // Finetime of Leading Edge
00097          FECHIP[uChip].fGet4FineTimeTE[iChan]       = 0; // Finetime of Trailing Edge
00098          FECHIP[uChip].fGet4LeDnl[iChan]            = 0; // DNL value for each bin
00099          FECHIP[uChip].fGet4LeDnlSum[iChan]         = 0; // Integral of DNL value up to each bin
00100          FECHIP[uChip].fGet4TeDnl[iChan]            = 0; // DNL value for each bin
00101          FECHIP[uChip].fGet4TeDnlSum[iChan]         = 0; // Integral of DNL value up to each bin
00102          FECHIP[uChip].fGet4TOT[iChan]              = 0; // Time over threshold
00103 
00104          FECHIP[uChip].fGet4PulseSpacingClose[iChan]= 0; // Pulse spacing between current and last hit, ns range
00105          FECHIP[uChip].fGet4PulseSpacingMid[iChan]  = 0; // Pulse spacing between current and last hit, us range
00106          FECHIP[uChip].fGet4PulseSpacingFar[iChan]  = 0; // Pulse spacing between current and last hit, s range
00107          FECHIP[uChip].fGet4InstantRate[iChan]      = 0; // Instantaneous rate average over 8 or 10 hits
00108         
00109          FECHIP[uChip].fGet4RisEdgesNbEvol[iChan]   = 0; // Nb of rising  edges depending on cycle/chan
00110          FECHIP[uChip].fGet4FalEdgesNbEvol[iChan]   = 0; // Nb of falling edges depending on cycle/chan
00111          FECHIP[uChip].fGet4HitsNbEvolution[iChan]  = 0; // Nb of matched hits depending on cycle/chan
00112          
00113          FECHIP[uChip].fNbConsecutiveLE[iChan]      = 0; // Nb of consecutive Leading edges (should stay at 1 or max 2 when multi hits)
00114          FECHIP[uChip].fNbConsecutiveTE[iChan]      = 0; // Nb of consecutive Trailing edges (should stay at 1 or max 2 when multi hits)
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             } // if( 1 == fRocPar->uDebugHistoOn )
00188          } // if( 1 == fRpcPar->uHitBuildingEnable )
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             } // if( 1 == fRocPar->uDebugHistoOn )
00203             
00204             // Correlation Histograms
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                // Channel iChan[0,NB_CHAN_GET4 -1[ <-> iChanSec[iChan, NB_CHAN_GET4 -1] on this chip
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                } // if( 1 == fRpcPar->uCorrelationHistoOn )
00234             } // for(Int_t iChanSec = iChan + 1; iChanSec < NB_CHAN_GET4; iChanSec++)
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                   } // if( 1 == fRpcPar->uCorrelationHistoOn )
00269                } // for(Int_t iChanSec = 0; iChanSec < NB_CHAN_GET4; iChanSec++)
00270             }// for(Int_t iChipSec = uChip + 1; iChipSec < 2*fRocPar->uNbFeets; iChipSec++)
00271          } // if( 1 == fRpcPar->uBlockOrderingEnable )
00272       } // for(Int_t iChan = 0; iChan < NB_CHAN_GET4; iChan++)
00273    } // for( UInt_t uChip = 0; uChip < fRocPar->uNbFeets; uChip++ )
00274       
00275    // ROC general variables
00276    uNbEvents = 0;
00277    
00278    // GET4 general variables
00279      // Clear buffer for the block time ordering (Multiple buffers solution)
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    // GET4 general histograms
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       //  Attempt to get beam profile with Tsinghua Pad RPC
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    //  Attempt to get beam profile with Tsinghua Pad RPC
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        } // if( 1 == fRpcPar->uCleanOuputEnable )
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        } // if( 1 == fRpcPar->uAddGet4DataInTree )
00453        if( 1 == fRpcPar->uCleanOuputEnable )
00454           delete fRootOut;
00455    }
00456 
00457    // Getting mean values for each strip in the Beam profile (offset)
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    // first assign input event:
00474    // since input event object is never discarded within processor lifetime,
00475    // we just search for subevent by name once to speed up processing
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    // Optional: if triggered mode, look for the VME crate data
00494    // since input event object is never discarded within processor lifetime,
00495    // we just search for subevent by name once to speed up processing
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    // then assign output event
00515    // since output event object is never discarded within processor lifetime,
00516    // we just search for subevent by name once to speed up processing
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    // Prepare root tree and tree output file
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          } // if( 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ) )
00559             else
00560             {
00561                cleanTree = TGo4Analysis::Instance()->GetTree( "CosyRpc" );
00562                TGo4Log::Info("RPC Tree recovered from Go4");
00563             } // else of if( 0 == TGo4Analysis::Instance()->GetTree( "CosyRpc" ) )
00564 
00565          // Data from CAEN v1290 & Lecroy QDC VME boards (triggered)
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             } // if( -1 != fRpcPar->iPmtTdc && -1 != fRpcPar->iPmtQdc )
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             } // if( -1 != fRpcPar->iRpcTdcLeading && -1 != fRpcPar->iRpcTdcTrailing )
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             } // if( -1 != fRpcPar->iReferenceTdc && -1 != fRpcPar->iReferenceChannel )
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             } // if( -1 != fRpcPar->iReferenceTdc && -1 != fRpcPar->iReferenceChannel )
00601          } // if( kFALSE == fRocPar->noTrigger )
00602 
00603          if( 1 == fRpcPar->uAddGet4DataInTree )
00604          {
00605             // Data from Get4-Roc
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       } // if( 0 == cleanTree)
00632    } // if( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay)
00633 
00634 }
00635 
00636 
00637 void TRPCProc::FinalizeEvent()
00638 {
00639         if(!fRocInputEvent->IsValid()) return; // skip incomplete roc events from first step
00640 // put additional RPC processing here 
00641 
00642   // When not first step
00643   if( 0 == dynamic_cast<TGo4MbsEvent*>(fRocInputEvent) )
00644       fMbsEventNumber = fRocInputEvent->fMbsEventNumber;
00645   if(uNbEvents == 0)
00646   {
00647     uFirstEventIndex = fMbsEventNumber;
00648     uPrevEventIndex  = fMbsEventNumber;
00649     // not needed but for safety, happen only once per run!
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         //loop over FEET rocs:
00662         for(Int_t iFeetRoc=0; iFeetRoc < (Int_t)fRocPar->uNbRocsGet4; iFeetRoc ++)
00663         {
00664       // Retrieve data structure for this ROC
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          } //  if( (1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) && 1 == fRpcPar->uAddGet4DataInTree )
00681 
00682          return;
00683       }
00684    }
00685 
00686    uNbEvents++;
00687 
00688    // Fill the tree
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       } // if( 1 == fRpcPar->uAddGet4DataInTree )
00700    } // if( ( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) )
00701 
00702 
00703    fOutputEvent->SetValid(kTRUE);
00704 }
00705 /**********************************************************************/
00706 /*
00707  * This function build hits from previously ordered data messages for a
00708  * given chip and save them in a common buffer (stream remerging).
00709  * It also checks the hits buffer status, and when all chip's buffers 
00710  * are ready (either with hits built are emptied because of invalid 
00711  * "fRpcPar->uSyncCycleSize" epoch block), it calls the hits time
00712  * ordering function TimeOrderBlock on the buffer for previous block, 
00713  * as no hits can be shifted there anymore
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    // Histogram of edge messages/event
00725    if( kTRUE == fRocPar->noTrigger )
00726       fGet4EdgeMessagePerEvent->Fill( (rocEvent->vMessageEventBuffer).size() );
00727       else fGet4EdgeMessagePerEvent->Fill( (rocEvent->fExtMessages).size() );
00728    
00729    // If the hit building is disabled, just clear the buffer and
00730    // go on
00731    if( 0 == fRpcPar->uHitBuildingEnable )
00732    {
00733       // PAL: Done by ROC event processor I think
00734       //(rocEvent->vMessageEventBuffer).clear();
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       // Time order and save NEXT buffer!
00743       // PREVIOUS is ok only with 2 buffers where NEXT = PREVIOUS
00744       if( fRocPar->uNbBuffers - 1  == uCurrentBlockBuffer) // index made a loop => next is 1st buffer
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       // Resets buffer status flags
00756       uLastEpochLastBlock = uCurrentEpoch2;
00757       uLastCycleLastBlock = uCurrentCycle2;
00758 
00759       // Multiple buffers solution => exchange current buffer
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    // To Change!
00772    // Multiple buffers solution
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    // Loop over the messages from the last "fRocPar->uSyncCycleSize" Epochs
00783    // stored in the vDataMessagesStack buffer of corresponding chip
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       } // if( kTRUE == fRocPar->noTrigger )
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          } // else of if( kTRUE == fRocPar->noTrigger )
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 //         if( 0 <= uNbEvents && 0 < mLastFromBuffer.GetRocMessage().getMessageType() )
00829 //            if( mLastFromBuffer.RocOrder((rocEvent->vMessageEventBuffer).at(uMessIndex)) !=
00830 //                mLastFromBuffer.LocalOrder((rocEvent->vMessageEventBuffer).at(uMessIndex))  )
00831 //            {
00832 //               Message(0, "Debug, the ordering is not the same with local and roc epochs %d %d!",
00833 //                     mLastFromBuffer.RocOrder((rocEvent->vMessageEventBuffer).at(uMessIndex)),
00834 //                     mLastFromBuffer.LocalOrder((rocEvent->vMessageEventBuffer).at(uMessIndex)) );
00835 //               Message(0, "%3d %d %d %d %d", mLastFromBuffer.GetRocMessage().getMessageType(),
00836 //                                         mLastFromBuffer.GetRocEpoch(), mLastFromBuffer.GetRocCycle(),
00837 //                                         mLastFromBuffer.GetLocalEpoch(), mLastFromBuffer.GetLocalCycle());
00838 //               Message(0, "%3d %d %d %d %d", storedData.getMessageType(),storedEpoch, storedEpochCycle,
00839 //                                             storedLocalEpoch, storedLocalEpochCycle);
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       // uChip is the Chip-ID of the GET4 which created this data event.
00889       UInt_t uChipStored    = storedData.getGet4Number();
00890       // Remap the Get4 chip index
00891 //      if( kTRUE == fRocPar->NoGet4Cleaning)
00892 //         uChipStored = fRocPar->RemapGet4Chip(uChipStored);
00893 //      if(fRocPar->uNbFeets*2 <= uChipStored)
00894 //         cout<<"arf"<<endl;
00895       // the channel depends on the Chip-ID and the Channel on this Chip
00896       UInt_t uChannelStored = storedData.getGet4ChNum();
00897       // the full channel depends on the Chip-ID and the Channel on this Chip
00898       UInt_t uFullChannelStored = uChipStored * 4 + storedData.getGet4ChNum();
00899 
00900       // Analyses works now with a variable number of FEET boards
00901       // e.g. fRocPar->uNbFeets * 8 Channels
00902       if ( uFullChannelStored >= 0 && uFullChannelStored < fRocPar->uNbFeets * 8 )
00903       {
00904          // for linearity and channel activity histograms one need the
00905          // Edge marker and the finetime.
00906          UInt_t uEdge     = storedData.getGet4Edge();
00907 
00908          // The linearity and channel activity histograms are filled
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             } // if( 1 == fRocPar->uDebugHistoOn )
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             } // if( 1 == fRocPar->uDebugHistoOn )
00962          }
00963          // exception handling
00964          try
00965          {
00966          // The curent hit is set with the new date event
00967          // one GET4 date event contains information about one edge
00968          // so for a complete hit information two GET4 date events
00969          // are needed
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             // here it is checked whether a hit information is
00977             // completed
00978             if ( (FECHIP[uChipStored].hitCurrent[uChannelStored]).Complete() )
00979             {
00980                // The time over threshold information is filled into
00981                // a histogram
00982                (FECHIP[uChipStored].fGet4TOT[uChannelStored])->Fill(
00983                   (FECHIP[uChipStored].hitCurrent[uChannelStored]).GetTOT() );
00984                
00985                // if the latest hit before on this channel is stored
00986                // in hitLatest the pulse spacing will be calculated
00987                // and filled into a histogram
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                // As if the falling edge is in a different epoch than 
01002                // the rising edge the hit is placed in the wrong epoch,
01003                // it can happen that the hit ends up in wrong buffer 
01004                //(aka epoch block). To correct this, two blocks are stored
01005                // and this check added.
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                // the completed hit is stored in hitLatest and
01032                // hitCurrent is cleared.               
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              // it seems that a trailing edge is missing. This error
01047              // condition is counted in a histogram
01048              fReconErrLE->Fill( uFullChannelStored );
01049          }
01050          catch( CETrailingEdgeAlreadySet )
01051          {
01052              // it seems that a leading edge is missing. This error
01053              // condition is counted in a histogram
01054             fReconErrTE->Fill( uFullChannelStored );
01055          }
01056          catch( CEGivesNegativeToT )
01057          {
01058              // it seems that this edges combinations would result in
01059              // a negative ToT => Physically impossible
01060              // => This error is counted in a histogram & the message jumped
01061             fReconErrNegToT->Fill( uFullChannelStored );
01062          }
01063          catch( CEOutOfTimeGate )
01064          {
01065              // it seems that this edges too far away one from the other,
01066              // terms of epochs (see TIME_GATE pre-processor definition)
01067              // => This error is counted in a histogram & the message jumped
01068             fReconErrTimeGate->Fill( uFullChannelStored );
01069          }
01070          catch( CEOutOfTimeGateDetail& error_obj )
01071          {
01072              // it seems that this edges too far away one from the other,
01073              // terms of epochs (see TIME_GATE pre-processor definition)
01074              // => This error is counted in a histogram & the message jumped
01075              // To improve Debugging and detect the "inverted falling 
01076              // edges VS epoch" detection, some data is passed out and used
01077              // to fill additional histograms
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              // it seems that this edges combinations would result in
01101              // a negative ToT => Physically impossible
01102              // => This error is counted in a histogram & the message jumped
01103              // To improve Debugging and detect the "inverted rising 
01104              // edges VS epoch" detection, some data is passed out and used
01105              // to fill additional histograms
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       } // if ( uFullChannelStored >= 0 && uFullChannelStored < fRocPar->uNbFeets * 8 )
01132    } // for( UInt_t uMessIndex = 0; uMessIndex < (rocEvent->vMessageEventBuffer).size(); uMessIndex++)
01133 
01134    // Time order and save NEXT buffer!
01135    // PREVIOUS is ok only with 2 buffers where NEXT = PREVIOUS
01136    if( fRocPar->uNbBuffers - 1  == uCurrentBlockBuffer ) // index made a loop => next is 1st buffer
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         // Multiple buffers solution => exchange current buffer
01152    uCurrentBlockBuffer = (uCurrentBlockBuffer + 1)%fRocPar->uNbBuffers;
01153 
01154    // PAL: Done by ROC event processor I think
01155    //(rocEvent->vMessageEventBuffer).clear();
01156    
01157    return kTRUE;
01158 }
01159 /**********************************************************************/
01160 /*
01161  * This function orders all hits in the given buffer by time, whitout
01162  * taking care of their original chip. The ordered data are added one 
01163  * by one to a TTree object, and the buffer is finally cleared
01164  */
01165 Bool_t TRPCProc::TimeOrderBlock(UInt_t bBufferToSort)
01166 {    
01167    // If the Block Ordering is disabled, just clear the buffer and
01168    // go on
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       // Add hit to the Tree
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       // Here we will have to insert the filling of the output event!!!!!
01205       if( uFullChan == fRocPar->uNbFeets*8 ) // ExtSync on Get4Chip!
01206       {
01207          (fOutputEvent->fUnpackedHits).push_back(hitTemp);
01208          continue; // Don't enter the control histograms has it would go out of buffer
01209       }
01210          else                               // Normal hit
01211          {
01212             (fOutputEvent->fUnpackedHits).push_back(hitTemp);
01213             // Fill root tree
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             } // if( ( 1 == fRpcPar->uCleanOuputEnable || 1 == fRpcPar->uRootDisplay) && 1 == fRpcPar->uAddGet4DataInTree )
01222          }
01223       
01224       if( 0 == fRocPar->uGet4Active[uChip] )
01225       {
01226          lTempBuffSort.pop_front();
01227          continue;
01228       }
01229 
01230       // Fill some control histograms
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; // Maybe not needed?
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       // Attempt to get a beam profile during june11 GSI test
01346       Double_t dTimeToDistanceFactor = 10.0;
01347          
01348       // a loop over all channel combinations..
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             // Channel iChan[0,NB_CHAN_GET4 -1[ <-> iChanSec[iChan, NB_CHAN_GET4 -1] on this chip
01358             for(Int_t iChanSec = iChanOne + 1; iChanSec < NB_CHAN_GET4; iChanSec++)
01359             {
01360                iFullChanSec = NB_CHAN_GET4*uChipOne + iChanSec;
01361                
01362                // when a complete hit is stored for the other
01363                // channel of the correlation histograms will 
01364                // be filled
01365                if ( iFullChanOne == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanSec].Complete() )
01366                {
01367                   FillCorrelationHistograms( uIndex, uChipOne, iChanOne, uChipOne, iChanSec);
01368                } //  if ( iFullChanOne == uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanSec].Complete() )
01369                else if ( iFullChanSec == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01370                {
01371                   FillCorrelationHistogramsInv( uIndex, uChipOne, iChanOne, uChipOne, iChanSec);
01372                } // if ( iFullChanSec == uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01373                uIndex++;
01374             } // for(Int_t iChanSec = iChanOne + 1; iChanSec < NB_CHAN_GET4; iChanSec++)
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                   // when a complete hit is stored for the other
01382                   // channel of the correlation histograms will 
01383                   // be filled
01384                   if ( iFullChanOne == (Int_t)uFullChan && FECHIP[uChipSec].hitLatestBlock[iChanSec].Complete() )
01385                   {
01386                      FillCorrelationHistograms( uIndex, uChipOne, iChanOne, uChipSec, iChanSec);
01387                   } //  if ( iFullChanOne == uFullChan && FECHIP[uChipSec].hitLatestBlock[iChanSec].Complete() )
01388                   else if ( iFullChanSec == (Int_t)uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01389                   {
01390                      FillCorrelationHistogramsInv( uIndex, uChipOne, iChanOne, uChipSec, iChanSec);
01391                   } // if ( iFullChanSec == uFullChan && FECHIP[uChipOne].hitLatestBlock[iChanOne].Complete() )
01392                   uIndex++;
01393                } // for(Int_t iChanSec = 0; iChanSec < NB_CHAN_GET4; iChanSec++)
01394             } // for(Int_t uChipSec = uChipOne + 1; uChipSec < 2*(Int_t)fRocPar->uNbFeets; uChipSec++)
01395             
01396             // Attempt to get a beam profile with june11 GSI test data
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                   } // if both chan last hit is complete
01410                }
01411          } // for(Int_t iChanOne = 0; iChanOne < NB_CHAN_GET4; iChanOne++)
01412       } // for( UInt_t uChipOne = 0; uChipOne < fRocPar->uNbFeets; uChipOne++ )
01413 
01414       //  Attempt to get beam profile with Tsinghua Pad RPC
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 // Input variable "One" is the current hit => current channel and "Sec" is the old hit!
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                }// if Ch4 different from ch1 and ch2 and ch3 + for loop on ch4 (chip and channel)
01486                }
01487             }// if ch3 correlated to ch1 and ch2
01488          } // if( hitLatestBlock[uCh3].Complete() )
01489          } // if Ch3 different from ch1 and ch2 + for loop on ch3 (chip and channel)
01490          else
01491             FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01492    } // if( 1 == fRpcPar->uCorrelationHistoOn )
01493    
01494    return kTRUE;
01495 }
01496 
01497 // Input variable "Sec" is the current hit => current channel and "One" is the old hit!
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                }// if Ch4 different from ch1 and ch2 and ch3 + for loop on ch4 (chip and channel)
01552                }
01553             }// if ch3 correlated to ch1 and ch2
01554          } // if( hitLatestBlock[uCh3].Complete() )
01555          } // if Ch3 different from ch1 and ch2 + for loop on ch3 (chip and channel)
01556          else
01557             FECHIP[uChipOne].fVCheckCorrelation[uIndexHisto]->Fill( uChipTer*NB_CHAN_GET4 + iChanTer );
01558    } // if( 1 == fRpcPar->uCorrelationHistoOn )
01559    
01560    return kTRUE;
01561 }
01562 /**********************************************************************/

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