]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSTrigger.cxx
Additional changes for report #70680 AliROOT Coverity DELETE_ARRAY checker fix
[u/mrichter/AliRoot.git] / ITS / AliITSTrigger.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
17 /* $Id$ */
18
19 ////////////////////////////////////////////////////////////////////////
20 //                                                                    //
21 // Simulates generation of Fast-OR signals from SPD (if needed).      //
22 // Processes the Fast-OR signals generated in AliITSsimulationSPD.    //
23 // Provides inputs for AliCentralTrigger.                             //
24 //                                                                    //
25 // Version 2, Henrik Tydesjo, Feb 2009                                //
26 // Version 1, D. Elia, C. Jorgensen, Mar 2006                         //
27 // Version 0, J. Conrad, E. Lopez Torres, Oct 2005                    //
28 //                                                                    //
29 ////////////////////////////////////////////////////////////////////////
30
31 #include "AliITSTrigger.h"
32 #include "AliLog.h"
33 #include "AliRun.h"
34 #include "AliRunLoader.h"
35 #include "AliITSLoader.h"
36 #include "AliTriggerInput.h"
37
38 ClassImp(AliITSTrigger)
39
40 //______________________________________________________________________
41 AliITSTrigger::AliITSTrigger() : 
42   AliTriggerDetector(),
43   fPITprocessor()
44 {
45   //standard constructor
46   SetName("ITS");
47 }
48 //______________________________________________________________________
49 AliITSTrigger::AliITSTrigger(AliITSTriggerConditions* cond) : 
50   AliTriggerDetector(),
51   fPITprocessor(cond)
52 {
53   // optional constructor
54   SetName("ITS");
55 }
56 //______________________________________________________________________
57 void AliITSTrigger::SetTriggerConditions(AliITSTriggerConditions* cond) {
58   // Sets the trigger conditions, normally coming from OCDB
59   fPITprocessor.SetTriggerConditions(cond);
60 }
61 //______________________________________________________________________
62 void AliITSTrigger::CreateInputs() {
63   // Create inputs, based on OCDB Pixel Trigger Conditions
64   if( fInputs.GetEntriesFast() > 0 ) return; // Inputs already created, no need to proceed
65   
66   // Load trigger conditions from OCDB if needed
67   if (! fPITprocessor.TriggerConditionsSet() ) {
68     AliError("Trigger conditions not set. No inputs created.");
69     return;
70   }
71
72   UInt_t numInputs = fPITprocessor.GetNumOutputs();
73   AliInfo(Form("Number of trigger inputs: %d",numInputs));
74   for (UInt_t inp=0; inp<numInputs; inp++) {
75     fInputs.AddLast( new AliTriggerInput(fPITprocessor.GetOutputLabel(inp), "SPD", 0) );
76   }
77 }
78 //______________________________________________________________________
79 void AliITSTrigger::Trigger() {
80   // Performs Pixel Trigger processing of the simulated fast-or signals
81
82   // Get the FO signals for this event
83   AliITSFOSignalsSPD* foSignals = NULL;
84   AliRunLoader* runLoader = AliRunLoader::Instance();
85   AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
86   if (!itsLoader) {
87     AliError("ITS loader is NULL.");
88   }
89
90    else {
91       itsLoader->LoadDigits();
92       TTree *tree = itsLoader->TreeD();
93       if(!tree) {
94         AliError("TreeD not available");
95         itsLoader->UnloadDigits();
96         return;
97       }
98       foSignals = (AliITSFOSignalsSPD*)tree->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
99       if(!foSignals) AliError("FO signals not retrieved");
100      }
101
102   // Process the FO signals
103   if (foSignals) {
104     fPITprocessor.PreprocessFOSignals(foSignals);
105     UInt_t numInputs = fPITprocessor.GetNumOutputs();
106     for (UInt_t inp=0; inp<numInputs; inp++) {
107       if (fPITprocessor.ProcessFOSignalsIndex(inp, foSignals)) {
108         SetInput(fPITprocessor.GetOutputLabel(inp));
109       }
110     }
111   }
112   else {
113     AliError("Fast-OR signals not available. No trigger processing done.");
114   }
115   if (itsLoader) itsLoader->UnloadDigits();
116 }