Changeset 4072 for trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc
- Timestamp:
- 05/14/04 16:35:57 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc
r4056 r4072 26 26 // MSrcRotate 27 27 // 28 // Task to rotate the position of the source as a function of Azimuth and 29 // Zenith angles 28 // Task to rotate the position of the source as a function of time 30 29 // 31 30 // Input Containers: … … 45 44 #include "MRawEvtHeader.h" 46 45 #include "MSrcRotate.h" 47 #include "MSrcPosCam.h"48 #include "MDCA.h"49 46 50 47 #include "MAstroSky2Local.h" 51 48 #include "MObservatory.h" 49 #include "MSrcPosCam.h" 50 #include "MDCA.h" 52 51 53 52 #include "MLog.h" … … 59 58 60 59 static const TString gsDefName = "MSrcRotate"; 61 static const TString gsDefTitle = " De-rotate position of the source";60 static const TString gsDefTitle = "Rotate position of the source"; 62 61 63 62 // ------------------------------------------------------------------------- … … 68 67 // 69 68 MSrcRotate::MSrcRotate(const char* srcPos, const char* dca, const char *name, const char *title) 70 : f SrcPos(NULL), fDCA(NULL), fRA(0), fDEC(0), fRunNumber(0)69 : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0) 71 70 { 72 71 fName = name ? name : gsDefName.Data(); 73 72 fTitle = title ? title : gsDefTitle.Data(); 74 73 75 fSrcPosName = srcPos;76 fDCAName = dca;74 SetSrcPosName(srcPos); 75 SetDCAName(dca); 77 76 } 78 77 … … 84 83 Int_t MSrcRotate::PreProcess(MParList *pList) 85 84 { 86 // look for/create MSrcPosCam 87 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam"); 88 if (!fSrcPos) 89 { 90 *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl; 91 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName)); 92 if(!fSrcPos) 93 return kFALSE; 94 } 95 96 // look for/create MDCA 97 fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA"); 98 if (!fDCA) 99 { 100 *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl; 101 fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName)); 102 if(!fDCA) 103 return kFALSE; 104 } 105 85 if(!SearchForSrcPos(pList)) 86 return kFALSE; 87 106 88 // look for MRawRunHeader 107 89 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader"); … … 141 123 // FIXME: for the time being, this is computed by assuming constant event rate 142 124 // 143 Int_t MSrcRotate:: Process()125 Int_t MSrcRotate::ComputeNewSrcPosition() 144 126 { 145 127 if(fRunHeader->GetRunNumber()!=fRunNumber) 146 128 { 147 129 fRunNumber=fRunHeader->GetRunNumber(); 148 130 149 131 // save the number of events, initial and final times 150 132 fNEvts = fRunHeader->GetNumEvents(); … … 155 137 if((ULong_t)TMath::Nint(fIniTime.GetMjd())!=(ULong_t)TMath::Nint(fFinTime.GetMjd())) 156 138 { 157 *fLog << err << "MSrcRotate:: ProcessError: Inial and final MJDs are different ("<<fIniTime.GetMjd()<<"!="<<fFinTime.GetMjd()<<")" << endl;139 *fLog << err << "MSrcRotate::ComputeNewSrcPosition Error: Inial and final MJDs are different ("<<fIniTime.GetMjd()<<"!="<<fFinTime.GetMjd()<<")" << endl; 158 140 return kFALSE; 159 141 } 160 142 161 143 #ifdef DEBUG 162 144 cout << endl << "********************" << endl; … … 169 151 } 170 152 171 153 172 154 // Compute the event time 173 155 // FIXME: for the time being, this is computed by assuming constant event rate … … 177 159 MTime refTime; 178 160 refTime.SetMjd(fRefMJD); 179 161 180 162 // de-rotate the source position 181 163 const MAstroSky2Local Observation(eventTime, *fObservatory); 182 164 const MAstroSky2Local RefObservation(refTime, *fObservatory); 183 165 184 166 #ifdef DEBUG 185 167 printf("Run:%d, Event:%d, iniMJD=%15.5f, finMJD=%15.5f, fDeltaT=%15.5f, newMJD=%15.5f, fRefMJD=%15.5f, rotation=%15.5f, ref=%15.5f\n", … … 190 172 // cout << "newMJD=" << newMJD << ", fRefMJD="<<fRefMJD<<", rotation="<<Observation.RotationAngle(fRA,fDEC)<<", ref="<<RefObservation.RotationAngle(fRA,fDEC)<< endl; 191 173 #endif 192 193 Double_t rotationAngle = Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC); 174 175 Double_t rotationAngle = fRefMJD ? 176 Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC) : 177 Observation.RotationAngle(fRA,fDEC) ; 178 MSrcPosCam* srcpos = GetSrcPosCam(); 179 MDCA* dca = GetDCA(); 194 180 195 181 Float_t c = TMath::Cos(rotationAngle); 196 182 Float_t s = TMath::Sin(rotationAngle); 197 183 // perform a rotation of -rotationAngle to move the source back to the "initial" position 198 Float_t newX = c* fSrcPos->GetX()-s*fSrcPos->GetY();199 Float_t newY = s* fSrcPos->GetX()+c*fSrcPos->GetY();200 184 Float_t newX = c*srcpos->GetX()-s*srcpos->GetY(); 185 Float_t newY = s*srcpos->GetX()+c*srcpos->GetY(); 186 201 187 #ifdef DEBUG 202 188 Double_t rotationAngleComp = fObservatory->RotationAngle(0.1256,2.63); 203 189 cout << "Event " << fEvtHeader->GetDAQEvtNumber() << endl; 204 cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos.GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl ,190 cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos.GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl; 205 191 #endif 206 207 fSrcPos->SetX(newX);208 fSrcPos->SetY(newY);209 fDCA->SetRefPoint(newX,newY);192 193 srcpos->SetX(newX); 194 srcpos->SetY(newY); 195 dca->SetRefPoint(newX,newY); 210 196 211 197 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.