Changeset 19561 for trunk/Mars/msim
- Timestamp:
- 07/11/19 17:15:32 (5 years ago)
- Location:
- trunk/Mars/msim
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/msim/MPhotonEvent.cc
r19355 r19561 101 101 // 102 102 // 103 // Version 1:103 // Version 2: 104 104 // ---------- 105 105 // - First implementation 106 // - fData is now A MClonesArray to avoid casting issues on some compilers 106 107 // 107 108 ///////////////////////////////////////////////////////////////////////////// … … 127 128 using namespace std; 128 129 129 // ==========================================================================130 131 class MyClonesArray : public TClonesArray132 {133 public:134 TObject **FirstRef() { return fCont; }135 136 // --------------------------------------------------------------------------137 //138 // This is an extremly optimized version of ExpandCreateFast. It only resets139 // the marker for the last element (fLast) to n-1 and doen't change anything140 // else. This implicitly assumes that the stored objects don't allocate141 // memory. It does not necessarily mean that the slots after fLast142 // are empty (set to 0). This is what is assumed in the TClonesArray.143 // We also don't call Changed() because it would reset Sorted. If the144 // array was sorted before it is also sorted now. You MUST make sure145 // that you only set n in a range for which valid entries have been146 // created before (e.g. by ExpandCreateFast).147 //148 void FastShrink(Int_t n)149 {150 fLast = n - 1;151 }152 153 // --------------------------------------------------------------------------154 //155 // This is a optimized (faster) version of Delete which deletes consequtive156 // entries from index idx1 to idx2 (both included) and calls their157 // destructor. Note that there is no range checking done!158 //159 void FastRemove(Int_t idx1, Int_t idx2)160 {161 // Remove object at index idx.162 163 //if (!BoundsOk("RemoveAt", idx1)) return 0;164 //if (!BoundsOk("RemoveAt", idx2)) return 0;165 166 Long_t dtoronly = TObject::GetDtorOnly();167 168 idx1 -= fLowerBound;169 idx2 -= fLowerBound;170 171 for (TObject **obj=fCont+idx1; obj<=fCont+idx2; obj++)172 {173 if (!*obj)174 continue;175 176 if ((*obj)->TestBit(kNotDeleted)) {177 // Tell custom operator delete() not to delete space when178 // object fCont[i] is deleted. Only destructors are called179 // for this object.180 TObject::SetDtorOnly(*obj);181 delete *obj;182 }183 184 *obj = 0;185 // recalculate array size186 }187 TObject::SetDtorOnly((void*)dtoronly);188 189 if (idx1<=fLast && fLast<=idx2)190 {191 do {192 fLast--;193 } while (fLast >= 0 && fCont[fLast] == 0);194 }195 196 Changed();197 }198 199 200 //void SetSorted() { fSorted = kTRUE; }201 202 // --------------------------------------------------------------------------203 //204 // This is an optimized version of Sort which doesn't check the205 // IsSortable flag before. It only sorts the entries from 0206 // to GetEntriesFast().207 //208 void UncheckedSort()209 {210 if (fSorted)211 return;212 213 const Int_t nentries = GetEntriesFast();214 if (nentries <= 0)215 return;216 217 QSort(GetObjectRef(First()), fKeep->GetObjectRef(fKeep->First()),218 0, TMath::Min(nentries, kMaxInt-fLowerBound));219 220 fSorted = kTRUE;221 }222 };223 224 // ==========================================================================225 130 226 131 // -------------------------------------------------------------------------- … … 274 179 275 180 // Just set fLast = n -1 276 static_cast<MyClonesArray&>(fData).FastShrink(n);181 fData.FastShrink(n); 277 182 return fData.GetEntriesFast(); 278 183 } … … 370 275 { 371 276 o=fData.UncheckedAt(n); 372 static_cast<MyClonesArray&>(fData).FastShrink(n+1);277 fData.FastShrink(n+1); 373 278 } 374 279 else … … 396 301 fData.UnSort(); 397 302 398 static_cast<MyClonesArray&>(fData).UncheckedSort(); /*Sort(GetEntriesFast())*/ 303 fData.UncheckedSort(); 304 // fData.Sort(fData.GetEntriesFast()); 399 305 } 400 306 -
trunk/Mars/msim/MPhotonEvent.h
r19338 r19561 11 11 12 12 #include <iosfwd> 13 #include "MClonesArray.h" 13 14 14 15 using namespace std; … … 21 22 { 22 23 private: 23 TClonesArray fData;24 MClonesArray fData; 24 25 25 26 public: … … 41 42 Double_t GetMeanT() const; 42 43 43 TClonesArray &GetArray() { return fData; }44 const TClonesArray &GetArray() const { return fData; }44 MClonesArray &GetArray() { return fData; } 45 const MClonesArray &GetArray() const { return fData; } 45 46 46 47 Bool_t AsciiWrite(ostream &out) const; … … 71 72 //void Clear(Option_t * = NULL); 72 73 73 ClassDef(MPhotonEvent, 1) //Container to store the raw Event Data74 ClassDef(MPhotonEvent, 2) //Container to store the raw Event Data 74 75 }; 75 76 -
trunk/Mars/msim/Makefile
r9518 r19561 28 28 MSimAtmosphere.cc \ 29 29 MSimAbsorption.cc \ 30 MSimPointingPos.cc 30 MSimPointingPos.cc \ 31 MClonesArray.cc 31 32 32 33 ############################################################ -
trunk/Mars/msim/SimLinkDef.h
r9351 r19561 18 18 #pragma link C++ class MSimMMCS+; 19 19 20 #pragma link C++ class MClonesArray-; // - needed as custom streamer is already implemented 21 20 22 #endif
Note:
See TracChangeset
for help on using the changeset viewer.