Changeset 4094 for trunk/MagicSoft/Mars/mtemp/mifae/library
- Timestamp:
- 05/18/04 10:16:45 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mtemp/mifae/library
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.cc
r4087 r4094 66 66 // 67 67 // Default constructor. The first argument is the name of the internal histo, 68 // the second (third) argument is the name of a container 69 // containing the source position in the camera plain, MScrPosCam (MDCA). 70 // The default is "MSrcPosCam" ("MDCA"). 71 // 72 MSrcPlace::MSrcPlace(const char* histname, const char* srcPos, const char* dca, const char *name, const char *title) 73 : fSrcPos(NULL), fDCA(NULL) 68 // the second (third) argument is the name of the input (output) container 69 // containing the source position in the camera plain. Fourth argument is the 70 // name of the output MDCA container. 71 // 72 MSrcPlace::MSrcPlace(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title) 73 : fSrcPosIn(NULL), fSrcPosOut(NULL), fDCA(NULL), fHistoName("SrcPosHist"), 74 fHistoBinPrec(1.), fHistPos(NULL) 74 75 { 75 76 fName = name ? name : gsDefName.Data(); 76 77 fTitle = title ? title : gsDefTitle.Data(); 77 78 78 fSrcPosName = srcPos; 79 fDCAName = dca; 80 81 const Float_t cameraSize = 600; //[mm] 82 const Float_t binPrecision = 1; //[mm] ~ 0.0033 deg 83 const UInt_t nbins = (UInt_t)(cameraSize*2/binPrecision); 84 85 fHistPos = new TH2F(histname,"",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize); 79 fSrcPosInName = srcPosIn; 80 fSrcPosOutName = srcPosOut; 81 fDCAName = dca; 86 82 87 83 fMode=kOn; 84 fCreateHisto=kTRUE; 88 85 } 89 86 // ------------------------------------------------------------------------- … … 103 100 void MSrcPlace::SavePosIntoHisto() 104 101 { 105 fHistPos->Fill(fSrcPos->GetX(),fSrcPos->GetY()); 102 if(fHistPos) 103 fHistPos->Fill(fSrcPosOut->GetX(),fSrcPosOut->GetY()); 106 104 } 107 105 // ------------------------------------------------------------------------- … … 111 109 void MSrcPlace::ReadPosFromHisto() 112 110 { 113 Axis_t x; 114 Axis_t y; 115 116 fHistPos->GetRandom2(x,y); 117 fSrcPos->SetXY(x,y); 118 fDCA->SetRefPoint(x,y); 111 if(fHistPos) 112 { 113 Axis_t x; 114 Axis_t y; 115 116 fHistPos->GetRandom2(x,y); 117 fSrcPosOut->SetXY(x,y); 118 fDCA->SetRefPoint(x,y); 119 } 119 120 } 120 121 // ------------------------------------------------------------------------- … … 125 126 Int_t MSrcPlace::PreProcess(MParList* pList) 126 127 { 127 // look for/create MSrcPosCam 128 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam"); 129 if (!fSrcPos) 130 { 131 *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl; 132 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName)); 133 if(!fSrcPos) 128 // create (if needed and requested) internal histogram 129 if(fCreateHisto && !fHistPos) 130 { 131 const Float_t cameraSize = 600; //[mm] 132 const UInt_t nbins = (UInt_t)(cameraSize*2/fHistoBinPrec); 133 fHistPos = new TH2F(fHistoName,"",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize); 134 fHistPos->SetDirectory(0); 135 *fLog << inf << "MSrcPlace::PreProcess Message: internal histogram " << fHistoName << " created with " << nbins << "x" << nbins << " bins" << endl; 136 } 137 138 // look for/create input MSrcPosCam 139 fSrcPosIn = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosInName), "MSrcPosCam"); 140 if (!fSrcPosIn) 141 { 142 *fLog << warn << AddSerialNumber(fSrcPosInName) << " [MSrcPosCam] not found... creating default container." << endl; 143 fSrcPosIn = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosInName)); 144 if(!fSrcPosIn) 145 return kFALSE; 146 } 147 148 // look for/create output MSrcPosCam 149 fSrcPosOut = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosOutName), "MSrcPosCam"); 150 if (!fSrcPosOut) 151 { 152 *fLog << warn << AddSerialNumber(fSrcPosOutName) << " [MSrcPosCam] not found... creating default container." << endl; 153 fSrcPosOut = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosOutName)); 154 if(!fSrcPosOut) 134 155 return kFALSE; 135 156 } … … 146 167 147 168 // check mode, look for a filled histogram in case kOff 148 if(fMode==kOn) 149 *fLog << inf << "MSrcPlace PreProcess Message: source postions will be stored in internal histo (" << fHistPos->GetName() << ")" << endl; 150 else 151 { 152 if(fHistPos->GetEntries()) 153 *fLog << inf << "MSrcPlace PreProcess Message: source postions will be read from internal histo (" << fHistPos->GetName() << ")" << endl; 169 if(fHistPos) 170 { 171 if(fMode==kOn) 172 *fLog << inf << "MSrcPlace PreProcess Message: source postions will be stored in internal histo (" << fHistPos->GetName() << ")" << endl; 154 173 else 155 174 { 156 *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl; 157 return kFALSE; 175 if(fHistPos->GetEntries()) 176 *fLog << inf << "MSrcPlace PreProcess Message: source postions will be read from internal histo (" << fHistPos->GetName() << ")" << endl; 177 else 178 { 179 *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl; 180 return kFALSE; 181 } 158 182 } 159 183 } … … 191 215 Int_t MSrcPlace::PostProcess() 192 216 { 193 if(fMode==kOn )217 if(fMode==kOn && fHistPos) 194 218 { 195 219 *fLog << inf << endl; -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPlace.h
r4087 r4094 16 16 17 17 private: 18 MSrcPosCam* fSrcPos; // Pointer to the source position 19 MDCA* fDCA; // Pointer to the MDCA object 18 MSrcPosCam* fSrcPosIn; // Pointer to the input source position container 19 MSrcPosCam* fSrcPosOut; // Pointer to the output source position container 20 MDCA* fDCA; // Pointer to the output MDCA container 20 21 21 TString fSrcPosName; // Name of the MSrcPosCam object 22 TString fDCAName; // Name of the MDCA object 23 24 TH2F* fHistPos; // histogram of the used source positions 22 TString fSrcPosInName; // Name of the input MSrcPosCam object 23 TString fSrcPosOutName; // Name of the output MSrcPosCam object 24 TString fDCAName; // Name of the MDCA object 25 26 TString fHistoName; // Name of internal histogram 27 Float_t fHistoBinPrec; // [mm] internal histo bin size 28 29 TH2F* fHistPos; // histogram of the used source positions 25 30 OnOffMode_t fMode; // On/Off data mode (write/read to/from the histogram) 31 Bool_t fCreateHisto; // flag to decide whether internal histo is created or not 26 32 27 33 void SavePosIntoHisto(); … … 35 41 36 42 public: 37 MSrcPlace(const char* histname="HistSrcPos",38 const char* src="MSrcPosCam", const char* dca="MDCA",43 MSrcPlace(const char* srcin="MSrcPosCam",const char* srcout="MSrcPosCam", 44 const char* dcaout="MDCA", 39 45 const char* name=NULL, const char* title=NULL); 40 46 41 47 virtual ~MSrcPlace(); 42 48 43 void SetMode(OnOffMode_t mode) {fMode=mode;} 44 void SetSrcPosName(TString name) {fSrcPosName=name;} 45 void SetDCAName(TString name) {fDCAName=name;} 49 void SetMode(OnOffMode_t mode) {fMode=mode;} 50 void SetInputSrcPosName(TString name) {fSrcPosInName=name;} 51 void SetOutputSrcPosName(TString name) {fSrcPosOutName=name;} 52 void SetDCAName(TString name) {fDCAName=name;} 53 void SetInternalHistoName(TString name) {fHistoName=name;} 54 void SetInternalHistoBinSize(Float_t size){fHistoBinPrec=size;} 55 void SetCreateHisto(Bool_t inp=kTRUE) {fCreateHisto=inp;} 46 56 47 OnOffMode_t GetMode() {return fMode;} 48 TH2F* GetPositionHisto() {return fHistPos;} 49 MSrcPosCam* GetSrcPosCam() {return fSrcPos;} 50 MDCA* GetDCA() {return fDCA;} 57 OnOffMode_t GetMode() {return fMode;} 58 TH2F* GetPositionHisto() {return fHistPos;} 59 MSrcPosCam* GetInputSrcPosCam() {return fSrcPosIn;} 60 MSrcPosCam* GetOutputSrcPosCam() {return fSrcPosOut;} 61 MDCA* GetDCA() {return fDCA;} 62 TString GetInternalHistoName() {return fHistoName;} 51 63 52 64 virtual Int_t ComputeNewSrcPosition() {return kTRUE;} -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc
r4087 r4094 47 47 #include "MLogManip.h" 48 48 49 49 50 ClassImp(MSrcPosFromFile); 50 51 … … 61 62 // 62 63 MSrcPosFromFile::MSrcPosFromFile(TString cardpath, OnOffMode_t mode, const char *name, const char *title) 63 : MSrcPlace(TString(gsDefName+"Hist").Data()),fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)64 : fRawRunHeader(NULL), fSourcePositionFilePath(cardpath) 64 65 { 65 66 fName = name ? name : gsDefName.Data(); … … 71 72 fRunMap=0x0; 72 73 73 fLastRun = 0; 74 fLastRun = 0; 75 fFirstRun = 0; 74 76 fLastValidSrcPosCam=0x0; 77 78 SetInternalHistoName(TString(fName)+"Hist"); 75 79 } 76 80 // ------------------------------------------------------------------------- … … 139 143 if(srcpos) 140 144 fLastValidSrcPosCam = srcpos; 145 else if(fLastValidSrcPosCam) 146 *fLog << inf << " not found in file. Taking previous position: "; 141 147 else 142 *fLog << inf << " not found in file. Taking previous position: ";143 144 if(fLastValidSrcPosCam)145 148 { 146 *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX();147 *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl;149 *fLog << warn << "MSrcPosFromFile::ComputeNewSrcPosition warning: no value for the first run. Taking first found run in file, run number " << fFirstRun << endl; 150 fLastValidSrcPosCam = (MSrcPosCam*)fRunMap->GetValue(run); 148 151 } 149 } 150 151 if(fLastValidSrcPosCam) 152 { 153 GetSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY()); 154 GetDCA()->SetRefPoint(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY()); 155 } 156 else 157 { 158 *fLog << err << "MSrcPosFromFile::ComputeNewSrcPosition error: no value for the first run. Don't know what values to take" << endl; 159 return kFALSE; 160 } 152 153 *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX(); 154 *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl; 155 } 156 157 GetOutputSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY()); 158 GetDCA()->SetRefPoint(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY()); 161 159 162 160 return kTRUE; … … 186 184 { 187 185 fin >> run >> x >> y; 186 if(!fFirstRun) fFirstRun=run; 188 187 if(fin.eof()) 189 188 break; -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.h
r4084 r4094 20 20 21 21 Int_t fNumRuns; 22 UInt_t fFirstRun; 22 23 UInt_t fLastRun; 23 24 -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc
r4087 r4094 62 62 // ------------------------------------------------------------------------- 63 63 // 64 // Default constructor. The first (second) argument is the name of a container65 // containing the source position in the camera plain, MScrPosCam (MDCA).66 // The default is "MSrcPosCam" ("MDCA").67 // 68 MSrcRotate::MSrcRotate(const char* srcPos , const char* dca, const char *name, const char *title)69 : MSrcPlace(TString(gsDefName+"Hist").Data()),fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)64 // Default constructor. The first (second) argument is the name of the 65 // input (output) MSrcPosCam object containing the source position in the 66 // camera plain 67 // 68 MSrcRotate::MSrcRotate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title) 69 : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0) 70 70 { 71 71 fName = name ? name : gsDefName.Data(); 72 72 fTitle = title ? title : gsDefTitle.Data(); 73 73 74 SetSrcPosName(srcPos); 74 SetInputSrcPosName(srcPosIn); 75 SetOutputSrcPosName(srcPosOut); 75 76 SetDCAName(dca); 77 78 SetInternalHistoName(TString(fName)+"Hist"); 76 79 } 77 80 … … 176 179 Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC) : 177 180 Observation.RotationAngle(fRA,fDEC) ; 178 MSrcPosCam* srcpos = GetSrcPosCam(); 181 MSrcPosCam* srcposIn = GetInputSrcPosCam(); 182 MSrcPosCam* srcposOut = GetOutputSrcPosCam(); 179 183 MDCA* dca = GetDCA(); 180 184 … … 182 186 Float_t s = TMath::Sin(rotationAngle); 183 187 // perform a rotation of -rotationAngle to move the source back to the "initial" position 184 Float_t newX = c*srcpos ->GetX()-s*srcpos->GetY();185 Float_t newY = s*srcpos ->GetX()+c*srcpos->GetY();188 Float_t newX = c*srcposIn->GetX()-s*srcposIn->GetY(); 189 Float_t newY = s*srcposIn->GetX()+c*srcposIn->GetY(); 186 190 187 191 #ifdef DEBUG 188 192 Double_t rotationAngleComp = fObservatory->RotationAngle(0.1256,2.63); 189 193 cout << "Event " << fEvtHeader->GetDAQEvtNumber() << endl; 190 cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos .GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl;194 cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPosIn.GetX()<< ", oldY="<<fIniSrcPosIn.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl; 191 195 #endif 192 196 193 srcpos->SetX(newX); 194 srcpos->SetY(newY); 197 srcposOut->SetXY(newX,newY); 195 198 dca->SetRefPoint(newX,newY); 196 199 -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h
r4072 r4094 31 31 32 32 public: 33 MSrcRotate(const char* src="MSrcPosCam", const char* dca="MDCA", 33 MSrcRotate(const char* srcIn="MSrcPosCam",const char* srcOut="MSrcPosCam", 34 const char* dca="MDCA", 34 35 const char* name=NULL, const char* title=NULL); 35 36 -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.cc
r4087 r4094 33 33 // Input Containers: 34 34 // MSrcPosCam 35 // [MDCA]36 35 // 37 36 // Output Containers: … … 62 61 // ------------------------------------------------------------------------- 63 62 // 64 // Default constructor. The first (second) argument is the name of a container65 // containing the source position in the camera plain, MScrPosCam (MDCA).66 // The default is "MSrcPosCam" ("MDCA").63 // Default constructor. The first (second) argument is the name of the 64 // input (output) MSrcPosCam object containing the source position in the 65 // camera plain 67 66 // 68 MSrcTranslate::MSrcTranslate(const char* srcPos , const char* dca, const char *name, const char *title)69 : MSrcPlace(TString(gsDefName+"Hist").Data()),fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)67 MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char* dca, const char *name, const char *title) 68 : fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE) 70 69 { 71 70 fName = name ? name : gsDefName.Data(); 72 71 fTitle = title ? title : gsDefTitle.Data(); 73 72 74 SetSrcPosName(srcPos); 73 SetInputSrcPosName(srcPosIn); 74 SetOutputSrcPosName(srcPosOut); 75 75 SetDCAName(dca); 76 77 SetInternalHistoName(TString(fName)+"Hist"); 76 78 } 77 79 … … 100 102 Double_t newX,newY; 101 103 102 MSrcPosCam* srcPos = GetSrcPosCam();103 MDCA* dca = GetDCA();104 104 MSrcPosCam* srcPosOut = GetOutputSrcPosCam(); 105 MDCA* dca = GetDCA(); 106 105 107 if(fTranslationIsRelative) 106 108 { 107 newX=srcPos->GetX()+fShiftX; 108 newY=srcPos->GetY()+fShiftY; 109 MSrcPosCam* srcPosIn = GetInputSrcPosCam(); 110 newX=srcPosIn->GetX()+fShiftX; 111 newY=srcPosIn->GetY()+fShiftY; 109 112 } 110 113 else … … 114 117 } 115 118 116 srcPos->SetX(newX); 117 srcPos->SetY(newY); 119 srcPosOut->SetXY(newX,newY); 118 120 dca->SetRefPoint(newX,newY); 119 121 -
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcTranslate.h
r4087 r4094 17 17 18 18 public: 19 MSrcTranslate(const char* src="MSrcPosCam", const char* dca="MDCA", 19 MSrcTranslate(const char* srcIn="MSrcPosCam", const char* srcOut="MSrcPosCam", 20 const char* dca="MDCA", 20 21 const char* name=NULL, const char* title=NULL); 21 22
Note:
See TracChangeset
for help on using the changeset viewer.