]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMD.cxx
updated macros (with new cut values) for (anti-)proton-(anti-)lambda and lambda-...
[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 #include "AliPMDRawToSDigits.h"
58   
59 ClassImp(AliPMD)
60  
61 //_____________________________________________________________________________
62 AliPMD::AliPMD()
63 {
64   //
65   // Default constructor
66   //
67   fIshunt     = 0;
68   fPar[0]     = 1.;
69   fPar[1]     = 1.;
70   fPar[2]     = 0.8;
71   fPar[3]     = 0.02;
72   fIn[0]      = 6.;
73   fIn[1]      = 20.;
74   fIn[2]      = 600.;
75   fIn[3]      = 27.;
76   fIn[4]      = 27.;
77   fGeo[0]     = 0.;
78   fGeo[1]     = 0.2;
79   fGeo[2]     = 4.;
80   fPadSize[0] = 0.8;
81   fPadSize[1] = 1.0;
82   fPadSize[2] = 1.2;
83   fPadSize[3] = 1.5;
84   fNumPads[0] = 0;
85   fNumPads[1] = 0;
86   fNumPads[2] = 0;
87   fNumPads[3] = 0;
88 }
89  
90 //_____________________________________________________________________________
91 AliPMD::AliPMD(const char *name, const char *title)
92   : AliDetector(name,title)
93 {
94   //
95   // Default constructor
96   //
97
98   // 
99   // Allocate the array of hits
100   fHits   = new TClonesArray("AliPMDhit",  405);
101   gAlice->GetMCApp()->AddHitList(fHits);
102
103
104   fIshunt =  0;
105   
106   fPar[0]     = 1.;
107   fPar[1]     = 1.;
108   fPar[2]     = 0.8;
109   fPar[3]     = 0.02;
110   fIn[0]      = 6.;
111   fIn[1]      = 20.;
112   fIn[2]      = 600.;
113   fIn[3]      = 27.;
114   fIn[4]      = 27.;
115   fGeo[0]     = 0.;
116   fGeo[1]     = 0.2;
117   fGeo[2]     = 4.;
118   fPadSize[0] = 0.8;
119   fPadSize[1] = 1.0;
120   fPadSize[2] = 1.2;
121   fPadSize[3] = 1.5;
122   fNumPads[0] = 0;
123   fNumPads[1] = 0;
124   fNumPads[2] = 0;
125   fNumPads[3] = 0;
126 }
127
128 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
129 {
130   // Makes PMD Loader
131  
132   fLoader = new AliPMDLoader(GetName(),topfoldername);
133  
134   if (fLoader)
135     {
136       AliDebug(100,"Success");
137     }
138   else
139     {
140       AliError("Failure");
141     }
142
143   return fLoader;
144 }
145
146 AliPMD::~AliPMD()
147 {
148   //
149   // Destructor
150   //
151 }
152
153 //_____________________________________________________________________________
154 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
155 {
156   //
157   // Add a PMD hit
158   //
159   TClonesArray &lhits = *fHits;
160   AliPMDhit *newcell, *curcell;
161   //  printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
162   // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
163   // vol[4],vol[5],vol[6],vol[7]);
164
165   newcell = new AliPMDhit(fIshunt, track, vol, hits);
166
167   for (Int_t i=0; i<fNhits; i++) {
168     //
169     // See if this cell has already been hit
170     curcell=(AliPMDhit*) lhits[i];
171     if (*curcell==*newcell) {
172 //        printf("Cell with same numbers found\n") ; curcell->Print();
173       *curcell = *curcell+*newcell;
174 //        printf("Cell after addition\n") ; curcell->Print();
175       delete newcell;
176       return;
177     }
178   }
179   new(lhits[fNhits++]) AliPMDhit(newcell);
180   delete newcell;
181 }
182  
183 //_____________________________________________________________________________
184 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
185 {
186   //
187   // Set PMD parameters
188   //
189   fPar[0] = p1;
190   fPar[1] = p2;
191   fPar[2] = p3;
192   fPar[3] = p4;
193 }
194  
195 //_____________________________________________________________________________
196 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
197 {
198   //
199   // Set PMD parameters
200   //
201   fIn[0] = p1;
202   fIn[1] = p2;
203   fIn[2] = p3;
204   fIn[3] = p4;
205   fIn[4] = p5;
206 }
207  
208 //_____________________________________________________________________________
209 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
210 {
211   //
212   // Set geometry parameters
213   //
214   fGeo[0] = p1;
215   fGeo[1] = p2;
216   fGeo[2] = p3;
217 }
218  
219 //_____________________________________________________________________________
220 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
221 {
222   //
223   // Set pad size
224   //
225   fPadSize[0] = p1;
226   fPadSize[1] = p2;
227   fPadSize[2] = p3;
228   fPadSize[3] = p4;
229 }
230  
231 //_____________________________________________________________________________
232 void AliPMD::StepManager()
233 {
234   //
235   // Called at every step in PMD
236   //
237 }
238
239 void AliPMD::MakeBranch(Option_t* option)
240 {
241     // Create Tree branches for the PMD
242     
243     const char *cH = strstr(option,"H");
244     if (cH && fLoader->TreeH() && (fHits == 0x0))
245       fHits   = new TClonesArray("AliPMDhit",  405);
246     
247     AliDetector::MakeBranch(option);
248 }
249
250
251 void AliPMD::SetTreeAddress()
252 {
253   // Set branch address
254
255     if (fLoader->TreeH() && fHits==0x0)
256       fHits   = new TClonesArray("AliPMDhit",  405);
257       
258     AliDetector::SetTreeAddress();
259 }
260
261 void AliPMD::SetCpvOff()
262 {
263   // Set the CPV plane off
264 }
265 void AliPMD::SetPreOff()
266 {
267   // Set the Preshower plane off
268
269 }
270 void AliPMD::SetModuleOff(Int_t /*imodule*/)
271 {
272   // Set the desired module off
273
274 }
275
276 //____________________________________________________________________________
277 void AliPMD::Hits2SDigits()  
278
279 // create summable digits
280
281   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
282   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
283   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
284                                "HS");
285   pmdDigitizer->SetZPosition(361.5);
286
287   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
288     pmdDigitizer->Hits2SDigits(iEvent);
289   }
290   fLoader->UnloadHits();
291   fLoader->UnloadSDigits();
292   delete pmdDigitizer;
293 }
294 //____________________________________________________________________________
295 void AliPMD::SDigits2Digits()  
296
297   // creates sdigits to digits
298 }
299 //____________________________________________________________________________
300 void AliPMD::Hits2Digits()  
301
302 // create digits
303
304   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
305   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
306   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
307                                "HD");
308   pmdDigitizer->SetZPosition(361.5);
309
310   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
311     pmdDigitizer->Hits2Digits(iEvent);
312   }
313   fLoader->UnloadHits();
314   fLoader->UnloadDigits();
315   delete pmdDigitizer;
316
317 }
318 // ---------------------------------------------------------------------------
319 AliDigitizer* AliPMD::CreateDigitizer(AliDigitizationInput* digInput) const
320
321   return new AliPMDDigitizer(digInput);
322 }
323 // ---------------------------------------------------------------------------
324 void AliPMD::Digits2Raw()
325
326 // convert digits of the current event to raw data
327
328   fLoader->LoadDigits();
329   TTree* digits = fLoader->TreeD();
330   if (!digits) {
331     AliError("No digits tree");
332     return;
333   }
334
335   AliPMDDDLRawData rawWriter;
336   rawWriter.WritePMDRawData(digits);
337
338   fLoader->UnloadDigits();
339 }
340
341 Bool_t AliPMD::Raw2SDigits(AliRawReader *rawReader)
342 {
343   // converts raw to sdigits
344   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
345   //runLoader->GetEvent(ievt);
346
347   AliPMDRawToSDigits pmdr2sd;
348   pmdr2sd.Raw2SDigits(runLoader, rawReader);
349   fLoader->UnloadSDigits();
350   return kTRUE;
351 }
352