00001 #include "TGet4v1Param.h" 00002 00003 #include "TGo4Version.h" 00004 #if __GO4BUILDVERSION__ > 40502 00005 #include "go4iostream.h" 00006 #else 00007 #include "Riostream.h" 00008 #endif 00009 00010 00011 00012 TGet4v1Param::TGet4v1Param() : TGo4Parameter() 00013 { 00014 numRocs = 0; 00015 for (int roc=0;roc<MAX_ROC;roc++) { 00016 activeRoc[roc] = kFALSE; 00017 timeScale[roc] = 1.0; 00018 timeShift[roc] = 0; 00019 uGet4RocsMapping[roc] = 0; 00020 } 00021 noTrigger = kTRUE; // ignore trigger window and take all messages with initial event division 00022 triggerSignal = 0; // 0 .. 3 is AUXs, 10-11 is SYNCs 00023 globalTrigger = kFALSE; // true for selecting messages under global corrected time window, false for using separate windows for each roc 00024 masterRoc = 77777; // id number of ROC which is time/trigger reference, big number is disable master roc 00025 maxBufferTriggers=10; 00026 maxBufferLoops=10; 00027 doSorting = kFALSE; // perform time sorting of messages 00028 bGet4Debug = kFALSE; 00029 00030 bTriggerAfterData = kFALSE; 00031 00033 iEventNbGap = -1; // -1 = check Off, Gap in event nember between get4 events 00034 uEventNbCycle = 0; // No Online Change - Size of the event nember cycle 00035 uSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in epochs 00036 bSuppressedEpochs = kFALSE;// No Online Change - kFALSE = Normal epoch operation, kTRUE = 24b readout suppressed epoch mode, epoch only just after data 00037 bLongTimeHistos = kFALSE; // Enable some Long duration counts monitoring histos (10 days) 00038 uRocCycleSize = 0; // No Online Change - Size of roc epoch counter cycle in epochs 00039 uMainSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs 00040 uNbRocsGet4 = 0; // No Online Change - Nb of Rocs "GET4" in setup 00041 uNbGet4 = 0; // No Online Change - Total Nb of active FEET boards in setup 00042 uSilentMode = 0; // Remove all printouts => Blind mode! 00043 uDebugHistoOn = 0; // No Online Change - Enable/Disable general debug histograms 00044 uDebugPrintOn = 0; // Number of data messages to be printed on screen for debug 00045 uGet4Print = 0; // Number of data messages to be printed on screen for debug 00046 00047 /************* GET4 v1.x debug *******/ 00048 dMaxTot = 300000.0; // Maximal allowed Tot for 24 bits hit building, in ps 00049 bTotHistoEnable = kFALSE; // Enable Tot histograms 00050 bDebugHistoEnable = kFALSE; // Enable the time difference, finetime and DNL histograms 00051 uNbEventsDnlUpdate = 1000; // Nb of events between 2 updates of the DNL histograms 00052 uGet4TimeDiffChip1 = 0; // Index of first chip to be used for time difference histos 00053 uGet4TimeDiffChip2 = 0; // Index of first chip to be used for time difference histos 00054 bChannelRateHistoEnable = kFALSE; // Enable Rate histograms for each channel 00055 bChipRateHistoEnable = kFALSE; // Enable Rate histograms for each chip 00056 /*************************************/ 00057 /*********** free-streaming **********/ 00058 bRawDataMode = kFALSE; // kFALSE = DABC data format, 1 SYNC/Event, kTRUE = RAW DATA format, all messages 00059 bFreeStreaming = kFALSE; // kFALSE = Sync trigger/no trigger, kTRUE= online detection/selection from data 00060 /*************************************/ 00061 00062 for (int n=0;n<MAX_GET4;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 iMainReferenceTdc = -1; // No Online Change - TDC used for the reference signals profiles in Detector classes, -1 disable it 00069 iReference1Channel = -1; // No Online Change - Channel used for the 1st reference histogram in Detector classes, -1 disable it 00070 iReference2Channel = -1; // No Online Change - Channel used for the 2nd reference histogram in Detector classes, -1 disable it 00071 } 00072 00073 00074 00075 TGet4v1Param::TGet4v1Param(const char* name) : TGo4Parameter(name) 00076 { 00077 numRocs = 4; 00078 for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) { 00079 if(rocid<numRocs) 00080 activeRoc[rocid]=kTRUE; 00081 else 00082 activeRoc[rocid]=kFALSE; 00083 00084 timeScale[rocid]=1.0; 00085 timeShift[rocid]=0; 00086 } 00087 00088 globalTrigger = true; 00089 00090 // use AUX2 as default trigger signal, while it is external trigger input for ROC 00091 triggerSignal = 2; 00092 noTrigger = kFALSE; 00093 masterRoc = 0; 00094 maxBufferTriggers=10; 00095 maxBufferLoops=10; 00096 doSorting = kTRUE; 00097 bGet4Debug = kFALSE; 00098 00099 bTriggerAfterData = kFALSE; 00100 00102 iEventNbGap = -1; // -1 = check Off, Gap in event nember between get4 events 00103 uSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in epochs 00104 bSuppressedEpochs = kFALSE;// No Online Change - kFALSE = Normal epoch operation, kTRUE = 24b readout suppressed epoch mode, epoch only just after data 00105 bLongTimeHistos = kFALSE; // Enable some Long duration counts monitoring histos (10 days) 00106 uRocCycleSize = 0; // No Online Change - Size of roc epoch counter cycle in epochs 00107 uMainSyncCycleSize = 0; // No Online Change - Size of the synchronization cycle in Main clock (250MHz) epochs 00108 uNbRocsGet4 = 0; // No Online Change - Nb of Rocs "GET4" in setup 00109 uNbGet4 = 0; // No Online Change - Total Nb of active FEET boards in setup 00110 uSilentMode = 0; // Remove all printouts => Blind mode! 00111 uDebugHistoOn = 0; // No Online Change - Enable/Disable general debug histograms 00112 uDebugPrintOn = 0; // Number of data messages to be printed on screen for debug 00113 uGet4Print = 0; // Number of data messages to be printed on screen for debug 00114 00115 /************* GET4 v1.x debug *******/ 00116 dMaxTot = 300000.0; // Maximal allowed Tot for 24 bits hit building, in ps 00117 bTotHistoEnable = kFALSE; // Enable Tot histograms 00118 bDebugHistoEnable = kFALSE; // Enable the time difference, finetime and DNL histograms 00119 uNbEventsDnlUpdate = 1000; // Nb of events between 2 updates of the DNL histograms 00120 uGet4TimeDiffChip1 = 0; // Index of first chip to be used for time difference histos 00121 uGet4TimeDiffChip2 = 0; // Index of first chip to be used for time difference histos 00122 bChannelRateHistoEnable = kFALSE; // Enable Rate histograms for each channel 00123 bChipRateHistoEnable = kFALSE; // Enable Rate histograms for each chip 00124 /*************************************/ 00125 /*********** free-streaming **********/ 00126 bRawDataMode = kFALSE; // kFALSE = DABC data format, 1 SYNC/Event, kTRUE = RAW DATA format, all messages 00127 bFreeStreaming = kFALSE; // kFALSE = Sync trigger/no trigger, kTRUE= online detection/selection from data 00128 /*************************************/ 00129 00130 for (int n=0;n<MAX_GET4;n++) { 00131 uGet4Mapping[n] = 0; // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here 00132 uGet4Active[n] = 0; // Activated Get4 chips (indexes after remapping => not hardware map !) 00133 uGet4EdgeInversion[n] = 0; // Edges inversion: affect all channels of a GET4 chip 00134 } 00135 00136 iMainReferenceTdc = -1; // No Online Change - TDC used for the reference signals profiles in Detector classes, -1 disable it 00137 iReference1Channel = -1; // No Online Change - Channel used for the 1st reference histogram in Detector classes, -1 disable it 00138 iReference2Channel = -1; // No Online Change - Channel used for the 2nd reference histogram in Detector classes, -1 disable it 00139 } 00140 00141 TGet4v1Param::~TGet4v1Param() 00142 { 00143 SetNbRocsGet4(0); 00144 00145 SetNbGet4(0); 00146 } 00147 00148 Bool_t TGet4v1Param::UpdateFrom(TGo4Parameter* rhs) 00149 { 00150 cout <<"TGet4v1Param::UpdateFrom" << endl; 00151 if(!TGo4Parameter::UpdateFrom(rhs)) return kFALSE; 00152 for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) { 00153 if(rocid>=numRocs) activeRoc[rocid]=kFALSE; 00154 } 00155 return SetConfigRocs(); 00156 } 00157 00158 // Roc functions 00159 Bool_t TGet4v1Param::SetConfigRocs() 00160 { 00161 /* 00162 for (UInt_t rocid=0;rocid<MAX_ROC; rocid++) 00163 { 00164 TGet4v1Event::ConfigRocs[rocid] = rocid < numRocs ? (UInt_t) activeRoc[rocid] : 0; 00165 cout <<"TGet4v1Param::SetConfigRocs sets rocid " << rocid << " to active:" << TGet4v1Event::ConfigRocs[rocid] << endl; 00166 } 00167 */ 00168 return kTRUE; 00169 } 00170 00171 // Get4 functions 00172 void TGet4v1Param::SetNbRocsGet4(UInt_t num) 00173 { 00174 uNbRocsGet4 = num; 00175 00176 if (uNbRocsGet4 > MAX_ROC) uNbRocsGet4 = MAX_ROC; 00177 00178 if (uNbRocsGet4==0) return; 00179 for (unsigned n=0;n<uNbRocsGet4;n++) 00180 uGet4RocsMapping[n] = n; 00181 } 00182 00183 Int_t TGet4v1Param::FindGet4RocId(UInt_t rocid) const 00184 { 00185 for(Int_t iGet4Roc=0; iGet4Roc < (Int_t)uNbRocsGet4; iGet4Roc++) 00186 if(rocid == uGet4RocsMapping[iGet4Roc]) return iGet4Roc; 00187 00188 return -1; 00189 } 00190 00191 UInt_t TGet4v1Param::DefineGet4IndexOffset(UInt_t rocid) const 00192 { 00193 Int_t id = FindGet4RocId(rocid); 00194 return id>=0 ? id*MAX_GET4_PER_ROC : 0; 00195 } 00196 00197 void TGet4v1Param::SetNbGet4(UInt_t num) 00198 { 00199 00200 uNbGet4 = num; 00201 if (uNbGet4>MAX_GET4) uNbGet4 = MAX_GET4; 00202 00203 if (uNbGet4==0) return; 00204 00205 for(UInt_t uGet4Index = 0; uGet4Index < uNbGet4; uGet4Index++) { 00206 // No Online Change - Get4 Mapping: there should be always at least 2*nbfeets entries here 00207 uGet4Mapping[uGet4Index] = uGet4Index; 00208 // Activated Get4 chips (indexes after remapping => not hardware map !) 00209 uGet4Active[uGet4Index] = 0; 00210 // Edges inversion: affect all channels of a GET4 chip 00211 uGet4EdgeInversion[uGet4Index] = 0; 00212 } 00213 } 00214 00215 UInt_t TGet4v1Param::RemapGet4Chip(UInt_t uChip) const 00216 { 00217 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00218 if( uChip == uGet4Mapping[temp_index]) return temp_index; 00219 return uNbGet4; 00220 } 00221 UInt_t TGet4v1Param::RemapGet4Chip(UInt_t roc, UInt_t uChip) const 00222 { 00223 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00224 if( DefineGet4IndexOffset(roc)+uChip == uGet4Mapping[temp_index]) return temp_index; 00225 return uNbGet4; 00226 } 00227 00228 // Data Triggering 00230 Int_t TGet4v1Param::IsTriggerMainChannel( UInt_t tdc, UInt_t channel ) 00231 { 00232 for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00233 { 00234 if( tdc == uMainSelectionTdc[uTrigger] && 00235 channel == uMainSelectionChannel[uTrigger]) 00236 return uTrigger; 00237 } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00238 return -1; 00239 } 00241 Int_t TGet4v1Param::IsTriggerSecChannel( UInt_t tdc, UInt_t channel ) 00242 { 00243 for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00244 { 00245 if( 0 < uNbSecondarySelectionCh[uTrigger]) 00246 { 00247 for(UInt_t uSecondary = 0; uSecondary < uNbSecondarySelectionCh[uTrigger]; uSecondary++) 00248 if( tdc == uSecondarySelectionTdc[uTrigger][uSecondary] && 00249 channel == uSecondarySelectionChannel[uTrigger][uSecondary] ) 00250 return uTrigger; 00251 } // if( 0 < uNbSecondarySelectionCh[iTrigger]) 00252 } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00253 return -1; 00254 } 00256 Int_t TGet4v1Param::GetSecChannelIndex( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) 00257 { 00258 if( 0 < uNbSecondarySelectionCh[uTrigger]) 00259 { 00260 for(UInt_t iSecondary = 0; iSecondary < uNbSecondarySelectionCh[uTrigger]; iSecondary++) 00261 if( tdc == uSecondarySelectionTdc[uTrigger][iSecondary] && 00262 channel == uSecondarySelectionChannel[uTrigger][iSecondary] ) 00263 return iSecondary; 00264 } // if( 0 < uNbSecondarySelectionCh[uTrigger]) 00265 return -1; 00266 } 00267 Bool_t TGet4v1Param::IsMainOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) 00268 { 00269 if( tdc == uMainSelectionTdc[uTrigger] && 00270 channel == uMainSelectionChannel[uTrigger]) 00271 return kTRUE; 00272 else return kFALSE; 00273 } 00274 Bool_t TGet4v1Param::IsSecOfThisTrigger( UInt_t uTrigger, UInt_t tdc, UInt_t channel ) 00275 { 00276 for(UInt_t iSecondary = 0; iSecondary < uNbSecondarySelectionCh[uTrigger]; iSecondary++) 00277 if( tdc == uSecondarySelectionTdc[uTrigger][iSecondary] && 00278 channel == uSecondarySelectionChannel[uTrigger][iSecondary] ) 00279 return kTRUE; 00280 return kFALSE; 00281 } 00282 00283 00284 Bool_t TGet4v1Param::PrintGet4Options() 00285 { 00286 cout<<"*************************************************"<<endl; 00287 cout<<" Option values"<<endl; 00288 cout<<"Trigger after data: "<<bTriggerAfterData<<endl; 00289 cout<<"Event index gap: "<<iEventNbGap<<endl; 00290 cout<<"Sync cycle size: "<<uSyncCycleSize<<" Epochs (1 synch + "<<(uSyncCycleSize-1)<<" Unsynched)"<<endl; 00291 cout<<"Sync cycle size (Main): "<<uMainSyncCycleSize<<" Epochs (1 synch + "<<(uMainSyncCycleSize-1)<<" Unsynched)"<<endl; 00292 cout<<"Nb ROC-GET4 : "<<uNbRocsGet4<<endl; 00293 cout<<"Rocs Mapping : |- "; 00294 for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++) 00295 { 00296 cout.width(2); 00297 cout<<uGet4RocsMapping[temp_index]<<" "; 00298 } 00299 cout<<endl<<" |-> "; 00300 for(UInt_t temp_index = 0; temp_index < uNbRocsGet4; temp_index++) 00301 { 00302 cout.width(2); 00303 cout<<temp_index<<" "; 00304 } 00305 cout<<endl; 00306 cout<<"Nb GET4 chips: "<<uNbGet4<<endl; 00307 cout<<"Get4 Mapping : |- "; 00308 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00309 { 00310 cout.width(2); 00311 cout<<uGet4Mapping[temp_index]<<" "; 00312 } 00313 cout<<endl<<" |-> "; 00314 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00315 { 00316 cout.width(2); 00317 cout<<temp_index<<" "; 00318 } 00319 cout<<endl; 00320 cout<<"Get4 Activated: |- "; 00321 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00322 { 00323 cout.width(2); 00324 cout<<temp_index<<" "; 00325 } 00326 cout<<endl<<" |-> "; 00327 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00328 { 00329 cout.width(2); 00330 cout<<uGet4Active[temp_index]<<" "; 00331 } 00332 cout<<endl; 00333 cout<<"Get4 Inversion: |- "; 00334 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00335 { 00336 cout.width(2); 00337 cout<<temp_index<<" "; 00338 } 00339 cout<<endl<<" |-> "; 00340 for(UInt_t temp_index = 0; temp_index < uNbGet4; temp_index++) 00341 { 00342 cout.width(2); 00343 cout<<uGet4EdgeInversion[temp_index]<<" "; 00344 } 00345 cout<<endl; 00346 cout<<"Nb Get4 message printed: "<<uGet4Print<<endl; 00347 if( 1 == uSilentMode ) 00348 cout<<"Silent Mode : ON "<<endl; 00349 else cout<<"Silent Mode : OFF"<<endl; 00350 if( 1 == uDebugHistoOn ) 00351 cout<<"Debug Histograms: ON "<<endl; 00352 else cout<<"Debug Histograms: OFF"<<endl; 00353 if( 1 == uDebugPrintOn ) 00354 cout<<"Debug Printout: ON "<<endl; 00355 else cout<<"Debug Printout: OFF"<<endl; 00356 cout<<"Chips used for time diff: "<<uGet4TimeDiffChip1<<" and "<<uGet4TimeDiffChip2<<endl; 00357 cout<<"Nb Get4 message printed: "<<uGet4Print<<endl; 00358 cout<<"*************************************************"<<endl; 00359 00360 /************* GET4 v1.0 *************/ 00361 cout<<" Get4 v1.0 Option values"<<endl; 00362 if( kTRUE == b32bReadoutModeGet4v1 ) 00363 cout<<"Readout Mode: 32 bits "<<endl; 00364 else 00365 { 00366 cout<<"Readout Mode: 24 bit"<<endl; 00367 if( kTRUE == bSuppressedEpochs ) 00368 cout<<"Suppressed epoch mode: ON "<<endl; 00369 else cout<<"Suppressed epoch mode: OFF"<<endl; 00370 } // else of if( kTRUE == b32bReadoutModeGet4v1 ) 00371 if( kTRUE == bLongTimeHistos ) 00372 cout<<"Long duration counts mon. hist.: ON "<<endl; 00373 else cout<<"Long duration counts mon. hist.: OFF"<<endl; 00374 cout<<"*************************************************"<<endl; 00375 /*************************************/ 00376 00377 /*********** free-streaming **********/ 00378 if( kTRUE == bFreeStreaming ) 00379 { 00380 cout<<" Free-streaming Option values"<<endl; 00381 for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00382 { 00383 cout<<"Tdc main trigger chan: "<<uMainSelectionTdc[uTrigger]<<endl; 00384 cout<<"Channel main trigger: "<<uMainSelectionChannel[uTrigger]<<endl; 00385 if( 0 < uNbSecondarySelectionCh[uTrigger]) 00386 { 00387 cout<<"Sec. trigger chans: |- "; 00388 for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) 00389 { 00390 cout.width(3); 00391 cout<<temp_index<<" "; 00392 } 00393 cout<<endl<<" TDC |-> "; 00394 for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) 00395 { 00396 cout.width(3); 00397 cout<<uSecondarySelectionTdc[uTrigger][temp_index]<<" "; 00398 } 00399 cout<<endl<<" Channel |-> "; 00400 for(UInt_t temp_index = 0; temp_index < uNbSecondarySelectionCh[uTrigger]; temp_index++) 00401 { 00402 cout.width(3); 00403 cout<<uSecondarySelectionChannel[uTrigger][temp_index]<<" "; 00404 } 00405 cout<<endl; 00406 } 00407 cout<<"Channel main trigger: "<<uMainSelectionChannel[uTrigger]<<endl; 00408 cout<<"Coincidenc Window start: "<<dCoincidenceWindowStart[uTrigger]<<" ns relative to main channel hits"<<endl; 00409 cout<<"Coincidenc Window stop: "<<dCoincidenceWindowStop[uTrigger]<<" ns relative to main channel hits"<<endl; 00410 } // for( UInt_t uTrigger = 0; uTrigger < uNbTriggers; uTrigger++) 00411 cout<<"Deadtime: "<<dDeadTime<<" ns"<<endl; 00412 if( kTRUE == bAllowEventMixing ) 00413 cout<<"Event mixing/superpos.: ON"<<endl; 00414 else cout<<"Event mixing/superpos.: OFF"<<endl; 00415 } // if( kTRUE == bFreeStreaming )// if( kTRUE == bFreeStreaming ) 00416 else if( 9 < triggerSignal ) 00417 cout<<" Use SYNC "<<(triggerSignal- 10)<<" as trigger"<<endl; 00418 else cout<<" Use AUX "<<triggerSignal<<" as trigger"<<endl; 00419 cout<<"*************************************************"<<endl; 00420 /*************************************/ 00421 /************** Detectors ************/ 00422 if(-1 < iMainReferenceTdc ) 00423 { 00424 cout<<" Detectors Option values"<<endl; 00425 cout<<"Tdc reference signals: "<<iMainReferenceTdc<<endl; 00426 if( -1 < iReference1Channel ) 00427 cout<<"Channel reference 1: "<<iReference1Channel<<endl; 00428 else cout<<"Reference 1: OFF"<<endl; 00429 if( -1 < iReference2Channel ) 00430 cout<<"Channel reference 2: "<<iReference2Channel<<endl; 00431 else cout<<"Reference 2: OFF"<<endl; 00432 } // if(-1 < iMainReferenceTdc ) 00433 else cout<<"Reference hist. in det.: OFF"<<endl; 00434 cout<<"*************************************************"<<endl; 00435 /*************************************/ 00436 00437 return kTRUE; 00438 }