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

onlinemonitor/rocmonitor/TRocParam.cxx (r4864/r3724)

Go to the documentation of this file.
00001 #include "TRocParam.h"
00002 
00003 #include "TGo4Log.h"
00004 #include "Riostream.h"
00005 using namespace std;
00006 
00007 TRocParam::TRocParam() : TGo4Parameter()
00008 {
00009    numRocs = 0;
00010    for (int roc=0;roc<MAX_ROC;roc++) {
00011       activeRoc[roc] = kFALSE;
00012       timeScale[roc] = 1.0;
00013       timeShift[roc] = 0;
00014       uFeetRocsMapping[roc] = 0;
00015       for (int nx=0;nx<MAX_NX;nx++) {
00016           ttriMode[roc][nx] = kFALSE;
00017       }
00018    }
00019 
00020    baselineCalibr = kFALSE;  // enables baseline calibration code
00021    pedInitState = roc::SYSMSG_USER_CALIBR_OFF;
00022    pedestalFile = "";
00023    pedSaveToFile = "";
00024    dynamicPedestal = kFALSE;
00025    pedestalAcquisition = kFALSE;
00026    storePedestalFile = kFALSE;
00027 
00028    pedTtriCalibrPeriod = 10000000000LL;
00029    pedExractionMethod = 0;
00030    pedVerbose = 0;
00031    nxDiffCh = -1; // channel, used for diff calcalculations (-1 disable)
00032    noTrigger = kTRUE;  // ignore trigger window and take all messages with initial event division
00033    triggerSignal = 0; // 0 .. 3 is AUXs, 10-11 is SYNCs
00034    globalTrigger = kFALSE; // true for selecting messages under global corrected time window, false for using separate windows for each roc
00035    masterRoc = 77777; // id number of ROC which is time/trigger reference, big number is disable master roc
00036    maxBufferTriggers=10;
00037    maxBufferLoops=10;
00038    doSorting = kFALSE;  // perform time sorting of messages
00039    numNX = 2; // use only two even number of nXYTERs
00040    bGet4Debug = kFALSE;
00041 
00043    NoGet4Cleaning     = kTRUE;   // write directly fExtentedMessages in buffer, no get4 cleaning
00044    iEventNbGap    = -1;      // -1 = check Off, Gap in event nember between get4 events
00045    uSyncCycleSize = 0;       // No Online Change - Size of the synchronization cycle in epochs
00046    uRocCycleSize  = 0;       // No Online Change - Size of roc epoch counter cycle in epochs
00047    uMainSyncCycleSize = 0;   // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs
00048    uNbBlockJumpedReset = 0;  // Nb of sync cycle epoch block to jump when a "GET4 RESET" message is received
00049    uNbRocsGet4 = 0;          // No Online Change - Nb of Rocs "GET4" in setup
00050    uNbFeets = 0;             // No Online Change - Total Nb of active FEET boards in setup
00051    uUseLocalEpochs = 0;      // Use ROC (0) / Local (1) epochs
00052    uNbBuffers = 0;           // No Online Change - Number of buffers to use for messages and hits ordering/matching
00053    uCosyRun = 0;             // For manual corrections: Cosy run values to use
00054    uSilentMode = 0;          // Remove all printouts => Blind mode!
00055    uSilentSyncMode = 0;      // Remove printouts about wrong sync size in epochs
00056    uManualDebug = 0;         // For manual corrections: 0 disable the messages about
00057    uDebugHistoOn = 0;        // No Online Change - Enable/Disable general debug histograms
00058    uDebugPrintOn = 0;        // Number of data messages to be printed on screen for debug
00059    uGet4Print = 0;           // Number of data messages to be printed on screen for debug
00060    uSortingHistoOn = 0;      // No Online Change - Enable/Disable debug histograms for time ordering
00061 
00062    for (int n=0;n<MAX_FEET*2;n++) {
00063       uGet4Mapping[n] = 0; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here
00064       uGet4Active[n] = 0; // Activated Get4 chips (indexes after remapping => not hardware map !)
00065       uGet4EdgeInversion[n] = 0;   // Edges inversion: affect all channels of a GET4 chip
00066    }
00067 }
00068 
00069 
00070 
00071 TRocParam::TRocParam(const char* name) : TGo4Parameter(name)
00072 {
00073    numRocs = 4;
00074    for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) {
00075       if(rocid<numRocs)
00076          activeRoc[rocid]=kTRUE;
00077       else
00078          activeRoc[rocid]=kFALSE;
00079 
00080       timeScale[rocid]=1.0;
00081       timeShift[rocid]=0;
00082       for (int nx=0;nx<MAX_NX;nx++) {
00083           ttriMode[rocid][nx] = kFALSE;
00084       }
00085    }
00086 
00087    baselineCalibr = kFALSE;
00088    pedInitState = roc::SYSMSG_USER_RECONFIGURE;
00089    pedestalFile = "";
00090    pedSaveToFile = "";
00091    pedTtriCalibrPeriod = 10000000000LL;
00092    pedExractionMethod = 0;
00093    pedVerbose = 0;
00094    globalTrigger = true;
00095 
00096    nxDiffCh = -1; // do not build diff histograms per default
00097    
00098    // use AUX2 as default trigger signal, while it is external trigger input for ROC
00099    triggerSignal = 2;
00100    noTrigger = kFALSE;
00101    masterRoc = 0;
00102    maxBufferTriggers=10;
00103    maxBufferLoops=10;
00104    doSorting = kTRUE;
00105    numNX = 2;
00106    bGet4Debug = kFALSE;
00107 
00109    NoGet4Cleaning     = kTRUE;   // write directly fExtentedMessages in buffer, no get4 cleaning
00110    iEventNbGap    = -1;      // -1 = check Off, Gap in event nember between get4 events
00111    uSyncCycleSize = 0;       // No Online Change - Size of the synchronization cycle in epochs
00112    uRocCycleSize  = 0;       // No Online Change - Size of roc epoch counter cycle in epochs
00113    uMainSyncCycleSize = 0;   // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs
00114    uNbBlockJumpedReset = 0;  // Nb of sync cycle epoch block to jump when a "GET4 RESET" message is received
00115    uNbRocsGet4 = 0;          // No Online Change - Nb of Rocs "GET4" in setup
00116    uNbFeets = 0;             // No Online Change - Total Nb of active FEET boards in setup
00117    uUseLocalEpochs = 0;      // Use ROC (0) / Local (1) epochs
00118    uNbBuffers = 0;           // No Online Change - Number of buffers to use for messages and hits ordering/matching
00119    uCosyRun = 0;             // For manual corrections: Cosy run values to use
00120    uSilentMode = 0;          // Remove all printouts => Blind mode!
00121    uSilentSyncMode = 0;      // Remove printouts about wrong sync size in epochs
00122    uManualDebug = 0;         // For manual corrections: 0 disable the messages about
00123    uDebugHistoOn = 0;        // No Online Change - Enable/Disable general debug histograms
00124    uDebugPrintOn = 0;        // Number of data messages to be printed on screen for debug
00125    uGet4Print = 0;           // Number of data messages to be printed on screen for debug
00126    uSortingHistoOn = 0;      // No Online Change - Enable/Disable debug histograms for time ordering
00127 
00128    for (int n=0;n<MAX_FEET*2;n++) {
00129       uGet4Mapping[n] = 0; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here
00130       uGet4Active[n] = 0; // Activated Get4 chips (indexes after remapping => not hardware map !)
00131       uGet4EdgeInversion[n] = 0;   // Edges inversion: affect all channels of a GET4 chip
00132    }
00133 }
00134 
00135 TRocParam::~TRocParam()
00136 {
00137    SetNbRocsGet4(0);
00138 
00139    SetNbFeets(0);
00140 }
00141 
00142 Bool_t TRocParam::UpdateFrom(TGo4Parameter* rhs)
00143 {
00144    TGo4Log::Info("TRocParam::UpdateFrom");
00145    Bool_t oldpedestalacquisiton=pedestalAcquisition;
00146    if(!TGo4Parameter::UpdateFrom(rhs)) return kFALSE;
00147    if(oldpedestalacquisiton && ! pedestalAcquisition) {
00148       // manual acquisition was switched off, mark storing the data:
00149       storePedestalFile=kTRUE;
00150    }
00151    for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) {
00152       if(rocid>=numRocs) activeRoc[rocid]=kFALSE;
00153    }
00154    return SetConfigRocs();
00155 }
00156 
00157 
00158 Bool_t TRocParam::SetConfigRocs()
00159 {
00160    for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) {
00161       TRocEvent::ConfigRocs[rocid] = rocid < numRocs ? (UInt_t) activeRoc[rocid] : 0;
00162       TGo4Log::Info("TRocParam::SetConfigRocs sets rocid %u to active: %u", rocid, TRocEvent::ConfigRocs[rocid]);
00163    }
00164    return kTRUE;
00165 }
00166 
00167 void TRocParam::SetNbRocsGet4(UInt_t num)
00168 {
00169    uNbRocsGet4 = num;
00170 
00171    if (uNbRocsGet4 > MAX_ROC) uNbRocsGet4 = MAX_ROC;
00172 
00173    if (uNbRocsGet4==0) return;
00174    for (unsigned n=0;n<uNbRocsGet4;n++)
00175       uFeetRocsMapping[n] = n;
00176 }
00177 
00178 Int_t TRocParam::FindFeetRocId(UInt_t rocid) const
00179 {
00180    for(Int_t iFeetRoc=0; iFeetRoc < (Int_t)uNbRocsGet4; iFeetRoc++)
00181       if(rocid == uFeetRocsMapping[iFeetRoc]) return iFeetRoc;
00182 
00183    return -1;
00184 }
00185 
00186 UInt_t TRocParam::DefineGet4IndexOffset(UInt_t rocid) const
00187 {
00188    Int_t id = FindFeetRocId(rocid);
00189    return id>=0 ? id*14 : 0;
00190 }
00191 
00192 void TRocParam::SetNbFeets(UInt_t num)
00193 {
00194 
00195    uNbFeets  = num;
00196    if (uNbFeets>MAX_FEET) uNbFeets = MAX_FEET;
00197 
00198    if (uNbFeets==0) return;
00199 
00200    for(UInt_t uGet4Index = 0; uGet4Index < 2*uNbFeets; uGet4Index++) {
00201       // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here
00202       uGet4Mapping[uGet4Index]       = uGet4Index;
00203       // Activated Get4 chips (indexes after remapping => not hardware map !)
00204       uGet4Active[uGet4Index]        = 0;
00205       // Edges inversion: affect all channels of a GET4 chip
00206       uGet4EdgeInversion[uGet4Index] = 0;
00207    }
00208 }
00209 
00210 UInt_t TRocParam::RemapGet4Chip(UInt_t uChip) const
00211 {
00212    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00213       if( uChip == uGet4Mapping[temp_index]) return temp_index;
00214    return 2*uNbFeets;
00215 }
00216 
00217 Bool_t TRocParam::PrintGet4Options()
00218 {
00219    cout<<"*************************************************"<<endl;
00220    cout<<"       Option values"<<endl;
00221    if(kTRUE == NoGet4Cleaning)
00222       cout<<"Get4 data cleaning:      OFF"<<endl;
00223       else cout<<"Get4 data cleaning:      ON"<<endl;
00224    cout<<"Event index gap:         "<<iEventNbGap<<endl;
00225    cout<<"Sync cycle size:         "<<uSyncCycleSize<<" Epochs (1 synch + "<<(uSyncCycleSize-1)<<" Unsynched)"<<endl;
00226    cout<<"Sync cycle size (Main):  "<<uMainSyncCycleSize<<" Epochs (1 synch + "<<(uMainSyncCycleSize-1)<<" Unsynched)"<<endl;
00227    cout<<"Nb sync blocks jump rst: "<<uNbBlockJumpedReset<<endl;
00228    cout<<"Nb ROC-GET4   :          "<<uNbRocsGet4<<endl;
00229    cout<<"Rocs Mapping  :  |-      ";
00230    for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++)
00231    {
00232       cout.width(2);
00233       cout<<uFeetRocsMapping[temp_index]<<" ";
00234    }
00235    cout<<endl<<"                 |->     ";
00236    for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++)
00237    {
00238       cout.width(2);
00239       cout<<temp_index<<" ";
00240    }
00241    cout<<endl;
00242    cout<<"Nb FEET boards:          "<<uNbFeets<<endl;
00243    cout<<"Get4 Mapping  :  |-      ";
00244    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00245    {
00246       cout.width(2);
00247       cout<<uGet4Mapping[temp_index]<<" ";
00248    }
00249    cout<<endl<<"                 |->     ";
00250    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00251    {
00252       cout.width(2);
00253       cout<<temp_index<<" ";
00254    }
00255    cout<<endl;
00256    cout<<"Get4 Activated:  |-      ";
00257    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00258    {
00259       cout.width(2);
00260       cout<<temp_index<<" ";
00261    }
00262    cout<<endl<<"                 |->     ";
00263    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00264    {
00265       cout.width(2);
00266       cout<<uGet4Active[temp_index]<<" ";
00267    }
00268    cout<<endl;
00269    cout<<"Get4 Inversion:  |-      ";
00270    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00271    {
00272       cout.width(2);
00273       cout<<temp_index<<" ";
00274    }
00275    cout<<endl<<"                 |->     ";
00276    for(UInt_t temp_index = 0; temp_index < 2*uNbFeets; temp_index++)
00277    {
00278       cout.width(2);
00279       cout<<uGet4EdgeInversion[temp_index]<<" ";
00280    }
00281    cout<<endl;
00282    cout<<"Nb Get4 message printed: "<<uGet4Print<<endl;
00283    if( uSilentMode )
00284       cout<<"Silent Mode                 :    ON "<<endl;
00285       else cout<<"Silent Mode                 :    OFF"<<endl;
00286    if( uSilentSyncMode )
00287       cout<<"Silent Mode for sync errors :    ON "<<endl;
00288       else cout<<"Silent Mode for sync errors :    OFF"<<endl;
00289    if( uManualDebug )
00290       cout<<"Debug Output for manual corr:    ON "<<endl;
00291       else cout<<"Debug Output for manual corr:    OFF"<<endl;
00292    if( uCosyRun )
00293       cout<<"Cosy Run for manual corrections: run "<<uCosyRun<<endl;
00294       else cout<<"Manual corrections inactive (run "<<uCosyRun<<" )"<<endl;
00295    if( uUseLocalEpochs )
00296       cout<<"Epochs used:                     local "<<endl;
00297       else cout<<"Epochs used:                     ROC"<<endl;
00298    cout<<"Nb of buffers:                   "<<uNbBuffers<<endl;
00299    if( uDebugHistoOn )
00300       cout<<"Debug Histograms:                ON "<<endl;
00301       else cout<<"Debug Histograms:                OFF"<<endl;
00302    if( uDebugPrintOn )
00303       cout<<"Debug Printout:                  ON "<<endl;
00304       else cout<<"Debug Printout:                  OFF"<<endl;
00305    if( uSortingHistoOn )
00306       cout<<"Deb Histograms for time sorting: ON "<<endl;
00307       else cout<<"Deb Histograms for time sorting: OFF"<<endl;
00308    cout<<"*************************************************"<<endl;
00309 
00310    return kTRUE;
00311 }

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