00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #include "RerootExodus/PlexusReroot.h"
00014 #include "Validity/VldContext.h"
00015
00016 #include "MessageService/MsgService.h"
00017 CVSID("$Id: PlexusReroot.cxx,v 1.15 2006/12/03 01:52:59 gmieg Exp $");
00018
00019 #include <iomanip>
00020
00021 #include "RerootExodus/RerootExodus.h"
00022
00023 ClassImp(PlexusReroot)
00024
00025
00026 PlexusReroot::PlexusReroot()
00027 : Plexus(), fNStrips(0), fStripToPixelModulo(0), fStripToPixelPermute(0)
00028 {
00029
00030
00031 MSG("Plex",Msg::kVerbose) << "default ctor" << endl;
00032
00033 fVldRange = RerootExodus::BuildVldRange();
00034 }
00035
00036
00037 PlexusReroot::PlexusReroot(const VldContext& )
00038 : Plexus(), fNStrips(0), fStripToPixelModulo(0), fStripToPixelPermute(0)
00039 {
00040
00041
00042 MSG("Plex",Msg::kInfo) << " PlexusReroot vldc ctor " << endl;
00043
00044 fVldRange = RerootExodus::BuildVldRange();
00045 }
00046
00047
00048 PlexusReroot::~PlexusReroot()
00049 {
00050
00051
00052 delete [] fStripToPixelModulo;
00053 delete [] fStripToPixelPermute;
00054
00055 }
00056
00057
00058 RawChannelId PlexusReroot::GetRawChannelId(const PlexStripEndId& pseid) const
00059 {
00060
00061
00062
00063
00064
00065
00066
00067 BuildPermute(pseid.GetPlane());
00068
00069 ElecType::Elec_t elec = ElecType::kReroot;
00070 Int_t crate = -1;
00071 Int_t chadd = -1;
00072
00073 Int_t plane = pseid.GetPlane();
00074 Int_t strip = pseid.GetStrip();
00075 StripEnd::StripEnd_t end = pseid.GetEnd();
00076 Int_t pixel;
00077
00078
00079 switch (end) {
00080 case StripEnd::kEast:
00081 pixel = fStripToPixelPermute[strip];
00082 break;
00083 case StripEnd::kWest:
00084 pixel = fStripToPixelModulo[strip];
00085 break;
00086 default:
00087 pixel = -1;
00088
00089 MSG("Plex",Msg::kFatal)
00090 << "PlexusExodus::GetRawChannelId(seid) illegal side "
00091 << StripEnd::AsString(pseid.GetEnd()) << endl;
00092 }
00093
00094
00095
00096 Detector::Detector_t detector = pseid.GetDetector();
00097
00098
00099 if (Detector::kNear == detector) {
00100 if ( pseid.GetPlane() <= 120 ) {
00101 pixel = strip;
00102 }
00103 }
00104
00105
00106 if (Detector::kCalDet == detector) {
00107 pixel = strip;
00108 }
00109
00110
00111 if ( strip >= fNStrips ) {
00112 pixel = -1;
00113
00114 MSG("Plex",Msg::kFatal)
00115 << "PlexusExodus::GetRawChannelId(seid) illegal strip # "
00116 << pseid.AsString() << " in " << fActvNameStrip2Pixel
00117 << " which has " << fNStrips << " strips " << endl;
00118 }
00119
00120 MangleFakeCrate(plane,pixel,end,crate,chadd);
00121
00122 return RawChannelId(detector,elec,crate,chadd);
00123
00124 }
00125
00126
00127 RawChannelId PlexusReroot::GetRawChannelId(const PlexPixelSpotId& psid) const
00128 {
00129
00130
00131 MSG("Exodus",Msg::kError)
00132 << "GetRawChannelId(PlexPixelSpotId) not supported: "
00133 << psid << endl;
00134 return RawChannelId();
00135 }
00136
00137
00138 RawChannelId PlexusReroot::GetRawChannelId(const PlexPinDiodeId& diodeid) const
00139 {
00140
00141
00142 MSG("Exodus",Msg::kError)
00143 << "GetRawChannelId(PlexPinDiodeId) not supported: "
00144 << diodeid << endl;
00145 return RawChannelId();
00146 }
00147
00148
00149 PlexPinDiodeId PlexusReroot::GetPinDiodeId(const RawChannelId& rcid) const
00150 {
00151
00152
00153 MSG("Exodus",Msg::kError)
00154 << "GetPinDiodeId(RawChannelId) not supported: "
00155 << rcid << endl;
00156 return PlexPinDiodeId();
00157 }
00158
00159
00160 PlexSEIdAltL PlexusReroot::GetSEIdAltL(const RawChannelId& rcid,
00161 const PlexCalib* calib,
00162 Int_t adc, Double_t time) const
00163 {
00164
00165
00166 Int_t plane = -1;
00167 StripEnd::StripEnd_t end = StripEnd::kUnknown;
00168 Int_t pixel = -1;
00169
00170 DemangleFakeCrate(rcid.GetCrate(),rcid.GetChAdd(),plane,pixel,end);
00171
00172
00173
00174 Int_t rpln = RerootExodus::SteelToRerootPlane(plane,kTRUE);
00175 PlexStripEndId pseid_base = RerootExodus::PECAB2SEId(rpln,0,0,0);
00176 Detector::Detector_t detector = pseid_base.GetDetector();
00177
00178
00179 BuildPermute(plane);
00180
00181 PlexSEIdAltL altlist;
00182
00183
00184
00185
00186 if ( Detector::kNear == detector && plane < 121 ) {
00187 Int_t strip = pixel;
00188 pseid_base.SetStrip(strip);
00189 pseid_base.SetEnd(end);
00190 PlexPixelSpotId spotid;
00191 altlist.AddStripEndId(pseid_base,spotid,0,calib,adc,time);
00192 return altlist;
00193 }
00194
00195
00196 if ( Detector::kCalDet == detector ) {
00197 Int_t strip = pixel;
00198 pseid_base.SetStrip(strip);
00199 pseid_base.SetEnd(end);
00200 PlexPixelSpotId spotid;
00201 altlist.AddStripEndId(pseid_base,spotid,0,calib,adc,time);
00202 return altlist;
00203 }
00204
00205 for (Int_t strip = 0; strip < fNStrips; strip++) {
00206 Bool_t test = kFALSE;
00207 switch ( end ) {
00208 case StripEnd::kWest:
00209 if ( pixel == fStripToPixelModulo[strip] ) test = kTRUE;
00210 break;
00211 case StripEnd::kEast:
00212 if ( pixel == fStripToPixelPermute[strip] ) test = kTRUE;
00213 break;
00214 default:
00215 break;
00216 }
00217 if (test) {
00218 pseid_base.SetStrip(strip);
00219 pseid_base.SetEnd(end);
00220 PlexPixelSpotId spotid;
00221 altlist.AddStripEndId(pseid_base,spotid,0,calib,adc,time);
00222 }
00223 }
00224
00225 return altlist;
00226
00227
00228 }
00229
00230
00231 ReadoutType::Readout_t PlexusReroot::GetReadoutType(const RawChannelId& rcid) const
00232 {
00233
00234
00235
00236 MSG("Exodus",Msg::kVerbose)
00237 << "GetReadoutType(RawChannelId) always returns kScintStrip "
00238 << rcid
00239 << endl;
00240 return ReadoutType::kScintStrip;
00241 }
00242
00243
00244 void PlexusReroot::BuildPermute(const Int_t steelpln) const
00245 {
00246
00247
00248 Int_t rpln = RerootExodus::SteelToRerootPlane(steelpln);
00249 TString reqtype = RerootExodus::ActvPlaneName(rpln);
00250
00251
00252 if (reqtype == fActvNameStrip2Pixel) return;
00253
00254
00255 delete [] fStripToPixelModulo;
00256 delete [] fStripToPixelPermute;
00257
00258
00259 fActvNameStrip2Pixel = reqtype;
00260 fNStrips = RerootExodus::NStripsNonZero(rpln);
00261
00262 fStripToPixelModulo = new Int_t [fNStrips];
00263 fStripToPixelPermute = new Int_t [fNStrips];
00264
00265
00266
00267 Int_t nstrip_swath = 1;
00268 Detector::Detector_t detector = RerootExodus::GetDetector();
00269 switch (detector) {
00270 case Detector::kNear: nstrip_swath = 24; break;
00271 case Detector::kFar: nstrip_swath = 24; break;
00272 default: nstrip_swath = 1;
00273 }
00274
00275 Int_t ioff1 = 1;
00276 for (Int_t strip = 0; strip < fNStrips; strip++) {
00277 Int_t swath = strip/nstrip_swath;
00278 Int_t inswath = strip%nstrip_swath;
00279 Int_t ioff = swath*ioff1;
00280 Int_t permute = (strip+ioff)%nstrip_swath;
00281
00282 fStripToPixelModulo[strip] = inswath;
00283 fStripToPixelPermute[strip] = permute;
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 }
00295
00296 }
00297
00298
00299 void PlexusReroot::MangleFakeCrate(const Int_t plane, const Int_t pixel,
00300 const StripEnd::StripEnd_t end,
00301 Int_t &crate, Int_t &chadd)
00302 {
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 const Int_t mask13 = 0x1fff;
00316 const Int_t mask10 = 0x03ff;
00317
00318 const Int_t mask1 = 0x0001;
00319 const Int_t mask8 = 0x00ff;
00320 const Int_t mask6 = 0x003f;
00321
00322 Int_t bits = ((plane & mask10) << 9) |
00323 ((end & mask1) << 8) |
00324 (pixel & mask8);
00325
00326
00327 const Int_t low4 = 0x0000f;
00328 const Int_t high16 = 0xffff0;
00329 Int_t bitstmp = ((bits & high16) << 1) | ( bits & low4 );
00330
00331
00332
00333
00334 bits = bitstmp;
00335
00336 crate = (bits >> 13) & mask6;
00337 chadd = bits & mask13;
00338
00339 }
00340 void PlexusReroot::DemangleFakeCrate(const Int_t crate, Int_t chadd,
00341 Int_t &plane, Int_t &pixel,
00342 StripEnd::StripEnd_t &end)
00343 {
00344
00345 const Int_t mask13 = 0x1fff;
00346 const Int_t mask10 = 0x03ff;
00347
00348 const Int_t mask1 = 0x0001;
00349 const Int_t mask8 = 0x00ff;
00350 const Int_t mask6 = 0x003f;
00351
00352 Int_t bits = ((crate & mask6) << 13 ) | (chadd & mask13);
00353
00354
00355 const Int_t low4 = 0x0000f;
00356 const Int_t high16 = 0xffff0 << 1;
00357 Int_t bitstmp = ((bits & high16) >> 1) | ( bits & low4 );
00358
00359
00360 bits = bitstmp;
00361
00362 plane = (bits >> 9) & mask10;
00363
00364
00365 end = ((bits>>8)&mask1) ? StripEnd::kNegative : StripEnd::kPositive;
00366 pixel = bits & mask8;
00367 }
00368
00369
00370 void PlexusReroot::BuildPixelMaps(const VldContext& ) const
00371 {
00372
00373
00374 MSG("Plex",Msg::kInfo) << "PlexusReroot::BuildPixelMaps " << endl;
00375 fVldRange.Print();
00376 return;
00377 }
00378
00379
00380 void PlexusReroot::BuildReadoutMap(const VldContext& ) const
00381 {
00382
00383
00384 MSG("Plex",Msg::kInfo) << "PlexusReroot::BuildReadoutMap " << endl;
00385 fVldRange.Print();
00386 return;
00387 }
00388
00389
00390 void PlexusReroot::BuildPinDiodeMap(const VldContext& ) const
00391 {
00392
00393
00394 MSG("Plex",Msg::kInfo) << "PlexusReroot::BuildPinDiodeMap " << endl;
00395 fVldRange.Print();
00396 return;
00397 }
00398
00399
00400