/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/lcio/MLcio.cpp

Go to the documentation of this file.
00001 /* @version $Revision: 1328 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2011-10-03 17:04:17 +0200 (Mon, 03 Oct 2011) $ */
00002 
00003 #include "geometry/Detector.hh"
00004 #include "geometry/Chamber.hh"
00005 #include "geometry/Dif.hh"
00006 #include "geometry/Chip.hh"
00007 #include "geometry/Board.hh"
00008 
00009 #include "event/Run.hh"
00010 
00011 #include "tools/MicroException.hh"
00012 #include "tools/Log.hh"
00013 /*
00014 #include "ChannelHit.hh"
00015 #include "Channel.hh"
00016 
00017 #include "SlowControlEntry.hh"
00018 #include "ChamberSlowControl.hh"
00019 
00020 
00021 #include "UTIL/LCTime.h"
00022 #include "IMPL/LCFlagImpl.h"
00023 #include "IMPL/LCCollectionVec.h"
00024 #include "IMPL/RawCalorimeterHitImpl.h"
00025 #include "IMPL/CalorimeterHitImpl.h"
00026 #include "IMPL/LCTOOLS.h"
00027 
00028 #include <string>
00029 
00030 #include "IO/LCWriter.h"
00031 #include "EVENT/LCIO.h"
00032 #include "DATA/LCFloatVec.h"
00033 #include "DATA/LCIntVec.h"
00034 
00035 
00036 #include "IMPL/TrackerRawDataImpl.h"
00037 #include "IMPL/TrackerDataImpl.h"
00038 #include "IMPL/TrackerPulseImpl.h"
00039 
00040 #include "UTIL/LCRelationNavigator.h"
00041 #include "UTIL/LCTime.h"
00042 #include "UTIL/CellIDEncoder.h"
00043 #include "UTIL/LCTypedVector.h"
00044 
00045 #include "UTIL/LCSplitWriter.h"
00046 
00047 static const int NEVENT = 10 ; // events
00048 static const int NMCPART = 10 ;  // mc particles per event
00049 static const int NHITS = 5 ;  // calorimeter hits per event
00050 
00051 #include "IMPL/LCTOOLS.h"
00052 */
00053 
00054 #include "lcio.h"
00055 #include "IMPL/LCRunHeaderImpl.h"
00056 #include "IMPL/LCEventImpl.h"
00057 #include "IMPL/LCCollectionVec.h"
00058 #include "IMPL/RawCalorimeterHitImpl.h"
00059 #include "IMPL/LCFlagImpl.h"
00060 
00061 #include "UTIL/CellIDEncoder.h"
00062 
00063 #include "lcio/MLcio.hh"
00064 #include "event/Event.hh"
00065 
00066 
00067 using namespace std;
00068 using namespace lcio ;
00069 
00070 /*------------------------------------------------------------------------------------*/
00071 void MLcio::setLCEventImp(LCEventImpl& evt, Event& evtRef)
00072 {
00073 try {
00074 
00075         evt.setRunNumber(  1   ) ;
00076     evt.setDetectorName( "m2" ) ;
00077     evt.setWeight( 1 ) ;
00078 
00079 
00080     evt.setEventNumber( evtRef.getId() ) ;
00081     // Event timestamp express in millisecond
00082         // But lcio timestamp express in second
00083     evt.setTimeStamp( evtRef.getTimeStamp() * 1000000  ) ;
00084 
00085 
00086     evt.parameters().setValue("Dif_syncro",evtRef.getDifSynchro() ) ;
00087     evt.parameters().setValue("Temperature",evtRef.getTemperature() ) ;
00088     evt.parameters().setValue("Pressure",evtRef.getPressure()) ;
00089     evt.parameters().setValue("Global trigger counter",(int)evtRef.getGlobalTriggerCounter() ) ;
00090     evt.parameters().setValue("Dif trigger counter",(int)evtRef.getDifTriggerCounter() ) ;
00091     //evt.parameters().setValue("SetDriftVoltage",evtRef.difTriggerCounter ) ;
00092     //evt.parameters().setValue("SetMeshVoltage",evtRef.difTriggerCounter ) ;
00093 
00094 
00095 
00096     // now add some raw calorimeter hits
00097     LCCollectionVec* calVec = new LCCollectionVec( LCIO::RAWCALORIMETERHIT )  ;
00098 
00099     LCFlagImpl chFlag(0) ;
00100     //chFlag.setBit( LCIO::CHBIT_ID1 ) ;
00101 
00102     chFlag.setBit( LCIO::RCHBIT_LONG )   ;  // long(1) - short(0) , incl./excl. position
00103     chFlag.setBit( LCIO::RCHBIT_BARREL ) ;  // barrel(1) - endcap(0)
00104     //chFlag.setBit( LCIO::RCHBIT_TIME   ) ; // 1: time information stored
00105     //chFlag.setBit( LCIO::RCHBIT_ID1   )  ;  // cellid1 stored
00106     //chFlag.setBit( LCIO::RCHBIT_NO_PTR ) ; // 1: pointer tag not added
00107     //chFlag.setBit( LCIO::RCHBIT_ENERGY_ERROR )  ;   // 1: store energy error
00108     calVec->setFlag( chFlag.getFlag()) ;
00109 
00110 
00111 //
00112 //OFFSET_CHAMBER *NB_CHANNEL* GetChamberId()
00113 //+ OFFSET_DIF *NB_CHANNEL*  GetDifId()
00114 //+ OFFSET_CHIP*NB_CHANNEL * GetChipId ()
00115 //+  channelId 
00116 //
00117         // Chambre 1024 -> 2 exp 10
00118         // Dif     128  -> 2 exp 7
00119         // Chip    1024 -> 2 exp 10
00120         // Channel 1024 -> 2 exp 10
00121     std::string cellIDEncoding( "CHAMBER:10,DIF:7,CHIP:10,CHANNEL:10") ;
00122     CellIDEncoder<RawCalorimeterHitImpl> cellEncoder( cellIDEncoding , calVec ) ;
00123 
00124 
00125     ChamberMap_t chamberList = evtRef.getRun().getDetector().getChambers();
00126     for (ChamberMap_t::iterator iter=chamberList.begin(); iter!=chamberList.end(); iter++)
00127     {
00128       Chamber& chamber = *(iter->second);
00129       try
00130       {
00131           const  multiset<ChannelHit*,sorter>& list = evtRef.getChannelHitVector(chamber);
00132           int order = 0 ;
00133           for (set<ChannelHit*,sorter>::iterator iter=list.begin(); iter!=list.end(); iter++)
00134           {
00135             ChannelHit& channelHit = *(*iter);
00136             const Channel& channel = channelHit.getChannel();
00137                 RawCalorimeterHitImpl* rawHit = NULL ;
00138             try
00139             {
00140                           // Create RawCalorimeterHit
00141                   rawHit = new RawCalorimeterHitImpl() ;
00142 
00143               if ( chamber.getType().compare(GASSIPLEXCHAMBER1)==0 ||  chamber.getType().compare(GASSIPLEXCHAMBER4)==0)
00144               {
00145                     channelHit.setTimestamp(evtRef.getTimeStamp());
00146                           }
00147                         
00148                         
00149                   cellEncoder["CHAMBER"] = channel.getChamber().getId(); 
00150                   cellEncoder["DIF"] = channel.getChip().getBoard().getDif()->getId(); 
00151                   cellEncoder["CHIP"] = channel.getChip().getId(); 
00152                   cellEncoder["CHANNEL"] = channel.getHardId(); 
00153                           cellEncoder.setCellID( rawHit ) ;
00154                         
00155                   rawHit->setAmplitude( channelHit.getDigitalValue()   )  ;
00156                   //rawHit->setTimeStamp( channelHit.getTimestamp() / 1000) ; 
00157 
00158               order++;  // because aEvent have already been  sorted
00159                   calVec->push_back( rawHit ) ;
00160             } // end try block
00161             catch (MicroException e)
00162             {
00163             }
00164 
00165           } // end for channelHits for this chamber
00166       }
00167       catch (MicroException e)
00168       {
00169                 // get ChamberHitVector for next chamber
00170       }
00171 
00172     }
00173     //LCTOOLS::printRawCalorimeterHits(calVec);
00174     // add all collections to the event
00175 
00176     evt.addCollection( calVec , "m2" ) ;
00177 
00178 
00179   }
00180   catch( Exception& ex){
00181 
00182     cout << " an excpetion occured: " << endl ;
00183     cout << "  " << ex.what() << endl ;
00184   }
00185 
00186 
00187 
00188 }

Generated on Mon Jun 11 16:55:46 2012 for MicromegasFramework by  doxygen 1.4.7