1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
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 //
28 <img src="picts/AliPMDClass.gif">
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>.
39 ///////////////////////////////////////////////////////////////////////////////
42 #include <TClonesArray.h>
43 #include <TGeometry.h>
46 #include <TVirtualMC.h>
49 #include "AliLoader.h"
50 #include "AliPMDLoader.h"
54 #include "AliPMDDigitizer.h"
55 #include "AliPMDhit.h"
56 #include "AliPMDDDLRawData.h"
57 #include "AliPMDRawToSDigits.h"
61 //_____________________________________________________________________________
65 // Default constructor
71 //_____________________________________________________________________________
72 AliPMD::AliPMD(const char *name, const char *title)
73 : AliDetector(name,title)
76 // Default constructor
80 // Allocate the array of hits
81 fHits = new TClonesArray("AliPMDhit", 405);
82 gAlice->GetMCApp()->AddHitList(fHits);
105 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
109 fLoader = new AliPMDLoader(GetName(),topfoldername);
113 AliDebug(100,"Success");
130 //_____________________________________________________________________________
131 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
136 TClonesArray &lhits = *fHits;
137 AliPMDhit *newcell, *curcell;
138 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
139 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
140 // vol[4],vol[5],vol[6],vol[7]);
142 newcell = new AliPMDhit(fIshunt, track, vol, hits);
144 for (i=0; i<fNhits; i++) {
146 // See if this cell has already been hit
147 curcell=(AliPMDhit*) lhits[i];
148 if (*curcell==*newcell) {
149 // printf("Cell with same numbers found\n") ; curcell->Print();
150 *curcell = *curcell+*newcell;
151 // printf("Cell after addition\n") ; curcell->Print();
156 new(lhits[fNhits++]) AliPMDhit(newcell);
160 //_____________________________________________________________________________
161 void AliPMD::BuildGeometry()
164 // Build simple ROOT TNode geometry for event display
168 const int kColorPMD = kRed;
171 top=gAlice->GetGeometry()->GetNode("alice");
174 new TBRIK("S_PMD","PMD box","void",300,300,5);
176 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
177 node->SetLineColor(kColorPMD);
181 //_____________________________________________________________________________
182 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
185 // Set PMD parameters
193 //_____________________________________________________________________________
194 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
197 // Set PMD parameters
206 //_____________________________________________________________________________
207 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
210 // Set geometry parameters
217 //_____________________________________________________________________________
218 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
229 //_____________________________________________________________________________
230 void AliPMD::StepManager()
233 // Called at every step in PMD
237 void AliPMD::MakeBranch(Option_t* option)
239 // Create Tree branches for the PMD
241 const char *cH = strstr(option,"H");
242 if (cH && fLoader->TreeH() && (fHits == 0x0))
243 fHits = new TClonesArray("AliPMDhit", 405);
245 AliDetector::MakeBranch(option);
249 void AliPMD::SetTreeAddress()
251 // Set branch address
253 if (fLoader->TreeH() && fHits==0x0)
254 fHits = new TClonesArray("AliPMDhit", 405);
256 AliDetector::SetTreeAddress();
259 //____________________________________________________________________________
260 void AliPMD::Hits2SDigits()
262 // create summable digits
264 AliRunLoader* runLoader = fLoader->GetRunLoader();
265 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
266 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
268 pmdDigitizer->SetZPosition(361.5);
270 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
271 pmdDigitizer->Hits2SDigits(iEvent);
273 fLoader->UnloadHits();
274 fLoader->UnloadSDigits();
277 //____________________________________________________________________________
278 void AliPMD::SDigits2Digits()
280 // creates sdigits to digits
282 //____________________________________________________________________________
283 void AliPMD::Hits2Digits()
287 AliRunLoader* runLoader = fLoader->GetRunLoader();
288 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
289 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
291 pmdDigitizer->SetZPosition(361.5);
293 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
294 pmdDigitizer->Hits2Digits(iEvent);
296 fLoader->UnloadHits();
297 fLoader->UnloadDigits();
301 // ---------------------------------------------------------------------------
302 AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager) const
304 return new AliPMDDigitizer(manager);
306 // ---------------------------------------------------------------------------
307 void AliPMD::Digits2Raw()
309 // convert digits of the current event to raw data
311 fLoader->LoadDigits();
312 TTree* digits = fLoader->TreeD();
314 AliError("No digits tree");
318 AliPMDDDLRawData rawWriter;
319 rawWriter.WritePMDRawData(digits);
321 fLoader->UnloadDigits();
324 Bool_t AliPMD::Raw2SDigits(AliRawReader *rawReader)
326 // converts raw to sdigits
327 AliRunLoader* runLoader = fLoader->GetRunLoader();
328 //runLoader->GetEvent(ievt);
330 AliPMDRawToSDigits pmdr2sd;
331 pmdr2sd.Raw2SDigits(runLoader, rawReader);
332 fLoader->UnloadSDigits();