Changeset 2752 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 01/06/04 16:12:03 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc
r2638 r2752 27 27 // MArrivalTime 28 28 // 29 // P R E L I M I N A R Y30 // Do not use this container. It has yet to be defined.29 // Times are calculated using the TSpline5 Root Class 30 // 31 31 ///////////////////////////////////////////////////////////////////////////// 32 32 #include "MArrivalTime.h" … … 55 55 56 56 // 57 // Calculates the arrival time for each pixel (for now, simply by finding the peak) 57 // Calculates the arrival time for each pixel 58 // Possible Methods 59 // Case 1: Spline5 (From TSpline5 Root Class) 60 // 58 61 // 59 62 … … 66 69 67 70 MRawEvtPixelIter pixel((MRawEvtData*)&evt); 68 69 Int_t saturatedpixels = 0; 70 71 71 72 while ( pixel.Next() ) 72 73 { 73 74 const UInt_t idx = pixel.GetPixelId(); 74 75 75 Byte_t *ptr = pixel.GetHiGainSamples(); 76 //If pixel has saturated and hasn't lo gains we return -1 76 77 77 Int_t n = evt.GetNumHiGainSamples(); 78 if (pixel.GetMaxHiGainSample() == 0xff) 79 { 80 if (!pixel.HasLoGain()) 81 { 82 fData[idx]=-1.0; 83 } 84 else //Calculate time using Lo Gains 85 { 86 Byte_t *ptr = pixel.GetLoGainSamples(); 78 87 79 Int_t i; 88 Int_t nSlice = evt.GetNumLoGainSamples(); 89 //Some casts are needed because TSpline5 constructor accepts only Double_t values 90 Double_t ptr2[nSlice]; 91 for (Int_t i = 0; i < nSlice; i++) 92 ptr2[i]=(Double_t)ptr[i]; 93 TSpline5 *spline = new TSpline5("spline",(Double_t) 0,(Double_t)(nSlice - 1),ptr2,nSlice); 94 Double_t abscissa=0.0; 95 Double_t maxAb=0.0; 96 Double_t maxOrd=0.0; 97 Double_t swap; 98 while (abscissa <= nSlice - 1) 99 { 100 swap=spline->Eval(abscissa); 101 if (swap > maxOrd) 102 { 103 maxOrd = swap; 104 maxAb = abscissa; 105 } 106 abscissa += 0.1; 107 } 108 fData[idx]=maxAb; 109 } 110 } 111 else //Calculate time using Hi Gains 112 { 113 Byte_t *ptr = pixel.GetHiGainSamples(); 80 114 81 Double_t arrtime = 0; 82 83 Double_t maxsign = 0; 84 85 for (i=0; i<n; i++) 86 { 87 if (ptr[i]==0xff) 88 break; 89 if (ptr[i]>maxsign) 90 { 91 maxsign = ptr[i]; 92 arrtime = i+1; 93 } 115 Int_t nSlice = evt.GetNumHiGainSamples(); 116 //Some casts are needed because TSpline5 constructor accepts only Double_t values 117 Double_t ptr2[nSlice]; 118 for (Int_t i = 0; i < nSlice; i++) 119 ptr2[i]=(Double_t)ptr[i]; 120 TSpline5 *spline = new TSpline5("spline",(Double_t) 0,(Double_t)(nSlice - 1),ptr2,nSlice); 121 Double_t abscissa=0.0; 122 Double_t maxAb=0.0; 123 Double_t maxOrd=0.0; 124 Double_t swap; 125 while (abscissa <= nSlice - 1) 126 { 127 swap=spline->Eval(abscissa); 128 if (swap > maxOrd) 129 { 130 maxOrd = swap; 131 maxAb = abscissa; 132 } 133 abscissa += 0.1; 134 } 135 fData[idx]=maxAb; 94 136 } 95 96 Bool_t saturatedlg = kFALSE;97 98 if (i!=n)99 {100 arrtime = 0;101 maxsign = 0;102 103 ptr = pixel.GetLoGainSamples();104 if (ptr==NULL)105 {106 *fLog << warn << "WARNING - Pixel #" << idx107 << " saturated but has no low gains... skipping!" << endl;108 return;109 }110 111 for (i=0; i<n; i++)112 {113 if (ptr[i]==0xff)114 saturatedlg = kTRUE;115 116 if (ptr[i]>maxsign)117 {118 maxsign = ptr[i];119 arrtime = i+1;120 }121 }122 }123 124 fData[idx]=arrtime;125 126 if (saturatedlg)127 saturatedpixels++;128 137 } 129 130 if (saturatedpixels>0)131 *fLog << warn << "WARNING: " << saturatedpixels132 << " pixel(s) had saturating low gains..." << endl;133 134 135 138 } 136 139 … … 138 141 // -------------------------------------------------------------------------- 139 142 // 140 // Returns the arrival time value (for now, it's the FADC slice number).143 // Returns the arrival time value 141 144 // 142 145 -
trunk/MagicSoft/Mars/manalysis/MArrivalTime.h
r2651 r2752 2 2 #define MARS_MArrivalTime 3 3 4 #ifndef ROOT_TArrayD 5 #include <TArrayD.h> 4 #ifndef ROOT_TArrayF 5 #include <TArrayF.h> 6 #endif 7 #ifndef ROOT_TSpline 8 #include <TSpline.h> 6 9 #endif 7 10 #ifndef MARS_MCamEvent … … 16 19 { 17 20 private: 18 TArray DfData; // Stores the arrival times21 TArrayF fData; // Stores the arrival times 19 22 20 23 public: … … 26 29 void Calc(const MRawEvtData &evt, const MGeomCam &geom); // Calculates arrival times 27 30 28 const TArray D&GetData() const { return fData; }31 const TArrayF &GetData() const { return fData; } 29 32 30 33 Double_t operator[](int i) { return fData[i]; } -
trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc
r2659 r2752 28 28 // 29 29 // This is a task that calculates the arrival times of photons. 30 // For now, it returns the number of time slice containig the maximum value. 31 // 32 // P R E L I M I N A R Y 33 // Other more sophisticated methods have to be implemented. 30 // It returns the absolute maximum of the spline that interpolates 31 // the FADC slices 34 32 // 35 33 // Input Containers: … … 37 35 // 38 36 // Output Containers: 39 // //MArrivalTime37 // MArrivalTime 40 38 // MRawEvtData 41 39 ////////////////////////////////////////////////////////////////////////////// 42 40 43 //#include "MArrivalTime.h"41 #include "MArrivalTime.h" 44 42 #include "MArrivalTimeCalc.h" 45 43 … … 65 63 // Default constructor. 66 64 // 65 67 66 MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title) 68 67 { … … 70 69 fTitle = title ? title : "Calculate photons arrival time"; 71 70 72 AddToBranchList("MRawEvtData.fHiGainPixId");73 AddToBranchList("MRawEvtData.fLoGainPixId");74 AddToBranchList("MRawEvtData.fHiGainFadcSamples");75 AddToBranchList("MRawEvtData.fLoGainFadcSamples");71 // AddToBranchList("MRawEvtData.fHiGainPixId"); 72 // AddToBranchList("MRawEvtData.fLoGainPixId"); 73 // AddToBranchList("MRawEvtData.fHiGainFadcSamples"); 74 // AddToBranchList("MRawEvtData.fLoGainFadcSamples"); 76 75 77 76 } … … 82 81 // - MRawRunHeader 83 82 // - MRawEvtData 84 // //- MArrivalTime83 // - MArrivalTime 85 84 // - MGeomCam 86 85 // 87 86 // The following output containers are also searched and created if 88 87 // they were not found: 89 // //- MArrivalTime88 // - MArrivalTime 90 89 // - MRawEvtData 91 90 // … … 114 113 } 115 114 116 /*fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));115 fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime")); 117 116 if (!fArrTime) 118 117 return kFALSE; 119 */ 118 120 119 return kTRUE; 121 120 } … … 123 122 124 123 // -------------------------------------------------------------------------- 125 // Evaluation of the mean arrival times ( for now it stands for the maximum in slices units)124 // Evaluation of the mean arrival times (spline interpolation) 126 125 // per pixel and store them in the MArrivalTime container. 127 126 // … … 130 129 MRawEvtPixelIter pixel(fRawEvt); 131 130 132 //fArrTime->Calc((const MRawEvtData&) *fRawEvt,(const MGeomCam&) *fGeom);133 //fArrTime->SetReadyToSave();131 fArrTime->Calc((const MRawEvtData&) *fRawEvt,(const MGeomCam&) *fGeom); 132 fArrTime->SetReadyToSave(); 134 133 135 //while (pixel.Next()){;}134 while (pixel.Next()){;} 136 135 137 136 return kTRUE; -
trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h
r2659 r2752 6 6 // MArrivalTimeCalc // 7 7 // // 8 // Evaluates the number of time slice into which the signal reaches a max.//9 // P R E L I M I N A R Y//10 // Other more sophisticated methods have to be implemented.//8 // Evaluates the Arrival Times // 9 // // 10 // // 11 11 ///////////////////////////////////////////////////////////////////////////// 12 12 … … 27 27 MRawRunHeader *fRunHeader; // RunHeader information 28 28 MGeomCam *fGeom; // Geometry information 29 //MArrivalTime *fArrTime; // Container with the photons arrival times29 MArrivalTime *fArrTime; // Container with the photons arrival times 30 30 31 31 Bool_t fEnableFix; // fix for a bug in files from older camera versions (<=40) … … 42 42 MArrivalTimeCalc(const char *name=NULL, const char *title=NULL); 43 43 44 // FIXME: The array size should be checked!45 46 44 ~MArrivalTimeCalc(){} 47 45 48 ClassDef(MArrivalTimeCalc, 0) // Task to calculate cerenkov photons from raw data46 ClassDef(MArrivalTimeCalc, 0) // Task to calculate Arrival Times from raw data 49 47 }; 50 48
Note:
See TracChangeset
for help on using the changeset viewer.