Changeset 2951 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 01/28/04 21:50:34 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
r2867 r2951 17 17 18 18 #pragma link C++ class MPedestalPix+; 19 #pragma link C++ class MHPedestalPixel+; 19 20 #pragma link C++ class MPedestalCam+; 20 21 #pragma link C++ class MPedCalcPedRun+; -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r2917 r2951 58 58 #include "MPedestalCam.h" 59 59 60 #include "MExtractedSignalPix.h" 61 #include "MExtractedSignalCam.h" 62 63 60 64 #include "MGeomCamMagic.h" 61 65 … … 69 73 // 70 74 MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title) 75 : fRawEvt(NULL), fPedestals(NULL), fSignals(NULL) 71 76 { 72 77 fName = name ? name : "MPedCalcPedRun"; … … 75 80 AddToBranchList("fHiGainPixId"); 76 81 AddToBranchList("fHiGainFadcSamples"); 77 } 82 83 Clear(); 84 } 85 86 void MPedCalcPedRun::Clear(const Option_t *o) 87 { 88 89 fNumHiGainSamples = 0; 90 fNumPixels = 0; 91 fNumSamplesTot = 0; 92 fUseHists = kFALSE; 93 94 fRawEvt = NULL; 95 fPedestals = NULL; 96 fSignals = NULL; 97 98 return; 99 100 } 101 78 102 79 103 // -------------------------------------------------------------------------- … … 101 125 return kFALSE; 102 126 127 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam"); 128 129 if (!fSignals && fUseHists) 130 { 131 *fLog << warn << "Cannot find MExtractedSignalCam... will not use histograms!" << endl; 132 fUseHists = kFALSE; 133 } 134 103 135 fNumSamplesTot=0; 104 136 … … 141 173 // the other one 142 174 fNumHiGainSamples = runheader->GetNumSamplesHiGain() & ~1; 175 176 if (fUseHists) 177 fPedestals->InitUseHists(); 143 178 144 179 return kTRUE; … … 170 205 171 206 const Float_t msum = (Float_t)sum; 172 const Float_t msqr = (Float_t)sqr; 173 174 const Float_t higainped = msum/fNumHiGainSamples; 175 const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSamples)/(fNumHiGainSamples-1.)); 176 207 177 208 const UInt_t idx = pixel.GetPixelId(); 178 (*fPedestals)[idx].Set(higainped, higainrms); 209 // 210 // These three lines have been uncommented by Markus Gaug 211 // If anybody needs them, please contact me!! 212 // 213 // const Float_t higainped = msum/fNumHiGainSamples; 214 // const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSamples)/(fNumHiGainSamples-1.)); 215 // (*fPedestals)[idx].Set(higainped, higainrms); 179 216 180 217 fSumx[idx] += msum; … … 182 219 // The old version: 183 220 // 221 // const Float_t msqr = (Float_t)sqr; 184 222 // fSumx2[idx] += msqr; 185 223 // … … 187 225 // 188 226 fSumx2[idx] += msum*msum; 227 228 if (fUseHists) 229 { 230 MExtractedSignalPix &sig = (*fSignals)[idx]; 231 const Float_t signal = sig.GetExtractedSignalHiGain(); 232 const Float_t signalPerSlice = signal/(Float_t)fSignals->GetNumUsedFADCSlices(); 233 (*fPedestals)[idx].FillHists(signalPerSlice); 234 } 189 235 } 190 236 191 237 fPedestals->SetReadyToSave(); 192 238 fNumSamplesTot += fNumHiGainSamples; 239 193 240 194 241 return kTRUE; … … 225 272 226 273 (*fPedestals)[pixid].Set(higainped, higainrms); 274 275 if (fUseHists) 276 (*fPedestals)[pixid].FitCharge(); 277 227 278 } 228 279 -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
r2878 r2951 18 18 class MRawEvtData; 19 19 class MPedestalCam; 20 class MExtractedSignalCam; 20 21 21 22 class MPedCalcPedRun : public MTask … … 25 26 ULong_t fNumSamplesTot; 26 27 27 MRawEvtData *fRawEvt; // raw event data (time slices) 28 MPedestalCam *fPedestals; // Pedestals of all pixels in the camera 28 MRawEvtData *fRawEvt; // raw event data (time slices) 29 MPedestalCam *fPedestals; // Pedestals of all pixels in the camera 30 MExtractedSignalCam *fSignals; // Signals of all pixels in the camera 29 31 30 32 TArrayF fSumx; // sum of values 31 33 TArrayF fSumx2; // sum of squared values 32 34 35 Bool_t fUseHists; 36 33 37 Bool_t ReInit(MParList *pList); 34 38 … … 40 44 MPedCalcPedRun(const char *name=NULL, const char *title=NULL); 41 45 46 void Clear(const Option_t *o=""); 47 48 void SetUseHists(const Bool_t b = kTRUE) { fUseHists = b; } 49 Bool_t IsUseHists() const { return fUseHists; } 50 42 51 ClassDef(MPedCalcPedRun, 0) // Task to calculate pedestals from pedestal runs raw data 43 52 }; -
trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
r2942 r2951 110 110 } 111 111 112 void MPedestalCam::InitUseHists() 113 { 114 fArray->ForEach(MPedestalPix, InitUseHists)(); 115 } 116 112 117 void MPedestalCam::Print(Option_t *o) const 113 118 { … … 175 180 Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const 176 181 { 177 switch (type) 182 183 switch (type) 178 184 { 179 185 case 0: 186 if ((*this)[idx].IsValid()) 180 187 val = (*this)[idx].GetPedestal(); 181 break; 188 else 189 return kFALSE; 190 break; 182 191 case 1: 192 if ((*this)[idx].IsValid()) 183 193 val = (*this)[idx].GetPedestalRms(); 184 break; 194 else 195 return kFALSE; 196 break; 197 case 2: 198 // if ((*this)[idx].IsFitValid()) 199 val = (*this)[idx].GetMean(); 200 // else 201 // return kFALSE; 202 break; 203 case 3: 204 // if ((*this)[idx].IsFitValid()) 205 val = (*this)[idx].GetMeanErr(); 206 // else 207 // return kFALSE; 208 break; 209 case 4: 210 // if ((*this)[idx].IsFitValid()) 211 val = (*this)[idx].GetSigma(); 212 // else 213 // return kFALSE; 214 break; 215 case 5: 216 // if ((*this)[idx].IsFitValid()) 217 val = (*this)[idx].GetSigmaErr(); 218 // else 219 // return kFALSE; 220 break; 221 case 6: 222 // if ((*this)[idx].IsFitValid()) 223 val = (*this)[idx].GetProb(); 224 // else 225 // return kFALSE; 226 break; 227 case 7: 228 // if ((*this)[idx].IsFitValid()) 229 val = ((*this)[idx].GetPedestal()-(*this)[idx].GetMean()); 230 // else 231 // return kFALSE; 232 break; 233 case 8: 234 // if ((*this)[idx].IsFitValid()) 235 val = ((*this)[idx].GetPedestalRms()-(*this)[idx].GetSigma()); 236 // else 237 // return kFALSE; 238 break; 185 239 default: 186 187 } 188 return val>=0;189 } 190 191 void MPedestalCam::DrawPixelContent(Int_t num) const192 { 193 *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;194 } 240 return kFALSE; 241 } 242 return kTRUE; 243 } 244 245 void MPedestalCam::DrawPixelContent(Int_t idx) const 246 { 247 (*this)[idx].Draw(); 248 } -
trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
r2942 r2951 21 21 22 22 void Clear(Option_t *o=""); 23 23 void InitUseHists(); 24 24 25 void InitSize(const UInt_t i); 25 26 Int_t GetSize() const; … … 34 35 35 36 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; 36 void DrawPixelContent(Int_t num) const;37 void DrawPixelContent(Int_t idx) const; 37 38 38 39 ClassDef(MPedestalCam, 1) // Storage Container for all pedestal information of the camera -
trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
r2929 r2951 34 34 35 35 #include "MLog.h" 36 #include "MLogManip.h" 36 37 37 38 ClassImp(MPedestalPix); 38 39 39 MPedestalPix::MPedestalPix() 40 using namespace std; 41 42 MPedestalPix::MPedestalPix() : fHist(NULL), fFlags(0) 40 43 { 41 44 Clear(); 42 45 } 46 47 MPedestalPix::~MPedestalPix() 48 { 49 if (fHist) 50 delete fHist; 51 } 52 43 53 44 54 // ------------------------------------------------------------------------ … … 48 58 void MPedestalPix::Clear(Option_t *o) 49 59 { 50 fPedestal = 0.; 51 fPedestalRms = 0.; 60 fPedestal = -1.; 61 fPedestalRms = -1.; 62 63 fMean = -1.; 64 fMeanErr = -1.; 65 fSigma = -1.; 66 fProb = -1.; 67 68 CLRBIT(fFlags,kFitted); 69 CLRBIT(fFlags,kFitValid); 70 52 71 } 53 72 73 void MPedestalPix::InitUseHists() 74 { 75 fPedestal = 0.; 76 fPedestalRms = 0.; 77 78 fHist = new MHPedestalPixel("MHPedestalPixel","Pedestal Histograms Pixel "); 79 80 if (!fHist) 81 *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl; 82 83 } 84 85 void MPedestalPix::FillHists(const Float_t f) 86 { 87 88 if (!fHist) 89 return; 90 91 fHist->FillCharge(f); 92 fHist->FillChargevsN(f); 93 } 94 95 96 void MPedestalPix::Set(Float_t m, Float_t r) 97 { 98 fPedestal = m; 99 fPedestalRms = r; 100 } 101 102 Bool_t MPedestalPix::IsValid() const 103 { 104 return fPedestal>=0||fPedestalRms>=0; 105 } 106 107 Bool_t MPedestalPix::IsFitted() const 108 { 109 return TESTBIT(fFlags,kFitted); 110 } 111 112 Bool_t MPedestalPix::IsFitValid() const 113 { 114 return TESTBIT(fFlags,kFitValid); 115 } 116 117 // -------------------------------------------------------------------------- 118 // 119 // 1) Return if the charge distribution is already succesfully fitted 120 // or if the histogram is empty 121 // 2) Cut the histograms empty edges 122 // 3) Fit the histograms with a Gaussian 123 // 4) In case of failure print out the fit results 124 // 5) Retrieve the results and store them in this class 125 // 126 void MPedestalPix::FitCharge() 127 { 128 129 // 130 // 1) Return if the charge distribution is already succesfully fitted 131 // or if the histogram is empty 132 // 133 if (fHist->IsFitOK() || fHist->IsEmpty()) 134 return; 135 136 137 fHist->CutAllEdges(); 138 139 // 140 // 2) Fit the Lo Gain histograms with a Gaussian 141 // 142 if(fHist->FitCharge()) 143 SETBIT(fFlags,kFitted); 144 else 145 CLRBIT(fFlags,kFitted); 146 147 // 148 // 6) Retrieve the results and store them in this class 149 // 150 fMean = fHist->GetChargeMean(); 151 fMeanErr = fHist->GetChargeMeanErr(); 152 fSigma = fHist->GetChargeSigma(); 153 fSigmaErr = fHist->GetChargeSigmaErr(); 154 fProb = fHist->GetChargeProb(); 155 156 if (CheckFitValidity()) 157 SETBIT(fFlags,kFitValid); 158 else 159 CLRBIT(fFlags,kFitValid); 160 161 return; 162 } 163 164 Bool_t MPedestalPix::CheckFitValidity() 165 { 166 167 if (fProb < 0.001) 168 return kFALSE; 169 170 return kTRUE; 171 172 } -
trunk/MagicSoft/Mars/manalysis/MPedestalPix.h
r2237 r2951 6 6 #endif 7 7 8 #ifndef MARS_MHPedestalPixel 9 #include "MHPedestalPixel.h" 10 #endif 11 12 class MHPedestalPixel; 8 13 class MPedestalPix : public MParContainer 9 14 { … … 12 17 Float_t fPedestalRms; // root mean square / sigma / standard deviation of pedestal 13 18 19 MHPedestalPixel *fHist; // Pointer to the histograms performing the fits, etc. 20 21 Float_t fMean; 22 Float_t fMeanErr; 23 Float_t fSigma; 24 Float_t fSigmaErr; 25 Float_t fProb; 26 27 Byte_t fFlags; 28 29 enum { kFitted, kFitValid }; 30 14 31 public: 15 32 MPedestalPix(); 16 33 ~MPedestalPix(); 34 17 35 void Clear(Option_t *o=""); 18 36 19 Float_t GetPedestal() const { return fPedestal; } 37 // Using histograms 38 void InitUseHists(); 39 void FillHists(const Float_t f); 40 41 // Setters 42 void SetPedestal(const Float_t f) { fPedestal = f; } 43 void SetPedestalRms(const Float_t f) { fPedestalRms = f; } 44 45 void Set(const Float_t m, const Float_t r); 46 47 // Getters 48 Float_t GetPedestal() const { return fPedestal; } 20 49 Float_t GetPedestalRms() const { return fPedestalRms; } 21 /*22 void SetMean(Float_t f) { fMean = f; }23 void SetSigma(Float_t f) { fSigma = f; }24 void SetMeanRms(Float_t f) { fMeanRms = f; }25 void SetSigmaRms(Float_t f) { fSigmaRms = f; }26 */27 50 28 void SetPedestal(Float_t f) { fPedestal = f; } 29 void SetPedestalRms(Float_t f) { fPedestalRms = f; } 30 void Set(Float_t m, Float_t r) { fPedestal = m; fPedestalRms = r; } 31 32 Bool_t IsValid() const { return fPedestal>=0||fPedestalRms>=0; } 51 Float_t GetMean() const { return fMean; } 52 Float_t GetMeanErr() const { return fMeanErr; } 53 Float_t GetSigma() const { return fSigma; } 54 Float_t GetSigmaErr() const { return fSigmaErr; } 55 Float_t GetProb() const { return fProb; } 56 57 Bool_t IsValid() const; 58 Bool_t IsFitted() const; 59 Bool_t IsFitValid() const; 60 61 // Fits 62 void FitCharge(); 63 Bool_t CheckFitValidity(); 64 65 // Draws 66 void Draw(Option_t *opt="") { fHist->Draw(opt); } 67 TObject *DrawClone(Option_t *opt="") const { return fHist->DrawClone(opt); } 33 68 34 69 ClassDef(MPedestalPix, 1) // Storage Container for Pedestal information of one pixel -
trunk/MagicSoft/Mars/manalysis/Makefile
r2867 r2951 33 33 34 34 SRCFILES = MPedestalPix.cc \ 35 MHPedestalPixel.cc \ 35 36 MPedestalCam.cc \ 36 37 MPedPhotPix.cc \
Note:
See TracChangeset
for help on using the changeset viewer.