LCOV - code coverage report
Current view: top level - HLT/TRD - AliHLTTRDEsdWriterComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 114 11.4 %
Date: 2016-06-14 17:26:59 Functions: 6 12 50.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        * 
       3             :  * ALICE Experiment at CERN, All rights reserved.                         *
       4             :  *                                                                        *
       5             :  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       6             :  *                  for The ALICE HLT Project.                            *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : /** @file   AliHLTTRDEsdWriterComponent.cxx
      18             :     @author Mateusz Ploskon
      19             :     @date   
      20             :     @brief  Writer component to store tracks of the HLT TRD
      21             : 
      22             :                                                                           */
      23             : #include "AliHLTTRDEsdWriterComponent.h"
      24             : #include "AliHLTTRDDefinitions.h"
      25             : #include "AliHLTTRDUtils.h"
      26             : #include "AliHLTCTPData.h"
      27             : #include "AliESDEvent.h"
      28             : #include "AliESDfriend.h"
      29             : #include "AliESDtrack.h"
      30             : #include "AliTRDtrackV1.h"
      31             : #include "TTree.h"
      32             : #include "TFile.h"
      33             : 
      34             : /** ROOT macro for the implementation of ROOT specific class methods */
      35           6 : ClassImp(AliHLTTRDEsdWriterComponent)
      36             : 
      37             : AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
      38           3 : :AliHLTRootFileWriterComponent()
      39           3 :   ,fTree(NULL)
      40           3 :   ,fFrTree(NULL)
      41           3 :   ,fESD(NULL)
      42           3 :   ,fESDfriend(NULL)
      43           3 :   ,fFile(NULL)
      44           3 :   ,fFrFile(NULL)
      45           3 :   ,fTracksArray(NULL)
      46          15 : {
      47             :   // see header file for class documentation
      48             :   // or
      49             :   // refer to README to build package
      50             :   // or
      51             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      52           6 : }
      53             : 
      54             : AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
      55           0 :   :AliHLTRootFileWriterComponent()
      56           0 :   ,fTree(NULL)
      57           0 :   ,fFrTree(NULL)
      58           0 :   ,fESD(NULL)
      59           0 :   ,fESDfriend(NULL)
      60           0 :   ,fFile(NULL)
      61           0 :   ,fFrFile(NULL)
      62           0 :   ,fTracksArray(NULL)
      63           0 : {
      64           0 : }
      65             : 
      66             : void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
      67             : {
      68             :   // Get the list of input data  
      69           0 :   list.clear(); // We do not have any requirements for our input data type(s).
      70           0 :   list.push_back( AliHLTTRDDefinitions::fgkTracksDataType );
      71           0 :   list.push_back( AliHLTTRDDefinitions::fgkHiLvlTracksDataType );
      72           0 : }
      73             : 
      74             : AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
      75          12 : {
      76             :   // see header file for class documentation
      77          12 : }
      78             : 
      79             : int AliHLTTRDEsdWriterComponent::InitWriter()
      80             : {
      81             :   // see header file for class documentation
      82             :   
      83           0 :   fFile = new TFile("AliHLTTRDESDs.root", "recreate");
      84           0 :   fESD = new AliESDEvent;
      85           0 :   fESD->CreateStdContent();
      86           0 :   fTree = new TTree("esdTree", "Tree with HLT::TRD ESD objects");
      87           0 :   fESD->WriteToTree(fTree);
      88           0 :   fFrFile = new TFile("AliHLTTRDESDfriends.root", "recreate");
      89           0 :   fESDfriend = new AliESDfriend();
      90           0 :   fFrTree = new TTree("esdFriendTree", "Tree with HLT::TRD ESD Friend objects");
      91           0 :   fFrTree->Branch("ESDfriend.","AliESDfriend", &fESDfriend);
      92           0 :   fESD->AddObject(fESDfriend);
      93           0 :   fFile->cd();
      94           0 :   fTree->GetUserInfo()->Add(fESD);
      95           0 :   fTracksArray = new TClonesArray("AliTRDtrackV1");
      96             : 
      97           0 :   SetupCTPData();
      98             : 
      99           0 :   return 0;
     100           0 : }
     101             : 
     102             : int AliHLTTRDEsdWriterComponent::CloseWriter()
     103             : {
     104             :   // see header file for class documentation
     105             : 
     106             :   //fTree->Print();
     107           0 :   fFile->cd();
     108           0 :   fTree->Write(fTree->GetName(),TObject::kOverwrite);
     109           0 :   fFile->Write();
     110           0 :   fFile->Close();
     111           0 :   fFrFile->cd();
     112           0 :   fFrTree->Write(fFrTree->GetName(),TObject::kOverwrite);
     113           0 :   fFrFile->Write();
     114           0 :   fFrFile->Close();
     115           0 :   delete fFile; fFile=0;
     116           0 :   delete fFrFile; fFrFile=0;
     117             :   //delete fTree;
     118           0 :   delete fTracksArray; fTracksArray=0;
     119             : 
     120           0 :   return AliHLTRootFileWriterComponent::CloseWriter();
     121             : }
     122             : 
     123             : int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
     124             :                                             const AliHLTComponentBlockData* /*blocks*/, 
     125             :                                             AliHLTComponentTriggerData& trigData )
     126             : {
     127           0 :   TClonesArray* TCAarray[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     128             :   Int_t usedEntries = 0;
     129             :   Int_t blockOrObject = 0;
     130             : 
     131           0 :   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTRDDefinitions::fgkTracksDataType); pBlock; pBlock=GetNextInputBlock()) 
     132             :     {
     133           0 :       TCAarray[0] = fTracksArray;
     134           0 :       AliHLTTRDUtils::ReadTracks(TCAarray[0], pBlock->fPtr, pBlock->fSize);
     135             :       usedEntries = 1;
     136             :       blockOrObject = -1;
     137             :     }
     138             : 
     139           0 :   for(const TObject *iter = GetFirstInputObject(AliHLTTRDDefinitions::fgkHiLvlTracksDataType); iter; iter = GetNextInputObject()) 
     140             :     {
     141           0 :       if(blockOrObject<0){
     142           0 :         HLTError("You may not mix high level and low level!");
     143           0 :         return -1;
     144             :       }
     145             : 
     146           0 :       TCAarray[usedEntries] = dynamic_cast<TClonesArray*>(const_cast<TObject*>(iter));
     147           0 :       if(!TCAarray[usedEntries])continue;
     148           0 :       usedEntries++;
     149             :       blockOrObject = 1;
     150           0 :     }
     151             : 
     152           0 :   if(!blockOrObject)
     153           0 :     return 0;
     154             : 
     155           0 :   fESD->Reset(); 
     156           0 :   fESD->SetMagneticField(GetBz());
     157           0 :   fESD->SetRunNumber(GetRunNo());
     158           0 :   fESD->SetPeriodNumber(GetPeriodNumber());
     159           0 :   fESD->SetOrbitNumber(GetOrbitNumber());
     160           0 :   fESD->SetBunchCrossNumber(GetBunchCrossNumber());
     161           0 :   fESD->SetTimeStamp(GetTimeStamp());
     162           0 :   fESD->SetEventType(7);
     163             : 
     164           0 :   const AliHLTCTPData* pCTPData=CTPData();
     165           0 :   if (pCTPData) {
     166           0 :     AliHLTTriggerMask_t mask=pCTPData->ActiveTriggers(trigData);
     167           0 :     for (int index=0; index<gkNCTPTriggerClasses; index++) {
     168           0 :       if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
     169           0 :       fESD->SetTriggerClass(pCTPData->Name(index), index);
     170           0 :     }
     171             :     //first 50 triggers
     172           0 :     AliHLTTriggerMask_t mask50;
     173           0 :     mask50.set(); // set all bits
     174           0 :     mask50 >>= 50; // shift 50 right
     175           0 :     fESD->SetTriggerMask((mask&mask50).to_ulong());
     176             :     /* next 50, to be implemented 
     177             :     pESD->SetTriggerMaskNext50((mask>>50).to_ulong());
     178             :     */
     179           0 :   }
     180             :   
     181           0 :   for(int i=0; i<usedEntries; i++){
     182           0 :     const TClonesArray* inArr = TCAarray[i];
     183           0 :     for(int ii=0; ii<inArr->GetEntriesFast(); ii++){
     184           0 :       AliTRDtrackV1* inV1 = (AliTRDtrackV1*)inArr->UncheckedAt(ii);
     185           0 :       AliESDtrack *esdTrack = new AliESDtrack();
     186           0 :       esdTrack->UpdateTrackParams(inV1, AliESDtrack::kTRDout);
     187           0 :       esdTrack->SetLabel(inV1->GetLabel());
     188           0 :       inV1->UpdateESDtrack(esdTrack);
     189           0 :       AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*inV1);
     190           0 :       calibTrack->SetOwner();
     191           0 :       esdTrack->AddCalibObject(calibTrack);
     192           0 :       fESD->AddTrack(esdTrack);
     193           0 :       delete esdTrack;
     194             :     }
     195             :   }
     196             :   
     197           0 :   fESD->GetESDfriend(fESDfriend);
     198           0 :   Int_t nb = fTree->Fill();
     199           0 :   HLTInfo("Tree filled with %i bytes\n", nb);  
     200           0 :   nb = fFrTree->Fill();
     201           0 :   HLTInfo("FrTree filled with %i bytes\n", nb);
     202           0 :   fESD->Reset();
     203           0 :   fESDfriend->~AliESDfriend();
     204           0 :   new (fESDfriend) AliESDfriend();
     205             : 
     206           0 :   if(blockOrObject<0){
     207           0 :     TCAarray[0]->Delete();
     208           0 :   }
     209             : 
     210             :   return 0;
     211           0 : }

Generated by: LCOV version 1.11