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 ///////////////////////////////////////////////////////////////////////////////
18 // FIT ( Fast Interaction Trigger ) Detector //
19 // This class contains the base procedures for the FIT //
24 <img src="gif/AliFITClass.gif">
27 <font size=+2 color=red>
28 <p>The responsible person for this module is
29 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
36 ///////////////////////////////////////////////////////////////////////////////
38 #include "TClonesArray.h"
41 #include "AliLoader.h"
47 #include "AliFITDigitizer.h"
48 #include "AliFITDigit.h"
49 #include "AliFITHits.h"
50 #include "AliFITRawData.h"
51 #include "AliFITRawReader.h"
55 //static AliFITdigit *digits;
57 //_____________________________________________________________________________
64 // Default constructor for class AliFIT
68 fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector
72 //_____________________________________________________________________________
73 AliFIT::AliFIT(const char *name, const char *title)
74 : AliDetector(name,title),
76 /* , fDigits(new AliFITDigit())*/
79 // Standard constructor for T0 Detector
82 // Initialise Hit array
83 AliMC* mc = gAlice->GetMCApp();
84 if( mc && mc->GetHitLists() ) {
85 fHits = new TClonesArray("AliFITHits",100); // from AliDetector
86 mc->AddHitList(fHits);
90 fDigits = new TClonesArray("AliFITDigit",100); // from AliDetector
93 //PH SetMarkerColor(kRed);
96 //_____________________________________________________________________________
108 cout<<" delete fDigits; "<<endl;
111 fRecPoints ->Delete();
113 cout<<" delete fRecPoints; "<<endl;
118 //_____________________________________________________________________________
119 void AliFIT::AddHit(Int_t track, Int_t *vol, Float_t *hits)
124 TClonesArray &lhits = *fHits;
125 new(lhits[fNhits++]) AliFITHits(fIshunt,track,vol,hits);
128 //____________________________________________________________________________
129 void AliFIT::AddDigit(Int_t npmt,
130 Int_t timeCFD, Int_t timeLED, Int_t timeQT0,
131 Int_t timeQT1, Int_t *labels)
135 TClonesArray &ldigits = *fDigits;
136 new(ldigits[fNdigits++]) AliFITDigit( npmt,timeCFD, timeLED, timeQT0, timeQT1, labels);
140 //-------------------------------------------------------------------------
144 // Initialis the T0 after it has been built
147 // if(AliLog::GetGlobalDebugLevel()>0) {
148 printf("\n%s: ",ClassName());
149 for(i=0;i<35;i++) printf("*");
150 printf(" FIT_INIT ");
151 for(i=0;i<35;i++) printf("*");
152 printf("\n%s: ",ClassName());
154 // Here the T0 initialisation code (if any!)
155 for(i=0;i<80;i++) printf("*");
160 //---------------------------------------------------------------------------
161 void AliFIT::MakeBranch(Option_t* option)
164 // Create Tree branches for the T0.
168 // H Make a branch of TClonesArray of AliT0Hit's
169 // D Make a branch of TClonesArray of AliT0Digit's
171 // R Make a branch of AliT0RecPointUps
173 // char branchname[20];
174 // sprintf(branchname,"%s",GetName());
175 // strncpy(branchname, GetName(), 20);
176 TString branchname = Form("%s", GetName());
178 const char *cH = strstr(option,"H");
179 const char *cD = strstr(option,"D");
180 const char *cS = strstr(option,"S");
182 if (cH && fLoader->TreeH())
184 if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405);
185 AliDetector::MakeBranch(option);
187 if (cD && fLoader->TreeD())
189 MakeBranchInTree(fLoader->TreeD(), GetName(),
190 &fDigits, 100, 0)->SetAddress(&fDigits);
191 // fLoader->TreeD()->Branch(branchname.Data(),"AliFITDigit",fDigits);
193 if (cS && fLoader->TreeS())
195 MakeBranchInTree(fLoader->TreeD(), branchname,
197 // fLoader->TreeS()->Branch(branchname,"AliFITDigit",&fDigits);
202 //_____________________________________________________________________________
203 void AliFIT::ResetHits()
208 AliDetector::ResetHits();
211 //____________________________________________________________________
212 void AliFIT::ResetDigits()
215 // Reset number of digits and the digits array for this detector
217 if (fDigits) fDigits->Clear();
221 //_____________________________________________________________________________
222 void AliFIT::SetTreeAddress()
225 TTree *treeH = fLoader->TreeH();
229 if (fHits == 0x0) fHits = new TClonesArray("AliFITHits", 405);
232 AliDetector::SetTreeAddress();
233 TTree *treeD = fLoader->TreeD();
235 if (fDigits == 0x0) fDigits = new TClonesArray("AliFITDigit",100);
236 TBranch* branch = treeD->GetBranch ("FIT");
237 if (branch) branch->SetAddress(&fDigits);
240 // SDigitizer for Federico
241 TTree *treeS = fLoader->TreeS();
243 // if (fDigits == 0x0) fDigits = new AliFITDigit();
244 TBranch* branch = treeS->GetBranch ("FIT");
245 if (branch) branch->SetAddress(&fDigits);
251 //_____________________________________________________________________________
252 AliDigitizer* AliFIT::CreateDigitizer(AliDigitizationInput* digInput) const
255 return new AliFITDigitizer(digInput);
258 //-------------------------------------------------------------------
259 void AliFIT::Digits2Raw()
262 // Starting from the FIT digits, writes the Raw Data objects
265 fLoader ->LoadDigits("read");
266 TTree* treeD = fLoader->TreeD();
268 AliError("no digits tree");
271 TBranch *branch = treeD->GetBranch("FIT");
273 AliFITRawData rawWriter;
274 rawWriter.SetVerbose(10);
276 AliDebug(2,Form(" Formatting raw data for FIT "));
278 rawWriter.RawDataFIT(branch);
281 fLoader->UnloadDigits();
285 //____________________________________________________________________________
286 void AliFIT::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
289 //FIT raw data-> digits conversion
290 // reconstruct time information from raw data
292 TClonesArray* digits = new TClonesArray ("AliFITDigit", 100);
293 digitsTree->Branch("FIT", &digits);
296 AliFITRawReader myrawreader(rawReader);
297 if (!myrawreader.Next())
298 AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
301 for (Int_t i=0; i<500; i++) allData[i]=0;
302 for (Int_t i=0; i<500; i++)
303 if(myrawreader.GetData(i)>0) allData[i]=myrawreader.GetData(i);
305 Int_t timeCFD, timeLED, timeQT1, timeQT0;
306 for (Int_t ipmt=0; ipmt<160; ipmt++) {
307 if(allData[ipmt]>0) {
308 timeCFD = allData[ipmt];
309 timeLED = allData[ipmt];
310 timeQT0= allData[ipmt+160];
311 timeQT1 = allData[ipmt+320];
312 AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0);
319 GetLoader()->WriteDigits("OVERWRITE");//write out digits