Changeset 9318 for trunk/MagicSoft/Mars/msimcamera
- Timestamp:
- 02/11/09 17:35:54 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/msimcamera
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msimcamera/MSimBundlePhotons.cc
r9243 r9318 89 89 90 90 // Read the look-up table 91 if (fLut.ReadFile(fFileName)<0) 91 fLut.Delete(); 92 if (!fFileName.IsNull() && fLut.ReadFile(fFileName)<0) 92 93 return kFALSE; 93 94 94 95 // If the table is empty remove this task from the tasklist 95 96 if (fLut.IsEmpty()) 97 { 98 *fLog << inf << "Look-up table to bundle photons empty... skipping." << endl; 96 99 return kSKIP; 100 } 97 101 98 102 // Now invert the tablee. Otherwise we have to do a lot of … … 103 107 if (!fLut.HasConstantLength() && fLut.GetMaxEntries()!=1) 104 108 return kFALSE; 109 110 *fLog << inf << "Using look-up table from " << fFileName << endl; 105 111 106 112 return kTRUE; -
trunk/MagicSoft/Mars/msimcamera/MSimReadout.cc
r9308 r9318 31 31 // system. 32 32 // 33 // You can give a conversion factor from the unitx of your analog signal 34 // to the units of your adc. This is a fixed factor because it is just 35 // a matter of what the meaning of an adc count is, nothing which could 36 // jitter or is a real part of the electronics. Such effects should 37 // be simulated somewhere else. 38 // 33 39 // 34 40 // Input Containers: … … 73 79 // 74 80 MSimReadout::MSimReadout(const char* name, const char *title) 75 : fRunHeader(0), fEvtHeader(0), fCamera(0), fPulsePos(0), fTrigger(0), fData(0) 81 : fRunHeader(0), fEvtHeader(0), fCamera(0), fPulsePos(0), fTrigger(0), fData(0), 82 fConversionFactor(1) 76 83 { 77 84 fName = name ? name : "MSimReadout"; … … 135 142 136 143 fRunHeader->InitPixels(cam->GetNumPixels()); 137 fRunHeader->SetValidMagicNumber();138 fRunHeader->SetSourceInfo("MonteCarlo"); // "Muon" from first event??139 fRunHeader->SetReadyToSave();140 144 141 145 fData->InitRead(fRunHeader); … … 209 213 } 210 214 211 const Float_t gain = 64./1; 212 const Float_t offset = 128; 215 const Float_t offset = 0;//128; 213 216 const UInt_t max = fData->GetMax(); 214 217 … … 230 233 { 231 234 Float_t slice = j+trig>=(Int_t)sig.GetSize() ? offset : 232 sig[j+trig] * gain+ offset;235 sig[j+trig] * fConversionFactor + offset; 233 236 234 237 // FIXME: Handle/Implement saturation! … … 257 260 return kTRUE; 258 261 } 262 263 // -------------------------------------------------------------------------- 264 // 265 // Read the parameters from the resource file. 266 // 267 // ConversionFactor: 1 268 // 269 Int_t MSimReadout::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 270 { 271 Bool_t rc = kFALSE; 272 if (IsEnvDefined(env, prefix, "ConversionFactor", print)) 273 { 274 rc = kTRUE; 275 fConversionFactor = GetEnvValue(env, prefix, "ConversionFactor", fConversionFactor); 276 } 277 278 return rc; 279 } -
trunk/MagicSoft/Mars/msimcamera/MSimReadout.h
r9308 r9318 24 24 MRawEvtData *fData; //! Digitized FADC signal 25 25 26 Double_t fConversionFactor; // Conversion factor (arbitrary) from analog signal to FADC counts 27 26 28 // MTask 27 29 Int_t PreProcess(MParList *pList); 28 30 Int_t Process(); 29 31 Bool_t ReInit(MParList *pList); 32 33 // MParContainer 34 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE); 30 35 31 36 public: -
trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc
r9308 r9318 82 82 #include "MTriggerPattern.h" 83 83 84 #include "MPedestalCam.h" 85 #include "MPedestalPix.h" 86 84 87 ClassImp(MSimTrigger); 85 88 … … 91 94 // 92 95 MSimTrigger::MSimTrigger(const char *name, const char *title) 93 : fCamera(0), fPulsePos(0), fTrigger(0), fRunHeader(0), fEvtHeader(0), 94 fDiscriminatorThreshold(-1), fDigitalSignalLength(8), fCoincidenceTime(0.5) 96 : fCamera(0), fPulsePos(0), fTrigger(0), fRunHeader(0), 97 fEvtHeader(0), fElectronicNoise(0), fGain(0), 98 fDiscriminatorThreshold(-1), fDigitalSignalLength(8), fCoincidenceTime(0.5), 99 fShiftBaseline(kTRUE), fUngainSignal(kTRUE) 95 100 { 96 101 fName = name ? name : "MSimTrigger"; … … 166 171 } 167 172 173 fElectronicNoise = 0; 174 if (fShiftBaseline) 175 { 176 fElectronicNoise = (MPedestalCam*)pList->FindObject("ElectronicNoise", "MPedestalCam"); 177 if (!fElectronicNoise) 178 { 179 *fLog << err << "ElectronicNoise [MPedestalCam] not found... aborting." << endl; 180 return kFALSE; 181 } 182 *fLog << inf << "Baseline will be shifted back to 0 for discriminator." << endl; 183 } 184 185 fGain = 0; 186 if (fUngainSignal) 187 { 188 fGain = (MPedestalCam*)pList->FindObject("Gain", "MPedestalCam"); 189 if (!fGain) 190 { 191 *fLog << err << "Gain [MPedestalCam] not found... aborting." << endl; 192 return kFALSE; 193 } 194 *fLog << inf << "Discriminator will be multiplied by applied gain." << endl; 195 } 196 168 197 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader"); 169 198 if (!fRunHeader) … … 177 206 return kFALSE; 178 207 179 180 if (fRouteAC.ReadFile(fNameRouteAC)<0) 181 return kFALSE; 182 183 if (fCoincidenceMap.ReadFile(fNameCoincidenceMap)<0) 184 return kFALSE; 208 fRouteAC.Delete(); 209 if (!fNameRouteAC.IsNull() && fRouteAC.ReadFile(fNameRouteAC)<0) 210 return kFALSE; 211 212 fCoincidenceMap.Delete(); 213 if (!fNameCoincidenceMap.IsNull() && fCoincidenceMap.ReadFile(fNameCoincidenceMap)<0) 214 return kFALSE; 215 216 // ---------------- Consistency checks ---------------------- 217 218 if (!fRouteAC.IsEmpty() && !fCoincidenceMap.IsEmpty() && 219 fCoincidenceMap.GetMaxIndex()>fRouteAC.GetNumRows()-1) 220 { 221 *fLog << err; 222 *fLog << "ERROR - AC routing produces " << fRouteAC.GetNumRows() << " analog channels," << endl; 223 *fLog << " but the coincidence map expects at least " << fCoincidenceMap.GetMaxIndex()+1 << " channels." << endl; 224 return kERROR; 225 } 185 226 186 227 if (fDiscriminatorThreshold<=0) … … 190 231 } 191 232 192 *fLog << inf << "Using discriminator threshold of " << fDiscriminatorThreshold << endl; 233 if (fElectronicNoise && !fRouteAC.IsEmpty() && !fRouteAC.IsDefault()) 234 { 235 // FIXME: Apply to analog channels when summing 236 *fLog << warn << "WARNING - A baseline shift doesn't make sense for sum-channels... reset." << endl; 237 fElectronicNoise = 0; 238 } 239 240 if (fGain && !fRouteAC.IsEmpty() && !fRouteAC.IsDefault()) 241 { 242 // FIXME: Apply to analog channels when summing 243 *fLog << warn << "WARNING - Ungain doesn't make sense for sum-channels... reset." << endl; 244 fGain = 0; 245 } 246 247 248 // ---------------- Information output ---------------------- 249 250 *fLog << inf; 251 252 if (fRouteAC.IsEmpty()) 253 *fLog << "Re-routing/summing of analog channels before discriminator switched off." << endl; 254 else 255 *fLog << "Using " << fNameRouteAC << " for re-routing/summing of analog channels before discriminator." << endl; 256 257 if (fCoincidenceMap.IsEmpty()) 258 *fLog << "No coincidences of digital channels will be checked. Signal-above-threshold trigger applied." << endl; 259 else 260 *fLog << "Using " << fNameCoincidenceMap << " to check for coincidences of the digital channels." << endl; 261 262 *fLog << "Using discriminator threshold of " << fDiscriminatorThreshold << endl; 193 263 194 264 return kTRUE; … … 204 274 // ================== Simulate channel bundling ==================== 205 275 206 const UInt_t npatch = fRouteAC.GetEntriesFast(); 207 208 MAnalogChannels patches(npatch, fCamera->GetNumSamples()); 209 210 for (UInt_t i=0; i<npatch; i++) 211 { 212 const MArrayI &row = fRouteAC.GetRow(i); 213 for (UInt_t j=0; j<row.GetSize(); j++) 214 { 215 // FIXME: Simulate clipping 216 const UInt_t idx = row[j]; 217 patches[i].AddSignal((*fCamera)[idx]); 276 // FIXME: Before we can bundle the channels we have to make a copy 277 // and simulate clipping 278 279 // Check if routing should be done 280 const Bool_t empty = fRouteAC.IsEmpty(); 281 282 // If no channels are summed the number of patches stays the same 283 const UInt_t npatch = empty ? fCamera->GetNumChannels() : fRouteAC.GetEntriesFast(); 284 285 // Use the given analog channels as default out. If channels are 286 // summed overwrite with a newly allocated set of analog channels 287 MAnalogChannels *patches = fCamera; 288 if (!empty) 289 { 290 // FIXME: Can we add gain and offset here into a new container? 291 292 patches = new MAnalogChannels(npatch, fCamera->GetNumSamples()); 293 for (UInt_t i=0; i<npatch; i++) 294 { 295 const MArrayI &row = fRouteAC.GetRow(i); 296 for (UInt_t j=0; j<row.GetSize(); j++) 297 { 298 const UInt_t idx = row[j]; 299 (*patches)[i].AddSignal((*fCamera)[idx]); 300 } 218 301 } 219 302 } … … 227 310 228 311 for (UInt_t i=0; i<npatch; i++) 229 ttls.AddAt(patches[i].Discriminate(fDiscriminatorThreshold, fDigitalSignalLength), i); 312 { 313 // FIXME: What if the gain was also allpied to the baseline? 314 const Double_t offset = fElectronicNoise ? (*fElectronicNoise)[i].GetPedestal() : 0; 315 const Double_t gain = fGain ? (*fGain)[i].GetPedestal() : 1; 316 ttls.AddAt((*patches)[i].Discriminate(fDiscriminatorThreshold*gain+offset, fDigitalSignalLength), i); 317 } 230 318 231 319 // FIXME: Write TTLs! 232 320 321 // If analog channels had been newly allocated free memmory 322 if (patches!=fCamera) 323 delete patches; 324 233 325 // =================== Simulate coincidences ====================== 326 327 // If the map is empty we create a one-pixel-coincidence map 328 // FIMXE: This could maybe be accelerated if the Clone can be 329 // omitted in the loop 330 if (fCoincidenceMap.IsEmpty()) 331 fCoincidenceMap.SetDefault(npatch); 234 332 235 333 // Calculate the minimum and maximum time for a valid trigger -
trunk/MagicSoft/Mars/msimcamera/MSimTrigger.h
r9308 r9318 15 15 class MRawEvtHeader; 16 16 class MRawRunHeader; 17 class MPedestalCam; 17 18 18 19 class MSimTrigger : public MTask 19 20 { 20 21 private: 21 MAnalogChannels *fCamera; //! The analog input channels 22 MParameterD *fPulsePos; //! The intended pulse positon 23 MParameterD *fTrigger; //! The trigger position w.r.t. the analog channels 24 MRawRunHeader *fRunHeader; //! The run header storing infos about the digitization 25 MRawEvtHeader *fEvtHeader; //! The event header storing the trigger information 22 MAnalogChannels *fCamera; //! The analog input channels 23 MParameterD *fPulsePos; //! The intended pulse positon 24 MParameterD *fTrigger; //! The trigger position w.r.t. the analog channels 25 MRawRunHeader *fRunHeader; //! The run header storing infos about the digitization 26 MRawEvtHeader *fEvtHeader; //! The event header storing the trigger information 27 MPedestalCam *fElectronicNoise; //! Electronic noise (for baseline correction) 28 MPedestalCam *fGain; //! Gain of the pulses 26 29 27 MLut fRouteAC; // Combinination map for the AC channels28 MLut fCoincidenceMap; // channels for which digital coincidence is checked30 MLut fRouteAC; // Combinination map for the AC channels 31 MLut fCoincidenceMap; // channels for which digital coincidence is checked 29 32 30 TString fNameRouteAC; // Name for the AC routing31 TString fNameCoincidenceMap; // Name for the coincidence mape33 TString fNameRouteAC; // Name for the AC routing 34 TString fNameCoincidenceMap; // Name for the coincidence mape 32 35 33 Float_t fDiscriminatorThreshold; // Discriminator threshold 34 Float_t fDigitalSignalLength; // Length of the output of the discriminator 35 Float_t fCoincidenceTime; // Minimum coincidence time (gate) 36 Float_t fDiscriminatorThreshold; // Discriminator threshold 37 Float_t fDigitalSignalLength; // Length of the output of the discriminator 38 Float_t fCoincidenceTime; // Minimum coincidence time (gate) 39 40 Bool_t fShiftBaseline; // Shift the baseline back to 0 for the threshold (needs ElectronicNoise [MPedestalCam]) 41 Bool_t fUngainSignal; // "Remove" the gain from the signal (needs Gain [MPedestalCam]) 36 42 37 43 // MSimTrigger
Note:
See TracChangeset
for help on using the changeset viewer.