/Users/jacquem/NetBeansProjects/MicromegasFramework/trunk/src/analyse/EventDisplayer.C File Reference

#include <TROOT.h>
#include <TRint.h>
#include <TCanvas.h>
#include <TTree.h>
#include <TFile.h>
#include <TSystem.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include <iostream>
#include <TreeClass.hh>
#include <sstream>
#include "Log.hh"
#include "Run.hh"
#include "Chamber.hh"
#include "Event.hh"
#include "Detector.hh"
#include "Centaure.hh"
#include "DiracLabview.hh"
#include "DiracChamber1.hh"
#include "GassiplexChamber1.hh"
#include "GassiplexChamber4.hh"
#include "HardRockChamber6.hh"
#include "XMLTool.hh"
#include "MicroException.hh"
#include <TApplication.h>
#include <TGClient.h>
#include <TGListBox.h>
#include <TList.h>

Include dependency graph for EventDisplayer.C:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file EventDisplayer.C.

00042 {  //un-named script to be run in ROOT framework
00043 
00044   FILELog::ReportingLevel() = FILELog::FromString(INFO);
00045 
00046   //----- Control usage and option
00047   if ( argc != 4  ) {
00048    FILE_LOG(logERROR)  << "usage: EventDisplay streeFile rootFile eventNumber" << endl;
00049    exit(1);
00050   }
00051 
00052 
00053 
00054   string steerName;
00055   steerName.assign(argv[1]);
00056 
00057   string rootName;
00058   rootName.assign(argv[2]);
00059 
00060   int event = atoi(argv[3]);
00061 
00062   TApplication *theApp;
00063 
00064   argc = 1;
00065   theApp = new TRint("App", &argc, argv);
00066 
00067 
00068   /******************************************/
00069   /******************************************/
00070   /******************************************/
00071   /******************************************/
00072   /******************************************/
00073   /******************************************/
00074 
00075 // test if sterr file exist
00076   FILE *file = fopen(steerName.c_str(), "r");
00077   if(file == NULL){
00078     FILE_LOG(logERROR)  << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00079     exit(0);
00080     fclose(file);
00081   }
00082 // create Run, set detector and steerDesc from steer XML file
00083     SteerDesc steerDesc;
00084     XMLTool xml;
00085     xml.parse(steerDesc, steerName);
00086     Detector detector;
00087 
00088     Run run(detector);
00089     if  ( !steerDesc.setRun(run))
00090     {
00091         exit(-1);
00092     }
00093     fclose(file);
00094 
00095     FILE_LOG(logINFO) << run << endl;
00096 
00097 
00098 
00099   /******************************************/
00100   /******************************************/
00101   /******************************************/
00102   /******************************************/
00103   /******************************************/
00104   /******************************************/
00105 
00106 
00107 
00108   gSystem->Load("libMicro.so");
00109   TFile *f = new TFile(rootName.c_str());
00110   if ( f->IsZombie()) {
00111     FILE_LOG(logERROR) << "Root file ["<< rootName.c_str() << "] does not exist" << endl;
00112     exit(-1);
00113   }
00114   TTree *tree = (TTree *) gROOT->FindObject("t1");
00115 
00116 
00117 gSystem->Load("libGeom");
00118 TGeoManager *frame =new TGeoManager("Frame","mM event displayer");
00119 
00120 TGeoMaterial *mat = new TGeoMaterial("SomeMaterial",1,1,1);
00121 TGeoMedium *med = new TGeoMedium("SomeMedium",1,mat);
00122 
00123 //TGeoVolume *world = frame->MakeBox("World", med, xLength, yLength, zLength); // x, y , z size unit cm
00124 
00125 // -----  create World volume who contains all other.
00126 TGeoVolume *world = frame->MakeBox("World", med, 1, 1, 1); // x, y , z size unit cm
00127 
00128 FILE_LOG(logINFO) << "Number of reoncstruct events: " << tree->GetEntries() << endl;
00129 MTEvent *evt = new MTEvent();
00130 TBranch *branch= tree->GetBranch("MTEvent");
00131 branch->SetAddress(&evt);
00132 
00133 tree->GetEntry(event);
00134 
00135 Int_t NC=evt->GetNchannel();
00136 frame->SetMaxVisNodes(NC);
00137 
00138   float x,y,z;
00139   for(int i=0;i<NC;i++)
00140   {
00141       int nodes = world->CountNodes();
00142 
00143       if ( world->CountNodes() < 1000 )
00144       {
00145          //the only known way to get the information from the channels number i
00146          MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(i);
00147 
00148          float xLength = .098 * 4; //cm
00149          float yLength = .098 * 4; // cm
00150          float zLength = .12; // cm
00151 
00152          // ChannelPad name
00153          string padID="";
00154          stringstream currentpad;// (stringstream::in | stringstream::out);
00155          currentpad<<i;
00156          padID="pad_"+currentpad.str();
00157 
00158          TGeoVolume *pad = frame->MakeBox(padID.c_str(),med,xLength,yLength,zLength );
00159          z=channel->GetZ();
00160          x=channel->GetX();//+xOffset;
00161          y=channel->GetY();//+yOffset;
00162          //set now the color of the pad
00163          int color;
00164          int sMax = 30;//set to limit of saturation
00165          stringstream ch;
00166          ch<<i;
00167          //string command="fChannels.fValue["+ch.str()+"]";
00168 
00169          color = channel->GetValue();
00170          color=60+40.*min(1.,(1.*color-20)/sMax);
00171         //world->AddNode(pad,1,new TGeoTranslation(z,x,y));
00172         world->AddNode(pad,1,new TGeoTranslation(x,y,z));
00173         pad->SetLineColor(color);
00174       }
00175       else
00176       {
00177           FILE_LOG(logERROR) << "Too Mnay Nodes !" << endl;
00178 
00179       }
00180 
00181   }
00182   frame->SetTopVolume(world);
00183   frame->CloseGeometry();
00184 
00185   world->Draw();
00186 
00187  theApp->Run();
00188  delete theApp;
00189    // run ROOT application
00190 
00191    return 0;
00192 }


Generated on Thu Jul 9 09:49:38 2009 for MicromegasFramework by  doxygen 1.5.8