/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/root/CaloEvent.cpp

Go to the documentation of this file.
00001 /* @version $Revision: 1352 $ * @modifiedby $Author: girardd $ * @lastmodified $Date: 2011-11-03 14:26:26 +0100 (Thu, 03 Nov 2011) $ */
00002 #include "root/CaloEvent.hh"
00003 #include "root/CaloHit.hh"
00004 #include "root/MTEvent.hh"
00005 #include "root/MTChannel.hh"
00006 #include <iostream>
00007 
00008 using namespace std;
00009 
00010 /*------------------------------------------------------------------------------
00011  *
00012  *    CaloEvent implementation
00013  */
00014 //______________________________________________________________________________
00015 ClassImp(CaloEvent)
00016 
00017  TClonesArray *CaloEvent::fgHits = 0;
00018 
00019 
00020 CaloEvent::CaloEvent() :
00021 fEventId(0)
00022 {
00023    // Create an CaloEvent object.
00024    // When the constructor is invoked for the first time, the class static
00025    // variable fgHits is 0 and the TClonesArray fgHits is created.
00026 
00027     if (!fgHits) {
00028         fgHits = new TClonesArray("CaloHit", 1000);
00029     }
00030     fHits = fgHits;
00031     fNHits = 0;
00032     fDeltaTmax = 0;
00033 
00034 }
00035 
00036 //______________________________________________________________________________
00037 CaloEvent::~CaloEvent()
00038 {
00039   this->Clear();
00040 }
00041 
00042 
00043 //______________________________________________________________________________
00044 CaloEvent& CaloEvent::operator=( const  MTEvent& rhs) 
00045 {
00046   // Set filtered event id to current input event ID
00047       this->fEventId = rhs.GetEventId();
00048       CaloHit hit; 
00049 
00050       // Loop over MTEvent channelHit
00051       int nbChannel = rhs.GetNchannel();
00052       for(int i=0;i<nbChannel  ;i++)
00053       {
00054         MTChannel *channel = (MTChannel*)rhs.GetChannels()->UncheckedAt(i);
00055 
00056         hit.SetX(channel->GetX());
00057         hit.SetY(channel->GetY());
00058         hit.SetZ(channel->GetZ());
00059 
00060         this->AddHit(hit);
00061       }
00062 
00063   return *this;
00064 
00065 }
00066 
00067 //______________________________________________________________________________
00068 void CaloEvent::Clear(Option_t * )
00069 {
00070   fHits->Clear("C"); //will also call Channel::Clear
00071   fNHits = 0;
00072 
00073 }
00074 
00075 //______________________________________________________________________________
00076 CaloHit* CaloEvent::AddHit(const CaloHit& aHit) {
00077 
00078 
00079    TClonesArray &hits = *fHits;
00080    CaloHit *hit = new(hits[fNHits++]) CaloHit(aHit);
00081 
00082 return hit;
00083 
00084 }

Generated on Mon Jan 7 13:15:22 2013 for MicromegasFramework by  doxygen 1.4.7