]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/Macros/AliTRDdisplayDigits3D.C
correcting DDL bit for AD and HLT
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDdisplayDigits3D.C
1 //_____________________________________________________________________________
2 Int_t AliTRDdisplayDigits3D(Int_t event = 0, Int_t thresh = 4
3                           , Bool_t sdigits = kFALSE) 
4 {
5   //  
6   //  TRD digits display
7   //
8   //  Input parameter:
9   //    <event>   : Event number 
10   //    <thresh>  : Threshold to suppress the noise
11   //    <sdigits> : If kTRUE it will display summable digits, normal digits otherwise.
12   //                The signal event is displayed in yellow.
13   //
14
15   Char_t *inputFile = "galice.root";
16
17   // Define the objects
18   AliTRDv1       *trd;
19   AliTRDgeometry *geo;
20
21   TString       evfoldname = AliConfig::GetDefaultEventFolderName();
22   AliRunLoader *runLoader  = AliRunLoader::GetRunLoader(evfoldname);
23   if (!runLoader) {
24     runLoader = AliRunLoader::Open(inputFile
25                                   ,AliConfig::GetDefaultEventFolderName()
26                                   ,"UPDATE");
27   }
28   if (!runLoader) {
29     printf("Can not open session for file %s.",inputFile);
30     return kFALSE;
31   }
32    
33   if (!runLoader->GetAliRun()) {
34     runLoader->LoadgAlice();
35   }
36   gAlice = runLoader->GetAliRun();  
37   if (!gAlice) {
38     printf("Could not find AliRun object.\n");
39     return kFALSE;
40   }
41
42   runLoader->GetEvent(event);
43   
44   AliLoader *loader = runLoader->GetLoader("TRDLoader");
45   if (!loader) {
46     printf("Can not get TRD loader from Run Loader");
47   }
48   loader->LoadDigits();
49   
50   // Get the pointer to the detector object
51   trd = (AliTRDv1*) gAlice->GetDetector("TRD");
52
53   // Get the pointer to the geometry object
54   if (trd) {
55     geo = trd->GetGeometry();
56   }
57   else {
58     printf("Cannot find the geometry\n");
59     return 1;
60   }
61
62   AliCDBManager *cdbManager  = AliCDBManager::Instance();
63   cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
64   AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
65   calibration->SetRun(0);
66
67   TCanvas *c1 = new TCanvas("digits","TRD digits display",0,0,700,730);
68   TView   *v  = new TView(1);
69   v->SetRange(-430,-560,-430,430,560,1710);
70   v->SetParallel();
71   c1->Clear();
72   c1->SetFillColor(1);
73   c1->SetTheta(90.0);
74   c1->SetPhi(0.0);
75
76   Int_t markerColorSignal = 2;
77   Int_t markerColorBgnd   = 7;
78   Int_t markerColorMerged = 5;
79   Int_t mask              = 10000000;
80
81   // Create the digits manager
82   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
83   digitsManager->SetSDigits(sdigits);
84
85   // Read the digits from the file
86   if (sdigits) {
87     digitsManager->ReadDigits(loader->TreeS());
88   }
89   else {
90     if (!loader->TreeD()) {
91       printf("mist\n");
92       return kFALSE;
93     }
94     digitsManager->ReadDigits(loader->TreeD());
95   }
96
97   Int_t totalsignal = 0;
98   Int_t totalbgnd   = 0;
99   Int_t totalmerged = 0;
100   Int_t timeMax     = calibration->GetNumberOfTimeBins();
101
102   // Loop through all detectors
103   for (Int_t idet = 0; idet < geo->Ndet(); idet++) {
104
105     printf("<AliTRDdisplayDigits3D> Loading detector %d\n",idet);
106     AliTRDdataArrayI *digits  = digitsManager->GetDigits(idet);
107     digits->Expand();
108
109     Int_t isec    = geo->GetSector(idet);
110     Int_t icha    = geo->GetChamber(idet);
111     Int_t ipla    = geo->GetPlane(idet);
112     AliTRDpadPlane *padPlane = new AliTRDpadPlane(ipla,icha);
113     Int_t  rowMax = padPlane->GetNrows();
114     Int_t  colMax = padPlane->GetNcols();
115
116     Int_t ndigits = digits->GetOverThreshold(thresh);
117
118     if (ndigits > 0) {
119
120       TPolyMarker3D *pmSignal = new TPolyMarker3D(ndigits);
121       Int_t isignal = 0;
122
123       for (Int_t time = 0; time < timeMax; time++) {
124         for (Int_t  col = 0;  col <  colMax;  col++) {
125           for (Int_t  row = 0;  row <  rowMax;  row++) {
126
127             Int_t amp = digits->GetDataUnchecked(row,col,time);
128
129             if (amp > thresh) {
130           
131               Double_t glb[3];
132               Double_t loc[3];
133
134               loc[0] = row;
135               loc[1] = col;
136               loc[2] = time;
137               geo->Local2Global(idet,loc,glb);
138               Double_t x = glb[0];
139               Double_t y = glb[1];
140               Double_t z = glb[2];
141
142               pmSignal->SetPoint(isignal,x,y,z);
143               isignal++;
144               totalsignal++;
145
146             }
147
148           }
149         }
150       }
151
152       digits->Compress(1,0);
153
154       pmSignal->SetMarkerSize(1); 
155       pmSignal->SetMarkerColor(markerColorSignal);
156       pmSignal->SetMarkerStyle(1);
157       pmSignal->Draw();
158    
159     }
160
161   }
162
163   delete padPlane;
164
165   TGeometry *geoAlice = gAlice->GetGeometry();
166   TNode     *main     = (TNode *) ((geoAlice->GetListOfNodes())->First());
167   TIter      next(main->GetListOfNodes());
168   TNode     *module   = 0;
169   while ((module = (TNode *) next())) {
170     Char_t ch[100];
171     sprintf(ch,"%s\n",module->GetTitle());
172     if ((ch[0] == 'T') && ((ch[1] == 'R') || (ch[1] == 'P'))) {
173       module->SetVisibility( 3);
174     }
175     else {
176       module->SetVisibility(-1);
177     }
178   }
179       
180   geoAlice->Draw("same");
181
182   c1->Modified(); 
183   c1->Update(); 
184
185   return 0;
186
187 }
188