00001 #ifndef MAPSSENSOR_HH_
00002 #define MAPSSENSOR_HH_
00003
00004 #include <vector>
00005 #include <map>
00006 #include <algorithm>
00007 #include <functional>
00008
00009 #include "TH1F.h"
00010 #include "TH2F.h"
00011
00012 #include "ToString.h"
00013 #include "Operators.h"
00014 #include "MapsException.hh"
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class MapsSensor {
00038 public:
00039
00040 typedef std::pair<int, int> coord;
00041
00042 typedef std::pair<double, double> physXY;
00043
00044
00045
00046
00047 MapsSensor(unsigned id, double zpos, double phi = 0) :
00048 myId(id), myPosition(zpos), myPhi(phi), myAlignment(0, 0) {
00049 }
00050 ;
00051
00052 MapsSensor(unsigned id, double zpos, physXY alignment, double phi = 0) :
00053 myId(id), myPosition(zpos), myPhi(phi), myAlignment(alignment) {
00054
00055 }
00056 ;
00057
00058 MapsSensor::physXY getAlignment() const;
00059
00060
00061
00062
00063 void setAlignment(MapsSensor::physXY alignment);
00064
00065
00066
00067
00068 inline void setPhi(const double phi) {
00069 myPhi = phi;
00070 }
00071
00072
00073
00074
00075 inline void setZPosition(const double zpos) {
00076 myPosition = zpos;
00077 }
00078
00079
00080
00081
00082 inline unsigned id() {
00083 return myId;
00084 }
00085 ;
00086
00087
00088
00089
00090 inline double zPosition() const {
00091 return myPosition;
00092 }
00093 ;
00094
00095
00096
00097
00098 inline double phi() {
00099 return myPhi;
00100 }
00101 ;
00102
00103 virtual ~MapsSensor();
00104
00105
00106
00107
00108 void registerTrackConfirm(unsigned threshold, coord place, unsigned bx);
00109
00110
00111
00112
00113 void registerTrackConfirm(unsigned threshold, coord place, unsigned bx,
00114 physXY fourthHitResid);
00115
00116
00117
00118
00119 void registerTrackMiss(unsigned threshold, coord predicted, unsigned bx);
00120
00121
00122
00123
00124 void registerTrackMiss(unsigned threshold, physXY predicted, unsigned bx);
00125
00126
00127
00128
00129 void registerGeneralHit(unsigned threshold, coord place, unsigned bx);
00130
00131
00132
00133
00134 void getInefficiencyXYPlot(TH2F& plot, bool physicalXY = false);
00135
00136
00137
00138
00139 void getEfficiencyXYPlot(TH2F& plot);
00140
00141
00142
00143
00144
00145 void getFourthHitResidualPlot(TH2F& plot);
00146
00147
00148
00149
00150 void setResidual(physXY resid);
00151
00152
00153
00154
00155 void getEfficiencyTimestamps(TH1F& plot);
00156
00157
00158
00159
00160 void getInefficiencyTimestamps(TH1F& plot);
00161
00162
00163
00164
00165 double getEfficiency(unsigned threshold, bool withShapers = true,
00166 bool withSamplers = true);
00167
00168
00169
00170
00171 void getEfficiencyCurve(TH1F&, int bins, int low, int high,
00172 bool withShapers = true, bool withSamplers = true);
00173
00174
00175
00176
00177
00178
00179 void getEfficiencyByGroup(TH2F&, unsigned threshold = 0);
00180
00181
00182
00183
00184 void getResidualXYPlot(TH2F&) const;
00185
00186 friend std::ostream& operator<<(std::ostream& s, const MapsSensor& ms);
00187
00188
00189
00190
00191 bool isDeadArea(const physXY) const;
00192
00193
00194
00195
00196 void convertHitToPhysical(const coord&, physXY&) const;
00197
00198
00199
00200
00201
00202
00203
00204 void convertPhysicalToHit(const physXY&, coord&) const throw(MapsException);
00205
00206
00207
00208
00209 void printEfficiencies(std::ostream&);
00210
00211
00212
00213
00214 static void mutualSensorMask(const std::vector<MapsSensor*>&, TH2F&);
00215
00216
00217
00218
00219 unsigned decodeRegion(const coord&) const;
00220
00221
00222
00223
00224 unsigned decodeRegion(const physXY&) const throw(MapsException);
00225
00226 protected:
00227 MapsSensor& operator=(MapsSensor& ms) {
00228 return *this;
00229 }
00230
00231 private:
00232
00233 MapsSensor(MapsSensor* ms);
00234
00235 unsigned myId;
00236 double myPosition;
00237 double myPhi;
00238
00239
00240
00241
00242
00243 std::map<unsigned, std::pair<unsigned, unsigned>* > myHitsByThreshold;
00244 std::map<unsigned, std::pair<unsigned, unsigned>* > myShaperHitsByThreshold;
00245 std::map<unsigned, std::pair<unsigned, unsigned>* >
00246 mySamplerHitsByThreshold;
00247
00248
00249
00250
00251 std::vector<unsigned> myKnownThresholds;
00252
00253
00254
00255
00256 std::map<unsigned, std::pair<unsigned, unsigned>* > myTimes;
00257
00258 physXY myAlignment;
00259
00260 std::vector<physXY > myResiduals;
00261 std::vector<physXY> myFourthHitResids;
00262
00263
00264
00265
00266 std::vector<MapsSensor::coord> myEfficientHits;
00267
00268
00269
00270
00271
00272 std::vector<MapsSensor::coord> myInefficientHits;
00273
00274
00275
00276
00277 std::vector<MapsSensor::physXY> myInefficientPlaces;
00278
00279
00280
00281
00282 std::vector<MapsSensor::coord> myGeneralHits;
00283
00284
00285
00286
00287
00288 void registerTrackMiss(unsigned threshold, unsigned bx);
00289
00290
00291
00292
00293 unsigned getLowestThresh() const;
00294 unsigned getHighestThresh() const;
00295
00296
00297
00298
00299
00300 void rotateLocalToGlobal(physXY&) const;
00301
00302
00303
00304
00305
00306 void rotateGlobalToLocal(physXY&) const;
00307
00308
00309
00310
00311 void align(physXY&) const;
00312
00313
00314
00315
00316 void malign(physXY&) const;
00317
00318 };
00319
00320 std::ostream& operator<<(std::ostream& s, const MapsSensor& ms);
00321
00322 #endif
00323