Changeset 9318 for trunk/MagicSoft/Mars
- Timestamp:
- 02/11/09 17:35:54 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9317 r9318 129 129 - corrected the emitted trigger positon 130 130 - (re)set calibration pattern 131 132 * mbase/MLut.[h,cc]: 133 - added overload of Delete() function 134 - added IsDefault 135 - added SetDefault 136 137 * mfileio/MWriteRootFile.cc: 138 - fixed output in OpenFile 139 140 * mjobs/MSequence.cc: 141 - allow the "Night" resource to be empty 142 143 * msimcamera/MSimBundlePhotons.cc: 144 - some small improvements in case of empty maps 145 146 * msimcamera/MSimReadout.[h,cc]: 147 - reset gain. Use the new fConversionFactor instead 148 - removed some setting of fRunHeader 149 150 * msimcamera/MSimTrigger.[h,cc]: 151 - on useer request now offset and gain can be used to 152 convert the signal back into units of phe 153 - added possibility to use empty lookup tables 154 - added debug output 155 131 156 132 157 -
trunk/MagicSoft/Mars/mbase/MLut.cc
r9257 r9318 57 57 } 58 58 59 void MLut::Delete(Option_t *option) 60 { 61 TObjArray::Delete(option); 62 63 fMaxEntries = 0; 64 fMinEntries = 0; 65 66 fMaxIndex = -1; 67 } 68 69 // -------------------------------------------------------------------------- 70 // 71 // Check if it is a default lut which would just map every entry to itself 72 // An empty Lut is a default lut 73 // 74 Bool_t MLut::IsDefault() const 75 { 76 if (IsEmpty()) 77 return kTRUE; 78 79 if (!HasConstantLength() || fMaxEntries!=1) 80 return kFALSE; 81 82 // Loop over all rows 83 for (Int_t y=0; y<GetEntriesFast(); y++) 84 if (GetRow(y)[0]!=y) 85 return kFALSE; 86 87 return kTRUE; 88 } 89 90 // -------------------------------------------------------------------------- 91 // 92 // Setup a default lut which just maps n-entris to themself 93 // 94 void MLut::SetDefault(UInt_t n) 95 { 96 Delete(); 97 98 for (UInt_t y=0; y<n; y++) 99 { 100 101 MArrayI &idx = *new MArrayI(1); 102 idx[0] = y; 103 Add(&idx); 104 } 105 106 fMinEntries = 1; 107 fMaxEntries = 1; 108 109 fMaxIndex = n; 110 } 111 59 112 // -------------------------------------------------------------------------- 60 113 // … … 165 218 MLut *lut = GetInverse(uniq); 166 219 167 Delete(); 220 // Keep fMaxIndex 221 TObjArray::Delete(); 168 222 169 223 for (Int_t i=0; i<=fMaxIndex; i++) … … 188 242 { 189 243 Delete(); 190 191 fMaxIndex = -1;192 fMaxEntries = 0;193 fMinEntries = 0;194 244 195 245 while (1) -
trunk/MagicSoft/Mars/mbase/MLut.h
r9255 r9318 13 13 { 14 14 private: 15 UInt_t fMinEntries; 16 UInt_t fMaxEntries; 15 UInt_t fMinEntries; // The minimum entries per row 16 UInt_t fMaxEntries; // The maximum entries per row 17 17 18 Int_t fMaxIndex; 18 Int_t fMaxIndex; // The maximum index fount in the lut 19 19 20 20 MLut *GetInverse(Bool_t uniq=kTRUE) const; 21 21 22 22 public: 23 MLut() : fMinEntries(0), fMaxEntries(0) { SetOwner(); } 23 MLut() : fMinEntries(0), fMaxEntries(0), fMaxIndex(0) { SetOwner(); } 24 25 // TObjArry 26 void Delete(Option_t *option=""); 24 27 25 28 // MLut Getter 26 29 const MArrayI &GetRow(UInt_t i) const; 30 31 Int_t GetNumRows() const { return GetEntriesFast(); } 27 32 28 33 UInt_t GetMaxEntries() const { return fMaxEntries; } … … 31 36 Bool_t HasConstantLength() const { return fMinEntries==fMaxEntries; } 32 37 Bool_t IsEmpty() const { return fMaxEntries==0; } 38 Bool_t IsDefault() const; 33 39 34 // MLut conver tions40 // MLut conversions 35 41 void SetInverse(const MLut &lut, Bool_t uniq=kTRUE); 36 42 void Invert(Bool_t uniq=kTRUE); 43 44 // Setter 45 void SetDefault(UInt_t n); 37 46 38 47 // MLut I/O -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r9315 r9318 123 123 if (TString(obj->GetName())=="/dev/null" && TString(obj->GetTitle())==title) 124 124 { 125 *fLog << inf 3 << "Found file '/dev/null' <Title=" << title << ">" << endl;125 *fLog << inf2 << "Found open file '/dev/null' <Title=" << title << ">... re-using." << endl; 126 126 file = dynamic_cast<TFile*>(obj); 127 127 break; … … 138 138 gSystem->ExpandPathName(fqp); 139 139 file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(fqp)); 140 } 141 142 if (file) 143 { 144 *fLog << inf2; 145 *fLog << "Found open file '" << name << "'... re-using." << endl; 146 *fLog << inf3; 147 *fLog << "Make sure that you do NOT write to trees which are" << endl; 148 *fLog << "scheduled already by a different MWriteRootFile..." << endl; 140 149 } 141 150 } … … 162 171 SetBit(kIsNotOwner); 163 172 164 *fLog << inf;165 *fLog << "File '" << name << "' already open... using." << endl;166 *fLog << inf3;167 *fLog << "Make sure that you do NOT write to trees which are" << endl;168 *fLog << "scheduled already by a different MWriteRootFile..." << endl;169 173 return fOut; 170 174 } -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r9186 r9318 890 890 891 891 str = GetEnvValue2(env, prefix, "Night", ""); 892 str += " 00:00:00"; 893 fNight.SetSqlDateTime(str); 892 if (str.IsNull()) 893 fNight = MTime(); 894 else 895 { 896 str += " 00:00:00"; 897 fNight.SetSqlDateTime(str); 898 } 894 899 895 900 fPeriod = fNight.GetMagicPeriod(); -
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.