LCOV - code coverage report
Current view: top level - ACORDE/ACORDEsim - AliACORDETrigger.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 60 1.7 %
Date: 2016-06-14 17:26:59 Functions: 1 5 20.0 %

          Line data    Source code
       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             : #include <Riostream.h>
      17             : #include <TTree.h>
      18             : #include <TClonesArray.h>
      19             : 
      20             : #include "AliRun.h"
      21             : #include "AliRunLoader.h"
      22             : #include "AliACORDETrigger.h"
      23             : #include "AliACORDEConstants.h"
      24             : 
      25             : //______________________________________________________________________
      26             : using std::cout;
      27             : using std::endl;
      28          12 : ClassImp(AliACORDETrigger)
      29             : 
      30             : AliACORDETrigger::AliACORDETrigger()
      31           0 :   :AliTriggerDetector(),
      32           0 :    fSingleMuon(0),
      33           0 :    fMultiMuon(0)
      34           0 : {
      35             : 
      36           0 :   cout << " ================>>>>>>>>>>>>>>>>> AliACORDETrigger" << endl;
      37           0 :    SetName("ACORDE");
      38           0 :    CreateInputs();
      39           0 :    for (Int_t i=0; i<60; i++) fModuleFired[i]=kFALSE;
      40           0 : }
      41             : 
      42             : void AliACORDETrigger::CreateInputs()
      43             : {
      44             :   // Do not create inputs again!!
      45           0 :   if( fInputs.GetEntriesFast() > 0 ) return;
      46             : 
      47             :   // two acorde triggers, single muon and multicoincidence
      48           0 :   fInputs.AddLast( new 
      49           0 :                    AliTriggerInput( "0ASL", 
      50           0 :                                     "ACORDE", 0 ) );
      51           0 :   fInputs.AddLast( new 
      52           0 :                    AliTriggerInput( "0AMU",
      53           0 :                                     "ACORDE", 0 ) );
      54           0 : }
      55             : 
      56             : void AliACORDETrigger::Trigger()
      57             : {
      58             :   
      59             :   // 1.- Get loaders and pointers
      60             :   // 2.- Loop over all entries
      61             :   //     set temporal variables to default values
      62             :   //     start the loop
      63             :   // 3.- Loop over all digits in an entrie
      64             :   //     Fill temporal arrays
      65             :   //     Find module with lowest time
      66             :   // 4.- Loop over temporal arrays
      67             :   //     Find number of modules within the time window
      68             :   // 5.- Set the relevant trigger
      69             : 
      70             :   // 1.- Get loaders and pointers
      71           0 :   AliRunLoader* runLoader = AliRunLoader::Instance();
      72             :   AliACORDELoader* loader = 
      73           0 :     (AliACORDELoader* )runLoader->GetLoader( "ACORDELoader" );
      74           0 :   loader->LoadDigits("READ");
      75           0 :   TTree* acordeDigitsTree = loader->TreeD();
      76           0 :   if (!acordeDigitsTree) return;
      77           0 :   TClonesArray* acordeDigits = new TClonesArray("AliACORDEdigit",1000);
      78           0 :   TBranch* digitBranch = acordeDigitsTree->GetBranch("ACORDEdigit");
      79           0 :   digitBranch->SetAddress(&acordeDigits);
      80             : 
      81             :   // 2.- Loop over all entries
      82             :   //     set temporal variables to default values
      83             : 
      84           0 :   Int_t MultiMin = AliACORDEConstants::Instance()->MultiMuonThreshold();
      85           0 :   Float_t time_window = AliACORDEConstants::Instance()->MultiMuonWindow();
      86             :   Int_t MinTimeModule = -1;
      87             :   Float_t MinTime = 1e10;
      88           0 :   Float_t ModuleTimes[60];
      89           0 :   for (Int_t i=0; i<60; i++) ModuleTimes[i] = -1.0;
      90             : 
      91             :   //     start the loop
      92           0 :   Int_t nEntries = (Int_t)acordeDigitsTree->GetEntries();
      93           0 :   cout << " ===AliACORDETrigger=== nEntries  " <<nEntries << endl; 
      94           0 :   for (Int_t e=0; e<nEntries; e++) {
      95           0 :     acordeDigitsTree->GetEvent(e);
      96             :     // 3.- Loop over all digits in an entrie
      97             :     //     Fill temporal arrays
      98             :     //     Find module with lowest time
      99           0 :     Int_t nDigits = acordeDigits->GetEntriesFast();
     100           0 :     cout << " ===AliACORDETrigger=== nDigits  " <<nDigits << endl; 
     101           0 :     for (Int_t d=0; d<nDigits; d++) {
     102           0 :       AliACORDEdigit* digit = (AliACORDEdigit*)acordeDigits->At(d);
     103           0 :       Int_t module = digit->GetModule();
     104           0 :       Float_t mod_time = digit->GetTime();
     105           0 :       ModuleTimes[module-1]=mod_time;
     106           0 :       if (mod_time < MinTime) {
     107             :         MinTime = mod_time;
     108             :         MinTimeModule = module;
     109           0 :       }
     110             :     } // end of loop over digits
     111             :   } // end of loop over events in digits tree
     112             : 
     113             :   // 4.- Loop over temporal arrays
     114             :   //     Find number of modules within the time window
     115           0 :   if (MinTimeModule == -1) return;
     116           0 :   for (Int_t i=0; i<60; i++) {
     117           0 :     if (ModuleTimes[i]<0) continue;
     118           0 :     Float_t diff = ModuleTimes[i]-MinTime;
     119           0 :     if (diff<time_window) {
     120           0 :       fMultiMuon++;
     121           0 :       fModuleFired[i]=kTRUE;
     122           0 :     }
     123           0 :   }
     124           0 :   cout << " fSingleMuon " << fSingleMuon
     125           0 :        << " MinTime " << MinTime
     126           0 :        << " fMultiMuon " << fMultiMuon << endl;
     127             :   // 5.- Set the relevant trigger
     128           0 :   fSingleMuon = MinTimeModule;
     129           0 :   SetInput( "0ASL" );
     130           0 :   if (fMultiMuon>=MultiMin) SetInput( "0AMU" );
     131           0 :   return;
     132           0 : }

Generated by: LCOV version 1.11