Changeset 3014 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 02/04/04 15:01:19 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
r2951 r3014 33 33 TArrayF fSumx2; // sum of squared values 34 34 35 Bool_t fUseHists;36 37 35 Bool_t ReInit(MParList *pList); 38 36 … … 46 44 void Clear(const Option_t *o=""); 47 45 48 void SetUseHists(const Bool_t b = kTRUE) { fUseHists = b; }49 Bool_t IsUseHists() const { return fUseHists; }50 51 46 ClassDef(MPedCalcPedRun, 0) // Task to calculate pedestals from pedestal runs raw data 52 47 }; -
trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
r2983 r3014 17 17 ! 18 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2001 19 ! Markus Gaug 02/2004 <mailto:markus@ifae.es> 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2004 21 22 ! 22 23 ! … … 38 39 #include "MLogManip.h" 39 40 41 #include "MParList.h" 42 43 #include "MHExtractedSignalPix.h" 44 45 #include "MExtractedSignalCam.h" 46 #include "MExtractedSignalPix.h" 47 40 48 #include "MGeomCam.h" 41 49 … … 44 52 using namespace std; 45 53 54 const UInt_t MPedestalCam::gkBlindPixelId = 559; 46 55 // -------------------------------------------------------------------------- 47 56 // … … 49 58 // 50 59 MPedestalCam::MPedestalCam(const char *name, const char *title) 51 : f NumTotSlices(0), fNumExtractSlices(0), fUseHists(kFALSE)60 : fTotalEntries(0), fExtractSlices(0.) 52 61 { 53 62 fName = name ? name : "MPedestalCam"; … … 56 65 fArray = new TClonesArray("MPedestalPix", 1); 57 66 67 // 68 // loop over all Pixels and create two histograms 69 // one for the Low and one for the High gain 70 // connect all the histogram with the container fHist 71 // 72 fHArray = new TObjArray; 73 fHArray->SetOwner(); 74 58 75 } 59 76 … … 64 81 MPedestalCam::~MPedestalCam() 65 82 { 66 delete fArray; 83 delete fArray; 84 delete fHArray; 67 85 } 68 86 … … 85 103 Int_t MPedestalCam::GetSize() const 86 104 { 87 return fArray->GetEntriesFast(); 88 } 105 return fArray->GetEntriesFast(); 106 } 107 108 Int_t MPedestalCam::GetHistSize() const 109 { 110 return fHArray->GetEntriesFast(); 111 } 112 89 113 90 114 // -------------------------------------------------------------------------- … … 106 130 } 107 131 132 // -------------------------------------------------------------------------- 133 // 134 // Get i-th pixel (pixel number) 135 // 136 MHPedestalPixel &MPedestalCam::operator()(UInt_t i) 137 { 138 return *static_cast<MHPedestalPixel*>(fHArray->UncheckedAt(i)); 139 } 140 141 // -------------------------------------------------------------------------- 142 // 143 // Get i-th pixel (pixel number) 144 // 145 const MHPedestalPixel &MPedestalCam::operator()(UInt_t i) const 146 { 147 return *static_cast<MHPedestalPixel*>(fHArray->UncheckedAt(i)); 148 } 149 150 151 // ------------------------------------------------------------------------- 152 // 108 153 void MPedestalCam::Clear(Option_t *o) 109 154 { 155 110 156 fArray->ForEach(TObject, Clear)(); 111 112 fNumTotSlices = 0; 113 fNumExtractSlices = 0; 114 } 115 116 void MPedestalCam::InitUseHists() 117 { 118 fArray->ForEach(MPedestalPix, InitUseHists)(); 119 120 fUseHists = kTRUE; 121 } 157 // fHArray->ForEach(TObject, Clear)(); 158 159 fTotalEntries = 0; 160 fExtractSlices = 0.; 161 } 162 163 // -------------------------------------------------------------------------- 164 // 165 // To setup the object we get the number of pixels from a MGeomCam object 166 // in the Parameter list. 167 // MPedestalPix sets its parameters to 0. (other than default which is -1.) 168 // 169 Bool_t MPedestalCam::SetupFill(const MParList *pList) 170 { 171 172 fArray->ForEach(MPedestalPix, InitUseHists)(); 173 fHArray->Delete(); 174 175 return kTRUE; 176 177 } 178 179 // -------------------------------------------------------------------------- 180 // 181 Bool_t MPedestalCam::Fill(const MParContainer *par, const Stat_t w) 182 { 183 184 MExtractedSignalCam *signal = (MExtractedSignalCam*)par; 185 if (!signal) 186 { 187 gLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl; 188 return kFALSE; 189 } 190 191 Float_t slices = (Float_t)signal->GetNumUsedFADCSlices(); 192 193 if (slices == 0.) 194 { 195 gLog << err << "Number of used signal slices in MExtractedSignalCam is zero ... abort." 196 << endl; 197 return kFALSE; 198 } 199 200 if (fExtractSlices != 0. && slices != fExtractSlices ) 201 { 202 gLog << err << "Number of used signal slices changed in MExtractedSignalCam ... abort." 203 << endl; 204 return kFALSE; 205 } 206 207 fExtractSlices = slices; 208 209 const Int_t n = signal->GetSize(); 210 211 if (fHArray->GetEntries()==0) 212 { 213 fHArray->Expand(n); 214 215 for (Int_t i=0; i<n; i++) 216 { 217 (*fHArray)[i] = new MHPedestalPixel; 218 MHPedestalPixel &hist = (*this)(i); 219 hist.ChangeHistId(i); 220 } 221 } 222 223 if (fHArray->GetEntries() != n) 224 { 225 gLog << err << "ERROR - Size mismatch... abort." << endl; 226 return kFALSE; 227 } 228 229 for (Int_t i=0; i<n; i++) 230 { 231 const MExtractedSignalPix &pix = (*signal)[i]; 232 233 const Float_t sig = pix.GetExtractedSignalHiGain(); 234 const Float_t sigPerSlice = sig/fExtractSlices; 235 236 MHPedestalPixel &hist = (*this)(i); 237 238 hist.FillCharge(sigPerSlice); 239 hist.FillChargevsN(sigPerSlice); 240 } 241 242 return kTRUE; 243 } 244 245 Bool_t MPedestalCam::Finalize() 246 { 247 for (Int_t i=0; i<fHArray->GetSize(); i++) 248 { 249 MHPedestalPixel &hist = (*this)(i); 250 251 // 252 // 1) Return if the charge distribution is already succesfully fitted 253 // or if the histogram is empty 254 // 255 if (hist.IsFitOK() || hist.IsEmpty()) 256 continue; 257 258 hist.CutAllEdges(); 259 260 // 261 // 2) Fit the Hi Gain histograms with a Gaussian 262 // 263 hist.FitCharge(); 264 } 265 return kTRUE; 266 } 267 122 268 123 269 void MPedestalCam::Print(Option_t *o) const … … 190 336 return kFALSE; 191 337 192 if ( idx == 559)338 if ((UInt_t)idx == gkBlindPixelId) 193 339 return kFALSE; 194 340 … … 196 342 const Float_t rms = (*this)[idx].GetPedestalRms(); 197 343 198 const Float_t pederr = rms/TMath::Sqrt((Float_t)fNumTotSlices); 199 const Float_t rmserr = rms/TMath::Sqrt((Float_t)fNumTotSlices/2.); 200 201 const Float_t mean = (*this)[idx].GetMean() / (Float_t)fNumExtractSlices; 202 const Float_t meanerr = (*this)[idx].GetMeanErr() / (Float_t)fNumExtractSlices; 203 const Float_t sigma = (*this)[idx].GetSigma() / TMath::Sqrt((Float_t) fNumExtractSlices); 204 const Float_t sigmaerr = (*this)[idx].GetSigmaErr() / TMath::Sqrt((Float_t) fNumExtractSlices); 344 const Float_t pederr = rms/TMath::Sqrt((Float_t)fTotalEntries); 345 const Float_t rmserr = rms/TMath::Sqrt((Float_t)fTotalEntries/2.); 346 347 const MHPedestalPixel &hist = (*this)(idx); 348 349 const Float_t mean = hist.GetChargeMean(); 350 const Float_t meanerr = hist.GetChargeMeanErr() * TMath::Sqrt((Float_t)fExtractSlices); 351 const Float_t sigma = hist.GetChargeSigma() * TMath::Sqrt((Float_t)fExtractSlices); 352 const Float_t sigmaerr = hist.GetChargeSigmaErr()* TMath::Sqrt((Float_t)fExtractSlices); 353 const Float_t prob = hist.GetChargeProb(); 205 354 206 355 switch (type) … … 244 393 case 8: 245 394 // if ((*this)[idx].IsFitValid()) 246 val = (*this)[idx].GetProb();395 val = prob; 247 396 // else 248 397 // return kFALSE; -
trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
r2969 r3014 2 2 #define MARS_MPedestalCam 3 3 4 #ifndef ROOT_TObjArray 5 #include <TObjArray.h> 6 #endif 7 8 #ifndef MARS_MH 9 #include "MH.h" 10 #endif 4 11 #ifndef MARS_MParContainer 5 12 #include "MParContainer.h" … … 13 20 class MGeomCam; 14 21 class MPedestalPix; 22 class MHPedestalPixel; 15 23 16 class MPedestalCam : public M ParContainer, public MCamEvent24 class MPedestalCam : public MH, public MCamEvent 17 25 { 18 private:19 TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer?20 26 21 ULong_t fNumTotSlices; 22 Byte_t fNumExtractSlices; 27 private: 23 28 24 Bool_t fUseHists; 25 29 static const UInt_t gkBlindPixelId; 30 31 TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer? 32 33 TObjArray *fHArray; //-> List of Lo/Hi gain Histograms 34 35 ULong_t fTotalEntries; 36 Float_t fExtractSlices; 37 26 38 public: 27 MPedestalCam(const char *name=NULL, const char *title=NULL); 28 ~MPedestalCam(); 39 MPedestalCam(const char *name=NULL, const char *title=NULL); 40 ~MPedestalCam(); 41 42 void Clear(Option_t *o=""); 43 44 void InitSize(const UInt_t i); 45 46 MPedestalPix &operator[](Int_t i); 47 MPedestalPix &operator[](Int_t i) const; 48 49 MHPedestalPixel &operator()(UInt_t i); 50 const MHPedestalPixel &operator()(UInt_t i) const; 51 52 Bool_t SetupFill(const MParList *pList); 53 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 54 Bool_t Finalize(); 55 56 // TObject *Clone(const char *) const; 57 58 // Setters 59 void SetTotalEntries(ULong_t n) { fTotalEntries = n; } 29 60 30 void Clear(Option_t *o=""); 31 32 void InitSize(const UInt_t i); 33 34 void InitUseHists(); 35 36 MPedestalPix &operator[](Int_t i); 37 MPedestalPix &operator[](Int_t i) const; 38 39 // Setters 40 void SetNumTotSlices(ULong_t n) { fNumTotSlices = n; } 41 void SetNumExtractSlices(Byte_t n) { fNumExtractSlices = n; } 42 43 // Getters 44 Int_t GetSize() const; 45 Float_t GetPedestalMin(const MGeomCam *cam) const; 46 Float_t GetPedestalMax(const MGeomCam *cam) const; 47 Bool_t IsUseHists() const { return fUseHists; } 48 49 50 void Print(Option_t *o="") const; 51 52 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; 53 void DrawPixelContent(Int_t idx) const; 54 55 ClassDef(MPedestalCam, 1) // Storage Container for all pedestal information of the camera 61 // Getters 62 Int_t GetSize() const; 63 Int_t GetHistSize() const; 64 ULong_t GetTotalEntries() const { return fTotalEntries; } 65 Float_t GetPedestalMin(const MGeomCam *cam) const; 66 Float_t GetPedestalMax(const MGeomCam *cam) const; 67 68 void Print(Option_t *o="") const; 69 70 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const; 71 void DrawPixelContent(Int_t idx) const; 72 73 ClassDef(MPedestalCam, 1) // Storage Container for all pedestal information of the camera 56 74 }; 57 75 -
trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
r2951 r3014 40 40 using namespace std; 41 41 42 MPedestalPix::MPedestalPix() : fHist(NULL), fFlags(0)42 MPedestalPix::MPedestalPix() 43 43 { 44 44 Clear(); 45 45 } 46 46 47 MPedestalPix::~MPedestalPix()48 {49 if (fHist)50 delete fHist;51 }52 53 47 54 48 // ------------------------------------------------------------------------ … … 61 55 fPedestalRms = -1.; 62 56 63 fMean = -1.;64 fMeanErr = -1.;65 fSigma = -1.;66 fProb = -1.;67 68 CLRBIT(fFlags,kFitted);69 CLRBIT(fFlags,kFitValid);70 71 57 } 72 58 … … 75 61 fPedestal = 0.; 76 62 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 63 } 94 64 … … 105 75 } 106 76 107 Bool_t MPedestalPix::IsFitted() const108 {109 return TESTBIT(fFlags,kFitted);110 }111 112 Bool_t MPedestalPix::IsFitValid() const113 {114 return TESTBIT(fFlags,kFitValid);115 }116 117 // --------------------------------------------------------------------------118 //119 // 1) Return if the charge distribution is already succesfully fitted120 // or if the histogram is empty121 // 2) Cut the histograms empty edges122 // 3) Fit the histograms with a Gaussian123 // 4) In case of failure print out the fit results124 // 5) Retrieve the results and store them in this class125 //126 void MPedestalPix::FitCharge()127 {128 129 //130 // 1) Return if the charge distribution is already succesfully fitted131 // or if the histogram is empty132 //133 if (fHist->IsFitOK() || fHist->IsEmpty())134 return;135 136 137 fHist->CutAllEdges();138 139 //140 // 2) Fit the Lo Gain histograms with a Gaussian141 //142 if(fHist->FitCharge())143 SETBIT(fFlags,kFitted);144 else145 CLRBIT(fFlags,kFitted);146 147 //148 // 6) Retrieve the results and store them in this class149 //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 else159 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
r2997 r3014 18 18 Float_t fPedestalRms; // root mean square / sigma / standard deviation of pedestal 19 19 20 MHPedestalPixel *fHist; // Pointer to the histograms performing the fits, etc.21 22 Float_t fMean;23 Float_t fMeanErr;24 Float_t fSigma;25 Float_t fSigmaErr;26 Float_t fProb;27 28 Byte_t fFlags;29 30 enum { kFitted, kFitValid };31 20 32 21 public: 33 22 MPedestalPix(); 34 ~MPedestalPix();35 23 36 24 void Clear(Option_t *o=""); … … 38 26 // Using histograms 39 27 void InitUseHists(); 40 void FillHists(const Float_t f);41 28 42 29 // Setters … … 47 34 48 35 // Getters 49 MHPedestalPixel *GetHist() const { return fHist; }50 51 36 Float_t GetPedestal() const { return fPedestal; } 52 37 Float_t GetPedestalRms() const { return fPedestalRms; } 53 38 54 Float_t GetMean() const { return fMean; }55 Float_t GetMeanErr() const { return fMeanErr; }56 Float_t GetSigma() const { return fSigma; }57 Float_t GetSigmaErr() const { return fSigmaErr; }58 Float_t GetProb() const { return fProb; }59 60 39 Bool_t IsValid() const; 61 Bool_t IsFitted() const; 62 Bool_t IsFitValid() const; 63 64 // Fits 65 void FitCharge(); 66 Bool_t CheckFitValidity(); 67 68 // Draws 69 void Draw(Option_t *opt="") { fHist->Draw(opt); } 70 TObject *DrawClone(Option_t *opt="") const { return fHist->DrawClone(opt); } 71 40 72 41 ClassDef(MPedestalPix, 1) // Storage Container for Pedestal information of one pixel 73 42 };
Note:
See TracChangeset
for help on using the changeset viewer.