Applying fixes and updates (Indra)
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONHitReconstructor.h
1 #ifndef ALIHLTMUONHITRECONSTRUCTOR_H
2 #define ALIHLTMUONHITRECONSTRUCTOR_H
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * All rights reserved.                                                   *
6  *                                                                        *
7  * Primary Authors:                                                       *
8  *   Indranil Das <indra.das@saha.ac.in>                                  *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          * 
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /* $Id$ */
20
21 ///////////////////////////////////////////////
22 //Author : Indranil Das, SINP, INDIA
23 //         Sukalyan Chattopadhyay, SINP, INDIA
24 //         
25 //Email :  indra.das@saha.ac.in
26 //         sukalyan.chattopadhyay@saha.ac.in 
27 ///////////////////////////////////////////////
28
29 #include <iostream>
30 #include <cstdio>
31 #include <fstream>
32 #include <cstring>
33 #include <cmath>
34 #include <map>
35
36 #include <TString.h>
37
38 #include <AliHLTLogging.h>
39
40 #include "AliRawReader.h"
41 #include "AliRawReaderFile.h"
42 #include "AliRawReaderRoot.h"
43 #include "AliRawReaderDate.h"
44
45 #if __GNUC__ < 3
46 #define std
47 #endif
48
49
50 typedef std::map<int,int> BusToDetElem;
51 typedef std::map<int,int> BusToDDL;
52
53 extern "C" struct AliHLTMUONRecHitStruct;
54
55
56 class AliHLTMUONHitReconstructor : public AliHLTLogging
57 {
58 public:
59
60   struct DHLTLut{
61     int fIdManuChannel;  // Manu channel address
62     int fIX,fIY;  // The X,Y number of the pad.
63     float fRealX,fRealY,fRealZ;  // The real coordinate of the pad.
64     int fPlane,fPcbZone;  // The plane and PCB zone ID numbers.
65   };
66
67   struct DHLTPad{
68     int fDetElemId;  // The detector element ID of the pad.
69     int fBuspatchId;  // The bus patch ID number for the pad.
70     int fIdManuChannel;  // The Manu channel address.
71     int fIX,fIY;  // The X,Y number of the pad.
72     float fRealX,fRealY,fRealZ;   // The real coordinate of the pad.
73     int fPlane,fPcbZone;   // The plane and PCB zone ID numbers.
74     int fCharge;  // The charge measured on the pad.
75   };
76
77   AliHLTMUONHitReconstructor();
78   virtual ~AliHLTMUONHitReconstructor(void);
79
80   bool LoadLookUpTable(DHLTLut* lookUpTableData, int lookUpTableId);
81   bool SetBusToDetMap(BusToDetElem busToDetElem);
82   bool SetBusToDDLMap(BusToDDL busToDDL);
83   
84   bool Run(int* rawData, int *rawDataSize, AliHLTMUONRecHitStruct recHit[], int *nofHit);
85   void SetDCCut(int dcCut) {fDCCut = dcCut;}
86   void SetDebugLevel(int debugLevel) {fDebugLevel = debugLevel;}
87   int GetDebugLevel() const {return fDebugLevel;}
88   int GetDEId(int iBusPatch) {return fBusToDetElem[iBusPatch] ;}           
89     
90   int GetLutLine(int iDDL) const;
91
92   static int GetkDetectorId() { return fgkDetectorId; }
93   static int GetkDDLOffSet() { return fgkDDLOffSet; }
94   static int GetkNofDDL() { return fgkNofDDL; }
95   static int GetkDDLHeaderSize() { return fgkDDLHeaderSize; }
96   
97 private: 
98   static const int fgkDetectorId ;            // DDL Offset
99   static const int fgkDDLOffSet ;             // DDL Offset
100   static const int fgkNofDDL ;                // Number of DDL 
101   static const int fgkDDLHeaderSize  ;        // DDL header size
102  
103 protected:
104   AliHLTMUONHitReconstructor(const AliHLTMUONHitReconstructor& rhs); // copy constructor
105   AliHLTMUONHitReconstructor& operator=(const AliHLTMUONHitReconstructor& rhs); // assignment operator
106   
107 private:
108
109   static const int fgkEvenLutSize ;          // Size of the LookupTable with event DDLID
110   static const int fgkOddLutSize ;           // Size of the LookupTable with odd DDLID
111   static const int fgkLutLine[2];            // nof Line in LookupTable    
112
113   static const int fgkMinIdManuChannel[2];   // Minimum value of idManuChannel in LookupTable  
114   static const int fgkMaxIdManuChannel[2];   // Maximum value of idManuChannel in LookupTable  
115   static const float fgkHalfPadSize[3];      // pad halflength for the pcb zones  
116   
117   int fkBlockHeaderSize;                     // Block header size
118   int fkDspHeaderSize;                       // DSP header size
119   int fkBuspatchHeaderSize;                  // buspatch header size
120   
121   int fDCCut;                                // DC Cut value
122
123   DHLTPad* fPadData;                         // pointer to the array containing the information of each padhits
124   DHLTLut* fLookUpTableData;                 // pointer to the array of Lookuptable data
125   
126   AliHLTMUONRecHitStruct *fRecPoints;       // Reconstructed hits
127   int *fRecPointsCount;                      // nof reconstructed hit  
128   int fMaxRecPointsCount;                    // max nof reconstructed hit  
129    
130   int fCentralCountB, fCentralCountNB;        // centeral hits 
131   int fIdOffSet,fDDLId;                       // DDLId and DDL id offset
132   int fDigitPerDDL;                           // Total nof Digits perDDL 
133   
134   int *fDetManuChannelIdList;                          // pointer to an array of idManuChannel
135   int *fCentralChargeB,*fCentralChargeNB;              // pointer to an array of central hit
136   float *fRecX,*fRecY;                                 // pointer to an array of reconstructed hit
137   float *fAvgChargeX,*fAvgChargeY;                     // average charge on central pad found using CG method
138   int fGetIdTotalData[336][80][2] ;                    // an array of idManuChannel with argumrnt of centralX,centralY and  planeType
139   int fNofFiredDetElem,fMaxFiredPerDetElem[13];        // counter for detector elements that are fired 
140   int fDebugLevel;
141   BusToDetElem fBusToDetElem;             // Mapping between bus address and detector element ID.
142   BusToDetElem fBusToDDL;                 // Mapping between bus address and DDL.
143
144
145   bool ReadDDL(int* rawData, int *rawDataSize);
146   void FindCentralHits(int minPadId, int maxPadId);
147   bool FindRecHits() ;
148   void RecXRecY();
149   bool MergeRecHits();
150
151 };
152
153 #endif // ALIHLTMUONHITRECONSTRUCTOR_H