00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef ALG_ALTDEMUXBASE_H
00013 #define ALG_ALTDEMUXBASE_H
00014
00015 #include "Algorithm/AlgBase.h"
00016 #include "Plex/PlexSEIdAltL.h"
00017 #include "UgliGeometry/UgliGeomHandle.h"
00018 #include "UgliGeometry/UgliStripHandle.h"
00019 #include "TCanvas.h"
00020 #include "TList.h"
00021 #include "TPad.h"
00022 #include "TH2.h"
00023 #include "TH1.h"
00024 #include "TPolyLine.h"
00025 #include "AltDeMuxPatternMaster.h"
00026 #include "AltDeMuxCalc.h"
00027 #include "AltDeMuxStructures.h"
00028 #include <string>
00029
00030 class CandDeMuxDigitHandle;
00031 class CandDigitListHandle;
00032 class CandDeMuxDigitListHandle;
00033 class TObjectItr;
00034
00035 class AlgAltDeMuxBase : public AlgBase
00036 {
00037
00038 public:
00039
00040
00041 AlgAltDeMuxBase();
00042 AlgAltDeMuxBase(const char* name);
00043 virtual ~AlgAltDeMuxBase();
00044
00045
00046 virtual void Trace(const char *c) const;
00047
00048
00049 virtual void RunAlg(AlgConfig &acd, CandHandle &ch, CandContext &cx);
00050
00051
00052 void Initialize(const char* name);
00053
00054 protected:
00055
00056
00057
00058
00059 void Setup();
00060 void SetConstants(const VldContext* vldc);
00061
00062
00063
00064 void StripNoise();
00065 void ClearArrays();
00066 void MakePixelMap(CandDigitListHandle& cdlh);
00067 void DisplayPixelMap();
00068 void MakeAltListMap(CandDigitListHandle& cdlh);
00069 void ReTagCrossTalk(CandDeMuxDigitListHandle& cdlh);
00070 void FinalReTagCrossTalk(CandDeMuxDigitListHandle& cdlh);
00071 void StripCrossTalk(CandDeMuxDigitListHandle& cdlh);
00072 void StripCrossTalkSingles(CandDeMuxDigitListHandle& cdlh);
00073 void TagCrossTalk(CandDeMuxDigitListHandle& cdlh);
00074 void ReBuildXTalkMap();
00075 void GetFibreLengths();
00076 void ResetTimingMask();
00077 void MakeTimingMask(bool useMask);
00078 void ReMakeTimingMask(bool useMask);
00079 void ReMakeMask();
00080
00081
00082
00083 bool RemoveSingle(Int_t iplane, PlexSEIdAltL* paltlist);
00084 void DeMuxPass(Int_t ipass);
00085 void DeMuxWhatsLeft();
00086 void MakeMaskGroups();
00087 void MakePlaneMap(Int_t iplane, bool useTargets=false);
00088 void MakePlaneMap(DeMuxSearchTactic);
00089 void GroupHits();
00090 bool SelectHits(Int_t iplane, bool makeGold, bool useGold=false);
00091 bool SelectHits(Int_t iplane, DeMuxSearchTactic);
00092 void GoldHits(Int_t iplane,Int_t istrip);
00093 void DeMuxHits(Int_t iplane, Int_t ie, Int_t iw, Int_t is);
00094 void DeMuxHits(Int_t iplane, PlexSEIdAltL* pAltE, PlexSEIdAltL* pAltW, Int_t is);
00095 void DeMuxHitE(Int_t iplane, PlexSEIdAltL* pAlt, Int_t is);
00096 void DeMuxHitW(Int_t iplane, PlexSEIdAltL* pAlt, Int_t is);
00097 void VetoHitE(Int_t iplane, PlexSEIdAltL* pAlt);
00098 void VetoHitW(Int_t iplane, PlexSEIdAltL* pAlt);
00099 void DeMuxSingleHitE(Int_t iplane, PlexSEIdAltL* pAlt, Int_t is);
00100 void DeMuxSingleHitW(Int_t iplane, PlexSEIdAltL* pAlt, Int_t is);
00101 void DeMuxHitE(Int_t iplane, Int_t ie, Int_t is);
00102 void DeMuxHitW(Int_t iplane, Int_t iw, Int_t is);
00103 Int_t DeMuxBigGroup(Int_t iplane, Int_t ig, bool gold);
00104 void DeMuxSingles(DeMuxSearchTactic tactic);
00105 void ReMuxPlane(Int_t iplane);
00106 void ReMuxPlane(Int_t iplane, std::vector<Int_t> stripPattern);
00107 void ReMuxSingleSidedPlane(Int_t iplane, std::vector<Int_t> stripPattern);
00108 void CleanMultiple();
00109 void CleanIsolatedHits();
00110 bool ValidatePlane(Int_t iplane, bool useTimeMask=false);
00111 bool ValidateBeamPlane(Int_t iplane, bool useTimeMask=false);
00112 bool ValidatePlaneAgainstTarget(Int_t iplane, Int_t targetStrip);
00113 bool DumpValidateBeamPlane(Int_t iplane, bool useTimeMask=false);
00114 bool ValidateMultipleMuonPlane(Int_t iplane);
00115 bool BestGuessForPlane(Int_t iplane, bool doSingleSided = true);
00116 bool BestGuessForSingleSidedHits(Int_t iplane);
00117 bool BestGuessForView(PlaneView::PlaneView_t kView);
00118 bool ValidateContainedCandidateEndPlanes();
00119 bool ValidateCCEndPlanes();
00120 bool ValidateContainedCandidateEndPlane(Int_t iplane);
00121 PlaneValidity_t ValidatePlaneForPattern(Int_t iplane, std::vector<Int_t>stripPattern);
00122 PlaneValidity_t ValidateOneSidedPlaneForPattern(Int_t iplane, std::vector<Int_t> stripPattern);
00123
00124 bool ValidityComp(PlaneValidity_t currentValidity, PlaneValidity_t newValidity, int ish, int ist, bool onesided);
00125
00126 DeMuxEventType_t EventID();
00127 Float_t DistanceToNearestInPlane(PlexSEIdAltL* paltlist);
00128
00129
00130 void MakeSearchTactics();
00131 void MakeSearchTacticsX();
00132 void MakeSearchTacticsY();
00133 DeMuxSearchTactic MakeSearchTactics(Int_t iplane);
00134 void NewTactic(DeMuxSearchTactic oldTactic);
00135 void MakeMultipleTargets(Int_t iplane);
00136
00137 void AddBackCrossTalk();
00138 void AddBackNoise();
00139 void Hough();
00140 void FitAsCosmic(bool useSingles=false);
00141 void SearchAndDestroy();
00142 DeMuxFitResult_t LinearFit(std::vector<DeMuxFitData_t>& data, Float_t refitDistance=-999.);
00143
00144
00145
00146 void CreateDiagnosticCanvas();
00147 void ClearDiagnosticHistos();
00148 void DrawDiagnosticPlots(Int_t ipass);
00149 void PrintWhatRemains();
00150 void PrintXTalk();
00151 void PrintNoise();
00152 void MakeFitPolyLines(DeMuxFitResult_t result, TPolyLine* &pPolyLine1, TPolyLine* &pPolyLine2, Int_t color=4, Int_t style=1);
00153
00154
00155
00156
00157 bool MaskExtrapolateForwards(int i, int imm, int im);
00158 bool MaskExtrapolateBack(int i, int ip, int ipp);
00159 bool MaskInterpolate(int i, int im, int ip);
00160 void SetMask(int ip, int is);
00161 void FillLowestHighest();
00162 void ResetMap(Int_t ne, Int_t nw);
00163 void PrintMap(Int_t ne, Int_t nw);
00164 Float_t XTalkCharge(PlexSEIdAltL* paltlist, Int_t istrip);
00165 Float_t XTalkPixelMap(PlexSEIdAltL* paltlist);
00166 Float_t PredictedSpotQ(PlexSEIdAltL* paltlist);
00167 bool IsXTalk(PlexSEIdAltL* paltlist, bool useBest=false);
00168 bool RemoveFromPlanesList(Int_t iplane, Int_t iew, PlexSEIdAltL* paltlist);
00169 void TidyUp();
00170 void UpdateXTalkMap(PlexSEIdAltL* paltlist);
00171
00172 UgliGeomHandle* pUgh;
00173
00174 Int_t _pixelToVaChannel[16];
00175 Float_t _pixelSpotXTalkMap[9][9];
00176 PlaneView::PlaneView_t fUVMap[MAX_NUMBER_OF_PLANES];
00177
00178
00179 Int_t _nDeMuxedPlanesU;
00180 Int_t _nDeMuxedPlanesV;
00181 Int_t _nHitPlanesU;
00182 Int_t _nHitPlanesV;
00183
00184
00185 bool fUseHoughSlope;
00186 bool fUseFitSlopeTime;
00187 bool fUseFitSlopeHits;
00188 bool fUseInterpolation;
00189 bool fUseSafeExtrapolationF;
00190 bool fUseSafeExtrapolationB;
00191 bool fUseExtrapolationF;
00192 bool fUseExtrapolationB;
00193 bool fUseSameStrip;
00194 bool fUseLevelStripF;
00195 bool fUseLevelStripB;
00196
00197
00198
00199
00200 Float_t fXTalkFraction;
00201 Float_t fXTalk1PEFraction;
00202 Float_t fXTalk2PEFraction;
00203 Float_t fXTalk5PEFraction;
00204 Float_t fNoiseTimeWindow;
00205 Int_t fTimingMaskWindow;
00206 Int_t fStripWindow;
00207 Float_t fSigmasForTimingWindow;
00208
00209 Float_t fTrackingLowPECut;
00210
00211
00212 Float_t fCutRawPE;
00213 Float_t fCutCorPE;
00214 Float_t fCutSigmaQ;
00215 bool fCutUseTimingMask;
00216 bool fCutUseMultipleLines;
00217 bool fCutUseTargetStrips;
00218 bool fCutGuessing;
00219 bool fDiagnosticPlots;
00220 DeMuxEventType_t fEventType;
00221 bool fHoughStatus;
00222 bool fFitHStatus;
00223 bool fFitTStatus;
00224
00225 Float_t fHoughSlopeU;
00226 Float_t fHoughSlopeV;
00227 DeMuxFitResult_t fFitTimeU;
00228 DeMuxFitResult_t fFitTimeV;
00229 DeMuxFitResult_t fFitHitU;
00230 DeMuxFitResult_t fFitHitV;
00231 DeMuxFitResult_t fFitQHitU;
00232 DeMuxFitResult_t fFitQHitV;
00233
00234 bool fFitTStatusU;
00235 bool fFitTStatusV;
00236 bool fFitHStatusU;
00237 bool fFitHStatusV;
00238
00239 Float_t fFitTSlopeU;
00240 Float_t fFitTSlopeV;
00241 Float_t fFitHSlopeU;
00242 Float_t fFitHSlopeV;
00243
00244 Float_t fFitTIntU;
00245 Float_t fFitTIntV;
00246 Float_t fFitHIntU;
00247 Float_t fFitHIntV;
00248
00249 Int_t fUniqueDeMuxedGroupID;
00250
00251
00252
00253
00254 std::vector<Float_t> multipleMuonInterceptsU;
00255 std::vector<Float_t> multipleMuonInterceptsV;
00256
00257
00258
00259
00260 bool amWriting;
00261 bool amShowing;
00262 bool amPSing;
00263 bool amHisting;
00264 bool amDrawing;
00265
00266 Int_t fCCHighestPlane;
00267 Int_t fCCNearestPlane;
00268 Int_t fHighestPlane;
00269 Int_t fLowestPlane;
00270 Int_t fHighestDeMuxedPairPlane;
00271 Int_t fLowestDeMuxedPairPlane;
00272
00273 private:
00274
00275
00276
00277
00278 AltDeMuxPatternMaster* pMaster;
00279 AltDeMuxCalc* pCalculator;
00280
00281
00282
00283
00284
00285
00286 std::vector<PlexSEIdAltL*>fPlanesAltLists[MAX_NUMBER_OF_PLANES][2];
00287
00288 std::vector<PlexSEIdAltL*>fDeMuxedPlanesAltLists[MAX_NUMBER_OF_PLANES][2];
00289
00290 std::vector<PlexSEIdAltL*>fXTalkPlanesAltLists[MAX_NUMBER_OF_PLANES][2];
00291
00292 std::vector<PlexSEIdAltL*>fNoisePlanesAltLists[MAX_NUMBER_OF_PLANES][2];
00293
00294 std::vector<DeMuxedPair>fDeMuxedPairs[MAX_NUMBER_OF_PLANES];
00295
00296 std::vector<DeMuxedSingle>fDeMuxedSingles[MAX_NUMBER_OF_PLANES];
00297
00298 std::vector<DeMuxSearchTactic>fSearchTactics;
00299
00300 std::vector<DeMuxMaskGroup>fMaskGroup[MAX_NUMBER_OF_PLANES];
00301
00302 std::vector <Int_t> fTargets;
00303
00304 std::vector <Float_t> fTimeList;
00305
00306
00307 Float_t fPMTmap[MAX_NUMBER_OF_PMTS][16];
00308 Float_t fXTalkmap[MAX_NUMBER_OF_PMTS][16];
00309 Float_t fVAmap[MAX_NUMBER_OF_PMTS][22];
00310 Float_t fPMTtot[MAX_NUMBER_OF_PMTS];
00311
00312
00313 Double_t fAbsTime;
00314 bool _smask[MAX_NUMBER_OF_STRIPS];
00315 bool fUVmask[MAX_NUMBER_OF_PLANES][MAX_NUMBER_OF_STRIPS];
00316 Int_t fInMask[MAX_NUMBER_OF_PLANES];
00317 bool fTimingMask[MAX_NUMBER_OF_PLANES][MAX_NUMBER_OF_STRIPS];
00318
00319
00320 Int_t fNGroups;
00321 Int_t fNInGroupE[100];
00322 Int_t fNInGroupW[100];
00323 Int_t fEGroup[100][100];
00324 Int_t fWGroup[100][100];
00325 bool fEFound[100];
00326 bool fWFound[100];
00327 Int_t fWCount;
00328 Int_t fECount;
00329 std::vector <int> fTargetStrips;
00330 Int_t fGoldPlaneHit[MAX_NUMBER_OF_PLANES];
00331 Int_t fGoldHitMap[MAX_NUMBER_OF_PLANES][100];
00332 Int_t fPlaneHit[MAX_NUMBER_OF_PLANES];
00333 Int_t fPlanePair[MAX_NUMBER_OF_PLANES];
00334 int fHitMap[MAX_NUMBER_OF_PLANES][100];
00335 float fQHitMapE[MAX_NUMBER_OF_PLANES][100];
00336 float fQHitMapW[MAX_NUMBER_OF_PLANES][100];
00337 bool fSearched[MAX_NUMBER_OF_PLANES];
00338
00339
00340 string diagnosticCanvastitle;
00341 bool diagnosticCanvas;
00342 Int_t NdemuxedHitsU[MAX_NUMBER_OF_PLANES];
00343 Float_t demuxedHitStripU[MAX_NUMBER_OF_PLANES][MAX_DISPLAYED_HITS];
00344 Float_t demuxedHitQU[MAX_NUMBER_OF_PLANES][MAX_DISPLAYED_HITS];
00345 Int_t NdemuxedHitsV[MAX_NUMBER_OF_PLANES];
00346 Float_t demuxedHitStripV[MAX_NUMBER_OF_PLANES][MAX_DISPLAYED_HITS];
00347 Float_t demuxedHitQV[MAX_NUMBER_OF_PLANES][MAX_DISPLAYED_HITS];
00348 TList* fList;
00349
00350 Float_t fQTotE[MAX_NUMBER_OF_PLANES];
00351 Float_t fQTotW[MAX_NUMBER_OF_PLANES];
00352 Float_t fQMaxE[MAX_NUMBER_OF_PLANES];
00353 Float_t fQMaxW[MAX_NUMBER_OF_PLANES];
00354
00355 bool fAmap[MAX_HITS_PLANE][MAX_HITS_PLANE];
00356 Int_t fSmap[MAX_HITS_PLANE][MAX_HITS_PLANE];
00357 bool fBmap[MAX_HITS_PLANE][MAX_HITS_PLANE];
00358
00359
00360 PlexSEIdAltL* pPlaneAltMapE[MAX_HITS_PLANE];
00361 PlexSEIdAltL* pPlaneAltMapW[MAX_HITS_PLANE];
00362
00363
00364
00365 Float_t fClearFibreC;
00366 Float_t fWLSFibreC;
00367 Float_t fScintillatorC;
00368
00369 Float_t fClearFibreN;
00370 Float_t fWLSFibreN;
00371 Float_t fScintillatorN;
00372
00373 Float_t fClearFibreNMC;
00374 Float_t fWLSFibreNMC;
00375 Float_t fScintillatorNMC;
00376
00377 Int_t fNumberOfStrips;
00378 Float_t fSigmaTData;
00379 Float_t fSigmaTMC;
00380 Float_t fSigmaT;
00381 Float_t fSigmaStripFromTiming;
00382
00383
00384
00385 TCanvas* fCanvas;
00386 TPad *fUpad;
00387 TPad *fVpad;
00388 TH2F *fUview;
00389 TH2F *fVview;
00390 TH2F *fUTime;
00391 TH2F *fVTime;
00392 TH2F *fUMask;
00393 TH2F *fVMask;
00394 TH2F *fHoughU;
00395 TH2F *fHoughV;
00396 TH1F *fHoughProjU;
00397 TH1F *fHoughProjV;
00398 TH1F *fHoughSliceU;
00399 TH1F *fHoughSliceV;
00400 TPolyLine* fUZFitT;
00401 TPolyLine* fVZFitT;
00402 TPolyLine* fUZFitS;
00403 TPolyLine* fVZFitS;
00404
00405 TPolyLine* fUZFitTSM1;
00406 TPolyLine* fVZFitTSM1;
00407 TPolyLine* fUZFitSSM1;
00408 TPolyLine* fVZFitSSM1;
00409
00410 TPolyLine* fUZFitTSM2;
00411 TPolyLine* fVZFitTSM2;
00412 TPolyLine* fUZFitSSM2;
00413 TPolyLine* fVZFitSSM2;
00414
00415 TPolyLine* fUZFitQSSM1;
00416 TPolyLine* fVZFitQSSM1;
00417 TPolyLine* fUZFitQSSM2;
00418 TPolyLine* fVZFitQSSM2;
00419
00420
00421 ClassDef(AlgAltDeMuxBase,0)
00422
00423 };
00424
00425 #endif // ALG_ALTDEMUXBASE_H