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 **************************************************************************/
16 /* $Id: AliADDigitizer.cxx $ */
18 ///_________________________________________________________________________
20 /// This class constructs Digits out of Hits
24 // --- Standard library ---
26 // --- ROOT system ---
30 #include <TGeoManager.h>
31 #include <TGeoPhysicalNode.h>
32 #include <AliGeomManager.h>
37 // --- AliRoot header files ---
41 #include "AliRunLoader.h"
42 #include "AliLoader.h"
43 #include "AliGRPObject.h"
44 #include "AliDigitizationInput.h"
45 #include "AliCDBManager.h"
46 #include "AliCDBStorage.h"
47 #include "AliCDBEntry.h"
48 //#include "AliADCalibData.h"
49 #include "AliCTPTimeParams.h"
50 #include "AliLHCClockPhase.h"
51 #include "AliADdigit.h"
52 #include "AliADDigitizer.h"
53 //#include "AliADSDigit.h"
55 ClassImp(AliADDigitizer)
57 //____________________________________________________________________________
58 AliADDigitizer::AliADDigitizer()
63 // default constructor
66 //____________________________________________________________________________
67 AliADDigitizer::AliADDigitizer(AliDigitizationInput* digInput)
68 :AliDigitizer(digInput),
75 //____________________________________________________________________________
76 AliADDigitizer::~AliADDigitizer()
88 //____________________________________________________________________________
89 Bool_t AliADDigitizer::Init()
91 fDigits = new TClonesArray ("AliADdigit",1000);
94 //____________________________________________________________________________
96 void AliADDigitizer::Digitize(Option_t* /*option*/)
98 // Creates digits from hits
101 Int_t modules[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
102 Int_t moduls[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
108 AliRunLoader* outRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
111 Error("Exec","Can not get output Run Loader");
114 AliLoader* outLoader = outRunLoader->GetLoader("ADLoader");
117 Error("Exec","Can not get output AD Loader");
121 outLoader->LoadDigits("update");
122 if (!outLoader->TreeD()) outLoader->MakeTree("D");
123 outLoader->MakeDigitsContainer();
124 TTree* treeD = outLoader->TreeD();
125 Int_t bufsize = 16000;
126 treeD->Branch("ADdigit",&fDigits, bufsize);
128 const Float_t eMin = 0;//1.52; //! MeVs, minimum energy
131 for (Int_t iInput=0; iInput < fDigInput->GetNinputs();iInput++)
133 AliRunLoader* runLoader = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(iInput));
134 AliLoader* loader = runLoader->GetLoader("ADLoader");
137 Error("Exec","Can not get AD Loader for input %d",iInput);
140 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
141 AliAD* ad = (AliAD*) runLoader->GetAliRun()->GetDetector("AD");
144 Error("Exec","No AD detector for input %d",iInput);
148 TTree* treeH = loader->TreeH();
151 Error("Exec","Cannot get TreeH for input %d",iInput);
154 TClonesArray* hits = ad->Hits();
156 // here I loop over tracks
157 Int_t nTracks = (Int_t) treeH->GetEntries();
158 for (Int_t iTrack=0; iTrack < nTracks; iTrack++)
161 treeH->GetEvent(iTrack);
162 Int_t nHits = hits->GetEntriesFast();
163 // here comes the loop over AD hits
164 for (Int_t iHit=0; iHit < nHits; iHit++)
166 AliADhit* hit = (AliADhit *)hits->UncheckedAt(iHit);
167 Float_t eloss_mev = hit->GetEloss()*1000.0;
168 Int_t module = hit->GetModule();
169 //cout << "Module AD!!! " << module << endl;
170 // at some point we shoukd have some calib objects to set real theresholds
171 // simple checking on hit, minimum energy at scintillator pad should be > 1.52 MeV's
172 if (eloss_mev > eMin)
174 modules[module] = 1;//cout << "energy: " << eloss_mev << endl;
175 }else modules[module] = 0;
176 }// end loop over hits
177 } // endo loop over tracks
178 for (Int_t i=0; i<16; i++)
180 moduls[i] = modules[i];
181 //cout << "iModule: " << i << " AD hits: " << moduls[i] << endl;
184 loader->UnloadHits();
186 } // end loop over inputs
188 // here I add the hits to the TreeD
190 Int_t tracks[3] = {-1,-1,-1};
191 for (Int_t i=0; i<16; i++)
196 AddDigit(tracks,mods,mods);
200 outLoader->WriteDigits("OVERWRITE");
201 outLoader->UnloadDigits();
205 //____________________________________________________________________________
206 void AliADDigitizer::AddDigit(Int_t* track, Int_t module, Float_t cell)
209 TClonesArray &ldigits = *fDigits;
210 new(ldigits[fNdigits++]) AliADdigit(track,module,cell);
212 //____________________________________________________________________________
213 void AliADDigitizer::AddDigit(Int_t* modul,Float_t cell)
216 TClonesArray &ldigits = *fDigits;
217 new(ldigits[fNdigits++]) AliADdigit(modul,cell);
220 //____________________________________________________________________________
221 void AliADDigitizer::ResetDigit()
225 if (fDigits) fDigits->Delete();