]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUON.cxx
Removing some compilation warnings.
[u/mrichter/AliRoot.git] / MUON / AliMUON.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 // Class AliMUON
20 // ------------------
21 // AliDetector class for MUON subsystem 
22 // providing simulation data management 
23 //-----------------------------------------------------------------------------
24
25 #include "AliMUON.h"
26
27 #include "AliMUONSDigitizerV2.h"
28 #include "AliMUONDigitizerV3.h"
29 #include "AliMUONDigitMaker.h"
30 #include "AliMUONCalibrationData.h"
31
32 #include "AliMUONDigitStoreV1.h"
33 #include "AliMUONVTriggerStore.h"
34 #include "AliMUONHitStoreV1.h"
35
36 #include "AliMUONChamberTrigger.h"
37 #include "AliMUONConstants.h"
38 #include "AliMUONGeometry.h"
39 #include "AliMUONGeometryTransformer.h"
40 #include "AliMUONGeometryBuilder.h"
41 #include "AliMUONVGeometryBuilder.h"    
42 #include "AliMUONCommonGeometryBuilder.h"
43 #include "AliMUONSt1GeometryBuilderV2.h"
44 #include "AliMUONSt2GeometryBuilderV2.h"
45 #include "AliMUONSlatGeometryBuilder.h"
46 #include "AliMUONTriggerGeometryBuilder.h"
47
48 #include "AliMUONRawWriter.h"
49
50 #include "AliLoader.h"
51 #include "AliCDBManager.h"
52 #include "AliRunDigitizer.h"
53 #include "AliMC.h"
54 #include "AliRun.h"
55 #include "AliRawDataHeaderSim.h"
56 #include "AliLog.h"
57
58 #include <TObjArray.h>
59
60 // Defaults parameters for Z positions of chambers
61 // taken from values for "stations" in AliMUON::AliMUON
62 //     const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
63 // and from array "dstation" in AliMUONv1::CreateGeometry
64 //          Float_t dstation[5]={20., 20., 20, 20., 20.};
65 //     for tracking chambers,
66 //          according to (Z1 = zch - dstation) and  (Z2 = zch + dstation)
67 //          for the first and second chambers in the station, respectively,
68 // and from "DTPLANES" in AliMUONv1::CreateGeometry
69 //           const Float_t DTPLANES = 15.;
70 //     for trigger chambers,
71 //          according to (Z1 = zch) and  (Z2 = zch + DTPLANES)
72 //          for the first and second chambers in the station, respectively
73
74 /// \cond CLASSIMP
75 ClassImp(AliMUON)  
76 /// \endcond
77
78 //__________________________________________________________________
79 AliMUON::AliMUON()
80   : AliDetector(),
81     fNCh(0),
82     fNTrackingCh(0),
83     fSplitLevel(0),
84     fChambers(0),
85     fGeometryBuilder(0),
86     fAccCut(kFALSE),
87     fAccMin(0.),
88     fAccMax(0.),   
89     fMaxStepGas(0.),
90     fMaxStepAlu(0.),
91     fMaxDestepGas(0.),
92     fMaxDestepAlu(0.),
93     fMaxIterPad(0),
94     fCurIterPad(0),
95     fTriggerScalerEvent(kFALSE),
96     fTriggerResponseV1(kFALSE),
97     fTriggerCoinc44(0),
98     fTriggerEffCells(0),
99     fDigitizerWithNoise(1),
100     fDigitizerNSigmas(4.0),
101     fIsTailEffect(kTRUE),
102     fRawWriter(0x0),
103     fDigitMaker(0x0),
104     fHitStore(0x0),
105     fDigitStoreConcreteClassName(),
106     fCalibrationData(0x0)
107 {
108 /// Default Constructor
109     
110     AliDebug(1,Form("default (empty) ctor this=%p",this));
111     fIshunt          = 0;
112 }
113
114 //__________________________________________________________________
115 AliMUON::AliMUON(const char *name, const char* title)
116   : AliDetector(name, title),
117     fNCh(AliMUONConstants::NCh()),
118     fNTrackingCh(AliMUONConstants::NTrackingCh()),
119     fSplitLevel(0),
120     fChambers(0),
121     fGeometryBuilder(0),
122     fAccCut(kFALSE),
123     fAccMin(0.),
124     fAccMax(0.),   
125     fMaxStepGas(0.1),
126     fMaxStepAlu(0.1),
127     fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200 
128     fMaxDestepAlu(-1), // in the calculation of the tracking parameters
129     fMaxIterPad(0),
130     fCurIterPad(0),
131     fTriggerScalerEvent(kFALSE),
132     fTriggerResponseV1(kFALSE),
133     fTriggerCoinc44(0),
134     fTriggerEffCells(0),
135     fDigitizerWithNoise(1),
136     fDigitizerNSigmas(4.0),
137     fIsTailEffect(kTRUE),
138     fRawWriter(0x0),
139     fDigitMaker(new AliMUONDigitMaker),
140     fHitStore(0x0),
141     fDigitStoreConcreteClassName("AliMUONDigitStoreV2S"),
142     fCalibrationData()
143 {
144   /// Standard constructor  
145   
146   AliDebug(1,Form("ctor this=%p",this));
147   fIshunt =  0;
148   
149   //PH SetMarkerColor(kRed);//
150     
151   // Geometry builder
152   fGeometryBuilder = new AliMUONGeometryBuilder(this);
153   
154   // Common geometry definitions
155   fGeometryBuilder
156     ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
157   
158   // By default, add also all the needed geometry builders.
159   // If you want to change this from outside, please use ResetGeometryBuilder
160   // method, followed by AddGeometryBuilder ones.
161   
162   AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
163   AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
164   AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
165   AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
166   
167   //
168   // Creating List of Chambers
169     Int_t ch;
170     fChambers = new TObjArray(AliMUONConstants::NCh());
171     fChambers->SetOwner(kTRUE);
172     
173     // Loop over stations
174     for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
175       // Loop over 2 chambers in the station
176       for (Int_t stCH = 0; stCH < 2; stCH++) {
177         //
178         //    
179         //    Default Parameters for Muon Tracking Stations
180         ch = 2 * st + stCH;
181         if (ch < AliMUONConstants::NTrackingCh()) {
182           fChambers->AddAt(new AliMUONChamber(ch),ch);
183         } else {
184           fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
185         }
186       } // Chamber stCH (0, 1) in 
187     }     // Station st (0...)
188   
189   Int_t runnumber = AliCDBManager::Instance()->GetRun();
190   
191   fCalibrationData = new AliMUONCalibrationData(runnumber);
192 }
193
194 //____________________________________________________________________
195 AliMUON::~AliMUON()
196 {
197 /// Destructor
198
199   AliDebug(1,Form("dtor this=%p",this));
200   delete fChambers;
201   delete fGeometryBuilder;
202   delete fRawWriter;
203   delete fDigitMaker;
204   delete fHitStore;
205   delete fCalibrationData;
206 }
207
208 //_____________________________________________________________________________
209 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
210 {
211 /// Add the geometry builder to the list
212
213   fGeometryBuilder->AddBuilder(geomBuilder);
214 }
215
216 //____________________________________________________________________
217 const AliMUONGeometry*  AliMUON::GetGeometry() const
218 {
219 /// Return geometry parametrisation
220
221   if ( !fGeometryBuilder) {
222     AliWarningStream() << "GeometryBuilder not defined." << std::endl;
223     return 0;
224   }
225   
226   return fGeometryBuilder->GetGeometry();
227 }   
228
229 //____________________________________________________________________
230 const AliMUONGeometryTransformer*  AliMUON::GetGeometryTransformer() const
231 {
232 /// Return geometry parametrisation
233
234   const AliMUONGeometry* kGeometry = GetGeometry();
235   
236   if ( !kGeometry) return 0;
237
238   return kGeometry->GetTransformer();
239 }   
240
241 //__________________________________________________________________
242 void 
243 AliMUON::MakeBranch(Option_t* opt)
244 {
245   /// Create branche(s) to hold MUON hits
246   AliDebug(1,"");
247   
248   TString sopt(opt);
249   if ( sopt != "H" ) return;
250     
251   if (!fHitStore)
252   {
253     fHitStore = new AliMUONHitStoreV1;
254     if ( gAlice->GetMCApp() )
255     {
256       if ( gAlice->GetMCApp()->GetHitLists() ) 
257       {
258         // AliStack::PurifyKine needs to be able to loop on our hits
259         // to remap the track numbers.
260         gAlice->GetMCApp()->AddHitList(fHitStore->Collection()); 
261       }  
262     }
263   }
264
265   TTree* treeH = fLoader->TreeH();
266   
267   if (!treeH)
268   {
269     AliFatal("No TreeH");
270   }
271   
272   fHitStore->Connect(*treeH);
273 }
274
275 //__________________________________________________________________
276 void  
277 AliMUON::SetTreeAddress()
278 {
279   /// Set Hits tree address  
280  
281 //  if ( gAlice->GetMCApp() && fHitStore )
282 //  {
283 //    TList* l = gAlice->GetMCApp()->GetHitLists();
284 //    if ( l )
285 //    {
286 //      TObject* o = l->First();
287 //      if (o!=fHitStore->HitCollection())
288 //      {
289 //        AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
290 //        l->Print();        
291 //      }
292 //    }  
293 //  }  
294 }
295
296 //_________________________________________________________________
297 void
298 AliMUON::ResetHits()
299 {
300   /// Reset hits
301   
302   AliDebug(1,"");
303   if (fHitStore) fHitStore->Clear();
304 }
305
306 //_________________________________________________________________
307 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
308 {
309 /// Set the inverse charge slope for chamber id
310
311     Int_t i=2*(id-1);    //PH    ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
312     //PH    ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
313     ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
314     ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
315 }
316 //__________________________________________________________________
317 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
318 {
319 /// Set sigma of charge spread for chamber id
320
321     Int_t i=2*(id-1);
322     ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
323     ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
324 }
325 //___________________________________________________________________
326 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
327 {
328 /// Set integration limits for charge spread
329     Int_t i=2*(id-1);
330     ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
331     ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
332 }
333
334 //__________________________________________________________________
335 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
336 {
337 /// Set maximum number for ADCcounts (saturation)
338
339     Int_t i=2*(id-1);
340     ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
341     ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
342 }
343
344 //__________________________________________________________________
345 void AliMUON::SetMaxStepGas(Float_t p1)
346 {
347 /// Set stepsize in gas
348
349   fMaxStepGas=p1;
350 }
351 //__________________________________________________________________
352 void AliMUON::SetMaxStepAlu(Float_t p1)
353 {
354 /// Set step size in Alu
355
356     fMaxStepAlu=p1;
357 }
358 //__________________________________________________________________
359 void AliMUON::SetMaxDestepGas(Float_t p1)
360 {
361 /// Set maximum step size in Gas
362
363     fMaxDestepGas=p1;
364 }
365 //__________________________________________________________________
366 void AliMUON::SetMaxDestepAlu(Float_t p1)
367 {
368 /// Set maximum step size in Alu
369
370   fMaxDestepAlu=p1;
371 }
372
373 //____________________________________________________________________
374 Float_t  AliMUON::GetMaxStepGas() const
375 {
376 /// Return stepsize in gas
377   
378   return fMaxStepGas;
379 }  
380
381 //____________________________________________________________________
382 Float_t  AliMUON::GetMaxStepAlu() const
383 {
384 /// Return step size in Alu
385   
386   return fMaxStepAlu;
387 }
388   
389 //____________________________________________________________________
390 Float_t  AliMUON::GetMaxDestepGas() const
391 {
392 /// Return maximum step size in Gas
393   
394   return fMaxDestepGas;
395 }
396   
397 //____________________________________________________________________
398 Float_t  AliMUON::GetMaxDestepAlu() const
399 {
400 /// Return maximum step size in Gas
401   
402   return fMaxDestepAlu;
403 }
404
405 //____________________________________________________________________
406  void  AliMUON::SetAlign(Bool_t align)
407 {
408 /// Set option for alignement to geometry builder
409  
410    fGeometryBuilder->SetAlign(align);
411 }   
412
413 //____________________________________________________________________
414  void  AliMUON::SetAlign(const TString& fileName, Bool_t align)
415 {
416 /// Set option for alignement to geometry builder
417  
418    fGeometryBuilder->SetAlign(fileName, align);
419 }   
420
421 //____________________________________________________________________
422 void   AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
423 {
424 /// Set the response for chamber id
425     ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
426 }
427
428 //____________________________________________________________________
429 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
430 {
431 /// Return digitizer
432   
433   AliMUONDigitizerV3* digitizer = new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
434   AliMUONDigitizerV3::SetNSigmas(fDigitizerNSigmas);
435   digitizer->SetCalibrationData(fCalibrationData);
436   return digitizer;
437 }
438
439 //_____________________________________________________________________
440 void AliMUON::SDigits2Digits()
441 {
442 /// Write TreeD here only 
443
444     char hname[30];
445     //    sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
446     fLoader->TreeD()->Write(hname,TObject::kOverwrite);
447     fLoader->TreeD()->Reset();
448 }
449
450 //_____________________________________________________________________
451 void AliMUON::Hits2SDigits()
452 {
453 /// Perform Hits2Digits using SDigitizerV2
454   
455   AliMUONSDigitizerV2 sdigitizer;
456   sdigitizer.ExecuteTask();
457 }
458
459 //_____________________________________________________________________
460 void AliMUON::Digits2Raw()
461 {
462 /// Convert digits of the current event to raw data
463
464   AliRawDataHeaderSim header;
465
466   if (!fRawWriter)
467   {
468     fRawWriter = new AliMUONRawWriter;
469     AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
470     if (fTriggerScalerEvent == kTRUE) 
471     {
472       fRawWriter->SetScalersNumbers();
473     }
474   }
475   
476   fLoader->LoadDigits("READ");
477   
478   TTree* treeD = fLoader->TreeD();
479   
480   if (!treeD)
481   {
482     AliError("Could not get TreeD");
483     return;
484   }
485   
486   AliMUONVTriggerStore*  triggerStore = AliMUONVTriggerStore::Create(*treeD);
487   AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
488
489   triggerStore->Connect(*treeD,kFALSE);
490   digitStore->Connect(*treeD,kFALSE);
491   
492   treeD->GetEvent(0);
493   
494   fRawWriter->SetHeader(header);
495   if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
496   {
497     AliError("pb writting raw data");
498   }
499   
500   delete triggerStore;
501   delete digitStore;
502   
503   fLoader->UnloadDigits();
504 }
505
506 //_____________________________________________________________________
507 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
508 {
509 /// Convert  raw data to SDigit
510
511   fLoader->LoadDigits("READ");
512   if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
513
514   TTree* treeS = fLoader->TreeS();
515   
516   AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
517   sDigitStore->Connect(*treeS);
518   
519   fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
520
521   fLoader->WriteSDigits("OVERWRITE");
522
523   fLoader->UnloadSDigits();
524
525   delete sDigitStore;
526   
527   return kTRUE;
528 }
529
530 //_______________________________________________________________________
531 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
532
533 /// Build standard getter (AliLoader type);
534 /// if detector wants to use castomized getter, it must overload this method
535  
536  AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
537          GetName(),topfoldername));
538  fLoader   = new AliLoader(GetName(),topfoldername);
539
540  return fLoader;
541 }
542
543 //________________________________________________________________________
544 void
545 AliMUON::ResetGeometryBuilder()
546 {
547 /// Only to be used by "experts" wanting to change the geometry builders
548 /// to be used. 
549 /// As the ctor of AliMUON now defines a default geometrybuilder, this
550 /// ResetGeometryBuilder() must be called prior to call the 
551 /// AddGeometryBuilder()
552
553   delete fGeometryBuilder;
554   fGeometryBuilder = new AliMUONGeometryBuilder(this);
555   fGeometryBuilder
556     ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
557 }
558
559 //____________________________________________________________________
560 Bool_t  AliMUON::GetTriggerResponseV1() const
561 {
562 ///
563 /// Returns fTriggerResponseV1
564 ///  
565     return fTriggerResponseV1;
566     
567 }  
568
569 //____________________________________________________________________
570 Int_t  AliMUON::GetTriggerCoinc44() const
571 {
572 ///
573 /// Returns fTriggerCoinc44
574 ///  
575     return fTriggerCoinc44;
576     
577 }
578
579 //____________________________________________________________________
580 Bool_t  AliMUON::GetTriggerEffCells() const
581 {
582 ///
583 /// Returns fTriggerEffCells
584 ///  
585     return fTriggerEffCells;
586     
587 }  
588
589 //____________________________________________________________________
590 Int_t  AliMUON::GetDigitizerWithNoise() const
591 {
592 ///
593 /// Returns fDigitizerWithNoise
594 ///  
595     return fDigitizerWithNoise;
596     
597 }  
598
599