mEmcApplyQAToSimu.C

Go to the documentation of this file.
00001 #include "mEmcApplyQAToSimu.h"
00002 
00003 #include "emcBadModules.h"
00004 #include "emcTowerContainer.h"
00005 #include "emcTowerContent.h"
00006 #include "emcNodeHelper.h"
00007 #include "EmcIndexer.h"
00008 
00009 #include <iostream>
00010 #include <cassert>
00011 
00012 using namespace std;
00013 
00014 //_____________________________________________________________________________
00015 mEmcApplyQAToSimu::mEmcApplyQAToSimu()
00016 {
00017   name = "mEmcApplyQAToSimu";
00018 }
00019 
00020 //_____________________________________________________________________________
00021 mEmcApplyQAToSimu::~mEmcApplyQAToSimu()
00022 {
00023 }
00024 
00025 //_____________________________________________________________________________
00026 PHBoolean
00027 mEmcApplyQAToSimu::event(PHCompositeNode* topNode)
00028 {
00029   PHCompositeNode* emcNode = emcNodeHelper::findCompositeNode(topNode,"EMC");
00030 
00031   if ( !emcNode ) 
00032     {
00033       cerr << __FILE__ << ":" << __LINE__ 
00034            << " Cannot get node EMC !"
00035            << endl;
00036       return false;
00037     }
00038 
00039   emcBadModules* bad = 
00040     emcNodeHelper::getObject<emcBadModules>("emcBadModules",emcNode);
00041 
00042   if ( !bad ) 
00043     {
00044       cerr << __FILE__ << ":" << __LINE__ 
00045            << " Cannot get emcBadModules object !"
00046            << endl;
00047       return false;
00048     }
00049 
00050   PHCompositeNode* dstNode = emcNodeHelper::findCompositeNode(topNode,"DST");
00051 
00052   if ( !dstNode ) 
00053     {
00054       cerr << __FILE__ << ":" << __LINE__ 
00055            << " Cannot get node DST !"
00056            << endl;
00057       return false;
00058     }
00059 
00060   emcTowerContainer* towers = 
00061     emcNodeHelper::getObject<emcTowerContainer>("emcTowerContainer",dstNode);
00062 
00063   if ( !towers ) 
00064    {
00065       cerr << __FILE__ << ":" << __LINE__ 
00066            << " Cannot get emcTowerContainer object !"
00067            << endl;
00068       return false;
00069     }
00070 
00071   size_t dead_count = 0;
00072 
00073   for ( size_t j = 0; j < towers->size(); ++j )
00074     {
00075       emcTowerContent* t_j = towers->getTower(j);
00076       assert(t_j!=0);
00077 
00078       // FIXME : test that t_j isSimulated == true.
00079 
00080       unsigned int dead = bad->Deadmap(t_j->TowerID());
00081 
00082       if (dead & 0x400) 
00083         {
00084           // set ecal and tof to zero 
00085           // In the case of real data (in MDO -> RDO):
00086           // a) in compressed mode: the tower is simply dropped 
00087           // b) in non-compressed mode: ADC and TDC are set to zero
00088           // We adopt b) here.  When merging with a real event,
00089           // the tower will be there (i.e. observable by the evaluator) but empty
00090           t_j->SetCalibrated(0.0,0.0);
00091           dead_count++;
00092         }
00093       t_j->SetNeighbours(dead,0);
00094     }
00095   
00096   if (dead_count) 
00097     {
00098       cout << " Total num. of EMCal dead channels: " << dead_count << endl ;
00099     }
00100   return true;
00101 }