]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMD.cxx
base class for clustering
[u/mrichter/AliRoot.git] / PMD / AliPMD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //
20 //                                                                           //
21 //  Photon Multiplicity Detector                                             //
22 //  This class contains the basic functions for the Photon Multiplicity      //
23 //  Detector. Functions specific to one particular geometry are              //
24 //  contained in the derived classes                                         //
25 //                                                                           //
26 //Begin_Html
27 /*
28 <img src="picts/AliPMDClass.gif">
29 </pre>
30 <br clear=left>
31 <font size=+2 color=red>
32 <p>The responsible person for this module is
33 <a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
34 </font>
35 <pre>
36 */
37 //End_Html
38 //                                                                           //
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #include <TBRIK.h>
42 #include <TClonesArray.h>
43 #include <TGeometry.h>
44 #include <TNode.h>
45 #include <TTree.h>
46 #include <TVirtualMC.h>
47
48 #include "AliLog.h"
49 #include "AliLoader.h" 
50 #include "AliPMDLoader.h" 
51 #include "AliPMD.h"
52 #include "AliRun.h"
53 #include "AliMC.h"
54 #include "AliPMDDigitizer.h"
55 #include "AliPMDhit.h"
56 #include "AliPMDDDLRawData.h"
57   
58 ClassImp(AliPMD)
59  
60 //_____________________________________________________________________________
61 AliPMD::AliPMD()
62 {
63   //
64   // Default constructor
65   //
66   fIshunt = 0;
67
68 }
69  
70 //_____________________________________________________________________________
71 AliPMD::AliPMD(const char *name, const char *title)
72   : AliDetector(name,title)
73 {
74   //
75   // Default constructor
76   //
77
78   // 
79   // Allocate the array of hits
80   fHits   = new TClonesArray("AliPMDhit",  405);
81   gAlice->GetMCApp()->AddHitList(fHits);
82
83
84   fIshunt =  0;
85   
86   fPar[0] = 1;
87   fPar[1] = 1;
88   fPar[2] = 0.8;
89   fPar[3] = 0.02;
90   fIn[0]  = 6;
91   fIn[1]  = 20;
92   fIn[2]  = 600;
93   fIn[3]  = 27;
94   fIn[4]  = 27;
95   fGeo[0] = 0;
96   fGeo[1] = 0.2;
97   fGeo[2] = 4;
98   fPadSize[0] = 0.8;
99   fPadSize[1] = 1.0;
100   fPadSize[2] = 1.2;
101   fPadSize[3] = 1.5;
102 }
103
104 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
105 {
106   // Makes PMD Loader
107  
108   fLoader = new AliPMDLoader(GetName(),topfoldername);
109  
110   if (fLoader)
111     {
112       AliInfo("Success");
113     }
114   else
115     {
116       AliError("Failure");
117     }
118
119   return fLoader;
120 }
121
122 AliPMD::~AliPMD()
123 {
124   //
125   // Destructor
126   //
127 }
128
129 //_____________________________________________________________________________
130 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
131 {
132   //
133   // Add a PMD hit
134   //
135   TClonesArray &lhits = *fHits;
136   AliPMDhit *newcell, *curcell;
137   //  printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
138   // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
139   // vol[4],vol[5],vol[6],vol[7]);
140
141   newcell = new AliPMDhit(fIshunt, track, vol, hits);
142   Int_t i;
143   for (i=0; i<fNhits; i++) {
144     //
145     // See if this cell has already been hit
146     curcell=(AliPMDhit*) lhits[i];
147     if (*curcell==*newcell) {
148 //        printf("Cell with same numbers found\n") ; curcell->Print();
149       *curcell = *curcell+*newcell;
150 //        printf("Cell after addition\n") ; curcell->Print();
151       delete newcell;
152       return;
153     }
154   }
155   new(lhits[fNhits++]) AliPMDhit(newcell);
156   delete newcell;
157 }
158  
159 //_____________________________________________________________________________
160 void AliPMD::BuildGeometry()
161 {
162   //
163   // Build simple ROOT TNode geometry for event display
164   //
165
166   TNode *node, *top;
167   const int kColorPMD  = kRed;
168
169   //
170   top=gAlice->GetGeometry()->GetNode("alice");
171
172   // PMD
173   new TBRIK("S_PMD","PMD box","void",300,300,5);
174   top->cd();
175   node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
176   node->SetLineColor(kColorPMD);
177   fNodes->Add(node);
178 }
179
180 //_____________________________________________________________________________
181 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
182 {
183   //
184   // Set PMD parameters
185   //
186   fPar[0] = p1;
187   fPar[1] = p2;
188   fPar[2] = p3;
189   fPar[3] = p4;
190 }
191  
192 //_____________________________________________________________________________
193 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
194 {
195   //
196   // Set PMD parameters
197   //
198   fIn[0] = p1;
199   fIn[1] = p2;
200   fIn[2] = p3;
201   fIn[3] = p4;
202   fIn[4] = p5;
203 }
204  
205 //_____________________________________________________________________________
206 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
207 {
208   //
209   // Set geometry parameters
210   //
211   fGeo[0] = p1;
212   fGeo[1] = p2;
213   fGeo[2] = p3;
214 }
215  
216 //_____________________________________________________________________________
217 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
218 {
219   //
220   // Set pad size
221   //
222   fPadSize[0] = p1;
223   fPadSize[1] = p2;
224   fPadSize[2] = p3;
225   fPadSize[3] = p4;
226 }
227  
228 //_____________________________________________________________________________
229 void AliPMD::StepManager()
230 {
231   //
232   // Called at every step in PMD
233   //
234 }
235
236 void AliPMD::MakeBranch(Option_t* option)
237 {
238     // Create Tree branches for the PMD
239     
240     const char *cH = strstr(option,"H");
241     if (cH && fLoader->TreeH() && (fHits == 0x0))
242       fHits   = new TClonesArray("AliPMDhit",  405);
243     
244     AliDetector::MakeBranch(option);
245 }
246
247
248 void AliPMD::SetTreeAddress()
249 {
250   // Set branch address
251
252     if (fLoader->TreeH() && fHits==0x0)
253       fHits   = new TClonesArray("AliPMDhit",  405);
254       
255     AliDetector::SetTreeAddress();
256 }
257
258 //____________________________________________________________________________
259 void AliPMD::Hits2SDigits()  
260
261 // create summable digits
262
263   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
264   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
265   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
266                                "HS");
267   pmdDigitizer->SetZPosition(361.5);
268
269   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
270     pmdDigitizer->Hits2SDigits(iEvent);
271   }
272   fLoader->UnloadHits();
273   fLoader->UnloadSDigits();
274   delete pmdDigitizer;
275 }
276 //____________________________________________________________________________
277 void AliPMD::SDigits2Digits()  
278
279   // creates sdigits to digits
280 }
281 //____________________________________________________________________________
282 void AliPMD::Hits2Digits()  
283
284 // create digits
285
286   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
287   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
288   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
289                                "HD");
290   pmdDigitizer->SetZPosition(361.5);
291
292   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
293     pmdDigitizer->Hits2Digits(iEvent);
294   }
295   fLoader->UnloadHits();
296   fLoader->UnloadDigits();
297   delete pmdDigitizer;
298
299 }
300 // ---------------------------------------------------------------------------
301 AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager) const
302
303   return new AliPMDDigitizer(manager);
304 }
305 // ---------------------------------------------------------------------------
306 void AliPMD::Digits2Raw()
307
308 // convert digits of the current event to raw data
309
310   fLoader->LoadDigits();
311   TTree* digits = fLoader->TreeD();
312   if (!digits) {
313     AliError("No digits tree");
314     return;
315   }
316
317   AliPMDDDLRawData rawWriter;
318   rawWriter.WritePMDRawData(digits);
319
320   fLoader->UnloadDigits();
321 }
322
323
324